@@ -179,10 +179,144 @@ class StridedSliceLayerGPUTest : public testing::WithParamInterface<StridedSlice
179
179
}
180
180
};
181
181
182
+ class StridedSliceLayerReshapeGPUTest : virtual public StridedSliceLayerGPUTest {
183
+ public:
184
+ void generate_inputs (const std::vector<ov::Shape>& targetInputStaticShapes) override {
185
+ inputs.clear ();
186
+ const auto & funcInputs = function->inputs ();
187
+ ov::Tensor tensor;
188
+
189
+ // input0: data
190
+ int32_t idx = 0 ;
191
+ tensor = ov::test::utils::create_and_fill_tensor (funcInputs[idx].get_element_type (), targetInputStaticShapes[idx]);
192
+ inputs.insert ({funcInputs[idx].get_node_shared_ptr (), tensor});
193
+
194
+ // input1: begin
195
+ if (rest_input_type[0 ] == ov::test::utils::InputLayerType::PARAMETER) {
196
+ idx += 1 ;
197
+ tensor = ov::Tensor (funcInputs[idx].get_element_type (), targetInputStaticShapes[idx]);
198
+ auto *dataPtr = tensor.data <float >();
199
+ for (size_t i = 0 ; i < begin.size (); i++) {
200
+ dataPtr[i] = static_cast <float >(begin[i]);
201
+ }
202
+ inputs.insert ({funcInputs[idx].get_node_shared_ptr (), tensor});
203
+ }
204
+
205
+ // input2: end
206
+ if (rest_input_type[1 ] == ov::test::utils::InputLayerType::PARAMETER) {
207
+ idx += 1 ;
208
+ tensor = ov::Tensor (funcInputs[idx].get_element_type (), targetInputStaticShapes[idx]);
209
+ auto *dataPtr = tensor.data <float >();
210
+ for (size_t i = 0 ; i < end.size (); i++) {
211
+ dataPtr[i] = static_cast <float >(end[i]);
212
+ }
213
+ inputs.insert ({funcInputs[idx].get_node_shared_ptr (), tensor});
214
+ }
215
+
216
+ // input3: stride
217
+ if (rest_input_type[2 ] == ov::test::utils::InputLayerType::PARAMETER) {
218
+ idx += 1 ;
219
+ tensor = ov::Tensor (funcInputs[idx].get_element_type (), targetInputStaticShapes[idx]);
220
+ auto *dataPtr = tensor.data <float >();
221
+ for (size_t i = 0 ; i < stride.size (); i++) {
222
+ dataPtr[i] = static_cast <float >(stride[i]);
223
+ }
224
+ inputs.insert ({funcInputs[idx].get_node_shared_ptr (), tensor});
225
+ }
226
+
227
+ // data for input_1d
228
+ idx += 1 ;
229
+ tensor = ov::test::utils::create_and_fill_tensor (funcInputs[idx].get_element_type (), targetInputStaticShapes[idx]);
230
+ inputs.insert ({funcInputs[idx].get_node_shared_ptr (), tensor});
231
+
232
+ inferRequestNum++;
233
+ }
234
+
235
+ protected:
236
+ std::vector<int64_t > begin;
237
+ std::vector<int64_t > end;
238
+ std::vector<int64_t > stride;
239
+ std::vector<ov::test::utils::InputLayerType> rest_input_type;
240
+ size_t inferRequestNum = 0 ;
241
+
242
+ void SetUp () override {
243
+ InputShape shapes;
244
+ StridedSliceParams ssParams;
245
+ std::tie (shapes, ssParams, inType, rest_input_type) = this ->GetParam ();
246
+
247
+ begin = ssParams.begin ;
248
+ end = ssParams.end ;
249
+ stride = ssParams.stride ;
250
+
251
+ targetDevice = ov::test::utils::DEVICE_GPU;
252
+
253
+ std::vector<InputShape> inputShapes;
254
+
255
+ ov::PartialShape input_1d_shape{1024 };
256
+
257
+ inputShapes.push_back (shapes);
258
+ if (rest_input_type[0 ] == ov::test::utils::InputLayerType::PARAMETER)
259
+ inputShapes.push_back (InputShape ({static_cast <int64_t >(begin.size ())}, std::vector<ov::Shape>(shapes.second .size (), {begin.size ()})));
260
+ if (rest_input_type[1 ] == ov::test::utils::InputLayerType::PARAMETER)
261
+ inputShapes.push_back (InputShape ({static_cast <int64_t >(end.size ())}, std::vector<ov::Shape>(shapes.second .size (), {end.size ()})));
262
+ if (rest_input_type[2 ] == ov::test::utils::InputLayerType::PARAMETER)
263
+ inputShapes.push_back (InputShape ({static_cast <int64_t >(stride.size ())}, std::vector<ov::Shape>(shapes.second .size (), {stride.size ()})));
264
+
265
+ inputShapes.push_back (InputShape (input_1d_shape, {input_1d_shape.to_shape ()}));
266
+
267
+ init_input_shapes (inputShapes);
268
+
269
+ ov::ParameterVector params{std::make_shared<ov::op::v0::Parameter>(inType, inputDynamicShapes.front ())};
270
+
271
+ std::shared_ptr<ov::Node> beginInput, endInput, strideInput;
272
+ if (rest_input_type[0 ] == ov::test::utils::InputLayerType::PARAMETER) {
273
+ auto beginNode = std::make_shared<ov::op::v0::Parameter>(ov::element::i64, ov::Shape{begin.size ()});
274
+ params.push_back (beginNode);
275
+ beginInput = beginNode;
276
+ } else {
277
+ beginInput = std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape{begin.size ()}, begin);
278
+ }
279
+
280
+ if (rest_input_type[1 ] == ov::test::utils::InputLayerType::PARAMETER) {
281
+ auto endNode = std::make_shared<ov::op::v0::Parameter>(ov::element::i64, ov::Shape{end.size ()});
282
+ params.push_back (endNode);
283
+ endInput = endNode;
284
+ } else {
285
+ endInput = std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape{end.size ()}, end);
286
+ }
287
+
288
+ if (rest_input_type[2 ] == ov::test::utils::InputLayerType::PARAMETER) {
289
+ auto strideNode = std::make_shared<ov::op::v0::Parameter>(ov::element::i64, ov::Shape{stride.size ()});
290
+ params.push_back (strideNode);
291
+ strideInput = strideNode;
292
+ } else {
293
+ strideInput = std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape{stride.size ()}, stride);
294
+ }
295
+
296
+ auto input_1d = std::make_shared<ov::op::v0::Parameter>(inType, input_1d_shape.to_shape ());
297
+ params.push_back (input_1d);
298
+
299
+ auto ss = std::make_shared<ov::op::v1::StridedSlice>(input_1d, beginInput, endInput, strideInput, ssParams.beginMask , ssParams.endMask ,
300
+ ssParams.newAxisMask , ssParams.shrinkAxisMask , ssParams.ellipsisAxisMask );
301
+ auto mul = std::make_shared<ov::op::v1::Multiply>(params[0 ], ss);
302
+
303
+ ov::ResultVector results;
304
+ for (size_t i = 0 ; i < mul->get_output_size (); i++) {
305
+ results.push_back (std::make_shared<ov::op::v0::Result>(mul->output (i)));
306
+ }
307
+
308
+ function = std::make_shared<ov::Model>(results, params, " StridedSlice" );
309
+ }
310
+ };
311
+
182
312
TEST_P (StridedSliceLayerGPUTest, Inference) {
183
313
run ();
184
314
}
185
315
316
+ TEST_P (StridedSliceLayerReshapeGPUTest, Inference) {
317
+ run ();
318
+ }
319
+
186
320
const std::vector<ov::element::Type> model_types = {
187
321
ov::element::f32
188
322
};
@@ -305,3 +439,19 @@ INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Common_Dynamic_6D, StridedSliceLa
305
439
::testing::ValuesIn(rest_input_types)),
306
440
StridedSliceLayerGPUTest::getTestCaseName);
307
441
} // namespace
442
+
443
+ const std::vector<InputShape> inputShapesDynamic3D = {
444
+ {{-1 , -1 , -1 },
445
+ {{ 1 , 1024 , 2 }}},
446
+ };
447
+ const std::vector<StridedSliceParams> paramsPlain3D = {
448
+ StridedSliceParams{ { 0 , 0 , 0 }, { 0 , 0 , 0 }, { 1 , 1 , 1 }, { 0 , 1 , 0 }, { 0 , 1 , 0 }, { 1 , 0 , 1 }, { }, { } },
449
+ };
450
+
451
+ INSTANTIATE_TEST_SUITE_P (smoke_CompareWithRefs_new_axis_3D, StridedSliceLayerReshapeGPUTest,
452
+ ::testing::Combine (
453
+ ::testing::ValuesIn (inputShapesDynamic3D),
454
+ ::testing::ValuesIn(paramsPlain3D),
455
+ ::testing::ValuesIn(model_types),
456
+ ::testing::Values(rest_input_types[0 ])),
457
+ StridedSliceLayerGPUTest::getTestCaseName);
0 commit comments