Skip to content

Commit 2bbe8e8

Browse files
authored
[mlir][tosa] Add more level_check tests for tensor_dim and tensor_size (#135062)
Signed-off-by: Jerry Ge <[email protected]>
1 parent 8820f4e commit 2bbe8e8

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

mlir/test/Dialect/Tosa/level_check.mlir

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,41 @@ func.func @test_unranked_tensor(%arg0: tensor<*xf32>) {
12061206

12071207
// -----
12081208

1209+
// CHECK-LABEL: tensor_dim
1210+
func.func @test_tensor_dim(%arg0: tensor<1x2147483648xf32>) {
1211+
%0 = tosa.const_shape {values = dense<0> : tensor<2xindex>} : () -> !tosa.shape<2>
1212+
%1 = tosa.const_shape {values = dense<1> : tensor<2xindex>} : () -> !tosa.shape<2>
1213+
1214+
// expected-error@+1 {{'tosa.slice' op failed level check: operand tensor size (in bytes) <= (1 << MAX_LOG2_SIZE - 1)}}
1215+
%2= tosa.slice %arg0, %0, %1 : (tensor<1x2147483648xf32>, !tosa.shape<2>, !tosa.shape<2>) -> tensor<1x1xf32>
1216+
return
1217+
}
1218+
1219+
// -----
1220+
1221+
// CHECK-LABEL: tensor_size
1222+
func.func @test_tensor_size(%arg0: tensor<1x1073741824xf32>) {
1223+
%0 = tosa.const_shape {values = dense<0> : tensor<2xindex>} : () -> !tosa.shape<2>
1224+
%1 = tosa.const_shape {values = dense<1> : tensor<2xindex>} : () -> !tosa.shape<2>
1225+
1226+
// expected-error@+1 {{'tosa.slice' op failed level check: operand tensor size (in bytes) <= (1 << MAX_LOG2_SIZE - 1)}}
1227+
%2= tosa.slice %arg0, %0, %1 : (tensor<1x1073741824xf32>, !tosa.shape<2>, !tosa.shape<2>) -> tensor<1x1xf32>
1228+
return
1229+
}
1230+
1231+
// -----
1232+
1233+
// CHECK-LABEL: tensor_size
1234+
func.func @test_tensor_size_ok(%arg0: tensor<1x536870911xf32>) {
1235+
%0 = tosa.const_shape {values = dense<0> : tensor<2xindex>} : () -> !tosa.shape<2>
1236+
%1 = tosa.const_shape {values = dense<1> : tensor<2xindex>} : () -> !tosa.shape<2>
1237+
1238+
%2= tosa.slice %arg0, %0, %1 : (tensor<1x536870911xf32>, !tosa.shape<2>, !tosa.shape<2>) -> tensor<1x1xf32>
1239+
return
1240+
}
1241+
1242+
// -----
1243+
12091244
// CHECK-LABEL: test_concat_tensor_list_size
12101245
func.func @test_concat_tensor_list_size() {
12111246
%0 = "tosa.const"() {values = dense<0> : tensor<1xi32>} : () -> tensor<1xi32>

0 commit comments

Comments
 (0)