@@ -624,18 +624,22 @@ func.func @transpose_canonicalize_strip_quant() -> (tensor<2x1x3x!quant.uniform<
624
624
625
625
// CHECK-LABEL: @slice_fold
626
626
func.func @slice_fold (%arg0: tensor <3 x4 xf32 >) -> tensor <3 x4 xf32 > {
627
+ %0 = tosa.const_shape {value = dense <[0 , 0 ]> : tensor <2 xindex >} : () -> !tosa.shape <2 >
628
+ %1 = tosa.const_shape {value = dense <[3 , 4 ]> : tensor <2 xindex >} : () -> !tosa.shape <2 >
627
629
// CHECK: return %arg0
628
- %0 = tosa.slice %arg0 { size = array< i64 : 3 , 4 >, start = array< i64 : 0 , 0 >}: ( tensor < 3 x 4 x f32 >) -> tensor <3 x4 xf32 >
629
- return %0 : tensor <3 x4 xf32 >
630
+ %3 = tosa.slice %arg0 , %0 , %1 : ( tensor < 3 x 4 x f32 >, !tosa.shape < 2 >, !tosa.shape < 2 >) -> tensor <3 x4 xf32 >
631
+ return %3 : tensor <3 x4 xf32 >
630
632
}
631
633
632
634
// -----
633
635
634
636
// CHECK-LABEL: @slice_nofold
635
637
func.func @slice_nofold (%arg0: tensor <?x4 xf32 >) -> tensor <?x4 xf32 > {
638
+ %0 = tosa.const_shape {value = dense <[0 , 0 ]> : tensor <2 xindex >} : () -> !tosa.shape <2 >
639
+ %1 = tosa.const_shape {value = dense <[3 , 4 ]> : tensor <2 xindex >} : () -> !tosa.shape <2 >
636
640
// CHECK: tosa.slice
637
- %0 = tosa.slice %arg0 { size = array< i64 : 3 , 4 >, start = array< i64 : 0 , 0 >}: (tensor <?x4 xf32 >) -> tensor <?x4 xf32 >
638
- return %0 : tensor <?x4 xf32 >
641
+ %3 = tosa.slice %arg0 , %0 , %1 : (tensor <?x4 xf32 >, !tosa.shape < 2 >, !tosa.shape < 2 >) -> tensor <?x4 xf32 >
642
+ return %3 : tensor <?x4 xf32 >
639
643
}
640
644
641
645
// -----
@@ -715,9 +719,12 @@ func.func @fold_resize_bilinear(%arg0 : tensor<1x15x13x1xi8>) -> tensor<1x15x13x
715
719
// CHECK: return %[[VAL_0]], %[[VAL_1]] : tensor<1x12x12x1xf32>, tensor<1x12x12x1xf32>
716
720
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 >) {
717
721
%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 >
718
- %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 >
719
- %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 >
720
- return %1 , %2 : tensor <1 x12 x12 x1 xf32 >, tensor <1 x12 x12 x1 xf32 >
722
+ %1 = tosa.const_shape {value = dense <[0 , 0 , 0 , 0 ]> : tensor <4 xindex >} : () -> !tosa.shape <4 >
723
+ %2 = tosa.const_shape {value = dense <[0 , 0 , 0 , 1 ]> : tensor <4 xindex >} : () -> !tosa.shape <4 >
724
+ %3 = tosa.const_shape {value = dense <[1 , 12 , 12 , 1 ]> : tensor <4 xindex >} : () -> !tosa.shape <4 >
725
+ %4 = tosa.slice %0 , %1 , %3 : (tensor <1 x12 x12 x2 xf32 >, !tosa.shape <4 >, !tosa.shape <4 >) -> tensor <1 x12 x12 x1 xf32 >
726
+ %5 = tosa.slice %0 , %2 , %3 : (tensor <1 x12 x12 x2 xf32 >, !tosa.shape <4 >, !tosa.shape <4 >) -> tensor <1 x12 x12 x1 xf32 >
727
+ return %4 , %5 : tensor <1 x12 x12 x1 xf32 >, tensor <1 x12 x12 x1 xf32 >
721
728
}
722
729
723
730
// -----
@@ -727,38 +734,56 @@ func.func @canonicalize_concat_slice_final_axis(%arg0 : tensor<1x12x12x1xf32>, %
727
734
// CHECK: return %[[VAL_0]], %[[VAL_1]] : tensor<1x12x12xf32>, tensor<1x12x12xf32>
728
735
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 >) {
729
736
%0 = tosa.concat %arg0 , %arg1 {axis = 1 : i32 } : (tensor <1 x12 x12 xf32 >, tensor <1 x12 x12 xf32 >) -> tensor <1 x24 x12 xf32 >
730
- %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 >
731
- %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 >
732
- return %1 , %2 : tensor <1 x12 x12 xf32 >, tensor <1 x12 x12 xf32 >
737
+ %1 = tosa.const_shape {value = dense <[0 , 0 , 0 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
738
+ %2 = tosa.const_shape {value = dense <[0 , 12 , 0 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
739
+ %3 = tosa.const_shape {value = dense <[1 , 12 , 12 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
740
+ %4 = tosa.slice %0 , %1 , %3 : (tensor <1 x24 x12 xf32 >, !tosa.shape <3 >, !tosa.shape <3 >) -> tensor <1 x12 x12 xf32 >
741
+ %5 = tosa.slice %0 , %2 , %3 : (tensor <1 x24 x12 xf32 >, !tosa.shape <3 >, !tosa.shape <3 >) -> tensor <1 x12 x12 xf32 >
742
+ return %4 , %5 : tensor <1 x12 x12 xf32 >, tensor <1 x12 x12 xf32 >
733
743
}
734
744
735
745
// -----
736
746
737
747
// CHECK-LABEL: @canonicalize_cross_concat_inputs
738
748
// CHECK-SAME: %[[VAL_0:.*]]: tensor<1x12x12xf32>, %[[VAL_1:.*]]: tensor<1x12x12xf32>
739
- // CHECK: %[[VAL_2:.*]] = tosa.concat %[[VAL_0]], %[[VAL_1]] {axis = 2 : i32} : (tensor<1x12x12xf32>, tensor<1x12x12xf32>) -> tensor<1x12x24xf32>
740
- // CHECK: %[[VAL_3:.*]] = tosa.slice %[[VAL_2]] {size = array<i64: 1, 12, 15>, start = array<i64: 0, 0, 0>} : (tensor<1x12x24xf32>) -> tensor<1x12x15xf32>
741
- // CHECK: %[[VAL_4:.*]] = tosa.slice %[[VAL_2]] {size = array<i64: 1, 12, 20>, start = array<i64: 0, 0, 4>} : (tensor<1x12x24xf32>) -> tensor<1x12x20xf32>
742
- // CHECK: return %[[VAL_3]], %[[VAL_4]] : tensor<1x12x15xf32>, tensor<1x12x20xf32>
749
+ // CHECK-DAG: %[[VAL_2:.*]] = tosa.const_shape {value = dense<[1, 12, 20]> : tensor<3xindex>}
750
+ // CHECK-DAG: %[[VAL_3:.*]] = tosa.const_shape {value = dense<[1, 12, 15]> : tensor<3xindex>}
751
+ // CHECK-DAG: %[[VAL_4:.*]] = tosa.const_shape {value = dense<[0, 0, 4]> : tensor<3xindex>}
752
+ // CHECK-DAG: %[[VAL_5:.*]] = tosa.const_shape {value = dense<0> : tensor<3xindex>}
753
+ // CHECK: %[[VAL_6:.*]] = tosa.concat %[[VAL_0]], %[[VAL_1]] {axis = 2 : i32} : (tensor<1x12x12xf32>, tensor<1x12x12xf32>) -> tensor<1x12x24xf32>
754
+ // CHECK: %[[VAL_7:.*]] = tosa.slice %[[VAL_6]], %[[VAL_5]], %[[VAL_3]]
755
+ // CHECK: %[[VAL_8:.*]] = tosa.slice %[[VAL_6]], %[[VAL_4]], %[[VAL_2]]
756
+ // CHECK: return %[[VAL_7]], %[[VAL_8]] : tensor<1x12x15xf32>, tensor<1x12x20xf32>
743
757
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 >) {
744
758
%0 = tosa.concat %arg0 , %arg1 {axis = 2 : i32 } : (tensor <1 x12 x12 xf32 >, tensor <1 x12 x12 xf32 >) -> tensor <1 x12 x24 xf32 >
745
- %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 >
746
- %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 >
747
- return %1 , %2 : tensor <1 x12 x15 xf32 >, tensor <1 x12 x20 xf32 >
759
+ %1 = tosa.const_shape {value = dense <[0 , 0 , 0 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
760
+ %2 = tosa.const_shape {value = dense <[0 , 0 , 4 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
761
+ %3 = tosa.const_shape {value = dense <[1 , 12 , 15 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
762
+ %4 = tosa.const_shape {value = dense <[1 , 12 , 20 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
763
+ %5 = tosa.slice %0 , %1 , %3 : (tensor <1 x12 x24 xf32 >, !tosa.shape <3 >, !tosa.shape <3 >) -> tensor <1 x12 x15 xf32 >
764
+ %6 = tosa.slice %0 , %2 , %4 : (tensor <1 x12 x24 xf32 >, !tosa.shape <3 >, !tosa.shape <3 >) -> tensor <1 x12 x20 xf32 >
765
+ return %5 , %6 : tensor <1 x12 x15 xf32 >, tensor <1 x12 x20 xf32 >
748
766
}
749
767
750
768
// -----
751
769
752
770
// CHECK-LABEL: @canonicalize_concat_slice_on_non_concat_axis
753
771
// CHECK-SAME: %[[VAL_0:.*]]: tensor<1x12x12xf32>, %[[VAL_1:.*]]: tensor<1x12x12xf32>
754
- // CHECK: %[[VAL_2:.*]] = tosa.slice %[[VAL_0]] {size = array<i64: 1, 6, 12>, start = array<i64: 0, 0, 0>} : (tensor<1x12x12xf32>) -> tensor<1x6x12xf32>
755
- // CHECK: %[[VAL_3:.*]] = tosa.slice %[[VAL_1]] {size = array<i64: 1, 3, 12>, start = array<i64: 1, 3, 0>} : (tensor<1x12x12xf32>) -> tensor<1x3x12xf32>
756
- // CHECK: return %[[VAL_2]], %[[VAL_3]] : tensor<1x6x12xf32>, tensor<1x3x12xf32>
772
+ // CHECK-DAG: %[[VAL_2:.*]] = tosa.const_shape {value = dense<[1, 3, 0]> : tensor<3xindex>}
773
+ // CHECK-DAG: %[[VAL_3:.*]] = tosa.const_shape {value = dense<[1, 3, 12]> : tensor<3xindex>}
774
+ // CHECK-DAG: %[[VAL_4:.*]] = tosa.const_shape {value = dense<0> : tensor<3xindex>}
775
+ // CHECK-DAG: %[[VAL_5:.*]] = tosa.const_shape {value = dense<[1, 6, 12]> : tensor<3xindex>}
776
+ // CHECK: %[[VAL_6:.*]] = tosa.slice %[[VAL_0]], %[[VAL_4]], %[[VAL_5]]
777
+ // CHECK: %[[VAL_7:.*]] = tosa.slice %[[VAL_1]], %[[VAL_2]], %[[VAL_3]]
778
+ // CHECK: return %[[VAL_6]], %[[VAL_7]] : tensor<1x6x12xf32>, tensor<1x3x12xf32>
757
779
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 >) {
758
780
%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 , 6 , 12 >, start = array<i64 : 0 , 0 , 0 >} : (tensor <1 x12 x24 xf32 >) -> tensor <1 x6 x12 xf32 >
760
- %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 >
761
- return %1 , %2 : tensor <1 x6 x12 xf32 >, tensor <1 x3 x12 xf32 >
781
+ %1 = tosa.const_shape {value = dense <[0 , 0 , 0 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
782
+ %2 = tosa.const_shape {value = dense <[1 , 6 , 12 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
783
+ %3 = tosa.const_shape {value = dense <[1 , 3 , 12 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
784
+ %4 = tosa.slice %0 , %1 , %2 : (tensor <1 x12 x24 xf32 >, !tosa.shape <3 >, !tosa.shape <3 >) -> tensor <1 x6 x12 xf32 >
785
+ %5 = tosa.slice %0 , %3 , %3 : (tensor <1 x12 x24 xf32 >, !tosa.shape <3 >, !tosa.shape <3 >) -> tensor <1 x3 x12 xf32 >
786
+ return %4 , %5 : tensor <1 x6 x12 xf32 >, tensor <1 x3 x12 xf32 >
762
787
}
763
788
764
789
// -----
0 commit comments