[Mlir-commits] [mlir] 1fd280d - [MLIR][Affine] Add missing check in affine data copy nest generation (#127809)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Feb 19 19:56:15 PST 2025
Author: Uday Bondhugula
Date: 2025-02-20T09:26:11+05:30
New Revision: 1fd280d0f2a31a41e74374c7757a8a4d01e116b5
URL: https://github.com/llvm/llvm-project/commit/1fd280d0f2a31a41e74374c7757a8a4d01e116b5
DIFF: https://github.com/llvm/llvm-project/commit/1fd280d0f2a31a41e74374c7757a8a4d01e116b5.diff
LOG: [MLIR][Affine] Add missing check in affine data copy nest generation (#127809)
Handle case where no lower or upper bound could be found for a
dimension. Invalid IR was being generated silently for a test case.
Fixes: https://github.com/llvm/llvm-project/issues/127808
Added:
Modified:
mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
mlir/test/Dialect/Affine/affine-data-copy.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp b/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
index 4e02559a08949..82b96e9876a6f 100644
--- a/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
+++ b/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
@@ -2001,8 +2001,15 @@ static LogicalResult generateCopy(
}
SmallVector<AffineMap, 4> lbMaps(rank), ubMaps(rank);
- for (unsigned i = 0; i < rank; ++i)
+ for (unsigned i = 0; i < rank; ++i) {
region.getLowerAndUpperBound(i, lbMaps[i], ubMaps[i]);
+ if (lbMaps[i].getNumResults() == 0 || ubMaps[i].getNumResults() == 0) {
+ LLVM_DEBUG(llvm::dbgs()
+ << "Missing lower or upper bound for region along dimension: "
+ << i << '\n');
+ return failure();
+ }
+ }
const FlatAffineValueConstraints *cst = region.getConstraints();
// 'regionSymbols' hold values that this memory region is symbolic/parametric
diff --git a/mlir/test/Dialect/Affine/affine-data-copy.mlir b/mlir/test/Dialect/Affine/affine-data-copy.mlir
index 330cf92bafba4..5615acae5ecc4 100644
--- a/mlir/test/Dialect/Affine/affine-data-copy.mlir
+++ b/mlir/test/Dialect/Affine/affine-data-copy.mlir
@@ -300,14 +300,15 @@ func.func @affine_parallel(%85:memref<2x5x4x2xi64>) {
}
}
}
- // CHECK: affine.for
- // CHECK-NEXT: affine.for %{{.*}} = 0 to 5
- // CHECK-NEXT: affine.for %{{.*}} = 0 to 4
- // CHECK-NEXT: affine.for %{{.*}} = 0 to 2
-
+ // Lower and upper bounds for the region can't be determined for the outermost
+ // dimension. No fast buffer generation.
// CHECK: affine.for
// CHECK-NEXT: affine.parallel
// CHECK-NEXT: affine.parallel
+ // CHECK-NEXT: affine.for
+ // CHECK-NOT: affine.for
+
+
return
}
More information about the Mlir-commits
mailing list