OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[GPU] OneDNN 3.8 fix (#30312)
Eddy Kim0d0dee69b9ec
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.cppindex 737abdf147f..6ebb72034b2 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@@ -92,20 +92,6 @@ protected:bool batched_dims_can_be_removed = false;- if (in0_l.count() != 0 && in1_l.count() != 0) {- size_t in0_batched_size = in0_l.count() / (in0_l.spatial(0) * in0_l.spatial(1));- size_t in1_batched_size = in1_l.count() / (in1_l.spatial(0) * in1_l.spatial(1));- size_t out_batched_size = out_l.count() / (out_l.spatial(0) * out_l.spatial(1));-- batched_dims_can_be_removed = in0_batched_size == 1 && in1_batched_size == 1 && out_batched_size == 1;- }-- if (gemm_with_bias) {- const auto& bias_l = in_layouts[2];- size_t bias_batched_size = bias_l.count() / (bias_l.spatial(0) * bias_l.spatial(1));- batched_dims_can_be_removed &= bias_batched_size == 1;- }-size_t rank = cldnn::format::dimension(out_l.format);in0_dt = onednn::convert_data_type(in0_l.data_type);diff --git a/src/plugins/intel_gpu/src/graph/program_node.cpp b/src/plugins/intel_gpu/src/graph/program_node.cppindex c109ae422a2..3cb8074302f 100644--- a/src/plugins/intel_gpu/src/graph/program_node.cpp+++ b/src/plugins/intel_gpu/src/graph/program_node.cpp@@ -1521,6 +1521,15 @@ void program_node::create_onednn_primitive_attributes(memory_offset++;};+ auto resize_layout_for_fc = [](const program_node *node, layout& in_layout) {+ if (node->is_type<fully_connected>()) {+ auto input_size = node->as<fully_connected>().get_primitive()->input_size;+ auto new_pshape = in_layout.get_partial_shape();+ new_pshape.resize(input_size);+ in_layout.set_partial_shape(new_pshape);+ }+ };+int32_t num_sum_post_ops = 0;for (size_t idx = 0; idx < cldnn_post_ops.size(); idx++) {auto& desc = cldnn_post_ops[idx];@@ -1582,8 +1591,7 @@ void program_node::create_onednn_primitive_attributes(new_layout.set_partial_shape(new_input_pshape);in = new_layout;}- size_t in_batched_size = in.count() / (in.spatial(0) * in.spatial(1));- dnnl::memory::dims dims = onednn::convert_gemm_tensor(in.get_tensor(), rank, in_batched_size == 1);+ dnnl::memory::dims dims = onednn::convert_gemm_tensor(in.get_tensor(), rank, false);dnnl::memory::data_type dt = onednn::convert_data_type(in.data_type);dnnl::memory::format_tag fmt = onednn::convert_gemm_data_format(dims, in.format);post_ops.append_binary(alg, dnnl::memory::desc(dims, dt, fmt));@@ -1648,6 +1656,7 @@ void program_node::create_onednn_primitive_attributes(update_onednn_post_op_list(onednn_post_op_type::eltwise_linear, empty_mem);} else {auto in_scale = get_input_layout(dep_idx++);+ resize_layout_for_fc(this, in_scale);dnnl::memory::desc in_scale_desc = onednn::layout_to_memory_desc(in_scale, onednn::get_default_data_format(in_scale));post_ops.append_binary(dnnl::algorithm::binary_mul, in_scale_desc);update_onednn_post_op_list(onednn_post_op_type::binary_mul, dep_idx - 1, onednn::get_default_data_format(in_scale), false,@@ -1660,6 +1669,7 @@ void program_node::create_onednn_primitive_attributes(update_onednn_post_op_list(onednn_post_op_type::eltwise_linear, empty_mem);} else {auto in_shift = get_input_layout(dep_idx++);+ resize_layout_for_fc(this, in_shift);dnnl::memory::desc in_shift_desc = onednn::layout_to_memory_desc(in_shift, onednn::get_default_data_format(in_shift));post_ops.append_binary(dnnl::algorithm::binary_add, in_shift_desc);update_onednn_post_op_list(onednn_post_op_type::binary_add, dep_idx - 1, onednn::get_default_data_format(in_shift), false,@@ -1692,6 +1702,7 @@ void program_node::create_onednn_primitive_attributes(update_onednn_post_op_list(onednn_post_op_type::eltwise_linear, empty_mem);} else {auto out_scale = get_input_layout(dep_idx++);+ resize_layout_for_fc(this, out_scale);dnnl::memory::desc out_scale_desc = onednn::layout_to_memory_desc(out_scale, onednn::get_default_data_format(out_scale));post_ops.append_binary(dnnl::algorithm::binary_mul, out_scale_desc);update_onednn_post_op_list(onednn_post_op_type::binary_mul, dep_idx - 1, onednn::get_default_data_format(out_scale), false,@@ -1705,6 +1716,7 @@ void program_node::create_onednn_primitive_attributes(update_onednn_post_op_list(onednn_post_op_type::eltwise_linear, empty_mem);} else {auto out_shift = get_input_layout(dep_idx++);+ resize_layout_for_fc(this, out_shift);dnnl::memory::desc out_shift_desc = onednn::layout_to_memory_desc(out_shift, onednn::get_default_data_format(out_shift));post_ops.append_binary(dnnl::algorithm::binary_add, out_shift_desc);update_onednn_post_op_list(onednn_post_op_type::binary_add, dep_idx - 1, onednn::get_default_data_format(out_shift), false,diff --git a/src/plugins/intel_gpu/src/runtime/ocl/ocl_device.cpp b/src/plugins/intel_gpu/src/runtime/ocl/ocl_device.cppindex 7f929e0b268..8931d0dc435 100644--- a/src/plugins/intel_gpu/src/runtime/ocl/ocl_device.cpp+++ b/src/plugins/intel_gpu/src/runtime/ocl/ocl_device.cpp@@ -322,10 +322,9 @@ device_info init_device_info(const cl::Device& device, const cl::Context& contex#ifdef ENABLE_ONEDNN_FOR_GPUusing namespace dnnl::impl::gpu::intel::jit;- ngen::HW hw = ngen::HW::Unknown;- ngen::Product product = {ngen::ProductFamily::Unknown, 0};- generator_t<ngen::HW::Unknown>::detectHWInfo(context.get(), device.get(), hw, product);- info.arch = convert_ngen_arch(hw);+ ngen::Product product = ngen::OpenCLCodeGenerator<ngen::HW::Unknown>::detectHWInfo(context.get(), device.get());+ info.arch = convert_ngen_arch(ngen::getCore(product.family));+// We change the value of this flag to avoid OneDNN usage for the platforms unknown to OneDNN// This is required to guarantee some level of forward compatibility for the new HW generations// as OneDNN code generators are not generic and typically requires some updates for the new architecturesdiff --git a/src/plugins/intel_gpu/src/runtime/ocl/ocl_engine.cpp b/src/plugins/intel_gpu/src/runtime/ocl/ocl_engine.cppindex 58f6fbb767a..794f30f0ae9 100644--- a/src/plugins/intel_gpu/src/runtime/ocl/ocl_engine.cpp+++ b/src/plugins/intel_gpu/src/runtime/ocl/ocl_engine.cpp@@ -64,38 +64,7 @@ void ocl_engine::create_onednn_engine(const ExecutionConfig& config) {auto casted = std::dynamic_pointer_cast<ocl_device>(_device);OPENVINO_ASSERT(casted, "[GPU] Invalid device type stored in ocl_engine");- const auto& cache_dir = config.get_cache_dir();- if (cache_dir.empty()) {- _onednn_engine = std::make_shared<dnnl::engine>(dnnl::ocl_interop::make_engine(casted->get_device().get(), casted->get_context().get()));- } else {- // Use cached blob- auto path = cache_dir;- if (path.back() != '/' && path.back() != '\\') {- path += "/";- }-- auto blob_id = dnnl::ocl_interop::get_engine_cache_blob_id(casted->get_device().get());- if (blob_id.empty()) {- // Create engine without cache_blob- _onednn_engine = std::make_shared<dnnl::engine>(dnnl::ocl_interop::make_engine(casted->get_device().get(), casted->get_context().get()));- return;- }-- std::string id_str(blob_id.begin(), blob_id.end());- size_t hash = std::hash<std::string>()(id_str);- path = path + std::to_string(hash) + ".onednn.cl_cache";-- auto onednn_cache_blob = ov::util::load_binary(path);- if (onednn_cache_blob.empty()) {- _onednn_engine = std::make_shared<dnnl::engine>(dnnl::ocl_interop::make_engine(casted->get_device().get(), casted->get_context().get()));-- onednn_cache_blob = dnnl::ocl_interop::get_engine_cache_blob(*_onednn_engine);- ov::intel_gpu::save_binary(path, onednn_cache_blob);- } else {- _onednn_engine = std::make_shared<dnnl::engine>(dnnl::ocl_interop::make_engine(casted->get_device().get(), casted->get_context().get(),- onednn_cache_blob));- }- }+ _onednn_engine = std::make_shared<dnnl::engine>(dnnl::ocl_interop::make_engine(casted->get_device().get(), casted->get_context().get()));}}diff --git a/src/plugins/intel_gpu/thirdparty/onednn_gpu b/src/plugins/intel_gpu/thirdparty/onednn_gpuindex fb61a91dd06..e571132a8cc 160000--- a/src/plugins/intel_gpu/thirdparty/onednn_gpu+++ b/src/plugins/intel_gpu/thirdparty/onednn_gpu@@ -1 +1 @@-Subproject commit fb61a91dd068f9f5abfe2629edbd7cdf53712c7a+Subproject commit e571132a8cc7b91a69422558b5932595f6d1f220