[Mlir-commits] [mlir] [mlir][tensor] Guard constant reshape folding (PR #179077)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Feb 4 09:49:27 PST 2026
================
@@ -2041,6 +2041,16 @@ static LogicalResult verifyTensorReshapeOp(TensorReshapeOp op,
verifyReshapeLikeTypes(op, expandedType, collapsedType, isExpansion)))
return failure();
+ // Reshape must preserve the number of elements when statically known.
+ int64_t expandedNumElements = expandedType.getNumElements();
----------------
MaheshRavishankar wrote:
This is the right approach, but looked at `getNumElements` method for `ShapedType` and that asserts if the shape is not static. I think you need to check that the shape is static, and then check the number of elements.
https://github.com/llvm/llvm-project/pull/179077
More information about the Mlir-commits
mailing list