Lines Matching +full:batch +full:- +full:reduce
1 // RUN: mlir-opt --split-input-file -pass-pipeline="builtin.module(func.func(tosa-to-linalg))" %s -verify-diagnostics -o -| FileCheck %s
3 // CHECK: #[[$MAP0:.*]] = affine_map<() -> ()>
5 // CHECK-LABEL: @test_abs_scalar
6 // CHECK-SAME: ([[ARG0:%[0-9a-zA-Z_]*]]
7 func.func @test_abs_scalar(%arg0: tensor<f32>) -> tensor<f32> {
13 // CHECK: } -> tensor<f32>
14 %0 = tosa.abs %arg0 : (tensor<f32>) -> tensor<f32>
20 // -----
22 // CHECK: #[[$MAP0:.*]] = affine_map<(d0) -> (d0)>
23 // CHECK-LABEL: @test_abs_1d_cast_static_to_dynamic
24 // CHECK-SAME: ([[ARG0:%[0-9a-zA-Z_]*]]
25 func.func @test_abs_1d_cast_static_to_dynamic(%arg0: tensor<5xf32>) -> tensor<?xf32> {
31 // CHECK: } -> tensor<5xf32>
33 %0 = "tosa.abs"(%arg0) : (tensor<5xf32>) -> tensor<?xf32>
39 // -----
41 // CHECK: #[[$MAP0:.*]] = affine_map<(d0) -> (d0)>
42 // CHECK-LABEL: @test_abs_1d_cast_dynamic_to_static
43 // CHECK-SAME: (%[[ARG0:[0-9a-zA-Z_]*]]
44 func.func @test_abs_1d_cast_dynamic_to_static(%arg0: tensor<?xf32>) -> tensor<5xf32> {
52 // CHECK: } -> tensor<?xf32>
54 %0 = "tosa.abs"(%arg0) : (tensor<?xf32>) -> tensor<5xf32>
60 // -----
62 // CHECK: #[[$MAP0:.*]] = affine_map<(d0) -> (d0)>
63 // CHECK-LABEL: @test_abs_1d_dynamic
64 // CHECK-SAME: ([[ARG0:%[0-9a-zA-Z_]*]]
65 func.func @test_abs_1d_dynamic(%arg0: tensor<?xf32>) -> tensor<?xf32> {
74 // CHECK: } -> tensor<?xf32>
75 %0 = tosa.abs %arg0 : (tensor<?xf32>) -> tensor<?xf32>
81 // -----
83 // CHECK: #[[$MAP0:.*]] = affine_map<() -> ()>
84 // CHECK-LABEL: @test_add_0d
85 // CHECK-SAME: [[ARG0:%[0-9a-zA-Z_]*]]:
86 // CHECK-SAME: [[ARG1:%[0-9a-zA-Z_]*]]:
87 func.func @test_add_0d(%arg0: tensor<f32>, %arg1: tensor<f32>) -> tensor<f32> {
94 // CHECK: } -> tensor<f32>
95 %0 = tosa.add %arg0, %arg1 : (tensor<f32>, tensor<f32>) -> tensor<f32>
102 // -----
104 // CHECK: #[[$MAP0:.+]] = affine_map<(d0, d1) -> (d0, d1)>
105 // CHECK: #[[$MAP1:.+]] = affine_map<(d0, d1) -> (0, d1)>
107 // CHECK-LABEL: func.func @test_add_2d_broadcast(
108 // CHECK-SAME: %[[ARG0:.*]]: tensor<2x1xf32>,
109 // CHECK-SAME: %[[ARG1:.*]]: tensor<1x1xf32>) -> tensor<2x1xf32> {
115 // CHECK: } -> tensor<2x1xf32>
118 func.func @test_add_2d_broadcast(%arg0: tensor<2x1xf32>, %arg1: tensor<1x1xf32>) -> tensor<2x1xf32> {
119 // tosa element-wise operators now require operands of equal ranks
120 %0 = tosa.add %arg0, %arg1 : (tensor<2x1xf32>, tensor<1x1xf32>) -> tensor<2x1xf32>
124 // -----
126 // CHECK: #[[$MAP0:.+]] = affine_map<(d0) -> (0)>
127 // CHECK: #[[$MAP1:.+]] = affine_map<(d0) -> (d0)>
128 // CHECK-LABEL: @test_add_1d_all_dynamic
129 // CHECK-SAME: %[[ARG0:[0-9a-zA-Z_]*]]:
130 // CHECK-SAME: %[[ARG1:[0-9a-zA-Z_]*]]:
131 func.func @test_add_1d_all_dynamic(%arg0: tensor<?xf32>, %arg1: tensor<?xf32>) -> tensor<?xf32> {
140 // CHECK: %[[ARG0_DIM0_BROADCAST:.*]] = scf.if %[[VAL_1]] -> (tensor<?xf32>) {
145 // CHECK: } -> tensor<?xf32>
152 // CHECK: %[[ARG0_DIM1_BROADCAST:.*]] = scf.if %[[VAL_7]] -> (tensor<?xf32>) {
157 // CHECK: } -> tensor<?xf32>
167 // CHECK: } -> tensor<?xf32>
168 %0 = tosa.add %arg0, %arg1 : (tensor<?xf32>, tensor<?xf32>) -> tensor<?xf32>
174 // -----
176 // CHECK: #[[$MAP0:.+]] = affine_map<(d0) -> (0)>
177 // CHECK: #[[$MAP1:.+]] = affine_map<(d0) -> (d0)>
178 // CHECK-LABEL: @test_add_1d_broadcast_dynamic_to_static
179 // CHECK-SAME: %[[ARG0:[0-9a-zA-Z_]*]]:
180 // CHECK-SAME: %[[ARG1:[0-9a-zA-Z_]*]]:
181 func.func @test_add_1d_broadcast_dynamic_to_static(%arg0: tensor<5xf32>, %arg1: tensor<?xf32>) -> tensor<5xf32> {
187 // CHECK: %[[ARG1_DIM0_BROADCAST:.*]] = scf.if %[[VAL_0]] -> (tensor<?xf32>) {
192 // CHECK: } -> tensor<5xf32>
203 // CHECK: } -> tensor<5xf32>
204 %0 = tosa.add %arg0, %arg1 : (tensor<5xf32>, tensor<?xf32>) -> tensor<5xf32>
210 // -----
212 // CHECK: #[[$MAP0:.+]] = affine_map<(d0) -> (0)>
213 // CHECK: #[[$MAP1:.+]] = affine_map<(d0) -> (d0)>
214 // CHECK-LABEL: @test_add_1d_broadcast_static_to_dynamic
215 // CHECK-SAME: %[[ARG0:[0-9a-zA-Z_]*]]:
216 // CHECK-SAME: %[[ARG1:[0-9a-zA-Z_]*]]:
217 func.func @test_add_1d_broadcast_static_to_dynamic(%arg0: tensor<1xf32>, %arg1: tensor<?xf32>) -> tensor<?xf32> {
226 // CHECK: } -> tensor<?xf32>
227 %0 = tosa.add %arg0, %arg1 : (tensor<1xf32>, tensor<?xf32>) -> tensor<?xf32>
233 // -----
235 // CHECK: #[[$MAP0:.+]] = affine_map<(d0) -> (0)>
236 // CHECK: #[[$MAP1:.+]] = affine_map<(d0) -> (d0)>
237 // CHECK-LABEL: @test_add_1d_broadcast_static_to_static
238 // CHECK-SAME: %[[ARG0:[0-9a-zA-Z_]*]]:
239 // CHECK-SAME: %[[ARG1:[0-9a-zA-Z_]*]]:
240 func.func @test_add_1d_broadcast_static_to_static(%arg0: tensor<1xf32>, %arg1: tensor<3xf32>) -> tensor<3xf32> {
247 // CHECK: } -> tensor<3xf32>
248 %0 = tosa.add %arg0, %arg1 : (tensor<1xf32>, tensor<3xf32>) -> tensor<3xf32>
254 // -----
256 // CHECK: #[[$MAP:.+]] = affine_map<(d0) -> (d0)>
257 // CHECK-LABEL: @test_add_1d_matching_no_broadcast
258 // CHECK-SAME: %[[ARG0:[0-9a-zA-Z_]*]]:
259 // CHECK-SAME: %[[ARG1:[0-9a-zA-Z_]*]]:
260 func.func @test_add_1d_matching_no_broadcast(%arg0: tensor<1xf32>, %arg1: tensor<1xf32>) -> tensor<1xf32> {
267 // CHECK: } -> tensor<1xf32>
268 %0 = tosa.add %arg0, %arg1 : (tensor<1xf32>, tensor<1xf32>) -> tensor<1xf32>
274 // -----
276 // CHECK: #[[$MAP0:.+]] = affine_map<(d0) -> (d0)>
277 // CHECK-LABEL: @test_add_1d_matching_static
278 // CHECK-SAME: %[[ARG0:[0-9a-zA-Z_]*]]:
279 // CHECK-SAME: %[[ARG1:[0-9a-zA-Z_]*]]:
280 func.func @test_add_1d_matching_static(%arg0: tensor<3xf32>, %arg1: tensor<3xf32>) -> tensor<3xf32> {
287 // CHECK: } -> tensor<3xf32>
288 %0 = tosa.add %arg0, %arg1 : (tensor<3xf32>, tensor<3xf32>) -> tensor<3xf32>
294 // -----
296 // CHECK: #[[$MAP0:.+]] = affine_map<(d0, d1) -> (0, d1)>
297 // CHECK: #[[$MAP1:.+]] = affine_map<(d0, d1) -> (d0, d1)>
298 // CHECK: #[[$MAP2:.+]] = affine_map<(d0, d1) -> (d0, 0)>
299 // CHECK-LABEL: @test_add_2d_all_dynamic
300 // CHECK-SAME: %[[ARG0:[0-9a-zA-Z_]*]]:
301 // CHECK-SAME: %[[ARG1:[0-9a-zA-Z_]*]]:
302 func.func @test_add_2d_all_dynamic(%arg0: tensor<?x?xf32>, %arg1: tensor<?x?xf32>) -> tensor<?x?xf32> {
315 // CHECK: %[[ARG0_DIM0_BROADCAST:.*]] = scf.if %[[VAL_1]] -> (tensor<?x?xf32>) {
322 // CHECK: } -> tensor<?x?xf32>
330 // CHECK: %[[ARG0_DIM1_BROADCAST:.*]] = scf.if %[[VAL_8]] -> (tensor<?x?xf32>) {
337 // CHECK: } -> tensor<?x?xf32>
345 // CHECK: %[[ARG1_DIM0_BROADCAST:.*]] = scf.if %[[VAL_15]] -> (tensor<?x?xf32>) {
352 // CHECK: } -> tensor<?x?xf32>
360 // CHECK: %[[ARG1_DIM1_BROADCAST:.*]] = scf.if %[[VAL_22]] -> (tensor<?x?xf32>) {
367 // CHECK: } -> tensor<?x?xf32>
378 // CHECK: } -> tensor<?x?xf32>
379 %0 = tosa.add %arg0, %arg1 : (tensor<?x?xf32>, tensor<?x?xf32>) -> tensor<?x?xf32>
385 // -----
387 // CHECK: #[[$MAP0:.+]] = affine_map<(d0, d1) -> (d0, 0)>
388 // CHECK: #[[$MAP1:.+]] = affine_map<(d0, d1) -> (d0, d1)>
389 // CHECK-LABEL: @test_select_2d_one_dynamic
390 // CHECK-SAME: %[[ARG0:[0-9a-zA-Z_]*]]:
391 // CHECK-SAME: %[[ARG1:[0-9a-zA-Z_]*]]:
392 // CHECK-SAME: %[[ARG2:[0-9a-zA-Z_]*]]:
393 func.func @test_select_2d_one_dynamic(%arg0: tensor<2x?xi1>, %arg1: tensor<2x?xf32>, %arg2: tensor<2x?xf32>) -> tensor<2x?xf32> {
404 // CHECK: %[[ARG0_BROADCAST:.*]] = scf.if %[[VAL_2]] -> (tensor<2x?xi1>) {
409 // CHECK: } -> tensor<2x?xi1>
417 // CHECK: %[[ARG1_BROADCAST:.*]] = scf.if %[[VAL_8]] -> (tensor<2x?xf32>) {
422 // CHECK: } -> tensor<2x?xf32>
430 // CHECK: %[[ARG2_BROADCAST:.*]] = scf.if %[[VAL_14]] -> (tensor<2x?xf32>) {
435 // CHECK: } -> tensor<2x?xf32>
446 // CHECK: } -> tensor<2x?xf32>
447 %0 = tosa.select %arg0, %arg1, %arg2 : (tensor<2x?xi1>, tensor<2x?xf32>, tensor<2x?xf32>) -> tensor<2x?xf32>
453 // -----
455 // CHECK-LABEL: @test_simple_f32
456 func.func @test_simple_f32(%arg0: tensor<1xf32>) -> () {
459 %0 = tosa.tanh %arg0 : (tensor<1xf32>) -> tensor<1xf32>
463 %1 = tosa.abs %arg0 : (tensor<1xf32>) -> tensor<1xf32>
467 %2 = tosa.add %0, %0 : (tensor<1xf32>, tensor<1xf32>) -> tensor<1xf32>
471 %3 = tosa.sub %0, %1 : (tensor<1xf32>, tensor<1xf32>) -> tensor<1xf32>
475 %4 = tosa.mul %0, %1 : (tensor<1xf32>, tensor<1xf32>) -> tensor<1xf32>
479 %5 = tosa.negate %0 : (tensor<1xf32>) -> tensor<1xf32>
483 %6 = tosa.pow %1, %2 : (tensor<1xf32>, tensor<1xf32>) -> tensor<1xf32>
487 %7 = tosa.rsqrt %1 : (tensor<1xf32>) -> tensor<1xf32>
491 %8 = tosa.log %arg0 : (tensor<1xf32>) -> tensor<1xf32>
495 %9 = tosa.exp %arg0 : (tensor<1xf32>) -> tensor<1xf32>
499 %10 = tosa.greater %0, %1 : (tensor<1xf32>, tensor<1xf32>) -> tensor<1xi1>
503 %11 = tosa.greater_equal %0, %1 : (tensor<1xf32>, tensor<1xf32>) -> tensor<1xi1>
507 %12 = tosa.equal %0, %1 : (tensor<1xf32>, tensor<1xf32>) -> tensor<1xi1>
511 %13 = tosa.select %10, %0, %1 : (tensor<1xi1>, tensor<1xf32>, tensor<1xf32>) -> tensor<1xf32>
515 %14 = tosa.maximum %0, %1 : (tensor<1xf32>, tensor<1xf32>) -> tensor<1xf32>
519 %15 = tosa.minimum %0, %1 : (tensor<1xf32>, tensor<1xf32>) -> tensor<1xf32>
523 %16 = tosa.ceil %0 : (tensor<1xf32>) -> tensor<1xf32>
527 %17 = tosa.floor %0 : (tensor<1xf32>) -> tensor<1xf32>
532 %18 = tosa.clamp %0 {min_int = 1 : i64, max_int = 5 : i64, min_fp = 1.0 : f32, max_fp = 5.0 : f32} : (tensor<1xf32>) -> tensor<1xf32>
539 %19 = tosa.sigmoid %0 : (tensor<1xf32>) -> tensor<1xf32>
543 // CHECK: [[CSTMIN:%.+]] = arith.constant -2.14748365E+9 : f32
550 %20 = tosa.cast %0 : (tensor<1xf32>) -> tensor<1xi32>
555 %21 = tosa.cast %0 : (tensor<1xf32>) -> tensor<1xi1>
559 %22 = tosa.cast %0 : (tensor<1xf32>) -> tensor<1xf16>
563 %23 = tosa.reciprocal %0 : (tensor<1xf32>) -> tensor<1xf32>
567 %24 = tosa.erf %0 : (tensor<1xf32>) -> tensor<1xf32>
571 %25 = tosa.sin %arg0 : (tensor<1xf32>) -> tensor<1xf32>
575 %26 = tosa.cos %arg0 : (tensor<1xf32>) -> tensor<1xf32>
580 // -----
582 // CHECK-LABEL: @test_simple_f16
583 func.func @test_simple_f16(%arg0: tensor<1xf16>) -> () {
587 %0 = tosa.cast %arg0 : (tensor<1xf16>) -> tensor<1xf32>
591 // CHECK: [[CSTMIN:%.+]] = arith.constant -1.280000e+02 : f16
596 %1 = "tosa.cast"(%arg0) : (tensor<1xf16>) -> tensor<1xi8>
599 // CHECK: [[ROUND:%.+]] = math.roundeven {{%[a-z0-9_]+}} : f16
605 // CHECK: [[MININT:%.+]] = arith.constant -2147483648 : i32
609 %2 = "tosa.cast"(%arg0) : (tensor<1xf16>) -> tensor<1xi32>
613 // -----
615 // CHECK-LABEL: @test_simple_i16
616 func.func @test_simple_i16(%arg0: tensor<1xi16>) -> () {
621 %0 = tosa.mul %arg0, %arg0 : (tensor<1xi16>, tensor<1xi16>) -> tensor<1xi32>
626 // -----
628 // CHECK-LABEL: @test_simple_ui8
629 func.func @test_simple_ui8(%arg0: tensor<1xui8>) -> () {
631 %0 = tosa.cast %arg0 : (tensor<1xui8>) -> tensor<1xf32>
635 // -----
637 // CHECK-LABEL: @test_simple_i32
638 func.func @test_simple_i32(%arg0: tensor<1xi32>, %unsigned: tensor<1xui32>, %unsigned64: tensor<1xui64>) -> () {
641 %0 = tosa.add %arg0, %arg0 : (tensor<1xi32>, tensor<1xi32>) -> tensor<1xi32>
645 %1 = tosa.sub %arg0, %arg0 : (tensor<1xi32>, tensor<1xi32>) -> tensor<1xi32>
649 %shift1 = "tosa.const"() <{value = dense<0> : tensor<1xi8>}> : () -> tensor<1xi8>
650 %2 = tosa.mul %arg0, %arg0, %shift1 : (tensor<1xi32>, tensor<1xi32>, tensor<1xi8>) -> tensor<1xi32>
655 %shift2 = "tosa.const"() <{value = dense<2> : tensor<1xi8>}> : () -> tensor<1xi8>
656 %3 = tosa.mul %arg0, %arg0, %shift2: (tensor<1xi32>, tensor<1xi32>, tensor<1xi8>) -> tensor<1xi32>
660 %40 = tosa.int_div %arg0, %arg0 : (tensor<1xi32>, tensor<1xi32>) -> tensor<1xi32>
666 %5 = tosa.negate %arg0 : (tensor<1xi32>) -> tensor<1xi32>
670 %6 = tosa.bitwise_and %arg0, %arg0 : (tensor<1xi32>, tensor<1xi32>) -> tensor<1xi32>
674 %7 = tosa.bitwise_or %arg0, %arg0 : (tensor<1xi32>, tensor<1xi32>) -> tensor<1xi32>
678 %8 = tosa.bitwise_xor %arg0, %arg0 : (tensor<1xi32>, tensor<1xi32>) -> tensor<1xi32>
682 %9 = tosa.logical_left_shift %arg0, %arg0 : (tensor<1xi32>, tensor<1xi32>) -> tensor<1xi32>
686 %10 = tosa.logical_right_shift %arg0, %arg0 : (tensor<1xi32>, tensor<1xi32>) -> tensor<1xi32>
690 %11 = tosa.arithmetic_right_shift %arg0, %arg0 {round = 0 : i1} : (tensor<1xi32>, tensor<1xi32>) -> tensor<1xi32>
704 %12 = tosa.arithmetic_right_shift %arg0, %arg0 {round = 1 : i1} : (tensor<1xi32>, tensor<1xi32>) -> tensor<1xi32>
707 %13 = tosa.clz %arg0 : (tensor<1xi32>) -> tensor<1xi32>
711 %14 = tosa.greater %0, %1 : (tensor<1xi32>, tensor<1xi32>) -> tensor<1xi1>
715 %15 = tosa.greater_equal %0, %1 : (tensor<1xi32>, tensor<1xi32>) -> tensor<1xi1>
719 %16 = tosa.select %14, %0, %1 : (tensor<1xi1>, tensor<1xi32>, tensor<1xi32>) -> tensor<1xi32>
723 %17 = tosa.maximum %0, %1 : (tensor<1xi32>, tensor<1xi32>) -> tensor<1xi32>
727 %18 = tosa.minimum %0, %1 : (tensor<1xi32>, tensor<1xi32>) -> tensor<1xi32>
730 // CHECK-DAG: arith.maxsi
731 // CHECK-DAG: arith.minsi
732 %19 = tosa.clamp %0 {min_int = 1 : i64, max_int = 5 : i64, min_fp = 1.0 : f32, max_fp = 5.0 : f32} : (tensor<1xi32>) -> tensor<1xi32>
735 // CHECK-DAG: %[[LB:.*]] = arith.constant 4 : i32
736 // CHECK-DAG: %[[UB:.*]] = arith.constant 32 : i32
737 // CHECK-DAG: arith.maxui %[[LB]],
738 // CHECK-DAG: arith.minui %[[UB]],
739 %u0 = tosa.clamp %unsigned {min_int = 4 : i64, max_int = 32 : i64, min_fp = 1.0 : f32, max_fp = 5.0 : f32} : (tensor<1xui32>) -> tensor<1xui32>
742 // CHECK-DAG: %[[LB:.*]] = arith.constant -1 : i32
743 // CHECK-DAG: %[[UB:.*]] = arith.constant -1 : i32
744 // CHECK-DAG: arith.maxui %[[LB]],
745 // CHECK-DAG: arith.minui %[[UB]],
746 %u1 = tosa.clamp %unsigned {min_int = 9223372036854775807 : i64, max_int = 9223372036854775807 : i64, min_fp = 1.0 : f32, max_fp = 5.0 : f32} : (tensor<1xui32>) -> tensor<1xui32>
749 // CHECK-DAG: %[[LB:.*]] = arith.constant 0 : i32
750 // CHECK-DAG: %[[UB:.*]] = arith.constant 0 : i32
751 // CHECK-DAG: arith.maxui %[[LB]],
752 // CHECK-DAG: arith.minui %[[UB]],
753 %u2 = tosa.clamp %unsigned {min_int = -3 : i64, max_int = -2 : i64, min_fp = 1.0 : f32, max_fp = 5.0 : f32} : (tensor<1xui32>) -> tensor<1xui32>
756 // CHECK-DAG: %[[LB:.*]] = arith.constant 0 : i64
757 // CHECK-DAG: %[[UB:.*]] = arith.constant 9223372036854775807 : i64
758 // CHECK-DAG: arith.maxui %[[LB]],
759 // CHECK-DAG: arith.minui %[[UB]],
760 %u3 = tosa.clamp %unsigned64 {min_int = -3 : i64, max_int = 9223372036854775807 : i64, min_fp = 1.0 : f32, max_fp = 5.0 : f32} : (tensor<1xui64>) -> tensor<1xui64>
764 %20 = tosa.cast %0 : (tensor<1xi32>) -> tensor<1xi16>
768 %21 = tosa.cast %0 : (tensor<1xi32>) -> tensor<1xi64>
773 %22 = tosa.cast %0 : (tensor<1xi32>) -> tensor<1xi1>
777 %23 = tosa.cast %0 : (tensor<1xi32>) -> tensor<1xf32>
783 %24 = tosa.abs %arg0 : (tensor<1xi32>) -> tensor<1xi32>
788 // -----
790 // CHECK-LABEL: @test_simple_ui8
791 func.func @test_simple_ui8(%arg0: tensor<1xi8>) -> () {
795 %0 = tosa.cast %arg0 : (tensor<1xi8>) -> tensor<1xf32>
800 // -----
802 // CHECK-LABEL: @test_i8
803 func.func @test_i8(%arg0: tensor<1xi8>) -> () {
806 // CHECK-DAG: %[[C127:.+]] = arith.constant -127
807 // CHECK-DAG: %[[C126:.+]] = arith.constant 126
808 // CHECK-DAG: %[[LOWER:.+]] = arith.maxsi %[[C127]], %[[ARG1]]
809 // CHECK-DAG: %[[CLAMPED:.+]] = arith.minsi %[[C126]], %[[LOWER]]
810 %0 = tosa.clamp %arg0 {min_int = -127 : i64, max_int = 126 : i64, min_fp = 0.0 : f32, max_fp = 0.0 : f32} : (tensor<1xi8>) -> tensor<1xi8>
814 // CHECK-DAG: %[[C128:.+]] = arith.constant -128
815 // CHECK-DAG: %[[C127:.+]] = arith.constant 127
816 // CHECK-DAG: %[[LOWER:.+]] = arith.maxsi %[[C128]], %[[ARG1]]
817 // CHECK-DAG: %[[CLAMPED:.+]] = arith.minsi %[[C127]], %[[LOWER]]
818 %1 = tosa.clamp %arg0 {min_int = -130 : i64, max_int = 130 : i64, min_fp = 0.0 : f32, max_fp = 0.0 : f32} : (tensor<1xi8>) -> tensor<1xi8>
823 // -----
825 // CHECK-LABEL: @test_i64
826 func.func @test_i64(%arg0: tensor<1xi64>) -> () {
829 // CHECK-DAG: %[[C127:.+]] = arith.constant -9223372036854775808
830 // CHECK-DAG: %[[C126:.+]] = arith.constant 9223372036854775807
831 // CHECK-DAG: %[[LOWER:.+]] = arith.maxsi %[[C127]], %[[ARG1]]
832 // CHECK-DAG: %[[CLAMPED:.+]] = arith.minsi %[[C126]], %[[LOWER]]
833 %0 = tosa.clamp %arg0 {min_int = -9223372036854775808 : i64, max_int = 9223372036854775807 : i64, min_fp = 0.0 : f32, max_fp = 0.0 : f32} : (tensor<1xi64>) -> tensor<1xi64>
838 // -----
840 // CHECK-LABEL: @test_clamp_f16
841 func.func @test_clamp_f16(%arg0: tensor<1xf16>) -> () {
844 // CHECK-DAG: %[[C0:.+]] = arith.constant 0.0
845 // CHECK-DAG: %[[C6:.+]] = arith.constant 6.0
846 // CHECK-DAG: %[[MIN:.+]] = arith.minimumf %[[ARG1]], %[[C6]]
847 // CHECK-DAG: %[[MAX:.+]] = arith.maximumf %[[MIN]], %[[C0]]
848 %0 = tosa.clamp %arg0 {min_int = 0 : i64, max_int = 0 : i64, min_fp = 0.0 : f32, max_fp = 6.0 : f32} : (tensor<1xf16>) -> tensor<1xf16>
853 // -----
855 // CHECK-LABEL: @test_bool
856 func.func @test_bool(%arg0: tensor<1xi1>, %arg1: tensor<1xi1>) -> () {
859 %0 = tosa.logical_and %arg0, %arg1 : (tensor<1xi1>, tensor<1xi1>) -> tensor<1xi1>
863 %1 = tosa.logical_or %arg0, %arg1 : (tensor<1xi1>, tensor<1xi1>) -> tensor<1xi1>
867 %2 = tosa.logical_xor %arg0, %arg1 : (tensor<1xi1>, tensor<1xi1>) -> tensor<1xi1>
872 %3 = tosa.logical_not %arg0 : (tensor<1xi1>) -> tensor<1xi1>
877 // -----
879 // CHECK-LABEL: @test_negate_quantized
880 func.func @test_negate_quantized(%arg0: tensor<1xi8>) -> () {
886 // CHECK: [[MIN:%.+]] = arith.constant -128
892 %0 = tosa.negate %arg0 {quantization_info = #tosa.unary_quant<input_zp = 0, output_zp = 7>} : (tensor<1xi8>) -> tensor<1xi8>
897 %1 = tosa.negate %arg0 {quantization_info = #tosa.unary_quant<input_zp = 32639, output_zp = 0>} : (tensor<1xi8>) -> tensor<1xi8>
902 %2 = tosa.negate %arg0 {quantization_info = #tosa.unary_quant<input_zp = 32640, output_zp = 0>} : (tensor<1xi8>) -> tensor<1xi8>
909 %3 = tosa.negate %arg0 {quantization_info = #tosa.unary_quant<input_zp = 0, output_zp = 0>} : (tensor<1xi8>) -> tensor<1xi8>
914 // -----
916 // CHECK-LABEL: @test_identity
917 // CHECK-SAME: %[[ARG0:[0-9a-zA-Z_]*]]: tensor<1xf32>,
918 // CHECK-SAME: %[[ARG1:[0-9a-zA-Z_]*]]: tensor<1xi32>
919 func.func @test_identity(%arg0: tensor<1xf32>, %arg1: tensor<1xi32>) -> (tensor<1xf32>, tensor<1xi32>) {
920 %0 = tosa.identity %arg0 : (tensor<1xf32>) -> tensor<1xf32>
921 %1 = tosa.identity %arg1 : (tensor<1xi32>) -> tensor<1xi32>
927 // -----
929 // CHECK-LABEL: @reduce_float
930 // CHECK-SAME: [[ARG0:%.+]]: tensor<5x4xf32>
931 func.func @reduce_float(%arg0: tensor<5x4xf32>) -> () {
935 // CHECK: [[REDUCE:%.+]] = linalg.reduce ins([[ARG0]] : tensor<5x4xf32>) outs([[FILL]] : tensor<4xf32>) dimensions = [0]
940 // CHECK: tensor.expand_shape [[REDUCE]] {{\[}}[0, 1]] output_shape [1, 4] : tensor<4xf32> into tensor<1x4xf32>
941 %0 = tosa.reduce_sum %arg0 {axis = 0 : i32} : (tensor<5x4xf32>) -> tensor<1x4xf32>
946 // CHECK: [[REDUCE:%.+]] = linalg.reduce ins([[ARG0]] : tensor<5x4xf32>) outs([[FILL]] : tensor<5xf32>) dimensions = [1]
951 // CHECK: tensor.expand_shape [[REDUCE]] {{\[}}[0, 1]] output_shape [5, 1] : tensor<5xf32> into tensor<5x1xf32>
952 %1 = tosa.reduce_sum %arg0 {axis = 1 : i32} : (tensor<5x4xf32>) -> tensor<5x1xf32>
956 // CHECK: linalg.reduce
958 %2 = tosa.reduce_prod %arg0 {axis = 0 : i32} : (tensor<5x4xf32>) -> tensor<1x4xf32>
962 // CHECK: linalg.reduce
964 %3 = tosa.reduce_min %arg0 {axis = 0 : i32} : (tensor<5x4xf32>) -> tensor<1x4xf32>
966 // CHECK: arith.constant -3.40282347E+38 : f32
968 // CHECK: linalg.reduce
970 %4 = tosa.reduce_max %arg0 {axis = 0 : i32} : (tensor<5x4xf32>) -> tensor<1x4xf32>
974 // -----
976 // CHECK-LABEL: @reduce_float_dyn
977 // CHECK-SAME: %[[ARG0:[0-9a-zA-Z_]*]]: tensor<?x5x4xf32>
978 func.func @reduce_float_dyn(%arg0: tensor<?x5x4xf32>) -> () {
984 // CHECK: %[[REDUCE:.+]] = linalg.reduce ins(%[[ARG0]] : tensor<?x5x4xf32>) outs(%[[FILL]] : tensor<?x4xf32>) dimensions = [1]
990 // CHECK: %[[DIM_1:.+]] = tensor.dim %[[REDUCE]], %[[C0_0]] : tensor<?x4xf32>
992 // CHECK: tensor.expand_shape %[[REDUCE]] {{\[}}[0], [1, 2]] output_shape [%[[DIM_1]], 1, 4] : tensor<?x4xf32> into tensor<?x1x4xf32>
993 %0 = tosa.reduce_sum %arg0 {axis = 1 : i32} : (tensor<?x5x4xf32>) -> tensor<?x1x4xf32>
997 // -----
999 // CHECK-LABEL: @reduce_float_dyn_rank_1
1000 // CHECK-SAME: %[[ARG0:[0-9a-zA-Z_]*]]: tensor<?xf32>
1001 func.func @reduce_float_dyn_rank_1(%arg0: tensor<?xf32>) -> () {
1002 // CHECK-DAG: %[[INIT:.+]] = tensor.empty() : tensor<f32>
1003 // CHECK-DAG: %[[CST0:.+]] = arith.constant 0.0
1005 // CHECK: %[[REDUCE:.+]] = linalg.reduce ins(%[[ARG0]] : tensor<?xf32>) outs(%[[FILL]] : tensor<f32>) dimensions = [0]
1010 // CHECK: tensor.expand_shape %[[REDUCE]] {{\[}}] output_shape [1] : tensor<f32> into tensor<1xf32>
1011 %0 = tosa.reduce_sum %arg0 {axis = 0 : i32} : (tensor<?xf32>) -> tensor<1xf32>
1015 // -----
1017 // CHECK-LABEL: @reduce_float_dyn_nonzero_batch
1018 // CHECK-SAME: (%[[ARG0:[0-9a-zA-Z_]*]]:
1019 func.func @reduce_float_dyn_nonzero_batch(%arg0: tensor<5x?x4xf32>) -> () {
1025 // CHECK: %[[REDUCE:.+]] = linalg.reduce ins(%[[ARG0]] : tensor<5x?x4xf32>) outs(%[[FILL]] : tensor<5x?xf32>) dimensions = [2]
1031 // CHECK: %[[DIM_1:.+]] = tensor.dim %[[REDUCE]], %[[C1_0]] : tensor<5x?xf32>
1033 // CHECK: tensor.expand_shape %[[REDUCE]] {{\[}}[0], [1, 2]] output_shape [5, %[[DIM_1]], 1] : tensor<5x?xf32> into tensor<5x?x1xf32>
1034 %0 = tosa.reduce_prod %arg0 {axis = 2 : i32} : (tensor<5x?x4xf32>) -> tensor<5x?x1xf32>
1038 // -----
1040 // CHECK-LABEL: @reduce_float_dyn_multiple
1041 // CHECK-SAME: (%[[ARG0:[0-9a-zA-Z_]*]]:
1042 func.func @reduce_float_dyn_multiple(%arg0: tensor<?x?xf32>) -> () {
1046 // CHECK: %[[CMIN:.+]] = arith.constant -3.40282347E+38
1048 // CHECK: %[[REDUCE:.+]] = linalg.reduce ins(%[[ARG0]] : tensor<?x?xf32>) outs(%[[FILL]] : tensor<?xf32>) dimensions = [1]
1054 // CHECK: %[[DIM_1:.+]] = tensor.dim %[[REDUCE]], %[[C0_0]] : tensor<?xf32>
1056 // CHECK: tensor.expand_shape %[[REDUCE]] {{\[}}[0, 1]] output_shape [%[[DIM_1]], 1] : tensor<?xf32> into tensor<?x1xf32>
1057 %0 = tosa.reduce_max %arg0 {axis = 1 : i32} : (tensor<?x?xf32>) -> tensor<?x1xf32>
1061 // -----
1063 // CHECK-LABEL: @reduce_int
1064 // CHECK-SAME: [[ARG0:%.+]]: tensor<5x4xi32>
1065 func.func @reduce_int(%arg0: tensor<5x4xi32>) -> () {
1069 // CHECK: [[REDUCE:%.+]] = linalg.reduce ins([[ARG0]] : tensor<5x4xi32>) outs([[FILL]] : tensor<4xi32>) dimensions = [0]
1074 // CHECK: tensor.expand_shape [[REDUCE]] {{\[}}[0, 1]] output_shape [1, 4] : tensor<4xi32> into tensor<1x4xi32>
1075 %0 = tosa.reduce_sum %arg0 {axis = 0 : i32} : (tensor<5x4xi32>) -> tensor<1x4xi32>
1080 // CHECK: [[REDUCE:%.+]] = linalg.reduce ins([[ARG0]] : tensor<5x4xi32>) outs([[FILL]] : tensor<5xi32>) dimensions = [1]
1085 // CHECK: tensor.expand_shape [[REDUCE]] {{\[}}[0, 1]] output_shape [5, 1] : tensor<5xi32> into tensor<5x1xi32>
1086 %1 = tosa.reduce_sum %arg0 {axis = 1 : i32} : (tensor<5x4xi32>) -> tensor<5x1xi32>
1090 // CHECK: linalg.reduce
1092 %2 = tosa.reduce_prod %arg0 {axis = 0 : i32} : (tensor<5x4xi32>) -> tensor<1x4xi32>
1096 // CHECK: linalg.reduce
1098 %3 = tosa.reduce_min %arg0 {axis = 0 : i32} : (tensor<5x4xi32>) -> tensor<1x4xi32>
1100 // CHECK: arith.constant -2147483648 : i32
1102 // CHECK: linalg.reduce
1104 %4 = tosa.reduce_max %arg0 {axis = 0 : i32} : (tensor<5x4xi32>) -> tensor<1x4xi32>
1108 // -----
1110 // CHECK-LABEL: @reduce_bool
1111 // CHECK-SAME: [[ARG0:%.+]]: tensor<5x4xi1>
1112 func.func @reduce_bool(%arg0: tensor<5x4xi1>) -> () {
1116 // CHECK: [[REDUCE:%.+]] = linalg.reduce ins([[ARG0]] : tensor<5x4xi1>) outs([[FILL]] : tensor<4xi1>) dimensions = [0]
1117 // CHECK: (%[[ARG1:[0-9a-zA-Z_]+]]: i1, %[[ARG2:[0-9a-zA-Z_]+]]: i1) {
1121 // CHECK: tensor.expand_shape [[REDUCE]] {{\[}}[0, 1]] output_shape [1, 4] : tensor<4xi1> into tensor<1x4xi1>
1122 %0 = tosa.reduce_all %arg0 {axis = 0 : i32} : (tensor<5x4xi1>) -> tensor<1x4xi1>
1126 // CHECK: linalg.reduce
1128 %1 = tosa.reduce_any %arg0 {axis = 0 : i32} : (tensor<5x4xi1>) -> tensor<1x4xi1>
1133 // -----
1134 // CHECK: #[[$MAP0:.*]] = affine_map<(d0) -> (d0)>
1136 // CHECK-LABEL: @rescale_i8
1137 // CHECK-SAME: (%[[ARG0:[0-9a-zA-Z_]*]]:
1138 func.func @rescale_i8(%arg0 : tensor<2xi8>) -> () {
1146 // CHECK-DAG: [[IN32:%.+]] = arith.extsi [[IN]]
1147 // CHECK-DAG: [[IN_ZEROED:%.+]] = arith.subi [[IN32]], [[C17]]
1148 // CHECK-DAG: [[SCALED:%.+]] = tosa.apply_scale [[IN_ZEROED]], [[C0]], [[C1]] {double_round = false}
1149 // CHECK-DAG: [[SCALED_ZEROED:%.+]] = arith.addi [[SCALED]], [[C22]]
1150 // CHECK-DAG: [[CMIN:%.+]] = arith.constant -128
1151 // CHECK-DAG: [[CMAX:%.+]] = arith.constant 127
1152 // CHECK-DAG: [[LOWER:%.+]] = arith.maxsi [[CMIN]], [[SCALED_ZEROED]]
1153 // CHECK-DAG: [[BOUNDED:%.+]] = arith.minsi [[CMAX]], [[LOWER]]
1154 // CHECK-DAG: [[TRUNC:%.+]] = arith.trunci [[BOUNDED]]
1155 // CHECK-DAG: linalg.yield [[TRUNC]]
1156 %0 = tosa.rescale %arg0 {input_zp = 17 : i32, output_zp = 22 : i32, multiplier = array<i32: 19689>, shift = array<i8: 15>, scale32 = false, double_round = false, per_channel = false} : (tensor<2xi8>) -> tensor<2xi8>
1162 // -----
1163 // CHECK: #[[$MAP0:.*]] = affine_map<(d0) -> (d0)>
1165 // CHECK-LABEL: @rescale_i8_unsigned_output
1166 // CHECK-SAME: (%[[ARG0:[0-9a-zA-Z_]*]]:
1167 func.func @rescale_i8_unsigned_output(%arg0 : tensor<2xi8>) -> () {
1175 // CHECK-DAG: [[IN32:%.+]] = arith.extsi [[IN]]
1176 // CHECK-DAG: [[IN_ZEROED:%.+]] = arith.subi [[IN32]], [[C17]]
1177 // CHECK-DAG: [[SCALED:%.+]] = tosa.apply_scale [[IN_ZEROED]], [[C0]], [[C1]] {double_round = false}
1178 // CHECK-DAG: [[SCALED_ZEROED:%.+]] = arith.addi [[SCALED]], [[C22]]
1179 // CHECK-DAG: [[CMIN:%.+]] = arith.constant 0
1180 // CHECK-DAG: [[CMAX:%.+]] = arith.constant 255
1181 // CHECK-DAG: [[LOWER:%.+]] = arith.maxsi [[CMIN]], [[SCALED_ZEROED]]
1182 // CHECK-DAG: [[BOUNDED:%.+]] = arith.minsi [[CMAX]], [[LOWER]]
1183 // CHECK-DAG: [[TRUNC:%.+]] = arith.trunci [[BOUNDED]]
1185 %1 = tosa.rescale %arg0 {input_zp = 17 : i32, output_zp = 22 : i32, multiplier = array<i32: 19689>, shift = array<i8: 15>, scale32 = false, double_round = false, per_channel = false, output_unsigned = true} : (tensor<2xi8>) -> tensor<2xi8>
1191 // -----
1193 // CHECK: #[[$MAP0:.*]] = affine_map<(d0, d1) -> (d0, d1)>
1195 // CHECK-LABEL: @rescale_i8_dyn_batch
1196 // CHECK-SAME: (%[[ARG0:[0-9a-zA-Z_]*]]:
1197 func.func @rescale_i8_dyn_batch(%arg0 : tensor<?x2xi8>) -> () {
1199 // CHECK: %[[BATCH:.+]] = tensor.dim %[[ARG0]], %[[C0]]
1200 // CHECK: %[[INIT:.+]] = tensor.empty(%[[BATCH]]) : tensor<?x2xi8>
1202 %0 = tosa.rescale %arg0 {input_zp = 17 : i32, output_zp = 22 : i32, multiplier = array<i32: 19689>, shift = array<i8: 15>, scale32 = false, double_round = false, per_channel = false} : (tensor<?x2xi8>) -> tensor<?x2xi8>
1205 // CHECK: %[[BATCH:.+]] = tensor.dim %[[ARG0]], %[[C0]]
1206 // CHECK: %[[INIT:.+]] = tensor.empty(%[[BATCH]]) : tensor<?x2xi8>
1208 %1 = tosa.rescale %arg0 {input_zp = 17 : i32, output_zp = 22 : i32, multiplier = array<i32: 19689>, shift = array<i8: 15>, scale32 = false, double_round = false, per_channel = false, output_unsigned = true} : (tensor<?x2xi8>) -> tensor<?x2xi8>
1213 // -----
1215 // CHECK: #[[$MAP1:.*]] = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)>
1217 // CHECK-LABEL: @rescale_dyn
1218 // CHECK-SAME: (%[[ARG0:[0-9a-zA-Z_]*]]:
1219 func.func @rescale_dyn(%arg0 : tensor<1x?x?x32xi32>) -> () {
1226 %0 = tosa.rescale %arg0 {double_round = true, input_zp = 0 : i32, multiplier = array<i32: 1376784203>, output_zp = 0 : i32, per_channel = false, scale32 = true, shift = array<i8: 38>} : (tensor<1x?x?x32xi32>) -> tensor<1x?x?x32xi8>
1230 // -----
1232 // CHECK: #[[$MAP0:.*]] = affine_map<(d0) -> (d0)>
1234 // CHECK-LABEL: @rescale_i8_unsigned_input
1235 // CHECK-SAME: (%[[ARG0:[0-9a-zA-Z_]*]]:
1236 func.func @rescale_i8_unsigned_input(%arg0 : tensor<2xi8>) -> () {
1244 // CHECK-DAG: [[IN32:%.+]] = arith.extui [[IN]]
1245 // CHECK-DAG: [[IN_ZEROED:%.+]] = arith.subi [[IN32]], [[C17]]
1246 // CHECK-DAG: [[SCALED:%.+]] = tosa.apply_scale [[IN_ZEROED]], [[C0]], [[C1]] {double_round = false}
1247 // CHECK-DAG: [[SCALED_ZEROED:%.+]] = arith.addi [[SCALED]], [[C22]]
1248 // CHECK-DAG: [[CMIN:%.+]] = arith.constant -128
1249 // CHECK-DAG: [[CMAX:%.+]] = arith.constant 127
1250 // CHECK-DAG: [[LOWER:%.+]] = arith.maxsi [[CMIN]], [[SCALED_ZEROED]]
1251 // CHECK-DAG: [[BOUNDED:%.+]] = arith.minsi [[CMAX]], [[LOWER]]
1252 // CHECK-DAG: [[TRUNC:%.+]] = arith.trunci [[BOUNDED]]
1254 %0 = tosa.rescale %arg0 {input_zp = 17 : i32, output_zp = 22 : i32, multiplier = array<i32: 19689>, shift = array<i8: 15>, scale32 = false, double_round = false, per_channel = false, input_unsigned = true} : (tensor<2xi8>) -> tensor<2xi8>
1259 // -----
1261 // CHECK: #[[$MAP0:.*]] = affine_map<(d0) -> (d0)>
1263 // CHECK-LABEL: @rescale_per_channel
1264 // CHECK-SAME: (%[[ARG0:[0-9a-zA-Z_]*]]:
1265 func.func @rescale_per_channel(%arg0 : tensor<3xi8>) -> (tensor<3xi8>) {
1274 // CHECK-DAG: [[IN32:%.+]] = arith.extsi [[IN]]
1275 // CHECK-DAG: [[IN_ZEROED:%.+]] = arith.subi [[IN32]], [[C243]]
1276 // CHECK-DAG: [[SCALED:%.+]] = tosa.apply_scale [[IN_ZEROED]], [[MULTIPLIER]], [[SHIFT]] {double_round = false}
1277 // CHECK-DAG: [[SCALED_ZEROED:%.+]] = arith.addi [[SCALED]], [[C252]]
1278 // CHECK-DAG: [[CMIN:%.+]] = arith.constant -128
1279 // CHECK-DAG: [[CMAX:%.+]] = arith.constant 127
1280 // CHECK-DAG: [[LOWER:%.+]] = arith.maxsi [[CMIN]], [[SCALED_ZEROED]]
1281 // CHECK-DAG: [[BOUNDED:%.+]] = arith.minsi [[CMAX]], [[LOWER]]
1282 // CHECK-DAG: [[TRUNC:%.+]] = arith.trunci [[BOUNDED]]
1283 // CHECK-DAG: linalg.yield [[TRUNC]]
1284 %0 = tosa.rescale %arg0 {input_zp = 243 : i32, output_zp = 252 : i32, multiplier = array<i32: 42, 43, 44>, shift = array<i8: 14, 15, 64>, scale32 = false, double_round = false, per_channel = false} : (tensor<3xi8>) -> tensor<3xi8>
1290 // -----
1292 // CHECK-LABEL: @rescaleDoubleRound
1293 func.func @rescaleDoubleRound(%arg0 : tensor<2xi8>) -> (tensor<2xi8>) {
1296 // CHECK-SAME: {double_round = true}
1297 %0 = tosa.rescale %arg0 {input_zp = 243 : i32, output_zp = 252 : i32, multiplier = array<i32: 19689>, shift = array<i8: 33>, scale32 = true, double_round = true, per_channel = false} : (tensor<2xi8>) -> tensor<2xi8>
1301 // CHECK-LABEL: @rescaleUnnecessaryDoubleRound
1302 func.func @rescaleUnnecessaryDoubleRound(%arg0 : tensor<2xi8>) -> (tensor<2xi8>) {
1305 // CHECK-SAME: {double_round = false}
1306 %0 = tosa.rescale %arg0 {input_zp = 243 : i32, output_zp = 252 : i32, multiplier = array<i32: 19689>, shift = array<i8: 15>, scale32 = true, double_round = true, per_channel = false} : (tensor<2xi8>) -> tensor<2xi8>
1310 // -----
1312 // CHECK: #[[$MAP0:.*]] = affine_map<(d0, d1) -> (d0, d1)>
1314 // CHECK-LABEL: @reverse
1315 // CHECK-SAME: (%[[ARG0:[0-9a-zA-Z_]*]]:
1316 func.func @reverse(%arg0: tensor<5x4xi32>) -> () {
1321 // CHECK-DAG: %[[I0:.+]] = linalg.index 0
1322 // CHECK-DAG: %[[I1:.+]] = linalg.index 1
1323 // CHECK-DAG: %[[SUB1:.+]] = arith.constant 1
1324 // CHECK-DAG: %[[RDIM_MINUS_C1:.+]] = arith.subi %[[RDIM]], %[[SUB1]]
1325 // CHECK-DAG: %[[READ_DIM:.+]] = arith.subi %[[RDIM_MINUS_C1]], %[[I0]]
1326 // CHECK-DAG: %[[EXTRACT:.+]] = tensor.extract %arg0[%[[READ_DIM]], %[[I1]]] : tensor<5x4xi32>
1328 %0 = tosa.reverse %arg0 {axis = 0 : i32} : (tensor<5x4xi32>) -> tensor<5x4xi32>
1334 // CHECK-DAG: %[[I0:.+]] = linalg.index 0
1335 // CHECK-DAG: %[[I1:.+]] = linalg.index 1
1336 // CHECK-DAG: %[[SUB1:.+]] = arith.constant 1
1337 // CHECK-DAG: %[[RDIM_MINUS_C1:.+]] = arith.subi %[[RDIM]], %[[SUB1]]
1338 // CHECK-DAG: %[[READ_DIM:.+]] = arith.subi %[[RDIM_MINUS_C1]], %[[I1]]
1339 // CHECK-DAG: %[[EXTRACT:.+]] = tensor.extract %arg0[%[[I0]], %[[READ_DIM]]] : tensor<5x4xi32>
1341 %1 = tosa.reverse %arg0 {axis = 1 : i32} : (tensor<5x4xi32>) -> tensor<5x4xi32>
1345 // -----
1347 // CHECK: #[[$MAP0:.*]] = affine_map<(d0) -> (d0)>
1349 // CHECK-LABEL: @reverse_dyn
1350 // CHECK-SAME: (%[[ARG0:[0-9a-zA-Z_]*]]:
1351 func.func @reverse_dyn(%arg0: tensor<?xi32>) -> () {
1358 // CHECK-DAG: %[[I0:.+]] = linalg.index 0
1359 // CHECK-DAG: %[[SUB1:.+]] = arith.constant 1
1360 // CHECK-DAG: %[[RDIM_MINUS_C1:.+]] = arith.subi %[[D0_2]], %[[SUB1]]
1361 // CHECK-DAG: %[[READ_DIM:.+]] = arith.subi %[[RDIM_MINUS_C1]], %[[I0]]
1362 // CHECK-DAG: %[[EXTRACT:.+]] = tensor.extract %arg0[%[[READ_DIM]]] : tensor<?xi32>
1364 %0 = tosa.reverse %arg0 {axis = 0 : i32} : (tensor<?xi32>) -> tensor<?xi32>
1368 // -----
1370 // CHECK-DAG: #[[$MAP0:.*]] = affine_map<(d0, d1, d2, d3) -> (d1, d3)>
1371 // CHECK-DAG: #[[$MAP1:.*]] = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)>
1373 // CHECK-LABEL: @tile
1374 // CHECK-SAME: %[[ARG0:.+]]: tensor<2x3xi8>
1375 func.func @tile(%arg0 : tensor<2x3xi8>) -> () {
1378 // CHECK: ^bb0(%[[ARG1:[0-9a-zA-Z_]+]]: i8
1381 %cst21 = tosa.const_shape { value = dense<[2, 1]> : tensor<2xindex> } : () -> !tosa.shape<2>
1382 %0 = tosa.tile %arg0, %cst21: (tensor<2x3xi8>, !tosa.shape<2>) -> tensor<4x3xi8>
1386 // CHECK: ^bb0(%[[ARG1:[0-9a-zA-Z_]+]]: i8
1389 %cst12 = tosa.const_shape { value = dense<[1, 2]> : tensor<2xindex> } : () -> !tosa.shape<2>
1390 %1 = tosa.tile %arg0, %cst12: (tensor<2x3xi8>, !tosa.shape<2>) -> tensor<2x6xi8>
1394 // CHECK: ^bb0(%[[ARG1:[0-9a-zA-Z_]+]]: i8
1397 %cst57 = tosa.const_shape { value = dense<[5, 7]> : tensor<2xindex> } : () -> !tosa.shape<2>
1398 %2 = tosa.tile %arg0, %cst57: (tensor<2x3xi8>, !tosa.shape<2>) -> tensor<10x21xi8>
1403 // -----
1405 // CHECK-DAG: #[[$MAP0:.*]] = affine_map<(d0, d1, d2, d3) -> (d1, d3)>
1406 // CHECK-DAG: #[[$MAP1:.*]] = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)>
1408 // CHECK-LABEL: @tile_dyn_input
1409 // CHECK-SAME: (%[[ARG0:[0-9a-zA-Z_]*]]:
1410 func.func @tile_dyn_input(%arg0 : tensor<?x3xi8>) -> () {
1417 // CHECK: tosa.reshape %[[GENERIC]] {new_shape = array<i64: -9223372036854775808, 3>}
1418 %cst21 = tosa.const_shape { value = dense<[2, 1]> : tensor<2xindex> } : () -> !tosa.shape<2>
1419 %0 = tosa.tile %arg0, %cst21: (tensor<?x3xi8>, !tosa.shape<2>) -> tensor<?x3xi8>
1424 // -----
1426 // CHECK-DAG: #[[$MAP0:.*]] = affine_map<(d0, d1, d2, d3) -> (d1, d3)>
1427 // CHECK-DAG: #[[$MAP1:.*]] = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)>
1429 // CHECK-LABEL: @tile_dyn_multiples
1430 // CHECK-SAME: (%[[ARG0:[0-9a-zA-Z_]*]]:
1431 func.func @tile_dyn_multiples(%arg0 : tensor<2x3xi8>) -> () {
1438 // CHECK: tosa.reshape %[[GENERIC]] {new_shape = array<i64: 2, -9223372036854775808>}
1439 %cst = tosa.const_shape { value = dense<[2, -1]> : tensor<2xindex> } : () -> !tosa.shape<2>
1440 %0 = tosa.tile %arg0, %cst: (tensor<2x3xi8>, !tosa.shape<2>) -> tensor<2x?xi8>
1445 // -----
1447 // CHECK: #[[$MAP0:.*]] = affine_map<(d0, d1) -> (d0, d1)>
1448 // CHECK: #[[$MAP1:.*]] = affine_map<(d0, d1) -> (d1)>
1449 // CHECK: #[[$MAP2:.*]] = affine_map<(d0, d1) -> (d0)>
1450 // CHECK: #[[$MAP3:.*]] = affine_map<(d0) -> (d0)>
1451 // CHECK: #[[$MAP4:.*]] = affine_map<(d0) -> ()>
1453 func.func @argmax(%arg0 : tensor<3x2xi32>, %arg1 : tensor<6xf32>) -> () {
1458 // CHECK: [[VAL_MIN:%.+]] = arith.constant -2147483648
1461 // CHECK: ^bb0(%[[ARG1:[0-9a-zA-Z_]+]]: i32, %[[ARG2:[0-9a-zA-Z_]+]]: i32, %[[ARG3:[0-9a-zA-Z_]+]]: i32
1468 %0 = tosa.argmax %arg0 { axis = 0 : i32} : (tensor<3x2xi32>) -> tensor<2xi32>
1474 // CHECK: [[VAL_MIN:%.+]] = arith.constant -2147483648
1477 // CHECK: ^bb0(%[[ARG1:[0-9a-zA-Z_]+]]: i32, %[[ARG2:[0-9a-zA-Z_]+]]: i32, %[[ARG3:[0-9a-zA-Z_]+]]: i32
1484 %1 = tosa.argmax %arg0 { axis = 1 : i32} : (tensor<3x2xi32>) -> tensor<3xi32>
1486 // CHECK: arith.constant -3.40282347E+38 : f32
1493 %2 = tosa.argmax %arg1 { axis = 0 : i32} : (tensor<6xf32>) -> tensor<i32>
1498 // -----
1500 // CHECK: #[[$MAP0:.*]] = affine_map<(d0, d1) -> (d0, d1)>
1501 // CHECK: #[[$MAP1:.*]] = affine_map<(d0, d1) -> (d1)>
1503 func.func @argmax_dyn_non_axis(%arg0 : tensor<3x?xi32>) -> () {
1510 // CHECK: %[[VAL_MIN:.+]] = arith.constant -2147483648
1513 // CHECK: ^bb0(%[[ARG1:[0-9a-zA-Z_]+]]: i32, %[[ARG2:[0-9a-zA-Z_]+]]: i32, %[[ARG3:[0-9a-zA-Z_]+]]: i32
1520 %0 = tosa.argmax %arg0 { axis = 0 : i32} : (tensor<3x?xi32>) -> tensor<?xi32>
1524 // -----
1526 // CHECK: #[[$MAP0:.*]] = affine_map<(d0, d1) -> (d0, d1)>
1527 // CHECK: #[[$MAP1:.*]] = affine_map<(d0, d1) -> (d0)>
1529 func.func @argmax_dyn_axis(%arg0 : tensor<3x?xi32>) -> () {
1534 // CHECK: %[[VAL_MIN:.+]] = arith.constant -2147483648
1543 %0 = tosa.argmax %arg0 { axis = 1 : i32} : (tensor<3x?xi32>) -> tensor<3xi32>
1547 // -----
1549 // CHECK-LABEL: @gather_float
1550 // CHECK-SAME: (%[[ARG0:[0-9a-zA-Z_]*]]
1551 // CHECK-SAME: %[[ARG1:[0-9a-zA-Z_]*]]
1552 func.func @gather_float(%arg0: tensor<2x3x2xf32>, %arg1: tensor<2x3xi32>) -> () {
1561 %0 = tosa.gather %arg0, %arg1 : (tensor<2x3x2xf32>, tensor<2x3xi32>) -> tensor<2x3x2xf32>
1565 // -----
1567 // CHECK-LABEL: @gather_float_dyn
1568 // CHECK-SAME: (%[[ARG0:[0-9a-zA-Z_]*]]
1569 // CHECK-SAME: %[[ARG1:[0-9a-zA-Z_]*]]
1570 func.func @gather_float_dyn(%arg0: tensor<?x3x2xf32>, %arg1: tensor<?x3xi32>) -> () {
1572 // CHECK: %[[BATCH:.+]] = tensor.dim %[[ARG0]], %[[C0]]
1573 // CHECK: %[[INIT:.+]] = tensor.empty(%[[BATCH]])
1581 %0 = tosa.gather %arg0, %arg1 : (tensor<?x3x2xf32>, tensor<?x3xi32>) -> tensor<?x3x2xf32>
1585 // -----
1587 // CHECK-LABEL: @gather_float_all_dynamic
1588 // CHECK-SAME: (%[[ARG0:[0-9a-zA-Z_]*]]
1589 // CHECK-SAME: %[[ARG1:[0-9a-zA-Z_]*]]
1590 func.func @gather_float_all_dynamic(%arg0: tensor<?x?x?xf32>, %arg1: tensor<?x?xi32>) -> () {
1592 // CHECK: %[[BATCH:.+]] = tensor.dim %[[ARG0]], %[[C0]]
1597 // CHECK: %[[INIT:.+]] = tensor.empty(%[[BATCH]], %[[INDEX]], %[[CHANNEL]])
1605 %0 = tosa.gather %arg0, %arg1 : (tensor<?x?x?xf32>, tensor<?x?xi32>) -> tensor<?x?x?xf32>
1609 // -----
1611 // CHECK-LABEL: @gather_int
1612 // CHECK-SAME: (%[[ARG0:[0-9a-zA-Z_]*]]
1613 // CHECK-SAME: %[[ARG1:[0-9a-zA-Z_]*]]
1614 func.func @gather_int(%arg0: tensor<2x3x2xi32>, %arg1: tensor<2x3xi32>) -> () {
1623 %0 = tosa.gather %arg0, %arg1 : (tensor<2x3x2xi32>, tensor<2x3xi32>) -> tensor<2x3x2xi32>
1627 // -----
1629 // CHECK-LABEL: @table8
1630 // CHECK-SAME: (%[[ARG0:[0-9a-zA-Z_]*]]:
1631 // CHECK-SAME: %[[ARG1:[0-9a-zA-Z_]*]]:
1632 func.func @table8(%arg0: tensor<6xi8>, %arg1: tensor<512xi8>) -> () {
1641 %0 = tosa.table %arg0, %arg1 : (tensor<6xi8>, tensor<512xi8>) -> tensor<6xi8>
1645 // -----
1647 // CHECK-LABEL: @table16
1648 // CHECK-SAME: (%[[ARG0:[0-9a-zA-Z_]*]]:
1649 // CHECK-SAME: %[[ARG1:[0-9a-zA-Z_]*]]:
1650 func.func @table16(%arg0: tensor<6xi16>, %arg1: tensor<513xi16>) -> () {
1674 %0 = tosa.table %arg0, %arg1 : (tensor<6xi16>, tensor<513xi16>) -> tensor<6xi32>
1678 // -----
1680 // CHECK-LABEL: @table8_dyn
1681 // CHECK-SAME: (%[[ARG0:[0-9a-zA-Z_]*]]:
1682 // CHECK-SAME: %[[ARG1:[0-9a-zA-Z_]*]]:
1683 func.func @table8_dyn(%arg0: tensor<?xi8>, %arg1: tensor<512xi8>) -> () {
1694 %0 = tosa.table %arg0, %arg1 : (tensor<?xi8>, tensor<512xi8>) -> tensor<?xi8>
1698 // -----
1700 // CHECK-LABEL: @table8_dyn_table
1701 // CHECK-SAME: (%[[ARG0:[0-9a-zA-Z_]*]]:
1702 // CHECK-SAME: %[[ARG1:[0-9a-zA-Z_]*]]:
1703 func.func @table8_dyn_table(%arg0: tensor<6xi8>, %arg1: tensor<?xi8>) -> () {
1712 %0 = tosa.table %arg0, %arg1 : (tensor<6xi8>, tensor<?xi8>) -> tensor<6xi8>
1716 // -----
1717 // NOTE: Assertions have been autogenerated by utils/generate-test-checks.py
1718 // CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2, d3, d4) -> (d0, d3, d4)>
1719 // CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2, d3, d4) -> (d0, d1, d2)>
1721 // CHECK-LABEL: func.func @test_static_rfft2d(
1722 // CHECK-SAME: %[[VAL_0:.*]]: tensor<5x5x8xf32>) -> (tensor<5x5x5xf32>, tensor<5x5x5xf32>) {
1730 // CHECK: %[[VAL_8:.*]] = linalg.fill ins(%[[VAL_7]] : f32) outs(%[[VAL_6]] : tensor<5x5x5xf32>) -> tensor<5x5x5xf32>
1733 // CHECK: %[[VAL_11:.*]] = linalg.fill ins(%[[VAL_10]] : f32) outs(%[[VAL_9]] : tensor<5x5x5xf32>) -> tensor<5x5x5xf32>
1768 // CHECK: } -> (tensor<5x5x5xf32>, tensor<5x5x5xf32>)
1771 func.func @test_static_rfft2d(%arg0: tensor<5x5x8xf32>) -> (tensor<5x5x5xf32>, tensor<5x5x5xf32>) {
1772 %output_real, %output_imag = "tosa.rfft2d"(%arg0) {} : (tensor<5x5x8xf32>) -> (tensor<5x5x5xf32>, tensor<5x5x5xf32>)
1776 // -----
1777 // NOTE: Assertions have been autogenerated by utils/generate-test-checks.py
1778 // CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2, d3, d4) -> (d0, d3, d4)>
1779 // CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2, d3, d4) -> (d0, d1, d2)>
1781 // CHECK-LABEL: func.func @test_dynamic_rfft2d(
1782 // CHECK-SAME: %[[VAL_0:.*]]: tensor<?x?x?xf32>) -> (tensor<?x?x?xf32>, tensor<?x?x?xf32>) {
1795 // CHECK: %[[VAL_13:.*]] = linalg.fill ins(%[[VAL_12]] : f32) outs(%[[VAL_11]] : tensor<?x?x?xf32>) -> tensor<?x?x?xf32>
1798 // CHECK: %[[VAL_16:.*]] = linalg.fill ins(%[[VAL_15]] : f32) outs(%[[VAL_14]] : tensor<?x?x?xf32>) -> tensor<?x?x?xf32>
1833 // CHECK: } -> (tensor<?x?x?xf32>, tensor<?x?x?xf32>)
1836 func.func @test_dynamic_rfft2d(%arg0: tensor<?x?x?xf32>) -> (tensor<?x?x?xf32>, tensor<?x?x?xf32>) {
1837 %output_real, %output_imag = "tosa.rfft2d"(%arg0) {} : (tensor<?x?x?xf32>) -> (tensor<?x?x?xf32>, tensor<?x?x?xf32>)
1841 // -----
1842 // NOTE: Assertions have been autogenerated by utils/generate-test-checks.py
1843 // CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2, d3, d4) -> (d0, d3, d4)>
1844 // CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2, d3, d4) -> (d0, d1, d2)>
1846 // CHECK-LABEL: func.func @test_static_fft2d(
1847 // CHECK-SAME: %[[VAL_0:.*]]: tensor<8x8x8xf32>,
1848 // CHECK-SAME: %[[VAL_1:.*]]: tensor<8x8x8xf32>) -> (tensor<8x8x8xf32>, tensor<8x8x8xf32>) {
1851 // CHECK: %[[VAL_4:.*]] = linalg.fill ins(%[[VAL_3]] : f32) outs(%[[VAL_2]] : tensor<8x8x8xf32>) -> tensor<8x8x8xf32>
1854 // CHECK: %[[VAL_7:.*]] = linalg.fill ins(%[[VAL_6]] : f32) outs(%[[VAL_5]] : tensor<8x8x8xf32>) -> tensor<8x8x8xf32>
1893 // CHECK: } -> (tensor<8x8x8xf32>, tensor<8x8x8xf32>)
1896 func.func @test_static_fft2d(%arg0: tensor<8x8x8xf32>, %arg1: tensor<8x8x8xf32>) -> (tensor<8x8x8xf32>, tensor<8x8x8xf32>) {
1897 %output_real, %output_imag = "tosa.fft2d"(%arg0, %arg1) {inverse=false} : (tensor<8x8x8xf32>, tensor<8x8x8xf32>) -> (tensor<8x8x8xf32>, tensor<8x8x8xf32>)
1901 // -----
1902 // NOTE: Assertions have been autogenerated by utils/generate-test-checks.py
1903 // CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2, d3, d4) -> (d0, d3, d4)>
1904 // CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2, d3, d4) -> (d0, d1, d2)>
1906 // CHECK-LABEL: func.func @test_dynamic_fft2d(
1907 // CHECK-SAME: %[[VAL_0:.*]]: tensor<?x?x?xf32>,
1908 // CHECK-SAME: %[[VAL_1:.*]]: tensor<?x?x?xf32>) -> (tensor<?x?x?xf32>, tensor<?x?x?xf32>) {
1917 // CHECK: %[[VAL_10:.*]] = linalg.fill ins(%[[VAL_9]] : f32) outs(%[[VAL_8]] : tensor<?x?x?xf32>) -> tensor<?x?x?xf32>
1920 // CHECK: %[[VAL_13:.*]] = linalg.fill ins(%[[VAL_12]] : f32) outs(%[[VAL_11]] : tensor<?x?x?xf32>) -> tensor<?x?x?xf32>
1948 // CHECK: %[[VAL_44:.*]] = arith.constant -1.000000e+00 : f32
1961 // CHECK: } -> (tensor<?x?x?xf32>, tensor<?x?x?xf32>)
1964 func.func @test_dynamic_fft2d(%arg0: tensor<?x?x?xf32>, %arg1: tensor<?x?x?xf32>) -> (tensor<?x?x?xf32>, tensor<?x?x?xf32>) {
1965 %output_real, %output_imag = "tosa.fft2d"(%arg0, %arg1) {inverse = true} : (tensor<?x?x?xf32>, tensor<?x?x?xf32>) -> (tensor<?x?x?xf32>, tensor<?x?x?xf32>)
1970 // -----
1972 // CHECK: #[[$MAP0:.+]] = affine_map<(d0) -> (d0)>
1974 // CHECK-LABEL: func.func @test_cast_fp32_i64(
1975 // CHECK-SAME: %[[ARG0:.*]]: tensor<1xf32>) -> tensor<1xi64> {
1980 // CHECK: %[[FP_INT_MIN:.*]] = arith.constant -9.22337203E+18 : f32
1988 // CHECK: } -> tensor<1xi64>
1990 func.func @test_cast_fp32_i64(%arg0: tensor<1xf32>) -> (tensor<1xi64>) {
1991 %0 = tosa.cast %arg0 : (tensor<1xf32>) -> tensor<1xi64>