Skip to content

Commit ee9326e

Browse files
committed
Update slice lit tests
1 parent daced61 commit ee9326e

File tree

1 file changed

+103
-50
lines changed
  • test/mlir/conversion/onnx_to_tosa/Tensor

1 file changed

+103
-50
lines changed

test/mlir/conversion/onnx_to_tosa/Tensor/Slice.mlir

Lines changed: 103 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@ func.func @slice_all_dynamic(%arg0: tensor<20x10x5xf32>,
5757
%0 = "onnx.Slice"(%arg0, %arg1, %arg2, %arg3, %arg4) : (tensor<20x10x5xf32>, tensor<1xi64>, tensor<1xi64>, tensor<1xi64>, tensor<1xi64>) -> tensor<20x9x5xf32>
5858
return %0 : tensor<20x9x5xf32>
5959
}
60+
// CHECK-LABEL: func.func @slice_all_dynamic
61+
// CHECK: onnx.Slice
6062

6163
// -----
6264

63-
func.func @slice_default_axes(%arg0: tensor<20x10x5xf32>,
65+
func.func @slice_dynamic_axes(%arg0: tensor<20x10x5xf32>,
6466
%arg1: tensor<3xi64>,
6567
%arg2: tensor<3xi64>)
6668
-> tensor<20x10x1xf32> {
@@ -69,6 +71,8 @@ func.func @slice_default_axes(%arg0: tensor<20x10x5xf32>,
6971
%2 = "onnx.Slice"(%arg0, %arg1, %arg2, %0, %1) {onnx_node_name = "onnx.Slice_0"} : (tensor<20x10x5xf32>, tensor<3xi64>, tensor<3xi64>, tensor<3xi64>, tensor<3xi64>) -> tensor<20x10x1xf32>
7072
return %2 : tensor<20x10x1xf32>
7173
}
74+
// CHECK-LABEL: func.func @slice_dynamic_axes
75+
// CHECK: onnx.Slice
7276

7377
// -----
7478

@@ -80,11 +84,17 @@ func.func @slice_just_steps(%arg0: tensor<100x200xf32>) -> tensor<20x20xf32> {
8084
%1 = "onnx.Slice"(%arg0, %starts, %ends, %axes, %steps) : (tensor<100x200xf32>, tensor<2xi64>, tensor<2xi64>, tensor<2xi64>, tensor<2xi64>) -> tensor<20x20xf32>
8185
return %1 : tensor<20x20xf32>
8286
}
83-
// CHECK-LABEL: func @slice_just_steps
84-
// CHECK: %0 = tosa.reshape %arg0 {new_shape = array<i64: 20, 5, 20, 10>} : (tensor<100x200xf32>) -> tensor<20x5x20x10xf32>
85-
// CHECK: %1 = tosa.slice %0 {size = array<i64: 20, 1, 20, 1>, start = array<i64: 0, 0, 0, 0>} : (tensor<20x5x20x10xf32>) -> tensor<20x1x20x1xf32>
86-
// CHECK: %2 = tosa.reshape %1 {new_shape = array<i64: 20, 20>} : (tensor<20x1x20x1xf32>) -> tensor<20x20xf32>
87-
// CHECK: return %2 : tensor<20x20xf32>
87+
// CHECK-LABEL: func.func @slice_just_steps
88+
// CHECK-SAME: ([[PARAM_0_:%.+]]: tensor<100x200xf32>) -> tensor<20x20xf32> {
89+
// CHECK: [[VAR_0_:%.+]] = tosa.const_shape {value = dense<[20, 5, 20, 10]> : tensor<4xindex>} : () -> !tosa.shape<4>
90+
// CHECK-DAG: [[VAR_1_:%.+]] = tosa.reshape [[PARAM_0_]], [[VAR_0_]] : (tensor<100x200xf32>, !tosa.shape<4>) -> tensor<20x5x20x10xf32>
91+
// CHECK-DAG: [[VAR_2_:%.+]] = tosa.const_shape {value = dense<0> : tensor<4xindex>} : () -> !tosa.shape<4>
92+
// CHECK-DAG: [[VAR_3_:%.+]] = tosa.const_shape {value = dense<[20, 1, 20, 1]> : tensor<4xindex>} : () -> !tosa.shape<4>
93+
// CHECK-DAG: [[VAR_4_:%.+]] = tosa.slice [[VAR_1_]], [[VAR_2_]], [[VAR_3_]] : (tensor<20x5x20x10xf32>, !tosa.shape<4>, !tosa.shape<4>) -> tensor<20x1x20x1xf32>
94+
// CHECK-DAG: [[VAR_5_:%.+]] = tosa.const_shape {value = dense<20> : tensor<2xindex>} : () -> !tosa.shape<2>
95+
// CHECK: [[VAR_6_:%.+]] = tosa.reshape [[VAR_4_]], [[VAR_5_]] : (tensor<20x1x20x1xf32>, !tosa.shape<2>) -> tensor<20x20xf32>
96+
// CHECK: return [[VAR_6_]] : tensor<20x20xf32>
97+
// CHECK: }
8898

8999
// -----
90100

@@ -96,12 +106,20 @@ func.func @slice_steps_and_edges(%arg0: tensor<100x200xf32>) -> tensor<16x17xf32
96106
%1 = "onnx.Slice"(%arg0, %starts, %ends, %axes, %steps) : (tensor<100x200xf32>, tensor<2xi64>, tensor<2xi64>, tensor<2xi64>, tensor<2xi64>) -> tensor<16x17xf32>
97107
return %1 : tensor<16x17xf32>
98108
}
99-
// CHECK-LABEL: func @slice_steps_and_edges
100-
// CHECK: %0 = tosa.slice %arg0 {size = array<i64: 80, 170>, start = array<i64: 5, 10>} : (tensor<100x200xf32>) -> tensor<80x170xf32>
101-
// CHECK: %1 = tosa.reshape %0 {new_shape = array<i64: 16, 5, 17, 10>} : (tensor<80x170xf32>) -> tensor<16x5x17x10xf32>
102-
// CHECK: %2 = tosa.slice %1 {size = array<i64: 16, 1, 17, 1>, start = array<i64: 0, 0, 0, 0>} : (tensor<16x5x17x10xf32>) -> tensor<16x1x17x1xf32>
103-
// CHECK: %3 = tosa.reshape %2 {new_shape = array<i64: 16, 17>} : (tensor<16x1x17x1xf32>) -> tensor<16x17xf32>
104-
// CHECK: return %3 : tensor<16x17xf32>
109+
// CHECK-LABEL: func.func @slice_steps_and_edges
110+
// CHECK-SAME: ([[PARAM_0_:%.+]]: tensor<100x200xf32>) -> tensor<16x17xf32> {
111+
// CHECK-DAG: [[VAR_0_:%.+]] = tosa.const_shape {value = dense<[5, 10]> : tensor<2xindex>} : () -> !tosa.shape<2>
112+
// CHECK-DAG: [[VAR_1_:%.+]] = tosa.const_shape {value = dense<[80, 170]> : tensor<2xindex>} : () -> !tosa.shape<2>
113+
// CHECK-DAG: [[VAR_2_:%.+]] = tosa.slice [[PARAM_0_]], [[VAR_0_]], [[VAR_1_]] : (tensor<100x200xf32>, !tosa.shape<2>, !tosa.shape<2>) -> tensor<80x170xf32>
114+
// CHECK-DAG: [[VAR_3_:%.+]] = tosa.const_shape {value = dense<[16, 5, 17, 10]> : tensor<4xindex>} : () -> !tosa.shape<4>
115+
// CHECK-DAG: [[VAR_4_:%.+]] = tosa.reshape [[VAR_2_]], [[VAR_3_]] : (tensor<80x170xf32>, !tosa.shape<4>) -> tensor<16x5x17x10xf32>
116+
// CHECK-DAG: [[VAR_5_:%.+]] = tosa.const_shape {value = dense<0> : tensor<4xindex>} : () -> !tosa.shape<4>
117+
// CHECK-DAG: [[VAR_6_:%.+]] = tosa.const_shape {value = dense<[16, 1, 17, 1]> : tensor<4xindex>} : () -> !tosa.shape<4>
118+
// CHECK-DAG: [[VAR_7_:%.+]] = tosa.slice [[VAR_4_]], [[VAR_5_]], [[VAR_6_]] : (tensor<16x5x17x10xf32>, !tosa.shape<4>, !tosa.shape<4>) -> tensor<16x1x17x1xf32>
119+
// CHECK-DAG: [[VAR_8_:%.+]] = tosa.const_shape {value = dense<[16, 17]> : tensor<2xindex>} : () -> !tosa.shape<2>
120+
// CHECK: [[VAR_9_:%.+]] = tosa.reshape [[VAR_7_]], [[VAR_8_]] : (tensor<16x1x17x1xf32>, !tosa.shape<2>) -> tensor<16x17xf32>
121+
// CHECK: return [[VAR_9_]] : tensor<16x17xf32>
122+
// CHECK: }
105123

106124
// -----
107125

@@ -113,15 +131,23 @@ func.func @slice_steps_and_edges_with_padding(%arg0: tensor<99x195xf32>) -> tens
113131
%1 = "onnx.Slice"(%arg0, %starts, %ends, %axes, %steps) : (tensor<99x195xf32>, tensor<2xi64>, tensor<2xi64>, tensor<2xi64>, tensor<2xi64>) -> tensor<19x19xf32>
114132
return %1 : tensor<19x19xf32>
115133
}
116-
// CHECK-LABEL: func @slice_steps_and_edges_with_padding
117-
// CHECK: %0 = tosa.const_shape {value = dense<[0, 1, 0, 5]> : tensor<4xindex>} : () -> !tosa.shape<4>
118-
// CHECK: %1 = "tosa.const"() <{value = dense<0.000000e+00> : tensor<f32>}> : () -> tensor<f32>
119-
// CHECK: %2 = tosa.pad %arg0, %0, %1 : (tensor<99x195xf32>, !tosa.shape<4>, tensor<f32>) -> tensor<100x200xf32>
120-
// CHECK: %3 = tosa.slice %2 {size = array<i64: 95, 190>, start = array<i64: 5, 10>} : (tensor<100x200xf32>) -> tensor<95x190xf32>
121-
// CHECK: %4 = tosa.reshape %3 {new_shape = array<i64: 19, 5, 19, 10>} : (tensor<95x190xf32>) -> tensor<19x5x19x10xf32>
122-
// CHECK: %5 = tosa.slice %4 {size = array<i64: 19, 1, 19, 1>, start = array<i64: 0, 0, 0, 0>} : (tensor<19x5x19x10xf32>) -> tensor<19x1x19x1xf32>
123-
// CHECK: %6 = tosa.reshape %5 {new_shape = array<i64: 19, 19>} : (tensor<19x1x19x1xf32>) -> tensor<19x19xf32>
124-
// CHECK: return %6 : tensor<19x19xf32>
134+
// CHECK-LABEL: func.func @slice_steps_and_edges_with_padding
135+
// CHECK-SAME: ([[PARAM_0_:%.+]]: tensor<99x195xf32>) -> tensor<19x19xf32> {
136+
// CHECK-DAG: [[VAR_0_:%.+]] = tosa.const_shape {value = dense<[0, 1, 0, 5]> : tensor<4xindex>} : () -> !tosa.shape<4>
137+
// CHECK-DAG: [[VAR_1_:%.+]] = "tosa.const"() <{value = dense<0.000000e+00> : tensor<f32>}> : () -> tensor<f32>
138+
// CHECK-DAG: [[VAR_2_:%.+]] = tosa.pad [[PARAM_0_]], [[VAR_0_]], [[VAR_1_]] : (tensor<99x195xf32>, !tosa.shape<4>, tensor<f32>) -> tensor<100x200xf32>
139+
// CHECK-DAG: [[VAR_3_:%.+]] = tosa.const_shape {value = dense<[5, 10]> : tensor<2xindex>} : () -> !tosa.shape<2>
140+
// CHECK-DAG: [[VAR_4_:%.+]] = tosa.const_shape {value = dense<[95, 190]> : tensor<2xindex>} : () -> !tosa.shape<2>
141+
// CHECK-DAG: [[VAR_5_:%.+]] = tosa.slice [[VAR_2_]], [[VAR_3_]], [[VAR_4_]] : (tensor<100x200xf32>, !tosa.shape<2>, !tosa.shape<2>) -> tensor<95x190xf32>
142+
// CHECK-DAG: [[VAR_6_:%.+]] = tosa.const_shape {value = dense<[19, 5, 19, 10]> : tensor<4xindex>} : () -> !tosa.shape<4>
143+
// CHECK-DAG: [[VAR_7_:%.+]] = tosa.reshape [[VAR_5_]], [[VAR_6_]] : (tensor<95x190xf32>, !tosa.shape<4>) -> tensor<19x5x19x10xf32>
144+
// CHECK-DAG: [[VAR_8_:%.+]] = tosa.const_shape {value = dense<0> : tensor<4xindex>} : () -> !tosa.shape<4>
145+
// CHECK-DAG: [[VAR_9_:%.+]] = tosa.const_shape {value = dense<[19, 1, 19, 1]> : tensor<4xindex>} : () -> !tosa.shape<4>
146+
// CHECK-DAG: [[VAR_10_:%.+]] = tosa.slice [[VAR_7_]], [[VAR_8_]], [[VAR_9_]] : (tensor<19x5x19x10xf32>, !tosa.shape<4>, !tosa.shape<4>) -> tensor<19x1x19x1xf32>
147+
// CHECK-DAG: [[VAR_11_:%.+]] = tosa.const_shape {value = dense<19> : tensor<2xindex>} : () -> !tosa.shape<2>
148+
// CHECK: [[VAR_12_:%.+]] = tosa.reshape [[VAR_10_]], [[VAR_11_]] : (tensor<19x1x19x1xf32>, !tosa.shape<2>) -> tensor<19x19xf32>
149+
// CHECK: return [[VAR_12_]] : tensor<19x19xf32>
150+
// CHECK: }
125151

126152
// -----
127153

@@ -133,14 +159,20 @@ func.func @slice_just_steps_with_padding(%arg0: tensor<99x195xf32>) -> tensor<20
133159
%1 = "onnx.Slice"(%arg0, %starts, %ends, %axes, %steps) : (tensor<99x195xf32>, tensor<2xi64>, tensor<2xi64>, tensor<2xi64>, tensor<2xi64>) -> tensor<20x20xf32>
134160
return %1 : tensor<20x20xf32>
135161
}
136-
// CHECK-LABEL: func @slice_just_steps_with_padding
137-
// CHECK: %0 = tosa.const_shape {value = dense<[0, 1, 0, 5]> : tensor<4xindex>} : () -> !tosa.shape<4>
138-
// CHECK: %1 = "tosa.const"() <{value = dense<0.000000e+00> : tensor<f32>}> : () -> tensor<f32>
139-
// CHECK: %2 = tosa.pad %arg0, %0, %1 : (tensor<99x195xf32>, !tosa.shape<4>, tensor<f32>) -> tensor<100x200xf32>
140-
// CHECK: %3 = tosa.reshape %2 {new_shape = array<i64: 20, 5, 20, 10>} : (tensor<100x200xf32>) -> tensor<20x5x20x10xf32>
141-
// CHECK: %4 = tosa.slice %3 {size = array<i64: 20, 1, 20, 1>, start = array<i64: 0, 0, 0, 0>} : (tensor<20x5x20x10xf32>) -> tensor<20x1x20x1xf32>
142-
// CHECK: %5 = tosa.reshape %4 {new_shape = array<i64: 20, 20>} : (tensor<20x1x20x1xf32>) -> tensor<20x20xf32>
143-
// CHECK: return %5 : tensor<20x20xf32>
162+
// CHECK-LABEL: func.func @slice_just_steps_with_padding
163+
// CHECK-SAME: ([[PARAM_0_:%.+]]: tensor<99x195xf32>) -> tensor<20x20xf32> {
164+
// CHECK-DAG: [[VAR_0_:%.+]] = tosa.const_shape {value = dense<[0, 1, 0, 5]> : tensor<4xindex>} : () -> !tosa.shape<4>
165+
// CHECK-DAG: [[VAR_1_:%.+]] = "tosa.const"() <{value = dense<0.000000e+00> : tensor<f32>}> : () -> tensor<f32>
166+
// CHECK-DAG: [[VAR_2_:%.+]] = tosa.pad [[PARAM_0_]], [[VAR_0_]], [[VAR_1_]] : (tensor<99x195xf32>, !tosa.shape<4>, tensor<f32>) -> tensor<100x200xf32>
167+
// CHECK-DAG: [[VAR_3_:%.+]] = tosa.const_shape {value = dense<[20, 5, 20, 10]> : tensor<4xindex>} : () -> !tosa.shape<4>
168+
// CHECK-DAG: [[VAR_4_:%.+]] = tosa.reshape [[VAR_2_]], [[VAR_3_]] : (tensor<100x200xf32>, !tosa.shape<4>) -> tensor<20x5x20x10xf32>
169+
// CHECK-DAG: [[VAR_5_:%.+]] = tosa.const_shape {value = dense<0> : tensor<4xindex>} : () -> !tosa.shape<4>
170+
// CHECK-DAG: [[VAR_6_:%.+]] = tosa.const_shape {value = dense<[20, 1, 20, 1]> : tensor<4xindex>} : () -> !tosa.shape<4>
171+
// CHECK-DAG: [[VAR_7_:%.+]] = tosa.slice [[VAR_4_]], [[VAR_5_]], [[VAR_6_]] : (tensor<20x5x20x10xf32>, !tosa.shape<4>, !tosa.shape<4>) -> tensor<20x1x20x1xf32>
172+
// CHECK-DAG: [[VAR_8_:%.+]] = tosa.const_shape {value = dense<20> : tensor<2xindex>} : () -> !tosa.shape<2>
173+
// CHECK: [[VAR_9_:%.+]] = tosa.reshape [[VAR_7_]], [[VAR_8_]] : (tensor<20x1x20x1xf32>, !tosa.shape<2>) -> tensor<20x20xf32>
174+
// CHECK: return [[VAR_9_]] : tensor<20x20xf32>
175+
// CHECK: }
144176

145177
// -----
146178

@@ -161,12 +193,17 @@ func.func @slice_start_greater_than_dim(%arg0: tensor<10x30xf32>) -> tensor<*xf3
161193
%axes = "onnx.Constant"() {value = dense<[0, 1]> : tensor<2xi64> } : () -> tensor<2xi64>
162194
%starts = "onnx.Constant"() {value = dense<[20, 20]> : tensor<2xi64> } : () -> tensor<2xi64>
163195
%ends = "onnx.Constant"() {value = dense<[21,21]> : tensor<2xi64> } : () -> tensor<2xi64>
164-
%steps = "onnx.Constant"() {value = dense<0> : tensor<2xi64> } : () -> tensor<2xi64>
196+
%steps = "onnx.Constant"() {value = dense<1> : tensor<2xi64> } : () -> tensor<2xi64>
165197
%1 = "onnx.Slice"(%arg0, %starts, %ends, %axes, %steps) : (tensor<10x30xf32>, tensor<2xi64>, tensor<2xi64>, tensor<2xi64>, tensor<2xi64>) -> tensor<*xf32>
166198
return %1 : tensor<*xf32>
167199
}
168-
// CHECK-LABEL: func @slice_start_greater_than_dim
169-
// CHECK: onnx.Slice
200+
// CHECK-LABEL: func.func @slice_start_greater_than_dim
201+
// CHECK-SAME: ([[PARAM_0_:%.+]]: tensor<10x30xf32>) -> tensor<0x1xf32> {
202+
// CHECK-DAG: [[VAR_0_:%.+]] = tosa.const_shape {value = dense<[10, 20]> : tensor<2xindex>} : () -> !tosa.shape<2>
203+
// CHECK-DAG: [[VAR_1_:%.+]] = tosa.const_shape {value = dense<[0, 1]> : tensor<2xindex>} : () -> !tosa.shape<2>
204+
// CHECK: [[VAR_2_:%.+]] = tosa.slice [[PARAM_0_]], [[VAR_0_]], [[VAR_1_]] : (tensor<10x30xf32>, !tosa.shape<2>, !tosa.shape<2>) -> tensor<0x1xf32>
205+
// CHECK: return [[VAR_2_]] : tensor<0x1xf32>
206+
// CHECK: }
170207

171208
// -----
172209

@@ -178,15 +215,23 @@ func.func @slice_step_greater_than_dim(%arg0: tensor<9x30xf32>) -> tensor<1x2xf3
178215
%1 = "onnx.Slice"(%arg0, %starts, %ends, %axes, %steps) : (tensor<9x30xf32>, tensor<2xi64>, tensor<2xi64>, tensor<2xi64>, tensor<2xi64>) -> tensor<1x2xf32>
179216
return %1 : tensor<1x2xf32>
180217
}
181-
// CHECK-LABEL: func @slice_step_greater_than_dim
182-
// CHECK: %0 = tosa.const_shape {value = dense<[0, 6, 0, 0]> : tensor<4xindex>} : () -> !tosa.shape<4>
183-
// CHECK: %1 = "tosa.const"() <{value = dense<0.000000e+00> : tensor<f32>}> : () -> tensor<f32>
184-
// CHECK: %2 = tosa.pad %arg0, %0, %1 : (tensor<9x30xf32>, !tosa.shape<4>, tensor<f32>) -> tensor<15x30xf32>
185-
// CHECK: %3 = tosa.slice %2 {size = array<i64: 10, 20>, start = array<i64: 5, 5>} : (tensor<15x30xf32>) -> tensor<10x20xf32>
186-
// CHECK: %4 = tosa.reshape %3 {new_shape = array<i64: 1, 10, 2, 10>} : (tensor<10x20xf32>) -> tensor<1x10x2x10xf32>
187-
// CHECK: %5 = tosa.slice %4 {size = array<i64: 1, 1, 2, 1>, start = array<i64: 0, 0, 0, 0>} : (tensor<1x10x2x10xf32>) -> tensor<1x1x2x1xf32>
188-
// CHECK: %6 = tosa.reshape %5 {new_shape = array<i64: 1, 2>} : (tensor<1x1x2x1xf32>) -> tensor<1x2xf32>
189-
// CHECK: return %6 : tensor<1x2xf32>
218+
// CHECK-LABEL: func.func @slice_step_greater_than_dim
219+
// CHECK-SAME: ([[PARAM_0_:%.+]]: tensor<9x30xf32>) -> tensor<1x2xf32> {
220+
// CHECK-DAG: [[VAR_0_:%.+]] = tosa.const_shape {value = dense<[0, 6, 0, 0]> : tensor<4xindex>} : () -> !tosa.shape<4>
221+
// CHECK-DAG: [[VAR_1_:%.+]] = "tosa.const"() <{value = dense<0.000000e+00> : tensor<f32>}> : () -> tensor<f32>
222+
// CHECK-DAG: [[VAR_2_:%.+]] = tosa.pad [[PARAM_0_]], [[VAR_0_]], [[VAR_1_]] : (tensor<9x30xf32>, !tosa.shape<4>, tensor<f32>) -> tensor<15x30xf32>
223+
// CHECK-DAG: [[VAR_3_:%.+]] = tosa.const_shape {value = dense<5> : tensor<2xindex>} : () -> !tosa.shape<2>
224+
// CHECK-DAG: [[VAR_4_:%.+]] = tosa.const_shape {value = dense<[10, 20]> : tensor<2xindex>} : () -> !tosa.shape<2>
225+
// CHECK-DAG: [[VAR_5_:%.+]] = tosa.slice [[VAR_2_]], [[VAR_3_]], [[VAR_4_]] : (tensor<15x30xf32>, !tosa.shape<2>, !tosa.shape<2>) -> tensor<10x20xf32>
226+
// CHECK-DAG: [[VAR_6_:%.+]] = tosa.const_shape {value = dense<[1, 10, 2, 10]> : tensor<4xindex>} : () -> !tosa.shape<4>
227+
// CHECK-DAG: [[VAR_7_:%.+]] = tosa.reshape [[VAR_5_]], [[VAR_6_]] : (tensor<10x20xf32>, !tosa.shape<4>) -> tensor<1x10x2x10xf32>
228+
// CHECK-DAG: [[VAR_8_:%.+]] = tosa.const_shape {value = dense<0> : tensor<4xindex>} : () -> !tosa.shape<4>
229+
// CHECK-DAG: [[VAR_9_:%.+]] = tosa.const_shape {value = dense<[1, 1, 2, 1]> : tensor<4xindex>} : () -> !tosa.shape<4>
230+
// CHECK-DAG: [[VAR_10_:%.+]] = tosa.slice [[VAR_7_]], [[VAR_8_]], [[VAR_9_]] : (tensor<1x10x2x10xf32>, !tosa.shape<4>, !tosa.shape<4>) -> tensor<1x1x2x1xf32>
231+
// CHECK-DAG: [[VAR_11_:%.+]] = tosa.const_shape {value = dense<[1, 2]> : tensor<2xindex>} : () -> !tosa.shape<2>
232+
// CHECK: [[VAR_12_:%.+]] = tosa.reshape [[VAR_10_]], [[VAR_11_]] : (tensor<1x1x2x1xf32>, !tosa.shape<2>) -> tensor<1x2xf32>
233+
// CHECK: return [[VAR_12_]] : tensor<1x2xf32>
234+
// CHECK: }
190235

191236
// -----
192237

@@ -198,12 +243,20 @@ func.func @slice_4d(%arg0: tensor<1x56x56x92xf32>) -> tensor<1x28x28x92xf32> {
198243
%1 = "onnx.Slice"(%arg0, %starts, %ends, %axes, %steps) : (tensor<1x56x56x92xf32>, tensor<2xi64>, tensor<2xi64>, tensor<2xi64>, tensor<2xi64>) -> tensor<1x28x28x92xf32>
199244
return %1 : tensor<1x28x28x92xf32>
200245
}
201-
// CHECK-LABEL: func @slice_4d
202-
// CHECK: %0 = tosa.const_shape {value = dense<[0, 0, 0, 1, 0, 1, 0, 0]> : tensor<8xindex>} : () -> !tosa.shape<8>
203-
// CHECK: %1 = "tosa.const"() <{value = dense<0.000000e+00> : tensor<f32>}> : () -> tensor<f32>
204-
// CHECK: %2 = tosa.pad %arg0, %0, %1 : (tensor<1x56x56x92xf32>, !tosa.shape<8>, tensor<f32>) -> tensor<1x57x57x92xf32>
205-
// CHECK: %3 = tosa.slice %2 {size = array<i64: 1, 56, 56, 92>, start = array<i64: 0, 1, 1, 0>} : (tensor<1x57x57x92xf32>) -> tensor<1x56x56x92xf32>
206-
// CHECK: %4 = tosa.reshape %3 {new_shape = array<i64: 1, 28, 2, 28, 2, 92>} : (tensor<1x56x56x92xf32>) -> tensor<1x28x2x28x2x92xf32>
207-
// CHECK: %5 = tosa.slice %4 {size = array<i64: 1, 28, 1, 28, 1, 92>, start = array<i64: 0, 0, 0, 0, 0, 0>} : (tensor<1x28x2x28x2x92xf32>) -> tensor<1x28x1x28x1x92xf32>
208-
// CHECK: %6 = tosa.reshape %5 {new_shape = array<i64: 1, 28, 28, 92>} : (tensor<1x28x1x28x1x92xf32>) -> tensor<1x28x28x92xf32>
209-
// CHECK: return %6 : tensor<1x28x28x92xf32>
246+
// CHECK-LABEL: func.func @slice_4d
247+
// CHECK-SAME: ([[PARAM_0_:%.+]]: tensor<1x56x56x92xf32>) -> tensor<1x28x28x92xf32> {
248+
// CHECK-DAG: [[VAR_0_:%.+]] = tosa.const_shape {value = dense<[0, 0, 0, 1, 0, 1, 0, 0]> : tensor<8xindex>} : () -> !tosa.shape<8>
249+
// CHECK-DAG: [[VAR_1_:%.+]] = "tosa.const"() <{value = dense<0.000000e+00> : tensor<f32>}> : () -> tensor<f32>
250+
// CHECK-DAG: [[VAR_2_:%.+]] = tosa.pad [[PARAM_0_]], [[VAR_0_]], [[VAR_1_]] : (tensor<1x56x56x92xf32>, !tosa.shape<8>, tensor<f32>) -> tensor<1x57x57x92xf32>
251+
// CHECK-DAG: [[VAR_3_:%.+]] = tosa.const_shape {value = dense<[0, 1, 1, 0]> : tensor<4xindex>} : () -> !tosa.shape<4>
252+
// CHECK-DAG: [[VAR_4_:%.+]] = tosa.const_shape {value = dense<[1, 56, 56, 92]> : tensor<4xindex>} : () -> !tosa.shape<4>
253+
// CHECK-DAG: [[VAR_5_:%.+]] = tosa.slice [[VAR_2_]], [[VAR_3_]], [[VAR_4_]] : (tensor<1x57x57x92xf32>, !tosa.shape<4>, !tosa.shape<4>) -> tensor<1x56x56x92xf32>
254+
// CHECK-DAG: [[VAR_6_:%.+]] = tosa.const_shape {value = dense<[1, 28, 2, 28, 2, 92]> : tensor<6xindex>} : () -> !tosa.shape<6>
255+
// CHECK-DAG: [[VAR_7_:%.+]] = tosa.reshape [[VAR_5_]], [[VAR_6_]] : (tensor<1x56x56x92xf32>, !tosa.shape<6>) -> tensor<1x28x2x28x2x92xf32>
256+
// CHECK-DAG: [[VAR_8_:%.+]] = tosa.const_shape {value = dense<0> : tensor<6xindex>} : () -> !tosa.shape<6>
257+
// CHECK-DAG: [[VAR_9_:%.+]] = tosa.const_shape {value = dense<[1, 28, 1, 28, 1, 92]> : tensor<6xindex>} : () -> !tosa.shape<6>
258+
// CHECK-DAG: [[VAR_10_:%.+]] = tosa.slice [[VAR_7_]], [[VAR_8_]], [[VAR_9_]] : (tensor<1x28x2x28x2x92xf32>, !tosa.shape<6>, !tosa.shape<6>) -> tensor<1x28x1x28x1x92xf32>
259+
// CHECK-DAG: [[VAR_11_:%.+]] = tosa.const_shape {value = dense<[1, 28, 28, 92]> : tensor<4xindex>} : () -> !tosa.shape<4>
260+
// CHECK: [[VAR_12_:%.+]] = tosa.reshape [[VAR_10_]], [[VAR_11_]] : (tensor<1x28x1x28x1x92xf32>, !tosa.shape<4>) -> tensor<1x28x28x92xf32>
261+
// CHECK: return [[VAR_12_]] : tensor<1x28x28x92xf32>
262+
// CHECK: }

0 commit comments

Comments
 (0)