[Mlir-commits] [mlir] [mlir][linalg] Add folder for transpose(transpose) -> transpose (PR #93606)
donald chen
llvmlistbot at llvm.org
Wed May 29 05:42:36 PDT 2024
================
@@ -1051,3 +1051,40 @@ func.func @transpose_identity_perm(%input: tensor<16x32x64xf32>,
// CHECK-NOT: linalg.transpose
// CHECK: return %[[INPUT]] : tensor<16x32x64xf32>
+// -----
+
+func.func @transpose_transpose_cancel(%input: tensor<5x4x3xf32>,
+ %init1: tensor<4x3x5xf32>,
+ %init2: tensor<5x4x3xf32>) -> tensor<5x4x3xf32> {
+ // CHECK-LABEL: @transpose_transpose_cancel
+ // CHECK-NOT: linalg.transpose
+ %transpose1 = linalg.transpose
+ ins(%input:tensor<5x4x3xf32>)
+ outs(%init1:tensor<4x3x5xf32>)
+ permutation = [1, 2, 0]
+ %transpose2 = linalg.transpose
+ ins(%transpose1:tensor<4x3x5xf32>)
+ outs(%init2:tensor<5x4x3xf32>)
+ permutation = [2, 0, 1]
+ func.return %transpose2 : tensor<5x4x3xf32>
----------------
cxy-1993 wrote:
nit: Maybe we should check func.return use %input as result?
https://github.com/llvm/llvm-project/pull/93606
More information about the Mlir-commits
mailing list