Skip to content

[mlir][tosa] Add more level_check tests for tensor_dim and tensor_size #135062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions mlir/test/Dialect/Tosa/level_check.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,41 @@ func.func @test_unranked_tensor(%arg0: tensor<*xf32>) {

// -----

// CHECK-LABEL: tensor_dim
func.func @test_tensor_dim(%arg0: tensor<1x2147483648xf32>) {
%0 = tosa.const_shape {values = dense<0> : tensor<2xindex>} : () -> !tosa.shape<2>
%1 = tosa.const_shape {values = dense<1> : tensor<2xindex>} : () -> !tosa.shape<2>

// expected-error@+1 {{'tosa.slice' op failed level check: operand tensor size (in bytes) <= (1 << MAX_LOG2_SIZE - 1)}}
%2= tosa.slice %arg0, %0, %1 : (tensor<1x2147483648xf32>, !tosa.shape<2>, !tosa.shape<2>) -> tensor<1x1xf32>
return
}

// -----

// CHECK-LABEL: tensor_size
func.func @test_tensor_size(%arg0: tensor<1x1073741824xf32>) {
%0 = tosa.const_shape {values = dense<0> : tensor<2xindex>} : () -> !tosa.shape<2>
%1 = tosa.const_shape {values = dense<1> : tensor<2xindex>} : () -> !tosa.shape<2>

// expected-error@+1 {{'tosa.slice' op failed level check: operand tensor size (in bytes) <= (1 << MAX_LOG2_SIZE - 1)}}
%2= tosa.slice %arg0, %0, %1 : (tensor<1x1073741824xf32>, !tosa.shape<2>, !tosa.shape<2>) -> tensor<1x1xf32>
return
}

// -----

// CHECK-LABEL: tensor_size
func.func @test_tensor_size_ok(%arg0: tensor<1x536870911xf32>) {
%0 = tosa.const_shape {values = dense<0> : tensor<2xindex>} : () -> !tosa.shape<2>
%1 = tosa.const_shape {values = dense<1> : tensor<2xindex>} : () -> !tosa.shape<2>

%2= tosa.slice %arg0, %0, %1 : (tensor<1x536870911xf32>, !tosa.shape<2>, !tosa.shape<2>) -> tensor<1x1xf32>
return
}

// -----

// CHECK-LABEL: test_concat_tensor_list_size
func.func @test_concat_tensor_list_size() {
%0 = "tosa.const"() {values = dense<0> : tensor<1xi32>} : () -> tensor<1xi32>
Expand Down