[Mlir-commits] [mlir] [MLIR] computeSliceParameters: use full slice if affine exprs are non-monotonic (PR #118502)

Matthias Gehre llvmlistbot at llvm.org
Wed Dec 4 07:38:48 PST 2024


================
@@ -581,7 +581,11 @@ computeSliceParameters(OpBuilder &builder, Location loc, Value valueToTile,
   sliceParams.strides.reserve(rank);
   for (unsigned r = 0; r < rank; ++r) {
     LLVM_DEBUG(llvm::dbgs() << "computeSliceParameters: for dim#" << r);
-    if (!isTiled(map.getSubMap({r}), tileSizes)) {
+    auto m = map.getSubMap({r});
+    // The offset & size computation below only handles the case when
+    // the map is monotonically increasing, i.e. the min and max values are
+    // attained at the lower and upper bounds of the iteration domain.
+    if (!isTiled(m, tileSizes) || !m.isComponentWiseMonotonicallyIncreasing()) {
----------------
mgehre-amd wrote:

Yes, it will take the full slice of that dimension of the input tensor, but it will tile the other dimensions of the input tensor (if their expressions are monotonic).

We could also error out in this case, and require the user to instead use a tile size of `0` for each dim with non-monotonic expression.
This makes sense a lot of sense to me if there is just a single op being tiled.

If we tile & fuse through a whole chain of ops, and only the last one has non-monotonic maps, maybe it would be nicer to allow tiling to succeed even the last op in the chain has some dimensions un-tiled?




https://github.com/llvm/llvm-project/pull/118502


More information about the Mlir-commits mailing list