[Mlir-commits] [mlir] [mlir] disable folding collapse expand to cast (PR #179209)
ofri frishman
llvmlistbot at llvm.org
Wed Feb 4 23:26:44 PST 2026
================
@@ -1385,6 +1385,21 @@ func.func @expand_collapse_do_not_fold_to_cast(%m: memref<1x3x2x384xui8, strided
// -----
+// CHECK-LABEL: func @expand_collapse_dynamic_do_not_fold_to_cast(
+// CHECK-NOT: memref.cast
+
+func.func @expand_collapse_dynamic_do_not_fold_to_cast(%m: memref<1x?x1x32xsi8, strided<[?, 32, 32, 1]>>, %dyn_size: index)
+ -> (memref<1x1x?x32xsi8, strided<[?, ?, 32, 1]>>)
+ {
+ %0 = memref.collapse_shape %m [[0], [1, 2], [3]]
+ : memref<1x?x1x32xsi8, strided<[?, 32, 32, 1]>> into memref<1x?x32xsi8, strided<[?, 32, 1]>>
+ %1 = memref.expand_shape %0 [[0, 1], [2], [3]] output_shape [1, 1, %dyn_size, 32]
----------------
ofri-frishman wrote:
>From what i see in the expand shape the reassociations based on shape are:
1 -> 1 x 1
? -> ?
32 -> 32
Which is valid as the dimensions match.
The last 2 reassociations groups you mentioned seem to match the values of the **stride** of the source but not the **shape** of the source.
Am I missing something here?
https://github.com/llvm/llvm-project/pull/179209
More information about the Mlir-commits
mailing list