[Mlir-commits] [mlir] [mlir][tensor][memref] Enhance collapse(expand(src)) canonicalization pattern. (PR #145995)
Han-Chung Wang
llvmlistbot at llvm.org
Thu Jun 26 18:56:37 PDT 2025
================
@@ -466,6 +466,24 @@ func.func @compose_collapse_of_collapse(%arg0 : memref<?x?x?x?x?xf32>)
// -----
+func.func @compose_collapse_of_expand_partially_dynamic(%arg0: memref<?xf16>, %arg1: index, %arg2: index) -> memref<8x?x?xf16> {
+ %expanded = memref.expand_shape %arg0 [[0, 1, 2, 3, 4]] output_shape [4, 2, %arg1, %arg2, 32] : memref<?xf16> into memref<4x2x?x?x32xf16>
+ %collapsed = memref.collapse_shape %expanded [[0, 1], [2], [3, 4]] : memref<4x2x?x?x32xf16> into memref<8x?x?xf16>
+ return %collapsed : memref<8x?x?xf16>
+}
+// CHECK: func @compose_collapse_of_expand_partially_dynamic
+// CHECK-SAME: %[[SRC:.[a-zA-Z0-9]+]]
+// CHECK-SAME: %[[ORIG_D2:.[a-zA-Z0-9]+]]
+// CHECK-SAME: %[[ORIG_D3:.[a-zA-Z0-9]+]]
+// CHECK-DAG: %[[C32:.+]] = arith.constant 32
+// CHECK: %[[NEW_D2:.+]] = arith.muli %[[ORIG_D3]], %[[C32]]
----------------
hanhanW wrote:
It is D2 in the expand_shape op. Let me rename it to `EXPAND_D2`.
https://github.com/llvm/llvm-project/pull/145995
More information about the Mlir-commits
mailing list