[Mlir-commits] [mlir] [mlir][tosa] Add verifier for `tosa.transpose` (PR #75376)
Kai Sasaki
llvmlistbot at llvm.org
Wed Dec 13 23:06:34 PST 2023
================
@@ -80,6 +80,49 @@ func.func @test_transpose_non_const(%arg0: tensor<13x21x3xf32>, %arg1: tensor<3x
// -----
+func.func @test_transpose_io_rank_mismatch(%arg0: tensor<13x21x3xf32>, %arg1: tensor<3xi32>) -> tensor<3x13x21x1xf32> {
+ // expected-error at +1 {{'tosa.transpose' op expected input tensor rank to equal result tensor rank}}
+ %0 = tosa.transpose %arg0, %arg1 : (tensor<13x21x3xf32>, tensor<3xi32>) -> tensor<3x13x21x1xf32>
+ return %0 : tensor<3x13x21x1xf32>
+}
+
+// -----
+
+func.func @test_transpose_invalid_perms_rank(%arg0: tensor<13x21x3xf32>, %arg1: tensor<3x2xi32>) -> tensor<3x13x21xf32> {
+ // expected-error at +1 {{'tosa.transpose' op expected permutation tensor to be rank 1 but got rank 2}}
+ %0 = tosa.transpose %arg0, %arg1 : (tensor<13x21x3xf32>, tensor<3x2xi32>) -> tensor<3x13x21xf32>
+ return %0 : tensor<3x13x21xf32>
+}
+
+// -----
+
+func.func @test_transpose_rank0_perms() {
+ %14 = tensor.empty() : tensor<5x27xi64>
+ %cst = tensor.empty() : tensor<i32>
+ // expected-error at +1 {{'tosa.transpose' op expected permutation tensor to be rank 1 but got rank 0}}
+ %72 = tosa.transpose %14, %cst : (tensor<5x27xi64>, tensor<i32>) -> tensor<?x?xi64>
+ return
+}
+
+// -----
+
+func.func @test_transpose_invalid_perms_size(%arg0: tensor<13x21x3xf32>, %arg1: tensor<7xi32>) -> tensor<3x13x21xf32> {
+ // expected-error at +1 {{'tosa.transpose' op expected permutation tensor dim 0 to have size 3 (input rank) but got size 7}}
+ %0 = tosa.transpose %arg0, %arg1 : (tensor<13x21x3xf32>, tensor<7xi32>) -> tensor<3x13x21xf32>
----------------
Lewuathe wrote:
The original case reported in https://github.com/llvm/llvm-project/issues/74479 seems to be covered by this case.
https://github.com/llvm/llvm-project/pull/75376
More information about the Mlir-commits
mailing list