[Mlir-commits] [mlir] [mlir] computeSliceParameters: Fix offset when m(0) != 0 (PR #122492)
Matthias Gehre
llvmlistbot at llvm.org
Mon Jan 13 00:53:30 PST 2025
================
@@ -596,8 +596,17 @@ computeSliceParameters(OpBuilder &builder, Location loc, Value valueToTile,
auto m = map.getSubMap({r});
LLVM_DEBUG(llvm::dbgs() << "computeSliceParameters: submap: " << m << "\n");
IRRewriter rewriter(builder);
- OpFoldResult offset = makeComposedFoldedAffineApply(rewriter, loc, m, lbs);
+ // The offset of the slice is map(lbs) - map(0).
+ SmallVector<Attribute> zeros(lbs.size(), rewriter.getIndexAttr(0));
+ SmallVector<Attribute> mAtZero;
+ auto res = m.constantFold(zeros, mAtZero);
+ assert(succeeded(res));
----------------
mgehre-amd wrote:
The `m.constantFold` is evaluating the affine map `m` with all inputs being zero.
The `constantFold` returns `failure()` when the affine map has symbols, but afaik linalg guarantees that the affine map has no symbols, the the evaluation of `m` into a constant is always possible. (Thus the assert; will add a message to it).
https://github.com/llvm/llvm-project/pull/122492
More information about the Mlir-commits
mailing list