[Mlir-commits] [mlir] [mlir][tensor] Add tests to invalid.mlir (PR #112759)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Fri Oct 18 00:56:57 PDT 2024
https://github.com/banach-space updated https://github.com/llvm/llvm-project/pull/112759
>From 4fc2c29a6fd120f15742d764c74cb6b859595a27 Mon Sep 17 00:00:00 2001
From: Andrzej Warzynski <andrzej.warzynski at arm.com>
Date: Thu, 17 Oct 2024 19:39:08 +0100
Subject: [PATCH 1/2] [mlir][tensor] Add tests to invalid.mlir
Adds two test with invalid usage of `tensor.extract_slice` that were
missing. Also moves one other test for `tensor.extract_slice`, so that
all tests for this Op are clustered together.
---
mlir/test/Dialect/Tensor/invalid.mlir | 37 +++++++++++++++++++++------
1 file changed, 29 insertions(+), 8 deletions(-)
diff --git a/mlir/test/Dialect/Tensor/invalid.mlir b/mlir/test/Dialect/Tensor/invalid.mlir
index 84e6c59e403dde..a33ef0ba563154 100644
--- a/mlir/test/Dialect/Tensor/invalid.mlir
+++ b/mlir/test/Dialect/Tensor/invalid.mlir
@@ -213,6 +213,27 @@ func.func @extract_slice_wrong_result_rank(%t: tensor<?xf32>, %idx : index) {
return
}
+
+// -----
+
+func.func @extract_slice_size_and_output_dim_mismatch_static_size(%t: tensor<16xf32>) {
+ // expected-error @+1 {{expected type to be 'tensor<4xf32>' or a rank-reduced version. (size mismatch)}}
+ %0 = tensor.extract_slice %t[0][4][1]
+ : tensor<16xf32> to tensor<6xf32>
+
+ return
+}
+
+// -----
+
+func.func @extract_slice_size_and_output_dim_mismatch_dynamic_size(%t: tensor<?xf32>, %idx : index) {
+ // expected-error @+2 {{expected type to be 'tensor<?xf32>' or a rank-reduced version. (size mismatch)}}
+ %c4 = arith.constant 4 : index
+ %0 = tensor.extract_slice %t[0][%c4][1] : tensor<?xf32> to tensor<4xi8>
+
+ return
+}
+
// -----
func.func @extract_slice_wrong_static_type(%t: tensor<8x16x4xf32>, %idx : index) {
@@ -235,6 +256,14 @@ func.func @extract_slice_wrong_dynamic_type(%t: tensor<8x16x4xf32>, %idx : index
// -----
+func.func @illegal_num_offsets(%arg0 : tensor<?x?x?xf32>, %arg1 : index, %arg2 : index) {
+ // expected-error at +1 {{expected 3 offset values}}
+ %0 = tensor.extract_slice %arg0[0, 0] [%arg1, %arg2] [1, 1] : tensor<?x?x?xf32> to tensor<?x?x?xf32>
+ return
+}
+
+// -----
+
func.func @insert_slice_wrong_result_rank(%t1: tensor<?xf32>, %t2: tensor<?x?xf32>, %idx : index) {
// expected-error @+1 {{expected rank to be smaller or equal to the other rank.}}
%0 = tensor.insert_slice %t2 into %t1[0][4][1] : tensor<?x?xf32> into tensor<?xf32>
@@ -349,14 +378,6 @@ func.func @rank(%0: f32) {
// -----
-func.func @illegal_num_offsets(%arg0 : tensor<?x?x?xf32>, %arg1 : index, %arg2 : index) {
- // expected-error at +1 {{expected 3 offset values}}
- %0 = tensor.extract_slice %arg0[0, 0] [%arg1, %arg2] [1, 1] : tensor<?x?x?xf32> to tensor<?x?x?xf32>
- return
-}
-
-// -----
-
func.func @illegal_num_offsets(%arg0 : tensor<?x?xf32>, %arg1 : tensor<?x?x?xf32>,
%arg2 : index, %arg3 : index) {
// expected-error at +1 {{expected 3 offset values}}
>From ff2ce65b3a60192dea951090e7b0b0719090d2ab Mon Sep 17 00:00:00 2001
From: Andrzej Warzynski <andrzej.warzynski at arm.com>
Date: Fri, 18 Oct 2024 08:56:45 +0100
Subject: [PATCH 2/2] fixup! [mlir][tensor] Add tests to invalid.mlir
Remove empty lines
---
mlir/test/Dialect/Tensor/invalid.mlir | 6 ------
1 file changed, 6 deletions(-)
diff --git a/mlir/test/Dialect/Tensor/invalid.mlir b/mlir/test/Dialect/Tensor/invalid.mlir
index a33ef0ba563154..921d7f9f1fefc3 100644
--- a/mlir/test/Dialect/Tensor/invalid.mlir
+++ b/mlir/test/Dialect/Tensor/invalid.mlir
@@ -200,7 +200,6 @@ func.func @tensor.reshape_num_elements_mismatch(
func.func @extract_slice_wrong_result_rank(%t: tensor<?xf32>, %idx : index) {
// expected-error @+1 {{expected rank to be smaller or equal to the other rank.}}
%0 = tensor.extract_slice %t[0][4][1] : tensor<?xf32> to tensor<?x?xf32>
-
return
}
@@ -209,7 +208,6 @@ func.func @extract_slice_wrong_result_rank(%t: tensor<?xf32>, %idx : index) {
func.func @extract_slice_wrong_result_rank(%t: tensor<?xf32>, %idx : index) {
// expected-error @+1 {{expected element type to be 'f32'}}
%0 = tensor.extract_slice %t[0][4][1] : tensor<?xf32> to tensor<4xi8>
-
return
}
@@ -220,7 +218,6 @@ func.func @extract_slice_size_and_output_dim_mismatch_static_size(%t: tensor<16x
// expected-error @+1 {{expected type to be 'tensor<4xf32>' or a rank-reduced version. (size mismatch)}}
%0 = tensor.extract_slice %t[0][4][1]
: tensor<16xf32> to tensor<6xf32>
-
return
}
@@ -230,7 +227,6 @@ func.func @extract_slice_size_and_output_dim_mismatch_dynamic_size(%t: tensor<?x
// expected-error @+2 {{expected type to be 'tensor<?xf32>' or a rank-reduced version. (size mismatch)}}
%c4 = arith.constant 4 : index
%0 = tensor.extract_slice %t[0][%c4][1] : tensor<?xf32> to tensor<4xi8>
-
return
}
@@ -240,7 +236,6 @@ func.func @extract_slice_wrong_static_type(%t: tensor<8x16x4xf32>, %idx : index)
// expected-error @+1 {{expected type to be 'tensor<?x4x4xf32>' or a rank-reduced version. (size mismatch)}}
%0 = tensor.extract_slice %t[0, 0, 0][%idx, 4, 4][1, 1, 1]
: tensor<8x16x4xf32> to tensor<4x4x4xf32>
-
return
}
@@ -250,7 +245,6 @@ func.func @extract_slice_wrong_dynamic_type(%t: tensor<8x16x4xf32>, %idx : index
// expected-error @+1 {{expected type to be 'tensor<4x4x4xf32>' or a rank-reduced version. (size mismatch)}}
%0 = tensor.extract_slice %t[0, 2, 0][4, 4, 4][1, 1, 1]
: tensor<8x16x4xf32> to tensor<?x4x4xf32>
-
return
}
More information about the Mlir-commits
mailing list