@@ -572,18 +572,22 @@ func.func @transpose_canonicalize_strip_quant() -> (tensor<2x1x3x!quant.uniform<
572572
573573// CHECK-LABEL: @slice_fold
574574func.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 >
575577 // 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 >
578580}
579581
580582// -----
581583
582584// CHECK-LABEL: @slice_nofold
583585func.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 >
584588 // 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 >
587591}
588592
589593// -----
@@ -663,9 +667,12 @@ func.func @fold_resize_bilinear(%arg0 : tensor<1x15x13x1xi8>) -> tensor<1x15x13x
663667// CHECK: return %[[VAL_0]], %[[VAL_1]] : tensor<1x12x12x1xf32>, tensor<1x12x12x1xf32>
664668func.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 >) {
665669 %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 >
669676}
670677
671678// -----
@@ -675,38 +682,56 @@ func.func @canonicalize_concat_slice_final_axis(%arg0 : tensor<1x12x12x1xf32>, %
675682// CHECK: return %[[VAL_0]], %[[VAL_1]] : tensor<1x12x12xf32>, tensor<1x12x12xf32>
676683func.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 >) {
677684 %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 >
681691}
682692
683693// -----
684694
685695// CHECK-LABEL: @canonicalize_cross_concat_inputs
686696// 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>
691705func.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 >) {
692706 %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 >
696714}
697715
698716// -----
699717
700718// CHECK-LABEL: @canonicalize_concat_slice_on_non_concat_axis
701719// 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>
705727func.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 >) {
706728 %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 >
710735}
711736
712737// -----
0 commit comments