Skip to content

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

[GPU] Extend deconv parameters to match size for onednn (#26793)

Steve Yoo1c01983e995b
diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/deconvolution_onednn.cpp b/src/plugins/intel_gpu/src/graph/impls/onednn/deconvolution_onednn.cpp
index 66b599fecea..1d5707194c5 100644
--- a/src/plugins/intel_gpu/src/graph/impls/onednn/deconvolution_onednn.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/deconvolution_onednn.cpp
@@ -45,6 +45,14 @@ static std::shared_ptr<dnnl::deconvolution_forward::primitive_desc> get_deconvol
pad_r[i] = (is - 1) * stride[i] - os + kernel_range - pad_l[i];
}
+ // Extend deconv parameters in case if spatials rank of output memory doesn't match size of parameters
+ int64_t insert_count = static_cast<int64_t>(output_md.get_dims().size()) - 2 - stride.size();
+ if (insert_count > 0) {
+ stride.insert(stride.end(), insert_count, 1);
+ pad_l.insert(pad_l.end(), insert_count, 0);
+ pad_r.insert(pad_r.end(), insert_count, 0);
+ }
+
if (!prim->bias.empty()) {
auto bias_md = onednn::layout_to_memory_desc(impl_params.get_input_layout(2), dnnl::memory::format_tag::any, true);
return std::make_shared<dnnl::deconvolution_forward::primitive_desc>(
diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/deconvolution_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/deconvolution_gpu_test.cpp
index f5c890390da..70257713686 100644
--- a/src/plugins/intel_gpu/tests/unit/test_cases/deconvolution_gpu_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_cases/deconvolution_gpu_test.cpp
@@ -3060,4 +3060,84 @@ TEST(deconvolution_f32_fw_gpu_onednn, basic_wsiz2x2_in2x2x1x1_stride2_nopad) {
ASSERT_FLOAT_EQ(expected_output_vec[i], output_ptr[i]);
}
}
+
+TEST(deconvolution_gpu_onednn, spatial_1d) {
+ auto& engine = get_test_engine();
+ if (!engine.get_device_info().supports_immad)
+ return;
+
+ tests::random_generator rg(GET_SUITE_NAME);
+ ov::PartialShape input_pshape = {1, 16, 6};
+ ov::PartialShape weights_pshape = {16, 16, 3};
+ layout in_layout{ ov::PartialShape::dynamic(input_pshape.size()), data_types::f16, format::bfyx };
+ layout weights_layout{ weights_pshape, data_types::f16, format::bfyx };
+
+ auto weights_data = rg.generate_random_1d<ov::float16>(weights_layout.count(), -1, 1);
+ auto weights_mem = engine.allocate_memory(weights_layout);
+ set_values(weights_mem, weights_data);
+
+ auto create_topology =[&]() {
+ topology topology;
+ topology.add(input_layout("input", in_layout));
+ topology.add(data("weights", weights_mem));
+ topology.add(deconvolution("deconv",
+ input_info("input"),
+ { "weights" },
+ 1,
+ ov::Strides{1},
+ ov::CoordinateDiff{0},
+ ov::Strides{1}));
+ topology.add(reorder("reorder", input_info("deconv"), format::bfyx, data_types::f32));
+ return topology;
+ };
+
+ auto topology_test = create_topology();
+ auto topology_ref = create_topology();
+
+ ExecutionConfig config_test = get_test_default_config(engine);
+ ov::intel_gpu::ImplementationDesc deconv_impl_test = { format::b_fs_yx_fsv16, "", impl_types::onednn };
+ config_test.set_property(ov::intel_gpu::force_implementations(ov::intel_gpu::ImplForcingMap{ { "deconv", deconv_impl_test } }));
+ config_test.set_property(ov::intel_gpu::optimize_data(true));
+ config_test.set_property(ov::intel_gpu::allow_new_shape_infer(true));
+
+ ExecutionConfig config_ref = get_test_default_config(engine);
+ ov::intel_gpu::ImplementationDesc deconv_impl_ref = { format::bfyx, "", impl_types::ocl };
+ config_ref.set_property(ov::intel_gpu::force_implementations(ov::intel_gpu::ImplForcingMap{{ "deconv", deconv_impl_ref } }));
+ config_ref.set_property(ov::intel_gpu::optimize_data(true));
+ config_ref.set_property(ov::intel_gpu::allow_new_shape_infer(true));
+
+ network network_test(engine, topology_test, config_test);
+ network network_ref(engine, topology_ref, config_ref);
+
+ auto input_data = rg.generate_random_1d<ov::float16>(input_pshape.size(), -1, 1);
+ auto input_mem = engine.allocate_memory({ input_pshape, data_types::f16, format::bfyx });
+ set_values(input_mem, input_data);
+
+ network_test.set_input_data("input", input_mem);
+ network_ref.set_input_data("input", input_mem);
+
+ auto outputs_test = network_test.execute();
+ auto outputs_ref = network_ref.execute();
+
+ ASSERT_EQ(outputs_test.size(), size_t(1));
+ ASSERT_EQ(outputs_test.begin()->first, "reorder");
+ ASSERT_EQ(outputs_ref.size(), size_t(1));
+ ASSERT_EQ(outputs_ref.begin()->first, "reorder");
+
+ auto output_memory_test = outputs_test.at("reorder").get_memory();
+ auto output_layout_test = output_memory_test->get_layout();
+ cldnn::mem_lock<float> output_ptr_test(output_memory_test, get_test_stream());
+
+ auto output_memory_ref = outputs_ref.at("reorder").get_memory();
+ auto output_layout_ref = output_memory_ref->get_layout();
+ cldnn::mem_lock<float> output_ptr_ref(output_memory_ref, get_test_stream());
+
+ ov::PartialShape expected_shape = {1, 16, 8};
+ ASSERT_EQ(output_layout_test.get_partial_shape(), expected_shape);
+ ASSERT_EQ(output_layout_ref.get_partial_shape(), expected_shape);
+
+ for (size_t i = 0; i < output_memory_ref->count(); i++) {
+ ASSERT_EQ(output_ptr_ref.data()[i], output_ptr_test.data()[i]);
+ }
+}
#endif