Skip to content

Commit 0369736

Browse files
[GPU] Update creating SpaceToBatch and BatchToSpace for dynamic and
static
1 parent f671bfc commit 0369736

File tree

4 files changed

+32
-52
lines changed

4 files changed

+32
-52
lines changed

src/plugins/intel_gpu/src/plugin/ops/batch_to_space.cpp

+1-14
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,10 @@ static void CreateBatchToSpaceOp(ProgramBuilder& p, const std::shared_ptr<ov::op
2323
std::vector<cldnn::tensor> tensor_inputs;
2424
tensor_inputs.reserve(3);
2525

26-
bool non_constant_input = false;
27-
for (size_t i = 1; i < 4; ++i) {
28-
auto inConst = ov::as_type_ptr<ov::op::v0::Constant>(op->get_input_node_shared_ptr(i));
29-
30-
bool is_const_input = (inConst != nullptr);
31-
OPENVINO_ASSERT((i == 1) || (i >= 2 && non_constant_input != is_const_input),
32-
"[GPU] Unsupported mixed node with constant and parameter in ", op->get_friendly_name(), " (", op->get_type_name(), ")");
33-
34-
if (!inConst) {
35-
non_constant_input = true;
36-
}
37-
}
38-
3926
auto output_pshape = op->get_output_partial_shape(0);
4027
auto out_size = output_pshape.is_static() ? tensor_from_dims(output_pshape.to_shape()) : cldnn::tensor();
4128

42-
if (non_constant_input) {
29+
if (p.use_new_shape_infer() || op->is_dynamic()) {
4330
auto batchToSpacePrim = cldnn::batch_to_space(layerName, inputs, out_size);
4431
p.add_primitive(*op, batchToSpacePrim);
4532
} else {

src/plugins/intel_gpu/src/plugin/ops/space_to_batch.cpp

+1-14
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,12 @@ static void CreateSpaceToBatchOp(ProgramBuilder& p, const std::shared_ptr<ov::op
2323
std::vector<cldnn::tensor> tensor_inputs;
2424
tensor_inputs.reserve(3);
2525

26-
bool non_constant_input = false;
27-
for (size_t i = 1; i < 4; ++i) {
28-
auto inConst = ov::as_type_ptr<ov::op::v0::Constant>(op->get_input_node_shared_ptr(i));
29-
30-
bool is_const_input = (inConst != nullptr);
31-
OPENVINO_ASSERT((i == 1) || (i >= 2 && non_constant_input != is_const_input),
32-
"[GPU] Unsupported mixed node with constant and parameter in ", op->get_friendly_name(), " (", op->get_type_name(), ")");
33-
34-
if (!inConst) {
35-
non_constant_input = true;
36-
}
37-
}
38-
3926
// In case of dynamic shapes pass dummy shape value to space_to_batch primitive
4027
// To be removed once we enable internal shape infer for all operations
4128
auto output_pshape = op->get_output_partial_shape(0);
4229
auto out_size = output_pshape.is_static() ? tensor_from_dims(output_pshape.to_shape()) : cldnn::tensor();
4330

44-
if (non_constant_input) {
31+
if (p.use_new_shape_infer() || op->is_dynamic()) {
4532
auto spaceToBatchPrim = cldnn::space_to_batch(layerName, inputs, out_size);
4633
p.add_primitive(*op, spaceToBatchPrim);
4734
} else {

src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/batch_to_space.cpp

+15-12
Original file line numberDiff line numberDiff line change
@@ -165,54 +165,57 @@ const std::vector<ov::test::utils::InputLayerType> restInputTypes = {
165165
ov::test::utils::InputLayerType::PARAMETER
166166
};
167167

168-
const std::vector<InputShape> inputShapesDynamic3D = {
169-
{{-1, -1, -1}, {{48, 3, 3}, {24, 4, 5}}},
168+
const std::vector<InputShape> inputShapes3D = {
169+
{{48, 3, 3}, {{48, 3, 3}}},
170+
{{-1, -1, -1}, {{48, 3, 3}, {24, 4, 5}}}
170171
};
171172

172173
const std::vector<BatchToSpaceParams> paramsPlain3D = {
173174
BatchToSpaceParams{ { 1, 2, 4 }, { 0, 0, 1 }, { 0, 0, 1 } },
174-
BatchToSpaceParams{ { 1, 3, 2 }, { 0, 1, 0 }, { 0, 2, 1 } },
175+
BatchToSpaceParams{ { 1, 3, 2 }, { 0, 1, 0 }, { 0, 2, 1 } }
175176
};
176177

177178
INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Plain_Dynamic_3D, BatchToSpaceLayerGPUTest,
178179
::testing::Combine(
179-
::testing::ValuesIn(inputShapesDynamic3D),
180+
::testing::ValuesIn(inputShapes3D),
180181
::testing::ValuesIn(paramsPlain3D),
181182
::testing::ValuesIn(inputPrecisions),
182183
::testing::ValuesIn(restInputTypes),
183184
::testing::Values(emptyAdditionalConfig)),
184185
BatchToSpaceLayerGPUTest::getTestCaseName);
185186

186-
const std::vector<InputShape> inputShapesDynamic4D = {
187-
{{-1, -1, -1, -1}, {{48, 3, 3, 1}, {24, 4, 5, 6}}},
187+
const std::vector<InputShape> inputShapes4D = {
188+
{{24, 4, 5, 6}, {{24, 4, 5, 6}}},
189+
{{-1, -1, -1, -1}, {{48, 3, 3, 1}, {24, 4, 5, 6}}}
188190
};
189191

190192
const std::vector<BatchToSpaceParams> paramsPlain4D = {
191193
BatchToSpaceParams{ { 1, 2, 4, 3 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 } },
192-
BatchToSpaceParams{ { 1, 3, 2, 4 }, { 0, 1, 0, 1 }, { 0, 2, 1, 3 } },
194+
BatchToSpaceParams{ { 1, 3, 2, 4 }, { 0, 1, 0, 1 }, { 0, 2, 1, 3 } }
193195
};
194196

195197
INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Plain_Dynamic_4D, BatchToSpaceLayerGPUTest,
196198
::testing::Combine(
197-
::testing::ValuesIn(inputShapesDynamic4D),
199+
::testing::ValuesIn(inputShapes4D),
198200
::testing::ValuesIn(paramsPlain4D),
199201
::testing::ValuesIn(inputPrecisions),
200202
::testing::ValuesIn(restInputTypes),
201203
::testing::Values(emptyAdditionalConfig)),
202204
BatchToSpaceLayerGPUTest::getTestCaseName);
203205

204-
const std::vector<InputShape> inputShapesDynamic5D = {
205-
{{-1, -1, -1, -1, -1}, {{48, 3, 3, 1, 5}, {96, 4, 5, 6, 7}}},
206+
const std::vector<InputShape> inputShapes5D = {
207+
{{96, 4, 5, 6, 7}, {{96, 4, 5, 6, 7}}},
208+
{{-1, -1, -1, -1, -1}, {{48, 3, 3, 1, 5}, {96, 4, 5, 6, 7}}}
206209
};
207210

208211
const std::vector<BatchToSpaceParams> paramsPlain5D = {
209212
BatchToSpaceParams{ { 1, 2, 4, 3, 2 }, { 0, 0, 1, 0, 2 }, { 0, 0, 1, 0, 3 } },
210-
BatchToSpaceParams{ { 1, 3, 2, 4, 2 }, { 0, 1, 0, 1, 3 }, { 0, 2, 1, 3, 2 } },
213+
BatchToSpaceParams{ { 1, 3, 2, 4, 2 }, { 0, 1, 0, 1, 3 }, { 0, 2, 1, 3, 2 } }
211214
};
212215

213216
INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Plain_Dynamic_5D, BatchToSpaceLayerGPUTest,
214217
::testing::Combine(
215-
::testing::ValuesIn(inputShapesDynamic5D),
218+
::testing::ValuesIn(inputShapes5D),
216219
::testing::ValuesIn(paramsPlain5D),
217220
::testing::ValuesIn(inputPrecisions),
218221
::testing::ValuesIn(restInputTypes),

src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/space_to_batch.cpp

+15-12
Original file line numberDiff line numberDiff line change
@@ -155,53 +155,56 @@ const std::vector<ov::test::utils::InputLayerType> restInputTypes = {
155155
ov::test::utils::InputLayerType::PARAMETER
156156
};
157157

158-
const std::vector<InputShape> inputShapesDynamic3D = {
159-
{{-1, -1, -1}, {{2, 3, 6}}},
158+
const std::vector<InputShape> inputShapes3D = {
159+
{{2, 3, 6}, {{2, 3, 6}}},
160+
{{-1, -1, -1}, {{2, 3, 6}}}
160161
};
161162

162163
const std::vector<SpaceToBatchParams> paramsPlain3D = {
163164
SpaceToBatchParams{ { 1, 2, 3 }, { 0, 2, 2 }, { 0, 3, 1 } },
164-
SpaceToBatchParams{ { 1, 4, 5 }, { 0, 4, 5 }, { 0, 9, 4 } },
165+
SpaceToBatchParams{ { 1, 4, 5 }, { 0, 4, 5 }, { 0, 9, 4 } }
165166
};
166167

167168
INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Dynamic3D, SpaceToBatchLayerGPUTest,
168169
::testing::Combine(
169-
::testing::ValuesIn(inputShapesDynamic3D),
170+
::testing::ValuesIn(inputShapes3D),
170171
::testing::ValuesIn(paramsPlain3D),
171172
::testing::ValuesIn(inputPrecisions),
172173
::testing::ValuesIn(restInputTypes)),
173174
SpaceToBatchLayerGPUTest::getTestCaseName);
174175

175176

176-
const std::vector<InputShape> inputShapesDynamic4D = {
177-
{{-1, -1, -1, -1}, {{2, 3, 6, 5}}},
177+
const std::vector<InputShape> inputShapes4D = {
178+
{{{2, 3, 6, 5}}, {{2, 3, 6, 5}}},
179+
{{-1, -1, -1, -1}, {{2, 3, 6, 5}}}
178180
};
179181

180182
const std::vector<SpaceToBatchParams> paramsPlain4D = {
181183
SpaceToBatchParams{ { 1, 1, 2, 3 }, { 0, 2, 2, 2 }, { 0, 3, 4, 5 } },
182-
SpaceToBatchParams{ { 1, 1, 4, 5 }, { 0, 2, 4, 5 }, { 0, 3, 2, 5 } },
184+
SpaceToBatchParams{ { 1, 1, 4, 5 }, { 0, 2, 4, 5 }, { 0, 3, 2, 5 } }
183185
};
184186

185187
INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Dynamic4D, SpaceToBatchLayerGPUTest,
186188
::testing::Combine(
187-
::testing::ValuesIn(inputShapesDynamic4D),
189+
::testing::ValuesIn(inputShapes4D),
188190
::testing::ValuesIn(paramsPlain4D),
189191
::testing::ValuesIn(inputPrecisions),
190192
::testing::ValuesIn(restInputTypes)),
191193
SpaceToBatchLayerGPUTest::getTestCaseName);
192194

193-
const std::vector<InputShape> inputShapesDynamic5D = {
194-
{{-1, -1, -1, -1, -1}, {{2, 3, 6, 5, 7}}},
195+
const std::vector<InputShape> inputShapes5D = {
196+
{{2, 3, 6, 5, 7}, {{2, 3, 6, 5, 7}}},
197+
{{-1, -1, -1, -1, -1}, {{2, 3, 6, 5, 7}}}
195198
};
196199

197200
const std::vector<SpaceToBatchParams> paramsPlain5D = {
198201
SpaceToBatchParams{ { 1, 1, 2, 3, 7 }, { 0, 2, 2, 2, 4 }, { 0, 3, 4, 5, 3 } },
199-
SpaceToBatchParams{ { 1, 1, 4, 5, 8 }, { 0, 2, 4, 5, 5 }, { 0, 3, 2, 5, 4 } },
202+
SpaceToBatchParams{ { 1, 1, 4, 5, 8 }, { 0, 2, 4, 5, 5 }, { 0, 3, 2, 5, 4 } }
200203
};
201204

202205
INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_Dynamic5D, SpaceToBatchLayerGPUTest,
203206
::testing::Combine(
204-
::testing::ValuesIn(inputShapesDynamic5D),
207+
::testing::ValuesIn(inputShapes5D),
205208
::testing::ValuesIn(paramsPlain5D),
206209
::testing::ValuesIn(inputPrecisions),
207210
::testing::ValuesIn(restInputTypes)),

0 commit comments

Comments
 (0)