brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · d29cb54 Raw
53 lines · plain
1// RUN: mlir-opt %s --canonicalize -split-input-file | FileCheck %s2 3// CHECK-LABEL:   func.func @test_cancel_transpose_transpose(4// CHECK-SAME:                                               %[[VAL_0:.*]]: tensor<1x2x3xi32>) -> tensor<1x2x3xi32> {5// CHECK:           return %[[VAL_0]] : tensor<1x2x3xi32>6// CHECK:         }7 8func.func @test_cancel_transpose_transpose(%arg0: tensor<1x2x3xi32>) -> (tensor<1x2x3xi32>) {9	%1 = tosa.transpose %arg0 { perms = array<i32: 1, 2, 0> }: (tensor<1x2x3xi32>) -> tensor<2x3x1xi32>10	%3 = tosa.transpose %1 { perms = array<i32: 2, 0, 1> }: (tensor<2x3x1xi32>) -> tensor<1x2x3xi32>11  return %3 : tensor<1x2x3xi32>12}13 14// -----15 16// CHECK-LABEL:   func.func @test_remove_identity_transpose(17// CHECK-SAME:                                              %[[VAL_0:.*]]: tensor<1x2x3xi32>) -> tensor<1x2x3xi32> {18// CHECK:           return %[[VAL_0]] : tensor<1x2x3xi32>19// CHECK:         }20 21func.func @test_remove_identity_transpose(%arg0: tensor<1x2x3xi32>) -> (tensor<1x2x3xi32>) {22	%1 = tosa.transpose %arg0 { perms = array<i32: 0, 1, 2> }: (tensor<1x2x3xi32>) -> tensor<1x2x3xi32>23  return %1 : tensor<1x2x3xi32>24}25 26// -----27 28// CHECK-LABEL:   func.func @test_do_not_cancel_different_transpose(29// CHECK-SAME:                                                      %[[VAL_0:.*]]: tensor<2x3x4x5xi32>) -> tensor<5x4x3x2xi32> {30// CHECK:           %[[VAL_2:.*]] = tosa.transpose %[[VAL_0]] {perms = array<i32: 3, 2, 1, 0>} : (tensor<2x3x4x5xi32>) -> tensor<5x4x3x2xi32>31// CHECK:           return %[[VAL_2]] : tensor<5x4x3x2xi32>32// CHECK:         }33 34func.func @test_do_not_cancel_different_transpose(%arg0: tensor<2x3x4x5xi32>) -> (tensor<5x4x3x2xi32>) {35	%1 = tosa.transpose %arg0 { perms = array<i32: 1, 2, 0, 3> }: (tensor<2x3x4x5xi32>) -> tensor<3x4x2x5xi32>36	%3 = tosa.transpose %1 { perms = array<i32: 3, 1, 0, 2> }: (tensor<3x4x2x5xi32>) -> tensor<5x4x3x2xi32>37  return %3 : tensor<5x4x3x2xi32>38}39 40// -----41 42// CHECK-LABEL:   func.func @test_prefer_compose_transpose(43// CHECK-SAME:                                                      %[[VAL_0:.*]]: tensor<1x2x3x4xi32>) -> tensor<4x3x2x1xi32> {44// CHECK:           %[[VAL_2:.*]] = tosa.transpose %[[VAL_0]] {perms = array<i32: 3, 2, 1, 0>} : (tensor<1x2x3x4xi32>) -> tensor<4x3x2x1xi32>45// CHECK:           return %[[VAL_2]] : tensor<4x3x2x1xi32>46// CHECK:         }47 48func.func @test_prefer_compose_transpose(%arg0: tensor<1x2x3x4xi32>) -> (tensor<4x3x2x1xi32>) {49	%1 = tosa.transpose %arg0 { perms = array<i32: 1, 2, 0, 3> }: (tensor<1x2x3x4xi32>) -> tensor<2x3x1x4xi32>50	%3 = tosa.transpose %1 { perms = array<i32: 3, 1, 0, 2> }: (tensor<2x3x1x4xi32>) -> tensor<4x3x2x1xi32>51  return %3 : tensor<4x3x2x1xi32>52}53