Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[GPU] Fix get_internal_buffer_desc() of group normalization to allow upper boundary dynamic shape (#30734)

Wilson Seokcd4fa7220450
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_bfyx_opt.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_bfyx_opt.cpp
index f17d5eec454..93972b93eee 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_bfyx_opt.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_bfyx_opt.cpp
@@ -318,8 +318,8 @@ public:
}
[[nodiscard]] std::vector<BufferDescriptor> get_internal_buffer_descs(const RuntimeParams& params) const override {
- auto desc = params.typed_desc<group_normalization>();
- const auto& shape = params.output_layouts[0].get_shape();
+ // Use get_max_shape() for upper bounded dynamic shape. This is not called for non upper bounded dynamic shape.
+ const auto& shape = params.output_layouts[0].get_partial_shape().get_max_shape();
auto buf = BufferDescriptor{shape[0] * shape[1], ov::element::f32};
return {buf, buf};
}
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_fsv16.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_fsv16.cpp
index 1caf1572d3d..08bdf571f69 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_fsv16.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_fsv16.cpp
@@ -279,8 +279,8 @@ public:
}
std::vector<BufferDescriptor> get_internal_buffer_descs(const RuntimeParams& params) const override {
- auto desc = params.typed_desc<group_normalization>();
- const auto& shape = params.output_layouts[0].get_shape();
+ // Use get_max_shape() for upper bounded dynamic shape. This is not called for non upper bounded dynamic shape.
+ const auto& shape = params.output_layouts[0].get_partial_shape().get_max_shape();
auto buf = BufferDescriptor{shape[0] * align_to(shape[1], fsv), ov::element::f32};
return {buf, buf};
}
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_ref.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_ref.cpp
index c835210975b..89ce90cbf47 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_ref.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_ref.cpp
@@ -177,7 +177,8 @@ public:
[[nodiscard]] std::vector<BufferDescriptor> get_internal_buffer_descs(const RuntimeParams& params) const override {
auto desc = params.typed_desc<group_normalization>();
- size_t batch = params.output_layouts[0].get_shape()[0];
+ // Use get_max_shape() for upper bounded dynamic shape. This is not called for non upper bounded dynamic shape.
+ size_t batch = params.output_layouts[0].get_partial_shape().get_max_shape()[0];
auto buf = BufferDescriptor{batch * static_cast<size_t>(desc->num_groups), ov::element::f32};
return {buf, buf};
}
diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/group_normalization.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/group_normalization.cpp
index 4c7c2dff9c2..3b17a0f296e 100644
--- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/group_normalization.cpp
+++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/group_normalization.cpp
@@ -17,6 +17,16 @@ const std::vector<ov::Shape> inputShapes = {
{3, 8, 28, 32, 12},
};
+// dynmaic shapes
+const std::vector<ov::test::InputShape> DynamicInputShapes = {
+ {{-1, -1, -1}, {{1, 8, 22}, {2, 4, 7}, {1, 8, 22}}},
+ {{-1, -1, -1, -1}, {{1, 16, 8, 8}, {2, 8, 4, 4}, {1, 16, 8, 8}}},
+ {{{1, 4}, {4, 16}, -1, -1}, {{1, 4, 6, 6}, {4, 16, 10, 10}, {1, 4, 6, 6}}},
+ {{-1, -1, -1, -1, -1}, {{1, 16, 7, 7, 1}, {2, 8, 4, 4, 1}, {1, 16, 7, 7, 1}}},
+ {{1, 64, {25, 50}, {31, 62}}, {{1, 64, 25, 31}}},
+ {{{1, 2}, 64, 25, 31}, {{1, 64, 25, 31}}},
+};
+
const std::vector<int64_t> numGroups = {
2, 4,
};
@@ -26,7 +36,7 @@ const std::vector<double> epsilon = {
};
INSTANTIATE_TEST_SUITE_P(
- smoke_GroupNormalization,
+ smoke_GroupNormalizationStatic,
GroupNormalizationTest,
testing::Combine(testing::ValuesIn(netPrecisions),
::testing::Values(ov::element::dynamic),
@@ -38,4 +48,16 @@ INSTANTIATE_TEST_SUITE_P(
testing::Values(ov::AnyMap())),
GroupNormalizationTest::getTestCaseName);
+ INSTANTIATE_TEST_SUITE_P(
+ smoke_GroupNormalizationDynamic,
+ GroupNormalizationTest,
+ testing::Combine(testing::ValuesIn(netPrecisions),
+ ::testing::Values(ov::element::dynamic),
+ ::testing::Values(ov::element::dynamic),
+ testing::ValuesIn(DynamicInputShapes),
+ testing::ValuesIn(numGroups),
+ testing::ValuesIn(epsilon),
+ testing::Values(ov::test::utils::DEVICE_GPU),
+ testing::Values(ov::AnyMap())),
+ GroupNormalizationTest::getTestCaseName);
} // anonymous namespace