From 7659551d71aca94cc54c846274080af96c348e01 Mon Sep 17 00:00:00 2001 From: "Dohyun Kim (Felix)" Date: Tue, 7 Feb 2023 16:37:26 +0900 Subject: [PATCH] [GPU][DG2] Fix fusings_gpu/gemm_2in_scale.basic/7 (#15353) * Onednn only supports 2D/3D gemm but openvino GPU plugin policy enforces 4D~6D. This API mismatch causes problems in the post-op axis and requires massive code changes. Therefore we decided to insert throw code for now and fix this issue later if some models require non-(per tensor/full tensor) post-ops. * Specifically, per-channel(=f) axis in this testcase becomes y-axis because onednn gemm merges b,f axes into one batch axis. --- .../intel_gpu/src/graph/impls/onednn/gemm_onednn.cpp | 8 ++++++++ src/plugins/intel_gpu/tests/fusions/gemm_fusion_test.cpp | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/gemm_onednn.cpp b/src/plugins/intel_gpu/src/graph/impls/onednn/gemm_onednn.cpp index 49d5ed8e4fb..2b789fc34d4 100644 --- a/src/plugins/intel_gpu/src/graph/impls/onednn/gemm_onednn.cpp +++ b/src/plugins/intel_gpu/src/graph/impls/onednn/gemm_onednn.cpp @@ -301,6 +301,14 @@ public: } static std::unique_ptr create(const gemm_node& arg, const kernel_impl_params& impl_params) { + bool full_tensor_or_per_tensor = true; + for (auto prim : arg.get_fused_primitives()) { + full_tensor_or_per_tensor &= + prim.input_layout.count() == prim.output_layout.count() || prim.input_layout.count() == 1; + } + if (!full_tensor_or_per_tensor) { + IE_THROW() << "Unimplemented: per channel binary post-operation is not supported for onednn gemm. Refer PR(#15353) message."; + } auto& engine = impl_params.prog->get_engine(); auto& config = impl_params.prog->get_config(); auto attr = arg.get_onednn_primitive_attributes(); diff --git a/src/plugins/intel_gpu/tests/fusions/gemm_fusion_test.cpp b/src/plugins/intel_gpu/tests/fusions/gemm_fusion_test.cpp index b30141e6abf..bcfc06cd6fb 100644 --- a/src/plugins/intel_gpu/tests/fusions/gemm_fusion_test.cpp +++ b/src/plugins/intel_gpu/tests/fusions/gemm_fusion_test.cpp @@ -74,6 +74,11 @@ public: } layout get_per_channel_layout(gemm_test_params& p) { + // WA: per channel binary post-operation is not supported for onednn gemm. Use single value for such case. + if (engine.get_device_info().supports_immad){ + std::cout << "per_channel layout for onednn gemm not supported." << std::endl; + return layout{p.default_type, p.default_format, tensor{1, 1, 1, 1}}; + } return layout{ p.default_type, p.default_format, tensor{ 1, p.in_shapes.at(0).feature[0], 1, 1 } }; }