2020-07-07 07:28:26 +08:00
|
|
|
// RUN: mlir-hlo-opt %s -split-input-file -pass-pipeline='func(canonicalize)' | FileCheck %s
|
|
|
|
|
|
|
|
// CHECK-LABEL: func @remove_noop
|
|
|
|
// CHECK-SAME: [[ARG:%[a-zA-Z0-9]+]]
|
|
|
|
func @remove_noop(%arg : tensor<2x3x9x5xi32>) -> tensor<2x3x9x5xi32> {
|
2020-07-07 12:51:24 +08:00
|
|
|
%0 = "mhlo.transpose"(%arg) {permutation = dense<[0, 1, 2, 3]> : tensor<4xi64>}: (tensor<2x3x9x5xi32>) -> tensor<2x3x9x5xi32>
|
2020-07-07 07:28:26 +08:00
|
|
|
// CHECK-NEXT: return [[ARG]]
|
|
|
|
return %0 : tensor<2x3x9x5xi32>
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
// CHECK-LABEL: func @keep_real_transpose
|
|
|
|
// CHECK-SAME: [[ARG:%[a-zA-Z0-9]+]]
|
|
|
|
func @keep_real_transpose(%arg : tensor<2x3x9x5xi32>) -> tensor<3x2x5x9xi32> {
|
2020-07-07 12:51:24 +08:00
|
|
|
// CHECK-NEXT: "mhlo.transpose"([[ARG]])
|
|
|
|
%0 = "mhlo.transpose"(%arg) {permutation = dense<[1, 0, 3, 2]> : tensor<4xi64>}: (tensor<2x3x9x5xi32>) -> tensor<3x2x5x9xi32>
|
2020-07-07 07:28:26 +08:00
|
|
|
return %0 : tensor<3x2x5x9xi32>
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
// CHECK-LABEL: func @keep_same_shape_real_transpose
|
|
|
|
// CHECK-SAME: [[ARG:%[a-zA-Z0-9]+]]
|
|
|
|
func @keep_same_shape_real_transpose(%arg : tensor<4x4xi32>) -> tensor<4x4xi32> {
|
2020-07-07 12:51:24 +08:00
|
|
|
// CHECK-NEXT: "mhlo.transpose"([[ARG]])
|
|
|
|
%0 = "mhlo.transpose"(%arg) {permutation = dense<[1, 0]> : tensor<2xi64>}: (tensor<4x4xi32>) -> tensor<4x4xi32>
|
2020-07-07 07:28:26 +08:00
|
|
|
return %0 : tensor<4x4xi32>
|
|
|
|
}
|