Skip to content

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

[GPU] allow more fusions for dynamic layers (#30730)

Eddy Kim6b90078e3f0e
diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp
index 3371530440a..8f0addbd605 100644
--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp
+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp
@@ -1156,7 +1156,8 @@ void prepare_primitive_fusing::fuse_simple_primitives(program &p) {
auto eltw_in_size = peer_node->get_output_layout();
if (eltw_in_size.is_dynamic()
// this whitelist condition is temporarily and to be relaxed soon.
- && !fused_node->is_type<fully_connected>())
+ && !fused_node->is_type<fully_connected>()
+ && !fused_node->is_type<convolution>())
return;
}
if (parent1.first->is_type<convolution>() && !conv_supports_fusings(parent1.first->as<convolution>()))
diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/remove_redundant_reorders.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/remove_redundant_reorders.cpp
index bb9602ce917..5a661a90989 100644
--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/remove_redundant_reorders.cpp
+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/remove_redundant_reorders.cpp
@@ -20,6 +20,7 @@
#include "concatenation_inst.h"
#include "region_yolo_inst.h"
#include "fully_connected_inst.h"
+#include "group_normalization_inst.h"
#include "mvn_inst.h"
#include <vector>
@@ -474,7 +475,9 @@ void remove_redundant_reorders::run(program& p) {
// Add fused_primitive_desc of reorder to the previous node which propagates original output layout
// during shape inference
if (input.is_type<mvn>() || input.is_type<concatenation>() || input.is_type<gather>() ||
- input.is_type<broadcast>() || input.is_type<select>() || input.is_type<eltwise>()) {
+ input.is_type<broadcast>() || input.is_type<select>() || input.is_type<eltwise>() ||
+ (input.is_dynamic() &&
+ (input.is_type<group_normalization>() || input.is_type<permute>()))) {
fused_primitive_desc local_desc(node.get_primitive());
local_desc.f_param = node.get_fuse_params();
local_desc.total_num_deps = node.get_dependencies().size();
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_bfyx_opt.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_bfyx_opt.hpp
index 3d90a5e4f5b..b64ed9e0ded 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_bfyx_opt.hpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_bfyx_opt.hpp
@@ -21,11 +21,17 @@ struct GroupNormalizationBfyxOpt : public GroupNormalizationBase {
explicit GroupNormalizationBfyxOpt(shape_types shape_type, ValidateFunc vf = nullptr) : GroupNormalizationBase(shape_type, std::move(vf)) {}
[[nodiscard]] std::unique_ptr<primitive_impl> create_impl(const program_node& node, const RuntimeParams& params) const override;
[[nodiscard]] bool validate_impl(const program_node& node) const override {
- static constexpr std::array supported_fmts = {
+ static constexpr std::array supported_input_fmts = {
format::bfyx,
format::bfzyx,
};
+ static constexpr std::array supported_output_fmts = {
+ format::bfyx,
+ format::bfzyx,
+ format::b_fs_yx_fsv16,
+ };
+
static constexpr std::array supported_types = {
ov::element::f32,
ov::element::f16,
@@ -35,7 +41,7 @@ struct GroupNormalizationBfyxOpt : public GroupNormalizationBase {
const auto& in0_layout = node.get_input_layout(0);
const auto& out_layout = node.get_output_layout(0);
- if (!one_of(in0_layout.format, supported_fmts) || !one_of(out_layout.format, supported_fmts)) {
+ if (!one_of(in0_layout.format, supported_input_fmts) || !one_of(out_layout.format, supported_output_fmts)) {
return false;
}
@@ -43,7 +49,7 @@ struct GroupNormalizationBfyxOpt : public GroupNormalizationBase {
return false;
}
- if (!fused_ops_are_one_of<eltwise, activation>(node.get_fused_primitives())) {
+ if (!fused_ops_are_one_of<eltwise, activation, reorder>(node.get_fused_primitives())) {
return false;
}
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_fsv16.cl b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_fsv16.cl
index b222ff22e8c..81494df5ec1 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_fsv16.cl
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_fsv16.cl
@@ -132,7 +132,9 @@ KERNEL(group_normalization_b_fs_yx_fsv16)(
output[output_index] = TO_OUTPUT_TYPE(normalized);
#endif
} else {
- output[output_index] = OUTPUT_VAL_ZERO;
+ #ifdef OUTPUT_LAYOUT_B_FS_YX_FSV16
+ output[output_index] = OUTPUT_VAL_ZERO;
+ #endif
}
}
#endif
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_fsv16.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_fsv16.hpp
index 51e4ae7486d..d415927cc36 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_fsv16.hpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/group_normalization_fsv16.hpp
@@ -21,10 +21,15 @@ struct GroupNormalizationFsv16Opt : public GroupNormalizationBase {
explicit GroupNormalizationFsv16Opt(shape_types shape_type, ValidateFunc vf = nullptr) : GroupNormalizationBase(shape_type, std::move(vf)) {}
[[nodiscard]] std::unique_ptr<primitive_impl> create_impl(const program_node& node, const RuntimeParams& params) const override;
[[nodiscard]] bool validate_impl(const program_node& node) const override {
- static constexpr std::array supported_fmts = {
+ static constexpr std::array supported_input_fmts = {
format::b_fs_yx_fsv16,
};
+ static constexpr std::array supported_output_fmts = {
+ format::b_fs_yx_fsv16,
+ format::bfyx,
+ };
+
static constexpr std::array supported_types = {
ov::element::f32,
ov::element::f16,
@@ -34,7 +39,7 @@ struct GroupNormalizationFsv16Opt : public GroupNormalizationBase {
const auto& in0_layout = node.get_input_layout(0);
const auto& out_layout = node.get_output_layout(0);
- if (!one_of(in0_layout.format, supported_fmts) || !one_of(out_layout.format, supported_fmts)) {
+ if (!one_of(in0_layout.format, supported_input_fmts) || !one_of(out_layout.format, supported_output_fmts)) {
return false;
}
@@ -49,7 +54,7 @@ struct GroupNormalizationFsv16Opt : public GroupNormalizationBase {
return false;
}
- if (!fused_ops_are_one_of<eltwise, activation>(node.get_fused_primitives())) {
+ if (!fused_ops_are_one_of<eltwise, activation, reorder>(node.get_fused_primitives())) {
return false;
}
}
diff --git a/src/plugins/intel_gpu/src/graph/include/group_normalization_inst.h b/src/plugins/intel_gpu/src/graph/include/group_normalization_inst.h
index 27fe3821469..af209068682 100644
--- a/src/plugins/intel_gpu/src/graph/include/group_normalization_inst.h
+++ b/src/plugins/intel_gpu/src/graph/include/group_normalization_inst.h
@@ -25,7 +25,20 @@ class typed_primitive_inst<group_normalization> : public typed_primitive_inst_ba
public:
template<typename ShapeType>
static std::vector<layout> calc_output_layouts(group_normalization_node const& /*node*/, const kernel_impl_params& impl_param) {
- return forward_input0_shape<ShapeType>(impl_param);
+ auto in_layout = impl_param.get_input_layout(0);
+ auto out_format = in_layout.format;
+ auto output_type = impl_param.desc->output_data_types[0].value_or(in_layout.data_type);
+
+ if (impl_param.has_fused_primitives()) {
+ output_type = impl_param.get_output_element_type();
+ for (auto& desc : impl_param.fused_desc) {
+ if (desc.is_type<reorder>()) {
+ out_format = desc.output_layout.format;
+ }
+ }
+ }
+
+ return { layout(in_layout.get<ShapeType>(), output_type, out_format) };
}
static layout calc_output_layout(group_normalization_node const& node, kernel_impl_params const& impl_param);
diff --git a/src/plugins/intel_gpu/src/graph/layout_optimizer.cpp b/src/plugins/intel_gpu/src/graph/layout_optimizer.cpp
index 36be3914797..31a55a2fbcf 100644
--- a/src/plugins/intel_gpu/src/graph/layout_optimizer.cpp
+++ b/src/plugins/intel_gpu/src/graph/layout_optimizer.cpp
@@ -41,6 +41,7 @@
#include "permute_inst.h"
#include "dft_inst.h"
#include "lstm_seq_inst.h"
+#include "group_normalization_inst.h"
#include "to_string_utils.h"
#include <vector>
#include <memory>
@@ -354,8 +355,14 @@ bool layout_optimizer::can_fuse_reorder_to_prev(program_node& prev, reorder_node
return true;
}
- if (prev.is_dynamic() || (!node.get_users().empty() && node.get_users().front()->is_dynamic()))
- return false;
+ bool is_dynamic = false;
+ if (prev.is_dynamic() || (!node.get_users().empty() && node.get_users().front()->is_dynamic())) {
+ if (!prev.is_type<permute>() &&
+ !prev.is_type<group_normalization>()) {
+ return false;
+ }
+ is_dynamic = true;
+ }
// Ref kernels are the main for depth_to_space, region_yolo and detection_output. It can do anything. Should not see next.
if (prev.is_type<depth_to_space>() || prev.is_type<region_yolo>()
@@ -373,6 +380,11 @@ bool layout_optimizer::can_fuse_reorder_to_prev(program_node& prev, reorder_node
if (prev.is_type<reorder>())
return true;
+ if (prev.is_type<group_normalization>() && is_dynamic && !prev.has_fused_primitives() &&
+ fmt_prev == format::bfyx && fmt_next == format::b_fs_yx_fsv16 &&
+ !prev.get_output_layout().data_padding && !next->get_output_layout().data_padding)
+ return true;
+
// resample_opt kernel can work cross-layout between fsv16 and fsv32
if (prev.is_type<resample>() &&
(fmt_prev == format::b_fs_yx_fsv16 || fmt_prev == format::b_fs_yx_fsv32
@@ -395,25 +407,33 @@ bool layout_optimizer::can_fuse_reorder_to_prev(program_node& prev, reorder_node
return true;
if (prev.is_type<permute>()) {
- if (fmt_prev == format::b_fs_yx_fsv32 && fmt_next == format::byxf)
- return true;
+ if (is_dynamic) {
+ if (!prev.has_fused_primitives() &&
+ fmt_prev == format::bfyx && fmt_next == format::b_fs_yx_fsv16)
+ return true;
- auto& permute_order = prev.as<permute>().get_primitive()->permute_order;
- if ((fmt_prev == format::b_fs_yx_fsv4 || fmt_prev == format::b_fs_yx_fsv32 || fmt_prev == format::b_fs_zyx_fsv32 ||
- fmt_prev == format::b_fs_yx_fsv16 || fmt_prev == format::b_fs_zyx_fsv16 || fmt_prev == format::bs_fs_yx_bsv16_fsv16)
- && permute_order.back() != 1
- && (!prev.as<permute>().is_rotating_except_batch())) {
- return false;
- }
- // permute kernel doesn't support reorder fusion for ranks > 6
- if (fmt_prev.dimension() > 6 || fmt_next.dimension() > 6)
return false;
+ } else {
+ if (fmt_prev == format::b_fs_yx_fsv32 && fmt_next == format::byxf)
+ return true;
- // Skip reorder fusing to permute when allow_new_shape_infer is True and input and output rank is different
- if (allow_new_shape_infer && (fmt_prev.dimension() != fmt_next.dimension()))
- return false;
+ auto& permute_order = prev.as<permute>().get_primitive()->permute_order;
+ if ((fmt_prev == format::b_fs_yx_fsv4 || fmt_prev == format::b_fs_yx_fsv32 || fmt_prev == format::b_fs_zyx_fsv32 ||
+ fmt_prev == format::b_fs_yx_fsv16 || fmt_prev == format::b_fs_zyx_fsv16 || fmt_prev == format::bs_fs_yx_bsv16_fsv16)
+ && permute_order.back() != 1
+ && (!prev.as<permute>().is_rotating_except_batch())) {
+ return false;
+ }
+ // permute kernel doesn't support reorder fusion for ranks > 6
+ if (fmt_prev.dimension() > 6 || fmt_next.dimension() > 6)
+ return false;
- return true;
+ // Skip reorder fusing to permute when allow_new_shape_infer is True and input and output rank is different
+ if (allow_new_shape_infer && (fmt_prev.dimension() != fmt_next.dimension()))
+ return false;
+
+ return true;
+ }
}
diff --git a/src/plugins/intel_gpu/src/graph/permute.cpp b/src/plugins/intel_gpu/src/graph/permute.cpp
index 202aa7134e4..d49719dd35d 100644
--- a/src/plugins/intel_gpu/src/graph/permute.cpp
+++ b/src/plugins/intel_gpu/src/graph/permute.cpp
@@ -52,14 +52,21 @@ std::vector<layout> permute_inst::calc_output_layouts(permute_node const& node,
auto input_layout = impl_param.get_input_layout();
auto output_type = desc->output_data_types[0].value_or(input_layout.data_type);
- if (impl_param.has_fused_primitives()) {
- output_type = impl_param.get_output_element_type();
- }
auto output_fmt = input_layout.format;
if (node.get_preferred_output_fmt() != format::any) {
output_fmt = node.get_preferred_output_fmt();
}
+
+ if (impl_param.has_fused_primitives()) {
+ output_type = impl_param.get_output_element_type();
+ for (auto& desc : impl_param.fused_desc) {
+ if (desc.is_type<reorder>()) {
+ output_fmt = desc.output_layout.format;
+ }
+ }
+ }
+
ShapeType input_shape = input_layout.get<ShapeType>();
ShapeType output_shape;
ov::Rank input_rank = input_shape.rank();
diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_bfzyx_to_bfyxz.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_bfzyx_to_bfyxz.h
index 4479e45d1a4..c6e389e6bab 100644
--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_bfzyx_to_bfyxz.h
+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_bfzyx_to_bfyxz.h
@@ -25,6 +25,7 @@ protected:
CommonDispatchData SetDefault(const permute_params& params) const override;
std::vector<FusedOpType> GetSupportedFusedOps() const override {
return {
+ FusedOpType::REORDER,
FusedOpType::ACTIVATION,
FusedOpType::QUANTIZE,
FusedOpType::ELTWISE
diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_f_y_axes.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_f_y_axes.h
index 1030c54befb..6d77e2eaf73 100644
--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_f_y_axes.h
+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_f_y_axes.h
@@ -23,7 +23,7 @@ protected:
JitConstants GetJitConstants(const permute_params& params, const CommonDispatchData& dispatchData) const override;
CommonDispatchData SetDefault(const permute_params& params) const override;
std::vector<FusedOpType> GetSupportedFusedOps() const override {
- return {FusedOpType::ACTIVATION, FusedOpType::QUANTIZE, FusedOpType::ELTWISE};
+ return {FusedOpType::REORDER, FusedOpType::ACTIVATION, FusedOpType::QUANTIZE, FusedOpType::ELTWISE};
}
};
} // namespace kernel_selector
diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_ref.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_ref.h
index 475c46800a1..739c6d95b5f 100644
--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_ref.h
+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_ref.h
@@ -27,6 +27,7 @@ protected:
CommonDispatchData SetDefault(const permute_params& params) const override;
std::vector<FusedOpType> GetSupportedFusedOps() const override {
return {
+ FusedOpType::REORDER,
FusedOpType::ACTIVATION,
FusedOpType::QUANTIZE,
FusedOpType::ELTWISE
diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_tile_8x8_4x4.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_tile_8x8_4x4.h
index fd47b5db7e8..5337d416f9e 100644
--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_tile_8x8_4x4.h
+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_tile_8x8_4x4.h
@@ -25,6 +25,7 @@ protected:
CommonDispatchData SetDefault(const permute_params& params) const override;
std::vector<FusedOpType> GetSupportedFusedOps() const override {
return {
+ FusedOpType::REORDER,
FusedOpType::ACTIVATION,
FusedOpType::QUANTIZE,
FusedOpType::ELTWISE
diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_tile_8x8_4x4_fsv.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_tile_8x8_4x4_fsv.h
index f83d32db7c8..fb2ccfb0a43 100644
--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_tile_8x8_4x4_fsv.h
+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_tile_8x8_4x4_fsv.h
@@ -25,6 +25,7 @@ protected:
CommonDispatchData SetDefault(const permute_params& params) const override;
std::vector<FusedOpType> GetSupportedFusedOps() const override {
return {
+ FusedOpType::REORDER,
FusedOpType::ACTIVATION,
FusedOpType::QUANTIZE,
FusedOpType::ELTWISE
diff --git a/src/plugins/intel_gpu/tests/unit/fusions/permute_fusion_test.cpp b/src/plugins/intel_gpu/tests/unit/fusions/permute_fusion_test.cpp
index 2714653727f..cdebbd95bff 100644
--- a/src/plugins/intel_gpu/tests/unit/fusions/permute_fusion_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/fusions/permute_fusion_test.cpp
@@ -80,6 +80,14 @@ public:
return layout{ p.permute_type, p.permute_format, p.in_shape, padding{} };
}
+ layout get_dynamic_input_layout(permute_reorder_params& p) {
+ ov::PartialShape pshape = {};
+ for (size_t i = 0; i < p.permute_format.dimension(); i++) {
+ pshape.push_back(ov::Dimension::dynamic());
+ }
+ return layout{ pshape, p.permute_type, p.permute_format, padding{} };
+ }
+
layout get_elt_input_layout(permute_reorder_params&p) {
ov::Shape output_shape;
auto input_shape = get_input_layout(p).get_dims();
@@ -506,9 +514,11 @@ INSTANTIATE_TEST_SUITE_P(fusings_gpu, permute_scale_eltwise_actv_scale_actv, ::t
#define CASE_PERMUTE_REORDER_F32_0 { 1, 16, 32, 2 }, { 0, 2, 1, 3 }, { 0, 2, 1, 3 }, data_types::f32, data_types::f32, format::b_fs_yx_fsv16, format::bfyx
#define CASE_PERMUTE_REORDER_F32_1 { 2, 7, 9, 27 }, { 0, 2, 1, 3 }, { 0, 2, 1, 3 }, data_types::f32, data_types::f32, format::b_fs_yx_fsv4, format::bfyx
#define CASE_PERMUTE_REORDER_F32_2 { 1, 16, 4, 5, 16 }, { 0, 2, 3, 4, 1 }, { 0, 2, 3, 4, 1 }, data_types::f32, data_types::f32, format::b_fs_zyx_fsv16, format::bfzyx
+#define CASE_PERMUTE_REORDER_F32_3 { 1, 16, 32, 2 }, { 0, 2, 1, 3 }, { 0, 2, 1, 3 }, data_types::f32, data_types::f32, format::bfyx, format::b_fs_yx_fsv16
#define CASE_PERMUTE_REORDER_F16_0 { 1, 16, 2, 4 }, { 0, 2, 1, 3 }, { 0, 2, 1, 3 }, data_types::f16, data_types::f16, format::b_fs_yx_fsv16, format::bfyx
#define CASE_PERMUTE_REORDER_F16_1 { 1, 16, 4, 5, 16 }, { 0, 2, 1, 3, 4 }, { 0, 1, 2, 3, 4 }, data_types::f16, data_types::f16, format::b_fs_zyx_fsv16, format::bfzyx
#define CASE_PERMUTE_REORDER_F16_2 { 1, 5, 1, 2, 14 }, { 0, 3, 2, 1, 4 }, { 0, 3, 2, 1, 4 }, data_types::f16, data_types::f16, format::b_fs_zyx_fsv16, format::bfzyx
+#define CASE_PERMUTE_REORDER_F16_3 { 1, 16, 2, 4 }, { 0, 2, 1, 3 }, { 0, 2, 1, 3 }, data_types::f16, data_types::f16, format::bfyx, format::b_fs_yx_fsv16
// type change
#define CASE_PERMUTE_REORDER_S8_TO_F32_0 { 1, 15, 4, 5 }, { 0, 2, 1, 3 }, { 0, 2, 1, 3 }, data_types::i8, data_types::f32, format::b_fs_yx_fsv4, format::bfyx
@@ -595,6 +605,28 @@ INSTANTIATE_TEST_SUITE_P(fusings_gpu, permute_redundant_reorder, ::testing::Valu
permute_reorder_params{ CASE_PERMUTE_REORDER_TILED_F16_11, 3, 4 },
}));
+class permute_redundant_reorder_dynamic : public PermuteReorderFusingTest {};
+TEST_P(permute_redundant_reorder_dynamic, basic) {
+ cfg_fused.set_property(ov::intel_gpu::allow_new_shape_infer(true));
+ cfg_not_fused.set_property(ov::intel_gpu::allow_new_shape_infer(true));
+
+ auto p = GetParam();
+ create_topologies(
+ input_layout("input", get_dynamic_input_layout(p)),
+ permute("permute1", input_info("input"), p.permute_order1),
+ reorder("reorder1", input_info("permute1"), p.output_format, p.output_type), // to be fused
+ permute("permute2", input_info("reorder1"), p.permute_order2) // dummy last op to make reorder fused
+ );
+
+ tolerance = 1e-5f;
+ execute(p);
+}
+
+INSTANTIATE_TEST_SUITE_P(fusings_gpu, permute_redundant_reorder_dynamic, ::testing::ValuesIn(std::vector<permute_reorder_params>{
+ permute_reorder_params{ CASE_PERMUTE_REORDER_F32_3, 3, 4 },
+ permute_reorder_params{ CASE_PERMUTE_REORDER_F16_3, 3, 4 },
+}));
+
class permute_act_reorder : public PermuteReorderFusingTest {};
TEST_P(permute_act_reorder, basic) {
diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/group_normalization_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/group_normalization_gpu_test.cpp
index ccfb31cb4ca..fbcae03896b 100644
--- a/src/plugins/intel_gpu/tests/unit/test_cases/group_normalization_gpu_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_cases/group_normalization_gpu_test.cpp
@@ -8,10 +8,11 @@
#include "program_wrapper.h"
#include "pass_manager.h"
-#include <intel_gpu/primitives/input_layout.hpp>
-#include <intel_gpu/primitives/group_normalization.hpp>
-#include <intel_gpu/primitives/reorder.hpp>
-#include <intel_gpu/primitives/permute.hpp>
+#include "intel_gpu/primitives/input_layout.hpp"
+#include "intel_gpu/primitives/group_normalization.hpp"
+#include "intel_gpu/primitives/reorder.hpp"
+#include "intel_gpu/primitives/permute.hpp"
+#include "intel_gpu/primitives/eltwise.hpp"
#include "openvino/reference/group_normalization.hpp"
#include "intel_gpu/runtime/compilation_context.hpp"
@@ -26,6 +27,7 @@ typedef std::tuple<
std::size_t, // Number of groups
double, // Epsilon
format, // First input layout
+ format, // Output layout
padding // Output padding
>
GroupNormalizationParams;
@@ -37,13 +39,14 @@ public:
void SetUp() override {
std::vector<std::int32_t> input_shape;
const auto& params = GetParam();
- std::tie(input_shape, num_groups_, epsilon_, format_, output_pad_) = params;
+ std::tie(input_shape, num_groups_, epsilon_, in_format_, out_format_, output_pad_) = params;
std::copy(std::begin(input_shape), std::end(input_shape), std::back_inserter(data_shape_));
tests::random_generator rg{"GroupNormalizationGPUTest"};
data_ = rg.generate_random_1d<float>(ov::shape_size(input_shape), -1, 1);
scale_ = rg.generate_random_1d<float>(input_shape[1], -1, 1);
bias_ = rg.generate_random_1d<float>(input_shape[1], -1, 1);
- const auto planar_format = format::dimension(format_) == 4 ? format::bfyx : format::bfzyx;
+ const auto planar_format = format::dimension(in_format_) == 4 ? format::bfyx : format::bfzyx;
+ bool is_dynamic_test = (in_format_ != out_format_);
topology tp;
auto &engine = get_test_engine();
@@ -52,10 +55,19 @@ public:
static_cast<std::int32_t>(scale_.size()), 1, 1}};
primitive_id reordered_data_primitive = data_primitive_ + "_reordered";
- tp.add(input_layout{data_primitive_, data_layout_});
+ if (is_dynamic_test) {
+ ov::PartialShape pshape = {};
+ for (size_t i = 0; i < in_format_.dimension(); i++) {
+ pshape.push_back(ov::Dimension::dynamic());
+ }
+ layout in_layout{pshape, data_types::f32, planar_format};
+ tp.add(input_layout{data_primitive_, in_layout});
+ } else {
+ tp.add(input_layout{data_primitive_, data_layout_});
+ }
tp.add(input_layout{scale_primitive_, scale_bias_layout_});
tp.add(input_layout{bias_primitive_, scale_bias_layout_});
- tp.add(reorder{reordered_data_primitive, data_primitive_, format_, data_types::f32});
+ tp.add(reorder{reordered_data_primitive, data_primitive_, in_format_, data_types::f32});
auto g = group_normalization{
"group_normalization_output",
@@ -67,9 +79,20 @@ public:
};
g.output_paddings = {output_pad_};
tp.add(g);
- tp.add(reorder{"output", input_info("group_normalization_output"), planar_format, data_types::f32});
+ tp.add(reorder{"group_normalization_output_reordered", input_info("group_normalization_output"), out_format_, data_types::f32});
+ tp.add(eltwise{"dummy_max",
+ input_info("group_normalization_output_reordered"),
+ input_info("group_normalization_output_reordered"),
+ cldnn::eltwise_mode::max});
+ tp.add(reorder{"output", input_info("dummy_max"), planar_format, data_types::f32});
+
+ auto config = get_test_default_config(engine);
+ if (is_dynamic_test) {
+ config.set_property(ov::intel_gpu::optimize_data(true));
+ config.set_property(ov::intel_gpu::allow_new_shape_infer(true));
+ }
- network_ = std::make_shared<cldnn::network>(engine, tp, get_test_default_config(engine));
+ network_ = std::make_shared<cldnn::network>(engine, tp, config);
}
void Test() {
@@ -103,7 +126,8 @@ private:
std::vector<float> bias_{};
std::size_t num_groups_{};
double epsilon_{};
- format format_{format::any};
+ format in_format_{format::any};
+ format out_format_{format::any};
padding output_pad_{padding()};
network::ptr network_{};
layout data_layout_{};
@@ -130,6 +154,11 @@ const std::vector<cldnn::format> f_blocked_4d_formats {
format::b_fs_yx_fsv16,
};
+const std::vector<cldnn::format> f_4d_formats {
+ format::bfyx,
+ format::b_fs_yx_fsv16,
+};
+
const std::vector<cldnn::format> f_planar_5d_formats {
format::bfzyx,
};
@@ -141,6 +170,7 @@ INSTANTIATE_TEST_SUITE_P(
::testing::ValuesIn(std::vector<size_t>{1, 4}),
::testing::Values(0.0025),
::testing::ValuesIn(f_planar_4d_formats),
+ ::testing::ValuesIn(f_4d_formats),
::testing::ValuesIn({padding(), padding({0, 0, 1, 1})})));
INSTANTIATE_TEST_SUITE_P(
@@ -150,6 +180,7 @@ INSTANTIATE_TEST_SUITE_P(
::testing::ValuesIn(std::vector<size_t>{1, 2, 4}),
::testing::Values(0.0025),
::testing::ValuesIn(f_blocked_4d_formats),
+ ::testing::ValuesIn(f_4d_formats),
::testing::ValuesIn({padding(), padding({0, 16, 0, 0})})));
INSTANTIATE_TEST_SUITE_P(
@@ -159,6 +190,7 @@ INSTANTIATE_TEST_SUITE_P(
::testing::ValuesIn(std::vector<size_t>{1, 4}),
::testing::Values(0.0025),
::testing::ValuesIn(f_planar_5d_formats),
+ ::testing::ValuesIn(f_planar_5d_formats),
::testing::ValuesIn({padding(), padding({0, 0, 1, 1})})));
} // anonymous namespace