We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a8b2c96 commit 9bf7023Copy full SHA for 9bf7023
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
@@ -2284,7 +2284,12 @@ LogicalResult IndexOp::verify() {
2284
}
2285
2286
OpFoldResult IndexOp::fold(FoldAdaptor adaptor) {
2287
- auto linalgOp = cast<LinalgOp>((*this)->getParentOp());
+ auto linalgOp = dyn_cast_or_null<LinalgOp>((*this)->getParentOp());
2288
+ // Bail out if `linalg.index` does not have a proper parent yet at this
2289
+ // point, e.g., when calling `createOrFold` during IR construction in
2290
+ // `genericOp::build`.
2291
+ if (!linalgOp)
2292
+ return OpFoldResult{};
2293
2294
// Index of unit dims is always 0.
2295
SmallVector<int64_t, 4> loopBounds = linalgOp.getStaticLoopRanges();
0 commit comments