[Mlir-commits] [mlir] [mlir][linalg] Bail out tensor.cast pack/unpack fold on unprovable tile sizes (PR #188000)

Hocky Yudhiono llvmlistbot at llvm.org
Mon Mar 23 03:17:14 PDT 2026


================
@@ -5015,17 +5017,21 @@ getNewMixedTileSizes(PatternRewriter &rewriter, Type newPackedTy,
       continue;
     }
 
-    // If the current result dim is static, update the dynamic mixed-size
-    // (provided the original value is dynamic).
+    // If the current result dim is static, update the dynamic mixed-size only
+    // when the original dynamic value is a known constant matching `shape`.
+    // Otherwise, bail out and let the fold fail conservatively.
     OpFoldResult tile = std::get<1>(it);
     if (Attribute attr = llvm::dyn_cast_if_present<Attribute>(tile)) {
       // Already a constant
       newMixedTileSizes.push_back(tile);
     } else {
-      assert(getConstantIntValue(tile).value() == shape &&
-             "tile size and dim size don't match!");
-      newMixedTileSizes.push_back(
-          (rewriter.getIntegerAttr(rewriter.getIndexType(), shape)));
+      std::optional<int64_t> constTile = getConstantIntValue(tile);
----------------
hockyy wrote:

Fixed by directly using `getConstantIntValue`'s int value bf3f5b7ec1dbf729f477313763537ef014e78c6c

https://github.com/llvm/llvm-project/pull/188000


More information about the Mlir-commits mailing list