@@ -572,18 +572,22 @@ func.func @transpose_canonicalize_strip_quant() -> (tensor<2x1x3x!quant.uniform<
572
572
573
573
// CHECK-LABEL: @slice_fold
574
574
func.func @slice_fold (%arg0: tensor <3 x4 xf32 >) -> tensor <3 x4 xf32 > {
575
+ %0 = tosa.const_shape {value = dense <[0 , 0 ]> : tensor <2 xindex >} : () -> !tosa.shape <2 >
576
+ %1 = tosa.const_shape {value = dense <[3 , 4 ]> : tensor <2 xindex >} : () -> !tosa.shape <2 >
575
577
// CHECK: return %arg0
576
- %0 = tosa.slice %arg0 { size = array< i64 : 3 , 4 >, start = array< i64 : 0 , 0 >}: ( tensor < 3 x 4 x f32 >) -> tensor <3 x4 xf32 >
577
- return %0 : tensor <3 x4 xf32 >
578
+ %3 = tosa.slice %arg0 , %0 , %1 : ( tensor < 3 x 4 x f32 >, !tosa.shape < 2 >, !tosa.shape < 2 >) -> tensor <3 x4 xf32 >
579
+ return %3 : tensor <3 x4 xf32 >
578
580
}
579
581
580
582
// -----
581
583
582
584
// CHECK-LABEL: @slice_nofold
583
585
func.func @slice_nofold (%arg0: tensor <?x4 xf32 >) -> tensor <?x4 xf32 > {
586
+ %0 = tosa.const_shape {value = dense <[0 , 0 ]> : tensor <2 xindex >} : () -> !tosa.shape <2 >
587
+ %1 = tosa.const_shape {value = dense <[3 , 4 ]> : tensor <2 xindex >} : () -> !tosa.shape <2 >
584
588
// CHECK: tosa.slice
585
- %0 = tosa.slice %arg0 { size = array< i64 : 3 , 4 >, start = array< i64 : 0 , 0 >}: (tensor <?x4 xf32 >) -> tensor <?x4 xf32 >
586
- return %0 : tensor <?x4 xf32 >
589
+ %3 = tosa.slice %arg0 , %0 , %1 : (tensor <?x4 xf32 >, !tosa.shape < 2 >, !tosa.shape < 2 >) -> tensor <?x4 xf32 >
590
+ return %3 : tensor <?x4 xf32 >
587
591
}
588
592
589
593
// -----
@@ -663,9 +667,12 @@ func.func @fold_resize_bilinear(%arg0 : tensor<1x15x13x1xi8>) -> tensor<1x15x13x
663
667
// CHECK: return %[[VAL_0]], %[[VAL_1]] : tensor<1x12x12x1xf32>, tensor<1x12x12x1xf32>
664
668
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 >) {
665
669
%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 >
666
- %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 >
667
- %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 >
668
- return %1 , %2 : tensor <1 x12 x12 x1 xf32 >, tensor <1 x12 x12 x1 xf32 >
670
+ %1 = tosa.const_shape {value = dense <[0 , 0 , 0 , 0 ]> : tensor <4 xindex >} : () -> !tosa.shape <4 >
671
+ %2 = tosa.const_shape {value = dense <[0 , 0 , 0 , 1 ]> : tensor <4 xindex >} : () -> !tosa.shape <4 >
672
+ %3 = tosa.const_shape {value = dense <[1 , 12 , 12 , 1 ]> : tensor <4 xindex >} : () -> !tosa.shape <4 >
673
+ %4 = tosa.slice %0 , %1 , %3 : (tensor <1 x12 x12 x2 xf32 >, !tosa.shape <4 >, !tosa.shape <4 >) -> tensor <1 x12 x12 x1 xf32 >
674
+ %5 = tosa.slice %0 , %2 , %3 : (tensor <1 x12 x12 x2 xf32 >, !tosa.shape <4 >, !tosa.shape <4 >) -> tensor <1 x12 x12 x1 xf32 >
675
+ return %4 , %5 : tensor <1 x12 x12 x1 xf32 >, tensor <1 x12 x12 x1 xf32 >
669
676
}
670
677
671
678
// -----
@@ -675,38 +682,56 @@ func.func @canonicalize_concat_slice_final_axis(%arg0 : tensor<1x12x12x1xf32>, %
675
682
// CHECK: return %[[VAL_0]], %[[VAL_1]] : tensor<1x12x12xf32>, tensor<1x12x12xf32>
676
683
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 >) {
677
684
%0 = tosa.concat %arg0 , %arg1 {axis = 1 : i32 } : (tensor <1 x12 x12 xf32 >, tensor <1 x12 x12 xf32 >) -> tensor <1 x24 x12 xf32 >
678
- %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 >
679
- %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 >
680
- return %1 , %2 : tensor <1 x12 x12 xf32 >, tensor <1 x12 x12 xf32 >
685
+ %1 = tosa.const_shape {value = dense <[0 , 0 , 0 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
686
+ %2 = tosa.const_shape {value = dense <[0 , 12 , 0 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
687
+ %3 = tosa.const_shape {value = dense <[1 , 12 , 12 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
688
+ %4 = tosa.slice %0 , %1 , %3 : (tensor <1 x24 x12 xf32 >, !tosa.shape <3 >, !tosa.shape <3 >) -> tensor <1 x12 x12 xf32 >
689
+ %5 = tosa.slice %0 , %2 , %3 : (tensor <1 x24 x12 xf32 >, !tosa.shape <3 >, !tosa.shape <3 >) -> tensor <1 x12 x12 xf32 >
690
+ return %4 , %5 : tensor <1 x12 x12 xf32 >, tensor <1 x12 x12 xf32 >
681
691
}
682
692
683
693
// -----
684
694
685
695
// CHECK-LABEL: @canonicalize_cross_concat_inputs
686
696
// CHECK-SAME: %[[VAL_0:.*]]: tensor<1x12x12xf32>, %[[VAL_1:.*]]: tensor<1x12x12xf32>
687
- // CHECK: %[[VAL_2:.*]] = tosa.concat %[[VAL_0]], %[[VAL_1]] {axis = 2 : i32} : (tensor<1x12x12xf32>, tensor<1x12x12xf32>) -> tensor<1x12x24xf32>
688
- // CHECK: %[[VAL_3:.*]] = tosa.slice %[[VAL_2]] {size = array<i64: 1, 12, 15>, start = array<i64: 0, 0, 0>} : (tensor<1x12x24xf32>) -> tensor<1x12x15xf32>
689
- // CHECK: %[[VAL_4:.*]] = tosa.slice %[[VAL_2]] {size = array<i64: 1, 12, 20>, start = array<i64: 0, 0, 4>} : (tensor<1x12x24xf32>) -> tensor<1x12x20xf32>
690
- // CHECK: return %[[VAL_3]], %[[VAL_4]] : tensor<1x12x15xf32>, tensor<1x12x20xf32>
697
+ // CHECK-DAG: %[[VAL_2:.*]] = tosa.const_shape {value = dense<[1, 12, 20]> : tensor<3xindex>}
698
+ // CHECK-DAG: %[[VAL_3:.*]] = tosa.const_shape {value = dense<[1, 12, 15]> : tensor<3xindex>}
699
+ // CHECK-DAG: %[[VAL_4:.*]] = tosa.const_shape {value = dense<[0, 0, 4]> : tensor<3xindex>}
700
+ // CHECK-DAG: %[[VAL_5:.*]] = tosa.const_shape {value = dense<0> : tensor<3xindex>}
701
+ // CHECK: %[[VAL_6:.*]] = tosa.concat %[[VAL_0]], %[[VAL_1]] {axis = 2 : i32} : (tensor<1x12x12xf32>, tensor<1x12x12xf32>) -> tensor<1x12x24xf32>
702
+ // CHECK: %[[VAL_7:.*]] = tosa.slice %[[VAL_6]], %[[VAL_5]], %[[VAL_3]]
703
+ // CHECK: %[[VAL_8:.*]] = tosa.slice %[[VAL_6]], %[[VAL_4]], %[[VAL_2]]
704
+ // CHECK: return %[[VAL_7]], %[[VAL_8]] : tensor<1x12x15xf32>, tensor<1x12x20xf32>
691
705
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 >) {
692
706
%0 = tosa.concat %arg0 , %arg1 {axis = 2 : i32 } : (tensor <1 x12 x12 xf32 >, tensor <1 x12 x12 xf32 >) -> tensor <1 x12 x24 xf32 >
693
- %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 >
694
- %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 >
695
- return %1 , %2 : tensor <1 x12 x15 xf32 >, tensor <1 x12 x20 xf32 >
707
+ %1 = tosa.const_shape {value = dense <[0 , 0 , 0 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
708
+ %2 = tosa.const_shape {value = dense <[0 , 0 , 4 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
709
+ %3 = tosa.const_shape {value = dense <[1 , 12 , 15 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
710
+ %4 = tosa.const_shape {value = dense <[1 , 12 , 20 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
711
+ %5 = tosa.slice %0 , %1 , %3 : (tensor <1 x12 x24 xf32 >, !tosa.shape <3 >, !tosa.shape <3 >) -> tensor <1 x12 x15 xf32 >
712
+ %6 = tosa.slice %0 , %2 , %4 : (tensor <1 x12 x24 xf32 >, !tosa.shape <3 >, !tosa.shape <3 >) -> tensor <1 x12 x20 xf32 >
713
+ return %5 , %6 : tensor <1 x12 x15 xf32 >, tensor <1 x12 x20 xf32 >
696
714
}
697
715
698
716
// -----
699
717
700
718
// CHECK-LABEL: @canonicalize_concat_slice_on_non_concat_axis
701
719
// CHECK-SAME: %[[VAL_0:.*]]: tensor<1x12x12xf32>, %[[VAL_1:.*]]: tensor<1x12x12xf32>
702
- // CHECK: %[[VAL_2:.*]] = tosa.slice %[[VAL_0]] {size = array<i64: 1, 6, 12>, start = array<i64: 0, 0, 0>} : (tensor<1x12x12xf32>) -> tensor<1x6x12xf32>
703
- // CHECK: %[[VAL_3:.*]] = tosa.slice %[[VAL_1]] {size = array<i64: 1, 3, 12>, start = array<i64: 1, 3, 0>} : (tensor<1x12x12xf32>) -> tensor<1x3x12xf32>
704
- // CHECK: return %[[VAL_2]], %[[VAL_3]] : tensor<1x6x12xf32>, tensor<1x3x12xf32>
720
+ // CHECK-DAG: %[[VAL_2:.*]] = tosa.const_shape {value = dense<[1, 3, 0]> : tensor<3xindex>}
721
+ // CHECK-DAG: %[[VAL_3:.*]] = tosa.const_shape {value = dense<[1, 3, 12]> : tensor<3xindex>}
722
+ // CHECK-DAG: %[[VAL_4:.*]] = tosa.const_shape {value = dense<0> : tensor<3xindex>}
723
+ // CHECK-DAG: %[[VAL_5:.*]] = tosa.const_shape {value = dense<[1, 6, 12]> : tensor<3xindex>}
724
+ // CHECK: %[[VAL_6:.*]] = tosa.slice %[[VAL_0]], %[[VAL_4]], %[[VAL_5]]
725
+ // CHECK: %[[VAL_7:.*]] = tosa.slice %[[VAL_1]], %[[VAL_2]], %[[VAL_3]]
726
+ // CHECK: return %[[VAL_6]], %[[VAL_7]] : tensor<1x6x12xf32>, tensor<1x3x12xf32>
705
727
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 >) {
706
728
%0 = tosa.concat %arg0 , %arg1 {axis = 2 : i32 } : (tensor <1 x12 x12 xf32 >, tensor <1 x12 x12 xf32 >) -> tensor <1 x12 x24 xf32 >
707
- %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 >
708
- %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 >
709
- return %1 , %2 : tensor <1 x6 x12 xf32 >, tensor <1 x3 x12 xf32 >
729
+ %1 = tosa.const_shape {value = dense <[0 , 0 , 0 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
730
+ %2 = tosa.const_shape {value = dense <[1 , 6 , 12 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
731
+ %3 = tosa.const_shape {value = dense <[1 , 3 , 12 ]> : tensor <3 xindex >} : () -> !tosa.shape <3 >
732
+ %4 = tosa.slice %0 , %1 , %2 : (tensor <1 x12 x24 xf32 >, !tosa.shape <3 >, !tosa.shape <3 >) -> tensor <1 x6 x12 xf32 >
733
+ %5 = tosa.slice %0 , %3 , %3 : (tensor <1 x12 x24 xf32 >, !tosa.shape <3 >, !tosa.shape <3 >) -> tensor <1 x3 x12 xf32 >
734
+ return %4 , %5 : tensor <1 x6 x12 xf32 >, tensor <1 x3 x12 xf32 >
710
735
}
711
736
712
737
// -----
0 commit comments