[Mlir-commits] [mlir] [mlir][memref] Fix crash in DimOp::fold for subview with ambiguous dropped dims (PR #183995)
Matthias Springer
llvmlistbot at llvm.org
Wed Mar 4 04:34:12 PST 2026
================
@@ -1084,8 +1084,12 @@ OpFoldResult DimOp::fold(FoldAdaptor adaptor) {
}
resultIndex++;
}
- assert(subview.isDynamicSize(sourceIndex) &&
- "expected dynamic subview size");
+ // If the source dimension is not dynamic, getDroppedDims() may have
+ // computed an incorrect mapping (e.g., when strides are all dynamic and
+ // there are multiple unit-size candidate dimensions), so conservatively
+ // bail out.
+ if (!subview.isDynamicSize(sourceIndex))
+ return {};
return subview.getDynamicSize(sourceIndex);
----------------
matthias-springer wrote:
I think we can just return `subview.getMixedSizes()[sourceIndex]`, which should work for both dynamic and static dims.
https://github.com/llvm/llvm-project/pull/183995
More information about the Mlir-commits
mailing list