Skip to content

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

[GPU] reorder_inputs fixed (#29638)

Mingyu Kimc1527ced68f0
diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/reorder_inputs.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/reorder_inputs.cpp
index 2eba5148acf..7a98f3c37ab 100644
--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/reorder_inputs.cpp
+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/reorder_inputs.cpp
@@ -115,7 +115,7 @@ struct travel_direction_wrapper<direction_e::backwards> {
};
static format get_target_output_format(layout_optimizer& lo, const std::map<program_node*, format::type>& fmt_map, program_node *node, program_node *next) {
- auto user_idx = node->get_user_index(*next);
+ auto user_idx = next->get_dependency_output_port(*node);
// 1. Check selected preferred_output_format
auto ret = node->get_preferred_output_fmt(user_idx);
@@ -541,16 +541,11 @@ static bool is_weights_dependency(program_node* predecessor, program_node* succe
// If there is layout mismatch between two layers, add reorder
template <direction_e dir>
void insert_reorders_in_dir(program& p, const std::map<program_node*, format::type>& fmt_map, reorder_factory& rf, layout_optimizer& lo, program_node* node) {
- auto fmt = fmt_map.at(node);
-
auto next_cpy = travel_direction_wrapper<dir>::next_nodes(node);
for (auto next : next_cpy) {
if (!next->is_in_data_flow())
continue;
- if (fmt_map.count(next) > 0 && fmt_map.at(next) == fmt)
- continue;
-
if (is_weights_dependency(node, next))
continue;
@@ -567,6 +562,8 @@ void insert_reorders_in_dir(program& p, const std::map<program_node*, format::ty
in_layout.format = get_target_output_format(lo, fmt_map, predecessor, successor);
out_layout.format = get_target_input_format(lo, fmt_map, successor, predecessor);
+ if (in_layout.format == out_layout.format)
+ continue;
GPU_DEBUG_LOG << dir_msg(dir) << " " << node->id() << " --> " << next->id() << " ## "
<< fmt_to_str(in_layout.format) << " --> " << fmt_to_str(out_layout.format) << std::endl;
diff --git a/src/plugins/intel_gpu/tests/unit/fusions/convolution_fusion_test.cpp b/src/plugins/intel_gpu/tests/unit/fusions/convolution_fusion_test.cpp
index 6fb20181eb1..c64f64906d8 100644
--- a/src/plugins/intel_gpu/tests/unit/fusions/convolution_fusion_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/fusions/convolution_fusion_test.cpp
@@ -2408,6 +2408,12 @@ INSTANTIATE_TEST_SUITE_P(fusings_gpu, conv_int8_scale_quantize_i8, ::testing::Va
class conv_int8_scale_quantize_i8_conv_b_fs_yx_fsv4_int8 : public ConvFusingTest {};
TEST_P(conv_int8_scale_quantize_i8_conv_b_fs_yx_fsv4_int8, basic) {
+ if (engine.get_device_info().supports_immad) {
+ std::cout << "[ SKIPPED ] The test is skipped (not targeting for onednn path)." << std::endl;
+ ASSERT_EQ(1, 1);
+ return;
+ }
+
auto p = GetParam();
create_topologies(
input_layout("input", get_input_layout(p)),
diff --git a/src/plugins/intel_gpu/tests/unit/passes/add_onednn_optimization_attributes_test.cpp b/src/plugins/intel_gpu/tests/unit/passes/add_onednn_optimization_attributes_test.cpp
index fc46e52ae44..5df98a9bea3 100644
--- a/src/plugins/intel_gpu/tests/unit/passes/add_onednn_optimization_attributes_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/passes/add_onednn_optimization_attributes_test.cpp
@@ -65,9 +65,9 @@ TEST(add_onednn_optimization_attributes, sum_post_op_for_residual_connection) {
if (!engine.get_device_info().supports_immad)
return;
- auto in_layout = layout{ov::PartialShape({1, 3, 32, 32}), data_types::f16, format::bfyx};
- auto input = engine.allocate_memory(layout{ov::PartialShape({1, 3, 32, 32}), data_types::f16, format::bfyx});
- auto weight = engine.allocate_memory(layout{ov::PartialShape({3, 3, 1, 1}), data_types::f16, format::bfyx});
+ auto in_layout = layout{ov::PartialShape({1, 16, 32, 32}), data_types::f16, format::bfyx};
+ auto input = engine.allocate_memory(layout{ov::PartialShape({1, 16, 32, 32}), data_types::f16, format::bfyx});
+ auto weight = engine.allocate_memory(layout{ov::PartialShape({16, 16, 1, 1}), data_types::f16, format::bfyx});
topology topology;
topology.add(input_layout("input", in_layout));
diff --git a/src/plugins/intel_gpu/tests/unit/passes/reorder_inputs_test.cpp b/src/plugins/intel_gpu/tests/unit/passes/reorder_inputs_test.cpp
index 1322c25025f..9fb9982e8c2 100644
--- a/src/plugins/intel_gpu/tests/unit/passes/reorder_inputs_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/passes/reorder_inputs_test.cpp
@@ -580,4 +580,41 @@ TEST(reorder_inputs, has_reshape_user) {
ASSERT_EQ(static_cast<float>(ref_output[x]), output_ptr[x]);
}
}
+
+TEST(reorder_inputs, two_connections_with_different_format) {
+ // Topology:
+ // convolution(fsv16) ___ convolution
+ // \__ deformable_conv
+ // \_ reshape
+ // Purpose:
+ // When convolution has reshape as a user, its layout may be chosen in a confusing way from get_preferred_format.
+ // This test mimics the behavior.
+ //
+ // Expectation:
+ // Reorder should be added only to deformable_conv as deformable_conv supports bfyx only.
+
+ auto& engine = get_test_engine();
+ auto input = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 32, 128, 128 } });
+ auto weights = engine.allocate_memory({ data_types::f16, format::bfyx, { 32, 32, 1, 1 } });
+ auto trans = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 2, 128, 128 } });
+
+ topology topology;
+ topology.add(data("weights", weights));
+ topology.add(data("trans", trans));
+ topology.add(input_layout("input", input->get_layout()));
+ topology.add(convolution("conv1", input_info("input"), "weights", "", 1, {1, 1}, {1, 1}, {0, 0}, {0, 0}, false));
+ topology.add(convolution("conv2", input_info("conv1"), "weights", "", 1, {1, 1}, {1, 1}, {0, 0}, {0, 0}, false));
+ topology.add(convolution("deform_conv", {input_info("conv1"), input_info("trans")}, "weights", "", true, 1, 1, {1, 1}, {1, 1}, {0, 0}, {0, 0}));
+ topology.add(reshape("reshape", input_info("conv1"), tensor(2, 16, 128, 128), cldnn::reshape::reshape_mode::base));
+
+ ExecutionConfig config = get_test_default_config(engine);
+ config.set_property(ov::intel_gpu::allow_new_shape_infer(true));
+ config.set_property(ov::intel_gpu::optimize_data(true));
+ auto prog = program::build_program(engine, topology, config);
+
+ auto& node = prog->get_node("deform_conv");
+ ASSERT_NE(node.get_selected_impl(), nullptr);
+ auto kernel_name = node.get_selected_impl()->get_kernel_name();
+ ASSERT_EQ(kernel_name, "deformable_convolution_gpu_bfyx_opt");
+}
#endif
diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/convolution_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/convolution_gpu_test.cpp
index 488727015bc..8ba87060f2f 100644
--- a/src/plugins/intel_gpu/tests/unit/test_cases/convolution_gpu_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_cases/convolution_gpu_test.cpp
@@ -5325,6 +5325,11 @@ TEST_P(convolution_gpu_fs_byx_fsv32, fs_byx_fsv32)
return;
}
+ if (engine.get_device_info().supports_immad) {
+ // This test is not targeting for onednn case
+ return;
+ }
+
const int batch_num = 2;
const int input_xy = 5;
const int input_f = testing::get<1>(GetParam());
@@ -7043,6 +7048,10 @@ TEST_P(convolution_depthwise_gpu, depthwise_conv_fs_b_yx_fsv32)
ASSERT_EQ(1, 1);
return;
}
+ if (engine.get_device_info().supports_immad) {
+ // This test is not targeting for onednn case
+ return;
+ }
const int batch_num = 2;
@@ -7726,7 +7735,7 @@ INSTANTIATE_TEST_SUITE_P(convolution_grouped_fsv4_fsv16,
TestParamType_grouped_convolution_gpu(4, 1, 6, 256, 512, 2, 1, 3, 16, 1, 1, true, true, true, format::b_fs_zyx_fsv16, ""),
TestParamType_grouped_convolution_gpu(1, 3, 1, 18, 2, 1, 3, 1, 2, 1, 1, true, true, true, format::b_fs_zyx_fsv16, ""),
TestParamType_grouped_convolution_gpu(2, 3, 4, 3, 18, 3, 3, 3, 1, 1, 1, false, false, false, format::b_fs_zyx_fsv16, "convolution_gpu_mmad_bfyx_to_b_fs_yx_fsv32"),
- TestParamType_grouped_convolution_gpu(79, 224, 224, 3, 64, 3, 3, 3, 1, 2, 1, false, false, false, format::b_fs_zyx_fsv16, "convolution_gpu_mmad_bfyx_to_b_fs_yx_fsv32")
+ TestParamType_grouped_convolution_gpu(79, 112, 112, 3, 32, 3, 3, 3, 1, 2, 1, false, false, false, format::b_fs_zyx_fsv16, "convolution_gpu_mmad_bfyx_to_b_fs_yx_fsv32")
),
convolution_grouped_gpu::PrintToStringParamName);
@@ -7930,7 +7939,9 @@ TEST_P(convolution_grouped_gpu, base) {
cldnn::mem_lock<float, mem_lock_type::read> out_ptr(out_mem, get_test_stream());
auto out_lay = out_mem->get_layout();
- ASSERT_EQ(out_mem->get_layout().format, input_data_format);
+ if (!engine.get_device_info().supports_immad) {
+ ASSERT_EQ(out_mem->get_layout().format, input_data_format); // This assertion is valid only for iGPU case
+ }
ASSERT_EQ(out_lay.batch(), expected_result.size());
ASSERT_EQ(out_lay.feature(), expected_result[0].size());
ASSERT_EQ(out_lay.spatial(2), expected_result[0][0].size());
@@ -7985,6 +7996,11 @@ TEST_P(convolution_general_gpu, conv_fp16_cases) {
ASSERT_EQ(1, 1);
return;
}
+ if (engine.get_device_info().supports_immad) {
+ std::cout << "[ SKIPPED ] The test is skipped (not targeting for onednn path)." << std::endl;
+ ASSERT_EQ(1, 1);
+ return;
+ }
const int input_x = testing::get<0>(GetParam()),
input_y = testing::get<1>(GetParam()),
diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/depth_concatenate_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/depth_concatenate_gpu_test.cpp
index 5aa9ac49d08..56b48c236fc 100644
--- a/src/plugins/intel_gpu/tests/unit/test_cases/depth_concatenate_gpu_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_cases/depth_concatenate_gpu_test.cpp
@@ -409,11 +409,15 @@ TEST(depth_concatenate_f32_gpu, test06_padded_input) {
//
// *Convolution has input offset so it should be propagated, both back to reorders and to second concatenation.
// As a result both concatenations should be optimized out and convolution should use optimized implementation.
+
const int32_t input_f = 32;
const int32_t output_f = 3 * input_f;
tests::random_generator rg(GET_SUITE_NAME);
auto& engine = get_test_engine();
+ if (engine.get_device_info().supports_immad) {
+ return;
+ }
auto input1 = engine.allocate_memory({ data_types::f16, format::fs_b_yx_fsv32, {1, input_f, 1, 1} });
auto input2 = engine.allocate_memory({ data_types::f16, format::fs_b_yx_fsv32, {1, input_f, 1, 1} });