@@ -638,18 +638,22 @@ func.func @transpose_canonicalize_strip_quant() -> (tensor<2x1x3x!quant.uniform<
638
638
639
639
// CHECK-LABEL: @slice_fold
640
640
func.func @slice_fold (%arg0: tensor <3 x4 xf32 >) -> tensor <3 x4 xf32 > {
641
+ %0 = tosa.const_shape {value = dense <[0 , 0 ]> : tensor <2 xindex >} : () -> !tosa.shape <2 >
642
+ %1 = tosa.const_shape {value = dense <[3 , 4 ]> : tensor <2 xindex >} : () -> !tosa.shape <2 >
641
643
// CHECK: return %arg0
642
- %0 = tosa.slice %arg0 { size = array< i64 : 3 , 4 >, start = array< i64 : 0 , 0 >}: ( tensor < 3 x 4 x f32 >) -> tensor <3 x4 xf32 >
643
- return %0 : tensor <3 x4 xf32 >
644
+ %3 = tosa.slice %arg0 , %0 , %1 : ( tensor < 3 x 4 x f32 >, !tosa.shape < 2 >, !tosa.shape < 2 >) -> tensor <3 x4 xf32 >
645
+ return %3 : tensor <3 x4 xf32 >
644
646
}
645
647
646
648
// -----
647
649
648
650
// CHECK-LABEL: @slice_nofold
649
651
func.func @slice_nofold (%arg0: tensor <?x4 xf32 >) -> tensor <?x4 xf32 > {
652
+ %0 = tosa.const_shape {value = dense <[0 , 0 ]> : tensor <2 xindex >} : () -> !tosa.shape <2 >
653
+ %1 = tosa.const_shape {value = dense <[3 , 4 ]> : tensor <2 xindex >} : () -> !tosa.shape <2 >
650
654
// CHECK: tosa.slice
651
- %0 = tosa.slice %arg0 { size = array< i64 : 3 , 4 >, start = array< i64 : 0 , 0 >}: (tensor <?x4 xf32 >) -> tensor <?x4 xf32 >
652
- return %0 : tensor <?x4 xf32 >
655
+ %3 = tosa.slice %arg0 , %0 , %1 : (tensor <?x4 xf32 >, !tosa.shape < 2 >, !tosa.shape < 2 >) -> tensor <?x4 xf32 >
656
+ return %3 : tensor <?x4 xf32 >
653
657
}
654
658
655
659
// -----
@@ -729,9 +733,12 @@ func.func @fold_resize_bilinear(%arg0 : tensor<1x15x13x1xi8>) -> tensor<1x15x13x
729
733
// CHECK: return %[[VAL_0]], %[[VAL_1]] : tensor<1x12x12x1xf32>, tensor<1x12x12x1xf32>
730
734
func.func @canonicalize_concat_slice_final_axis (%arg0 : tensor <1 x12 x12 x1 xf32 >, %arg1 : tensor <1 x12 x12 x1 xf32 >) -> (tensor <1 x12 x12 x1 xf32 >, tensor <1 x12 x12 x1 xf32 >) {
731
735
%0 = tosa.concat %arg0 , %arg1 {axis = 3 : i32 } : (tensor <1 x12 x12 x1 xf32 >, tensor <1 x12 x12 x1 xf32 >) -> tensor <1 x12 x12 x2 xf32 >
732
- %1 = tosa.slice %0 {size = array<i64 : 1 , 12 , 12 , 1 >, start = array<i64 : 0 , 0 , 0 , 0 >} : (tensor <1 x12 x12 x2 xf32 >) -> tensor <1 x12 x12 x1 xf32 >
733
- %2 = tosa.slice %0 {size = array<i64 : 1 , 12 , 12 , 1 >, start = array<i64 : 0 , 0 , 0 , 1 >} : (tensor <1 x12 x12 x2 xf32 >) -> tensor <1 x12 x12 x1 xf32 >
734
- return %1 , %2 : tensor <1 x12 x12 x1 xf32 >, tensor <1 x12 x12 x1 xf32 >
736
+ %1 = tosa.const_shape {value = dense <[0 , 0 , 0 , 0 ]> : tensor <4 xindex >} : () -> !tosa.shape <4 >
737
+ %2 = tosa.const_shape {value = dense <[0 , 0 , 0 , 1 ]> : tensor <4 xindex >} : () -> !tosa.shape <4 >
738
+ %3 = tosa.const_shape {value = dense <[1 , 12 , 12 , 1 ]> : tensor <4 xindex >} : () -> !tosa.shape <4 >
739
+ %4 = tosa.slice %0 , %1 , %3 : (tensor <1 x12 x12 x2 xf32 >, !tosa.shape <4 >, !tosa.shape <4 >) -> tensor <1 x12 x12 x1 xf32 >
740
+ %5 = tosa.slice %0 , %2 , %3 : (tensor <1 x12 x12 x2 xf32 >, !tosa.shape <4 >, !tosa.shape <4 >) -> tensor <1 x12 x12 x1 xf32 >
741
+ return %4 , %5 : tensor <1 x12 x12 x1 xf32 >, tensor <1 x12 x12 x1 xf32 >
735
742
}
736
743
737
744
// -----
@@ -741,38 +748,56 @@ func.func @canonicalize_concat_slice_final_axis(%arg0 : tensor<1x12x12x1xf32>, %
741
748
// CHECK: return %[[VAL_0]], %[[VAL_1]] : tensor<1x12x12xf32>, tensor<1x12x12xf32>
742
749
func.func @canonicalize_concat_slice_middle_axis (%arg0 : tensor <1 x12 x12 xf32 >, %arg1 : tensor <1 x12 x12 xf32 >) -> (tensor <1 x12 x12 xf32 >, tensor <1 x12 x12 xf32 >) {
743
750
%0 = tosa.concat %arg0 , %arg1 {axis = 1 : i32 } : (tensor <1 x12 x12 xf32 >, tensor <1 x12 x12 xf32 >) -> tensor <1 x24 x12 xf32 >
744
- %1 = tosa.slice %0 {size = array<i64 : 1 , 12 , 12 >, start = array<i64 : 0 , 0 , 0 >} : (tensor <1 x24 x12 xf32 >) -> tensor <1 x12 x12 xf32 >
745
- %2 = tosa.slice %0 {size = array<i64 : 1 , 12 , 12 >, start = array<i64 : 0 , 12 , 0 >} : (tensor <1 x24 x12 xf32 >) -> tensor <1 x12 x12 xf32 >
746
- return %1 , %2 : tensor <1 x12 x12 xf32 >, tensor <1 x12 x12 xf32 >
751
+ %1 = tosa.const_shape {value = dense <[0 , 0 , 0 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
752
+ %2 = tosa.const_shape {value = dense <[0 , 12 , 0 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
753
+ %3 = tosa.const_shape {value = dense <[1 , 12 , 12 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
754
+ %4 = tosa.slice %0 , %1 , %3 : (tensor <1 x24 x12 xf32 >, !tosa.shape <3 >, !tosa.shape <3 >) -> tensor <1 x12 x12 xf32 >
755
+ %5 = tosa.slice %0 , %2 , %3 : (tensor <1 x24 x12 xf32 >, !tosa.shape <3 >, !tosa.shape <3 >) -> tensor <1 x12 x12 xf32 >
756
+ return %4 , %5 : tensor <1 x12 x12 xf32 >, tensor <1 x12 x12 xf32 >
747
757
}
748
758
749
759
// -----
750
760
751
761
// CHECK-LABEL: @canonicalize_cross_concat_inputs
752
762
// CHECK-SAME: %[[VAL_0:.*]]: tensor<1x12x12xf32>, %[[VAL_1:.*]]: tensor<1x12x12xf32>
753
- // CHECK: %[[VAL_2:.*]] = tosa.concat %[[VAL_0]], %[[VAL_1]] {axis = 2 : i32} : (tensor<1x12x12xf32>, tensor<1x12x12xf32>) -> tensor<1x12x24xf32>
754
- // CHECK: %[[VAL_3:.*]] = tosa.slice %[[VAL_2]] {size = array<i64: 1, 12, 15>, start = array<i64: 0, 0, 0>} : (tensor<1x12x24xf32>) -> tensor<1x12x15xf32>
755
- // CHECK: %[[VAL_4:.*]] = tosa.slice %[[VAL_2]] {size = array<i64: 1, 12, 20>, start = array<i64: 0, 0, 4>} : (tensor<1x12x24xf32>) -> tensor<1x12x20xf32>
756
- // CHECK: return %[[VAL_3]], %[[VAL_4]] : tensor<1x12x15xf32>, tensor<1x12x20xf32>
763
+ // CHECK-DAG: %[[VAL_2:.*]] = tosa.const_shape {value = dense<[1, 12, 20]> : tensor<3xindex>}
764
+ // CHECK-DAG: %[[VAL_3:.*]] = tosa.const_shape {value = dense<[1, 12, 15]> : tensor<3xindex>}
765
+ // CHECK-DAG: %[[VAL_4:.*]] = tosa.const_shape {value = dense<[0, 0, 4]> : tensor<3xindex>}
766
+ // CHECK-DAG: %[[VAL_5:.*]] = tosa.const_shape {value = dense<0> : tensor<3xindex>}
767
+ // CHECK: %[[VAL_6:.*]] = tosa.concat %[[VAL_0]], %[[VAL_1]] {axis = 2 : i32} : (tensor<1x12x12xf32>, tensor<1x12x12xf32>) -> tensor<1x12x24xf32>
768
+ // CHECK: %[[VAL_7:.*]] = tosa.slice %[[VAL_6]], %[[VAL_5]], %[[VAL_3]]
769
+ // CHECK: %[[VAL_8:.*]] = tosa.slice %[[VAL_6]], %[[VAL_4]], %[[VAL_2]]
770
+ // CHECK: return %[[VAL_7]], %[[VAL_8]] : tensor<1x12x15xf32>, tensor<1x12x20xf32>
757
771
func.func @canonicalize_cross_concat_inputs (%arg0 : tensor <1 x12 x12 xf32 >, %arg1 : tensor <1 x12 x12 xf32 >) -> (tensor <1 x12 x15 xf32 >, tensor <1 x12 x20 xf32 >) {
758
772
%0 = tosa.concat %arg0 , %arg1 {axis = 2 : i32 } : (tensor <1 x12 x12 xf32 >, tensor <1 x12 x12 xf32 >) -> tensor <1 x12 x24 xf32 >
759
- %1 = tosa.slice %0 {size = array<i64 : 1 , 12 , 15 >, start = array<i64 : 0 , 0 , 0 >} : (tensor <1 x12 x24 xf32 >) -> tensor <1 x12 x15 xf32 >
760
- %2 = tosa.slice %0 {size = array<i64 : 1 , 12 , 20 >, start = array<i64 : 0 , 0 , 4 >} : (tensor <1 x12 x24 xf32 >) -> tensor <1 x12 x20 xf32 >
761
- return %1 , %2 : tensor <1 x12 x15 xf32 >, tensor <1 x12 x20 xf32 >
773
+ %1 = tosa.const_shape {value = dense <[0 , 0 , 0 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
774
+ %2 = tosa.const_shape {value = dense <[0 , 0 , 4 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
775
+ %3 = tosa.const_shape {value = dense <[1 , 12 , 15 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
776
+ %4 = tosa.const_shape {value = dense <[1 , 12 , 20 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
777
+ %5 = tosa.slice %0 , %1 , %3 : (tensor <1 x12 x24 xf32 >, !tosa.shape <3 >, !tosa.shape <3 >) -> tensor <1 x12 x15 xf32 >
778
+ %6 = tosa.slice %0 , %2 , %4 : (tensor <1 x12 x24 xf32 >, !tosa.shape <3 >, !tosa.shape <3 >) -> tensor <1 x12 x20 xf32 >
779
+ return %5 , %6 : tensor <1 x12 x15 xf32 >, tensor <1 x12 x20 xf32 >
762
780
}
763
781
764
782
// -----
765
783
766
784
// CHECK-LABEL: @canonicalize_concat_slice_on_non_concat_axis
767
785
// CHECK-SAME: %[[VAL_0:.*]]: tensor<1x12x12xf32>, %[[VAL_1:.*]]: tensor<1x12x12xf32>
768
- // CHECK: %[[VAL_2:.*]] = tosa.slice %[[VAL_0]] {size = array<i64: 1, 6, 12>, start = array<i64: 0, 0, 0>} : (tensor<1x12x12xf32>) -> tensor<1x6x12xf32>
769
- // CHECK: %[[VAL_3:.*]] = tosa.slice %[[VAL_1]] {size = array<i64: 1, 3, 12>, start = array<i64: 1, 3, 0>} : (tensor<1x12x12xf32>) -> tensor<1x3x12xf32>
770
- // CHECK: return %[[VAL_2]], %[[VAL_3]] : tensor<1x6x12xf32>, tensor<1x3x12xf32>
786
+ // CHECK-DAG: %[[VAL_2:.*]] = tosa.const_shape {value = dense<[1, 3, 0]> : tensor<3xindex>}
787
+ // CHECK-DAG: %[[VAL_3:.*]] = tosa.const_shape {value = dense<[1, 3, 12]> : tensor<3xindex>}
788
+ // CHECK-DAG: %[[VAL_4:.*]] = tosa.const_shape {value = dense<0> : tensor<3xindex>}
789
+ // CHECK-DAG: %[[VAL_5:.*]] = tosa.const_shape {value = dense<[1, 6, 12]> : tensor<3xindex>}
790
+ // CHECK: %[[VAL_6:.*]] = tosa.slice %[[VAL_0]], %[[VAL_4]], %[[VAL_5]]
791
+ // CHECK: %[[VAL_7:.*]] = tosa.slice %[[VAL_1]], %[[VAL_2]], %[[VAL_3]]
792
+ // CHECK: return %[[VAL_6]], %[[VAL_7]] : tensor<1x6x12xf32>, tensor<1x3x12xf32>
771
793
func.func @canonicalize_concat_slice_on_non_concat_axis (%arg0 : tensor <1 x12 x12 xf32 >, %arg1 : tensor <1 x12 x12 xf32 >) -> (tensor <1 x6 x12 xf32 >, tensor <1 x3 x12 xf32 >) {
772
794
%0 = tosa.concat %arg0 , %arg1 {axis = 2 : i32 } : (tensor <1 x12 x12 xf32 >, tensor <1 x12 x12 xf32 >) -> tensor <1 x12 x24 xf32 >
773
- %1 = tosa.slice %0 {size = array<i64 : 1 , 6 , 12 >, start = array<i64 : 0 , 0 , 0 >} : (tensor <1 x12 x24 xf32 >) -> tensor <1 x6 x12 xf32 >
774
- %2 = tosa.slice %0 {size = array<i64 : 1 , 3 , 12 >, start = array<i64 : 1 , 3 , 12 >} : (tensor <1 x12 x24 xf32 >) -> tensor <1 x3 x12 xf32 >
775
- return %1 , %2 : tensor <1 x6 x12 xf32 >, tensor <1 x3 x12 xf32 >
795
+ %1 = tosa.const_shape {value = dense <[0 , 0 , 0 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
796
+ %2 = tosa.const_shape {value = dense <[1 , 6 , 12 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
797
+ %3 = tosa.const_shape {value = dense <[1 , 3 , 12 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
798
+ %4 = tosa.slice %0 , %1 , %2 : (tensor <1 x12 x24 xf32 >, !tosa.shape <3 >, !tosa.shape <3 >) -> tensor <1 x6 x12 xf32 >
799
+ %5 = tosa.slice %0 , %3 , %3 : (tensor <1 x12 x24 xf32 >, !tosa.shape <3 >, !tosa.shape <3 >) -> tensor <1 x3 x12 xf32 >
800
+ return %4 , %5 : tensor <1 x6 x12 xf32 >, tensor <1 x3 x12 xf32 >
776
801
}
777
802
778
803
// -----
0 commit comments