[Mlir-commits] [mlir] [mlir][linalg] Add folder for `linalg.index` (PR #136640)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Tue Apr 22 05:57:36 PDT 2025
================
@@ -2283,6 +2283,19 @@ LogicalResult IndexOp::verify() {
return success();
}
+OpFoldResult IndexOp::fold(FoldAdaptor adaptor) {
+ auto linalgOp = cast<LinalgOp>((*this)->getParentOp());
+
+ // Index of unit dims is always 0.
+ SmallVector<int64_t, 4> loopBounds = linalgOp.getStaticLoopRanges();
+ uint64_t dim = getDim();
+ assert(dim < loopBounds.size());
----------------
banach-space wrote:
[nit] Add an error message.
https://github.com/llvm/llvm-project/pull/136640
More information about the Mlir-commits
mailing list