Skip to content

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

[GPU] Fix rank-2 weights detection in FullyConnected (#36950)

Andrew Kwangwoong Park2c3fe6fa4f19
diff --git a/src/plugins/intel_gpu/src/graph/fully_connected.cpp b/src/plugins/intel_gpu/src/graph/fully_connected.cpp
index c69163668bd..13cb6ccb863 100644
--- a/src/plugins/intel_gpu/src/graph/fully_connected.cpp
+++ b/src/plugins/intel_gpu/src/graph/fully_connected.cpp
@@ -131,7 +131,8 @@ layout fully_connected_inst::calc_output_layout(fully_connected_node const& node
if (weights_pshape.size() != 2) {
// Detect 3D weights being passed to oneDNN
- if (supports_immad && weights_pshape.size() == 4 && weights_layout.batch() > 1 && weights_layout.spatial(1) == feature) {
+ if (supports_immad && desc->weights_rank == 3 && weights_pshape.size() == 4 &&
+ weights_layout.batch() > 1 && weights_layout.spatial(1) == feature) {
return calc_output_layouts<ov::PartialShape>(node, impl_param)[0];
} else {
weights_layout.set_partial_shape(reshape_to_2d(weights_pshape, feature));
diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/mat_mul.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/mat_mul.cpp
index 9f60589fb5b..c62ec4ea8a3 100644
--- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/mat_mul.cpp
+++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/mat_mul.cpp
@@ -150,6 +150,20 @@ INSTANTIATE_TEST_SUITE_P(smoke_MatMul_fc_fb_io_block_f16, GPUMatMulLayerTest,
::testing::Values(additional_config)),
MatMulLayerTest::getTestCaseName);
+std::vector<std::vector<ov::Shape>> fc_rank2_weights_shapeRelatedParams = {
+ { {1, 1}, {64, 1} },
+};
+
+INSTANTIATE_TEST_SUITE_P(smoke_MatMul_fc_rank2_weights, GPUMatMulLayerTest,
+ ::testing::Combine(
+ ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(fc_rank2_weights_shapeRelatedParams)),
+ ::testing::Values(std::make_pair(false, true)),
+ ::testing::ValuesIn(fc_f16_inputPrecisions),
+ ::testing::ValuesIn(fc_f16_secondaryInputTypes),
+ ::testing::Values(ov::test::utils::DEVICE_GPU),
+ ::testing::Values(additional_config)),
+ MatMulLayerTest::getTestCaseName);
+
std::vector<std::vector<ov::Shape>> fc4d_shapeRelatedParams = {
{ {16, 16, 16, 576}, {576, 1728} },
};