Skip to content

Commit 6029d12

Browse files
committed
Add test for onnx.Cast v21 to tosa lowering
Signed-off-by: Rickert, Jonas <[email protected]>
1 parent 6e5d133 commit 6029d12

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/mlir/conversion/onnx_to_tosa/Math/Elementwise.mlir

+13
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ func.func @test_cast_f32_i8(%arg0: tensor<13x21x1xf32>) -> tensor<13x21x1xi8> {
1919

2020
// -----
2121

22+
func.func @test_cast_int4_and_uint4_to_from_int8_uint8(%arg0: tensor<1xi4>, %arg1: tensor<1xui4>) -> (tensor<1xi4>, tensor<1xui4>) {
23+
%0 = "onnx.Cast"(%arg0) {saturate = 1 : si64, to = i8} : (tensor<1xi4>) -> tensor<1xi8>
24+
%1 = "onnx.Cast"(%0) {saturate = 1 : si64, to = i4} : (tensor<1xi8>) -> tensor<1xi4>
25+
%2 = "onnx.Cast"(%arg1) {saturate = 1 : si64, to = ui8} : (tensor<1xui4>) -> tensor<1xui8>
26+
%3 = "onnx.Cast"(%2) {saturate = 1 : si64, to = ui4} : (tensor<1xui8>) -> tensor<1xui4>
27+
onnx.Return %1, %3 : tensor<1xi4>, tensor<1xui4>
28+
// CHECK-LABEL: func.func @test_cast_int4_and_uint4_to_from_int8_uint8(
29+
// TOSA does not support int4 casting
30+
// CHECK-NOT: tosa.cast
31+
}
32+
33+
// -----
34+
2235
func.func @test_cast_f16_i8(%arg0: tensor<13x21x1xf16>) -> tensor<13x21x1xi8> {
2336
%0 = "onnx.Cast"(%arg0) {to = i8} : (tensor<13x21x1xf16>) -> tensor<13x21x1xi8>
2437
"func.return"(%0) : (tensor<13x21x1xi8>) -> ()

0 commit comments

Comments
 (0)