[Mlir-commits] [mlir] [mlir][vector] Additional transpose folding (PR #138347)
James Newling
llvmlistbot at llvm.org
Mon May 12 10:51:33 PDT 2025
================
@@ -65,13 +65,15 @@ func.func @transpose102_8x1x8xf32(%arg0: vector<8x1x8xf32>) -> vector<1x8x8xf32>
return %0 : vector<1x8x8xf32>
}
-// CHECK-LABEL: func @transpose1023_1x1x8x8xf32(
-func.func @transpose1023_1x1x8x8xf32(%arg0: vector<1x1x8x8xf32>) -> vector<1x1x8x8xf32> {
- // Note the single 2-D extract/insert pair since 2 and 3 are not transposed!
- // CHECK: vector.extract {{.*}}[0, 0] : vector<8x8xf32> from vector<1x1x8x8xf32>
- // CHECK-NEXT: vector.insert {{.*}} [0, 0] : vector<8x8xf32> into vector<1x1x8x8xf32>
- %0 = vector.transpose %arg0, [1, 0, 2, 3] : vector<1x1x8x8xf32> to vector<1x1x8x8xf32>
- return %0 : vector<1x1x8x8xf32>
+// CHECK-LABEL: func @transpose1023_2x1x8x4xf32(
+func.func @transpose1023_2x1x8x4xf32(%arg0: vector<2x1x8x4xf32>) -> vector<1x2x8x4xf32> {
+ // Note the 2-D extract/insert pair since dimensions 2 and 3 are not transposed!
+ // CHECK: vector.extract {{.*}}[0, 0] : vector<8x4xf32> from vector<2x1x8x4xf32>
+ // CHECK-NEXT: vector.insert {{.*}} [0, 0] : vector<8x4xf32> into vector<1x2x8x4xf32>
+ // CHECK-NEXT: vector.extract {{.*}}[1, 0] : vector<8x4xf32> from vector<2x1x8x4xf32>
+ // CHECK-NEXT: vector.insert {{.*}} [0, 1] : vector<8x4xf32> into vector<1x2x8x4xf32>
----------------
newling wrote:
I've changed the type of the (result) vector from <1x1x..> to <1x2x..>
Why? Because now the <1x1x...> case gets folded, so we end up with `return %arg0`. Based on the original comment in the test
> "Note the single 2-D extract/insert pair since 2 and 3 are not transposed!"
I assume changing the sizes of dims 0/1 retains the original goal of the test.
https://github.com/llvm/llvm-project/pull/138347
More information about the Mlir-commits
mailing list