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][CLANG-TIDY] Enable readability-braces-around-statements (#37208)
Nesterov Alexander92c427fa10dd
diff --git a/src/plugins/intel_gpu/.clang-tidy b/src/plugins/intel_gpu/.clang-tidyindex b47e77d5d5c..fba4aea8793 100644--- a/src/plugins/intel_gpu/.clang-tidy+++ b/src/plugins/intel_gpu/.clang-tidy@@ -21,6 +21,7 @@ Checks: >readability-redundant-string-cstr,readability-qualified-auto,readability-else-after-return,+ readability-braces-around-statements,modernize-use-equals-default,modernize-use-equals-delete,readability-implicit-bool-conversion,@@ -50,4 +51,6 @@ CheckOptions:value: true- key: readability-simplify-boolean-expr.SimplifyDeMorganRelaxedvalue: true+ - key: readability-braces-around-statements.ShortStatementLines+ value: "2"---diff --git a/src/plugins/intel_gpu/include/intel_gpu/graph/fused_primitive_desc.hpp b/src/plugins/intel_gpu/include/intel_gpu/graph/fused_primitive_desc.hppindex 6ad035b94d5..cf4d5017d12 100644--- a/src/plugins/intel_gpu/include/intel_gpu/graph/fused_primitive_desc.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/graph/fused_primitive_desc.hpp@@ -50,16 +50,19 @@ struct fused_primitive_desc {template<typename T>std::shared_ptr<T> get_typed_fuse_params() const {auto p = std::dynamic_pointer_cast<T>(f_param);- if (!p)+ if (!p) {throw std::runtime_error("Invalid dynamic cast of fused parameters!");+ }return p;}bool operator==(const fused_primitive_desc& rhs) const {- if (total_num_deps != rhs.total_num_deps)+ if (total_num_deps != rhs.total_num_deps) {return false;- if (outer_dep_start_idx != rhs.outer_dep_start_idx)+ }+ if (outer_dep_start_idx != rhs.outer_dep_start_idx) {return false;+ }return *desc == *rhs.desc;}diff --git a/src/plugins/intel_gpu/include/intel_gpu/graph/kernel_impl_params.hpp b/src/plugins/intel_gpu/include/intel_gpu/graph/kernel_impl_params.hppindex b7dd825dbf5..e0209fe2d93 100644--- a/src/plugins/intel_gpu/include/intel_gpu/graph/kernel_impl_params.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/graph/kernel_impl_params.hpp@@ -4,27 +4,25 @@#pragma once+#include <cstdint>+#include <memory>+#include <string>+#include <vector>++#include "intel_gpu/graph/fused_primitive_desc.hpp"#include "intel_gpu/graph/serialization/binary_buffer.hpp"+#include "intel_gpu/primitives/primitive.hpp"#include "intel_gpu/runtime/engine.hpp"#include "intel_gpu/runtime/memory.hpp"#include "intel_gpu/runtime/stream.hpp"-#include "intel_gpu/runtime/utils.hpp"#include "intel_gpu/runtime/tensor.hpp"-#include "intel_gpu/primitives/primitive.hpp"--#include "intel_gpu/graph/fused_primitive_desc.hpp"--#include <cstdint>-#include <string>-#include <vector>-#include <memory>+#include "intel_gpu/runtime/utils.hpp"namespace cldnn {struct program;struct network;-struct ExecutionFlags : public std::bitset<5> {static const size_t SHAPE_CHANGED = 0;static const size_t IMPL_CHANGED = 1;@@ -35,12 +33,12 @@ struct ExecutionFlags : public std::bitset<5> {struct kernel_impl_params final {struct Hasher {- size_t operator()(const kernel_impl_params &k) const {+ size_t operator()(const kernel_impl_params& k) const {return k.hash();}};- const program *prog;+ const program* prog;cldnn::device_type dev_type;stream::ptr strm;std::shared_ptr<const primitive> desc;@@ -54,7 +52,7 @@ struct kernel_impl_params final {#ifdef ENABLE_ONEDNN_FOR_GPUstd::vector<cldnn::fused_primitive_desc_onednn> fused_desc_onednn;std::shared_ptr<dnnl::primitive_attr> attrs_onednn;-#endif // ENABLE_ONEDNN_FOR_GPU+#endif // ENABLE_ONEDNN_FOR_GPUstd::vector<event::ptr> dep_events;event::ptr out_event = nullptr;@@ -82,8 +80,7 @@ struct kernel_impl_params final {std::map<size_t, size_t> in_port_to_shape_info_offset;std::map<size_t, size_t> out_port_to_shape_info_offset;- kernel_impl_params() : prog(nullptr), dev_type(cldnn::device_type::integrated_gpu), strm(nullptr), desc(nullptr), unique_id(0) {- }+ kernel_impl_params() : prog(nullptr), dev_type(cldnn::device_type::integrated_gpu), strm(nullptr), desc(nullptr), unique_id(0) {}kernel_impl_params(program& _prog,cldnn::device_type _dev_type,@@ -93,24 +90,26 @@ struct kernel_impl_params final {const std::vector<layout>& _in_layouts,const std::vector<layout>& _out_layouts,const std::vector<cldnn::fused_primitive_desc>& _fused_descs)- : prog(&_prog)- , dev_type(_dev_type)- , strm(std::move(_strm))- , desc(std::move(_desc))- , unique_id(_uid)- , input_layouts(_in_layouts)- , output_layouts(_out_layouts)- , fused_desc(_fused_descs)- , primary_input_idx(0) {- }+ : prog(&_prog),+ dev_type(_dev_type),+ strm(std::move(_strm)),+ desc(std::move(_desc)),+ unique_id(_uid),+ input_layouts(_in_layouts),+ output_layouts(_out_layouts),+ fused_desc(_fused_descs),+ primary_input_idx(0) {}~kernel_impl_params() = default;const layout& get_input_layout(size_t idx = 0) const {OPENVINO_ASSERT(input_layouts.size() > idx,"The size of input layouts must be greater than the requested index: ",- "Requested index is ", idx, ", ",- "but the size of input layouts is ", input_layouts.size());+ "Requested index is ",+ idx,+ ", ",+ "but the size of input layouts is ",+ input_layouts.size());return input_layouts[idx];}@@ -123,16 +122,22 @@ struct kernel_impl_params final {const layout& get_output_layout(size_t idx = 0) const {OPENVINO_ASSERT(output_layouts.size() > idx,"The size of output layouts must be greater than the requested index: ",- "Requested index is ", idx, ", ",- "but the size of output layouts is ", output_layouts.size());+ "Requested index is ",+ idx,+ ", ",+ "but the size of output layouts is ",+ output_layouts.size());return output_layouts[idx];}layout& get_output_layout(size_t idx = 0) {OPENVINO_ASSERT(output_layouts.size() > idx,"The size of output layouts must be greater than the requested index: ",- "Requested index is ", idx, ", ",- "but the size of output layouts is ", output_layouts.size());+ "Requested index is ",+ idx,+ ", ",+ "but the size of output layouts is ",+ output_layouts.size());return output_layouts[idx];}@@ -140,21 +145,28 @@ struct kernel_impl_params final {return input_layouts.size();}- bool has_fused_primitives() const { return !fused_desc.empty(); }+ bool has_fused_primitives() const {+ return !fused_desc.empty();+ }ov::element::Type_t get_output_element_type() const {- if (fused_desc.empty())+ if (fused_desc.empty()) {return output_layouts[0].data_type;+ }return fused_desc.back().output_layout.data_type;}bool is_dynamic() const {- for (const auto& i : input_layouts)- if (i.is_dynamic())+ for (const auto& i : input_layouts) {+ if (i.is_dynamic()) {return true;- for (const auto& i : output_layouts)- if (i.is_dynamic())+ }+ }+ for (const auto& i : output_layouts) {+ if (i.is_dynamic()) {return true;+ }+ }return false;}@@ -167,7 +179,9 @@ struct kernel_impl_params final {}template <class PType>- std::shared_ptr<const PType> typed_desc() const { return std::static_pointer_cast<const PType>(desc); }+ std::shared_ptr<const PType> typed_desc() const {+ return std::static_pointer_cast<const PType>(desc);+ }template <class PType>bool is_type() const {@@ -181,8 +195,12 @@ struct kernel_impl_params final {const device_info& get_device_info() const;- stream& get_stream() const { return *strm; }- stream::ptr get_stream_ptr() const { return strm; }+ stream& get_stream() const {+ return *strm;+ }+ stream::ptr get_stream_ptr() const {+ return strm;+ }size_t hash() const;bool operator==(const kernel_impl_params& rhs) const;diff --git a/src/plugins/intel_gpu/include/intel_gpu/graph/network.hpp b/src/plugins/intel_gpu/include/intel_gpu/graph/network.hppindex fe56224e17f..8b02f913fc2 100644--- a/src/plugins/intel_gpu/include/intel_gpu/graph/network.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/graph/network.hpp@@ -132,16 +132,18 @@ public:// Get list of optimized prmitivesstd::vector<primitive_id> optimized_primitives;for (decltype(all_primitive_org_ids.size()) i = 0; i < all_primitive_org_ids.size(); i++) {- if (all_primitive_ids[i] == "_optimized_")+ if (all_primitive_ids[i] == "_optimized_") {optimized_primitives.push_back(all_primitive_org_ids[i]);+ }}std::map<primitive_id, event::ptr> result;for (auto& id : primitive_ids) {if (std::find(optimized_primitives.begin(), optimized_primitives.end(), id) == optimized_primitives.end()) {- if (has_event(id))+ if (has_event(id)) {result.emplace(id, get_primitive_event(id));- else+ } else {result.emplace(id, nullptr);+ }}}return result;diff --git a/src/plugins/intel_gpu/include/intel_gpu/graph/serialization/layout_serializer.hpp b/src/plugins/intel_gpu/include/intel_gpu/graph/serialization/layout_serializer.hppindex 1acfd95a7c7..67024fd2e92 100644--- a/src/plugins/intel_gpu/include/intel_gpu/graph/serialization/layout_serializer.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/graph/serialization/layout_serializer.hpp@@ -100,8 +100,9 @@ public:static void save(BufferType& buffer, const cldnn::format& format) {cldnn::format::type fmt_type = format;buffer << make_data(&fmt_type, sizeof(cldnn::format::type));- if (fmt_type == cldnn::format::custom)+ if (fmt_type == cldnn::format::custom) {buffer << format.traits();+ }}};diff --git a/src/plugins/intel_gpu/include/intel_gpu/graph/serialization/weights_reorder_params.hpp b/src/plugins/intel_gpu/include/intel_gpu/graph/serialization/weights_reorder_params.hppindex 2bfeac2136c..60716004fdf 100644--- a/src/plugins/intel_gpu/include/intel_gpu/graph/serialization/weights_reorder_params.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/graph/serialization/weights_reorder_params.hpp@@ -25,8 +25,9 @@ namespace cldnn {}bool operator==(const WeightsReorderParams& rhs) const {- if (typeid(*this) != typeid(rhs))+ if (typeid(*this) != typeid(rhs)) {return false;+ }return _in_layout == rhs._in_layout &&_out_layout == rhs._out_layout &&diff --git a/src/plugins/intel_gpu/include/intel_gpu/plugin/program_builder.hpp b/src/plugins/intel_gpu/include/intel_gpu/plugin/program_builder.hppindex f24c2995aba..5fc676a6f56 100644--- a/src/plugins/intel_gpu/include/intel_gpu/plugin/program_builder.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/plugin/program_builder.hpp@@ -186,8 +186,9 @@ void CreateElementwiseOp(ProgramBuilder& p,void validate_inputs_count(const std::shared_ptr<ov::Node>& op, std::vector<size_t> possible_inputs_count);inline bool ends_with(const std::string& value, const std::string& suffix) {- if (suffix.size() > value.size())+ if (suffix.size() > value.size()) {return false;+ }return std::equal(suffix.rbegin(), suffix.rend(), value.rbegin());}diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/activation.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/activation.hppindex 157e1ba8c50..626ba2ab1c7 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/activation.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/activation.hpp@@ -133,8 +133,9 @@ struct activation : public primitive_base<activation> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const activation>(rhs);@@ -163,8 +164,9 @@ protected:auto ret = std::map<size_t, const input_info*>{};auto idx = input.size();- if (additional_params_input.is_valid())+ if (additional_params_input.is_valid()) {ret[idx++] = &additional_params_input;+ }return ret;}diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/adaptive_pooling.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/adaptive_pooling.hppindex e06d055b462..b5da933f4f0 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/adaptive_pooling.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/adaptive_pooling.hpp@@ -90,8 +90,9 @@ struct adaptive_pooling : public primitive_base<adaptive_pooling> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const adaptive_pooling>(rhs);@@ -121,8 +122,9 @@ protected:auto ret = std::map<size_t, const input_info*>{};auto idx = input.size();- if (indices_output.is_valid())+ if (indices_output.is_valid()) {ret[idx++] = &indices_output;+ }return ret;}diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/arg_max_min.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/arg_max_min.hppindex 34bf41153b8..5a056158298 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/arg_max_min.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/arg_max_min.hpp@@ -98,8 +98,9 @@ struct arg_max_min : public primitive_base<arg_max_min> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const arg_max_min>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/assign.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/assign.hppindex 241ebbcef4a..37b4bfe1317 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/assign.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/assign.hpp@@ -37,8 +37,9 @@ struct assign : public primitive_base<assign> {ov::element::Type user_specified_type;bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const assign>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/batch_to_space.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/batch_to_space.hppindex b351a0e8d06..9728650b34e 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/batch_to_space.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/batch_to_space.hpp@@ -84,8 +84,9 @@ struct batch_to_space : public primitive_base<batch_to_space> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const batch_to_space>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/border.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/border.hppindex 0d044d720fc..dbddf08556b 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/border.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/border.hpp@@ -86,8 +86,9 @@ struct border : public primitive_base<border> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const border>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/broadcast.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/broadcast.hppindex 3a5be14fa8b..ab8c634e38f 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/broadcast.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/broadcast.hpp@@ -138,8 +138,9 @@ struct broadcast : public primitive_base<broadcast> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const broadcast>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/bucketize.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/bucketize.hppindex 401a46b9a50..80c697ab3c2 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/bucketize.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/bucketize.hpp@@ -34,8 +34,9 @@ struct bucketize : primitive_base<bucketize> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const bucketize>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/col2im.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/col2im.hppindex 639d43518e4..f864cb73173 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/col2im.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/col2im.hpp@@ -62,8 +62,9 @@ struct col2im : public primitive_base<col2im> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const col2im>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/concatenation.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/concatenation.hppindex 7929daae110..3fedf30f949 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/concatenation.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/concatenation.hpp@@ -67,8 +67,9 @@ struct concatenation : public primitive_base<concatenation> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const concatenation>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/convert_color.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/convert_color.hppindex 8b357745fa3..1cea3292073 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/convert_color.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/convert_color.hpp@@ -57,8 +57,9 @@ struct convert_color : public primitive_base<convert_color> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const convert_color>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/convolution.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/convolution.hppindex b7b5d41c5d0..75eb1d923f9 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/convolution.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/convolution.hpp@@ -231,8 +231,9 @@ struct convolution : public primitive_base<convolution> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const convolution>(rhs);@@ -307,17 +308,21 @@ protected:OPENVINO_ASSERT(weights.is_valid());ret[idx++] = &weights;- if (bias.is_valid())+ if (bias.is_valid()) {ret[idx++] = &bias;+ }- if (weights_zero_points.is_valid())+ if (weights_zero_points.is_valid()) {ret[idx++] = &weights_zero_points;+ }- if (activations_zero_points.is_valid())+ if (activations_zero_points.is_valid()) {ret[idx++] = &activations_zero_points;+ }- if (compensation.is_valid())+ if (compensation.is_valid()) {ret[idx++] = &compensation;+ }return ret;}diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/crop.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/crop.hppindex b0b25219609..38090795fec 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/crop.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/crop.hpp@@ -139,8 +139,9 @@ struct crop : public primitive_base<crop> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const crop>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/ctc_greedy_decoder.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/ctc_greedy_decoder.hppindex 49214fd2611..dd1006782bf 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/ctc_greedy_decoder.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/ctc_greedy_decoder.hpp@@ -56,8 +56,9 @@ struct ctc_greedy_decoder : public primitive_base<ctc_greedy_decoder> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const ctc_greedy_decoder>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/ctc_loss.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/ctc_loss.hppindex 0ddfc9195da..eb75cb868a0 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/ctc_loss.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/ctc_loss.hpp@@ -44,8 +44,9 @@ struct ctc_loss : primitive_base<ctc_loss> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const ctc_loss>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/cum_sum.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/cum_sum.hppindex bd582037f91..8ca6f59713b 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/cum_sum.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/cum_sum.hpp@@ -41,8 +41,9 @@ struct cum_sum : public primitive_base<cum_sum> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const cum_sum>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/custom_gpu_primitive.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/custom_gpu_primitive.hppindex 8dd86d3ae27..66da2bea4a0 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/custom_gpu_primitive.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/custom_gpu_primitive.hpp@@ -171,25 +171,31 @@ struct custom_gpu_primitive : public primitive_base<custom_gpu_primitive> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const custom_gpu_primitive>(rhs);- if (kernel_entry_point != rhs_casted.kernel_entry_point)+ if (kernel_entry_point != rhs_casted.kernel_entry_point) {return false;+ }- if (build_options != rhs_casted.build_options)+ if (build_options != rhs_casted.build_options) {return false;+ }- if (kernel_arguments != rhs_casted.kernel_arguments)+ if (kernel_arguments != rhs_casted.kernel_arguments) {return false;+ }- if (kernels_code != rhs_casted.kernels_code)+ if (kernels_code != rhs_casted.kernels_code) {return false;+ }- if (gws != rhs_casted.gws)+ if (gws != rhs_casted.gws) {return false;+ }return lws == rhs_casted.lws;}diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/deconvolution.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/deconvolution.hppindex f040b9a3ebf..c525d539bbc 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/deconvolution.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/deconvolution.hpp@@ -379,8 +379,9 @@ struct deconvolution : public primitive_base<deconvolution> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const deconvolution>(rhs);@@ -443,11 +444,13 @@ protected:OPENVINO_ASSERT(weights.is_valid());ret[idx++] = &weights;- if (bias.is_valid())+ if (bias.is_valid()) {ret[idx++] = &bias;+ }- if (output_shape_id.is_valid())+ if (output_shape_id.is_valid()) {ret[idx++] = &output_shape_id;+ }return ret;}diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/depth_to_space.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/depth_to_space.hppindex b8de2d0f1a0..9b70a34348f 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/depth_to_space.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/depth_to_space.hpp@@ -48,8 +48,9 @@ struct depth_to_space : public primitive_base<depth_to_space> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const depth_to_space>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/detection_output.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/detection_output.hppindex d6d30f115ee..b5046b5ea6f 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/detection_output.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/detection_output.hpp@@ -96,9 +96,10 @@ struct detection_output : public primitive_base<detection_output> {clip_before_nms(clip_before_nms),clip_after_nms(clip_after_nms),objectness_score(objectness_score) {- if (decrease_label_id && background_label_id != 0)+ if (decrease_label_id && background_label_id != 0) {throw std::invalid_argument("Cannot use decrease_label_id and background_label_id parameter simultaneously.");+ }}/// @brief Number of classes to be predicted.@@ -165,8 +166,9 @@ struct detection_output : public primitive_base<detection_output> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const detection_output>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/dft.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/dft.hppindex 6984bace086..f73b1e8a277 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/dft.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/dft.hpp@@ -108,8 +108,9 @@ struct dft : public primitive_base<dft> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const dft>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/dynamic_quantize.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/dynamic_quantize.hppindex 4a2d6a29fef..c5cac3dc85d 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/dynamic_quantize.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/dynamic_quantize.hpp@@ -38,8 +38,9 @@ struct dynamic_quantize : public primitive_base<dynamic_quantize> {, innermost_size(innermost_size) {num_outputs = 2;if (attrs.quantization_type == ov::op::internal::DynamicQuantize::QuantizationType::Asymmetric &&- attrs.output_storage_type == ov::op::internal::DynamicQuantize::OutputStorageType::Planar)+ attrs.output_storage_type == ov::op::internal::DynamicQuantize::OutputStorageType::Planar) {num_outputs++;+ }if (attrs.precomputed_reduction) {num_outputs++;}@@ -67,8 +68,9 @@ struct dynamic_quantize : public primitive_base<dynamic_quantize> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const dynamic_quantize>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/eltwise.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/eltwise.hppindex 0f10253e875..d2ee94e43aa 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/eltwise.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/eltwise.hpp@@ -204,8 +204,9 @@ struct eltwise : public primitive_base<eltwise> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const eltwise>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/embedding_bag.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/embedding_bag.hppindex 7f54d96041c..a0311cbca6a 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/embedding_bag.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/embedding_bag.hpp@@ -48,8 +48,9 @@ struct embedding_bag : public primitive_base<embedding_bag> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const embedding_bag>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/experimental_detectron_detection_output.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/experimental_detectron_detection_output.hppindex 3b04a5de230..b186b40021f 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/experimental_detectron_detection_output.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/experimental_detectron_detection_output.hpp@@ -111,8 +111,9 @@ struct experimental_detectron_detection_output : public primitive_base<experimen}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const experimental_detectron_detection_output>(rhs);@@ -163,11 +164,13 @@ protected:auto ret = std::map<size_t, const input_info*>{};auto idx = input.size();- if (output_classes.is_valid())+ if (output_classes.is_valid()) {ret[idx++] = &output_classes;+ }- if (output_scores.is_valid())+ if (output_scores.is_valid()) {ret[idx++] = &output_scores;+ }return ret;}diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/experimental_detectron_generate_proposals_single_image.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/experimental_detectron_generate_proposals_single_image.hppindex e54f6077a41..29b79f9c88b 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/experimental_detectron_generate_proposals_single_image.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/experimental_detectron_generate_proposals_single_image.hpp@@ -75,8 +75,9 @@ struct experimental_detectron_generate_proposals_single_image}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const experimental_detectron_generate_proposals_single_image>(rhs);@@ -110,8 +111,9 @@ protected:auto ret = std::map<size_t, const input_info*>{};auto idx = input.size();- if (output_roi_scores.is_valid())+ if (output_roi_scores.is_valid()) {ret[idx++] = &output_roi_scores;+ }return ret;}diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/experimental_detectron_prior_grid_generator.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/experimental_detectron_prior_grid_generator.hppindex 0555e5c46fc..1046926eb58 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/experimental_detectron_prior_grid_generator.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/experimental_detectron_prior_grid_generator.hpp@@ -62,8 +62,9 @@ struct experimental_detectron_prior_grid_generator}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const experimental_detectron_prior_grid_generator>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/experimental_detectron_roi_feature_extractor.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/experimental_detectron_roi_feature_extractor.hppindex cc9082a5480..e8514807596 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/experimental_detectron_roi_feature_extractor.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/experimental_detectron_roi_feature_extractor.hpp@@ -54,8 +54,9 @@ struct experimental_detectron_roi_feature_extractor : public primitive_base<expe}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const experimental_detectron_roi_feature_extractor>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/experimental_detectron_topk_rois.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/experimental_detectron_topk_rois.hppindex dcd20854c16..96605b960ff 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/experimental_detectron_topk_rois.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/experimental_detectron_topk_rois.hpp@@ -38,8 +38,9 @@ struct experimental_detectron_topk_rois : public primitive_base<experimental_det}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const experimental_detectron_topk_rois>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/extract_image_patches.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/extract_image_patches.hppindex 8c22e23e233..85ac6a59c16 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/extract_image_patches.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/extract_image_patches.hpp@@ -58,8 +58,9 @@ struct extract_image_patches : public primitive_base<extract_image_patches> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const extract_image_patches>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/eye.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/eye.hppindex 1eab8f4480d..4b3ff1935d7 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/eye.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/eye.hpp@@ -40,8 +40,9 @@ struct eye : public primitive_base<eye> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const eye>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/fake_convert.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/fake_convert.hppindex cacd4c2cd7b..313b6ee5521 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/fake_convert.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/fake_convert.hpp@@ -49,8 +49,9 @@ struct fake_convert : public primitive_base<fake_convert> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const fake_convert>(rhs);return (destination_type == rhs_casted.destination_type);}diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/fully_connected.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/fully_connected.hppindex 5507e171f09..570fb4a82a6 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/fully_connected.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/fully_connected.hpp@@ -145,12 +145,15 @@ struct fully_connected : public primitive_base<fully_connected> {input_size(input_size),weights_rank(weights_rank),weights_transposed(weights_transposed) {- if (activation_scale.is_valid())+ if (activation_scale.is_valid()) {dynamic_quantized_activation = true;- if (activation_zero_point.is_valid())+ }+ if (activation_zero_point.is_valid()) {dynamic_quantized_activation_zp = true;- if (activation_precomputed_reduction.is_valid())+ }+ if (activation_precomputed_reduction.is_valid()) {dynamic_quantized_precomputed_reduction = true;+ }OPENVINO_ASSERT(!decompression_scale.empty(), "[GPU] Compressed fully connected requires at least decompression scale input");}@@ -197,8 +200,9 @@ struct fully_connected : public primitive_base<fully_connected> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const fully_connected>(rhs);@@ -277,23 +281,29 @@ protected:OPENVINO_ASSERT(weights.is_valid());ret[idx++] = &weights;- if (bias.is_valid())+ if (bias.is_valid()) {ret[idx++] = &bias;+ }- if (decompression_scale.is_valid())+ if (decompression_scale.is_valid()) {ret[idx++] = &decompression_scale;+ }- if (decompression_zero_point.is_valid())+ if (decompression_zero_point.is_valid()) {ret[idx++] = &decompression_zero_point;+ }- if (activation_scale.is_valid())+ if (activation_scale.is_valid()) {ret[idx++] = &activation_scale;+ }- if (activation_zero_point.is_valid())+ if (activation_zero_point.is_valid()) {ret[idx++] = &activation_zero_point;+ }- if (activation_precomputed_reduction.is_valid())+ if (activation_precomputed_reduction.is_valid()) {ret[idx++] = &activation_precomputed_reduction;+ }return ret;}diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/gated_delta_net.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/gated_delta_net.hppindex d78a7951d75..302163b31cc 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/gated_delta_net.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/gated_delta_net.hpp@@ -44,8 +44,9 @@ struct gated_delta_net : public primitive_base<gated_delta_net> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const gated_delta_net>(rhs);return k_head_size == rhs_casted.k_head_size && v_head_size == rhs_casted.v_head_size && k_heads_num == rhs_casted.k_heads_num &&diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/gated_mlp.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/gated_mlp.hppindex 469954fafd6..a8e28ec294a 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/gated_mlp.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/gated_mlp.hpp@@ -111,8 +111,9 @@ struct gated_mlp : public primitive_base<gated_mlp> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const gated_mlp>(rhs);return activation == rhs_casted.activation &&compressed_weights == rhs_casted.compressed_weights &&@@ -165,19 +166,25 @@ protected:ret[idx++] = &weights_up;ret[idx++] = &weights_down;- if (decompression_scale_gate.is_valid())+ if (decompression_scale_gate.is_valid()) {ret[idx++] = &decompression_scale_gate;- if (decompression_scale_up.is_valid())+ }+ if (decompression_scale_up.is_valid()) {ret[idx++] = &decompression_scale_up;- if (decompression_scale_down.is_valid())+ }+ if (decompression_scale_down.is_valid()) {ret[idx++] = &decompression_scale_down;+ }- if (decompression_zero_point_gate.is_valid())+ if (decompression_zero_point_gate.is_valid()) {ret[idx++] = &decompression_zero_point_gate;- if (decompression_zero_point_up.is_valid())+ }+ if (decompression_zero_point_up.is_valid()) {ret[idx++] = &decompression_zero_point_up;- if (decompression_zero_point_down.is_valid())+ }+ if (decompression_zero_point_down.is_valid()) {ret[idx++] = &decompression_zero_point_down;+ }return ret;}diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/gather.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/gather.hppindex 31f04d2d8bf..9fde2e6e790 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/gather.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/gather.hpp@@ -107,8 +107,9 @@ struct gather : public primitive_base<gather> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const gather>(rhs);@@ -171,11 +172,13 @@ protected:auto ret = std::map<size_t, const input_info*>{};auto idx = input.size();- if (decompression_scale.is_valid())+ if (decompression_scale.is_valid()) {ret[idx++] = &decompression_scale;+ }- if (decompression_zero_point.is_valid())+ if (decompression_zero_point.is_valid()) {ret[idx++] = &decompression_zero_point;+ }return ret;}diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/gather_elements.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/gather_elements.hppindex 7ffab44cd4a..674d6f12b9e 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/gather_elements.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/gather_elements.hpp@@ -51,8 +51,9 @@ struct gather_elements : public primitive_base<gather_elements> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const gather_elements>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/gather_matmul.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/gather_matmul.hppindex 37c8b4791ee..90eb6e111f4 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/gather_matmul.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/gather_matmul.hpp@@ -44,8 +44,9 @@ struct gather_matmul : public primitive_base<gather_matmul> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const gather_matmul>(rhs);return has_bias == rhs_casted.has_bias && has_zp == rhs_casted.has_zp && n_activated_experts == rhs_casted.n_activated_experts;}diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/gather_nd.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/gather_nd.hppindex bb7229c2531..216ce3589b1 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/gather_nd.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/gather_nd.hpp@@ -60,8 +60,9 @@ struct gather_nd : public primitive_base<gather_nd> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const gather_nd>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/gemm.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/gemm.hppindex dcb07d3523f..037f34d69ef 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/gemm.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/gemm.hpp@@ -64,8 +64,9 @@ struct gemm : public primitive_base<gemm> {auto get_transposed_order = [] (size_t rank, bool transposed) {std::vector<int64_t> order(rank);std::iota(order.begin(), order.end(), 0);- if (transposed && rank > 1)+ if (transposed && rank > 1) {std::swap(order[rank - 1], order[rank - 2]);+ }return order;};@@ -179,8 +180,9 @@ struct gemm : public primitive_base<gemm> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const gemm>(rhs);@@ -236,8 +238,9 @@ protected:auto ret = std::map<size_t, const input_info*>{};auto idx = input.size();- if (beam_table.is_valid())+ if (beam_table.is_valid()) {ret[idx++] = &beam_table;+ }return ret;}diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/generate_proposals.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/generate_proposals.hppindex 23dc3f9f363..de89174b324 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/generate_proposals.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/generate_proposals.hpp@@ -79,8 +79,9 @@ struct generate_proposals}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const generate_proposals>(rhs);@@ -128,11 +129,13 @@ protected:auto ret = std::map<size_t, const input_info*>{};auto idx = input.size();- if (output_rois_scores.is_valid())+ if (output_rois_scores.is_valid()) {ret[idx++] = &output_rois_scores;+ }- if (output_rois_num.is_valid())+ if (output_rois_num.is_valid()) {ret[idx++] = &output_rois_num;+ }return ret;}diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/grid_sample.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/grid_sample.hppindex b4d5828e0d1..fe7be9a1a6a 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/grid_sample.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/grid_sample.hpp@@ -39,8 +39,9 @@ struct grid_sample : primitive_base<grid_sample> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const grid_sample>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/grn.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/grn.hppindex 87ab7a8d408..630ae0a5a1b 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/grn.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/grn.hpp@@ -35,8 +35,9 @@ struct grn : public primitive_base<grn> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const grn>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/group_normalization.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/group_normalization.hppindex 02d53d930a4..c1aeb0e2d1e 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/group_normalization.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/group_normalization.hpp@@ -48,8 +48,9 @@ struct group_normalization : public primitive_base<group_normalization> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }const auto& rhs_casted = downcast<const group_normalization>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/grouped_matmul.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/grouped_matmul.hppindex 4488305d681..2ef14a0d471 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/grouped_matmul.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/grouped_matmul.hpp@@ -75,8 +75,9 @@ struct grouped_matmul : public primitive_base<grouped_matmul> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const grouped_matmul>(rhs);return compressed_weights == rhs_casted.compressed_weights &&decompression_scale.is_valid() == rhs_casted.decompression_scale.is_valid() &&@@ -118,10 +119,12 @@ protected:std::map<size_t, const input_info*> get_dependencies_map() const override {auto ret = std::map<size_t, const input_info*>{};auto idx = input.size();- if (decompression_scale.is_valid())+ if (decompression_scale.is_valid()) {ret[idx++] = &decompression_scale;- if (decompression_zero_point.is_valid())+ }+ if (decompression_zero_point.is_valid()) {ret[idx++] = &decompression_zero_point;+ }return ret;}};diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/istft.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/istft.hppindex e18952dd5e8..a177628a8f8 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/istft.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/istft.hpp@@ -40,8 +40,9 @@ struct ISTFT : public primitive_base<ISTFT> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const ISTFT>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/kv_cache.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/kv_cache.hppindex 9c33c64cfde..9c9536aa9d6 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/kv_cache.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/kv_cache.hpp@@ -71,8 +71,9 @@ struct kv_cache : public primitive_base<kv_cache> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const kv_cache>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/lora.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/lora.hppindex 5deb4288d2d..466f8aaa374 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/lora.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/lora.hpp@@ -37,8 +37,9 @@ struct lora : public primitive_base<lora> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const lora>(rhs);return transposed_states == rhs_casted.transposed_states;diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/lrn.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/lrn.hppindex ba255fe1725..59814c11a3a 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/lrn.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/lrn.hpp@@ -71,8 +71,9 @@ struct lrn : public primitive_base<lrn> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const lrn>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/matrix_nms.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/matrix_nms.hppindex 5dd3e8a8daf..a71797e6982 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/matrix_nms.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/matrix_nms.hpp@@ -57,8 +57,9 @@ struct matrix_nms : public primitive_base<matrix_nms> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const matrix_nms>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_3gemm_fused_compressed.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_3gemm_fused_compressed.hppindex 56b6cbfd982..488a4772d23 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_3gemm_fused_compressed.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_3gemm_fused_compressed.hpp@@ -145,8 +145,9 @@ struct moe_3gemm_fused_compressed : public primitive_base<moe_3gemm_fused_compremoe_otd_descriptor _otd;bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const moe_3gemm_fused_compressed>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_gather.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_gather.hppindex 1702b9bcde8..36d3a9acff1 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_gather.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_gather.hpp@@ -38,8 +38,9 @@ struct moe_gather : public primitive_base<moe_gather> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const moe_gather>(rhs);return num_experts_per_token == rhs_casted.num_experts_per_token && has_batch_dim == rhs_casted.has_batch_dim;diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_gemm.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_gemm.hppindex d29fac65357..5939d96c319 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_gemm.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_gemm.hpp@@ -58,8 +58,9 @@ struct moe_gemm : public primitive_base<moe_gemm> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const moe_gemm>(rhs);return has_bias == rhs_casted.has_bias &&num_experts_per_token == rhs_casted.num_experts_per_token &&diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_mask_gen.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_mask_gen.hppindex 4445fdb036a..1046f9fa542 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_mask_gen.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_mask_gen.hpp@@ -12,13 +12,7 @@ namespace cldnn {struct moe_mask_gen : public primitive_base<moe_mask_gen> {CLDNN_DECLARE_PRIMITIVE(moe_mask_gen)- enum MoEMaskGenOutputIdx {- TOKENS_PER_EXPERT = 0,- EXPERTS_INFO_START_IDX = 1,- EXPERTS_ID = 2,- TOKENS_LENS_PER_EXPERT = 3,- NUM_ACTUALLY_USED_EXPERTS = 4- };+ enum MoEMaskGenOutputIdx { TOKENS_PER_EXPERT = 0, EXPERTS_INFO_START_IDX = 1, EXPERTS_ID = 2, TOKENS_LENS_PER_EXPERT = 3, NUM_ACTUALLY_USED_EXPERTS = 4 };moe_mask_gen() : primitive_base("", {}) {}@@ -33,10 +27,10 @@ struct moe_mask_gen : public primitive_base<moe_mask_gen> {/// @param output4 : number of actually used expertsmoe_mask_gen(const primitive_id& id,- const input_info& router_idx,- const int32_t num_total_experts,- const int32_t num_experts_per_token,- const bool onednn_grouped_gemm_used = false)+ const input_info& router_idx,+ const int32_t num_total_experts,+ const int32_t num_experts_per_token,+ const bool onednn_grouped_gemm_used = false): primitive_base(id, {router_idx}, 5),num_total_experts(num_total_experts),num_experts_per_token(num_experts_per_token),@@ -55,11 +49,11 @@ struct moe_mask_gen : public primitive_base<moe_mask_gen> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }if (const auto* rhs_casted = dynamic_cast<const moe_mask_gen*>(&rhs)) {- return num_total_experts == rhs_casted->num_total_experts &&- num_experts_per_token == rhs_casted->num_experts_per_token &&+ return num_total_experts == rhs_casted->num_total_experts && num_experts_per_token == rhs_casted->num_experts_per_token &&onednn_grouped_gemm_used == rhs_casted->onednn_grouped_gemm_used;}return false;@@ -83,12 +77,7 @@ struct moe_mask_gen : public primitive_base<moe_mask_gen> {struct moe_mask_gen_reshape : public primitive_base<moe_mask_gen_reshape> {CLDNN_DECLARE_PRIMITIVE(moe_mask_gen_reshape)- enum MoEMaskGenReshapeOutputIdx {- TOKENS_PER_EXPERT = 0,- EXPERTS_INFO_START_IDX = 1,- EXPERTS_ID = 2,- TOKENS_LENS_PER_EXPERT = 3- };+ enum MoEMaskGenReshapeOutputIdx { TOKENS_PER_EXPERT = 0, EXPERTS_INFO_START_IDX = 1, EXPERTS_ID = 2, TOKENS_LENS_PER_EXPERT = 3 };moe_mask_gen_reshape() : primitive_base("", {}) {}diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_router_fused.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_router_fused.hppindex 5159bdc71b3..5a85b47e5ab 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_router_fused.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_router_fused.hpp@@ -36,8 +36,9 @@ struct moe_router_fused : public primitive_base<moe_router_fused> {MoERouterFused::Config _config;bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const moe_router_fused>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_scatter_reduction.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_scatter_reduction.hppindex 94a1819d5a3..c04b95b9784 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_scatter_reduction.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/moe_scatter_reduction.hpp@@ -53,8 +53,9 @@ struct moe_scatter_reduction : public primitive_base<moe_scatter_reduction> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const moe_scatter_reduction>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/multiclass_nms.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/multiclass_nms.hppindex f2aa993fcdb..96c7b2c71a2 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/multiclass_nms.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/multiclass_nms.hpp@@ -57,8 +57,9 @@ struct multiclass_nms : public primitive_base<multiclass_nms> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const multiclass_nms>(rhs);@@ -106,11 +107,13 @@ protected:auto ret = std::map<size_t, const input_info*>{};auto idx = input.size();- if (output_selected_indices.is_valid())+ if (output_selected_indices.is_valid()) {ret[idx++] = &output_selected_indices;+ }- if (output_selected_num.is_valid())+ if (output_selected_num.is_valid()) {ret[idx++] = &output_selected_num;+ }return ret;}diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/multinomial.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/multinomial.hppindex 6bfdc940485..18011599392 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/multinomial.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/multinomial.hpp@@ -53,8 +53,9 @@ struct multinomial : public primitive_base<multinomial> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }const multinomial& rhs_casted = downcast<const multinomial>(rhs);return output_data_type == rhs_casted.output_data_type &&with_replacement == rhs_casted.with_replacement &&diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/mvn.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/mvn.hppindex 8a526fe872f..99e616e772c 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/mvn.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/mvn.hpp@@ -52,8 +52,9 @@ struct mvn : public primitive_base<mvn> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const mvn>(rhs);@@ -92,8 +93,9 @@ struct mvn : public primitive_base<mvn> {// If all axes from 2 to rank-1 is a part of reduction scope,// then it's mapped to the old MVN case and don't require alignmentfor (int64_t i = 2; i < rank; i++) {- if (std::find_if(axes.begin(), axes.end(), [i, &shape](const int64_t& v){ return v == i || shape[i].get_max_length() == 1; }) == axes.end())+ if (std::find_if(axes.begin(), axes.end(), [i, &shape](const int64_t& v){ return v == i || shape[i].get_max_length() == 1; }) == axes.end()) {return true;+ }}return false;diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/non_max_suppression.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/non_max_suppression.hppindex fbce4878aa3..a8a8ede02eb 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/non_max_suppression.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/non_max_suppression.hpp@@ -91,8 +91,9 @@ struct non_max_suppression : public primitive_base<non_max_suppression> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const non_max_suppression>(rhs);@@ -143,23 +144,29 @@ protected:auto ret = std::map<size_t, const input_info*>{};auto idx = input.size();- if (num_select_per_class.is_valid())+ if (num_select_per_class.is_valid()) {ret[idx++] = &num_select_per_class;+ }- if (iou_threshold.is_valid())+ if (iou_threshold.is_valid()) {ret[idx++] = &iou_threshold;+ }- if (score_threshold.is_valid())+ if (score_threshold.is_valid()) {ret[idx++] = &score_threshold;+ }- if (soft_nms_sigma.is_valid())+ if (soft_nms_sigma.is_valid()) {ret[idx++] = &soft_nms_sigma;+ }- if (second_output.is_valid())+ if (second_output.is_valid()) {ret[idx++] = &second_output;+ }- if (third_output.is_valid())+ if (third_output.is_valid()) {ret[idx++] = &third_output;+ }return ret;}diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/normalize.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/normalize.hppindex d3af5a32375..66b63e79e20 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/normalize.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/normalize.hpp@@ -64,8 +64,9 @@ struct normalize : public primitive_base<normalize> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const normalize>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/one_hot.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/one_hot.hppindex 08188cce7a9..189f0886552 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/one_hot.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/one_hot.hpp@@ -119,8 +119,9 @@ struct one_hot : public primitive_base<one_hot> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const one_hot>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/pa_kv_reorder.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/pa_kv_reorder.hppindex 387a17b0248..01d6708d396 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/pa_kv_reorder.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/pa_kv_reorder.hpp@@ -41,8 +41,9 @@ struct pa_kv_reorder : public primitive_base<pa_kv_reorder> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const pa_kv_reorder>(rhs);return is_key_by_channel == rhs_casted.is_key_by_channel && scales_zp_size == rhs_casted.scales_zp_size && kv_heads_num == rhs_casted.kv_heads_num &&diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/paged_attention.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/paged_attention.hppindex a6c37f1b006..a2bbdc572b1 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/paged_attention.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/paged_attention.hpp@@ -86,8 +86,9 @@ struct paged_attention : public primitive_base<paged_attention> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const paged_attention>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/paged_causal_conv1d.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/paged_causal_conv1d.hppindex 8e30b2ee569..3cd6ff32679 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/paged_causal_conv1d.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/paged_causal_conv1d.hpp@@ -44,8 +44,9 @@ struct paged_causal_conv1d : public primitive_base<paged_causal_conv1d> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const paged_causal_conv1d>(rhs);return hidden_size == rhs_casted.hidden_size && kernel_size == rhs_casted.kernel_size;diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/paged_gated_delta_net.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/paged_gated_delta_net.hppindex c80f43da7fc..e2d6c59ffb5 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/paged_gated_delta_net.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/paged_gated_delta_net.hpp@@ -60,8 +60,9 @@ struct paged_gated_delta_net : public primitive_base<paged_gated_delta_net> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const paged_gated_delta_net>(rhs);return k_head_size == rhs_casted.k_head_size && v_head_size == rhs_casted.v_head_size && k_heads_num == rhs_casted.k_heads_num &&diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/permute.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/permute.hppindex 0b771a4d363..cbcd2cd8fe1 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/permute.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/permute.hpp@@ -40,8 +40,9 @@ struct permute : public primitive_base<permute> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const permute>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/pooling.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/pooling.hppindex 1375668fc11..96e068db399 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/pooling.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/pooling.hpp@@ -175,8 +175,9 @@ struct pooling : public primitive_base<pooling> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const pooling>(rhs);@@ -228,8 +229,9 @@ protected:auto ret = std::map<size_t, const input_info*>{};auto idx = input.size();- if (indices_output.is_valid())+ if (indices_output.is_valid()) {ret[idx++] = &indices_output;+ }return ret;}diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/primitive.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/primitive.hppindex 380053bb65e..400d749dbc2 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/primitive.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/primitive.hpp@@ -39,8 +39,9 @@ struct input_info {/// @brief Copy assignment.input_info& operator=(const input_info& other) {- if (this == &other)+ if (this == &other) {return *this;+ }pid = other.pid;idx = other.idx;return *this;@@ -145,8 +146,9 @@ public:auto result = input;auto dependencies_map = get_dependencies_map();- for (const auto& dep : dependencies_map)+ for (const auto& dep : dependencies_map) {result.push_back(*dep.second);+ }return result;}@@ -171,30 +173,37 @@ public:}bool compare_common_params(const primitive& rhs) const {- if (type != rhs.type)+ if (type != rhs.type) {return false;+ }- if (num_outputs != rhs.num_outputs)+ if (num_outputs != rhs.num_outputs) {return false;+ }- if (dependencies().size() != rhs.dependencies().size())+ if (dependencies().size() != rhs.dependencies().size()) {return false;+ }- if (output_data_types.size() != rhs.output_data_types.size())+ if (output_data_types.size() != rhs.output_data_types.size()) {return false;+ }for (size_t i = 0; i < output_data_types.size(); ++i) {if (output_data_types[i].value_or(data_types::dynamic) !=- rhs.output_data_types[i].value_or(data_types::dynamic))+ rhs.output_data_types[i].value_or(data_types::dynamic)) {return false;+ }}- if (output_paddings.size() != rhs.output_paddings.size())+ if (output_paddings.size() != rhs.output_paddings.size()) {return false;+ }for (size_t i = 0; i < output_paddings.size(); ++i) {- if (output_paddings[i] != rhs.output_paddings[i])+ if (output_paddings[i] != rhs.output_paddings[i]) {return false;+ }}return true;@@ -307,8 +316,9 @@ public:/// @brief Returns mutable reference to input dependency at given index.input_info& get_dependency(size_t idx) {- if (idx < input.size())+ if (idx < input.size()) {return input[idx];+ }auto dependencies_map = get_dependencies_map();OPENVINO_ASSERT(dependencies_map.count(idx) > 0,@@ -329,8 +339,9 @@ public:/// @brief Returns const reference to input dependency at given index.const input_info& get_dependency(size_t idx) const {- if (idx < input.size())+ if (idx < input.size()) {return input[idx];+ }auto dependencies_map = get_dependencies_map();OPENVINO_ASSERT(dependencies_map.count(idx) > 0,diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/prior_box.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/prior_box.hppindex 2be1f5c9c62..d0628686f02 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/prior_box.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/prior_box.hpp@@ -227,8 +227,9 @@ struct prior_box : public primitive_base<prior_box> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const prior_box>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/proposal.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/proposal.hppindex 411a079ecd6..6b91cbece05 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/proposal.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/proposal.hpp@@ -200,8 +200,9 @@ struct proposal : public primitive_base<proposal> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const proposal>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/quantize.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/quantize.hppindex 77e1991e8cd..fb8544ab477 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/quantize.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/quantize.hpp@@ -91,8 +91,9 @@ struct quantize : public primitive_base<quantize> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const quantize>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/random_uniform.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/random_uniform.hppindex 2e357e59aa1..ed6b6d30190 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/random_uniform.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/random_uniform.hpp@@ -56,8 +56,9 @@ struct random_uniform : public primitive_base<random_uniform> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const random_uniform>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/read_value.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/read_value.hppindex 3f7ff73b7fe..32404c88edc 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/read_value.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/read_value.hpp@@ -42,8 +42,9 @@ struct read_value : public primitive_base<read_value> {ov::element::Type user_specified_type;bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const read_value>(rhs);@@ -56,8 +57,9 @@ struct read_value : public primitive_base<read_value> {ov::element::Type_t data_type = user_specified_type;ob << variable_id;ob << output_layouts.size();- for (const auto& layout : output_layouts)+ for (const auto& layout : output_layouts) {ob << layout;+ }ob << make_data(&data_type, sizeof(ov::element::Type_t));}diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/reduce.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/reduce.hppindex 732302df19e..63379ce3fa8 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/reduce.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/reduce.hpp@@ -71,8 +71,9 @@ struct reduce : public primitive_base<reduce> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const reduce>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/region_yolo.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/region_yolo.hppindex 36c139d97b8..066a944e152 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/region_yolo.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/region_yolo.hpp@@ -66,8 +66,9 @@ struct region_yolo : public primitive_base<region_yolo> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const region_yolo>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/reorder.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/reorder.hppindex ea3e01ad05f..d7a79f9259b 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/reorder.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/reorder.hpp@@ -194,8 +194,9 @@ struct reorder : public primitive_base<reorder> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const reorder>(rhs);@@ -271,8 +272,9 @@ protected:auto ret = std::map<size_t, const input_info*>{};auto idx = input.size();- if (mean.is_valid())+ if (mean.is_valid()) {ret[idx++] = &mean;+ }return ret;}diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/reorg_yolo.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/reorg_yolo.hppindex 4700f941edb..a9d2794b76c 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/reorg_yolo.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/reorg_yolo.hpp@@ -37,8 +37,9 @@ struct reorg_yolo : public primitive_base<reorg_yolo> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const reorg_yolo>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/resample.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/resample.hppindex 8d699b664fa..8ab1d5d8d31 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/resample.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/resample.hpp@@ -44,8 +44,9 @@ struct resample : public primitive_base<resample> {cube_coeff(0.0f),coord_trans_mode(InterpolateOp::CoordinateTransformMode::ASYMMETRIC),round_mode(InterpolateOp::NearestMode::FLOOR) {- if (scales.size() != axes.size())+ if (scales.size() != axes.size()) {throw std::runtime_error("Resample's scales/axes count does not match");+ }if (operation_type == InterpolateOp::InterpolateMode::LINEAR) {coord_trans_mode = InterpolateOp::CoordinateTransformMode::HALF_PIXEL;}@@ -78,8 +79,9 @@ struct resample : public primitive_base<resample> {cube_coeff(cube_coeff),coord_trans_mode(ctm),round_mode(nm) {- if (scales.size() != axes.size() && shape_calc_mode == InterpolateOp::ShapeCalcMode::SCALES)+ if (scales.size() != axes.size() && shape_calc_mode == InterpolateOp::ShapeCalcMode::SCALES) {throw std::runtime_error("Resample's scales/axes count does not match");+ }}/// @brief resample with dynamic sizes/scales@@ -169,8 +171,9 @@ struct resample : public primitive_base<resample> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const resample>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/reshape.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/reshape.hppindex 410f63b53ab..af1b1d62b38 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/reshape.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/reshape.hpp@@ -77,8 +77,9 @@ struct reshape : public primitive_base<reshape> {reshape_mode mode = reshape_mode::base;bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const reshape>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/reverse.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/reverse.hppindex cc7ae744860..842842301ec 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/reverse.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/reverse.hpp@@ -36,8 +36,9 @@ struct reverse : public primitive_base<reverse> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const reverse>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/reverse_sequence.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/reverse_sequence.hppindex d47ce82dfb7..c89acc59b32 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/reverse_sequence.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/reverse_sequence.hpp@@ -32,20 +32,25 @@ struct reverse_sequence : public primitive_base<reverse_sequence> {int32_t batch_a = batch_axis;int32_t seq_a = seq_axis;- if (batch_a < 0)+ if (batch_a < 0) {batch_a += number_of_dims;+ }- if (seq_a < 0)+ if (seq_a < 0) {seq_a += number_of_dims;+ }- if (batch_a == seq_a)+ if (batch_a == seq_a) {throw std::runtime_error("Batch axis and sequence axis should not be equal\n");+ }- if (batch_a < 0 || batch_a >= number_of_dims)+ if (batch_a < 0 || batch_a >= number_of_dims) {throw std::runtime_error("Incorrect batch axis value! Actual axis is" + std::to_string(batch_a));+ }- if (seq_a < 0 || seq_a >= number_of_dims)+ if (seq_a < 0 || seq_a >= number_of_dims) {throw std::runtime_error("Incorrect sequence axis value! Actual axis is" + std::to_string(seq_a));+ }}/// @brief The axis which is partially reversed.@@ -61,8 +66,9 @@ struct reverse_sequence : public primitive_base<reverse_sequence> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const reverse_sequence>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/rms.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/rms.hppindex 1f1f126674a..a5ae054173c 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/rms.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/rms.hpp@@ -51,8 +51,9 @@ struct rms : public primitive_base<rms> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const rms>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/rnn.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/rnn.hppindex 527197746d9..7bd6070c606 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/rnn.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/rnn.hpp@@ -113,8 +113,9 @@ struct RNNParams : public primitive_base<PType> {}bool operator==(const primitive& rhs) const override {- if (!primitive::compare_common_params(rhs))+ if (!primitive::compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const PType>(rhs);bool act_params_eq = activation_params.size() == rhs_casted.activation_params.size();diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/roi_align.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/roi_align.hppindex 922831a7423..621803046a5 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/roi_align.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/roi_align.hpp@@ -86,8 +86,9 @@ struct roi_align : public primitive_base<roi_align> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const roi_align>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/roi_pooling.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/roi_pooling.hppindex b46ea3a0ebb..b653bd04df7 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/roi_pooling.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/roi_pooling.hpp@@ -108,8 +108,9 @@ struct roi_pooling : public primitive_base<roi_pooling> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const roi_pooling>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/roll.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/roll.hppindex 9c11bd4e2f6..f58f026f828 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/roll.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/roll.hpp@@ -53,8 +53,9 @@ struct roll : primitive_base<roll> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const roll>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/rope.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/rope.hppindex bfbac9a762d..9b90c9e010b 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/rope.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/rope.hpp@@ -56,8 +56,9 @@ struct rope : public primitive_base<rope> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const rope>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/scaled_dot_product_attention.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/scaled_dot_product_attention.hppindex cc82fe924ee..b584642fd6c 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/scaled_dot_product_attention.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/scaled_dot_product_attention.hpp@@ -61,8 +61,9 @@ struct scaled_dot_product_attention : public primitive_base<scaled_dot_product_adata_inputs_num -= 2; // scalesif (quantization_attributes.quantization_type == ov::op::internal::DynamicQuantize::QuantizationType::Asymmetric &&- quantization_attributes.output_storage_type == ov::op::internal::DynamicQuantize::OutputStorageType::Planar)+ quantization_attributes.output_storage_type == ov::op::internal::DynamicQuantize::OutputStorageType::Planar) {data_inputs_num -= 2; // zp+ }}has_attn_mask_input = data_inputs_num > ScaledDotProductAttentionInputIdx::ATTN_MASK;has_scale_input = data_inputs_num > ScaledDotProductAttentionInputIdx::SCALE;@@ -120,8 +121,9 @@ struct scaled_dot_product_attention : public primitive_base<scaled_dot_product_a}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const scaled_dot_product_attention>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/scatter_elements_update.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/scatter_elements_update.hppindex e7f6a3b052a..a1f57c59e4d 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/scatter_elements_update.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/scatter_elements_update.hpp@@ -49,8 +49,9 @@ struct scatter_elements_update : public primitive_base<scatter_elements_update>}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const scatter_elements_update>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/scatter_nd_update.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/scatter_nd_update.hppindex b082fce7105..44690091fbc 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/scatter_nd_update.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/scatter_nd_update.hpp@@ -37,8 +37,9 @@ struct scatter_nd_update : public primitive_base<scatter_nd_update> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const scatter_nd_update>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/scatter_update.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/scatter_update.hppindex 30035e4019f..7637e008a44 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/scatter_update.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/scatter_update.hpp@@ -46,8 +46,9 @@ struct scatter_update : public primitive_base<scatter_update> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const scatter_update>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/search_sorted.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/search_sorted.hppindex bb54028f53e..7a1e9cb2a44 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/search_sorted.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/search_sorted.hpp@@ -33,8 +33,9 @@ struct search_sorted : public primitive_base<search_sorted> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const search_sorted>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/segment_max.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/segment_max.hppindex 249cf3e8068..c0edcd5acea 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/segment_max.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/segment_max.hpp@@ -49,8 +49,9 @@ struct segment_max : public primitive_base<segment_max> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const segment_max>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/select.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/select.hppindex ee9028be5f3..b1f2a1910a7 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/select.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/select.hpp@@ -42,8 +42,9 @@ struct select : public primitive_base<select> {ov::op::AutoBroadcastSpec broadcast_spec;bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const select>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/shuffle_channels.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/shuffle_channels.hppindex d3f6b730292..8f1dc1c0dc6 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/shuffle_channels.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/shuffle_channels.hpp@@ -39,8 +39,9 @@ struct shuffle_channels : public primitive_base<shuffle_channels> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const shuffle_channels>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/softmax.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/softmax.hppindex 2b2fef19537..8e7d931fb29 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/softmax.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/softmax.hpp@@ -47,8 +47,9 @@ struct softmax : public primitive_base<softmax> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const softmax>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/space_to_batch.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/space_to_batch.hppindex acf539549f3..c2f2ee7c5da 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/space_to_batch.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/space_to_batch.hpp@@ -81,8 +81,9 @@ struct space_to_batch : public primitive_base<space_to_batch> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const space_to_batch>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/space_to_depth.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/space_to_depth.hppindex edbd13db820..789bcbcc930 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/space_to_depth.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/space_to_depth.hpp@@ -71,8 +71,9 @@ struct space_to_depth : public primitive_base<space_to_depth> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const space_to_depth>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/sparse_fill_empty_rows.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/sparse_fill_empty_rows.hppindex df36a937a53..5ce0e0fb33f 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/sparse_fill_empty_rows.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/sparse_fill_empty_rows.hpp@@ -56,8 +56,9 @@ struct sparse_fill_empty_rows : public primitive_base<sparse_fill_empty_rows> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const sparse_fill_empty_rows>(rhs);return indices == rhs_casted.indices &&values == rhs_casted.values &&diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/stft.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/stft.hppindex 9dce230332a..54ea2c265b3 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/stft.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/stft.hpp@@ -41,8 +41,9 @@ struct STFT : public primitive_base<STFT> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const STFT>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/strided_slice.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/strided_slice.hppindex 125457d6130..d25bd5d17e4 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/strided_slice.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/strided_slice.hpp@@ -147,8 +147,9 @@ struct strided_slice : public primitive_base<strided_slice> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const strided_slice>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/swiglu.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/swiglu.hppindex 4292e7da65f..d4102375ff0 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/swiglu.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/swiglu.hpp@@ -94,8 +94,9 @@ struct swiglu : public primitive_base<swiglu> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const swiglu>(rhs);return axis == rhs_casted.axis && glu_stride == rhs_casted.glu_stride &&diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/tile.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/tile.hppindex cee1aec6d4b..f098851ae5f 100644--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/tile.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/tile.hpp@@ -40,8 +40,9 @@ struct tile : public primitive_base<tile> {}bool operator==(const primitive& rhs) const override {- if (!compare_common_params(rhs))+ if (!compare_common_params(rhs)) {return false;+ }auto rhs_casted = downcast<const tile>(rhs);diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/compounds.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/compounds.hppindex cd91c5b1c0e..9821cb166e1 100644--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/compounds.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/compounds.hpp@@ -217,8 +217,9 @@ public:mutable_array_ref(const mutable_array_ref& other) : _data(other._data), _size(other._size) {}mutable_array_ref& operator=(const mutable_array_ref& other) {- if (this == &other)+ if (this == &other) {return *this;+ }_data = other._data;_size = other._size;return *this;diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/device_info.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/device_info.hppindex a45b10e8d6c..2bd71be4c77 100644--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/device_info.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/device_info.hpp@@ -161,27 +161,33 @@ struct device_info {// Relying solely on the UUID is not reliable in all the cases (particularly on legacy platforms),// where the UUID may be missing or incorrectly generated// Therefore, we also validate other attributes- if (uuid.uuid != other.uuid.uuid)+ if (uuid.uuid != other.uuid.uuid) {return false;+ }- if (pci_info != other.pci_info)+ if (pci_info != other.pci_info) {return false;+ }- if (sub_device_idx != other.sub_device_idx)+ if (sub_device_idx != other.sub_device_idx) {return false;+ }if (vendor_id != other.vendor_id ||dev_name != other.dev_name ||- driver_version != other.driver_version)+ driver_version != other.driver_version) {return false;+ }if (dev_type != other.dev_type ||gfx_ver != other.gfx_ver ||- arch != other.arch)+ arch != other.arch) {return false;+ }- if (ip_version != other.ip_version || device_id != other.device_id)+ if (ip_version != other.ip_version || device_id != other.device_id) {return false;+ }return execution_units_count == other.execution_units_count && max_global_mem_size == other.max_global_mem_size;}diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/format.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/format.hppindex 4b161cb5b76..33d700d8336 100644--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/format.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/format.hpp@@ -297,8 +297,9 @@ struct format {}/// @brief Checks if @p format is weights formatstatic bool is_weights_format(const format& fmt) {- if (fmt == format::custom)+ if (fmt == format::custom) {return true;+ }const auto internal_order = fmt.traits().internal_order;const auto weights_chars = { "o", "i" };for (const auto& c : weights_chars) {@@ -325,8 +326,9 @@ struct format {auto c = o_order[i];auto pos = i_order.find(c);- if (pos == std::string::npos)+ if (pos == std::string::npos) {OPENVINO_THROW("Unknown coord type: " + std::to_string(c));+ }i_dims.push_back(pos);}@@ -395,8 +397,9 @@ struct format {/// @brief Transforms dimension from internal order to external ordersize_t internal_to_external(size_t idx) const {auto index = order().find_first_of(internal_order()[idx]);- if (index == std::string::npos)+ if (index == std::string::npos) {throw std::invalid_argument("Internal dimension index does not map to external index.");+ }return index;}diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/impl_forcing_map_read.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/impl_forcing_map_read.hppindex 18ceffd883b..b8b8b3c8855 100644--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/impl_forcing_map_read.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/impl_forcing_map_read.hpp@@ -39,14 +39,17 @@ struct Read<ov::intel_gpu::ImplForcingMap> {while (is.good()) {is >> c;if (c == ',') {- if (enclosed_container_level == 0)+ if (enclosed_container_level == 0) {break;+ }}- if (c == '{' || c == '[')+ if (c == '{' || c == '[') {++enclosed_container_level;+ }if (c == '}' || c == ']') {- if (enclosed_container_level == 0)+ if (enclosed_container_level == 0) {break;+ }--enclosed_container_level;}diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/layout.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/layout.hppindex 7fb6e4f0710..f231cba7678 100644--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/layout.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/layout.hpp@@ -4,25 +4,23 @@#pragma once-#include "tensor.hpp"--#include <cmath>-#include <cstdlib>-#include <vector>#include <algorithm>-#include <limits>-#include <string>-#include <functional>#include <array>#include <bitset>+#include <cmath>+#include <cstdlib>+#include <functional>+#include <limits>#include <optional>+#include <string>+#include <vector>+#include "intel_gpu/graph/serialization/binary_buffer.hpp"+#include "intel_gpu/graph/serialization/vector_serializer.hpp"#include "openvino/core/partial_shape.hpp"#include "openvino/core/type/element_type.hpp"#include "openvino/core/type/element_type_traits.hpp"--#include "intel_gpu/graph/serialization/binary_buffer.hpp"-#include "intel_gpu/graph/serialization/vector_serializer.hpp"+#include "tensor.hpp"namespace cldnn {/// @addtogroup cpp_api C++ API@@ -57,14 +55,17 @@ struct data_type_traits {}static ov::element::Type max_type(ov::element::Type t1, ov::element::Type t2) {- if (t1.bitwidth() < t2.bitwidth())+ if (t1.bitwidth() < t2.bitwidth()) {return t2;+ }- if (t1.bitwidth() > t2.bitwidth())+ if (t1.bitwidth() > t2.bitwidth()) {return t1;+ }- if (t2.is_real())+ if (t2.is_real()) {return t2;+ }return t1;}@@ -76,41 +77,41 @@ struct data_type_traits {template <typename T>static T max(data_types data_type) {switch (data_type) {- case data_types::i8:- return static_cast<T>(std::numeric_limits<int8_t>::max());- case data_types::u8:- return static_cast<T>(std::numeric_limits<uint8_t>::max());- case data_types::i32:- return static_cast<T>(std::numeric_limits<int32_t>::max());- case data_types::i64:- return static_cast<T>(std::numeric_limits<int64_t>::max());- case data_types::f16:- return static_cast<T>(std::numeric_limits<ov::float16>::max());- case data_types::f32:- return static_cast<T>(std::numeric_limits<float>::max());- default:- assert(0);- return static_cast<T>(0);+ case data_types::i8:+ return static_cast<T>(std::numeric_limits<int8_t>::max());+ case data_types::u8:+ return static_cast<T>(std::numeric_limits<uint8_t>::max());+ case data_types::i32:+ return static_cast<T>(std::numeric_limits<int32_t>::max());+ case data_types::i64:+ return static_cast<T>(std::numeric_limits<int64_t>::max());+ case data_types::f16:+ return static_cast<T>(std::numeric_limits<ov::float16>::max());+ case data_types::f32:+ return static_cast<T>(std::numeric_limits<float>::max());+ default:+ assert(0);+ return static_cast<T>(0);}}template <typename T>static T min(data_types data_type) {switch (data_type) {- case data_types::i8:- return static_cast<T>(std::numeric_limits<int8_t>::lowest());- case data_types::u8:- return static_cast<T>(std::numeric_limits<uint8_t>::lowest());- case data_types::i32:- return static_cast<T>(std::numeric_limits<int32_t>::lowest());- case data_types::i64:- return static_cast<T>(std::numeric_limits<int64_t>::lowest());- case data_types::f16:- return static_cast<T>(std::numeric_limits<ov::float16>::lowest());- case data_types::f32:- return static_cast<T>(std::numeric_limits<float>::lowest());- default:- assert(0);- return static_cast<T>(0);+ case data_types::i8:+ return static_cast<T>(std::numeric_limits<int8_t>::lowest());+ case data_types::u8:+ return static_cast<T>(std::numeric_limits<uint8_t>::lowest());+ case data_types::i32:+ return static_cast<T>(std::numeric_limits<int32_t>::lowest());+ case data_types::i64:+ return static_cast<T>(std::numeric_limits<int64_t>::lowest());+ case data_types::f16:+ return static_cast<T>(std::numeric_limits<ov::float16>::lowest());+ case data_types::f32:+ return static_cast<T>(std::numeric_limits<float>::lowest());+ default:+ assert(0);+ return static_cast<T>(0);}}};@@ -130,7 +131,8 @@ inline data_types element_type_to_data_type(ov::element::Type t) {return cldnn::data_types::i32;case ov::element::Type_t::boolean:return cldnn::data_types::u8;- default: return t;+ default:+ return t;}}@@ -141,9 +143,11 @@ struct padding {using DynamicDimsMask = std::bitset<SHAPE_RANK_MAX>;static constexpr DynamicDimsMask EMPTY_MASK{0x0};- std::array<ov::Dimension::value_type, SHAPE_RANK_MAX> _lower_size = {0}; ///< Lower padding sizes. For spatials, it means size of left (X) and top (Y) padding.- std::array<ov::Dimension::value_type, SHAPE_RANK_MAX> _upper_size = {0}; ///< Upper padding sizes. For spatials, it means size of right (X) and bottom (Y) padding.- DynamicDimsMask _dynamic_dims_mask = EMPTY_MASK; ///< A mask saying which dimension has dynamic pad+ std::array<ov::Dimension::value_type, SHAPE_RANK_MAX> _lower_size = {+ 0}; ///< Lower padding sizes. For spatials, it means size of left (X) and top (Y) padding.+ std::array<ov::Dimension::value_type, SHAPE_RANK_MAX> _upper_size = {+ 0}; ///< Upper padding sizes. For spatials, it means size of right (X) and bottom (Y) padding.+ DynamicDimsMask _dynamic_dims_mask = EMPTY_MASK; ///< A mask saying which dimension has dynamic pad/// @brief/// @param lower_sizes Top-left padding sizes, in the same size and order as shape.@@ -151,18 +155,17 @@ struct padding {padding(const std::vector<ov::Dimension::value_type>& lower_sizes,const std::vector<ov::Dimension::value_type>& upper_sizes,const DynamicDimsMask& dynamic_pad_dims = EMPTY_MASK) {- // paddings- OPENVINO_ASSERT(lower_sizes.size() <= SHAPE_RANK_MAX);- OPENVINO_ASSERT(upper_sizes.size() <= SHAPE_RANK_MAX);- std::copy_n(lower_sizes.begin(), lower_sizes.size(), _lower_size.begin());- std::copy_n(upper_sizes.begin(), upper_sizes.size(), _upper_size.begin());- _dynamic_dims_mask = dynamic_pad_dims;- }+ // paddings+ OPENVINO_ASSERT(lower_sizes.size() <= SHAPE_RANK_MAX);+ OPENVINO_ASSERT(upper_sizes.size() <= SHAPE_RANK_MAX);+ std::copy_n(lower_sizes.begin(), lower_sizes.size(), _lower_size.begin());+ std::copy_n(upper_sizes.begin(), upper_sizes.size(), _upper_size.begin());+ _dynamic_dims_mask = dynamic_pad_dims;+ }/// @brief Constrcuts symmetric padding./// @param sizes Top-left and bottom-right padding sizes, in the same size and order as shape.- explicit padding(const std::vector<ov::Dimension::value_type>& sizes,- const DynamicDimsMask& dynamic_pad_dims = EMPTY_MASK)+ explicit padding(const std::vector<ov::Dimension::value_type>& sizes, const DynamicDimsMask& dynamic_pad_dims = EMPTY_MASK): padding(sizes, sizes, dynamic_pad_dims) {}/// @brief Constructs "zero-sized" padding.@@ -170,8 +173,14 @@ struct padding {/// @brief Returns true if padding size is not zero.explicit operator bool() const {- return std::any_of(_lower_size.begin(), _lower_size.end(), [](ov::Dimension::value_type i){ return i > 0; }) ||- std::any_of(_upper_size.begin(), _upper_size.end(), [](ov::Dimension::value_type i){ return i > 0; });+ return std::any_of(_lower_size.begin(),+ _lower_size.end(),+ [](ov::Dimension::value_type i) {+ return i > 0;+ }) ||+ std::any_of(_upper_size.begin(), _upper_size.end(), [](ov::Dimension::value_type i) {+ return i > 0;+ });}bool is_dynamic() const {@@ -179,9 +188,7 @@ struct padding {}friend bool operator==(const padding& lhs, const padding& rhs) {- return lhs._dynamic_dims_mask == rhs._dynamic_dims_mask &&- lhs._lower_size == rhs._lower_size &&- lhs._upper_size == rhs._upper_size;+ return lhs._dynamic_dims_mask == rhs._dynamic_dims_mask && lhs._lower_size == rhs._lower_size && lhs._upper_size == rhs._upper_size;}friend bool operator!=(const padding& lhs, const padding& rhs) {@@ -190,13 +197,15 @@ struct padding {friend bool operator<(const padding& lhs, const padding& rhs) {// Compare only actual padding size not _dynamic_dims_mask- if (lhs._lower_size < rhs._lower_size) return true;- if (lhs._lower_size > rhs._lower_size)+ if (lhs._lower_size < rhs._lower_size)+ return true;+ if (lhs._lower_size > rhs._lower_size) {return false;+ }return lhs._upper_size < rhs._upper_size;}- static padding max(padding const& lhs, padding const& rhs, float filling_value = 0.0f) {+ static padding max(const padding& lhs, const padding& rhs, float filling_value = 0.0f) {auto ret = lhs;for (size_t i = 0; i < SHAPE_RANK_MAX; ++i) {ret._lower_size[i] = std::max(ret._lower_size[i], rhs._lower_size[i]);@@ -221,8 +230,9 @@ struct padding {sizes.assign(_upper_size.begin(), _upper_size.end());ob << sizes;OPENVINO_ASSERT(sizes.size() == _dynamic_dims_mask.size(), "invalid size.");- for (size_t i = 0; i < _dynamic_dims_mask.size(); i++)+ for (size_t i = 0; i < _dynamic_dims_mask.size(); i++) {sizes[i] = static_cast<ov::Dimension::value_type>(_dynamic_dims_mask[i]);+ }ob << sizes;}@@ -234,8 +244,9 @@ struct padding {std::copy_n(sizes.begin(), sizes.size(), _upper_size.begin());ib >> sizes;OPENVINO_ASSERT(sizes.size() == _dynamic_dims_mask.size(), "invalid size.");- for (size_t i = 0; i < _dynamic_dims_mask.size(); i++)+ for (size_t i = 0; i < _dynamic_dims_mask.size(); i++) {_dynamic_dims_mask[i] = static_cast<bool>(sizes[i]);+ }}};@@ -243,38 +254,33 @@ struct padding {/// @details Contains information about data stored in @ref memory.struct layout {struct Hasher {- size_t operator()(const layout &l) const {+ size_t operator()(const layout& l) const {return l.hash();}};/// Constructs layout based on @p data_type and @p size information described by @ref tensor- layout(data_types data_type, cldnn::format fmt, tensor size, padding apadding = padding())- : data_type(data_type)- , format(fmt)- , data_padding(apadding) {- auto sizes = fmt == format::any ? size.sizes() : size.sizes(format::get_default_format(fmt.dimension(),- format::is_weights_format(fmt),- format::is_grouped(fmt)));- ov::Shape shape(sizes.begin(), sizes.end());- this->size = ov::PartialShape(shape);- }+ layout(data_types data_type, cldnn::format fmt, tensor size, padding apadding = padding()) : data_type(data_type), format(fmt), data_padding(apadding) {+ auto sizes = fmt == format::any ? size.sizes()+ : size.sizes(format::get_default_format(fmt.dimension(), format::is_weights_format(fmt), format::is_grouped(fmt)));+ ov::Shape shape(sizes.begin(), sizes.end());+ this->size = ov::PartialShape(shape);+ }layout(ov::PartialShape size, data_types data_type, cldnn::format fmt, padding apadding = padding())- : data_type(data_type)- , format(fmt)- , data_padding(apadding)- , size(size) {}+ : data_type(data_type),+ format(fmt),+ data_padding(apadding),+ size(size) {}layout(const layout& other) = default;- layout()- : data_type(cldnn::data_types::dynamic),- format(cldnn::format::any) {}+ layout() : data_type(cldnn::data_types::dynamic), format(cldnn::format::any) {}layout& operator=(const layout& other) {- if (this == &other)+ if (this == &other) {return *this;+ }data_type = other.data_type;format = other.format;data_padding = other.data_padding;@@ -290,7 +296,6 @@ struct layout {return clone_with_other_shape(ov::PartialShape(new_shape));}-friend bool operator==(const layout& lhs, const layout& rhs) {return lhs.data_type == rhs.data_type && lhs.format == rhs.format && lhs.size == rhs.size && lhs.data_padding == rhs.data_padding;}@@ -300,12 +305,15 @@ struct layout {}friend bool operator<(const layout& lhs, const layout& rhs) {- if (lhs.data_type != rhs.data_type)+ if (lhs.data_type != rhs.data_type) {return (lhs.data_type < rhs.data_type);- if (lhs.format != rhs.format)+ }+ if (lhs.format != rhs.format) {return (lhs.format < rhs.format);- if (lhs.count() < rhs.count())+ }+ if (lhs.count() < rhs.count()) {return (lhs.count() < rhs.count());+ }return (lhs.data_padding < rhs.data_padding);}@@ -322,7 +330,7 @@ struct layout {size_t get_linear_size() const;/// Modify padding in layout- layout with_padding(padding const& padd) const;+ layout with_padding(const padding& padd) const;/// Data type stored in @ref memory (see. @ref data_types)ov::element::Type_t data_type;@@ -382,8 +390,9 @@ struct layout {bool has_upper_bound() const {for (const auto& dim : size) {- if (dim.get_max_length() == -1)+ if (dim.get_max_length() == -1) {return false;+ }}return true;}@@ -396,7 +405,7 @@ struct layout {tensor get_tensor() const;- template<typename T>+ template <typename T>T get() const;void set_tensor(const tensor& size);@@ -413,7 +422,9 @@ struct layout {// for smaller buffer which, currently, should always be performedbool identical(const layout& other) const;- static size_t max_rank() { return 8; }+ static size_t max_rank() {+ return 8;+ }static ov::PartialShape transform(const ov::PartialShape& pshape, const cldnn::format& old_fmt, const cldnn::format& new_fmt);size_t hash() const {@@ -442,8 +453,9 @@ struct layout {/// @param _sizes an array that supports operator[] and stores data in the same order as shape./// e.g. it could be std::vector, std::array, or std::bitset, etc.template <class TArray>- inline static std::vector<ov::Dimension::value_type> format_sizes(const TArray _sizes, const cldnn::format &fmt,- const ov::Dimension::value_type default_val = 1) {+ inline static std::vector<ov::Dimension::value_type> format_sizes(const TArray _sizes,+ const cldnn::format& fmt,+ const ov::Dimension::value_type default_val = 1) {const auto& output_order = fmt.order();std::vector<ov::Dimension::value_type> sizes(output_order.size(), default_val);@@ -477,8 +489,9 @@ inline ::std::ostream& operator<<(::std::ostream& os, const std::vector<layout>&for (size_t i = 0; i < layouts.size(); i++) {ss << layouts[i].to_short_string();- if (i + 1 != layouts.size())+ if (i + 1 != layouts.size()) {ss << ", ";+ }}ss << "]";diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/memory.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/memory.hppindex be853f758d5..6dbc68ae43a 100644--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/memory.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/memory.hpp@@ -279,8 +279,9 @@ inline std::vector<T> read_vector(cldnn::memory::ptr mem, const cldnn::stream& s} else {auto append_from_lock = [](auto& lock, std::vector<T>& out) {out.reserve(lock.end() - lock.begin());- for (auto it = lock.begin(); it != lock.end(); ++it)+ for (auto it = lock.begin(); it != lock.end(); ++it) {out.push_back(static_cast<T>(*it));+ }};switch (mem_dtype) {case data_types::i32: {diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/memory_pool.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/memory_pool.hppindex f97bd3c9c4c..c10a0796193 100644--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/memory_pool.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/memory_pool.hpp@@ -44,8 +44,9 @@ class memory_restricter {void insert(const Key& key) {if (ordered_keys_set1) {auto it = std::lower_bound(ordered_keys_set1->begin(), ordered_keys_set1->end(), key);- if (it != ordered_keys_set1->end() && *it == key)+ if (it != ordered_keys_set1->end() && *it == key) {return;+ }}auto it2 = std::lower_bound(ordered_keys_set2.begin(), ordered_keys_set2.end(), key);if (it2 == ordered_keys_set2.end() || *it2 != key) {@@ -119,8 +120,9 @@ using memory_set = std::unordered_set<memory_user, memory_set_hasher>;struct memory_user_comparer {bool operator()(const memory_user& l_mu, const memory_user& r_mu) const {- if (l_mu._network_id != r_mu._network_id)+ if (l_mu._network_id != r_mu._network_id) {return l_mu._network_id < r_mu._network_id;+ }return l_mu._unique_id < r_mu._unique_id;}};@@ -136,14 +138,18 @@ struct memory_record {struct padded_pool_comparer {bool operator()(const layout& ll, const layout& rl) const {- if (ll.format != rl.format)+ if (ll.format != rl.format) {return ll.format < rl.format;- if (ll.data_type != rl.data_type)+ }+ if (ll.data_type != rl.data_type) {return ll.data_type < rl.data_type;- if (ll.spatial(0) != rl.spatial(0))+ }+ if (ll.spatial(0) != rl.spatial(0)) {return ll.spatial(0) < rl.spatial(0);- if (ll.spatial(1) != rl.spatial(1))+ }+ if (ll.spatial(1) != rl.spatial(1)) {return ll.spatial(1) < rl.spatial(1);+ }return ll.data_padding < rl.data_padding;}};diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/profiling.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/profiling.hppindex edb8233efca..285054ae9ed 100644--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/profiling.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/profiling.hpp@@ -212,15 +212,18 @@ public:: _stage_name(stage_name), _lifetime_logging_mode(lifetime_logging_mode), _print_mem_usage(print_mem_usage) {- if (_lifetime_logging_mode)+ if (_lifetime_logging_mode) {start_logging();+ }}~mem_usage_logger() {- if (_lifetime_logging_mode)+ if (_lifetime_logging_mode) {stop_logging();- if (_print_mem_usage && _is_active)+ }+ if (_print_mem_usage && _is_active) {print_mem_usage_info();+ }}void start_logging() {@@ -369,17 +372,19 @@ private:footprint.peak_rss = (int64_t)(pmc.PeakWorkingSetSize/1024);#elif !defined(__APPLE__)std::ifstream status("/proc/self/status");- if (!status.is_open())+ if (!status.is_open()) {return footprint;+ }std::string line, title;while (std::getline(status, line)) {std::istringstream iss(line);iss >> title;- if (title == "VmHWM:")+ if (title == "VmHWM:") {iss >> footprint.peak_rss;- else if (title == "VmRSS:")+ } else if (title == "VmRSS:") {iss >> footprint.rss;+ }}#endifreturn footprint;diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/tensor.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/tensor.hppindex 408cbe59287..6c75635a30f 100644--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/tensor.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/tensor.hpp@@ -189,8 +189,9 @@ public:_sizes[tensor_batch_dim_max] = feature_num;_sizes[tensor_batch_dim_max + tensor_feature_dim_max] = x;_sizes[tensor_batch_dim_max + tensor_feature_dim_max + 1] = y;- if (batch_num == 0 && feature_num == 0 && x == 0 && y == 0)+ if (batch_num == 0 && feature_num == 0 && x == 0 && y == 0) {_sizes[tensor_batch_dim_max + tensor_feature_dim_max + 2] = 0;+ }}/// @brief Constructs @p tensor.@@ -256,25 +257,29 @@ public:explicit tensor(const std::vector<value_type>& sizes, value_type default_size = 1): tensor(default_size) {int max_size = std::min(static_cast<int>(sizes.size()), tensor_dim_max);- for (int i = 0; i < max_size; i++)+ for (int i = 0; i < max_size; i++) {_sizes[i] = sizes[i];+ }}tensor(format fmt, const std::vector<value_type>& sizes, value_type default_size = 1): tensor(default_size) {const auto& in_order = fmt.order();const auto& out_order = fmt.internal_order();- if (in_order.size() != sizes.size())+ if (in_order.size() != sizes.size()) {throw std::invalid_argument("The count of values passed to initialize tensor does not match passed format.");+ }for (size_t out_idx = 0; out_idx < out_order.size(); ++out_idx) {auto channel = out_order[out_idx];- if (channel == '?')+ if (channel == '?') {continue;+ }auto in_idx = in_order.find(channel);- if (in_idx == in_order.npos)+ if (in_idx == in_order.npos) {throw std::runtime_error("Internal order of a format contains channel which does not appear in external order.");+ }_sizes[out_idx] = sizes[in_idx];}@@ -288,8 +293,9 @@ public:/// @brief Copy assignment.tensor& operator=(const tensor& other) {- if (this == &other)+ if (this == &other) {return *this;+ }std::copy(std::cbegin(other._sizes), std::cend(other._sizes), std::begin(_sizes));return *this;}@@ -303,13 +309,16 @@ public:}friend bool operator<(const tensor& lhs, const tensor& rhs) {- if (lhs.raw.size() != rhs.raw.size())+ if (lhs.raw.size() != rhs.raw.size()) {return lhs.raw.size() < rhs.raw.size();+ }for (size_t i = 0; i < lhs.raw.size(); ++i) {- if (lhs.raw[i] < rhs.raw[i])+ if (lhs.raw[i] < rhs.raw[i]) {return true;- if (rhs.raw[i] < lhs.raw[i])+ }+ if (rhs.raw[i] < lhs.raw[i]) {return false;+ }}return false;@@ -403,15 +412,17 @@ public:/// @brief Assign and addtensor& operator+=(const tensor& rhs) {- for (size_t i = 0; i < tensor_dim_max; i++)+ for (size_t i = 0; i < tensor_dim_max; i++) {_sizes[i] += rhs._sizes[i];+ }return *this;}/// @brief Assign and subtracttensor& operator-=(const tensor& rhs) {- for (size_t i = 0; i < tensor_dim_max; i++)+ for (size_t i = 0; i < tensor_dim_max; i++) {_sizes[i] -= rhs._sizes[i];+ }return *this;}@@ -424,8 +435,9 @@ public:for (size_t i = 0; i < sizes.size(); ++i) {auto c = output_order[i];auto pos = internal_order.find(c);- if (pos == std::string::npos)+ if (pos == std::string::npos) {throw std::domain_error(std::string("Unknown coord type: ") + c);+ }sizes[i] = _sizes[pos];}@@ -436,8 +448,9 @@ public:/// @brief Returns a vector of tensors values, ordered batch, feature, spatial_x, spatial_y.std::vector<value_type> sizes() const {std::vector<value_type> sizes(sizeof(_sizes) / sizeof(_sizes[0]), 0);- for (size_t i = 0; i < sizes.size(); ++i)+ for (size_t i = 0; i < sizes.size(); ++i) {sizes[i] = _sizes[i];+ }return sizes;}@@ -506,8 +519,9 @@ public:for (size_t i = 0; i < new_order.size(); i++) {auto c = new_order[i]; //bfxywz- if (c == '?')+ if (c == '?') {continue;+ }if (new_sizes[i] == -1) {new_sizes[i] = 1;}@@ -608,8 +622,9 @@ public:/// @brief Returns a tensor containing values maximum from @p lhs and @p rhs.static tensor max(tensor const& lhs, tensor const& rhs) {auto ret = lhs;- for (size_t i = 0; i < tensor_dim_max; ++i)+ for (size_t i = 0; i < tensor_dim_max; ++i) {ret._sizes[i] = std::max(ret._sizes[i], rhs._sizes[i]);+ }return ret;}@@ -617,8 +632,9 @@ public:/// @brief Returns a tensor containing values minimum from @p lhs and @p rhs.static tensor min(tensor const& lhs, tensor const& rhs) {auto ret = lhs;- for (size_t i = 0; i < tensor_dim_max; ++i)+ for (size_t i = 0; i < tensor_dim_max; ++i) {ret._sizes[i] = std::min(ret._sizes[i], rhs._sizes[i]);+ }return ret;}@@ -641,8 +657,9 @@ private:template <details::dim_vec_kind Kind>inline void details::dim_vec_kind_init<Kind>::init_tensor_values(cldnn::tensor& t) {- for (size_t i = _dimOffset; i < (size_t)(_dimOffset + _dimSize); i++)+ for (size_t i = _dimOffset; i < (size_t)(_dimOffset + _dimSize); i++) {t._sizes[i] = _sizes[i - _dimOffset];+ }}/// @brief Adds two @p tensorsdiff --git a/src/plugins/intel_gpu/src/graph/activation.cpp b/src/plugins/intel_gpu/src/graph/activation.cppindex 1fdd91b1cf9..aa4d1380b80 100644--- a/src/plugins/intel_gpu/src/graph/activation.cpp+++ b/src/plugins/intel_gpu/src/graph/activation.cpp@@ -32,8 +32,9 @@ layout activation_inst::calc_output_layout(activation_node const& node, kernel_iif (input_node_layout.data_type == data_types::i8 || input_node_layout.data_type == data_types::u8 ||input_node_layout.data_type == data_types::i32) {- if (std::find(activations_int8.begin(), activations_int8.end(), func) == activations_int8.end())+ if (std::find(activations_int8.begin(), activations_int8.end(), func) == activations_int8.end()) {CLDNN_ERROR_MESSAGE(desc->id, "Requested activation is not supported for integer type.");+ }}if (impl_param.has_fused_primitives()) {diff --git a/src/plugins/intel_gpu/src/graph/arg_max_min.cpp b/src/plugins/intel_gpu/src/graph/arg_max_min.cppindex d3c7f325582..90986b58e15 100644--- a/src/plugins/intel_gpu/src/graph/arg_max_min.cpp+++ b/src/plugins/intel_gpu/src/graph/arg_max_min.cpp@@ -27,8 +27,9 @@ layout arg_max_min_inst::calc_output_layout(arg_max_min_node const& node, kerneloutput_idx_type = *(desc->output_data_types[0]);}auto size_check = [&](size_t tensor_size) {- if (desc->input.size() == 1 && values_first)+ if (desc->input.size() == 1 && values_first) {return;+ }size_t max_size;// lowest integer not representable in floating point type = 2^(mantissa_bits + 1) + 1// https://stackoverflow.com/questions/3793838/which-is-the-first-integer-that-an-ieee-754-float-is-incapable-of-representing-ediff --git a/src/plugins/intel_gpu/src/graph/batch_to_space.cpp b/src/plugins/intel_gpu/src/graph/batch_to_space.cppindex 803521f57dd..70fefa2e6e6 100644--- a/src/plugins/intel_gpu/src/graph/batch_to_space.cpp+++ b/src/plugins/intel_gpu/src/graph/batch_to_space.cpp@@ -23,8 +23,9 @@ layout batch_to_space_inst::calc_output_layout(batch_to_space_node const& node,auto output_type = desc->output_data_types[0].value_or(input_layout.data_type);- if (impl_param.has_fused_primitives())+ if (impl_param.has_fused_primitives()) {output_type = impl_param.get_output_element_type();+ }const size_t spatial_num = format::spatial_num(input_format);@@ -32,38 +33,46 @@ layout batch_to_space_inst::calc_output_layout(batch_to_space_node const& node,const auto& crops_begin = desc->crops_begin;const auto& crops_end = desc->crops_end;- if (block_shape.batch[0] != 1)+ if (block_shape.batch[0] != 1) {CLDNN_ERROR_MESSAGE(desc->id,"block_shape[0] is expected to be 1. Actual block_shape[0] is " +std::to_string(block_shape.batch[0]));+ }- if (crops_begin.batch[0] != 0)+ if (crops_begin.batch[0] != 0) {CLDNN_ERROR_MESSAGE(desc->id,"crops_begin[0] is expected to be 0. Actual crops_begin[0] is " +std::to_string(crops_begin.batch[0]));+ }- if (crops_end.batch[0] != 0)+ if (crops_end.batch[0] != 0) {CLDNN_ERROR_MESSAGE(desc->id,"crops_end[0] is expected to be 0. Actual crops_end[0] is " +std::to_string(crops_end.batch[0]));+ }size_t block_sizes_multiplied = block_shape.feature[0];- for (size_t i = 0; i < spatial_num; ++i)+ for (size_t i = 0; i < spatial_num; ++i) {block_sizes_multiplied *= block_shape.spatial[i];+ }- if (input_layout.batch() % block_sizes_multiplied != 0)+ if (input_layout.batch() % block_sizes_multiplied != 0) {CLDNN_ERROR_MESSAGE(desc->id,"The batch of the input tensor must be divisible by multiplied block sizes = " +std::to_string(block_sizes_multiplied));+ }- if (crops_begin.feature[0] + crops_end.feature[0] >= block_shape.feature[0] * input_layout.feature())+ if (crops_begin.feature[0] + crops_end.feature[0] >= block_shape.feature[0] * input_layout.feature()) {CLDNN_ERROR_MESSAGE(desc->id,"Output dimensions must be positive");+ }- for (size_t i = 0; i < spatial_num; ++i)- if (crops_begin.spatial[i] + crops_end.spatial[i] >= block_shape.spatial[i] * input_layout.spatial(i))+ for (size_t i = 0; i < spatial_num; ++i) {+ if (crops_begin.spatial[i] + crops_end.spatial[i] >= block_shape.spatial[i] * input_layout.spatial(i)) {CLDNN_ERROR_MESSAGE(desc->id,"Output dimensions must be positive");+ }+ }return layout{output_type, input_format, desc->out_size};}@@ -91,8 +100,9 @@ std::vector<layout> batch_to_space_inst::calc_output_layouts(batch_to_space_nodeauto end_data = desc->crops_end;auto output_type = desc->output_data_types[0].value_or(input0_layout.data_type);- if (impl_param.has_fused_primitives())+ if (impl_param.has_fused_primitives()) {output_type = impl_param.get_output_element_type();+ }if (desc->shape_constant == 0 && (!constant_mem.count(1) || !constant_mem.count(2) || !constant_mem.count(3))) {auto out_shape = ov::PartialShape::dynamic(input0_size);diff --git a/src/plugins/intel_gpu/src/graph/broadcast.cpp b/src/plugins/intel_gpu/src/graph/broadcast.cppindex 0aa08c433df..7533a811bbc 100644--- a/src/plugins/intel_gpu/src/graph/broadcast.cpp+++ b/src/plugins/intel_gpu/src/graph/broadcast.cpp@@ -31,8 +31,9 @@ layout broadcast_inst::calc_output_layout(broadcast_node const& node, kernel_impstd::transform(desc->target_shape.begin(), desc->target_shape.end(), dims_converted.begin(), [](size_t value) {return static_cast<tensor::value_type>(value);});- for (size_t i = dims_converted.size(); i < 4; i++)+ for (size_t i = dims_converted.size(); i < 4; i++) {dims_converted.push_back(1); // extend shape to 4d+ }return { output_type,input_layout.format,@@ -134,16 +135,19 @@ void broadcast_inst::on_execute() {}void broadcast_inst::update_output_memory() {- if (!can_be_optimized())+ if (!can_be_optimized()) {return;+ }build_deps();- if (input_memory_ptr() == nullptr)+ if (input_memory_ptr() == nullptr) {return;+ }- if (static_cast<bool>(_outputs[0]) && _network.get_engine().is_the_same_buffer(output_memory(), input_memory()))+ if (static_cast<bool>(_outputs[0]) && _network.get_engine().is_the_same_buffer(output_memory(), input_memory())) {return;+ }GPU_DEBUG_TRACE_DETAIL << id() << " : update_output_memory with mem of input " << get_node().get_dependency(0).id()<< " : " << input_memory_ptr()->buffer_ptr() << std::endl;@@ -158,8 +162,9 @@ void broadcast_inst::update_output_memory() {broadcast_inst::typed_primitive_inst(network& network, broadcast_node const& node) : parent(network, node) {auto input_layout = node.get_input_layout();- if (input_layout.is_dynamic())+ if (input_layout.is_dynamic()) {return;+ }const auto& output_sizes = argument->broadcast_sizes;std::vector<tensor::value_type> input_dims = input_layout.get_dims();diff --git a/src/plugins/intel_gpu/src/graph/col2im.cpp b/src/plugins/intel_gpu/src/graph/col2im.cppindex 96d8b51d2bf..7c071504533 100644--- a/src/plugins/intel_gpu/src/graph/col2im.cpp+++ b/src/plugins/intel_gpu/src/graph/col2im.cpp@@ -50,10 +50,11 @@ std::vector<layout> col2im_inst::calc_output_layouts(col2im_node const& node, keconst auto batch = is_batched ? input_layout.batch() : 1;const auto num_elements = is_batched ? input_layout.feature() : input_layout.batch();- if (is_batched)+ if (is_batched) {reshaped_input.set_partial_shape({batch, num_elements, num_blocks_l});- else+ } else {reshaped_input.set_partial_shape({num_elements, num_blocks_l});+ }} else {OPENVINO_ASSERT(input_layout.is_static(), "col2im supports static shape only.");}diff --git a/src/plugins/intel_gpu/src/graph/common_utils/parallel_mem_streambuf.cpp b/src/plugins/intel_gpu/src/graph/common_utils/parallel_mem_streambuf.cppindex 246af70806f..d422e9ce584 100644--- a/src/plugins/intel_gpu/src/graph/common_utils/parallel_mem_streambuf.cpp+++ b/src/plugins/intel_gpu/src/graph/common_utils/parallel_mem_streambuf.cpp@@ -81,19 +81,22 @@ static bool get_mmap_file_info(const void* addr, std::filesystem::path& out_pathreturn true;#elsestd::ifstream maps_file("/proc/self/maps");- if (!maps_file.is_open())+ if (!maps_file.is_open()) {return false;+ }const auto addr_val = reinterpret_cast<uintptr_t>(addr);std::string line;while (std::getline(maps_file, line)) {// Format: start-end perms offset dev inode [pathname]std::istringstream iss(line);std::string addr_range, perms, offset_str, dev, inode_str;- if (!(iss >> addr_range >> perms >> offset_str >> dev >> inode_str))+ if (!(iss >> addr_range >> perms >> offset_str >> dev >> inode_str)) {continue;+ }const auto dash = addr_range.find('-');- if (dash == std::string::npos)+ if (dash == std::string::npos) {continue;+ }uintptr_t range_start = 0, range_end = 0;try {range_start = static_cast<uintptr_t>(std::stoull(addr_range.substr(0, dash), nullptr, 16));@@ -101,17 +104,20 @@ static bool get_mmap_file_info(const void* addr, std::filesystem::path& out_path} catch (...) {continue;}- if (addr_val < range_start || addr_val >= range_end)+ if (addr_val < range_start || addr_val >= range_end) {continue;+ }// Skip whitespace after inode to reach the optional pathname field.// Use getline instead of operator>> to handle paths that contain spaces.std::string pathname;std::getline(iss >> std::ws, pathname);- if (pathname.empty())+ if (pathname.empty()) {return false; // anonymous mapping (no pathname)+ }std::filesystem::path path(pathname);- if (!path.is_absolute())+ if (!path.is_absolute()) {return false; // special region like [heap], [stack], [vdso]+ }out_path = path;std::streamoff map_offset = 0;try {@@ -268,11 +274,13 @@ void ParallelMemStreamBuf::parallel_copy(char* dst, const char* src, size_t sizestd::memcpy(dst + offset, src + offset, copy_size);});} catch (...) {- for (auto& t : workers)+ for (auto& t : workers) {t.join();+ }const size_t done = i * chunk_size;- if (done < size)+ if (done < size) {std::memcpy(dst + done, src + done, size - done);+ }return;}}diff --git a/src/plugins/intel_gpu/src/graph/compilation_context.cpp b/src/plugins/intel_gpu/src/graph/compilation_context.cppindex 14f9ee23cb3..caf9171f1d0 100644--- a/src/plugins/intel_gpu/src/graph/compilation_context.cpp+++ b/src/plugins/intel_gpu/src/graph/compilation_context.cpp@@ -19,8 +19,9 @@ public:}void push_task(kernel_impl_params key, Task&& task) override {- if (_stop_compilation)+ if (_stop_compilation) {return;+ }auto promise = std::make_shared<std::promise<void>>();@@ -57,8 +58,9 @@ public:}void cancel() noexcept override {- if (_stop_compilation)+ if (_stop_compilation) {return;+ }_stop_compilation = true;@@ -67,8 +69,9 @@ public:{std::lock_guard<std::recursive_mutex> lock(_mutex);- if (_task_executor != nullptr)+ if (_task_executor != nullptr) {_task_executor.reset();+ }_task_keys.clear();}}diff --git a/src/plugins/intel_gpu/src/graph/concatenation.cpp b/src/plugins/intel_gpu/src/graph/concatenation.cppindex d43c0c94542..3a9ee378fb3 100644--- a/src/plugins/intel_gpu/src/graph/concatenation.cpp+++ b/src/plugins/intel_gpu/src/graph/concatenation.cpp@@ -33,8 +33,9 @@ layout concatenation_inst::calc_output_layout(concatenation_node const& node, keresult_sizes[axis_index] = 0;for (size_t i = 0; i < desc->input.size(); ++i) {auto input_sizes = impl_param.get_input_layout(i).get_dims();- if (impl_param.get_input_layout(i).format == format::b_fs_yx_fsv16)+ if (impl_param.get_input_layout(i).format == format::b_fs_yx_fsv16) {output_format = format::b_fs_yx_fsv16;+ }result_sizes[axis_index] += input_sizes[axis_index];}@@ -56,8 +57,9 @@ std::vector<layout> concatenation_inst::calc_output_layouts(const concatenation_}auto output_format = input_layout.format;for (size_t i = 0; i < desc->input.size(); ++i) {- if (impl_param.get_input_layout(i).format == format::b_fs_yx_fsv16)+ if (impl_param.get_input_layout(i).format == format::b_fs_yx_fsv16) {output_format = format::b_fs_yx_fsv16;+ }}auto axis_index = desc->axis;@@ -85,10 +87,11 @@ std::string concatenation_inst::to_string(concatenation_node const& node) {for (size_t i = 0; i < node.get_inputs_count(); ++i) {ss_inputs << node.input(i).id();- if (node.input(i).get_output_layout().is_static())+ if (node.input(i).get_output_layout().is_static()) {ss_inputs << ", count: " << node.input(i).get_output_layout().count();- else+ } else {ss_inputs << ", count: " << "?";+ }i != (node.get_inputs_count() - 1) ? ss_inputs << ", " : ss_inputs << "";}@@ -159,8 +162,9 @@ concatenation_inst::typed_primitive_inst(network& network, concatenation_node coauto* processed_node = processed_nodes.first;processed_node->_outputs = _outputs;if (processed_node->type() == concatenation::type_id() && processed_node->can_be_optimized()) {- if (!processed_node->_deps.empty())+ if (!processed_node->_deps.empty()) {stack.push_back(&processed_node->_deps);+ }}}}diff --git a/src/plugins/intel_gpu/src/graph/condition.cpp b/src/plugins/intel_gpu/src/graph/condition.cppindex 25f5795395e..3a0539788d2 100644--- a/src/plugins/intel_gpu/src/graph/condition.cpp+++ b/src/plugins/intel_gpu/src/graph/condition.cpp@@ -260,8 +260,9 @@ void condition_inst::postprocess_output_memory(network::ptr executed_net, cldnn:}_outputs[out_mem_idx] = mem_ptr;- if (mem_ptr)+ if (mem_ptr) {GPU_DEBUG_LOG << "Inner net - Outputs[" << out_mem_idx << "]" << mem_ptr->get_layout().to_short_string() << std::endl;+ }}}} // namespace cldnndiff --git a/src/plugins/intel_gpu/src/graph/convolution.cpp b/src/plugins/intel_gpu/src/graph/convolution.cppindex ff1685917e7..d2c5d39aa27 100644--- a/src/plugins/intel_gpu/src/graph/convolution.cpp+++ b/src/plugins/intel_gpu/src/graph/convolution.cpp@@ -41,18 +41,21 @@ std::vector<layout> calc_output_layout_impl(convolution_node const& node, kernelinput_layout.format == format::winograd_2x3_s1_fused_weights ||input_layout.format == format::winograd_6x3_s1_fused_weights ||input_layout.format == format::image_2d_weights_winograd_6x3_s1_fbxyb ||- input_layout.format == format::image_2d_weights_winograd_6x3_s1_xfbyb)+ input_layout.format == format::image_2d_weights_winograd_6x3_s1_xfbyb) {CLDNN_ERROR_MESSAGE(desc->id,"Input for convolution should not be in winograd weights format - it is reserved for weights only");+ }if (input_layout.format == format::winograd_2x3_s1_data) {- if (input_layout.feature() % 32 != 0)+ if (input_layout.feature() % 32 != 0) {CLDNN_ERROR_MESSAGE(desc->id,"Input for winograd 2x3 convolution should have features count divisable by 32");- if (weights_layout.ofm() % 32 != 0)+ }+ if (weights_layout.ofm() % 32 != 0) {CLDNN_ERROR_MESSAGE(desc->id,"Number of filters (OFM) for winograd 2x3 convolution should be divisable by 32");+ }CLDNN_ERROR_LESS_THAN(desc->id,"input width",@@ -196,8 +199,9 @@ std::string convolution_inst::to_string(convolution_node const& node) {convolution_inst::typed_primitive_inst(network& network, convolution_node const& node) :parent(network, node),_deform_conv_dep_offset(node.get_deform_conv_dep_offset()) {- if (node.is_dynamic())+ if (node.is_dynamic()) {return;+ }OPENVINO_ASSERT(all_not_zeroes(argument->stride), "[GPU] Convolution strides must be positive numbers");OPENVINO_ASSERT(all_not_zeroes(argument->dilation), "[GPU] Convolution dilations must be positive numbers");diff --git a/src/plugins/intel_gpu/src/graph/crop.cpp b/src/plugins/intel_gpu/src/graph/crop.cppindex e15ba12d253..033f5d9eedb 100644--- a/src/plugins/intel_gpu/src/graph/crop.cpp+++ b/src/plugins/intel_gpu/src/graph/crop.cpp@@ -142,8 +142,9 @@ std::vector<layout> crop_inst::calc_output_layouts(const crop_node& /*node*/, cofor (int32_t prev = 0; prev < desc->output_idx; prev++) {auto prev_crop_shape = output_layouts[prev].get_partial_shape().to_shape();for (size_t i = 0; i < dims; ++i) {- if (prev_crop_shape[i] != input_shape.to_shape()[i])+ if (prev_crop_shape[i] != input_shape.to_shape()[i]) {startOffset[i] += prev_crop_shape[i];+ }}}@@ -265,16 +266,19 @@ void crop_inst::on_execute() {}void crop_inst::update_output_memory() {- if (!can_be_optimized())+ if (!can_be_optimized()) {return;+ }build_deps();- if (input_memory_ptr() == nullptr)+ if (input_memory_ptr() == nullptr) {return;+ }- if (_outputs[0] && get_network().get_engine().is_the_same_buffer(output_memory(), input_memory()))+ if (_outputs[0] && get_network().get_engine().is_the_same_buffer(output_memory(), input_memory())) {return;+ }// Can_be_optimized nodes are allocating from memory_pool too. In this case,// we need release the legacy output memory from memory pool explicitly.diff --git a/src/plugins/intel_gpu/src/graph/data.cpp b/src/plugins/intel_gpu/src/graph/data.cppindex ce82565e6c5..194ade06ad7 100644--- a/src/plugins/intel_gpu/src/graph/data.cpp+++ b/src/plugins/intel_gpu/src/graph/data.cpp@@ -21,8 +21,9 @@ GPU_DEFINE_PRIMITIVE_TYPE_ID(data)namespace {memory::ptr attach_or_copy_data(network& network, memory::ptr mem) {auto& engine = network.get_engine();- if (mem->is_allocated_by(engine))+ if (mem->is_allocated_by(engine)) {return mem;+ }memory::ptr result = engine.allocate_memory(mem->get_layout(), false);mem_lock<char, mem_lock_type::read> src(mem, network.get_stream());diff --git a/src/plugins/intel_gpu/src/graph/debug_helper.cpp b/src/plugins/intel_gpu/src/graph/debug_helper.cppindex 8b6ff209c95..2382f5c9d5c 100644--- a/src/plugins/intel_gpu/src/graph/debug_helper.cpp+++ b/src/plugins/intel_gpu/src/graph/debug_helper.cpp@@ -3,36 +3,49 @@//#include "debug_helper.hpp"+#include <regex>+#include "intel_gpu/runtime/execution_config.hpp"#include "intel_gpu/runtime/internal_properties.hpp"#include "openvino/util/file_util.hpp"#ifdef GPU_DEBUG_CONFIG-#include "impls/ocl/kernels_cache.hpp"-#include "to_string_utils.h"-#include "loop_inst.h"-#include "condition_inst.h"-#include "activation_inst.h"-#include "program_dump_graph.h"+# include <sys/stat.h>++# include <fstream>+# include <iomanip>-#include <iomanip>-#include <fstream>-#include <sys/stat.h>+# include "activation_inst.h"+# include "condition_inst.h"+# include "impls/ocl/kernels_cache.hpp"+# include "loop_inst.h"+# include "program_dump_graph.h"+# include "to_string_utils.h"namespace cldnn {namespace {-float convert_element(int64_t i) { return static_cast<float>(i); }-float convert_element(int32_t i) { return static_cast<float>(i); }+float convert_element(int64_t i) {+ return static_cast<float>(i);+}+float convert_element(int32_t i) {+ return static_cast<float>(i);+}-float convert_element(float f) { return f; }+float convert_element(float f) {+ return f;+}-float convert_element(ov::float16 h) { return static_cast<float>(h); }+float convert_element(ov::float16 h) {+ return static_cast<float>(h);+}-float convert_element(ov::bfloat16 h) { return static_cast<float>(h); }+float convert_element(ov::bfloat16 h) {+ return static_cast<float>(h);+}size_t get_x_pitch(const layout& layout) {try {@@ -48,9 +61,10 @@ size_t get_x_pitch(const layout& layout) {}template <class T>-std::pair<float, float> __validate_data_range(memory::ptr mem, stream& stream, const layout& data_layout, std::string &info) {- if (!mem)+std::pair<float, float> __validate_data_range(memory::ptr mem, stream& stream, const layout& data_layout, std::string& info) {+ if (!mem) {return {0.0f, 0.0f};+ }// Reinterpret buffer to represent actual data layout (same as log_memory_to_file)auto actual_mem = mem->get_engine()->reinterpret_buffer(*mem, data_layout);@@ -72,10 +86,12 @@ std::pair<float, float> __validate_data_range(memory::ptr mem, stream& stream, cGPU_DEBUG_COUT << err_str << " WAS FOUND: " << info << " *********************" << std::endl;return {0.0f, 0.0f};}- if (val > val_max)+ if (val > val_max) {val_max = val;- if (val < val_min)+ }+ if (val < val_min) {val_min = val;+ }}count = actual_mem->count();} else {@@ -95,10 +111,12 @@ std::pair<float, float> __validate_data_range(memory::ptr mem, stream& stream, cGPU_DEBUG_COUT << err_str << " WAS FOUND: " << info << " *********************" << std::endl;return {0.0f, 0.0f};}- if (val > val_max)+ if (val > val_max) {val_max = val;- if (val < val_min)+ }+ if (val < val_min) {val_min = val;+ }count++;}}@@ -117,18 +135,23 @@ std::pair<float, float> __validate_data_range(memory::ptr mem, stream& stream, creturn {val_min, val_max};}-std::pair<float, float> validate_data_range(memory::ptr mem, stream& stream, const layout& data_layout, std::string &info) {+std::pair<float, float> validate_data_range(memory::ptr mem, stream& stream, const layout& data_layout, std::string& info) {auto data_type = data_layout.data_type;- if (data_type == cldnn::data_types::f32)+ if (data_type == cldnn::data_types::f32) {return __validate_data_range<float>(mem, stream, data_layout, info);- if (data_type == cldnn::data_types::f16)+ }+ if (data_type == cldnn::data_types::f16) {return __validate_data_range<ov::float16>(mem, stream, data_layout, info);- if (data_type == cldnn::data_types::bf16)+ }+ if (data_type == cldnn::data_types::bf16) {return __validate_data_range<ov::bfloat16>(mem, stream, data_layout, info);- if (data_type == cldnn::data_types::i8)+ }+ if (data_type == cldnn::data_types::i8) {return __validate_data_range<int8_t>(mem, stream, data_layout, info);- if (data_type == cldnn::data_types::u8)+ }+ if (data_type == cldnn::data_types::u8) {return __validate_data_range<uint8_t>(mem, stream, data_layout, info);+ }GPU_DEBUG_INFO << "Unsupport data type for validating data range " << data_type << std::endl;return {0.0f, 0.0f};}@@ -142,17 +165,12 @@ void dump(memory::ptr mem, stream& stream, std::ofstream& file_stream, bool dumptmp_size.batch[0] = batch_size;if (tmp_size == size) {file_stream << "shape: " << size.to_string() << " ";- file_stream << "(count: " << size.count()- << ", addr: " << mem->buffer_ptr()- << ", original format: " << cldnn::fmt_to_str(mem->get_layout().format) << ")"- << (dump_raw ? " raw data" : "") << std::endl;+ file_stream << "(count: " << size.count() << ", addr: " << mem->buffer_ptr() << ", original format: " << cldnn::fmt_to_str(mem->get_layout().format)+ << ")" << (dump_raw ? " raw data" : "") << std::endl;} else {file_stream << "shape: " << tmp_size.to_string() << " ";- file_stream << "(count: " << tmp_size.count()- << ", addr: " << mem->buffer_ptr()- << ", original format: " << cldnn::fmt_to_str(mem->get_layout().format)- << ", original shape: " << size.to_string() << ")"- << (dump_raw ? " raw data" : "") << std::endl;+ file_stream << "(count: " << tmp_size.count() << ", addr: " << mem->buffer_ptr() << ", original format: " << cldnn::fmt_to_str(mem->get_layout().format)+ << ", original shape: " << size.to_string() << ")" << (dump_raw ? " raw data" : "") << std::endl;}if (size.count() == 0) {@@ -192,7 +210,7 @@ void dump(memory::ptr mem, stream& stream, std::ofstream& file_stream, bool dumpfile_stream << buffer.str();}-void unpack(cldnn::data_types type, uint8_t input, int8_t &v0, int8_t &v1) {+void unpack(cldnn::data_types type, uint8_t input, int8_t& v0, int8_t& v1) {if (type == cldnn::data_types::i4) {char s_bit = (input & 0x08);char mask = s_bit > 0 ? 0xF0 : 0x00;@@ -218,15 +236,12 @@ void dump_i4u4(cldnn::data_types type, memory::ptr mem, stream& stream, std::ofstmp_size.batch[0] = batch_size;if (tmp_size == size) {file_stream << "shape: " << size.to_string() << " ";- file_stream << "(count: " << size.count()- << ", original format: " << cldnn::fmt_to_str(mem->get_layout().format) << ")"+ file_stream << "(count: " << size.count() << ", original format: " << cldnn::fmt_to_str(mem->get_layout().format) << ")"<< (dump_raw ? " raw data" : "") << std::endl;} else {file_stream << "shape: " << tmp_size.to_string() << " ";- file_stream << "(count: " << tmp_size.count()- << ", original format: " << cldnn::fmt_to_str(mem->get_layout().format)- << ", original shape: " << size.to_string() << ")"- << (dump_raw ? " raw data" : "") << std::endl;+ file_stream << "(count: " << tmp_size.count() << ", original format: " << cldnn::fmt_to_str(mem->get_layout().format)+ << ", original shape: " << size.to_string() << ")" << (dump_raw ? " raw data" : "") << std::endl;}if (size.count() == 0) {@@ -271,33 +286,33 @@ void log_memory_to_file(memory::ptr mem, layout data_layout, stream& stream, stdauto actual_mem = mem->get_engine()->reinterpret_buffer(*mem, data_layout);auto mem_dt = actual_mem->get_layout().data_type;- if (mem_dt == cldnn::data_types::f32)+ if (mem_dt == cldnn::data_types::f32) {dump<float>(actual_mem, stream, file_stream, dump_raw);- else if (mem_dt == cldnn::data_types::f16)+ } else if (mem_dt == cldnn::data_types::f16) {dump<ov::float16>(actual_mem, stream, file_stream, dump_raw);- else if (mem_dt == cldnn::data_types::bf16)+ } else if (mem_dt == cldnn::data_types::bf16) {dump<ov::bfloat16>(actual_mem, stream, file_stream, dump_raw);- else if (mem_dt == cldnn::data_types::i64)+ } else if (mem_dt == cldnn::data_types::i64) {dump<int64_t>(actual_mem, stream, file_stream, dump_raw);- else if (mem_dt == cldnn::data_types::i32)+ } else if (mem_dt == cldnn::data_types::i32) {dump<int32_t>(actual_mem, stream, file_stream, dump_raw);- else if (mem_dt == cldnn::data_types::i8)+ } else if (mem_dt == cldnn::data_types::i8) {dump<int8_t>(actual_mem, stream, file_stream, dump_raw);- else if (mem_dt == cldnn::data_types::u8)+ } else if (mem_dt == cldnn::data_types::u8) {dump<uint8_t>(actual_mem, stream, file_stream, dump_raw);- else if (mem_dt == cldnn::data_types::f8e5m2)+ } else if (mem_dt == cldnn::data_types::f8e5m2) {dump<ov::float8_e5m2>(actual_mem, stream, file_stream, dump_raw);- else if (mem_dt == cldnn::data_types::f8e4m3)+ } else if (mem_dt == cldnn::data_types::f8e4m3) {dump<ov::float8_e4m3>(actual_mem, stream, file_stream, dump_raw);- else if (mem_dt == cldnn::data_types::f4e2m1)+ } else if (mem_dt == cldnn::data_types::f4e2m1) {dump<ov::float4_e2m1>(actual_mem, stream, file_stream, dump_raw);- else if (mem_dt == cldnn::data_types::f8e8m0)+ } else if (mem_dt == cldnn::data_types::f8e8m0) {dump<ov::float8_e8m0>(actual_mem, stream, file_stream, dump_raw);- else if (mem_dt == cldnn::data_types::boolean)+ } else if (mem_dt == cldnn::data_types::boolean) {dump<uint8_t>(actual_mem, stream, file_stream, dump_raw);- else if (mem_dt == cldnn::data_types::i4 || mem_dt == cldnn::data_types::u4)+ } else if (mem_dt == cldnn::data_types::i4 || mem_dt == cldnn::data_types::u4) {dump_i4u4(mem_dt, actual_mem, stream, file_stream, dump_raw);- else+ } elseGPU_DEBUG_COUT << "Dump for this data type is not supported: " << dt_to_str(mem_dt) << std::endl;}@@ -307,7 +322,7 @@ std::string get_file_path_for_binary_dump(cldnn::layout layout, const std::strinstd::string format = layout.format.to_string();std::string tensor;auto dims = layout.get_dims();- for (size_t r = 0 ; r < layout.get_rank() ; r++) {+ for (size_t r = 0; r < layout.get_rank(); r++) {tensor += ("_" + to_string(dims[r]));}@@ -317,11 +332,13 @@ std::string get_file_path_for_binary_dump(cldnn::layout layout, const std::strin}bool is_target_iteration(int64_t iteration, const std::set<int64_t> dump_iteration) {- if (iteration < 0)+ if (iteration < 0) {return true;+ }- if (dump_iteration.empty())+ if (dump_iteration.empty()) {return true;+ }return dump_iteration.find(iteration) != std::end(dump_iteration);}@@ -357,10 +374,11 @@ bool is_layer_name_matched(const std::string& layer_name, const std::string& patbool is_layer_for_dumping(const ExecutionConfig& config, const std::string& layer_name) {const auto& dump_layers = config.get_dump_layer_names();- if (dump_layers.empty())+ if (dump_layers.empty()) {return true;+ }- auto iter = std::find_if(dump_layers.begin(), dump_layers.end(), [&](const std::string& dl){+ auto iter = std::find_if(dump_layers.begin(), dump_layers.end(), [&](const std::string& dl) {return is_layer_name_matched(layer_name, dl);});return (iter != dump_layers.end());@@ -368,8 +386,9 @@ bool is_layer_for_dumping(const ExecutionConfig& config, const std::string& layestd::vector<std::string> get_filenames_for_matched_layer_loading_binaries(const ExecutionConfig& config, const std::string& id) {std::vector<std::string> file_names;- if (config.get_load_dump_raw_binary().empty())+ if (config.get_load_dump_raw_binary().empty()) {return file_names;+ }for (const auto& load_layer : config.get_load_dump_raw_binary()) {size_t file = load_layer.rfind(":");@@ -380,14 +399,14 @@ std::vector<std::string> get_filenames_for_matched_layer_loading_binaries(constsize_t found = 0;do {found = file_name_str.find(",", head);- if (found != std::string::npos)+ if (found != std::string::npos) {file_names.push_back(file_name_str.substr(head, (found - head)));- else+ } else {file_names.push_back(file_name_str.substr(head));+ }- head = found+1;- GPU_DEBUG_LOG << " Layer name loading raw dump : " << load_layer.substr(0, file) << " / the dump file : "- << file_names.back() << std::endl;+ head = found + 1;+ GPU_DEBUG_LOG << " Layer name loading raw dump : " << load_layer.substr(0, file) << " / the dump file : " << file_names.back() << std::endl;} while (found != std::string::npos);return file_names;@@ -401,18 +420,18 @@ std::vector<std::string> get_filenames_for_matched_layer_loading_binaries(const} // namespaceNodeDebugHelper::NodeDebugHelper(const primitive_inst& inst)- : m_inst(inst)- , m_stream(inst.get_network().get_stream())- , m_network(inst.get_network())- , m_program(inst.get_network().get_program().get())- , m_iter(m_network.iteration) {+ : m_inst(inst),+ m_stream(inst.get_network().get_stream()),+ m_network(inst.get_network()),+ m_program(inst.get_network().get_program().get()),+ m_iter(m_network.iteration) {const auto& config = m_network.get_config();// Load binary dump for input layersif (!config.get_load_dump_raw_binary().empty()) {const std::string layer_name = m_inst.id();auto files = get_filenames_for_matched_layer_loading_binaries(config, layer_name);if (!files.empty()) {- m_stream.finish(); // Wait for stream completion before buffer assignment+ m_stream.finish(); // Wait for stream completion before buffer assignmentif (m_inst.is_input()) {// Loading binary dumps for output tensors of input-layers : only one output exists or index(dstN) existsauto dump_file = get_matched_from_filelist(files, "_dst0__");@@ -433,10 +452,11 @@ NodeDebugHelper::NodeDebugHelper(const primitive_inst& inst)OPENVINO_ASSERT(!bin.empty(), "Failure loading binary from OV_LOAD_DUMP_RAW_BINARY : " + dump_file);auto output_mem = m_inst.output_memory_ptr(i);- OPENVINO_ASSERT(output_mem->size() == bin.size(), "memory size mis-match for OV_LOAD_DUMP_RAW_BINARY : " + layer_name- + "\n Expected size : " + to_string(output_mem->size()) + ", Binary : " + to_string(bin.size()));+ OPENVINO_ASSERT(output_mem->size() == bin.size(),+ "memory size mis-match for OV_LOAD_DUMP_RAW_BINARY : " + layer_name ++ "\n Expected size : " + to_string(output_mem->size()) + ", Binary : " + to_string(bin.size()));- output_mem->copy_from(m_stream, static_cast<void *>(&bin[0]), true);+ output_mem->copy_from(m_stream, static_cast<void*>(&bin[0]), true);}} else {auto check_dst = get_matched_from_filelist(files, "_dst0__");@@ -453,23 +473,23 @@ NodeDebugHelper::NodeDebugHelper(const primitive_inst& inst)dump_file = get_matched_from_filelist(files, pattern);}if (dump_file.empty()) {- GPU_DEBUG_COUT << " Skip loading for input(" << i << ") of " << layer_name << std::endl;+ GPU_DEBUG_COUT << " Skip loading for input(" << i << ") of " << layer_name << std::endl;continue;}OPENVINO_ASSERT((!dump_file.empty()), "Could not find expected pattern '_src[N]__' for binary dump input");- GPU_DEBUG_COUT << " Load binary dump : " << dump_file << " for input(" << i << ") of " << layer_name << std::endl;+ GPU_DEBUG_COUT << " Load binary dump : " << dump_file << " for input(" << i << ") of " << layer_name << std::endl;std::vector<uint8_t> bin = ov::util::load_binary(dump_file);OPENVINO_ASSERT(!bin.empty(), "Failure loading binary from OV_LOAD_DUMP_RAW_BINARY : " + dump_file);auto input_mem = m_inst.dep_memory_ptr(i);if (input_mem->size() != bin.size()) {- std::cout << "WARNING: memory size mis-match for OV_LOAD_DUMP_RAW_BINARY : " + layer_name- << " " << input_mem->size() << " / " << bin.size() << std::endl;+ std::cout << "WARNING: memory size mis-match for OV_LOAD_DUMP_RAW_BINARY : " + layer_name << " " << input_mem->size() << " / "+ << bin.size() << std::endl;bin.resize(input_mem->size());}- input_mem->copy_from(m_stream, static_cast<void *>(&bin[0]), true);+ input_mem->copy_from(m_stream, static_cast<void*>(&bin[0]), true);}}}@@ -479,15 +499,15 @@ NodeDebugHelper::NodeDebugHelper(const primitive_inst& inst)if (!config.get_dump_tensors_path().empty()) {const std::string& layer_name = inst.id();- if (is_target_iteration(m_iter, config.get_dump_iterations()) &&- config.get_dump_tensors() != ov::intel_gpu::DumpTensors::out && is_layer_for_dumping(config, layer_name)) {- m_stream.finish(); // Wait for stream completion before dumping input buffers+ if (is_target_iteration(m_iter, config.get_dump_iterations()) && config.get_dump_tensors() != ov::intel_gpu::DumpTensors::out &&+ is_layer_for_dumping(config, layer_name)) {+ m_stream.finish(); // Wait for stream completion before dumping input buffersstd::string debug_str_for_bin_load = " Command for loading : OV_LOAD_DUMP_RAW_BINARY=\"" + layer_name + ":";for (size_t i = 0; i < m_inst.dependencies().size(); i++) {std::string name = get_file_prefix() + "_src" + std::to_string(i);auto input_mem = m_inst.dep_memory_ptr(i);if (input_mem == nullptr) {- GPU_DEBUG_COUT << " input_mem_" << i << " is nullptr. Nothing to dump." << std::endl;+ GPU_DEBUG_COUT << " input_mem_" << i << " is nullptr. Nothing to dump." << std::endl;continue;}@@ -505,28 +525,23 @@ NodeDebugHelper::NodeDebugHelper(const primitive_inst& inst)const bool dump_raw = config.get_dump_tensors_format() == ov::intel_gpu::DumpFormat::text_raw;GPU_DEBUG_COUT << " Dump " << (dump_raw ? "raw " : "") << name << std::endl;auto filename = config.get_dump_tensors_path() + get_name_for_dump(name) + ".txt";- log_memory_to_file(input_mem,- input_layout,- m_stream,- filename,- dump_raw);+ log_memory_to_file(input_mem, input_layout, m_stream, filename, dump_raw);}}if (config.get_dump_tensors_format() == ov::intel_gpu::DumpFormat::binary && !inst.is_input()) {- debug_str_for_bin_load[debug_str_for_bin_load.size()-1] = '\"';+ debug_str_for_bin_load[debug_str_for_bin_load.size() - 1] = '\"';GPU_DEBUG_COUT << debug_str_for_bin_load << std::endl;}}}}-NodeDebugHelper::~NodeDebugHelper() {const auto& config = m_network.get_config();if (config.get_validate_output_buffer() && !m_network.is_internal()) {- m_stream.finish(); // Wait for stream completion before checking output buffers+ m_stream.finish(); // Wait for stream completion before checking output buffersfor (size_t i = 0; i < m_inst.outputs_memory_count(); i++) {auto output_mem = m_inst.output_memory_ptr(i);std::string info = m_inst.id() + "(" + std::to_string(i) + ") at iteration " + std::to_string(m_network.get_current_iteration_num());@@ -536,8 +551,7 @@ NodeDebugHelper::~NodeDebugHelper() {// FP16 mantissa loss early warning for Sin/Cos activation inputsif (m_inst.desc()->type == activation::type_id()) {auto act_desc = std::static_pointer_cast<const activation>(m_inst.desc());- if (act_desc->activation_function == activation_func::sin ||- act_desc->activation_function == activation_func::cos) {+ if (act_desc->activation_function == activation_func::sin || act_desc->activation_function == activation_func::cos) {auto input_mem = m_inst.dep_memory_ptr(0);auto dep = m_inst.dependencies().at(0);auto input_layout = dep.first->get_output_layout(dep.second);@@ -547,10 +561,8 @@ NodeDebugHelper::~NodeDebugHelper() {float abs_max = std::max(std::abs(val_min), std::abs(val_max));constexpr float threshold = 1024.0f;if (abs_max >= threshold) {- GPU_DEBUG_COUT << "*** FP16 MANTISSA LOSS WARNING *** : " << m_inst.id()- << " input max(abs)=" << abs_max- << " (threshold=" << threshold << ")"- << " — Sin/Cos output will lose fractional precision" << std::endl;+ GPU_DEBUG_COUT << "*** FP16 MANTISSA LOSS WARNING *** : " << m_inst.id() << " input max(abs)=" << abs_max << " (threshold=" << threshold+ << ")" << " — Sin/Cos output will lose fractional precision" << std::endl;}}}@@ -561,17 +573,15 @@ NodeDebugHelper::~NodeDebugHelper() {if (!config.get_dump_tensors_path().empty()) {const std::string layer_name = m_inst.id();- if (is_target_iteration(m_iter, config.get_dump_iterations()) &&- config.get_dump_tensors() != ov::intel_gpu::DumpTensors::in &&+ if (is_target_iteration(m_iter, config.get_dump_iterations()) && config.get_dump_tensors() != ov::intel_gpu::DumpTensors::in &&is_layer_for_dumping(config, layer_name)) {- m_stream.finish(); // Wait for stream completion before dumping output buffers- std::string debug_str_for_bin_load = " Command for loading : OV_LOAD_DUMP_RAW_BINARY=\""- + layer_name + ":";+ m_stream.finish(); // Wait for stream completion before dumping output buffers+ std::string debug_str_for_bin_load = " Command for loading : OV_LOAD_DUMP_RAW_BINARY=\"" + layer_name + ":";for (size_t i = 0; i < m_inst.outputs_memory_count(); i++) {std::string name = get_file_prefix() + "_dst" + std::to_string(i);auto output_mem = m_inst.output_memory_ptr(i);if (output_mem == nullptr) {- GPU_DEBUG_COUT << " output_mem is nullptr. Nothing to dump." << std::endl;+ GPU_DEBUG_COUT << " output_mem is nullptr. Nothing to dump." << std::endl;continue;}@@ -582,18 +592,14 @@ NodeDebugHelper::~NodeDebugHelper() {mem_lock<char, mem_lock_type::read> lock(output_mem, m_stream);ov::util::save_binary(ov::util::make_path(filename), lock.data(), output_mem->size());- GPU_DEBUG_COUT << " Dump layer dst : " << layer_name << " to " << filename << std::endl;+ GPU_DEBUG_COUT << " Dump layer dst : " << layer_name << " to " << filename << std::endl;debug_str_for_bin_load += (filename + ",");} else {const bool dump_raw = config.get_dump_tensors_format() == ov::intel_gpu::DumpFormat::text_raw;GPU_DEBUG_COUT << " Dump " << (dump_raw ? "raw " : "") << name << std::endl;auto filename = config.get_dump_tensors_path() + get_name_for_dump(name) + ".txt";// Text dump- log_memory_to_file(output_mem,- m_inst.get_output_layout(i),- m_stream,- filename,- dump_raw);+ log_memory_to_file(output_mem, m_inst.get_output_layout(i), m_stream, filename, dump_raw);}}for (size_t i = 0; i < m_inst.get_intermediates_memories().size(); i++) {@@ -651,16 +657,15 @@ NodeDebugHelper::~NodeDebugHelper() {}if (config.get_dump_tensors_format() == ov::intel_gpu::DumpFormat::binary && m_inst.is_input()) {- debug_str_for_bin_load[debug_str_for_bin_load.size()-1] = '\"';- GPU_DEBUG_COUT << debug_str_for_bin_load << std::endl;;+ debug_str_for_bin_load[debug_str_for_bin_load.size() - 1] = '\"';+ GPU_DEBUG_COUT << debug_str_for_bin_load << std::endl;+ ;}}}}-NetworkDebugHelper::NetworkDebugHelper(network& net)- : m_network(net)- , m_iter(net.iteration) {+NetworkDebugHelper::NetworkDebugHelper(network& net) : m_network(net), m_iter(net.iteration) {if (m_network.get_config().get_network_marker()) {NetworkMarkerHelper::enqueue_start_marker(m_network);}@@ -702,8 +707,9 @@ NetworkDebugHelper::NetworkDebugHelper(network& net)}}}- if (!m_network.is_internal())+ if (!m_network.is_internal()) {exit(0);+ }}}@@ -728,9 +734,8 @@ NetworkDebugHelper::~NetworkDebugHelper() {}}- GPU_DEBUG_COUT << "[program:" << std::setw(2) << ((prog != nullptr) ? prog->get_id() : 0)- << "|network:" << std::setw(2) << net_id << "|iter:" << std::setw(4) << m_iter << "] benchmark_app cmd: "- << data_shape_str.str() << std::endl;+ GPU_DEBUG_COUT << "[program:" << std::setw(2) << ((prog != nullptr) ? prog->get_id() : 0) << "|network:" << std::setw(2) << net_id+ << "|iter:" << std::setw(4) << m_iter << "] benchmark_app cmd: " << data_shape_str.str() << std::endl;}if (!config.get_dump_graphs_path().empty() && is_target_iteration(m_iter, config.get_dump_iterations())) {@@ -741,8 +746,8 @@ NetworkDebugHelper::~NetworkDebugHelper() {};std::string path = get_dir_path(m_network.get_config());if (!path.empty()) {- std::ofstream ofs(path + "cldnn_program_exec_p" + get_fixed_str(prog->get_id()) + "_n" + get_fixed_str(net_id)- + "_" + get_fixed_str(m_iter, 5) + ".graph");+ std::ofstream ofs(path + "cldnn_program_exec_p" + get_fixed_str(prog->get_id()) + "_n" + get_fixed_str(net_id) + "_" + get_fixed_str(m_iter, 5) ++ ".graph");dump_graph_init(ofs, *prog, [this](const primitive_id& id) -> std::shared_ptr<const primitive_inst> {return m_network.get_primitive(id);});@@ -769,16 +774,18 @@ void NetworkDebugHelper::dump_memory_pool(std::string dump_path, int64_t curr_itconst auto& config = prog->get_config();// Dump detailed entries in memory pool- if (config.get_dump_memory_pool() > 1)+ if (config.get_dump_memory_pool() > 1) {m_network.get_memory_pool().dump(m_network.get_id(), curr_iter, dump_path);+ }auto get_constants_mem_size = [&](allocation_type type) -> size_t {size_t mem_size = 0;for (auto& prim : m_network._primitives) {if (prim.second->get_node().is_constant()) {for (size_t i = 0; i < prim.second->outputs_memory_count(); i++) {- if (prim.second->output_memory_ptr(i)->get_allocation_type() == type)+ if (prim.second->output_memory_ptr(i)->get_allocation_type() == type) {mem_size += prim.second->output_memory_ptr(i)->size();+ }}}}@@ -787,8 +794,9 @@ void NetworkDebugHelper::dump_memory_pool(std::string dump_path, int64_t curr_itauto get_variables_mem_size = [&](allocation_type type) -> size_t {size_t mem_size = 0;for (const auto& var : m_network.get_variables()) {- if (var.second->get_memory() && var.second->get_memory()->get_allocation_type() == type)+ if (var.second->get_memory() && var.second->get_memory()->get_allocation_type() == type) {mem_size += var.second->get_actual_mem_size();+ }}return mem_size;};@@ -797,42 +805,42 @@ void NetworkDebugHelper::dump_memory_pool(std::string dump_path, int64_t curr_itfor (auto& prim : m_network._inputs) {for (size_t i = 0; i < prim->outputs_memory_count(); i++) {auto mem = prim->output_memory_ptr(i);- if (mem)+ if (mem) {mem_size += mem->size();+ }}}return mem_size;};auto get_mb_size = [&](int64_t size) -> std::string {- if (size == 0) return "0 MB";+ if (size == 0)+ return "0 MB";return std::to_string(static_cast<float>(size) / (1024 * 1024)) + " MB";};- int64_t usm_host_const_mem_size = get_constants_mem_size(allocation_type::usm_host);- int64_t usm_device_const_mem_size = get_constants_mem_size(allocation_type::usm_device);- int64_t usm_host_var_mem_size = get_variables_mem_size(allocation_type::usm_host);- int64_t usm_device_var_mem_size = get_variables_mem_size(allocation_type::usm_device);- int64_t param_mem_size = get_parameters_mem_size();- int64_t host_mem_size = m_network.get_engine().get_used_device_memory(allocation_type::usm_host);- int64_t device_mem_size = m_network.get_engine().get_used_device_memory(allocation_type::usm_device);- int64_t usm_host_mem_pool_size = m_network.get_memory_pool().get_total_mem_pool_size(allocation_type::usm_host);- int64_t usm_host_etc_size = host_mem_size - usm_host_mem_pool_size- - usm_host_const_mem_size - usm_host_var_mem_size;- int64_t usm_device_mem_pool_size = m_network.get_memory_pool().get_total_mem_pool_size(allocation_type::usm_device);- int64_t usm_device_etc_size = device_mem_size - usm_device_mem_pool_size- - usm_device_const_mem_size - usm_device_var_mem_size;+ int64_t usm_host_const_mem_size = get_constants_mem_size(allocation_type::usm_host);+ int64_t usm_device_const_mem_size = get_constants_mem_size(allocation_type::usm_device);+ int64_t usm_host_var_mem_size = get_variables_mem_size(allocation_type::usm_host);+ int64_t usm_device_var_mem_size = get_variables_mem_size(allocation_type::usm_device);+ int64_t param_mem_size = get_parameters_mem_size();+ int64_t host_mem_size = m_network.get_engine().get_used_device_memory(allocation_type::usm_host);+ int64_t device_mem_size = m_network.get_engine().get_used_device_memory(allocation_type::usm_device);+ int64_t usm_host_mem_pool_size = m_network.get_memory_pool().get_total_mem_pool_size(allocation_type::usm_host);+ int64_t usm_host_etc_size = host_mem_size - usm_host_mem_pool_size - usm_host_const_mem_size - usm_host_var_mem_size;+ int64_t usm_device_mem_pool_size = m_network.get_memory_pool().get_total_mem_pool_size(allocation_type::usm_device);+ int64_t usm_device_etc_size = device_mem_size - usm_device_mem_pool_size - usm_device_const_mem_size - usm_device_var_mem_size;GPU_DEBUG_COUT << "------------------------------------------------------------------------" << std::endl;GPU_DEBUG_COUT << "Memory statistics for (net_id:" << m_network.get_id() << ", iter:" << curr_iter << ")" << std::endl;- GPU_DEBUG_COUT << " * Parameter : " << get_mb_size(param_mem_size) << std::endl;- GPU_DEBUG_COUT << " Total host mem size : " << get_mb_size(host_mem_size) << std::endl;- GPU_DEBUG_COUT << " * Memory pool @ host : " << get_mb_size(usm_host_mem_pool_size) << std::endl;- GPU_DEBUG_COUT << " * Constant @ host : " << get_mb_size(usm_host_const_mem_size) << std::endl;- GPU_DEBUG_COUT << " * Variable @ host : " << get_mb_size(usm_host_var_mem_size) << std::endl;- GPU_DEBUG_COUT << " * ETC @ host : " << get_mb_size(usm_host_etc_size) << std::endl;- GPU_DEBUG_COUT << " Total device mem size : " << get_mb_size(device_mem_size) << std::endl;- GPU_DEBUG_COUT << " * Memory pool @ device : " << get_mb_size(usm_device_mem_pool_size) << std::endl;- GPU_DEBUG_COUT << " * Constant @ device : " << get_mb_size(usm_device_const_mem_size) << std::endl;- GPU_DEBUG_COUT << " * Variable @ device : " << get_mb_size(usm_device_var_mem_size) << std::endl;- GPU_DEBUG_COUT << " * ETC @ device : " << get_mb_size(usm_device_etc_size) << std::endl;+ GPU_DEBUG_COUT << " * Parameter : " << get_mb_size(param_mem_size) << std::endl;+ GPU_DEBUG_COUT << " Total host mem size : " << get_mb_size(host_mem_size) << std::endl;+ GPU_DEBUG_COUT << " * Memory pool @ host : " << get_mb_size(usm_host_mem_pool_size) << std::endl;+ GPU_DEBUG_COUT << " * Constant @ host : " << get_mb_size(usm_host_const_mem_size) << std::endl;+ GPU_DEBUG_COUT << " * Variable @ host : " << get_mb_size(usm_host_var_mem_size) << std::endl;+ GPU_DEBUG_COUT << " * ETC @ host : " << get_mb_size(usm_host_etc_size) << std::endl;+ GPU_DEBUG_COUT << " Total device mem size : " << get_mb_size(device_mem_size) << std::endl;+ GPU_DEBUG_COUT << " * Memory pool @ device : " << get_mb_size(usm_device_mem_pool_size) << std::endl;+ GPU_DEBUG_COUT << " * Constant @ device : " << get_mb_size(usm_device_const_mem_size) << std::endl;+ GPU_DEBUG_COUT << " * Variable @ device : " << get_mb_size(usm_device_var_mem_size) << std::endl;+ GPU_DEBUG_COUT << " * ETC @ device : " << get_mb_size(usm_device_etc_size) << std::endl;GPU_DEBUG_COUT << "------------------------------------------------------------------------" << std::endl;}@@ -844,8 +852,9 @@ std::unordered_map<std::string, kernel::ptr> NetworkMarkerHelper::_compiled_kernkernel::ptr NetworkMarkerHelper::get_or_compile_marker(network& net, const std::string& kernel_name) {std::lock_guard<std::mutex> lock(_mutex);auto it = _compiled_kernels.find(kernel_name);- if (it != _compiled_kernels.end())+ if (it != _compiled_kernels.end()) {return it->second;+ }auto kernel_src = std::make_shared<kernel_string>();kernel_src->str = "__kernel void " + kernel_name + "() {}";@@ -885,4 +894,4 @@ void NetworkMarkerHelper::enqueue_finish_marker(network& net) {} // namespace cldnn-#endif // GPU_DEBUG_CONFIG+#endif // GPU_DEBUG_CONFIGdiff --git a/src/plugins/intel_gpu/src/graph/debug_helper.hpp b/src/plugins/intel_gpu/src/graph/debug_helper.hppindex 3ded63d3922..d2293117c51 100644--- a/src/plugins/intel_gpu/src/graph/debug_helper.hpp+++ b/src/plugins/intel_gpu/src/graph/debug_helper.hpp@@ -43,8 +43,9 @@ public:private:std::string get_iteration_prefix() {- if (m_iter < 0)+ if (m_iter < 0) {return std::string("");+ }return std::to_string(m_iter) + "_";}diff --git a/src/plugins/intel_gpu/src/graph/deconvolution.cpp b/src/plugins/intel_gpu/src/graph/deconvolution.cppindex 0a2e1e6b49e..c5b439c6254 100644--- a/src/plugins/intel_gpu/src/graph/deconvolution.cpp+++ b/src/plugins/intel_gpu/src/graph/deconvolution.cpp@@ -113,8 +113,9 @@ std::vector<layout> deconvolution_inst::calc_output_layouts(deconvolution_node coutput_type = impl_param.get_output_element_type();}- if (input_layout.is_dynamic())+ if (input_layout.is_dynamic()) {return {layout{ShapeType::dynamic(input_layout.get<ShapeType>().rank()), output_type, input_layout.format}};+ }auto strides = desc->stride;auto dilations = desc->dilations;@@ -247,8 +248,9 @@ std::string deconvolution_inst::to_string(deconvolution_node const& node) {deconvolution_inst::typed_primitive_inst(network& network, deconvolution_node const& node): parent(network, node) {- if (node.is_dynamic())+ if (node.is_dynamic()) {return;+ }auto stride = argument->stride;auto pad = argument->pad;diff --git a/src/plugins/intel_gpu/src/graph/depth_to_space.cpp b/src/plugins/intel_gpu/src/graph/depth_to_space.cppindex f6cf275e2ef..633d7cbc063 100644--- a/src/plugins/intel_gpu/src/graph/depth_to_space.cpp+++ b/src/plugins/intel_gpu/src/graph/depth_to_space.cpp@@ -21,11 +21,12 @@ layout depth_to_space_inst::calc_output_layout(depth_to_space_node const& node,const size_t block_size = desc->block_size;- if (input_layout.feature() % (block_size * block_size) != 0)+ if (input_layout.feature() % (block_size * block_size) != 0) {CLDNN_ERROR_MESSAGE(desc->id,"The depth of the input tensor must be divisible by squared block size. Actual block size is " +std::to_string(block_size));+ }auto out_size = input_layout.get_tensor();if (format::spatial_num(input_layout.format) == 3) {diff --git a/src/plugins/intel_gpu/src/graph/detection_output.cpp b/src/plugins/intel_gpu/src/graph/detection_output.cppindex 77ebac52de2..f0612946981 100644--- a/src/plugins/intel_gpu/src/graph/detection_output.cpp+++ b/src/plugins/intel_gpu/src/graph/detection_output.cpp@@ -150,8 +150,9 @@ detection_output_inst::typed_primitive_inst(network& network, detection_output_nauto location_layout = node.location().get_output_layout();auto confidence_layout = node.confidence().get_output_layout();auto prior_box_layout = node.prior_box().get_output_layout();- if (location_layout.is_dynamic() || confidence_layout.is_dynamic() || prior_box_layout.is_dynamic())+ if (location_layout.is_dynamic() || confidence_layout.is_dynamic() || prior_box_layout.is_dynamic()) {return;+ }CLDNN_ERROR_NOT_PROPER_FORMAT(node.id(),"Location memory format",diff --git a/src/plugins/intel_gpu/src/graph/dft.cpp b/src/plugins/intel_gpu/src/graph/dft.cppindex f039e704ec4..c597ef8a937 100644--- a/src/plugins/intel_gpu/src/graph/dft.cpp+++ b/src/plugins/intel_gpu/src/graph/dft.cpp@@ -61,8 +61,9 @@ std::vector<layout> dft_inst::calc_output_layouts(dft_node const& /*node*/, kerninput1_layout.get<ShapeType>()};- if (impl_param.input_layouts.size() == 3)+ if (impl_param.input_layouts.size() == 3) {input_shapes.push_back(impl_param.get_input_layout(2).get<ShapeType>());+ }std::vector<ShapeType> output_shapes = {ShapeType()};std::unordered_map<size_t, ov::Tensor> const_data;diff --git a/src/plugins/intel_gpu/src/graph/dynamic_quantize.cpp b/src/plugins/intel_gpu/src/graph/dynamic_quantize.cppindex 4fd8a86c38d..3f9d4fee80f 100644--- a/src/plugins/intel_gpu/src/graph/dynamic_quantize.cpp+++ b/src/plugins/intel_gpu/src/graph/dynamic_quantize.cpp@@ -3,12 +3,13 @@//#include "ov_ops/dynamic_quantize.hpp"++#include <string>+#include "dynamic_quantize_inst.h"#include "fully_connected_inst.h"--#include "primitive_type_base.h"#include "json_object.h"-#include <string>+#include "primitive_type_base.h"namespace cldnn {GPU_DEFINE_PRIMITIVE_TYPE_ID(dynamic_quantize);@@ -17,17 +18,18 @@ GPU_DEFINE_PRIMITIVE_TYPE_ID(dynamic_quantize);// can_be_optimized flag will be turned on from primitive_inst::update_shape functionstatic bool should_skip_execution(const dynamic_quantize_node& node, const layout& act_layout, const dynamic_quantize::Attributes& attrs) {if (cldnn::data_type_traits::is_floating_point(attrs.quantization_dt)) {- return false; // Execute unconditionally for floating point types.+ return false; // Execute unconditionally for floating point types.}- if (!node.is_runtime_skippable()- || !act_layout.is_static())+ if (!node.is_runtime_skippable() || !act_layout.is_static()) {return false;+ }// Do not skip dynamic quantization if any user node is not fully connected.(such as SDPA)for (const auto& user : node.get_users()) {- if (!user->is_type<fully_connected>())+ if (!user->is_type<fully_connected>()) {return false;+ }}// If batch size is 1, dynamic_quantize is disabled for performance reason@@ -46,7 +48,7 @@ static bool should_skip_execution(const dynamic_quantize_node& node, const layoureturn false;}-layout dynamic_quantize_inst::calc_output_layout(dynamic_quantize_node const& /*node*/, kernel_impl_params const& impl_param) {+layout dynamic_quantize_inst::calc_output_layout(const dynamic_quantize_node& /*node*/, const kernel_impl_params& impl_param) {auto desc = impl_param.typed_desc<dynamic_quantize>();const auto& input_layout = impl_param.get_input_layout();auto output_type = desc->attrs.quantization_dt;@@ -55,9 +57,9 @@ layout dynamic_quantize_inst::calc_output_layout(dynamic_quantize_node const& /*return layout(output_type, output_format, input_layout.get_tensor());}-template<typename ShapeType>-std::vector<layout> dynamic_quantize_inst::__calc_output_layouts(const dynamic_quantize_node &node,- const layout &act_layout,+template <typename ShapeType>+std::vector<layout> dynamic_quantize_inst::__calc_output_layouts(const dynamic_quantize_node& node,+ const layout& act_layout,const dynamic_quantize::Attributes& attrs) {ov::op::internal::DynamicQuantize op;op.set_attrs(attrs);@@ -70,8 +72,8 @@ std::vector<layout> dynamic_quantize_inst::__calc_output_layouts(const dynamic_qauto output_shapes = ov::op::internal::DynamicQuantize::shape_infer(&op, input_shapes);- std::vector<layout> output_layouts = { layout(output_shapes[0], attrs.quantization_dt, output_format),- layout(output_shapes[1], attrs.scale_dt, output_format) };+ std::vector<layout> output_layouts = {layout(output_shapes[0], attrs.quantization_dt, output_format),+ layout(output_shapes[1], attrs.scale_dt, output_format)};auto flag_skip_execution = should_skip_execution(node, act_layout, attrs);@@ -83,7 +85,8 @@ std::vector<layout> dynamic_quantize_inst::__calc_output_layouts(const dynamic_q}if (attrs.precomputed_reduction) {OPENVINO_ASSERT(output_layouts.size() == 2,- "Dynamic quantization is supposed to have 2 outputs in front of precomputed reduction, but got: ", output_layouts.size());+ "Dynamic quantization is supposed to have 2 outputs in front of precomputed reduction, but got: ",+ output_layouts.size());output_layouts.emplace_back(layout(output_shapes[2], attrs.precomputed_reduction_dt, output_format));}@@ -101,22 +104,22 @@ std::vector<layout> dynamic_quantize_inst::__calc_output_layouts(const dynamic_qreturn output_layouts;}-template std::vector<layout> dynamic_quantize_inst::__calc_output_layouts<ov::PartialShape>(const dynamic_quantize_node &node,- const layout &act_layout,+template std::vector<layout> dynamic_quantize_inst::__calc_output_layouts<ov::PartialShape>(const dynamic_quantize_node& node,+ const layout& act_layout,const dynamic_quantize::Attributes& config);-template<typename ShapeType>-std::vector<layout> dynamic_quantize_inst::calc_output_layouts(dynamic_quantize_node const& node, const kernel_impl_params& impl_param) {+template <typename ShapeType>+std::vector<layout> dynamic_quantize_inst::calc_output_layouts(const dynamic_quantize_node& node, const kernel_impl_params& impl_param) {auto desc = impl_param.typed_desc<dynamic_quantize>();const auto& input_layout = impl_param.get_input_layout();return __calc_output_layouts<ov::PartialShape>(node, input_layout, desc->attrs);}-template std::vector<layout> dynamic_quantize_inst::calc_output_layouts<ov::PartialShape>(const dynamic_quantize_node &node,+template std::vector<layout> dynamic_quantize_inst::calc_output_layouts<ov::PartialShape>(const dynamic_quantize_node& node,const kernel_impl_params& impl_param);-std::string dynamic_quantize_inst::to_string(dynamic_quantize_node const& node) {+std::string dynamic_quantize_inst::to_string(const dynamic_quantize_node& node) {auto desc = node.get_primitive();auto node_info = node.desc_to_json();@@ -137,33 +140,35 @@ std::string dynamic_quantize_inst::to_string(dynamic_quantize_node const& node)return primitive_description.str();}-dynamic_quantize_inst::typed_primitive_inst(network& network, dynamic_quantize_node const& node) : parent(network, node) {}+dynamic_quantize_inst::typed_primitive_inst(network& network, const dynamic_quantize_node& node) : parent(network, node) {}void dynamic_quantize_inst::on_execute() {update_output_memory();}void dynamic_quantize_inst::update_output_memory() {- if (!can_be_optimized())+ if (!can_be_optimized()) {return;+ }- if (_node != nullptr)+ if (_node != nullptr) {build_deps();+ }- if (input_memory_ptr() == nullptr)+ if (input_memory_ptr() == nullptr) {return;+ }- if (static_cast<bool>(_outputs[0])- && _network.get_engine().is_the_same_buffer(output_memory(), input_memory())- && output_memory().get_layout().identical(get_output_layout()))+ if (static_cast<bool>(_outputs[0]) && _network.get_engine().is_the_same_buffer(output_memory(), input_memory()) &&+ output_memory().get_layout().identical(get_output_layout())) {return;+ }OPENVINO_ASSERT(input_memory_ptr() != nullptr, "[GPU] Failed to reuse input in ", id(), " primitive: input memory was not allocated");// Can_be_optimized nodes are allocating from memory_pool too. In this case,// we need release the legacy output memory from memory pool explicitly.- if (static_cast<bool>(_outputs[0]) &&- get_node().get_program().get_config().get_enable_memory_pool()) {+ if (static_cast<bool>(_outputs[0]) && get_node().get_program().get_config().get_enable_memory_pool()) {_network.get_memory_pool().release_memory(_outputs[0].get(), get_node().get_unique_id(), get_node().id(), _network.get_id());}diff --git a/src/plugins/intel_gpu/src/graph/eltwise.cpp b/src/plugins/intel_gpu/src/graph/eltwise.cppindex 031b6dd184a..954464d44fe 100644--- a/src/plugins/intel_gpu/src/graph/eltwise.cpp+++ b/src/plugins/intel_gpu/src/graph/eltwise.cpp@@ -52,14 +52,16 @@ static cldnn::layout get_eltwise_output_layout(const layout& input_layout, kernecldnn::format out_format = input_layout.format;for (size_t i = 0; i < desc->input_size(); i++) {- if (impl_param.primary_input_idx == i)+ if (impl_param.primary_input_idx == i) {continue;+ }auto l = impl_param.get_non_padded_input_layout(i);- if (l.format == format::b_fs_zyx_fsv16) // use optimized 5D+ if (l.format == format::b_fs_zyx_fsv16) { // use optimized 5Dout_format = format::b_fs_zyx_fsv16;- else if (l.format == format::bs_fs_zyx_bsv16_fsv16)+ } else if (l.format == format::bs_fs_zyx_bsv16_fsv16) {out_format = format::bs_fs_zyx_bsv16_fsv16;+ }}return layout(output_shapes[0], out_data_type, out_format);@@ -83,15 +85,17 @@ layout eltwise_inst::calc_output_layout(eltwise_node const& node, kernel_impl_paauto size = input_node_layout.get_tensor();auto format = input_node_layout.format;for (size_t i = 0; i < desc->input_size(); i++) {- if (i == primary_input_idx)+ if (i == primary_input_idx) {continue;+ }auto l = impl_param.get_non_padded_input_layout(i);size = tensor::max(size, l.get_tensor());- if (l.format == format::b_fs_zyx_fsv16) // use optimized 5D+ if (l.format == format::b_fs_zyx_fsv16) { // use optimized 5Dformat = format::b_fs_zyx_fsv16;- else if (l.format == format::bs_fs_zyx_bsv16_fsv16)+ } else if (l.format == format::bs_fs_zyx_bsv16_fsv16) {format = format::bs_fs_zyx_bsv16_fsv16;+ }}auto output_layout = layout(output_type, format, size);@@ -127,8 +131,9 @@ layout eltwise_inst::calc_output_layout(eltwise_node const& node, kernel_impl_paeltwise_mode::bitwise_and,eltwise_mode::bitwise_or,eltwise_mode::bitwise_xor};- if (std::find(eltwise_int_modes.begin(), eltwise_int_modes.end(), mode) == eltwise_int_modes.end())+ if (std::find(eltwise_int_modes.begin(), eltwise_int_modes.end(), mode) == eltwise_int_modes.end()) {CLDNN_ERROR_MESSAGE(desc->id, "Requested eltwise mode is not supported for integer types.");+ }}// Logic and comparison operations should return i8 for any inputs@@ -214,8 +219,9 @@ std::vector<layout> eltwise_inst::calc_output_layouts(eltwise_node const& /*nodeauto in_shape = input_pshape.get_shape();for (size_t i = 0; i < desc->stride[0].spatial.size(); i++) {const int idx = static_cast<int>(in_shape.size() - 1 - i);- if (idx < 0)+ if (idx < 0) {break;+ }in_shape[idx] = (in_shape[idx] - 1) / desc->stride[0].spatial[i] + 1;}input_layout.set_partial_shape({in_shape});@@ -234,8 +240,9 @@ static inline std::string stringify_vector(const std::vector<float>& v) {for (size_t i = 0; i < v.size(); ++i) {s << v.at(i);- if (i + 1 < v.size())+ if (i + 1 < v.size()) {s << ", ";+ }}s << " }";@@ -360,8 +367,9 @@ eltwise_inst::typed_primitive_inst(network& network, eltwise_node const& node) :auto prim = node.get_primitive();auto inputs_count = node.get_inputs_count();- if (is_dynamic())+ if (is_dynamic()) {return;+ }if (!prim->stride.empty()) {// number of strides must match number of inputs@@ -380,22 +388,24 @@ eltwise_inst::typed_primitive_inst(network& network, eltwise_node const& node) :auto stride = prim->stride[i];const auto in_x_div_stride_x = (in_layout.spatial(0) - 1) / stride.spatial[0] + 1;- if (in_x_div_stride_x != out_x && in_x_div_stride_x != 1)+ if (in_x_div_stride_x != out_x && in_x_div_stride_x != 1) {CLDNN_ERROR_NOT_EQUAL(node.id(),"Eltwise input_x / stride_x",in_x_div_stride_x,"Eltwise output_x",out_x,"");+ }const auto in_y_div_stride_y = (in_layout.spatial(1) - 1) / stride.spatial[1] + 1;- if (in_y_div_stride_y != out_y && in_y_div_stride_y != 1)+ if (in_y_div_stride_y != out_y && in_y_div_stride_y != 1) {CLDNN_ERROR_NOT_EQUAL(node.id(),"Eltwise inputyx / stride_y",in_y_div_stride_y,"Eltwise output_y",out_y,"");+ }}} else if (inputs_count > 1) {ov::op::v1::Add op;@@ -471,12 +481,15 @@ void eltwise_inst::check_inputs_count(eltwise_node const& node) {bool eltwise_node::need_align_for_numpy_broadcast(const layout& input) const {if (is_valid_output_layout() &&- (format::is_default_format(get_output_layout().format) || input.format == get_output_layout().format))+ (format::is_default_format(get_output_layout().format) || input.format == get_output_layout().format)) {return false;- if (get_input_layouts().size() < 2)+ }+ if (get_input_layouts().size() < 2) {return false;- if (get_primitive()->broadcast_spec != ov::op::AutoBroadcastType::NUMPY)+ }+ if (get_primitive()->broadcast_spec != ov::op::AutoBroadcastType::NUMPY) {return false;+ }auto pshape_a_rank = get_input_pshape(0).size();auto pshape_b_rank = get_input_pshape(1).size();diff --git a/src/plugins/intel_gpu/src/graph/eye.cpp b/src/plugins/intel_gpu/src/graph/eye.cppindex 93ef060f43d..3571bdb2e3f 100644--- a/src/plugins/intel_gpu/src/graph/eye.cpp+++ b/src/plugins/intel_gpu/src/graph/eye.cpp@@ -24,8 +24,9 @@ std::vector<layout> eye_inst::calc_output_layouts(eye_node const& /*node*/, consconst auto& memory_deps = impl_param.memory_deps;for (size_t i = 0; i < 4; i++) {- if (memory_deps.count(i) > 0)+ if (memory_deps.count(i) > 0) {const_data.emplace(i, memory_deps.at(i));+ }}auto ta = cldnn::make_tensor_accessor(const_data);@@ -53,8 +54,9 @@ std::string eye_inst::to_string(eye_node const& node) {eye_info.add("rows id", node.get_dependency(0).id());eye_info.add("cols id", node.get_dependency(1).id());eye_info.add("diagInd id", node.get_dependency(2).id());- if (node.get_dependencies().size() == 4)+ if (node.get_dependencies().size() == 4) {eye_info.add("batchShape id", node.get_dependency(3).id());+ }node_info->add("slice info", eye_info);std::stringstream primitive_description;node_info->dump(primitive_description);diff --git a/src/plugins/intel_gpu/src/graph/fully_connected.cpp b/src/plugins/intel_gpu/src/graph/fully_connected.cppindex 21d843e52fd..89d4aa9b4ce 100644--- a/src/plugins/intel_gpu/src/graph/fully_connected.cpp+++ b/src/plugins/intel_gpu/src/graph/fully_connected.cpp@@ -47,14 +47,16 @@ format::type get_preferred_format(fully_connected_node const& node, const kernelauto input_layout = impl_param.get_input_layout();// for 3d output we have to chose bfyx format- if (impl_param.typed_desc<fully_connected>()->input_size == 3)+ if (impl_param.typed_desc<fully_connected>()->input_size == 3) {return format::bfyx;+ }if (data_type_traits::is_floating_point(input_layout.data_type) &&(is_batch_after_spatial(input_layout.format.order()) ||input_layout.format == format::bs_f_bsv16 ||- input_layout.format == format::bs_fs_fsv8_bsv8))+ input_layout.format == format::bs_fs_fsv8_bsv8)) {return format::yxfb;+ }bool no_spatial_padding = true;// C++ 11 range loop shouldn't be used here because of incorrect iterator functionality in mutable_array_ref<>@@ -68,16 +70,18 @@ format::type get_preferred_format(fully_connected_node const& node, const kernelif (input_layout.data_type == data_types::f32 &&one_of<cldnn::format>(input_layout.format, {format::bfyx, format::bfzyx, format::bfwzyx}) &&no_spatial_padding &&- input_layout.batch() != 8)+ input_layout.batch() != 8) {return input_layout.format;+ }auto input_pitches = input_layout.get_pitches();if (input_layout.data_type == data_types::f16 &&(input_layout.format == format::bfyx || input_layout.format == format::bfzyx || input_layout.format == format::bfwzyx) &&no_spatial_padding &&input_pitches[0] % 2 == 0 &&- input_layout.batch() != 16)+ input_layout.batch() != 16) {return input_layout.format;+ }// this condition tests whether our input is batch>1 in bfyx format, if yes there will be// extra reorder between input and this fc from bfyx to yxfb format (so@@ -86,8 +90,9 @@ format::type get_preferred_format(fully_connected_node const& node, const kernelinput_layout.format == format::bfyx &&input_layout.batch() > 1 &&input_pitches[2] == 1 &&- input_pitches[3] == 1)+ input_pitches[3] == 1) {return format::yxfb;+ }return format::bfyx;}@@ -102,8 +107,9 @@ layout fully_connected_inst::calc_output_layout(fully_connected_node const& nodeauto weights_layout = *impl_param.weights_layout;auto weights_pshape = weights_layout.get_partial_shape();auto output_type = desc->output_data_types[0].value_or(input_layout.data_type);- if (data_type_traits::is_i8_u8(input_layout.data_type) && desc->output_data_types[0])+ if (data_type_traits::is_i8_u8(input_layout.data_type) && desc->output_data_types[0]) {output_type = *desc->output_data_types[0];+ }if (impl_param.has_fused_primitives()) {output_type = impl_param.get_output_element_type();@@ -115,10 +121,11 @@ layout fully_connected_inst::calc_output_layout(fully_connected_node const& nodeauto staticShape = shape.to_shape();size_t total = std::accumulate(staticShape.begin(), staticShape.end(), static_cast<size_t>(1), std::multiplies<size_t>());std::vector<int64_t> reshapeSize;- if (desc->weights_transposed)+ if (desc->weights_transposed) {reshapeSize = { static_cast<int64_t>(total) / feature, feature };- else+ } else {reshapeSize = { feature, static_cast<int64_t>(total) / feature };+ }return reshapeSize;};@@ -192,8 +199,9 @@ std::vector<layout> fully_connected_inst::calc_output_layouts(fully_connected_noauto weights_layout = *impl_param.weights_layout;auto output_type = desc->output_data_types[0].value_or(input_layout.data_type);- if (data_type_traits::is_i8_u8(input_layout.data_type) && desc->output_data_types[0])+ if (data_type_traits::is_i8_u8(input_layout.data_type) && desc->output_data_types[0]) {output_type = *desc->output_data_types[0];+ }if (impl_param.has_fused_primitives()) {output_type = impl_param.get_output_element_type();@@ -231,8 +239,9 @@ std::vector<layout> fully_connected_inst::calc_output_layouts(fully_connected_noformat::type output_format = is_static && !allow_new_shape_infer ? get_preferred_format(node, impl_param) :input_layout.format.value;- if (node.get_preferred_output_fmt() != format::any)+ if (node.get_preferred_output_fmt() != format::any) {output_format = node.get_preferred_output_fmt();+ }return { layout{output_shapes[0], output_type, output_format} };}@@ -254,13 +263,15 @@ kernel_impl_params fully_connected_inst::get_fake_aligned_params(kernel_impl_par// Allow padding only for feature and outermost dimmensionauto can_apply_fake_alignment = true;- if (input_shape.size() == 3)+ if (input_shape.size() == 3) {can_apply_fake_alignment &= orig_input_layout.data_padding._lower_size[1] == 0 &&orig_input_layout.data_padding._upper_size[1] == 0;+ }- if (output_shape.size() == 3)+ if (output_shape.size() == 3) {can_apply_fake_alignment &= orig_output_layout.data_padding._lower_size[1] == 0 &&orig_output_layout.data_padding._upper_size[1] == 0;+ }for (const auto& fused_desc : orig_impl_param.fused_desc) {if (fused_desc.has_outer_dep()) {@@ -383,8 +394,9 @@ std::string fully_connected_inst::to_string(fully_connected_node const& node) {}bool fully_connected_inst::can_apply_single_batch_optimization(const kernel_impl_params& impl_param) {- if (impl_param.output_layouts.empty() || impl_param.output_layouts[0].is_dynamic())+ if (impl_param.output_layouts.empty() || impl_param.output_layouts[0].is_dynamic()) {return false;+ }// Only support i4/u4 weight so farif (impl_param.weights_layout) {@@ -397,8 +409,9 @@ bool fully_connected_inst::can_apply_single_batch_optimization(const kernel_impl// Don't support swiglu fusedif (!impl_param.fused_desc.empty()) {for (const auto& f : impl_param.fused_desc) {- if (f.is_type<swiglu>())+ if (f.is_type<swiglu>()) {return false;+ }}}diff --git a/src/plugins/intel_gpu/src/graph/gather.cpp b/src/plugins/intel_gpu/src/graph/gather.cppindex 04582cab7ac..2deee82bdea 100644--- a/src/plugins/intel_gpu/src/graph/gather.cpp+++ b/src/plugins/intel_gpu/src/graph/gather.cpp@@ -23,8 +23,9 @@ layout gather_inst::calc_output_layout(gather_node const& node, kernel_impl_paradims_converted.push_back(static_cast<tensor::value_type>(dim));}// extend shape to 4d- for (size_t i = dims_converted.size(); i < 4; i++)+ for (size_t i = dims_converted.size(); i < 4; i++) {dims_converted.push_back(1);+ }format output_format = input_layout.format;if (dims_converted.size() == 5) {@@ -139,16 +140,19 @@ void gather_inst::on_execute() {}void gather_inst::update_output_memory() {- if (!can_be_optimized())+ if (!can_be_optimized()) {return;+ }build_deps();- if (input_memory_ptr() == nullptr)+ if (input_memory_ptr() == nullptr) {return;+ }- if (static_cast<bool>(_outputs[0]) && _network.get_engine().is_the_same_buffer(output_memory(), input_memory()))+ if (static_cast<bool>(_outputs[0]) && _network.get_engine().is_the_same_buffer(output_memory(), input_memory())) {return;+ }GPU_DEBUG_TRACE_DETAIL << id() << " : update_output_memory with mem of input " << get_node().get_dependency(0).id()<< " : " << input_memory_ptr()->buffer_ptr() << std::endl;diff --git a/src/plugins/intel_gpu/src/graph/gather_matmul.cpp b/src/plugins/intel_gpu/src/graph/gather_matmul.cppindex c3d9aef915a..f5601258a50 100644--- a/src/plugins/intel_gpu/src/graph/gather_matmul.cpp+++ b/src/plugins/intel_gpu/src/graph/gather_matmul.cpp@@ -40,10 +40,11 @@ std::vector<layout> gather_matmul_inst::calc_output_layouts(const gather_matmul_// SwiGLU fusion halves output features (weights pack gate + value).for (const auto& fd : impl_param.fused_desc) {if (fd.is_type<swiglu>()) {- if (out_features.is_static())+ if (out_features.is_static()) {out_features = out_features.get_length() / 2;- else+ } else {out_features = ov::Dimension::dynamic();+ }break;}}@@ -65,8 +66,9 @@ std::string gather_matmul_inst::to_string(const gather_matmul_node& node) {bgm_info.add("has_bias", desc->has_bias);bgm_info.add("has_zp", desc->has_zp);bgm_info.add("n_activated_experts", desc->n_activated_experts);- if (desc->output_data_types[0].has_value())+ if (desc->output_data_types[0].has_value()) {bgm_info.add("out dt: ", dt_to_str(*desc->output_data_types[0]));+ }node_info->add("gather_matmul_info", bgm_info);node_info->dump(primitive_description);diff --git a/src/plugins/intel_gpu/src/graph/gemm.cpp b/src/plugins/intel_gpu/src/graph/gemm.cppindex f1f19a7a82e..7d8560dadb4 100644--- a/src/plugins/intel_gpu/src/graph/gemm.cpp+++ b/src/plugins/intel_gpu/src/graph/gemm.cpp@@ -1,19 +1,20 @@// Copyright (C) 2018-2026 Intel Corporation// SPDX-License-Identifier: Apache-2.0//-#include "gemm_inst.h"-#include "primitive_type_base.h"-#include "json_object.h"+#include "intel_gpu/op/gemm.hpp"++#include <algorithm>#include <string>#include <utility>-#include <algorithm>-#include "intel_gpu/op/gemm.hpp"+#include "gemm_inst.h"+#include "json_object.h"+#include "primitive_type_base.h"namespace cldnn {GPU_DEFINE_PRIMITIVE_TYPE_ID(gemm)-layout gemm_inst::calc_output_layout(gemm_node const& node, kernel_impl_params const& impl_param) {+layout gemm_inst::calc_output_layout(const gemm_node& node, const kernel_impl_params& impl_param) {auto prim = impl_param.typed_desc<gemm>();auto input0_layout = impl_param.get_input_layout(0);@@ -41,8 +42,7 @@ layout gemm_inst::calc_output_layout(gemm_node const& node, kernel_impl_params cinput_shape_update = _input_shape_update;}if (input_shape_update.size() == 1) {- first_input ? input_shape_update.insert(input_shape_update.begin(), 1)- : input_shape_update.insert(input_shape_update.end(), 1);+ first_input ? input_shape_update.insert(input_shape_update.begin(), 1) : input_shape_update.insert(input_shape_update.end(), 1);output_rank = std::max(output_rank, rank + 1);}input_shape_update.insert(input_shape_update.begin(), output_rank - input_shape_update.size(), 1);@@ -83,12 +83,14 @@ layout gemm_inst::calc_output_layout(gemm_node const& node, kernel_impl_params csize_t ones_to_add = 4 - std::min(output_shape.size(), static_cast<size_t>(4));output_shape.insert(output_shape.begin(), ones_to_add, 1);- if (!prim->output_transpose_order.empty())+ if (!prim->output_transpose_order.empty()) {output_shape = transpose_shape(output_shape, prim->output_transpose_order);+ }auto output_type = input0_layout.data_type;- if ((output_type == data_types::u8 || output_type == data_types::i8) && prim->output_data_types[0])+ if ((output_type == data_types::u8 || output_type == data_types::i8) && prim->output_data_types[0]) {output_type = *prim->output_data_types[0];+ }if (impl_param.has_fused_primitives()) {output_type = impl_param.get_output_element_type();@@ -107,8 +109,8 @@ layout gemm_inst::calc_output_layout(gemm_node const& node, kernel_impl_params creturn layout(output_shape, output_type, output_format, prim->output_paddings[0]);}-template<typename ShapeType>-std::vector<layout> gemm_inst::calc_output_layouts(gemm_node const& node, const kernel_impl_params& impl_param) {+template <typename ShapeType>+std::vector<layout> gemm_inst::calc_output_layouts(const gemm_node& node, const kernel_impl_params& impl_param) {auto prim = impl_param.typed_desc<gemm>();auto input0_layout = impl_param.get_input_layout(0);auto input1_layout = impl_param.get_input_layout(1);@@ -124,16 +126,10 @@ std::vector<layout> gemm_inst::calc_output_layouts(gemm_node const& node, constop.set_transpose_a(false);op.set_transpose_b(false);- std::vector<ShapeType> input_shapes = {- input0_layout.get<ShapeType>(),- input1_layout.get<ShapeType>()- };+ std::vector<ShapeType> input_shapes = {input0_layout.get<ShapeType>(), input1_layout.get<ShapeType>()};- std::vector<ShapeType> output_shapes = ov::intel_gpu::op::shape_infer(&op,- input_shapes,- prim->input0_transpose_order,- prim->input1_transpose_order,- prim->output_transpose_order);+ std::vector<ShapeType> output_shapes =+ ov::intel_gpu::op::shape_infer(&op, input_shapes, prim->input0_transpose_order, prim->input1_transpose_order, prim->output_transpose_order);cldnn::format output_format = input0_layout.format;if (output_shapes[0].size() > output_format.dimension()) {@@ -142,13 +138,14 @@ std::vector<layout> gemm_inst::calc_output_layouts(gemm_node const& node, const// Therefore, adjust output_format to proper rank.(say, bfzyx)output_format = cldnn::format::adjust_to_rank(output_format, output_shapes[0].size());}- if (node.get_preferred_output_fmt() != format::any)+ if (node.get_preferred_output_fmt() != format::any) {output_format = node.get_preferred_output_fmt();+ }- return { layout{output_shapes[0], output_type, output_format, prim->output_paddings[0]} };+ return {layout{output_shapes[0], output_type, output_format, prim->output_paddings[0]}};}-template std::vector<layout> gemm_inst::calc_output_layouts<ov::PartialShape>(gemm_node const& node, const kernel_impl_params& impl_param);+template std::vector<layout> gemm_inst::calc_output_layouts<ov::PartialShape>(const gemm_node& node, const kernel_impl_params& impl_param);std::vector<layout> gemm_inst::transform_input_layouts(const std::shared_ptr<const gemm> primitive,const std::vector<layout>& input_layouts,@@ -188,14 +185,17 @@ std::vector<layout> gemm_inst::transform_input_layouts(const std::shared_ptr<conif (input_rank == 1) {if (input_pshape.is_static()) {auto input_shape = input_pshape.to_shape();- transposed_input_pshape = ov::PartialShape{ static_cast<int64_t>(*std::max_element(input_shape.begin(), input_shape.end())) };+ transposed_input_pshape = ov::PartialShape{static_cast<int64_t>(*std::max_element(input_shape.begin(), input_shape.end()))};} else {transposed_input_pshape = ov::PartialShape::dynamic(input_rank);}} else {if (input_pshape.is_static()) {- OPENVINO_ASSERT(input_pshape.size() >= input_rank, "[GPU] Requested input rank[",- input_rank, "] in gemm primitive is greater than actual shape: ", input_pshape.to_string());+ OPENVINO_ASSERT(input_pshape.size() >= input_rank,+ "[GPU] Requested input rank[",+ input_rank,+ "] in gemm primitive is greater than actual shape: ",+ input_pshape.to_string());std::vector<ov::Dimension> dims(input_pshape.begin(), input_pshape.begin() + input_rank);transposed_input_pshape = ov::PartialShape(dims);} else {@@ -204,8 +204,7 @@ std::vector<layout> gemm_inst::transform_input_layouts(const std::shared_ptr<con}if (transposed_input_pshape.size() == 1) {- first_input ? transposed_input_pshape.insert(transposed_input_pshape.begin(), 1)- : transposed_input_pshape.insert(transposed_input_pshape.end(), 1);+ first_input ? transposed_input_pshape.insert(transposed_input_pshape.begin(), 1) : transposed_input_pshape.insert(transposed_input_pshape.end(), 1);// Do not swap weight (2nd input) because TRANSPOSE_Y_LAST expects [Y=K, X=N];// swapping would make input1_offset1 = TILE_K * K instead of TILE_K * N.@@ -236,8 +235,9 @@ std::vector<layout> gemm_inst::transform_input_layouts(const std::shared_ptr<constd::vector<layout> layouts = input_layouts;// Format update for rank > 4 case- if (layouts[0].format.dimension() < transposed_input0_pshape.size())+ if (layouts[0].format.dimension() < transposed_input0_pshape.size()) {layouts[0].format = cldnn::format::get_default_format(transposed_input0_pshape.size());+ }layouts[0].set_partial_shape(transposed_input0_pshape);layouts[0].data_padding = get_transposed_padding(layouts[0].data_padding, input_rank, input_format_rank, primitive->transpose_input0 != 0u, true);layouts[1].set_partial_shape(transposed_input1_pshape);@@ -252,9 +252,7 @@ std::vector<layout> gemm_inst::transform_input_layouts(const std::shared_ptr<conreturn layouts;}-layout gemm_inst::transform_output_layout(const std::shared_ptr<const gemm> primitive,- const std::vector<layout>& input_layouts,- const layout& output_layout) {+layout gemm_inst::transform_output_layout(const std::shared_ptr<const gemm> primitive, const std::vector<layout>& input_layouts, const layout& output_layout) {auto transpose_pshape = [](const ov::PartialShape& pshape, const std::vector<int64_t>& transpose_order) {ov::PartialShape transposed_pshape = pshape;auto rank_diff = pshape.size() - transpose_order.size();@@ -271,8 +269,7 @@ layout gemm_inst::transform_output_layout(const std::shared_ptr<const gemm> primov::PartialShape transposed_input0_pshape = transpose_pshape(input_layouts[0].get_partial_shape(), primitive->input0_transpose_order);ov::PartialShape transposed_input1_pshape = transpose_pshape(input_layouts[1].get_partial_shape(), primitive->input1_transpose_order);- auto M = (transposed_input0_pshape.size() > 1) ? transposed_input0_pshape[transposed_input0_pshape.size() - 2]- : transposed_input0_pshape[0];+ auto M = (transposed_input0_pshape.size() > 1) ? transposed_input0_pshape[transposed_input0_pshape.size() - 2] : transposed_input0_pshape[0];auto N = transposed_input1_pshape[transposed_input1_pshape.size() - 1];auto output_pshape = transposed_input0_pshape;@@ -287,8 +284,9 @@ layout gemm_inst::transform_output_layout(const std::shared_ptr<const gemm> primoutput_pshape[j] = std::max(output_pshape[j].get_length(), input_pshape[j].get_length());} else {ov::Dimension broadcasted_dim;- if (ov::Dimension::broadcast_merge(broadcasted_dim, output_pshape[j], input_pshape[j]))+ if (ov::Dimension::broadcast_merge(broadcasted_dim, output_pshape[j], input_pshape[j])) {output_pshape[j] = std::move(broadcasted_dim);+ }}}}@@ -310,7 +308,7 @@ layout gemm_inst::transform_output_layout(const std::shared_ptr<const gemm> primreturn updated_output_layout;}-std::string gemm_inst::to_string(gemm_node const& node) {+std::string gemm_inst::to_string(const gemm_node& node) {auto desc = node.get_primitive();auto node_info = node.desc_to_json();auto alpha = desc->alpha;@@ -341,5 +339,5 @@ std::string gemm_inst::to_string(gemm_node const& node) {return primitive_description.str();}-gemm_inst::typed_primitive_inst(network& network, gemm_node const& node) : parent(network, node) {}+gemm_inst::typed_primitive_inst(network& network, const gemm_node& node) : parent(network, node) {}} // namespace cldnndiff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/add_required_reorders.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/add_required_reorders.cppindex 17202e175c9..7832644b677 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/add_required_reorders.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/add_required_reorders.cpp@@ -2,19 +2,18 @@// SPDX-License-Identifier: Apache-2.0//+#include <algorithm>+#include <memory>+#include <stdexcept>+#include <vector>-#include "pass_manager.h"-#include "program_node.h"+#include "assign_inst.h"#include "convert_color_inst.h"#include "fully_connected_inst.h"#include "gated_mlp_inst.h"-#include "assign_inst.h"#include "mvn_inst.h"--#include <algorithm>-#include <memory>-#include <vector>-#include <stdexcept>+#include "pass_manager.h"+#include "program_node.h"using namespace cldnn;@@ -25,8 +24,9 @@ void eliminate_pad_for_onednn_impl(program& p, program_node& node) {bool use_onednn = false;for (size_t idx = 0; idx < node.get_dependencies().size(); idx++) {const auto& input = node.get_dependency(idx);- if (!input.is_in_data_flow() || input.is_constant())+ if (!input.is_in_data_flow() || input.is_constant()) {continue;+ }if (input.get_output_layout().data_padding) {has_paddings = true;break;@@ -49,8 +49,9 @@ void eliminate_pad_for_onednn_impl(program& p, program_node& node) {auto node_and_port = node.get_dependency_with_port(idx);auto& input = *node_and_port.first;auto port = node_and_port.second;- if (!input.is_in_data_flow() || input.is_constant())+ if (!input.is_in_data_flow() || input.is_constant()) {continue;+ }const auto& in_layout = input.get_output_layout(false, port);const auto& in_padding = in_layout.data_padding;@@ -98,7 +99,7 @@ void eliminate_pad_for_onednn_impl(program& p, program_node& node) {return;}}-} // namespace+} // namespace/*This pass checks if data formats (layouts) of output/input in hidden layers match.@@ -113,12 +114,12 @@ void add_required_reorders::add_reorder(program& p, program_node* node, program_reorder_layout.format = usr->get_output_layout().format;reorder_layout.data_type = usr->get_output_layout().data_type;- if (keep_original_dt)+ if (keep_original_dt) {reorder_layout.data_type = node->get_output_layout().data_type;+ }// dep index in reorder id distinguishes multi-port edges; otherwise add_intermediate fails on the second pass.- auto it = std::find_if(usr->get_dependencies().begin(), usr->get_dependencies().end(),- [&](const std::pair<program_node*, int32_t>& dep) {+ auto it = std::find_if(usr->get_dependencies().begin(), usr->get_dependencies().end(), [&](const std::pair<program_node*, int32_t>& dep) {return node == dep.first;});if (it == usr->get_dependencies().end()) {@@ -129,8 +130,7 @@ void add_required_reorders::add_reorder(program& p, program_node* node, program_throw std::runtime_error("Internal Error: container index out of range exception.");}- auto new_reorder = std::make_shared<reorder>(- node->id() + "_reorder_" + usr->id() + "_p" + std::to_string(idx), node->id(), reorder_layout);+ auto new_reorder = std::make_shared<reorder>(node->id() + "_reorder_" + usr->id() + "_p" + std::to_string(idx), node->id(), reorder_layout);auto& new_reorder_node = p.get_or_create(new_reorder);new_reorder_node.set_output_layout(reorder_layout, false);@@ -151,8 +151,9 @@ bool add_required_reorders::test_format(cldnn::program_node& node, format requesauto current_format = dep->get_output_layout(false, dep_with_port.second).format;- if (dep->is_constant() || format::is_weights_format(current_format))+ if (dep->is_constant() || format::is_weights_format(current_format)) {continue;+ }if (dep->is_type<reorder>()) {const auto& port = dep_with_port.second;@@ -172,10 +173,12 @@ void add_required_reorders::run(program& p) {auto usr_itr = p.get_processing_order().begin();while (usr_itr != p.get_processing_order().end()) {const auto& usr = *usr_itr++;- if (usr->get_dependencies().empty())+ if (usr->get_dependencies().empty()) {continue; // only nodes with dependencies- if (usr->is_type<data>())+ }+ if (usr->is_type<data>()) {continue;+ }if (!usr->is_all_valid_output_layouts()) {usr->recalc_output_layouts(false);@@ -200,8 +203,9 @@ void add_required_reorders::run(program& p) {for (size_t i = 0; i < usr->get_dependencies().size(); i++) {auto& eltwise_node = usr->as<eltwise>();auto& dep = usr->get_dependency(i);- if (!dep.is_in_data_flow() || dep.is_constant())+ if (!dep.is_in_data_flow() || dep.is_constant()) {continue;+ }auto dep_layout = dep.get_output_layout();auto out_layout = usr->get_output_layout();bool required_reorder = (format::dimension(out_layout.format) != format::dimension(dep_layout.format)) ||@@ -229,15 +233,18 @@ void add_required_reorders::run(program& p) {// Some kernels use blocked aligned subgroup reads for a vector of elements from dependency tensor// In that case jitter checks that layout of input tensor from fused op is same as output layout or broadcast is possible// The code below is intended to insert additional reorder node for const eltwise dependency to ensure jitter can process such fusion- if (!fused_op.is_type<eltwise>() && (!fused_op.is_type<activation>() || fused_op.total_num_deps != 2))+ if (!fused_op.is_type<eltwise>() && (!fused_op.is_type<activation>() || fused_op.total_num_deps != 2)) {continue;+ }- if (!fused_op.has_outer_dep())+ if (!fused_op.has_outer_dep()) {continue;+ }auto dep_id = fused_op.outer_dep_start_idx;auto& dep = usr->get_dependency(dep_id);- if (!dep.is_type<data>())+ if (!dep.is_type<data>()) {continue;+ }auto dep_layout = dep.get_output_layout();@@ -270,13 +277,13 @@ void add_required_reorders::run(program& p) {new_reorder_node.recalc_output_layout(false);}}-}eliminate_pad_for_onednn_impl(p, *usr);- if (usr->type()->has_impl_for(*usr))+ if (usr->type()->has_impl_for(*usr)) {continue;+ }bool correct_layout_selected = false;bool weights_data = (usr->is_type<convolution>() || usr->is_type<deconvolution>() || usr->is_type<fully_connected>() || usr->is_type<gated_mlp>());@@ -290,9 +297,7 @@ void add_required_reorders::run(program& p) {ToDo: Here we should handle also the situation where primitive usr has data inputs in differentformats*/- layout current_layout(original_layout.get_partial_shape(),- original_layout.data_type,- node.first->get_output_layout().format);+ layout current_layout(original_layout.get_partial_shape(), original_layout.data_type, node.first->get_output_layout().format);usr->set_output_layout(current_layout, false);if (usr->type()->has_impl_for(*usr)) {correct_layout_selected = true;@@ -306,12 +311,13 @@ void add_required_reorders::run(program& p) {std::vector<cldnn::format> preferred_layout_formats;size_t max_in_dims = std::max(cldnn::format::dimension(original_layout.format), static_cast<size_t>(4));for (const auto& node : usr->get_dependencies()) {- if (format::is_weights_format(node.first->get_output_layout().format))+ if (format::is_weights_format(node.first->get_output_layout().format)) {continue;+ }max_in_dims = std::max(cldnn::format::dimension(node.first->get_output_layout().format), max_in_dims);}// This list of preferred layouts has been selected arbitrarily due to developers' experience- preferred_layout_formats = { cldnn::format::get_default_format(max_in_dims) };+ preferred_layout_formats = {cldnn::format::get_default_format(max_in_dims)};if (max_in_dims == 8) {preferred_layout_formats.push_back(cldnn::format::bfvuwzyx);} else if (max_in_dims == 7) {@@ -340,8 +346,17 @@ void add_required_reorders::run(program& p) {}OPENVINO_ASSERT(correct_layout_selected,- "[GPU] No layout format available for ", usr->id(), ", impl_type: ", usr->get_preferred_impl_type(),- " (format: ", original_layout.format.to_string(),- ", data_type: ", ov::element::Type(original_layout.data_type), ") ", original_layout.to_string(), ", ", correct_layout_selected);+ "[GPU] No layout format available for ",+ usr->id(),+ ", impl_type: ",+ usr->get_preferred_impl_type(),+ " (format: ",+ original_layout.format.to_string(),+ ", data_type: ",+ ov::element::Type(original_layout.data_type),+ ") ",+ original_layout.to_string(),+ ", ",+ correct_layout_selected);}}diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/basic_memory_dependencies.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/basic_memory_dependencies.cppindex c1bbc8077e3..1325634fe48 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/basic_memory_dependencies.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/basic_memory_dependencies.cpp@@ -21,8 +21,9 @@ void basic_memory_dependencies::run(program& p) {itr++;// data primitive can't be reused- if (node->is_type<data>())+ if (node->is_type<data>()) {continue;+ }// add my dependencies to restriction list (can't share input.output buffers)for (const auto& it : node->get_dependencies()) {@@ -45,10 +46,12 @@ void basic_memory_dependencies::run(program& p) {if (fused_op.is_type<eltwise>() && fused_op.deps.size() == 1) {// If it is first sum, reuse the bufferauto fusing_type = onednn_add_fusing_helpers::get_add_fusing_type(*node, fused_op);- if (fusing_type != add_fusing_type::sum || eltw_dep != 0)+ if (fusing_type != add_fusing_type::sum || eltw_dep != 0) {continue;- if (!fused_op.has_outer_dep())+ }+ if (!fused_op.has_outer_dep()) {continue;+ }eltw_dep = fused_op.outer_dep_start_idx;auto& eltw_node = node->get_dependency(eltw_dep);node->can_share_buffer(false);diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/concat_input_order.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/concat_input_order.cppindex bbebdbd1f87..f4ea8070930 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/concat_input_order.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/concat_input_order.cpp@@ -2,16 +2,16 @@// SPDX-License-Identifier: Apache-2.0//-#include "pass_manager.h"-#include "pooling_inst.h"+#include <tuple>+#include <vector>+#include "convolution_inst.h"-#include "fully_connected_inst.h"#include "data_inst.h"-#include "intel_gpu/runtime/memory.hpp"+#include "fully_connected_inst.h"#include "intel_gpu/graph/program.hpp"--#include <vector>-#include <tuple>+#include "intel_gpu/runtime/memory.hpp"+#include "pass_manager.h"+#include "pooling_inst.h"using namespace cldnn;@@ -23,19 +23,20 @@ bool can_shuffle_features(program_node& node, program_node& concat_node, stream&if (node.is_type<convolution>()) {auto& conv_node = node.as<convolution>();auto& wei_node = conv_node.weights();- if (ov::element::Type(wei_node.get_output_layout().data_type).bitwidth() < 8)+ if (ov::element::Type(wei_node.get_output_layout().data_type).bitwidth() < 8) {return false;+ }- return conv_node.get_groups() == 1 && node.get_dependency_index(concat_node) == 0 &&- conv_node.get_deformable_groups() == 1 && !conv_node.get_transposed() &&- !conv_node.activations_zero_points_term() &&- wei_node.is_type<data>() && wei_node.is_constant() && !wei_node.is_output();+ return conv_node.get_groups() == 1 && node.get_dependency_index(concat_node) == 0 && conv_node.get_deformable_groups() == 1 &&+ !conv_node.get_transposed() && !conv_node.activations_zero_points_term() && wei_node.is_type<data>() && wei_node.is_constant() &&+ !wei_node.is_output();}if (node.is_type<fully_connected>()) {auto& fc_node = node.as<fully_connected>();auto& wei_node = fc_node.weights();- if (ov::element::Type(wei_node.get_output_layout().data_type).bitwidth() < 8)+ if (ov::element::Type(wei_node.get_output_layout().data_type).bitwidth() < 8) {return false;+ }return node.get_dependency_index(concat_node) == 0 && wei_node.is_type<data>() && wei_node.is_constant() && !wei_node.is_output();}@@ -48,8 +49,9 @@ bool can_shuffle_features(program_node& node, program_node& concat_node, stream&if (pass_through) {// Primitives that are feature order invariant, pass-through shuffled features to usersfor (const auto& user : node.get_users()) {- if (!can_shuffle_features(*user, node, stream))+ if (!can_shuffle_features(*user, node, stream)) {return false;+ }}return true;}@@ -125,8 +127,9 @@ void concat_input_order::run(program& p) {// 4. Not already aligned// 5. Users can accept shuffled features// 6. No fused primitives- if (!node->is_type<concatenation>() || node->is_output() || node->is_dynamic())+ if (!node->is_type<concatenation>() || node->is_output() || node->is_dynamic()) {continue;+ }auto& concat_node = node->as<concatenation>();auto prim = concat_node.get_primitive();@@ -138,10 +141,11 @@ void concat_input_order::run(program& p) {auto out_format = concat_node.get_output_layout().format;bool correct_format = (out_format == format::b_fs_yx_fsv16) || (out_format == format::b_fs_yx_fsv32);tensor::value_type alignment = 1;- if (out_format == format::b_fs_yx_fsv16)+ if (out_format == format::b_fs_yx_fsv16) {alignment = 16;- else if (out_format == format::b_fs_yx_fsv32)+ } else if (out_format == format::b_fs_yx_fsv32) {alignment = 32;+ }bool single_format = true;std::vector<tensor::value_type> feature_sizes;@@ -166,20 +170,23 @@ void concat_input_order::run(program& p) {can_shuffle_users &= can_shuffle_features(*user, concat_node, p.get_stream());}- if (!along_f || !no_fusing || !correct_format || !single_format || already_aligned || !can_shuffle_users)+ if (!along_f || !no_fusing || !correct_format || !single_format || already_aligned || !can_shuffle_users) {continue;+ }// Perform the optimization// Calculate new input order - first inputs preserving alignment, then reststd::vector<size_t> new_order;new_order.reserve(inputs_count);for (size_t i = 0; i < feature_sizes.size(); ++i) {- if (feature_sizes[i] % alignment == 0)+ if (feature_sizes[i] % alignment == 0) {new_order.push_back(i);+ }}for (size_t i = 0; i < feature_sizes.size(); ++i) {- if (feature_sizes[i] % alignment != 0)+ if (feature_sizes[i] % alignment != 0) {new_order.push_back(i);+ }}// Calculate new rangestensor::value_type current_offset = 0;diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/fuse_primitives_with_layout.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/fuse_primitives_with_layout.cppindex 8ead07c43db..4e7c6301552 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/fuse_primitives_with_layout.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/fuse_primitives_with_layout.cpp@@ -28,26 +28,30 @@ void fuse_primitives_with_layout::run(program& p) {auto node_itr = itr++;const auto& node = (*node_itr);- if (node->is_output() || node->is_constant())+ if (node->is_output() || node->is_constant()) {continue;+ }// No optimized Eltwise kernel supports fused-operation for fs_b_yx_fsv32// Check fusing quantize to eltwise for this caseauto func_fuse_quantize = [&](quantize_node& node) {bool should_fuse = false;auto out_layout = node.get_output_layout();- if (out_layout.is_dynamic() || node.is_in_shape_of_subgraph())+ if (out_layout.is_dynamic() || node.is_in_shape_of_subgraph()) {return;+ }auto& input_node = node.get_dependency(0);auto in_layout = input_node.get_output_layout();if (input_node.get_users().size() != 1 || input_node.get_dependencies().empty() ||- in_layout.is_dynamic() || input_node.is_in_shape_of_subgraph() || in_layout.format != out_layout.format)+ in_layout.is_dynamic() || input_node.is_in_shape_of_subgraph() || in_layout.format != out_layout.format) {return;+ }should_fuse |= input_node.is_type<eltwise>() && eltwise_supports_fusings(input_node.as<eltwise>());- if (!should_fuse)+ if (!should_fuse) {return;+ }p.fuse_nodes(input_node, node, &fusing_history);need_recalc_processing_order = true;@@ -57,6 +61,7 @@ void fuse_primitives_with_layout::run(program& p) {}// Need to update processing order when peer node processing number is greater than fused node- if (need_recalc_processing_order)+ if (need_recalc_processing_order) {p.get_processing_order().calc_processing_order(p);+ }}diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/graph_initializations.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/graph_initializations.cppindex 186732fc620..1079e582988 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/graph_initializations.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/graph_initializations.cpp@@ -26,11 +26,12 @@ void graph_initializations::set_outputs(program& p) {p.outputs.push_back(o_node.get());}} else {- for (auto& node : p.nodes_map)+ for (auto& node : p.nodes_map) {if (node.second->is_endpoint() && !node.second->is_type<data>()) {node.second->set_output(true);p.outputs.push_back(node.second.get());}+ }}}diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/handle_reshape.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/handle_reshape.cppindex 40e3f726156..cc79977a599 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/handle_reshape.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/handle_reshape.cpp@@ -29,8 +29,9 @@ void handle_reshape::run(program& p) {auto output_lay = node.get_output_layout();if (!node.is_in_place() ||- node.has_fused_primitives())+ node.has_fused_primitives()) {return;+ }if (input_lay.identical(output_lay)) {p.add_optimized_primitive_info(node.id());@@ -52,13 +53,15 @@ void handle_reshape::run(program& p) {while (node_itr != p.get_processing_order().end()) {const auto& node = (*node_itr++);program_helpers::do_for_types<reshape>(*node, [&p](reshape_node& node) {- if (node.is_output() || node.get_users().size() > 1 || node.has_fused_primitives() || node.is_dynamic())+ if (node.is_output() || node.get_users().size() > 1 || node.has_fused_primitives() || node.is_dynamic()) {return;+ }const auto& out_node = node.get_users().front();- if (!out_node->is_type<reshape>())+ if (!out_node->is_type<reshape>()) {return;+ }const auto& out_reshape = out_node->as<reshape>();// In case of new shape infer we should not shrink reshapes chain if first reshape changes input rank, e.g.@@ -66,8 +69,9 @@ void handle_reshape::run(program& p) {// Configuration above will fail if we remove reshape1 node as attempt to handle special zero will fail due to small rank of inputif (p.is_new_shape_infer() &&out_node->get_output_pshape().size() != node.get_input_pshape().size() &&- (out_reshape.get_primitive()->special_zero || node.get_primitive()->special_zero))+ (out_reshape.get_primitive()->special_zero || node.get_primitive()->special_zero)) {return;+ }p.extract_and_remove(node);});@@ -79,8 +83,9 @@ void handle_reshape::run(program& p) {auto& input_node = *dep.first;const auto& input_port = dep.second;- if (input_node.is_type<reorder>())+ if (input_node.is_type<reorder>()) {continue;+ }node->get_output_layout();@@ -93,10 +98,12 @@ void handle_reshape::run(program& p) {// find users who are onednn implfor (const auto& user : node->get_users()) {if (user->is_type<reorder>() &&- !(*user).as<reorder>().get_primitive()->truncate) // not to split conversion only reorder+ !(*user).as<reorder>().get_primitive()->truncate) { // not to split conversion only reorderreorder_node_to_split.push_back(user);- if (user->can_use(impl_types::onednn))+ }+ if (user->can_use(impl_types::onednn)) {onednn_users.push_back(user);+ }}// If onednn user doesn't support new input data type from future "reorder:_reshape_input_" reorder,@@ -140,8 +147,9 @@ void handle_reshape::run(program& p) {// reshape node for first user will be the orginal reshape from the graphif (!found_one) {if ((std::find(reorder_node_to_split.begin(), reorder_node_to_split.end(), user) !=- reorder_node_to_split.end()) && (user->get_output_layout().get_rank() == node->get_output_layout().get_rank()))+ reorder_node_to_split.end()) && (user->get_output_layout().get_rank() == node->get_output_layout().get_rank())) {reorder_reshape_nodes.push_back(node);+ }found_one = true;continue;}@@ -172,8 +180,9 @@ void handle_reshape::run(program& p) {}}- if (reorder_reshape_nodes.empty())+ if (reorder_reshape_nodes.empty()) {continue;+ }// add new reorder nodes to proper reshape nodeauto reshape_reorder_id = 0;diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_runtime_skippable_nodes.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_runtime_skippable_nodes.cppindex c482e04b38a..e10ceac51aa 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_runtime_skippable_nodes.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_runtime_skippable_nodes.cpp@@ -2,25 +2,24 @@// SPDX-License-Identifier: Apache-2.0//-#include "pass_manager.h"+#include "broadcast_inst.h"+#include "dynamic_quantize_inst.h"#include "gather_inst.h"-#include "non_max_suppression_inst.h"-#include "permute_inst.h"-#include "strided_slice_inst.h"-#include "kv_cache_inst.h"#include "gemm_inst.h"-#include "shape_of_inst.h"-#include "broadcast_inst.h"-#include "non_zero_inst.h"+#include "kv_cache_inst.h"+#include "lora_inst.h"#include "non_max_suppression_inst.h"-#include "unique_inst.hpp"+#include "non_zero_inst.h"+#include "pass_manager.h"+#include "permute_inst.h"+#include "program_helpers.h"+#include "resample_inst.h"#include "scatter_elements_update_inst.h"-#include "scatter_update_inst.h"#include "scatter_nd_update_inst.h"-#include "dynamic_quantize_inst.h"-#include "lora_inst.h"-#include "resample_inst.h"-#include "program_helpers.h"+#include "scatter_update_inst.h"+#include "shape_of_inst.h"+#include "strided_slice_inst.h"+#include "unique_inst.hpp"using namespace cldnn;@@ -31,23 +30,25 @@ void mark_runtime_skippable_nodes::run(program& p) {const auto& node = *itr++;// Set gathers that might be skipped at runtime as can_be_optimized.// If not set, memory dependency will not work for the nodes that are skipped at runtime- if (node->is_type<data>() || node->is_constant())+ if (node->is_type<data>() || node->is_constant()) {continue;+ }std::function<bool(const program_node& node)> all_users_are_shape_of = [&](const program_node& node) {- if (node.is_input() || node.is_output())+ if (node.is_input() || node.is_output()) {return false;+ }for (const auto& u : node.get_users()) {- if (!u->is_type<shape_of>())+ if (!u->is_type<shape_of>()) {return false;+ }}return true;};if (all_users_are_shape_of(*node) &&// primitives that should be executed to know output shapes- !node->is_type<gather_nonzero>() && !node->is_type<unique_gather>() &&- !node->is_type<non_max_suppression_gather>()) {+ !node->is_type<gather_nonzero>() && !node->is_type<unique_gather>() && !node->is_type<non_max_suppression_gather>()) {// always to skip, no runtime executionnode->can_be_optimized(true);GPU_DEBUG_TRACE_DETAIL << "[mark_runtime_skippable_nodes] : " << node->id() << " has only shape_of as users. Set can_be_optimized always"@@ -58,10 +59,10 @@ void mark_runtime_skippable_nodes::run(program& p) {program_helpers::do_for_types<gather>(*node, [](gather_node& node) {// Check patternauto impl_params = node.get_kernel_impl_params();- if (node.has_fused_primitives() ||- (impl_params->get_input_layout(0).data_type != impl_params->get_output_layout().data_type) ||- node.get_dependency(1).is_constant() || node.get_dependency(1).is_type<data>())+ if (node.has_fused_primitives() || (impl_params->get_input_layout(0).data_type != impl_params->get_output_layout().data_type) ||+ node.get_dependency(1).is_constant() || node.get_dependency(1).is_type<data>()) {return;+ }auto idx_rank = impl_params->get_input_layout(1).get_partial_shape().size();if (idx_rank != 1) {@@ -69,9 +70,8 @@ void mark_runtime_skippable_nodes::run(program& p) {}if (node.is_dynamic()) {auto axis = impl_params->typed_desc<gather>()->axis;- if (impl_params->get_input_layout(0).get_partial_shape()[axis] == -1- || impl_params->get_input_layout(1).get_partial_shape()[0] == -1- || impl_params->get_input_layout(0).get_partial_shape()[axis] == impl_params->get_input_layout(1).get_partial_shape()[0]) {+ if (impl_params->get_input_layout(0).get_partial_shape()[axis] == -1 || impl_params->get_input_layout(1).get_partial_shape()[0] == -1 ||+ impl_params->get_input_layout(0).get_partial_shape()[axis] == impl_params->get_input_layout(1).get_partial_shape()[0]) {// May be skippednode.can_be_optimized(true);// Set runtime skippable only when the node is set as can_be_optimized finally.@@ -83,23 +83,25 @@ void mark_runtime_skippable_nodes::run(program& p) {program_helpers::do_for_types<permute>(*node, [](permute_node& node) {// if node is already optimized at compilation time, do not handle at runtime- if (node.can_be_optimized())+ if (node.can_be_optimized()) {return;+ }auto impl_params = node.get_kernel_impl_params();- if (node.is_output() ||- node.has_fused_primitives() ||- (impl_params->get_input_layout(0).data_type != impl_params->get_output_layout().data_type) ||- impl_params->get_input_layout(0).data_padding.is_dynamic())+ if (node.is_output() || node.has_fused_primitives() || (impl_params->get_input_layout(0).data_type != impl_params->get_output_layout().data_type) ||+ impl_params->get_input_layout(0).data_padding.is_dynamic()) {return;+ }// TODO: For now, all permutes with dynamic shape are applied.// A more detailed pattern will need to be applied laterif (node.is_dynamic()) {- if (node.get_dependency(0).is_type<kv_cache>())+ if (node.get_dependency(0).is_type<kv_cache>()) {return;+ }// If the user is concatenation, priority should be given to in place concat optimization at runtime- if (node.have_user_with_type<concatenation>() && node.get_users().size() == 1)+ if (node.have_user_with_type<concatenation>() && node.get_users().size() == 1) {return;+ }node.can_be_optimized(true);// Set runtime skippable only when the node is set as can_be_optimized finally.node.set_runtime_skippable(true);@@ -109,23 +111,19 @@ void mark_runtime_skippable_nodes::run(program& p) {program_helpers::do_for_types<strided_slice>(*node, [](strided_slice_node& node) {auto impl_params = node.get_kernel_impl_params();- if (node.is_output()- || node.has_fused_primitives()- || (impl_params->get_input_layout(0).format != impl_params->get_output_layout().format)- || (impl_params->get_input_layout(0).data_type != impl_params->get_output_layout().data_type))+ if (node.is_output() || node.has_fused_primitives() || (impl_params->get_input_layout(0).format != impl_params->get_output_layout().format) ||+ (impl_params->get_input_layout(0).data_type != impl_params->get_output_layout().data_type)) {return;+ }auto prim = impl_params->typed_desc<strided_slice>();auto begin = prim->begin;auto strides = prim->strides;auto begin_mask = prim->begin_mask;- if (prim->end_mask.empty()- || !prim->new_axis_mask.empty()- || !prim->shrink_axis_mask.empty()- || !prim->ellipsis_mask.empty()- || (!all_zeroes(begin) && !all_ones(begin_mask))- || !all_ones(strides))+ if (prim->end_mask.empty() || !prim->new_axis_mask.empty() || !prim->shrink_axis_mask.empty() || !prim->ellipsis_mask.empty() ||+ (!all_zeroes(begin) && !all_ones(begin_mask)) || !all_ones(strides)) {return;+ }auto end = prim->end;auto end_mask = prim->end_mask;@@ -140,8 +138,9 @@ void mark_runtime_skippable_nodes::run(program& p) {break;}}- if (!end.empty() && !is_valid)+ if (!end.empty() && !is_valid) {return;+ }node.can_be_optimized(true);// Set runtime skippable only when the node is set as can_be_optimized finally.node.set_runtime_skippable(true);@@ -150,32 +149,34 @@ void mark_runtime_skippable_nodes::run(program& p) {program_helpers::do_for_types<broadcast>(*node, [](broadcast_node& node) {auto impl_params = node.get_kernel_impl_params();- if (node.is_output()- || node.has_fused_primitives()- || (impl_params->get_input_layout(0).format != impl_params->get_output_layout().format)- || (impl_params->get_input_layout(0).data_type != impl_params->get_output_layout().data_type))+ if (node.is_output() || node.has_fused_primitives() || (impl_params->get_input_layout(0).format != impl_params->get_output_layout().format) ||+ (impl_params->get_input_layout(0).data_type != impl_params->get_output_layout().data_type)) {return;+ }if (node.is_dynamic()) {// If the user is reorder, it could be fused to broadcast in the remove_redundant_reorders pass.// In this case, broadcast can not be optimized due to different input and output shapes.- if (node.have_user_with_type<reorder>() && node.get_users().size() == 1)+ if (node.have_user_with_type<reorder>() && node.get_users().size() == 1) {return;+ }// Check if the size of rank is different, or if one of static dimensions has different sizeauto input_pshape = impl_params->get_input_layout(0).get_partial_shape();auto output_pshape = impl_params->get_output_layout().get_partial_shape();if (input_pshape.rank().is_static() && output_pshape.rank().is_static()) {- if (input_pshape.size() != output_pshape.size())+ if (input_pshape.size() != output_pshape.size()) {return;+ }auto input_pdim = input_pshape.begin();auto output_pdim = output_pshape.begin();while (input_pdim != input_pshape.end()) {if (input_pdim->is_static() && output_pdim->is_static()) {- if (input_pdim->get_max_length() != output_pdim->get_max_length())+ if (input_pdim->get_max_length() != output_pdim->get_max_length()) {return;+ }}input_pdim++;@@ -193,20 +194,22 @@ void mark_runtime_skippable_nodes::run(program& p) {program_helpers::do_for_types<reorder>(*node, [](reorder_node& node) {auto impl_params = node.get_kernel_impl_params();- if ((node.is_output() && node.get_dependency(0).is_input())- || node.has_fused_primitives()- || (impl_params->get_input_layout(0).format != impl_params->get_output_layout().format)- || (impl_params->get_input_layout(0).data_type != impl_params->get_output_layout().data_type)- || (impl_params->get_input_layout(0).data_padding != impl_params->get_output_layout().data_padding))+ if ((node.is_output() && node.get_dependency(0).is_input()) || node.has_fused_primitives() ||+ (impl_params->get_input_layout(0).format != impl_params->get_output_layout().format) ||+ (impl_params->get_input_layout(0).data_type != impl_params->get_output_layout().data_type) ||+ (impl_params->get_input_layout(0).data_padding != impl_params->get_output_layout().data_padding)) {return;+ }if (node.is_dynamic()) {- if (!node.is_output() && node.get_users().size() != 1)+ if (!node.is_output() && node.get_users().size() != 1) {return;+ }// If the user is concatenation with 1 user and the concat is optimized, priority should be given to in place concat optimization at runtime- if (node.have_user_with_type<concatenation>() && node.get_users().front()->can_be_optimized())+ if (node.have_user_with_type<concatenation>() && node.get_users().front()->can_be_optimized()) {return;+ }node.can_be_optimized(true);// Set runtime skippable only when the node is set as can_be_optimized finally.@@ -218,11 +221,11 @@ void mark_runtime_skippable_nodes::run(program& p) {program_helpers::do_for_types<scatter_elements_update>(*node, [](scatter_elements_update_node& node) {auto impl_params = node.get_kernel_impl_params();- if ((node.is_output() && node.get_dependency(0).is_input())- || node.has_fused_primitives()- || (impl_params->get_input_layout(0).format != impl_params->get_output_layout().format)- || (impl_params->get_input_layout(0).data_type != impl_params->get_output_layout().data_type))+ if ((node.is_output() && node.get_dependency(0).is_input()) || node.has_fused_primitives() ||+ (impl_params->get_input_layout(0).format != impl_params->get_output_layout().format) ||+ (impl_params->get_input_layout(0).data_type != impl_params->get_output_layout().data_type)) {return;+ }if (node.is_dynamic()) {node.can_be_optimized(true);@@ -235,11 +238,11 @@ void mark_runtime_skippable_nodes::run(program& p) {program_helpers::do_for_types<scatter_update>(*node, [](scatter_update_node& node) {auto impl_params = node.get_kernel_impl_params();- if ((node.is_output() && node.get_dependency(0).is_input())- || node.has_fused_primitives()- || (impl_params->get_input_layout(0).format != impl_params->get_output_layout().format)- || (impl_params->get_input_layout(0).data_type != impl_params->get_output_layout().data_type))+ if ((node.is_output() && node.get_dependency(0).is_input()) || node.has_fused_primitives() ||+ (impl_params->get_input_layout(0).format != impl_params->get_output_layout().format) ||+ (impl_params->get_input_layout(0).data_type != impl_params->get_output_layout().data_type)) {return;+ }if (node.is_dynamic()) {node.can_be_optimized(true);@@ -252,11 +255,11 @@ void mark_runtime_skippable_nodes::run(program& p) {program_helpers::do_for_types<scatter_nd_update>(*node, [](scatter_nd_update_node& node) {auto impl_params = node.get_kernel_impl_params();- if ((node.is_output() && node.get_dependency(0).is_input())- || node.has_fused_primitives()- || (impl_params->get_input_layout(0).format != impl_params->get_output_layout().format)- || (impl_params->get_input_layout(0).data_type != impl_params->get_output_layout().data_type))+ if ((node.is_output() && node.get_dependency(0).is_input()) || node.has_fused_primitives() ||+ (impl_params->get_input_layout(0).format != impl_params->get_output_layout().format) ||+ (impl_params->get_input_layout(0).data_type != impl_params->get_output_layout().data_type)) {return;+ }if (node.is_dynamic()) {node.can_be_optimized(true);@@ -266,13 +269,13 @@ void mark_runtime_skippable_nodes::run(program& p) {}});- program_helpers::do_for_types<dynamic_quantize>(*node, [](dynamic_quantize_node & node) {+ program_helpers::do_for_types<dynamic_quantize>(*node, [](dynamic_quantize_node& node) {auto impl_params = node.get_kernel_impl_params();- if ((node.is_output() && node.get_dependency(0).is_input())- || node.has_fused_primitives()- || (impl_params->get_input_layout(0).format != impl_params->get_output_layout().format))+ if ((node.is_output() && node.get_dependency(0).is_input()) || node.has_fused_primitives() ||+ (impl_params->get_input_layout(0).format != impl_params->get_output_layout().format)) {return;+ }if (node.is_dynamic()) {node.can_be_optimized(true);diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_shape_of_subgraphs.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_shape_of_subgraphs.cppindex 6fd31a5baf0..376401e50e7 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_shape_of_subgraphs.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_shape_of_subgraphs.cpp@@ -65,33 +65,39 @@ void mark_shape_of_subgraphs::look_for_shape_of_subgraph(program_node& node) {}// Node should have at least one dependency marked as a part of shape_of subgraph- if (!has_shape_of_subgraph_dep || !can_execute_in_subgraph)+ if (!has_shape_of_subgraph_dep || !can_execute_in_subgraph) {return;+ }- if (!can_mark_node(node))+ if (!can_mark_node(node)) {return;+ }mark_node(node);}bool mark_shape_of_subgraphs::can_mark_node(const program_node& node) {- if (node.has_fused_primitives())+ if (node.has_fused_primitives()) {return false;+ }// read_value, convolution, fully_connected, and gemm may have initializers that are part of a shape_of sub-graph,// but these nodes themselves are not considered part of such sub-graph- if (node.is_type<read_value>() || node.is_type<convolution>() || node.is_type<fully_connected>() || node.is_type<gemm>())+ if (node.is_type<read_value>() || node.is_type<convolution>() || node.is_type<fully_connected>() || node.is_type<gemm>()) {return false;+ }// CPU implementation does not support float data types for mask and mixed types for data inputs, so check them// before including it into shape_of sub-graphif (node.is_type<select>() &&(data_type_traits::is_floating_point(node.get_input_layout(0).data_type) ||- node.get_input_layout(1).data_type != node.get_input_layout(2).data_type))+ node.get_input_layout(1).data_type != node.get_input_layout(2).data_type)) {return false;+ }- if (node.is_type<reshape>())+ if (node.is_type<reshape>()) {return true;+ }// Exclude eltwise with boolean mode types since CPU reference implementation// couldn't save result in int8 data type (as it requested by GPU plugin,@@ -99,16 +105,18 @@ bool mark_shape_of_subgraphs::can_mark_node(const program_node& node) {if (node.is_type<eltwise>()) {const auto& eltwise_node = node.as<eltwise>();auto eltwise_mode = eltwise_node.get_primitive()->mode;- if (eltwise::eltwise_bool_modes.find(eltwise_mode) != eltwise::eltwise_bool_modes.end())+ if (eltwise::eltwise_bool_modes.find(eltwise_mode) != eltwise::eltwise_bool_modes.end()) {return false;+ }}// Exclude gather_compressed primitive because gather_cpu_impl doesn't support it.if (node.is_type<gather>()) {const auto& gather_node = node.as<gather>();auto gather_compressed_weight_mode = gather_node.get_primitive()->compressed_weights;- if (gather_compressed_weight_mode)+ if (gather_compressed_weight_mode) {return false;+ }}// Exclude stride_slice primitive if it's input is big const ternsor, else CPU reference implementation@@ -121,8 +129,9 @@ bool mark_shape_of_subgraphs::can_mark_node(const program_node& node) {// skip mark_node for broadcast node if dependency nodes are data and shape_ofconst auto& dependencies = node.get_dependencies();if (node.is_type<broadcast>() && dependencies.size() == 2) {- if (dependencies[0].first->is_type<data>() && dependencies[1].first->is_type<shape_of>() && (dependencies[1].first->get_users().size() == 1))+ if (dependencies[0].first->is_type<data>() && dependencies[1].first->is_type<shape_of>() && (dependencies[1].first->get_users().size() == 1)) {return false;+ }}return true;@@ -133,8 +142,9 @@ void mark_shape_of_subgraphs::mark_node(program_node& node) {// If current node has shape_of type add it to dependant shape_of nodes for// correct dependency propagation for users- if (is_shape_of_subgraph_root(node))+ if (is_shape_of_subgraph_root(node)) {node.add_dependant_shape_of_node(&node);+ }// Add parent shape_of nodes from other dependencies if there are anyfor (auto dep : node.get_dependencies()) {diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_state_init_subgraphs.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_state_init_subgraphs.cppindex d98d25172f2..a097ef735d6 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_state_init_subgraphs.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_state_init_subgraphs.cpp@@ -2,31 +2,35 @@// SPDX-License-Identifier: Apache-2.0//-#include "read_value_inst.h"-#include "pass_manager.h"#include <queue>#include "intel_gpu/graph/program.hpp"+#include "pass_manager.h"+#include "read_value_inst.h"using namespace cldnn;void mark_state_init_subgraphs::mark_init_subgraph(program& p, read_value_node& node) {const auto& variable_id = node.get_primitive()->variable_id;- if (p.contains_state(variable_id))+ if (p.contains_state(variable_id)) {return;+ }std::queue<program_node*> q;q.push(&node);auto can_be_marked = [&](const program_node* dep_node) {- if (p.has_state_initializers(variable_id, dep_node->id()))+ if (p.has_state_initializers(variable_id, dep_node->id())) {return false;+ }for (const auto& u : dep_node->get_users()) {- if (u == &node)+ if (u == &node) {continue;- if (p.has_state_initializers(variable_id, u->id()))+ }+ if (p.has_state_initializers(variable_id, u->id())) {continue;+ }return false;}GPU_DEBUG_TRACE_DETAIL << "marked " << dep_node->id() << " as node in a init_subgraph for " << node.id() << std::endl;diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/oooq_memory_dependencies.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/oooq_memory_dependencies.cppindex 778543698e3..4ada5faebbf 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/oooq_memory_dependencies.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/oooq_memory_dependencies.cpp@@ -35,8 +35,9 @@ public:uint64_t thatval = myval | that.storage[i];bool local_change = myval != thatval;changed |= local_change;- if (local_change)+ if (local_change) {storage[i] = thatval;+ }}return changed;}diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/post_input_reorder.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/post_input_reorder.cppindex baa44fefefa..84d0994cfca 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/post_input_reorder.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/post_input_reorder.cpp@@ -2,13 +2,14 @@// SPDX-License-Identifier: Apache-2.0//-#include "pass_manager.h"-#include "impls/ocl/primitive_base.hpp"-#include "fully_connected_inst.h"-#include "fully_connected/fully_connected_params.h"#include <memory>#include <stdexcept>+#include "fully_connected/fully_connected_params.h"+#include "fully_connected_inst.h"+#include "impls/ocl/primitive_base.hpp"+#include "pass_manager.h"+using namespace cldnn;/*@@ -19,16 +20,12 @@ If not than required reorder is added to the network./*Add a reorder in between node and usr with reorder_layout as layout*/-program_node& post_input_reorder::add_reorder(program& p,- program_node* node,- program_node* usr,- const layout& reorder_layout) {+program_node& post_input_reorder::add_reorder(program& p, program_node* node, program_node* usr, const layout& reorder_layout) {auto new_reorder = std::make_shared<reorder>(node->id() + "_reorder_" + usr->id(), node->id(), reorder_layout);auto& new_reorder_node = p.get_or_create(new_reorder);// ToDo: add a method to program class which adds an intermediate node given a node and its user- auto it = std::find_if(usr->get_dependencies().begin(), usr->get_dependencies().end(),- [&](const std::pair<program_node*, int32_t>& dep) {+ auto it = std::find_if(usr->get_dependencies().begin(), usr->get_dependencies().end(), [&](const std::pair<program_node*, int32_t>& dep) {return node == dep.first;});if (it == usr->get_dependencies().end()) {@@ -50,10 +47,10 @@ void post_input_reorder::run(program& p) {// add a reorder if primitive's input format doesn't match implementation's input formatif (node->is_type<fully_connected>()) {auto* const fc_impl = dynamic_cast<ocl::typed_primitive_impl_ocl<fully_connected>*>(impl);- if (!fc_impl || node->can_be_optimized())+ if (!fc_impl || node->can_be_optimized()) {continue;- const auto& fc_params =- *static_cast<kernel_selector::fully_connected_params*>(fc_impl->_kernel_data.params.get());+ }+ const auto& fc_params = *static_cast<kernel_selector::fully_connected_params*>(fc_impl->_kernel_data.params.get());auto layout_format = from_data_layout(fc_params.inputs[0].GetLayout());const auto& input = node->get_dependencies()[0].first;@@ -61,10 +58,7 @@ void post_input_reorder::run(program& p) {if (input_layout.format != layout_format) {auto previous_layout = node->get_output_layout();- layout current_layout(input_layout.get_partial_shape(),- input_layout.data_type,- layout_format,- input_layout.data_padding);+ layout current_layout(input_layout.get_partial_shape(), input_layout.data_type, layout_format, input_layout.data_padding);auto& reorder = add_reorder(p, input, node, current_layout);reorder.set_unique_id();reorder.get_output_layout(false);diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/post_optimize_weights.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/post_optimize_weights.cppindex 1e751696c2b..5667c005ba8 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/post_optimize_weights.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/post_optimize_weights.cpp@@ -46,8 +46,9 @@ void post_optimize_weights::optimize_weights(T& node, program& p) {auto impl = node.get_selected_impl();// Skip load-time weights reordering if impl is not selected- if (!impl)+ if (!impl) {return;+ }if (impl->is_dynamic()) {// TODO: To relax current limitation w.r.t the future optimization of weight reorder process@@ -56,12 +57,15 @@ void post_optimize_weights::optimize_weights(T& node, program& p) {// Also we skip weight reorder for onednn impl because onednn fully connected layer is using simple format, therefore// reordering to cldnn shape_agnostic_kernel's preferred blocked format at build time does not helpful for the performance.// This situation might be changed once onednn shape agnostic kernel is used in the future.- if (p.is_internal_program())+ if (p.is_internal_program()) {return;- if (node.get_preferred_impl_type() == impl_types::onednn)+ }+ if (node.get_preferred_impl_type() == impl_types::onednn) {return;- if (node.type() != fully_connected::type_id())+ }+ if (node.type() != fully_connected::type_id()) {return;+ }}// Don't run impl selection to avoid double compilation of reorder kernels// in main program and internal program for constant propagation@@ -322,7 +326,8 @@ void post_optimize_weights::run(program& p) {optimize_weights(node->as<gru_seq>(), p);}}- if (found_lstm)+ if (found_lstm) {p.get_processing_order().calc_processing_order(p);+ }}} // namespace cldnn\ No newline at end of filediff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/pre_replace_deconv.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/pre_replace_deconv.cppindex 697d949676c..06acb78eff0 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/pre_replace_deconv.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/pre_replace_deconv.cpp@@ -29,8 +29,9 @@ void pre_replace_deconv::run(program& p) {auto& node = (*node_itr).second;// find deconvolution primitives with stride 1 and change them to convolution with transposed weightsif (node->is_type<deconvolution>()) {- if (node->is_dynamic())+ if (node->is_dynamic()) {continue;+ }auto& deconv_node = node->as<deconvolution>();auto& weights_node = deconv_node.weights();@@ -59,8 +60,9 @@ void pre_replace_deconv::run(program& p) {// int8/uint8 inputperform_opt |= (input_layout.data_type == data_types::i8 || input_layout.data_type == data_types::u8);- if (!perform_opt)+ if (!perform_opt) {continue;+ }// setting convolution parameters based on deconvolution paramsauto output_layout = deconv_node.get_output_layout();@@ -98,8 +100,9 @@ void pre_replace_deconv::run(program& p) {std::vector<std::shared_ptr<program_node>> bias_connections;if (biases_nodes_id.is_valid()) {auto bias_iter = p.nodes_map.find(biases_nodes_id.pid);- if (bias_iter == p.nodes_map.end())+ if (bias_iter == p.nodes_map.end()) {continue;+ }auto bias_id_node_ptr = bias_iter->second;bias_connections.push_back(bias_id_node_ptr);@@ -184,8 +187,9 @@ void pre_replace_deconv::run(program& p) {if (weights_data_type != data_types::f16 &&weights_data_type != data_types::f32 &&bias_data_type != data_types::f16 &&- bias_data_type != data_types::f32)+ bias_data_type != data_types::f32) {continue;+ }// setting convolution parameters based on deconvolution paramsov::Strides stride(spatial_rank, 1);@@ -218,12 +222,14 @@ void pre_replace_deconv::run(program& p) {if (weights_data_type == data_types::f16) {mem_lock<ov::float16, mem_lock_type::read> src{ weights_node_ptr->as<data>().get_attached_memory_ptr(), stream };- for (uint32_t i = 0; i < weights_layout.count(); i++)+ for (uint32_t i = 0; i < weights_layout.count(); i++) {weights_vec_float.push_back(static_cast<float>(src.data()[i]));+ }} else {mem_lock<float, mem_lock_type::read> src{ weights_node_ptr->as<data>().get_attached_memory_ptr(), stream };- for (uint32_t i = 0; i < weights_layout.count(); i++)+ for (uint32_t i = 0; i < weights_layout.count(); i++) {weights_vec_float.push_back(src.data()[i]);+ }}std::vector<std::vector<std::vector<float> > > subpixel_weights(pixel_shuffle_size);diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_buffer_fusing.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_buffer_fusing.cppindex 7d80a547b9b..b1419dae6dd 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_buffer_fusing.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_buffer_fusing.cpp@@ -169,9 +169,10 @@ bool concat_in_place_optimization::match(const program_node& concat_node,return false;size_t concat_users = 0;- for (const auto& user : pred.first->get_users())+ for (const auto& user : pred.first->get_users()) {if (user->is_type<concatenation>())concat_users += 1;+ }// If input is used by more than one concatenation then they may require different paddings.if (concat_users != 1)@@ -334,10 +335,11 @@ void concat_in_place_optimization::update_in_place_concat_paddings(upper_padd[concat_axis] -= input_length;// set new padding for input- if (is_runtime)+ if (is_runtime) {pred_layout.data_padding = padding(lower_padd, upper_padd, dyn_pad_dims);- else+ } else {pred_layout.data_padding = padding(lower_padd, upper_padd);+ }// move lower padd further//// |-------------- lower padd -------------|---------- upper padd -----------|diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_buffer_fusing.h b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_buffer_fusing.hindex 21afba755c3..a44af07ad2a 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_buffer_fusing.h+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_buffer_fusing.h@@ -49,11 +49,12 @@ struct concat_in_place_optimization : pattern_match_optimization_typed<concat_inwhile (!need_reopt.empty()) {auto& prop = *need_reopt.front();need_reopt.pop_front();- if (match(prop))+ if (match(prop)) {optimize_cascade(prop, need_reopt);- else+ } else {// TODO: Revert extra padding when cascade adjustment failed.prop.can_be_optimized(false);+ }}return false; // node not invalidated}diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_padding.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_padding.cppindex 7cb7a32f9dd..4bba0a844f1 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_padding.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_padding.cpp@@ -2,23 +2,25 @@// SPDX-License-Identifier: Apache-2.0//-#include "pooling_inst.h"-#include "fully_connected_inst.h"-#include "program_node.h"-#include "pass_manager.h"+#include <algorithm>++#include "col2im_inst.h"#include "convolution_inst.h"+#include "fully_connected_inst.h"#include "mvn_inst.h"-#include "col2im_inst.h"+#include "pass_manager.h"+#include "pooling_inst.h"+#include "program_node.h"#include "sliding_window_utils.hpp"-#include <algorithm>using namespace cldnn;using namespace ov::intel_gpu;void prepare_padding::run(program& p) {for (const auto& node : p.get_processing_order()) {- if (!node->is_type<fully_connected>())+ if (!node->is_type<fully_connected>()) {continue;+ }auto& weight_node = node->get_dependency(1);if (weight_node.is_constant()) {@@ -32,33 +34,30 @@ void prepare_padding::run(program& p) {std::vector<ov::Dimension::value_type> new_paddings(const_shape.size(), 0);new_paddings[inner_most_idx] = 1;- if (node->get_preferred_impl_type() == impl_types::onednn &&- weight_node.is_type<data>() &&+ if (node->get_preferred_impl_type() == impl_types::onednn && weight_node.is_type<data>() &&(weight_node.get_output_layout(false).data_type == cldnn::data_types::u4 ||weight_node.get_output_layout(false).data_type == cldnn::data_types::i4)) {- auto weight_in_layout = weight_layout.convert_to_weights_layout(false);+ auto weight_in_layout = weight_layout.convert_to_weights_layout(false);auto weight_out_layout = weight_in_layout;weight_out_layout.data_padding = padding::max(weight_out_layout.data_padding, padding({0}, new_paddings));auto weights_reorder_params = std::make_shared<WeightsReorderParams>(weight_in_layout, weight_out_layout, false, false);- auto new_reorder = std::make_shared<reorder>("padding_reorder_for_" + weight_node.id(),- weight_node.id(), weights_reorder_params);+ auto new_reorder = std::make_shared<reorder>("padding_reorder_for_" + weight_node.id(), weight_node.id(), weights_reorder_params);auto& new_reorder_node = p.get_or_create(new_reorder);p.add_intermediate(new_reorder_node, *node, weight_node, new_reorder_node.get_dependencies().empty());new_reorder_node.recalc_output_layouts(false);} else if (node->get_preferred_impl_type() == impl_types::ocl &&p.get_config().get_force_implementations().find(node->id()) == p.get_config().get_force_implementations().end() &&- node->get_input_layout(0).data_type == cldnn::data_types::f16 &&- node->get_input_layout(0).format == cldnn::format::bfyx &&- node->get_input_layout(0).get_partial_shape()[1].is_static() && // feature dim of input should be static- node->as<fully_connected>().get_primitive()->input_size == 2 && // only 2D fc is supported+ node->get_input_layout(0).data_type == cldnn::data_types::f16 && node->get_input_layout(0).format == cldnn::format::bfyx &&+ node->get_input_layout(0).get_partial_shape()[1].is_static() && // feature dim of input should be static+ node->as<fully_connected>().get_primitive()->input_size == 2 && // only 2D fc is supportednode->as<fully_connected>().get_primitive()->weights_rank == 2 &&weight_node.get_output_layout(false).data_type == cldnn::data_types::f16) {// fully_connected_bf_tiled_opt requires 4-bytes aligned input.auto input0_new_layout = node->get_input_layout(0);input0_new_layout.data_padding = padding::max(input0_new_layout.data_padding, padding({0}, new_paddings));auto new_input_reorder = std::make_shared<reorder>("padding_reorder_for_" + node->get_dependency(0).id(),- input_info(node->get_dependency(0).id()),- input0_new_layout);+ input_info(node->get_dependency(0).id()),+ input0_new_layout);auto& new_input_reorder_node = p.get_or_create(new_input_reorder);p.add_intermediate(new_input_reorder_node, *node, node->get_dependency(0), new_input_reorder_node.get_dependencies().empty());new_input_reorder_node.recalc_output_layouts(false);@@ -70,26 +69,30 @@ void prepare_padding::run(program& p) {if (output_size_handling_enabled) {// Prepare upper padding for primitives that support output_size parameter.for (const auto& node : p.get_processing_order()) {- if (node->get_dependencies().empty())+ if (node->get_dependencies().empty()) {continue;+ }- if (node->get_dependency(0).is_type<data>())+ if (node->get_dependency(0).is_type<data>()) {continue;+ }// Padded offsets aren't supported by onednn kernels- if (node->get_preferred_impl_type() == impl_types::onednn)+ if (node->get_preferred_impl_type() == impl_types::onednn) {continue;+ }auto add_required_padding = [&p](program_node& node, padding& needed_padding) {// Add extra reorder for cldnn primitive to handle required padding if neededauto& input = node.get_dependency(0);bool is_usr_onednn = false;- for (const auto& input_usr : input.get_users())- if (input_usr->get_preferred_impl_type() == impl_types::onednn)+ for (const auto& input_usr : input.get_users()) {+ if (input_usr->get_preferred_impl_type() == impl_types::onednn) {is_usr_onednn = true;+ }+ }- if ((input.get_preferred_impl_type() == impl_types::onednn || is_usr_onednn) &&- node.get_preferred_impl_type() == impl_types::ocl &&+ if ((input.get_preferred_impl_type() == impl_types::onednn || is_usr_onednn) && node.get_preferred_impl_type() == impl_types::ocl &&static_cast<bool>(needed_padding)) {auto new_reorder = std::make_shared<reorder>(node.id() + "_padding_reorder_for_" + input.id(), input.id(), input.get_output_layout());auto& new_reorder_node = p.get_or_create(new_reorder);@@ -105,16 +108,15 @@ void prepare_padding::run(program& p) {const auto& prim = prim_node.get_primitive();auto format = node->get_output_layout().format;- if (format == format::b_fs_zyx_fsv16 ||- format == format::bs_fs_zyx_bsv16_fsv16 ||- format == format::bs_fs_yx_bsv16_fsv16 ||- format == format::bs_fs_yx_bsv32_fsv32 ||- format == format::b_fs_zyx_fsv32)+ if (format == format::b_fs_zyx_fsv16 || format == format::bs_fs_zyx_bsv16_fsv16 || format == format::bs_fs_yx_bsv16_fsv16 ||+ format == format::bs_fs_yx_bsv32_fsv32 || format == format::b_fs_zyx_fsv32) {continue;+ }auto in_layout = prim_node.get_input_layout();const auto spatial_rank = in_layout.get_spatial_rank();- if (spatial_rank > 3 || spatial_rank < 1) continue; // FIXME: should support spatial_rank > 3?+ if (spatial_rank > 3 || spatial_rank < 1)+ continue; // FIXME: should support spatial_rank > 3?auto padding_begin = prim->padding_begin;auto padding_end = prim->padding_end;@@ -162,8 +164,9 @@ void prepare_padding::run(program& p) {auto& prim_node = node->as<deconvolution>();const auto& prim = prim_node.get_primitive();- if (!prim->with_output_size)+ if (!prim->with_output_size) {continue;+ }auto filter_size = prim_node.weights().get_output_layout().get_tensor();@@ -181,8 +184,9 @@ void prepare_padding::run(program& p) {auto& prim_node = node->as<pooling>();const auto& prim = prim_node.get_primitive();- if (!prim->with_output_size)+ if (!prim->with_output_size) {continue;+ }padding needed_padding;// WA for this format. sliding window needs to be fixed --perf degradation for IncepctionV1 type models@@ -191,7 +195,7 @@ void prepare_padding::run(program& p) {size.spatial[i] = static_cast<ov::Dimension::value_type>(prim->size[prim->size.size() - i - 1]);}- if (node->get_output_layout().format == format::b_fs_yx_fsv16)+ if (node->get_output_layout().format == format::b_fs_yx_fsv16) {needed_padding = calc_sliding_window_needed_input_padding(prim_node.get_input_layout(),prim->output_size,size,@@ -200,8 +204,9 @@ void prepare_padding::run(program& p) {ov::Strides(prim->size.size(), 1),false,1);- else+ } else {needed_padding = prim_node.get_input_layout().data_padding;+ }add_required_padding(prim_node, needed_padding);}@@ -210,26 +215,26 @@ void prepare_padding::run(program& p) {// Prepare optimized padding for bfyx convolution.for (auto& pair : p.nodes_map) {- if (pair.second->type() != convolution::type_id())+ if (pair.second->type() != convolution::type_id()) {continue;+ }auto& node = pair.second->as<convolution>();- if (node.get_dependencies().empty())+ if (node.get_dependencies().empty()) {continue;+ }- if (node.is_dynamic() && !node.use_explicit_padding())+ if (node.is_dynamic() && !node.use_explicit_padding()) {continue;+ }auto& conv_input_node = node.get_dependency(0);auto conv_layout = node.get_output_layout();// right now output padding optimization is only available for bfyx format and data type = float32- if (conv_layout.format != cldnn::format::bfyx &&- conv_layout.format != cldnn::format::b_fs_yx_fsv16 &&- conv_layout.format != cldnn::format::b_fs_zyx_fsv16 &&- conv_layout.format != cldnn::format::bs_fs_yx_bsv16_fsv16 &&- conv_layout.format != cldnn::format::b_fs_yx_fsv4 &&- conv_layout.format != cldnn::format::fs_b_yx_fsv32) {+ if (conv_layout.format != cldnn::format::bfyx && conv_layout.format != cldnn::format::b_fs_yx_fsv16 &&+ conv_layout.format != cldnn::format::b_fs_zyx_fsv16 && conv_layout.format != cldnn::format::bs_fs_yx_bsv16_fsv16 &&+ conv_layout.format != cldnn::format::b_fs_yx_fsv4 && conv_layout.format != cldnn::format::fs_b_yx_fsv32) {continue;}@@ -238,20 +243,24 @@ void prepare_padding::run(program& p) {// For 3d convolution padding is needed only for int8 case// FP16/32 kernels can work w/o physical padding- if (prev_prim_output_layout.format == cldnn::format::b_fs_zyx_fsv16 &&- prev_prim_output_layout.data_type != data_types::i8 && prev_prim_output_layout.data_type != data_types::u8)+ if (prev_prim_output_layout.format == cldnn::format::b_fs_zyx_fsv16 && prev_prim_output_layout.data_type != data_types::i8 &&+ prev_prim_output_layout.data_type != data_types::u8) {continue;+ }// We shoudn't apply any padding to nodes which are marked as outputs or have type as data- if (conv_input_node.is_output() || conv_input_node.is_type<data>())+ if (conv_input_node.is_output() || conv_input_node.is_type<data>()) {continue;+ }// Padded offsets aren't supported by onednn kernels- if (conv_input_node.get_preferred_impl_type() == impl_types::onednn)+ if (conv_input_node.get_preferred_impl_type() == impl_types::onednn) {continue;+ }- if (node.get_preferred_impl_type() == impl_types::onednn)+ if (node.get_preferred_impl_type() == impl_types::onednn) {continue;+ }auto needed_padding = get_needed_padding_for_convolution(node);@@ -260,7 +269,8 @@ void prepare_padding::run(program& p) {if (node.get_preferred_impl_type() == impl_types::ocl && format::is_default_format(conv_input_node.get_output_layout().format)) {if (conv_input_node.is_type<mvn>() || conv_input_node.is_type<col2im>()) {auto new_reorder = std::make_shared<reorder>(node.id() + "_padding_reorder_for_" + conv_input_node.id(),- conv_input_node.id(), conv_input_node.get_output_layout());+ conv_input_node.id(),+ conv_input_node.get_output_layout());auto& new_reorder_node = p.get_or_create(new_reorder);p.add_intermediate(new_reorder_node, node, conv_input_node);new_reorder_node.recalc_output_layouts(false);@@ -318,12 +328,9 @@ cldnn::padding prepare_padding::get_needed_padding_for_convolution(convolution_npadding_end_y = std::max<ov::Dimension::value_type>(pad_y, 0);padding_end_z = std::max<ov::Dimension::value_type>(pad_z, 0);} else {- auto input_limit_x = -pad_x + (conv_layout.spatial(0) - 1) * stride_x +- (filter_layout.spatial(0) - 1) * dilation_x + 1;- auto input_limit_y = -pad_y + (conv_layout.spatial(1) - 1) * stride_y +- (filter_layout.spatial(1) - 1) * dilation_y + 1;- auto input_limit_z = -pad_z + (conv_layout.spatial(2) - 1) * stride_z +- (filter_layout.spatial(2) - 1) * dilation_z + 1;+ auto input_limit_x = -pad_x + (conv_layout.spatial(0) - 1) * stride_x + (filter_layout.spatial(0) - 1) * dilation_x + 1;+ auto input_limit_y = -pad_y + (conv_layout.spatial(1) - 1) * stride_y + (filter_layout.spatial(1) - 1) * dilation_y + 1;+ auto input_limit_z = -pad_z + (conv_layout.spatial(2) - 1) * stride_z + (filter_layout.spatial(2) - 1) * dilation_z + 1;padding_begin_x = std::max<ov::Dimension::value_type>(pad_x, 0);padding_begin_y = std::max<ov::Dimension::value_type>(pad_y, 0);@@ -340,12 +347,13 @@ cldnn::padding prepare_padding::get_needed_padding_for_convolution(convolution_n// right_padding = needed_buffer_size_x - left_padding - prev_prim_output_layout.spatial(0);cldnn::padding needed_padding = padding();- if (padding_begin.size() >= 3)+ if (padding_begin.size() >= 3) {needed_padding = padding({0, 0, padding_begin_z, padding_begin_y, padding_begin_x}, {0, 0, padding_end_z, padding_end_y, padding_end_x}, 0);- else if (padding_begin.size() >= 2)+ } else if (padding_begin.size() >= 2) {needed_padding = padding({0, 0, padding_begin_y, padding_begin_x}, {0, 0, padding_end_y, padding_end_x}, 0);- else if (!padding_begin.empty())+ } else if (!padding_begin.empty()) {needed_padding = padding({0, 0, padding_begin_x}, {0, 0, padding_end_x}, 0);+ }needed_padding = padding::max(prev_prim_output_layout.data_padding, needed_padding);return needed_padding;diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cppindex 5b00dbf984e..631ac992efb 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp@@ -1382,9 +1382,10 @@ void prepare_primitive_fusing::fuse_simple_primitives(program &p) {merge_allowed = fused_node->get_users().size() == 1;} else {merge_allowed = fused_node->get_users().size() == 1;- for (const auto& parent : fused_node->get_dependencies())+ for (const auto& parent : fused_node->get_dependencies()) {if (parent.first->id() == peer_node->id())merge_allowed = false;+ }}if (!merge_allowed)diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing_through.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing_through.cppindex ac154d341a6..1766dce2e1f 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing_through.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing_through.cpp@@ -2,22 +2,23 @@// SPDX-License-Identifier: Apache-2.0//-#include "pass_manager.h"-#include "program_helpers.h"-#include "strided_slice_inst.h"-#include "reshape_inst.h"-#include "reduce_inst.h"+#include <memory>+#include <vector>+#include "data_inst.h"#include "eltwise_inst.h"#include "mutable_data_inst.h"-#include <vector>-#include <memory>+#include "pass_manager.h"+#include "program_helpers.h"+#include "reduce_inst.h"+#include "reshape_inst.h"+#include "strided_slice_inst.h"using namespace cldnn;void prepare_primitive_fusing_through::run(program& p) {GPU_DEBUG_IF(p.get_config().get_disable_post_ops_fusions() != 0)- return;+ return;auto try_fuse_through = [&](program_node& node) -> std::vector<program_node*> {// This function tries to fuse peer_node to first non reorder or reshape previous primitive.@@ -31,26 +32,31 @@ void prepare_primitive_fusing_through::run(program& p) {// - Activation w/o additional buffers// 3. Paddings are not allowed for fused nodeauto can_raise_up_through = [](program_node* node) {- if (!node->is_type<reshape>() && !node->is_type<reorder>())+ if (!node->is_type<reshape>() && !node->is_type<reorder>()) {return false;+ }- if (node->get_dependencies().empty())+ if (node->get_dependencies().empty()) {return false;+ }- if (node->get_users().size() > 1)+ if (node->get_users().size() > 1) {return false;+ }- if (node->is_type<reorder>() &&- node->get_output_layout().data_type != node->get_input_layout(0).data_type)+ if (node->is_type<reorder>() && node->get_output_layout().data_type != node->get_input_layout(0).data_type) {return false;+ }- // Not to fuse reshape after Reduce changing the order of un-reduced axes. It is expected to be optimized out.- if (node->is_type<reshape>() && node->get_dependencies().front().first->is_type<reduce>())+ // Not to fuse reshape after Reduce changing the order of un-reduced+ // axes. It is expected to be optimized out.+ if (node->is_type<reshape>() && node->get_dependencies().front().first->is_type<reduce>()) {return false;+ }- // Not to raise up target node through reshape or reorder where the size of dimension is changed (e.g. Unsqueeze or Squeeze)- return (!node->is_type<reshape>() && !node->is_type<reorder>()) ||- node->get_output_pshape().size() == node->get_input_pshape(0).size();+ // Not to raise up target node through reshape or reorder where the+ // size of dimension is changed (e.g. Unsqueeze or Squeeze)+ return (!node->is_type<reshape>() && !node->is_type<reorder>()) || node->get_output_pshape().size() == node->get_input_pshape(0).size();};std::vector<program_node*> pass_through;@@ -72,12 +78,14 @@ void prepare_primitive_fusing_through::run(program& p) {auto* node = (*node_itr++);cldnn::program_node* input_node;- if (node->is_output() || node->is_constant())+ if (node->is_output() || node->is_constant()) {continue;+ }if (node->is_type<activation>()) {- if (node->get_dependencies().size() > 1)+ if (node->get_dependencies().size() > 1) {continue;+ }input_node = &node->get_dependency(0);} else if (node->is_type<quantize>()) {@@ -89,8 +97,9 @@ void prepare_primitive_fusing_through::run(program& p) {input_node = &node->get_dependency(0);} else if (node->is_type<eltwise>()) {- if (node->get_dependencies().size() != 2)+ if (node->get_dependencies().size() != 2) {continue;+ }size_t second_input_idx = 0;bool has_constant_input = false;@@ -104,8 +113,9 @@ void prepare_primitive_fusing_through::run(program& p) {}}- if (!has_constant_input)+ if (!has_constant_input) {continue;+ }input_node = &node->get_dependency(second_input_idx);} else {@@ -116,11 +126,13 @@ void prepare_primitive_fusing_through::run(program& p) {bool use_fuse_through = fuse_through_order.size() > 1;bool fused_node_has_multiple_users = fuse_through_order.back()->get_users().size() > 1;- if (!use_fuse_through || fused_node_has_multiple_users)+ if (!use_fuse_through || fused_node_has_multiple_users) {continue;+ }- if (static_cast<bool>(node->get_output_layout().data_padding))+ if (static_cast<bool>(node->get_output_layout().data_padding)) {continue;+ }auto* new_prev = fuse_through_order[fuse_through_order.size() - 1];auto* new_next = fuse_through_order[fuse_through_order.size() - 2];@@ -131,37 +143,41 @@ void prepare_primitive_fusing_through::run(program& p) {if (node->is_type<quantize>() && !node->as<quantize>().has_per_tensor_values()) {auto target_shape = new_prev->get_output_layout().get_partial_shape();auto current_input_shape = node->get_input_layout(0).get_partial_shape();- if ((target_shape != current_input_shape) || target_shape.is_dynamic() || current_input_shape.is_dynamic())+ if ((target_shape != current_input_shape) || target_shape.is_dynamic() || current_input_shape.is_dynamic()) {continue;+ }}// Check broadcastable for fused eltwise's outputif (node->is_type<eltwise>()) {auto out_shape = new_prev->get_output_layout().get_partial_shape(); // new_prev's layout became node's new layout after fusingauto in_shape = node->get_dependency(1).get_output_layout().get_partial_shape();- if (!broadcastable(in_shape, out_shape, true, true))+ if (!broadcastable(in_shape, out_shape, true, true)) {continue;+ }}- if (new_prev->is_type<input_layout>() ||- new_prev->is_type<mutable_data>() ||- new_prev->is_type<quantize>())+ if (new_prev->is_type<input_layout>() || new_prev->is_type<mutable_data>() || new_prev->is_type<quantize>()) {continue;+ }std::vector<cldnn::program_node*> dependencies;for (const auto& dep : node->get_dependencies()) {- if (dep.first == input_node)+ if (dep.first == input_node) {continue;+ }dependencies.push_back(dep.first);}- for (auto* dep : dependencies)+ for (auto* dep : dependencies) {p.remove_connection(*dep, *node);+ }p.move_node(*node, *new_prev, *new_next);- for (auto* dep : dependencies)+ for (auto* dep : dependencies) {p.add_connection(*dep, *node);+ }// Update node's layout and keep original data typeauto target_dt = node->get_output_layout().data_type;diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/propagate_constants.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/propagate_constants.cppindex 49227a2d44d..dd95a391966 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/propagate_constants.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/propagate_constants.cpp@@ -2,27 +2,27 @@// SPDX-License-Identifier: Apache-2.0//+#include "data_inst.h"+#include "intel_gpu/graph/network.hpp"+#include "intel_gpu/graph/program.hpp"+#include "intel_gpu/runtime/debug_configuration.hpp"+#include "intel_gpu/runtime/engine.hpp"#include "intel_gpu/runtime/internal_properties.hpp"+#include "intel_gpu/runtime/itt.hpp"+#include "mutable_data_inst.h"#include "pass_manager.h"#include "program_node.h"-#include "intel_gpu/runtime/engine.hpp"-#include "intel_gpu/runtime/debug_configuration.hpp"-#include "intel_gpu/graph/program.hpp"-#include "intel_gpu/graph/network.hpp"-#include "data_inst.h"-#include "mutable_data_inst.h"-#include "intel_gpu/runtime/itt.hpp"#include "registry/implementation_manager.hpp"#ifdef ENABLE_ONEDNN_FOR_GPU-#include "reorder_inst.h"-#include "graph/impls/onednn/utils.hpp"-#endif // ENABLE_ONEDNN_FOR_GPU-#include <vector>+# include "graph/impls/onednn/utils.hpp"+# include "reorder_inst.h"+#endif // ENABLE_ONEDNN_FOR_GPU#include <list>#include <memory>-#include <utility>-#include <unordered_set>#include <queue>+#include <unordered_set>+#include <utility>+#include <vector>using namespace cldnn;@@ -33,8 +33,9 @@ namespace {// incorrect shape_type classification.void try_reselect_impl_for_node(program_node* node) {bool can_select_impl = !node->is_type<data>() && (!node->is_type<mutable_data>() || !node->get_dependencies().empty());- if (!can_select_impl)+ if (!can_select_impl) {return;+ }auto* selected_impl = node->get_selected_impl();bool has_selected_impl = selected_impl != nullptr;@@ -46,8 +47,9 @@ void try_reselect_impl_for_node(program_node* node) {need_new_impl_selection = (is_node_dynamic != is_impl_dynamic);}- if (!need_new_impl_selection)+ if (!need_new_impl_selection) {return;+ }// Refresh stale output layouts before building kernel params.// After invalidate_users(), cached output_layouts may still reflect@@ -59,8 +61,9 @@ void try_reselect_impl_for_node(program_node* node) {auto params = node->get_kernel_impl_params();auto shape_type = ImplementationManager::get_shape_type(*params);- if (shape_type == shape_types::dynamic_shape)+ if (shape_type == shape_types::dynamic_shape) {return;+ }auto selected_impl_manager = node->type()->choose_impl(*node, shape_type);std::string fail_reason;@@ -92,8 +95,9 @@ void try_reselect_impl_for_node(program_node* node) {void propagate_constants::run(program& p) {OV_ITT_SCOPED_TASK(ov::intel_gpu::itt::domains::intel_gpu_plugin, "pass::PropagateConstants");for (const auto& node : p.get_processing_order()) {- if (node->is_constant())+ if (node->is_constant()) {handle_constant(p, *node);+ }}auto&& to_replace = calculate(p.get_engine(), p.get_config(), p.get_task_executor());@@ -107,10 +111,12 @@ void propagate_constants::run(program& p) {auto proc_itr = p.get_processing_order().begin();while (proc_itr != p.get_processing_order().end()) {const auto& node = (*proc_itr++);- if (!node->is_constant())+ if (!node->is_constant()) {continue;- if (has_non_const_user(*node) || (node->is_output() && !node->is_type<data>()))+ }+ if (has_non_const_user(*node) || (node->is_output() && !node->is_type<data>())) {continue;+ }auto& users = node->users;auto& deps = node->dependencies;@@ -122,18 +128,19 @@ void propagate_constants::run(program& p) {for (auto& usr : users) {auto& usr_deps = usr->dependencies;- usr_deps.erase(std::remove_if(usr_deps.begin(), usr_deps.end(),- [&](const std::pair<program_node*, int>& dep) {- return node == dep.first;- }), usr_deps.end());+ usr_deps.erase(std::remove_if(usr_deps.begin(),+ usr_deps.end(),+ [&](const std::pair<program_node*, int>& dep) {+ return node == dep.first;+ }),+ usr_deps.end());}users.clear();if (!node->is_output()) {auto rem = p.remove_if_dangling(*node);- assert(rem &&- "Non-output constant node which has only constant users should have been removed during constants "- "propagation pass");+ assert(rem && "Non-output constant node which has only constant users should have been removed during constants "+ "propagation pass");(void)rem;}}@@ -160,8 +167,9 @@ void propagate_constants::run(program& p) {for (auto& dep : curr_node_deps) {auto dep_users = dep.first->get_users();for (auto& dep_user : dep_users) {- if (dep_user == &curr_node)+ if (dep_user == &curr_node) {p.remove_connection(*dep.first, curr_node);+ }}}@@ -174,7 +182,9 @@ void propagate_constants::run(program& p) {// dependencies)curr_node.users.erase(std::remove_if(curr_node.users.begin(),curr_node.users.end(),- [](program_node* node) { return node->is_constant(); }),+ [](program_node* node) {+ return node->is_constant();+ }),curr_node.users.end());bool was_dynamic = curr_node.get_output_layout().is_dynamic();p.replace(curr_node, new_node);@@ -190,8 +200,9 @@ void propagate_constants::run(program& p) {while (!queue.empty()) {auto* n = queue.front();queue.pop();- if (reselection_targets.count(n) > 0)+ if (reselection_targets.count(n) > 0) {continue;+ }reselection_targets.insert(n);if (!n->is_all_valid_output_layouts()) {for (const auto& user : n->get_users()) {@@ -211,24 +222,25 @@ void propagate_constants::run(program& p) {}bool propagate_constants::has_non_const_user(program_node& node) const {- if (!node.is_constant())+ if (!node.is_constant()) {return true;+ }for (const auto& user : node.get_users()) {- if (!user->is_constant())+ if (!user->is_constant()) {return true;+ }}return false;}-using cache_tuple =- std::tuple<std::shared_ptr<weightless_cache_manager>, std::shared_ptr<layout>, std::shared_ptr<reorder>>;+using cache_tuple = std::tuple<std::shared_ptr<weightless_cache_manager>, std::shared_ptr<layout>, std::shared_ptr<reorder>>;-std::list<std::tuple<primitive_id, memory::ptr, cache_tuple>>-propagate_constants::calculate(engine& engine,- const ExecutionConfig& config,- std::shared_ptr<ov::threading::IStreamsExecutor> task_executor) {- if (!has_non_trivial_constants)+std::list<std::tuple<primitive_id, memory::ptr, cache_tuple>> propagate_constants::calculate(engine& engine,+ const ExecutionConfig& config,+ std::shared_ptr<ov::threading::IStreamsExecutor> task_executor) {+ if (!has_non_trivial_constants) {return {};+ }ExecutionConfig cf_config = config.clone();cf_config.set_property(ov::intel_gpu::optimize_data(false));@@ -254,8 +266,7 @@ propagate_constants::calculate(engine& engine,net->reset_execution(true); // wait for computations to completeauto outputs = net->get_outputs();- std::list<std::tuple<primitive_id, memory::ptr, cache_tuple>>- ret;+ std::list<std::tuple<primitive_id, memory::ptr, cache_tuple>> ret;for (auto& out : outputs) {cache_tuple cache_info{};auto it = weightless_cache_map.find(out->id());@@ -271,20 +282,23 @@ propagate_constants::calculate(engine& engine,void propagate_constants::handle_constant(program& prog, program_node& node) {if (!node.is_type<data>()) {add_constant(prog, node);- if (has_non_const_user(node))+ if (has_non_const_user(node)) {const_outputs.push_back(node.id());+ }}}void propagate_constants::add_constant(program& prog, program_node& node) {- if (node.is_type<data>())+ if (node.is_type<data>()) {return;+ }nodes.insert(prog.get_node_ptr(node.get_primitive()->id));has_non_trivial_constants = true;// if a node is either an endpoint or an output, always add it as an output- if (node.is_endpoint() || node.is_output())+ if (node.is_endpoint() || node.is_output()) {const_outputs.push_back(node.id());+ }// if a non-tirivial constant has a trivial input, add this input as an input for our networkadd_deps_to_tpl(prog, node.get_dependencies());@@ -306,11 +320,10 @@ void propagate_constants::add_constant(program& prog, program_node& node) {prog.add_intermediate(rotate_node, node, 0);prog.get_or_create(rotate_prim).recalc_output_layouts(false);nodes.insert(prog.get_node_ptr(rotate_node.id()));- GPU_DEBUG_LOG << "Added " << rotate_reorder_id << " for transposing weights before "- << node.id() << std::endl;+ GPU_DEBUG_LOG << "Added " << rotate_reorder_id << " for transposing weights before " << node.id() << std::endl;}}-#endif // ENABLE_ONEDNN_FOR_GPU+#endif // ENABLE_ONEDNN_FOR_GPU}void propagate_constants::add_deps_to_tpl(program& prog, const std::vector<std::pair<program_node*, int32_t>>& deps) {diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/remove_redundant_reorders.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/remove_redundant_reorders.cppindex 0b7b46eae56..26a0e98a18a 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/remove_redundant_reorders.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/remove_redundant_reorders.cpp@@ -2,43 +2,42 @@// SPDX-License-Identifier: Apache-2.0//-#include "intel_gpu/runtime/debug_configuration.hpp"--#include "pass_manager.h"-#include "program_helpers.h"+#include <list>+#include <utility>+#include <vector>-#include "reshape_inst.h"-#include "convert_color_inst.h"-#include "one_hot_inst.h"-#include "shape_of_inst.h"-#include "gather_inst.h"-#include "select_inst.h"-#include "eltwise_inst.h"#include "broadcast_inst.h"-#include "permute_inst.h"-#include "depth_to_space_inst.h"#include "concatenation_inst.h"-#include "region_yolo_inst.h"+#include "convert_color_inst.h"+#include "depth_to_space_inst.h"+#include "eltwise_inst.h"#include "fully_connected_inst.h"+#include "gather_inst.h"#include "group_normalization_inst.h"+#include "intel_gpu/runtime/debug_configuration.hpp"#include "mvn_inst.h"+#include "one_hot_inst.h"+#include "pass_manager.h"+#include "permute_inst.h"+#include "program_helpers.h"+#include "region_yolo_inst.h"+#include "reshape_inst.h"#include "rms_inst.h"--#include <vector>-#include <list>-#include <utility>+#include "select_inst.h"+#include "shape_of_inst.h"using namespace cldnn;-#define LOG_NODE_REMOVAL(id) GPU_DEBUG_LOG_PASS << __func__ << ":" << __LINE__ << ": remove node: " << (id) << std::endl;-#define LOG_NODE_REPLACEMENT(id) GPU_DEBUG_LOG_PASS << __func__ << ":" << __LINE__ << ": replace node: " << (id) << std::endl;+#define LOG_NODE_REMOVAL(id) GPU_DEBUG_LOG_PASS << __func__ << ":" << __LINE__ << ": remove node: " << (id) << std::endl;+#define LOG_NODE_REPLACEMENT(id) GPU_DEBUG_LOG_PASS << __func__ << ":" << __LINE__ << ": replace node: " << (id) << std::endl;namespace {bool does_any_user_have_impl_type(program_node& node, impl_types impl) {for (const auto& user : node.get_users()) {- if (user->get_preferred_impl_type() == impl)+ if (user->get_preferred_impl_type() == impl) {return true;+ }}return false;@@ -46,16 +45,18 @@ bool does_any_user_have_impl_type(program_node& node, impl_types impl) {} // namespace-remove_redundant_reorders::remove_redundant_reorders(bool enable_reorder_fusing, bool update_implementations,- bool remove_output_reorders)- : base_pass("remove_redundant_reorders"), enable_reorder_fusing(enable_reorder_fusing), update_implementations(update_implementations),- remove_output_reorders(remove_output_reorders) {}+remove_redundant_reorders::remove_redundant_reorders(bool enable_reorder_fusing, bool update_implementations, bool remove_output_reorders)+ : base_pass("remove_redundant_reorders"),+ enable_reorder_fusing(enable_reorder_fusing),+ update_implementations(update_implementations),+ remove_output_reorders(remove_output_reorders) {}void remove_redundant_reorders::run(program& p) {auto& lo = p.get_layout_optimizer();auto update_implementation = [&](program_node& node) {- if (!update_implementations)+ if (!update_implementations) {return;+ }node.set_unique_id();node.set_selected_impl(node.type()->create_impl(node));@@ -70,41 +71,47 @@ void remove_redundant_reorders::run(program& p) {if (enable_reorder_fusing) {while (itr != p.get_processing_order().end()) {auto* node_ptr = *itr++;- if (!node_ptr->is_type<reorder>()) // only care for reorders+ if (!node_ptr->is_type<reorder>()) { // only care for reorderscontinue;+ }auto& node = node_ptr->as<reorder>();auto& input = node.input();auto output_layout = node.get_output_layout();- if (!node.is_simple_reorder() || node.is_output())+ if (!node.is_simple_reorder() || node.is_output()) {continue;+ }std::function<bool(program_node&)> has_quantize_user;has_quantize_user = [&has_quantize_user](program_node& node) -> bool {const auto& users = node.get_users();- if (users.size() != 1)+ if (users.size() != 1) {return false;- if (users.front()->is_type<quantize>())+ }+ if (users.front()->is_type<quantize>()) {return true;- if (users.front()->is_type<reorder>())+ }+ if (users.front()->is_type<reorder>()) {return has_quantize_user(*users.front());+ }return false;};// Avoid different data types between input and outputauto same_data_type = input.get_output_layout().data_type == output_layout.data_type;- auto i8_u8_input = input.get_output_layout().data_type == data_types::i8 ||- input.get_output_layout().data_type == data_types::u8;+ auto i8_u8_input = input.get_output_layout().data_type == data_types::i8 || input.get_output_layout().data_type == data_types::u8;auto quantize_user = has_quantize_user(node);- if (!same_data_type && (!i8_u8_input || !quantize_user))+ if (!same_data_type && (!i8_u8_input || !quantize_user)) {continue;+ }// Avoid optimization of nv12 reorder- if (node.get_dependencies().size() != 1 || node.get_primitive()->has_surface_input())+ if (node.get_dependencies().size() != 1 || node.get_primitive()->has_surface_input()) {continue;+ }bool all_users_fuse = true;std::vector<program_node*> recalc_list;@@ -115,24 +122,28 @@ void remove_redundant_reorders::run(program& p) {break;}- if (usr->is_type<fully_connected>())+ if (usr->is_type<fully_connected>()) {recalc_list.push_back(usr);+ }}- if (!all_users_fuse)+ if (!all_users_fuse) {continue;+ }auto output_padded = static_cast<bool>(output_layout.data_padding);auto can_omit_padding = ((output_layout.format == format::b_fs_yx_fsv16 || output_layout.format == format::b_fs_yx_fsv32) &&- (input.get_output_layout().format == format::bfyx || input.get_output_layout().format == format::b_fs_yx_fsv4)) ||+ (input.get_output_layout().format == format::bfyx || input.get_output_layout().format == format::b_fs_yx_fsv4)) ||(output_layout.format == format::b_fs_zyx_fsv16 && input.get_output_layout().format == format::bfzyx);if (output_padded && !can_omit_padding) {- if (input.get_users().size() != 1)+ if (input.get_users().size() != 1) {continue;+ }- if (input.is_type<input_layout>())+ if (input.is_type<input_layout>()) {continue;+ }input.merge_output_padding(output_layout.data_padding);}@@ -151,27 +162,27 @@ void remove_redundant_reorders::run(program& p) {itr = p.get_processing_order().begin();while (itr != p.get_processing_order().end()) {auto* node = *itr++;- if (!node->is_type<reorder>()) // only care for reorders+ if (!node->is_type<reorder>()) { // only care for reorderscontinue;+ }auto& r_node = node->as<reorder>();// Do not opt out result reorder of Loop body networkbool is_loop_body_network_output = (r_node.get_program().is_body_program() && r_node.is_output());- if (is_loop_body_network_output)+ if (is_loop_body_network_output) {continue;+ }auto& dep_node = r_node.get_dependency(0);- if (!dep_node.is_type<reorder>())+ if (!dep_node.is_type<reorder>()) {continue;+ }auto& r_dep_node = dep_node.as<reorder>();- bool remove_dep = r_dep_node.is_simple_reorder() &&- r_dep_node.get_users().size() == 1 &&- !r_dep_node.is_output() &&- !r_dep_node.get_primitive()->has_surface_input() &&- !r_node.get_primitive()->weights_reorder_params;+ bool remove_dep = r_dep_node.is_simple_reorder() && r_dep_node.get_users().size() == 1 && !r_dep_node.is_output() &&+ !r_dep_node.get_primitive()->has_surface_input() && !r_node.get_primitive()->weights_reorder_params;// for chains like// fp32 -> reorder -> u8 -> reorder -> fp32@@ -181,11 +192,8 @@ void remove_redundant_reorders::run(program& p) {continue;}- bool remove_current = r_node.is_simple_reorder() &&- r_dep_node.get_users().size() == 1 &&- !r_dep_node.is_output() &&- !r_node.get_primitive()->has_surface_input() &&- r_node.get_input_layout().data_padding == r_node.get_output_layout().data_padding;+ bool remove_current = r_node.is_simple_reorder() && r_dep_node.get_users().size() == 1 && !r_dep_node.is_output() &&+ !r_node.get_primitive()->has_surface_input() && r_node.get_input_layout().data_padding == r_node.get_output_layout().data_padding;if (remove_dep) {// for chains like@@ -196,8 +204,9 @@ void remove_redundant_reorders::run(program& p) {// b_fs_yx_fsv16 -> reorder(ofmt:bfyx) -> bfyxauto output_layout = r_dep_node.get_output_layout();auto prim = std::const_pointer_cast<reorder>(r_node.get_primitive());- if (prim->output_format == format::any)+ if (prim->output_format == format::any) {prim->output_format = output_layout.format;+ }LOG_NODE_REMOVAL(r_dep_node.id());r_dep_node.can_be_optimized(true);@@ -227,40 +236,40 @@ void remove_redundant_reorders::run(program& p) {itr = p.get_processing_order().begin();while (itr != p.get_processing_order().end()) {auto* node = *itr++;- if (!node->is_type<reorder>())+ if (!node->is_type<reorder>()) {continue;+ }auto& r_node = node->as<reorder>();- if (!r_node.get_primitive()->has_surface_input() ||- r_node.is_output() ||- r_node.has_mean() ||- r_node.get_users().size() > 1 ||- !r_node.get_primitive()->subtract_per_feature.empty() ||- r_node.has_fused_primitives())+ if (!r_node.get_primitive()->has_surface_input() || r_node.is_output() || r_node.has_mean() || r_node.get_users().size() > 1 ||+ !r_node.get_primitive()->subtract_per_feature.empty() || r_node.has_fused_primitives()) {continue;+ }- if (!r_node.get_users().front()->is_type<concatenation>())+ if (!r_node.get_users().front()->is_type<concatenation>()) {continue;+ }auto& concat_node = r_node.get_users().front()->as<concatenation>();- if (concat_node.get_output_layout().batch() == 1)+ if (concat_node.get_output_layout().batch() == 1) {continue;+ }- if (!concat_node.get_users().front()->is_type<reorder>())+ if (!concat_node.get_users().front()->is_type<reorder>()) {continue;+ }auto& r_node_next = concat_node.get_users().front()->as<reorder>();- if (r_node.get_output_layout().data_type == r_node_next.get_output_layout().data_type)+ if (r_node.get_output_layout().data_type == r_node_next.get_output_layout().data_type) {continue;+ }auto new_layout = r_node.get_output_layout();new_layout.data_type = r_node_next.get_output_layout().data_type;auto orig_reorder_prim = r_node.get_primitive();- auto new_reorder_prim = std::make_shared<reorder>(r_node.id() + "_fused",- orig_reorder_prim->input[0],- new_layout);+ auto new_reorder_prim = std::make_shared<reorder>(r_node.id() + "_fused", orig_reorder_prim->input[0], new_layout);new_reorder_prim->input_mem_type = orig_reorder_prim->input_mem_type;auto& new_reorder_node = p.get_or_create(new_reorder_prim);@@ -274,18 +283,20 @@ void remove_redundant_reorders::run(program& p) {itr = p.get_processing_order().begin();while (itr != p.get_processing_order().end()) {auto* node = *itr++;- if (!node->is_type<reorder>()) // only care for reorders+ if (!node->is_type<reorder>()) { // only care for reorderscontinue;+ }- if (node->is_dynamic())+ if (node->is_dynamic()) {continue;+ }auto& r_node = node->as<reorder>();auto& dep_node = r_node.get_dependency(0);- bool no_output_optimization = remove_output_reorders ?- r_node.is_output() && (dep_node.is_output() || dep_node.is_type<input_layout>() ||- dep_node.can_be_optimized() || dep_node.get_users().size() != 1) : r_node.is_output();+ bool no_output_optimization = remove_output_reorders ? r_node.is_output() && (dep_node.is_output() || dep_node.is_type<input_layout>() ||+ dep_node.can_be_optimized() || dep_node.get_users().size() != 1)+ : r_node.is_output();// Do not opt out result reorder of Loop body networkno_output_optimization |= (r_node.get_program().is_body_program() && r_node.is_output());@@ -305,40 +316,34 @@ void remove_redundant_reorders::run(program& p) {}}- if (!r_node.is_simple_reorder() ||- no_output_optimization ||- r_node.get_primitive()->has_surface_input())+ if (!r_node.is_simple_reorder() || no_output_optimization || r_node.get_primitive()->has_surface_input()) {continue;+ }auto o_layout = r_node.get_output_layout();const auto& i_layout = r_node.get_input_layout(0);auto is_r_node_rank_changed = r_node.get_output_layout().get_rank() != dep_node.get_output_layout().get_rank();- if (is_r_node_rank_changed &&- ((!update_implementations && dep_node.is_type<crop>()) ||- (dep_node.is_type<crop>() && dep_node.can_be_optimized())))+ if (is_r_node_rank_changed && ((!update_implementations && dep_node.is_type<crop>()) || (dep_node.is_type<crop>() && dep_node.can_be_optimized()))) {continue;+ }// Optimize reorder b_fs_yx_fsv16 -> bfyx when spatials are equal to 1. In this case we can reinterpret buffer,// but pads need to be handled correctly.- if (i_layout.format == format::b_fs_yx_fsv16 && o_layout.format == format::bfyx && !r_node.is_output() &&- i_layout.spatial(0) == 1 && i_layout.spatial(1) == 1 &&- i_layout.data_padding._upper_size[2] == 0 && i_layout.data_padding._lower_size[2] == 0 &&- i_layout.data_padding._upper_size[3] == 0 && i_layout.data_padding._lower_size[3] == 0 &&- !o_layout.data_padding &&- i_layout.data_type == o_layout.data_type &&- !does_any_user_have_impl_type(r_node, impl_types::onednn)) {+ if (i_layout.format == format::b_fs_yx_fsv16 && o_layout.format == format::bfyx && !r_node.is_output() && i_layout.spatial(0) == 1 &&+ i_layout.spatial(1) == 1 && i_layout.data_padding._upper_size[2] == 0 && i_layout.data_padding._lower_size[2] == 0 &&+ i_layout.data_padding._upper_size[3] == 0 && i_layout.data_padding._lower_size[3] == 0 && !o_layout.data_padding &&+ i_layout.data_type == o_layout.data_type && !does_any_user_have_impl_type(r_node, impl_types::onednn)) {// If the newly aligned pad is merged into output layout during post_optimize_graph phase// and then buffer is reinterpreted, user node cannot handle pad properly for kernel execution- if (!update_implementations || (i_layout.feature() % 16 == 0 &&- !i_layout.data_padding && !o_layout.data_padding) || i_layout.batch() == 1) {+ if (!update_implementations || (i_layout.feature() % 16 == 0 && !i_layout.data_padding && !o_layout.data_padding) || i_layout.batch() == 1) {r_node.can_be_optimized(true);r_node.requires_reinterpret(true);std::vector<ov::Dimension::value_type> pad_lo(o_layout.data_padding._lower_size.begin(),- o_layout.data_padding._lower_size.begin() + o_layout.get_rank());+ o_layout.data_padding._lower_size.begin() + o_layout.get_rank());std::vector<ov::Dimension::value_type> pad_hi(o_layout.data_padding._upper_size.begin(),- o_layout.data_padding._upper_size.begin() + o_layout.get_rank());+ o_layout.data_padding._upper_size.begin() + o_layout.get_rank());pad_lo[0] = i_layout.data_padding._lower_size[0];pad_hi[0] = i_layout.data_padding._upper_size[0];@@ -355,11 +360,13 @@ void remove_redundant_reorders::run(program& p) {}}- if (!o_layout.compatible(i_layout))+ if (!o_layout.compatible(i_layout)) {continue;+ }- if (r_node.is_output() && i_layout.get_linear_size() != o_layout.get_linear_size())+ if (r_node.is_output() && i_layout.get_linear_size() != o_layout.get_linear_size()) {continue;+ }// mark as optimizedr_node.can_be_optimized(true);@@ -374,8 +381,7 @@ void remove_redundant_reorders::run(program& p) {}LOG_NODE_REMOVAL(r_node.id());- p.extract_and_remove(- r_node); // try to remove if possible (with respect to r_node not being marked as output)+ p.extract_and_remove(r_node); // try to remove if possible (with respect to r_node not being marked as output)}}@@ -383,48 +389,52 @@ void remove_redundant_reorders::run(program& p) {itr = p.get_processing_order().begin();while (itr != p.get_processing_order().end()) {const auto& node = *itr++;- if (!node->is_type<reorder>())+ if (!node->is_type<reorder>()) {continue;+ }std::list<program_node*> r_nodes_to_remove;- if (node->get_dependencies().size() != 1)+ if (node->get_dependencies().size() != 1) {continue;+ }- if (node->has_fused_primitives())+ if (node->has_fused_primitives()) {continue;+ }auto& dep = node->get_dependency(0);for (const auto& user : dep.get_users()) {- if (user->is_type<reorder>() &&- user != node &&- !user->is_output() &&- !user->has_fused_primitives()) {+ if (user->is_type<reorder>() && user != node && !user->is_output() && !user->has_fused_primitives()) {auto l1 = node->get_output_layout();auto l2 = user->get_output_layout();// in multiple outputs, remove redundant reorder is only allowed for same output port idxauto l1_port_idx = node->get_dependency_with_port(0).second;auto l2_port_idx = user->get_dependency_with_port(0).second;- if (l1.identical(l2) && (l1_port_idx == l2_port_idx))+ if (l1.identical(l2) && (l1_port_idx == l2_port_idx)) {r_nodes_to_remove.push_back(user);+ }}}- if (r_nodes_to_remove.empty())+ if (r_nodes_to_remove.empty()) {continue;+ }- if (itr == p.get_processing_order().end())+ if (itr == p.get_processing_order().end()) {break;+ }auto rem_itr = r_nodes_to_remove.begin();while (rem_itr != r_nodes_to_remove.end()) {auto* remove_reorder_node = *rem_itr++;// Outer loop iterator has been already moved, so if we try to remove a node which the iterator// pointing to, we should increment it again- if (remove_reorder_node == *itr)+ if (remove_reorder_node == *itr) {itr++;+ }LOG_NODE_REMOVAL(remove_reorder_node->id());p.replace_all_usages(*remove_reorder_node, *node);@@ -439,37 +449,42 @@ void remove_redundant_reorders::run(program& p) {if (enable_reorder_fusing) {while (itr != p.get_processing_order().end()) {const auto& node_ptr = *itr++;- if (!node_ptr->is_type<reorder>()) // only care for reorders+ if (!node_ptr->is_type<reorder>()) { // only care for reorderscontinue;+ }auto& node = node_ptr->as<reorder>();auto& input = node.input();auto output_layout = node.get_output_layout();- if (!node.is_simple_reorder())+ if (!node.is_simple_reorder()) {continue;+ }- if (input.get_users().size() != 1)+ if (input.get_users().size() != 1) {continue;+ }bool same_data_type = input.get_output_layout().data_type == output_layout.data_type;bool allowed_dt_conversion_fuse =- (input.is_type<one_hot>() || input.is_type<permute>() || input.is_type<mvn>() ||- input.is_type<fully_connected>() ||- input.is_type<concatenation>() || input.is_type<depth_to_space>() || input.is_type<region_yolo>() ||- input.is_type<detection_output>() || input.is_type<gather>() || input.is_type<broadcast>() ||- input.is_type<select>() || input.is_type<eltwise>() || input.is_type<rms>()) && !input.is_constant();- if (!same_data_type && !allowed_dt_conversion_fuse)+ (input.is_type<one_hot>() || input.is_type<permute>() || input.is_type<mvn>() || input.is_type<fully_connected>() ||+ input.is_type<concatenation>() || input.is_type<depth_to_space>() || input.is_type<region_yolo>() || input.is_type<detection_output>() ||+ input.is_type<gather>() || input.is_type<broadcast>() || input.is_type<select>() || input.is_type<eltwise>() || input.is_type<rms>()) &&+ !input.is_constant();+ if (!same_data_type && !allowed_dt_conversion_fuse) {continue;+ }- if (!lo.can_fuse_reorder_to_prev(input, node, input.get_output_layout().format, output_layout.format))+ if (!lo.can_fuse_reorder_to_prev(input, node, input.get_output_layout().format, output_layout.format)) {continue;+ }// Do not opt out result reorder of Loop body networkbool is_loop_body_network_output = (node.get_program().is_body_program() && node.is_output());- if (is_loop_body_network_output)+ if (is_loop_body_network_output) {continue;+ }auto old_output_layout_of_input = input.get_output_layout();input.set_output_layout(output_layout, false);@@ -477,10 +492,9 @@ void remove_redundant_reorders::run(program& p) {// Add fused_primitive_desc of reorder to the previous node which propagates original output layout// during shape inferenceconst bool is_onednn_fc = (input.get_preferred_impl_type() == impl_types::onednn) && input.is_type<fully_connected>();- if ((input.is_type<mvn>() || input.is_type<concatenation>() || input.is_type<gather>() ||- input.is_type<broadcast>() || input.is_type<select>() || input.is_type<eltwise>() ||- input.is_type<rms>() ||- (input.is_dynamic() && (input.is_type<group_normalization>() || input.is_type<permute>()))) ||+ if ((input.is_type<mvn>() || input.is_type<concatenation>() || input.is_type<gather>() || input.is_type<broadcast>() ||+ input.is_type<select>() || input.is_type<eltwise>() || input.is_type<rms>() ||+ (input.is_dynamic() && (input.is_type<group_normalization>() || input.is_type<permute>()))) ||is_onednn_fc) {fused_primitive_desc local_desc(node.get_primitive());local_desc.f_param = node.get_fuse_params();@@ -504,9 +518,10 @@ void remove_redundant_reorders::run(program& p) {itr = p.get_processing_order().begin();while (itr != p.get_processing_order().end()) {const auto& node_ptr = *itr++;- if (!node_ptr->is_type<reorder>() || !node_ptr->is_in_data_flow() || node_ptr->get_users().size() != 1 ||- node_ptr->get_dependencies().size() != 1 || node_ptr->is_dynamic())+ if (!node_ptr->is_type<reorder>() || !node_ptr->is_in_data_flow() || node_ptr->get_users().size() != 1 || node_ptr->get_dependencies().size() != 1 ||+ node_ptr->is_dynamic()) {continue;+ }auto& node = node_ptr->as<reorder>();auto prim_desc = node.get_primitive();@@ -515,19 +530,19 @@ void remove_redundant_reorders::run(program& p) {auto& dep = node_ptr->get_dependency(0);auto quantize_opt = usr->is_type<quantize>() &&- (dep.get_output_layout().format == format::b_fs_yx_fsv16 ||- dep.get_output_layout().format == format::bfyx ||- (dep.get_output_layout().format == format::fs_b_yx_fsv32 &&- !lo.has_all_enabled_onednn_impls_optimization_attribute()));+ (dep.get_output_layout().format == format::b_fs_yx_fsv16 || dep.get_output_layout().format == format::bfyx ||+ (dep.get_output_layout().format == format::fs_b_yx_fsv32 && !lo.has_all_enabled_onednn_impls_optimization_attribute()));auto convert_color_opt = usr->is_type<convert_color>() && prim_desc->has_surface_input();- if (!quantize_opt && !convert_color_opt)+ if (!quantize_opt && !convert_color_opt) {continue;+ }auto same_data_type = node.get_input_layout().data_type == node.get_output_layout().data_type;- if (!same_data_type && !convert_color_opt)+ if (!same_data_type && !convert_color_opt) {continue;+ }dep.merge_output_padding(node.get_output_layout().data_padding);@@ -540,48 +555,55 @@ void remove_redundant_reorders::run(program& p) {// Remove reorder for cldnn convolution bfyx -> fs_b_yx_fsv32. (no case for onednn)auto try_fuse_reorder_bfyx_to_fsv32 = [&](reorder_node* node) -> bool {- if (node->get_users().size() != 1)+ if (node->get_users().size() != 1) {return false;+ }const auto& usr = node->get_users().front();auto& dep = node->get_dependency(0);- auto dep_layout = dep.get_output_layout();+ auto dep_layout = dep.get_output_layout();- if (!(usr->is_type<convolution>()) ||- node->get_output_layout().data_type != dep_layout.data_type ||- dep_layout.format != format::bfyx)+ if (!(usr->is_type<convolution>()) || node->get_output_layout().data_type != dep_layout.data_type || dep_layout.format != format::bfyx) {return false;- if (usr->as<convolution>().get_preferred_impl_type() == impl_types::onednn)+ }+ if (usr->as<convolution>().get_preferred_impl_type() == impl_types::onednn) {return false;- if (usr->get_output_layout().format != format::fs_b_yx_fsv32)+ }+ if (usr->get_output_layout().format != format::fs_b_yx_fsv32) {return false;+ }- if (dep.is_type<input_layout>())+ if (dep.is_type<input_layout>()) {return false;+ }- // Skip reorder padding fusing when any one of sibling nodes is optimized out or doesn't support padding.+ // Skip reorder padding fusing when any one of sibling nodes is optimized+ // out or doesn't support padding.if (node->get_output_layout().data_padding) {- if (update_implementations)+ if (update_implementations) {return false;+ }for (auto* user : dep.get_users()) {if (user != node) {- if (user->can_be_optimized())+ if (user->can_be_optimized()) {return false;+ }auto node_format = node->get_output_layout().format;auto sizes_in_format = layout::format_sizes(node->get_input_layout(0).data_padding._lower_size, node_format);for (size_t axis = 0; axis < sizes_in_format.size(); axis++) {- if (!user->is_padding_supported(static_cast<int>(axis),- static_cast<int>(sizes_in_format[axis])))+ if (!user->is_padding_supported(static_cast<int>(axis), static_cast<int>(sizes_in_format[axis]))) {return false;+ }}}}}- if (usr->as<convolution>().get_primitive()->groups != 1)+ if (usr->as<convolution>().get_primitive()->groups != 1) {return false;+ }dep.merge_output_padding(node->get_output_layout().data_padding);LOG_NODE_REMOVAL(node->id());@@ -597,27 +619,29 @@ void remove_redundant_reorders::run(program& p) {auto try_fuse_reorder_fsv16_to_bfyx = [&](reorder_node* node) -> bool {auto& input = node->input();- if (!(input.is_type<convolution>()) ||- (input.is_dynamic()) ||- !(input.get_output_layout().format == format::b_fs_yx_fsv16) ||- !(node->get_output_layout().format == format::bfyx))+ if (!(input.is_type<convolution>()) || (input.is_dynamic()) || !(input.get_output_layout().format == format::b_fs_yx_fsv16) ||+ !(node->get_output_layout().format == format::bfyx)) {return false;+ }- if (input.as<convolution>().get_primitive()->groups != 1)+ if (input.as<convolution>().get_primitive()->groups != 1) {return false;+ }// Avoid onednn convolution selects ref kernel for fsv16 -> bfyx- if (input.as<convolution>().get_preferred_impl_type() == impl_types::onednn)+ if (input.as<convolution>().get_preferred_impl_type() == impl_types::onednn) {return false;+ }- if (input.get_users().size() != 1)+ if (input.get_users().size() != 1) {return false;+ }auto& input_dep = input.get_dependency(0);- if (input_dep.get_output_layout().format != format::b_fs_yx_fsv16 ||- input_dep.get_output_layout().data_type == data_types::u8 ||- input_dep.get_output_layout().data_type == data_types::i8)+ if (input_dep.get_output_layout().format != format::b_fs_yx_fsv16 || input_dep.get_output_layout().data_type == data_types::u8 ||+ input_dep.get_output_layout().data_type == data_types::i8) {return false;+ }for (const auto& user : node->get_users()) {// if concat is reorder's user and concat's axis is 0(Batch) or 1(Feature), conv's output would have padding.@@ -625,8 +649,9 @@ void remove_redundant_reorders::run(program& p) {if (user->is_type<concatenation>()) {auto& concat_node = user->as<concatenation>();auto concat_axis = concat_node.get_primitive()->axis;- if (concat_axis == 0 || concat_axis == 1)+ if (concat_axis == 0 || concat_axis == 1) {return false;+ }}}@@ -654,32 +679,36 @@ void remove_redundant_reorders::run(program& p) {}input.set_output_layout(old_output_layout_of_input, false);return false;-};if (enable_reorder_fusing) {itr = p.get_processing_order().begin();while (itr != p.get_processing_order().end()) {const auto& node = *itr++;- if (!node->is_type<reorder>())+ if (!node->is_type<reorder>()) {continue;+ }auto& r_node = node->as<reorder>();- if (!r_node.is_in_data_flow() || r_node.get_dependencies().size() != 1)+ if (!r_node.is_in_data_flow() || r_node.get_dependencies().size() != 1) {continue;+ }- if (!r_node.is_simple_reorder())+ if (!r_node.is_simple_reorder()) {continue;+ }// Remove reorder for Convolution bfyx -> fs_b_yx_fsv32// Process remaining patterns here that are not removed at the first while loop// e.g., reorder with otuput padding- if (try_fuse_reorder_bfyx_to_fsv32(&r_node))+ if (try_fuse_reorder_bfyx_to_fsv32(&r_node)) {continue;+ }// Remove reorder for Convolution b_fs_yx_fsv16 -> bfyx- if (try_fuse_reorder_fsv16_to_bfyx(&r_node))+ if (try_fuse_reorder_fsv16_to_bfyx(&r_node)) {continue;+ }}}@@ -691,33 +720,34 @@ void remove_redundant_reorders::run(program& p) {itr = p.get_processing_order().begin();while (itr != p.get_processing_order().end()) {auto* node = *itr++;- if (!node->is_type<reshape>())+ if (!node->is_type<reshape>()) {continue;+ }auto& reshape_node = node->as<reshape>();auto& dep_node = reshape_node.get_dependency(0);- if (!dep_node.is_type<reshape>())+ if (!dep_node.is_type<reshape>()) {continue;+ }auto& reshape_input_node = dep_node.as<reshape>();// In case of new shape infer we should not shrink reshapes chain if first reshape changes input rank, e.g.// [a, b] -> reshape1 -> [a1, b1, c1] -> reshape2 -> [a2, b2, 0] and any of the reshapes has special_zero=true// Configuration above will fail if we remove reshape1 node as attempt to handle special zero will fail due to small rank of input- if (p.is_new_shape_infer() &&- reshape_node.get_output_pshape().size() != dep_node.get_input_pshape().size() &&- (reshape_node.get_primitive()->special_zero || reshape_input_node.get_primitive()->special_zero))+ if (p.is_new_shape_infer() && reshape_node.get_output_pshape().size() != dep_node.get_input_pshape().size() &&+ (reshape_node.get_primitive()->special_zero || reshape_input_node.get_primitive()->special_zero)) {continue;+ }- if (reshape_node.is_dynamic())+ if (reshape_node.is_dynamic()) {continue;+ }- bool remove_dep = reshape_input_node.get_users().size() == 1 && !reshape_input_node.is_output() &&- !reshape_input_node.has_fused_primitives();+ bool remove_dep = reshape_input_node.get_users().size() == 1 && !reshape_input_node.is_output() && !reshape_input_node.has_fused_primitives();bool remove_current = remove_dep && !reshape_input_node.get_dependencies().empty() &&- reshape_input_node.get_input_layout(0) == reshape_node.get_output_layout() &&- !reshape_node.has_fused_primitives();+ reshape_input_node.get_input_layout(0) == reshape_node.get_output_layout() && !reshape_node.has_fused_primitives();if (remove_dep) {LOG_NODE_REMOVAL(reshape_input_node.id());@@ -738,10 +768,10 @@ void remove_redundant_reorders::run(program& p) {itr = p.get_processing_order().begin();while (itr != p.get_processing_order().end()) {const auto& node = *itr++;- if (!node->is_type<reorder>() || node->has_fused_primitives() ||- !node->is_in_data_flow() || node->get_users().size() != 1 ||- !node->get_users().front()->is_type<shape_of>())+ if (!node->is_type<reorder>() || node->has_fused_primitives() || !node->is_in_data_flow() || node->get_users().size() != 1 ||+ !node->get_users().front()->is_type<shape_of>()) {continue;+ }auto& dep = node->get_dependency(0);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.cppindex 4ecafbbd4fb..5508705612b 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@@ -699,15 +699,17 @@ void reorder_inputs::run(program& p, reorder_factory& rf) {auto expected_format = format::any;if (data_type_traits::is_i8_u8(d_layout.data_type)) {- if (d_format == format::b_fs_yx_fsv16)+ if (d_format == format::b_fs_yx_fsv16) {expected_format = format::b_fs_yx_fsv32;- else if (d_format == format::bs_fs_yx_bsv32_fsv16)+ } else if (d_format == format::bs_fs_yx_bsv32_fsv16) {expected_format = format::bs_fs_yx_bsv32_fsv32;+ }} else if (data_type_traits::is_floating_point(d_layout.data_type)) {- if (d_format == format::b_fs_yx_fsv32)+ if (d_format == format::b_fs_yx_fsv32) {expected_format = format::b_fs_yx_fsv16;- else if (d_format == format::bs_fs_yx_bsv32_fsv32)+ } else if (d_format == format::bs_fs_yx_bsv32_fsv32) {expected_format = format::bs_fs_yx_bsv32_fsv16;+ }}if (expected_format != format::any && d_layout.format != expected_format) {diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/reorder_transfer.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/reorder_transfer.cppindex c879fa06dc8..c3ba5c4c358 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/reorder_transfer.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/reorder_transfer.cpp@@ -14,8 +14,9 @@ void reorder_transfer::run(program& p) {while (itr != p.get_processing_order().end()) {const auto& node = *itr++;- if (!node->is_type<reorder>())+ if (!node->is_type<reorder>()) {continue;+ }auto& reorder_node = node->as<reorder>();@@ -24,8 +25,9 @@ void reorder_transfer::run(program& p) {reorder_node.get_users().size() == 1 &&reorder_node.get_dependencies().size() == 1 &&reorder_node.is_type_conversion_only();- if (!is_simple_type_conversion_reorder)+ if (!is_simple_type_conversion_reorder) {continue;+ }auto transfer_through_node = [](cldnn::program_node* node) -> bool { // Conditions can be extended to other opsreturn node->is_type<permute>() &&diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/select_preferred_formats.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/select_preferred_formats.cppindex 15a226a3bdf..d627e5a1486 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/select_preferred_formats.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/select_preferred_formats.cpp@@ -66,26 +66,31 @@ static void optimize_conv_permute(program_node& node) {static void optimize_permute_conv(program_node& node) {// Goal: Eliminate the Reorder by aligning connection to byxf- if (node.get_dependencies().empty())+ if (node.get_dependencies().empty()) {return;+ }auto& dep = node.get_dependency(0);// Dependency must be a Permute node (not network output)- if (!dep.is_type<permute>() || dep.is_output())+ if (!dep.is_type<permute>() || dep.is_output()) {return;+ }- if ((node.get_users().size() != 1) || (node.get_output_layout().get_rank() != 4))+ if ((node.get_users().size() != 1) || (node.get_output_layout().get_rank() != 4)) {return;+ }auto& pnode = dep.as<permute>();- if (pnode.get_output_layout().data_type != node.get_output_layout().data_type)+ if (pnode.get_output_layout().data_type != node.get_output_layout().data_type) {return;+ }// NHWC <-> NCHW (ensures reverse rotation pattern)- if (!pnode.is_reverse_rotating_except_batch())+ if (!pnode.is_reverse_rotating_except_batch()) {return;+ }auto pnode_upstream_fmt = pnode.get_dependency(0).get_preferred_output_fmt();auto node_fmt = node.get_preferred_output_fmt();@@ -93,8 +98,9 @@ static void optimize_permute_conv(program_node& node) {bool is_compatible_format = ((pnode_upstream_fmt == format::bfyx || pnode_upstream_fmt == format::any)&& (node_fmt == format::byxf));- if (!is_compatible_format)+ if (!is_compatible_format) {return;+ }// Set the layouts so that the memory buffer is re-interpreted rather than physically shuffled.node.set_preferred_input_fmt(0, format::byxf);diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/skipped_branch_memory_dependencies.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/skipped_branch_memory_dependencies.cppindex f3faded3bfb..8fa8d436721 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/skipped_branch_memory_dependencies.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/skipped_branch_memory_dependencies.cpp@@ -19,17 +19,20 @@ void skipped_branch_memory_dependencies::run(program& p) {while (itrB != processing_order.end()) {const auto& nodeB = *itrB;auto itrA = ++itrB;- if (!nodeB->may_use_mempool())+ if (!nodeB->may_use_mempool()) {continue;- if (nodeB->get_users().empty())+ }+ if (nodeB->get_users().empty()) {continue;+ }// find the last user of B in processing orderauto itrUsr = nodeB->get_users().begin();auto lastUsr = itrUsr++;while (itrUsr != nodeB->get_users().end()) {- if (processing_order.get_processing_number(*lastUsr) < processing_order.get_processing_number(*itrUsr))+ if (processing_order.get_processing_number(*lastUsr) < processing_order.get_processing_number(*itrUsr)) {lastUsr = itrUsr;+ }itrUsr++;}diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/trim_to_outputs.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/trim_to_outputs.cppindex f70dd15f09e..9e128654e49 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/trim_to_outputs.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/trim_to_outputs.cpp@@ -6,9 +6,10 @@// ToDo: remove those include with the appropriate code below once we will have support for multiple outputs of a// primitive-#include "pooling_inst.h"-#include <vector>#include <queue>+#include <vector>++#include "pooling_inst.h"using namespace cldnn;@@ -25,9 +26,9 @@ void trim_to_outputs::run(program& p) {std::vector<program_node*> special_nodes;for (const auto& node : p.get_processing_order()) { // input layout may become disconnected during prior boxes calculations so- if (node->is_type<input_layout>()) { // it may have not been marked at this place but we don't want to remove it- special_nodes.push_back(node); // ToDo: remove this after support for multi-outputs in primitives will- } // be implemented.+ if (node->is_type<input_layout>()) { // it may have not been marked at this place but we don't want to remove it+ special_nodes.push_back(node); // ToDo: remove this after support for multi-outputs in primitives will+ } // be implemented.}queue.push(special_nodes);@@ -39,10 +40,10 @@ void trim_to_outputs::run(program& p) {if (!node->is_marked()) {node->mark();if (!node->get_dependencies().empty()) {- std::vector<program_node*> deps;- for (const auto& dep : node->get_dependencies()) {- deps.push_back(dep.first);- }+ std::vector<program_node*> deps;+ for (const auto& dep : node->get_dependencies()) {+ deps.push_back(dep.first);+ }queue.push(deps);}}@@ -52,8 +53,9 @@ void trim_to_outputs::run(program& p) {// all not-marked nodes should be removedstd::vector<program_node*> to_rem;for (const auto& node : p.get_processing_order()) {- if (!node->is_marked())+ if (!node->is_marked()) {to_rem.push_back(node);+ }}p.remove_nodes(to_rem);diff --git a/src/plugins/intel_gpu/src/graph/group_normalization.cpp b/src/plugins/intel_gpu/src/graph/group_normalization.cppindex 7c40377e89b..3876cd918e8 100644--- a/src/plugins/intel_gpu/src/graph/group_normalization.cpp+++ b/src/plugins/intel_gpu/src/graph/group_normalization.cpp@@ -15,8 +15,9 @@ layout group_normalization_inst::calc_output_layout(group_normalization_node conauto input_node_layout = impl_param.get_non_padded_input_layout();auto output_type = impl_param.desc->output_data_types[0].value_or(input_node_layout.data_type);- if (impl_param.has_fused_primitives())+ if (impl_param.has_fused_primitives()) {output_type = impl_param.get_output_element_type();+ }return layout(output_type, input_node_layout.format, input_node_layout.get_tensor());}diff --git a/src/plugins/intel_gpu/src/graph/grouped_matmul.cpp b/src/plugins/intel_gpu/src/graph/grouped_matmul.cppindex 1c294a70379..86a0166a376 100644--- a/src/plugins/intel_gpu/src/graph/grouped_matmul.cpp+++ b/src/plugins/intel_gpu/src/graph/grouped_matmul.cpp@@ -50,8 +50,9 @@ std::string grouped_matmul_inst::to_string(grouped_matmul_node const& node) {std::stringstream primitive_description;json_composite info;- if (desc->output_data_types[0].has_value())+ if (desc->output_data_types[0].has_value()) {info.add("out dt: ", dt_to_str(*desc->output_data_types[0]));+ }node_info->add("grouped_matmul_info", info);node_info->dump(primitive_description);diff --git a/src/plugins/intel_gpu/src/graph/impls/cm/paged_attention.cpp b/src/plugins/intel_gpu/src/graph/impls/cm/paged_attention.cppindex ca77c517d40..ece8e2f9a8d 100644--- a/src/plugins/intel_gpu/src/graph/impls/cm/paged_attention.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/cm/paged_attention.cpp@@ -504,8 +504,9 @@ public:void prepare_xattn_metadata(primitive_inst& instance) {auto* rt_params = static_cast<PagedAttentionRuntimeParams*>(m_rt_params.get());OPENVINO_ASSERT(rt_params != nullptr);- if (!rt_params->enable_xattn_estimation || m_xattn_meta.empty())+ if (!rt_params->enable_xattn_estimation || m_xattn_meta.empty()) {return;+ }auto& stream = instance.get_network().get_stream();auto meta_mem = instance.get_intermediates_memories()[PagedAttentionInternBuffIdx::XATTN_SUBSEQ_META];@@ -781,12 +782,14 @@ private:auto validate_input = [&](size_t idx, const char* name) {const auto it = input_mem.find(idx);- if (it == input_mem.end() || it->second == nullptr)+ if (it == input_mem.end() || it->second == nullptr) {OPENVINO_THROW("XAttention ", name, " input is required at index ", idx);+ }const auto input_size = it->second->count();- if (input_size != 1 && input_size != batch_size)+ if (input_size != 1 && input_size != batch_size) {OPENVINO_THROW("XAttention ", name, " input size (", input_size, ") must be 1 or equal to batch size (", batch_size, ")");+ }};validate_input(PagedAttentionInputIdx::XATTENTION_BLOCK_SIZE, "block size");diff --git a/src/plugins/intel_gpu/src/graph/impls/cm/paged_attention_gen.cpp b/src/plugins/intel_gpu/src/graph/impls/cm/paged_attention_gen.cppindex 203d56fdda0..a19fe8f3b63 100644--- a/src/plugins/intel_gpu/src/graph/impls/cm/paged_attention_gen.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/cm/paged_attention_gen.cpp@@ -548,8 +548,9 @@ JitConstants PagedAttentionGeneratorSingleTokenFinalization::get_jit_constants(cArguments PagedAttentionGeneratorSingleTokenFinalization::get_arguments_desc(const kernel_impl_params& params) const {Arguments args;const auto has_scores_output = params.output_layouts.size() > 1;- if (has_scores_output)+ if (has_scores_output) {OPENVINO_THROW("[GPU][CM] PagedAttentionGeneratorSingleTokenFinalization with scores output is not supported yet");+ }args.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, PagedAttentionInternBuffIdx::DECODE_PARTITIONOUT}); // partition dataargs.push_back({ArgumentDescriptor::Types::OUTPUT, 0}); // output@@ -727,8 +728,9 @@ JitConstants PagedAttentionGeneratorSmallQFinalization::get_jit_constants(constArguments PagedAttentionGeneratorSmallQFinalization::get_arguments_desc(const kernel_impl_params& params) const {Arguments args;const auto has_scores_output = params.output_layouts.size() > 1;- if (has_scores_output)+ if (has_scores_output) {OPENVINO_THROW("[GPU][CM] PagedAttentionGeneratorSmallQFinalization with scores output is not supported yet");+ }args.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, PagedAttentionInternBuffIdx::SMALL_Q_PARTITIONOUT});args.push_back({ArgumentDescriptor::Types::OUTPUT, 0});diff --git a/src/plugins/intel_gpu/src/graph/impls/cm/paged_attention_gen.hpp b/src/plugins/intel_gpu/src/graph/impls/cm/paged_attention_gen.hppindex f052e8f911f..731b49a72ea 100644--- a/src/plugins/intel_gpu/src/graph/impls/cm/paged_attention_gen.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/cm/paged_attention_gen.hpp@@ -68,8 +68,9 @@ inline SingleTokenQChunking get_single_token_q_chunking(const kernel_impl_paramsconst int32_t budget_bytes = reg_file_size * grf_bytes - 1;int32_t max_q_by_matrix = budget_bytes / (bytes_per_float * rs_cols);- if (max_q_by_matrix < 1)+ if (max_q_by_matrix < 1) {max_q_by_matrix = 1;+ }const int32_t target_chunk = std::min<int32_t>(MaxRepeatCount, max_q_by_matrix);diff --git a/src/plugins/intel_gpu/src/graph/impls/cm/vl_sdpa_opt.cpp b/src/plugins/intel_gpu/src/graph/impls/cm/vl_sdpa_opt.cppindex 1b565836714..6f4ba156aea 100644--- a/src/plugins/intel_gpu/src/graph/impls/cm/vl_sdpa_opt.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/cm/vl_sdpa_opt.cpp@@ -68,8 +68,9 @@ protected:// transpose shape into BHLS(4D), or HLS(3D)auto transpose_pshape = [](const ov::PartialShape& pshape, const std::vector<int64_t>& order) {- if (order.empty())+ if (order.empty()) {return pshape;+ }auto transposed_pshape = ov::PartialShape::dynamic(pshape.rank());for (size_t i = 0; i < order.size(); i++) {@@ -141,8 +142,9 @@ protected:// transpose shape into BHLS(4D), or HLS(3D)auto transpose_pshape = [](const ov::Shape& pshape, const std::vector<int64_t>& order) {- if (order.empty())+ if (order.empty()) {return pshape;+ }auto transposed_pshape = ov::Shape(pshape.size());for (size_t i = 0; i < order.size(); i++) {diff --git a/src/plugins/intel_gpu/src/graph/impls/common/condition.cpp b/src/plugins/intel_gpu/src/graph/impls/common/condition.cppindex 0fcda899d42..afbe04f6239 100644--- a/src/plugins/intel_gpu/src/graph/impls/common/condition.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/common/condition.cpp@@ -36,8 +36,9 @@ struct condition_impl : typed_primitive_impl<condition> {event::ptr execute_impl(const std::vector<event::ptr>& events, condition_inst& instance) override {// Wait for condition statement event only, and pass all other events to sub-network directly- if (!events.empty())+ if (!events.empty()) {events[0]->wait();+ }auto& stream = instance.get_network().get_stream();set_node_params(instance.get_node());@@ -46,8 +47,9 @@ struct condition_impl : typed_primitive_impl<condition> {network::ptr executed_net = pred ? instance.get_net_true() : instance.get_net_false();auto branch = pred ? instance.get_branch_true() : instance.get_branch_false();bool can_skip_subgraph = branch.inner_program->can_be_optimized();- if (!can_skip_subgraph)+ if (!can_skip_subgraph) {executed_net->set_shape_predictor(instance.get_network().get_shape_predictor());+ }GPU_DEBUG_LOG << "predicate: " << (pred ? "True" : "False") << std::endl;GPU_DEBUG_LOG << "can_skip_subgraph: " << (can_skip_subgraph ? "True" : "False") << std::endl;@@ -78,8 +80,9 @@ struct condition_impl : typed_primitive_impl<condition> {<< ", external: " << input_external_node->first << ")" << std::endl;for (size_t dep_idx = 0; dep_idx < instance.dependencies().size(); ++dep_idx) {if (instance.dependencies()[dep_idx].first->id() == input_external_node->first) {- if (events.size() > dep_idx)+ if (events.size() > dep_idx) {output_events.push_back(events[dep_idx]);+ }output_mem_ptr = instance.input_memory_ptr(dep_idx);output_layout = instance.dependencies()[dep_idx].first->get_output_layout();break;@@ -138,9 +141,11 @@ struct condition_impl : typed_primitive_impl<condition> {// Set output memory of condition_inst to inner network output memory after inner network executioninstance.postprocess_output_memory(executed_net, branch);- for (auto& output : sub_net_results)- if (output.second.get_event() != nullptr)+ for (auto& output : sub_net_results) {+ if (output.second.get_event() != nullptr) {output_events.push_back(output.second.get_event());+ }+ }return stream.group_events(output_events);}diff --git a/src/plugins/intel_gpu/src/graph/impls/common/loop.cpp b/src/plugins/intel_gpu/src/graph/impls/common/loop.cppindex edc6f569cb1..f4c4f2196a7 100644--- a/src/plugins/intel_gpu/src/graph/impls/common/loop.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/common/loop.cpp@@ -168,8 +168,9 @@ struct loop_impl : typed_primitive_impl<loop> {int64_t execution_condition = 1;if (!instance.get_initial_execution_id().empty()) {// Wait for completion of the execution_condition of outer_network- if (outer_network.has_event(instance.get_initial_execution_id()))+ if (outer_network.has_event(instance.get_initial_execution_id())) {outer_network.get_primitive_event(instance.get_initial_execution_id())->wait();+ }memory::ptr first_execution_condition_mem = outer_network.get_primitive(instance.get_initial_execution_id())->output_memory_ptr();execution_condition = read_scalar_value(first_execution_condition_mem, stream);}@@ -279,8 +280,9 @@ struct loop_impl : typed_primitive_impl<loop> {GPU_DEBUG_LOG << "current_iteration_idx(" << instance.get_num_iterations_id() << ", "<< num_actual_iterations_mem << ") : " << current_iteration_idx << std::endl;- if (is_dynamic)+ if (is_dynamic) {instance.update_output_layout();+ }instance.postprocess_output_memory(is_dynamic, current_iteration_idx);ev->set();diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/activation.cpp b/src/plugins/intel_gpu/src/graph/impls/cpu/activation.cppindex ea7041e2b9b..3d317652202 100644--- a/src/plugins/intel_gpu/src/graph/impls/cpu/activation.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/cpu/activation.cpp@@ -103,12 +103,14 @@ struct activation_impl : public typed_primitive_impl<activation> {const auto* params = instance.get_impl_params();std::vector<memory::ptr> input_mem_ptrs;- for (size_t i = 0; i < instance.dependencies().size(); i++)+ for (size_t i = 0; i < instance.dependencies().size(); i++) {input_mem_ptrs.push_back(instance.dep_memory_ptr(i));+ }// TODO: consider to re-implement lock/unlock in more exception-safetest way- for (size_t i = 0; i < input_mem_ptrs.size(); i++)+ for (size_t i = 0; i < input_mem_ptrs.size(); i++) {input_host_tensors.push_back(make_tensor(params->input_layouts[i], input_mem_ptrs[i]->lock(stream, mem_lock_type::read)));+ }// Most of the evaluate functions expect same data type for all inputs, so we need to convert params from floatauto param_a = static_cast<typename ov::element_type_traits<DT>::value_type>(additional_params.a);@@ -122,8 +124,9 @@ struct activation_impl : public typed_primitive_impl<activation> {input_host_tensors.push_back(ov::Tensor(input_dt, {}, ¶m_a));}} else if (activation_function == activation_func::swish) {- if (additional_params.a != 1.0f)+ if (additional_params.a != 1.0f) {input_host_tensors.push_back(ov::Tensor(input_dt, {}, ¶m_a));+ }}auto output_mem_ptr = instance.output_memory_ptr();@@ -134,8 +137,9 @@ struct activation_impl : public typed_primitive_impl<activation> {OPENVINO_ASSERT(op->evaluate(output_host_tensors, input_host_tensors),"[GPU] Couldn't execute activation primitive with id ", instance.id());- for (size_t i = 0; i < input_mem_ptrs.size(); i++)+ for (size_t i = 0; i < input_mem_ptrs.size(); i++) {input_mem_ptrs[i]->unlock(stream);+ }}event::ptr execute_impl(const std::vector<event::ptr>& events, activation_inst& instance) override {diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/broadcast.cpp b/src/plugins/intel_gpu/src/graph/impls/cpu/broadcast.cppindex 30aee71437f..201e6dddc0e 100644--- a/src/plugins/intel_gpu/src/graph/impls/cpu/broadcast.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/cpu/broadcast.cpp@@ -81,11 +81,13 @@ struct broadcast_impl : public typed_primitive_impl<broadcast> {}std::vector<memory::ptr> input_mem_ptrs;- for (size_t i = 0; i < instance.dependencies().size(); i++)+ for (size_t i = 0; i < instance.dependencies().size(); i++) {input_mem_ptrs.push_back(instance.dep_memory_ptr(i));+ }- for (size_t i = 0; i < input_mem_ptrs.size(); i++)+ for (size_t i = 0; i < input_mem_ptrs.size(); i++) {input_host_tensors.push_back(make_tensor(params->input_layouts[i], input_mem_ptrs[i]->lock(stream, mem_lock_type::read)));+ }if (instance.dependencies().size() < 2) {OPENVINO_ASSERT(!target_shape.empty(), "[GPU] Unexpected empty target_shape for broadcast operation with id ", instance.id());@@ -105,8 +107,9 @@ struct broadcast_impl : public typed_primitive_impl<broadcast> {OPENVINO_ASSERT(op->evaluate(output_host_tensors, input_host_tensors),"[GPU] Couldn't execute broadcast primitive with id ", instance.id());- for (size_t i = 0; i < input_mem_ptrs.size(); i++)+ for (size_t i = 0; i < input_mem_ptrs.size(); i++) {input_mem_ptrs[i]->unlock(stream);+ }if (pass_through_events) {return stream.group_events(events);diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/concat.cpp b/src/plugins/intel_gpu/src/graph/impls/cpu/concat.cppindex 8ac7a9a3df4..94ea1a44289 100644--- a/src/plugins/intel_gpu/src/graph/impls/cpu/concat.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/cpu/concat.cpp@@ -63,9 +63,10 @@ struct concatenation_impl : public typed_primitive_impl<concatenation> {ov::TensorVector input_host_tensors;ov::TensorVector output_host_tensors;- for (auto input_layout : instance.get_impl_params()->input_layouts)+ for (auto input_layout : instance.get_impl_params()->input_layouts) {OPENVINO_ASSERT(input_layout.data_type == instance.get_impl_params()->get_output_layout().data_type,"[GPU] Couldn't create concat operation: unsupported mixed inputs/output data types");+ }std::vector<memory::ptr> input_mem_ptrs;for (size_t i = 0; i < instance.dependencies().size(); i++) {@@ -92,8 +93,9 @@ struct concatenation_impl : public typed_primitive_impl<concatenation> {OPENVINO_ASSERT(op->evaluate(output_host_tensors, input_host_tensors),"[GPU] Couldn't execute concat primitive with id ", instance.id());- for (size_t i = 0; i < input_mem_ptrs.size(); i++)+ for (size_t i = 0; i < input_mem_ptrs.size(); i++) {input_mem_ptrs[i]->unlock(stream);+ }if (pass_through_events) {return stream.group_events(events);diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/cpu_impl_helpers.hpp b/src/plugins/intel_gpu/src/graph/impls/cpu/cpu_impl_helpers.hppindex f75674ebcba..f3a9e4a82f7 100644--- a/src/plugins/intel_gpu/src/graph/impls/cpu/cpu_impl_helpers.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/cpu/cpu_impl_helpers.hpp@@ -53,14 +53,16 @@ inline float iou(const bounding_box& box1, const bounding_box& box2) {float intersection_x = (inter_xmax - inter_xmin);float intersection_y = (inter_ymax - inter_ymin);- if (intersection_x <= 0 || intersection_y <= 0)+ if (intersection_x <= 0 || intersection_y <= 0) {return 0.f;+ }float intersection = intersection_x * intersection_y;float union_ = (area1 + area2 - intersection);- if (union_ <= 0)+ if (union_ <= 0) {return 0.f;+ }return intersection / union_;}@@ -78,8 +80,9 @@ template <typename T>using vector4D = vector2D<vector2D<T>>;inline event::ptr make_output_event(cldnn::stream& stream, bool is_output) {- if (is_output)+ if (is_output) {return stream.create_user_event(true);+ }return nullptr;}diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/crop.cpp b/src/plugins/intel_gpu/src/graph/impls/cpu/crop.cppindex 1145a139b5d..330f4362775 100644--- a/src/plugins/intel_gpu/src/graph/impls/cpu/crop.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/cpu/crop.cpp@@ -71,8 +71,9 @@ struct crop_impl : public typed_primitive_impl<crop> {std::vector<int64_t> steps_vec(input_shape.size(), 1);std::vector<int64_t> stop_vec;- for (size_t i = 0; i < start_vec.size(); i++)+ for (size_t i = 0; i < start_vec.size(); i++) {stop_vec.push_back(start_vec[i] + output_shape[i]);+ }auto start_tensor = ov::Tensor(ov::element::i64, {start_vec.size()}, start_vec.data());@@ -89,8 +90,9 @@ struct crop_impl : public typed_primitive_impl<crop> {output_host_tensors.push_back(output_tensor);- if (!op)+ if (!op) {op = std::make_shared<ov::op::v8::Slice>();+ }OPENVINO_ASSERT(op->evaluate(output_host_tensors, input_host_tensors),"[GPU] Couldn't execute crop primitive with id ", instance.id());diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/detection_output.cpp b/src/plugins/intel_gpu/src/graph/impls/cpu/detection_output.cppindex ae200365b82..ede8fac7138 100644--- a/src/plugins/intel_gpu/src/graph/impls/cpu/detection_output.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/cpu/detection_output.cpp@@ -217,9 +217,11 @@ public:scoreIndexPairs.end(),comp_score_descend<std::pair<int, int>>);- if (top_k != -1)- if (scoreIndexPairs.size() > static_cast<size_t>(top_k))+ if (top_k != -1) {+ if (scoreIndexPairs.size() > static_cast<size_t>(top_k)) {scoreIndexPairs.resize(top_k);+ }+ }while (!scoreIndexPairs.empty()) {const int cls = scoreIndexPairs.front().second.first;const int prior = scoreIndexPairs.front().second.second;diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/eltwise.cpp b/src/plugins/intel_gpu/src/graph/impls/cpu/eltwise.cppindex 4910ea3ea01..966560df9f1 100644--- a/src/plugins/intel_gpu/src/graph/impls/cpu/eltwise.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/cpu/eltwise.cpp@@ -190,23 +190,26 @@ struct eltwise_impl : public typed_primitive_impl<eltwise> {}std::vector<memory::ptr> input_mem_ptrs;- for (size_t i = 0; i < instance.dependencies().size(); i++)+ for (size_t i = 0; i < instance.dependencies().size(); i++) {input_mem_ptrs.push_back(instance.dep_memory_ptr(i));+ }auto output_mem_ptr = instance.output_memory_ptr();cldnn::mem_lock<uint8_t, mem_lock_type::write> output_lock(output_mem_ptr, stream);- for (size_t i = 0; i < input_mem_ptrs.size(); i++)+ for (size_t i = 0; i < input_mem_ptrs.size(); i++) {input_host_tensors.push_back(make_tensor(params->input_layouts[i], input_mem_ptrs[i]->lock(stream, mem_lock_type::read)));+ }output_host_tensors.push_back(make_tensor(params->output_layouts[0], output_lock.data()));OPENVINO_ASSERT(op->evaluate(output_host_tensors, input_host_tensors),"[GPU] Couldn't execute eltwise primitive with id ", instance.id());- for (size_t i = 0; i < input_mem_ptrs.size(); i++)+ for (size_t i = 0; i < input_mem_ptrs.size(); i++) {input_mem_ptrs[i]->unlock(stream);+ }if (pass_through_events) {return stream.group_events(events);diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/fake_convert.cpp b/src/plugins/intel_gpu/src/graph/impls/cpu/fake_convert.cppindex 0ed9c6da94c..016acbd868f 100644--- a/src/plugins/intel_gpu/src/graph/impls/cpu/fake_convert.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/cpu/fake_convert.cpp@@ -69,15 +69,17 @@ struct fake_convert_impl : public typed_primitive_impl<fake_convert> {}std::vector<memory::ptr> input_mem_ptrs;- for (size_t i = 0; i < instance.dependencies().size(); i++)+ for (size_t i = 0; i < instance.dependencies().size(); i++) {input_mem_ptrs.push_back(instance.dep_memory_ptr(i));+ }auto output_mem_ptr = instance.output_memory_ptr();cldnn::mem_lock<uint8_t, mem_lock_type::read_write> output_lock(output_mem_ptr, stream);- for (size_t i = 0; i < input_mem_ptrs.size(); i++)+ for (size_t i = 0; i < input_mem_ptrs.size(); i++) {input_host_tensors.push_back(make_tensor(params->input_layouts[i], input_mem_ptrs[i]->lock(stream, mem_lock_type::read)));+ }output_host_tensors.push_back(make_tensor(params->output_layouts[0], output_lock.data()));diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/gather.cpp b/src/plugins/intel_gpu/src/graph/impls/cpu/gather.cppindex d7817514439..e86a1af6602 100644--- a/src/plugins/intel_gpu/src/graph/impls/cpu/gather.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/cpu/gather.cpp@@ -77,15 +77,17 @@ struct gather_impl : public typed_primitive_impl<gather> {}std::vector<memory::ptr> input_mem_ptrs;- for (size_t i = 0; i < instance.dependencies().size(); i++)+ for (size_t i = 0; i < instance.dependencies().size(); i++) {input_mem_ptrs.push_back(instance.dep_memory_ptr(i));+ }auto output_mem_ptr = instance.output_memory_ptr();cldnn::mem_lock<uint8_t, mem_lock_type::read_write> output_lock(output_mem_ptr, stream);- for (size_t i = 0; i < input_mem_ptrs.size(); i++)+ for (size_t i = 0; i < input_mem_ptrs.size(); i++) {input_host_tensors.push_back(make_tensor(params->input_layouts[i], input_mem_ptrs[i]->lock(stream, mem_lock_type::read)));+ }auto axis_tensor = ov::Tensor(ov::element::i64, ov::Shape{1}, static_cast<void*>(&axis));@@ -95,8 +97,9 @@ struct gather_impl : public typed_primitive_impl<gather> {OPENVINO_ASSERT(op->evaluate(output_host_tensors, input_host_tensors),"[GPU] Couldn't execute gather primitive with id ", instance.id());- for (size_t i = 0; i < input_mem_ptrs.size(); i++)+ for (size_t i = 0; i < input_mem_ptrs.size(); i++) {input_mem_ptrs[i]->unlock(stream);+ }if (pass_through_events) {return stream.group_events(events);diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/non_max_suppression.cpp b/src/plugins/intel_gpu/src/graph/impls/cpu/non_max_suppression.cppindex e3d8dcdaea5..1ad3203c2f0 100644--- a/src/plugins/intel_gpu/src/graph/impls/cpu/non_max_suppression.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/cpu/non_max_suppression.cpp@@ -62,8 +62,9 @@ std::vector<result_indices> run_nms(std::priority_queue<boxInfo, std::vector<boxInfo>, decltype(less)> sorted_boxes(less);for (size_t bbi = 0; bbi < boxes[bi].size(); ++bbi) {- if (scores[bi][ci][bbi] > score_threshold)+ if (scores[bi][ci][bbi] > score_threshold) {sorted_boxes.emplace(boxInfo({scores[bi][ci][bbi], static_cast<int>(bbi), 0}));+ }}fb.reserve(sorted_boxes.size());@@ -81,8 +82,9 @@ std::vector<result_indices> run_nms(box_is_selected = false;break;}- if (currBox.score <= score_threshold)+ if (currBox.score <= score_threshold) {break;+ }}currBox.suppress_begin_index = static_cast<int>(fb.size());if (box_is_selected) {@@ -375,8 +377,9 @@ void run(non_max_suppression_inst& instance) {}// New API for mutiple outputs support- if (instance.outputs_memory_count() == 3)+ if (instance.outputs_memory_count() == 3) {store_third_output(stream, instance.output_memory_ptr(2), result);+ }if (instance.outputs_memory_count() >= 2) {store_second_output(stream, instance.output_memory_ptr(1), result, output_size);diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/proposal.cpp b/src/plugins/intel_gpu/src/graph/impls/cpu/proposal.cppindex a768ab365ac..23529438256 100644--- a/src/plugins/intel_gpu/src/graph/impls/cpu/proposal.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/cpu/proposal.cpp@@ -159,8 +159,9 @@ std::vector<roi_t> perform_nms(const std::vector<proposal_t>& proposals,if (!overlaps) {res.push_back(bbox);- if (res.size() == top_n)+ if (res.size() == top_n) {break;+ }}}@@ -381,8 +382,9 @@ struct proposal_impl : typed_primitive_impl<proposal> {float_write_helper(top_data + 5 * i + 2, 0.0f);float_write_helper(top_data + 5 * i + 3, 0.0f);float_write_helper(top_data + 5 * i + 4, 0.0f);- if (top_data_prob != nullptr)+ if (top_data_prob != nullptr) {float_write_helper(top_data_prob + i, 0.0f);+ }}}}@@ -404,8 +406,9 @@ struct proposal_impl : typed_primitive_impl<proposal> {}if (instance.dep_memory(proposal_inst::cls_scores_index).get_layout().data_type !=- instance.dep_memory(proposal_inst::bbox_pred_index).get_layout().data_type)+ instance.dep_memory(proposal_inst::bbox_pred_index).get_layout().data_type) {throw std::runtime_error("clDNN: proposal primitive doesn't support mixed bbox and scores types");+ }if (instance.dependencies().size() == 4) {auto proposal_probabilities = instance.dep_memory_ptr(proposal_inst::proposal_probabilities_out);diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/range.cpp b/src/plugins/intel_gpu/src/graph/impls/cpu/range.cppindex f17b80d367d..adafb584969 100644--- a/src/plugins/intel_gpu/src/graph/impls/cpu/range.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/cpu/range.cpp@@ -50,15 +50,17 @@ struct range_impl : public typed_primitive_impl<range> {ov::TensorVector output_host_tensors;std::vector<memory::ptr> input_mem_ptrs;- for (size_t i = 0; i < instance.dependencies().size(); i++)+ for (size_t i = 0; i < instance.dependencies().size(); i++) {input_mem_ptrs.push_back(instance.dep_memory_ptr(i));+ }auto output_mem_ptr = instance.output_memory_ptr();cldnn::mem_lock<uint8_t, mem_lock_type::read_write> output_lock(output_mem_ptr, stream);- for (size_t i = 0; i < input_mem_ptrs.size(); i++)+ for (size_t i = 0; i < input_mem_ptrs.size(); i++) {input_host_tensors.push_back(make_tensor(params->input_layouts[i], input_mem_ptrs[i]->lock(stream, mem_lock_type::read)));+ }output_host_tensors.push_back(make_tensor(params->output_layouts[0], output_lock.data()));@@ -72,8 +74,9 @@ struct range_impl : public typed_primitive_impl<range> {OPENVINO_ASSERT(op->evaluate(output_host_tensors, input_host_tensors),"[GPU] Couldn't execute range primitive with id ", instance.id());- for (size_t i = 0; i < input_mem_ptrs.size(); i++)+ for (size_t i = 0; i < input_mem_ptrs.size(); i++) {input_mem_ptrs[i]->unlock(stream);+ }if (pass_through_events) {return stream.group_events(events);diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/reorder.cpp b/src/plugins/intel_gpu/src/graph/impls/cpu/reorder.cppindex d1f98b1e0a9..4444f04041e 100644--- a/src/plugins/intel_gpu/src/graph/impls/cpu/reorder.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/cpu/reorder.cpp@@ -46,8 +46,9 @@ struct reorder_impl : public typed_primitive_impl<reorder> {const auto* params = instance.get_impl_params();- if (instance.get_impl_params()->input_layouts[0].format != instance.get_impl_params()->input_layouts[0].format)+ if (instance.get_impl_params()->input_layouts[0].format != instance.get_impl_params()->input_layouts[0].format) {OPENVINO_THROW("[GPU] Unsupported reorder case: input and output type are different");+ }ov::TensorVector input_host_tensors;ov::TensorVector output_host_tensors;diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/scatter_update.cpp b/src/plugins/intel_gpu/src/graph/impls/cpu/scatter_update.cppindex 6aadb93ca31..66bce6b4ab9 100644--- a/src/plugins/intel_gpu/src/graph/impls/cpu/scatter_update.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/cpu/scatter_update.cpp@@ -66,15 +66,17 @@ struct scatter_update_impl : public typed_primitive_impl<scatter_update> {auto axis_tensor = ov::Tensor(ov::element::i64, ov::Shape{1}, static_cast<void*>(&axis));std::vector<memory::ptr> input_mem_ptrs;- for (size_t i = 0; i < instance.dependencies().size(); i++)+ for (size_t i = 0; i < instance.dependencies().size(); i++) {input_mem_ptrs.push_back(instance.dep_memory_ptr(i));+ }auto output_mem_ptr = instance.output_memory_ptr();cldnn::mem_lock<uint8_t, mem_lock_type::read_write> output_lock(output_mem_ptr, stream);- for (size_t i = 0; i < input_mem_ptrs.size(); i++)+ for (size_t i = 0; i < input_mem_ptrs.size(); i++) {input_host_tensors.push_back(make_tensor(params->input_layouts[i], input_mem_ptrs[i]->lock(stream, mem_lock_type::read)));+ }input_host_tensors.push_back(axis_tensor);@@ -87,8 +89,9 @@ struct scatter_update_impl : public typed_primitive_impl<scatter_update> {OPENVINO_ASSERT(op->evaluate(output_host_tensors, input_host_tensors),"[GPU] Couldn't execute scatter_update primitive with id ", instance.id());- for (size_t i = 0; i < input_mem_ptrs.size(); i++)+ for (size_t i = 0; i < input_mem_ptrs.size(); i++) {input_mem_ptrs[i]->unlock(stream);+ }if (pass_through_events) {return stream.group_events(events);diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/select.cpp b/src/plugins/intel_gpu/src/graph/impls/cpu/select.cppindex 4b20dd7f36c..235413fc574 100644--- a/src/plugins/intel_gpu/src/graph/impls/cpu/select.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/cpu/select.cpp@@ -68,11 +68,13 @@ struct select_impl : public typed_primitive_impl<select> {}std::vector<memory::ptr> input_mem_ptrs;- for (size_t i = 0; i < instance.dependencies().size(); i++)+ for (size_t i = 0; i < instance.dependencies().size(); i++) {input_mem_ptrs.push_back(instance.dep_memory_ptr(i));+ }- for (size_t i = 0; i < input_mem_ptrs.size(); i++)+ for (size_t i = 0; i < input_mem_ptrs.size(); i++) {input_host_tensors.push_back(make_tensor(params->input_layouts[i], input_mem_ptrs[i]->lock(stream, mem_lock_type::read)));+ }auto output_mem_ptr = instance.output_memory_ptr();@@ -82,8 +84,9 @@ struct select_impl : public typed_primitive_impl<select> {OPENVINO_ASSERT(op->evaluate(output_host_tensors, input_host_tensors),"[GPU] Couldn't execute select primitive with id ", instance.id());- for (size_t i = 0; i < input_mem_ptrs.size(); i++)+ for (size_t i = 0; i < input_mem_ptrs.size(); i++) {input_mem_ptrs[i]->unlock(stream);+ }if (pass_through_events) {return stream.group_events(events);diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/shape_of.cpp b/src/plugins/intel_gpu/src/graph/impls/cpu/shape_of.cppindex 639e6c359e8..833dfde5e78 100644--- a/src/plugins/intel_gpu/src/graph/impls/cpu/shape_of.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/cpu/shape_of.cpp@@ -48,13 +48,15 @@ struct shape_of_impl : public typed_primitive_impl<shape_of> {if (output_dt == data_types::i32) {cldnn::mem_lock<int32_t, mem_lock_type::write> output_lock(output_mem_ptr, stream);auto shape = instance.get_input_layout().get_shape();- for (size_t i = 0; i < shape.size(); i++)+ for (size_t i = 0; i < shape.size(); i++) {output_lock[i] = static_cast<int32_t>(shape[i]);+ }} else if (output_dt == data_types::i64) {cldnn::mem_lock<int64_t, mem_lock_type::write> output_lock(output_mem_ptr, stream);auto shape = instance.get_input_layout().get_shape();- for (size_t i = 0; i < shape.size(); i++)+ for (size_t i = 0; i < shape.size(); i++) {output_lock[i] = static_cast<int64_t>(shape[i]);+ }} else {OPENVINO_THROW("[GPU] Couldn't execute shape_of operation: unsupported output data type (", output_dt , ")");}diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/tile.cpp b/src/plugins/intel_gpu/src/graph/impls/cpu/tile.cppindex 944317ae231..803f903d0a6 100644--- a/src/plugins/intel_gpu/src/graph/impls/cpu/tile.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/cpu/tile.cpp@@ -67,15 +67,18 @@ struct tile_impl : public typed_primitive_impl<tile> {}std::vector<memory::ptr> input_mem_ptrs;- for (size_t i = 0; i < instance.dependencies().size(); i++)+ for (size_t i = 0; i < instance.dependencies().size(); i++) {input_mem_ptrs.push_back(instance.dep_memory_ptr(i));+ }- for (size_t i = 0; i < input_mem_ptrs.size(); i++)+ for (size_t i = 0; i < input_mem_ptrs.size(); i++) {input_host_tensors.push_back(make_tensor(params->input_layouts[i], input_mem_ptrs[i]->lock(stream, mem_lock_type::read)));+ }if (instance.dependencies().size() == 1) {- if (repeats.empty())+ if (repeats.empty()) {OPENVINO_THROW("[GPU] Unexpected configuration of tile impl");+ }auto repeats_tensor = ov::Tensor(ov::element::i64, {repeats.size()}, repeats.data());input_host_tensors.push_back(repeats_tensor);@@ -89,8 +92,9 @@ struct tile_impl : public typed_primitive_impl<tile> {OPENVINO_ASSERT(op->evaluate(output_host_tensors, input_host_tensors),"[GPU] Couldn't execute tile primitive with id ", instance.id());- for (size_t i = 0; i < input_mem_ptrs.size(); i++)+ for (size_t i = 0; i < input_mem_ptrs.size(); i++) {input_mem_ptrs[i]->unlock(stream);+ }if (pass_through_events) {return stream.group_events(events);diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/arg_max_min.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/arg_max_min.cppindex 3c828d1f31d..eae95e0c158 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/arg_max_min.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/arg_max_min.cpp@@ -19,15 +19,17 @@ static inline kernel_selector::argm_axis GetArgMaxMinAxis(int64_t axis, size_t rcase 0: return kernel_selector::argm_axis::BATCH;case 1: return kernel_selector::argm_axis::FEATURE;case 2:- if (rank > 4)+ if (rank > 4) {return kernel_selector::argm_axis::Z;- else+ } else {return kernel_selector::argm_axis::Y;+ }case 3:- if (rank > 4)+ if (rank > 4) {return kernel_selector::argm_axis::Y;- else+ } else {return kernel_selector::argm_axis::X;+ }case 4: return kernel_selector::argm_axis::X;default: OPENVINO_THROW("Invalid arg_max_min axis ", axis);}@@ -93,15 +95,17 @@ public:argm_params.topK = top_k;}- if (mode == ov::op::TopKMode::MAX)+ if (mode == ov::op::TopKMode::MAX) {argm_params.argMaxMinOut = kernel_selector::argm_output::MAX;- else+ } else {argm_params.argMaxMinOut = kernel_selector::argm_output::MIN;+ }- if (sort_type == ov::op::TopKSortType::SORT_VALUES)+ if (sort_type == ov::op::TopKSortType::SORT_VALUES) {argm_params.argMaxMinSortType = kernel_selector::argm_sort::VALUE;- else+ } else {argm_params.argMaxMinSortType = kernel_selector::argm_sort::INDEX;+ }if (outputs_num == 2) { // for backward compatibilityif (primitive->input_size() != 3) {diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/border.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/border.cppindex 8e6d03b1d91..2a15b5aa0c3 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/border.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/border.cpp@@ -151,8 +151,9 @@ protected:std::vector<BufferDescriptor> internal_buffers;if (_kernel_data.params != nullptr) {const auto& prim_params = static_cast<const kernel_selector::border_params&>(*_kernel_data.params);- if (prim_params.inputs[0].LogicalSize() == 0)+ if (prim_params.inputs[0].LogicalSize() == 0) {internal_buffers.emplace_back(1, ov::element::u8);+ }}return internal_buffers;diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/concatenation.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/concatenation.cppindex ce258492f68..0edeca8a474 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/concatenation.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/concatenation.cpp@@ -15,8 +15,9 @@ namespace ocl {namespace {kernel_selector::concat_axis convert_axis(int64_t axis, size_t rank) {auto cldnn_axis = axis >= 0 ? axis : axis + static_cast<int64_t>(rank);- if (cldnn_axis >= static_cast<int64_t>(rank))+ if (cldnn_axis >= static_cast<int64_t>(rank)) {OPENVINO_THROW("Concatenation axis exceeds number of dimensions");+ }// Difference in dimension ordering between OV and GPU plugin,// reverse spatial dimensions after batch and feature.diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/convolution.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/convolution.cppindex dea64390406..4f6164a026e 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/convolution.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/convolution.cpp@@ -84,8 +84,9 @@ public:conv_params.grouped_weights_shape = primitive->grouped_weights_shape;auto deform_conv_dep_offset = primitive->deformable_mode ? 1 : 0;- if (primitive->input.size() == 3)+ if (primitive->input.size() == 3) {deform_conv_dep_offset++;+ }const size_t weights_input_idx = 1 + deform_conv_dep_offset;auto weights_layout = impl_param.input_layouts[weights_input_idx]@@ -239,8 +240,9 @@ public:if (format == format::b_fs_zyx_fsv16 ||format == format::bs_fs_zyx_bsv16_fsv16 ||format == format::bs_fs_yx_bsv16_fsv16 ||- format == format::b_fs_zyx_fsv32)+ format == format::b_fs_zyx_fsv32) {conv_params.allowInputReordering = true;+ }conv_params.set_dynamic_shape_offsets();diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/convolution.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl/convolution.hppindex d026907fa5c..c73d14eff7b 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/convolution.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/convolution.hpp@@ -48,8 +48,9 @@ struct ConvolutionImplementationManager : public ImplementationManager {if (!one_of(in_dt, supported_activation_types) ||!one_of(wei_dt, supported_weights_types) ||- !one_of(out_dt, supported_activation_types))+ !one_of(out_dt, supported_activation_types)) {return false;+ }if (m_shape_type == shape_types::dynamic_shape) {static const std::vector<format::type> supported_dyn_formats = {@@ -59,8 +60,9 @@ struct ConvolutionImplementationManager : public ImplementationManager {format::b_fs_zyx_fsv16};- if (!one_of(input_fmt.value, supported_dyn_formats) || !one_of(output_fmt.value, supported_dyn_formats))+ if (!one_of(input_fmt.value, supported_dyn_formats) || !one_of(output_fmt.value, supported_dyn_formats)) {return false;+ }} else {static const std::vector<format::type> supported_fp_only_formats = {format::yxfb,@@ -92,8 +94,9 @@ struct ConvolutionImplementationManager : public ImplementationManager {bool i8u8_case = data_type_traits::is_i8_u8(in_dt) &&(one_of(input_fmt.value, supported_int_only_formats) || one_of(input_fmt.value, supported_common_formats));- if (!fp_common_case && !fp16_case && !i8u8_case)+ if (!fp_common_case && !fp16_case && !i8u8_case) {return false;+ }}return true;diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/cum_sum.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/cum_sum.cppindex f0136830c75..627cc315444 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/cum_sum.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/cum_sum.cpp@@ -20,24 +20,27 @@ kernel_selector::cum_sum_axis convert_axis(int64_t axis, size_t rank) {case 0: return kernel_selector::cum_sum_axis::BATCH;case 1: return kernel_selector::cum_sum_axis::FEATURE;case 2:- if (rank == 6)+ if (rank == 6) {return kernel_selector::cum_sum_axis::W;- else if (rank == 5)+ } else if (rank == 5) {return kernel_selector::cum_sum_axis::Z;- else+ } else {return kernel_selector::cum_sum_axis::Y;+ }case 3:- if (rank == 6)+ if (rank == 6) {return kernel_selector::cum_sum_axis::Z;- else if (rank == 5)+ } else if (rank == 5) {return kernel_selector::cum_sum_axis::Y;- else+ } else {return kernel_selector::cum_sum_axis::X;+ }case 4:- if (rank == 6)+ if (rank == 6) {return kernel_selector::cum_sum_axis::Y;- else+ } else {return kernel_selector::cum_sum_axis::X;+ }case 5: return kernel_selector::cum_sum_axis::X;default: return kernel_selector::cum_sum_axis::BATCH;}diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/custom_primitive.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/custom_primitive.cppindex 8b9863453d1..58f6710619a 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/custom_primitive.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/custom_primitive.cpp@@ -138,8 +138,9 @@ struct custom_gpu_primitive_impl : typed_primitive_impl<custom_gpu_primitive> {}std::vector<BufferDescriptor> get_internal_buffer_descs(const kernel_impl_params& impl_params) const override {- if (size_expr_map.empty())+ if (size_expr_map.empty()) {return {};+ }const auto& input_layout = impl_params.input_layouts[0];auto shape = input_layout.get_shape();diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/dynamic_quantize.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/dynamic_quantize.cppindex 6285d515f51..fc2293c9018 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/dynamic_quantize.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/dynamic_quantize.cpp@@ -41,12 +41,14 @@ struct dynamic_quantize_impl : typed_primitive_impl_ocl<dynamic_quantize> {// It refers to IFM value of weight of fully connected, resolved when the primitive was created.params.fc_ifm_size = primitive->innermost_size;- if (impl_param.output_layouts.size() > 2)+ if (impl_param.output_layouts.size() > 2) {params.outputs.push_back(convert_data_tensor(impl_param.get_output_layout(2)));+ }// Keep 2d data as bf layout- if (primitive->input_size == 2)+ if (primitive->input_size == 2) {params.outputs[0] = params.outputs[0].FlattenFeatureAndSpatials();+ }const auto& desc = impl_param.typed_desc<dynamic_quantize>();params.group_sizes = desc->attrs.group_sizes;diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/eltwise.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/eltwise.cppindex 1ee59621c12..4614a0a0dea 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/eltwise.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/eltwise.cpp@@ -78,8 +78,9 @@ public:std::vector<ov::Dimension::value_type> output_size = impl_param.get_output_layout().get_tensor().raw.vector();bool broadcast = false;for (size_t d = 0; d < output_size.size(); d++) {- if (output_size[d] != 1 && input_size[d] == 1)+ if (output_size[d] != 1 && input_size[d] == 1) {broadcast = true;+ }}if (broadcast) {params.broadcast = true;@@ -106,8 +107,9 @@ public:if (!params.stride.empty()) {const auto& stride = params.stride[0];for (size_t i = 1; i < params.stride.size(); i++) {- if (stride.x != params.stride[i].x || stride.y != params.stride[i].y)+ if (stride.x != params.stride[i].x || stride.y != params.stride[i].y) {params.layoutBased = true;+ }}} else if (params.inputs.size() > 1 && (!params.inputs[0].SameDimsSizes(params.inputs[1]))) {params.broadcast = true;diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/fully_connected.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/fully_connected.cppindex 5dcaef8724f..467cb7a9cd7 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/fully_connected.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/fully_connected.cpp@@ -2,11 +2,11 @@// SPDX-License-Identifier: Apache-2.0//-#include "primitive_base.hpp"-#include "kernel_base.h"-#include "fully_connected_inst.h"#include "fully_connected/fully_connected_kernel_selector.h"#include "fully_connected/fully_connected_params.h"+#include "fully_connected_inst.h"+#include "kernel_base.h"+#include "primitive_base.hpp"namespace cldnn {namespace ocl {@@ -30,9 +30,8 @@ struct fully_connected_impl : typed_primitive_impl_ocl<fully_connected> {return ov::PartialShape({shape[0], shape[1]});};- auto weights_reorder_params = std::make_shared<WeightsReorderParams>(from_weights_tensor(params.src),- from_weights_tensor(params.dest),- params.rotate);+ auto weights_reorder_params =+ std::make_shared<WeightsReorderParams>(from_weights_tensor(params.src), from_weights_tensor(params.dest), params.rotate);auto output_layout = weights_reorder_params->get_output_layout();output_layout.set_partial_shape(crop_to_2d(output_layout.get_partial_shape()));weights_reorder_params->set_output_layout(output_layout);@@ -65,13 +64,15 @@ protected:args.weights = instance.weights_memory();args.bias = instance.bias_term() ? instance.bias_memory() : nullptr;- args.inputs = { instance.input_memory_ptr(0) };+ args.inputs = {instance.input_memory_ptr(0)};size_t in_id = instance.bias_term() ? 3 : 2;- if (desc->decompression_scale.is_valid())+ if (desc->decompression_scale.is_valid()) {args.inputs.push_back(instance.dep_memory_ptr(in_id++));+ }- if (desc->decompression_zero_point.is_valid())+ if (desc->decompression_zero_point.is_valid()) {args.inputs.push_back(instance.dep_memory_ptr(in_id));+ }return args;}@@ -86,10 +87,9 @@ public:auto static_shape = shape.to_shape();size_t total = std::accumulate(static_shape.begin(), static_shape.end(), static_cast<size_t>(1), std::multiplies<size_t>());auto dim = feature.is_static() ? feature.get_length() : static_cast<int64_t>(static_shape[rank - 1]);- return ov::PartialShape{ static_cast<int64_t>(total) / dim, dim };+ return ov::PartialShape{static_cast<int64_t>(total) / dim, dim};}return ov::PartialShape{ov::Dimension::dynamic(), feature};-};auto input0_layout = input_layouts[0];@@ -138,11 +138,11 @@ public:auto input0_pshape = input_layouts[0].get_partial_shape();auto input1_pshape = input_layouts[1].get_partial_shape();const auto out_features_dim = primitive->weights_transposed ? input1_pshape[0] : input1_pshape[1];- ov::PartialShape updated_out_pshape {input0_pshape[0], out_features_dim};+ ov::PartialShape updated_out_pshape{input0_pshape[0], out_features_dim};const auto output_feature_size = swiglu_fused ? out_features_dim / 2 : out_features_dim;if (primitive->input_size == 3) {- updated_out_pshape = { input0_pshape[0], input0_pshape[1], output_feature_size};+ updated_out_pshape = {input0_pshape[0], input0_pshape[1], output_feature_size};}updated_out_layout.set_partial_shape(updated_out_pshape);@@ -154,8 +154,9 @@ public:bool swiglu_fused = false;if (!updated_impl_param.fused_desc.empty()) {for (const auto& f : updated_impl_param.fused_desc) {- if (f.is_type<swiglu>())+ if (f.is_type<swiglu>()) {swiglu_fused = true;+ }}}@@ -184,8 +185,7 @@ public:if (with_zp) {params.has_decompression_zp = true;params.decompression_zero_point = convert_data_tensor(updated_impl_param.input_layouts[3]);- if (updated_impl_param.input_layouts[3].get_linear_size() == 1 &&- primitive->decompression_zero_point_scalar.has_value()) {+ if (updated_impl_param.input_layouts[3].get_linear_size() == 1 && primitive->decompression_zero_point_scalar.has_value()) {params.scalar_zp = true;params.zp_value = primitive->decompression_zero_point_scalar.value();}@@ -196,12 +196,14 @@ public:}}- if (primitive->input_size != 3)- params.outputs = { params.outputs[0].FlattenFeatureAndSpatials() };+ if (primitive->input_size != 3) {+ params.outputs = {params.outputs[0].FlattenFeatureAndSpatials()};+ }bool is_quantized = true;- for (const auto& input : impl_param.input_layouts)+ for (const auto& input : impl_param.input_layouts) {is_quantized &= data_type_traits::is_quantized(input.data_type);+ }if (is_quantized) {params.quantization = kernel_selector::QuantizationType::SYMMETRIC;@@ -209,8 +211,7 @@ public:params.quantization = kernel_selector::QuantizationType::NONE;}- params.dynamic_quantization_group_size =- impl_param.get_program().get_config().get_dynamic_quantization_group_size();+ params.dynamic_quantization_group_size = impl_param.get_program().get_config().get_dynamic_quantization_group_size();return params;}@@ -226,7 +227,7 @@ public:update_shapes(params, updated_impl_param);if (impl_param.typed_desc<fully_connected>()->input_size != 3) {- params.outputs = { params.outputs[0].FlattenFeatureAndSpatials() };+ params.outputs = {params.outputs[0].FlattenFeatureAndSpatials()};}(_kernel_data.update_dispatch_data_func)(*_kernel_data.params, _kernel_data);@@ -238,45 +239,47 @@ namespace detail {attach_fully_connected_impl::attach_fully_connected_impl() {implementation_map<fully_connected>::add(impl_types::ocl,shape_types::dynamic_shape,- typed_primitive_impl_ocl<fully_connected>::create<fully_connected_impl>, {- std::make_tuple(data_types::f32, format::bfyx),- std::make_tuple(data_types::f16, format::bfyx),- std::make_tuple(data_types::i32, format::bfyx),- std::make_tuple(data_types::u8, format::bfyx),- std::make_tuple(data_types::i8, format::bfyx),- });+ typed_primitive_impl_ocl<fully_connected>::create<fully_connected_impl>,+ {+ std::make_tuple(data_types::f32, format::bfyx),+ std::make_tuple(data_types::f16, format::bfyx),+ std::make_tuple(data_types::i32, format::bfyx),+ std::make_tuple(data_types::u8, format::bfyx),+ std::make_tuple(data_types::i8, format::bfyx),+ });implementation_map<fully_connected>::add(impl_types::ocl,shape_types::static_shape,- typed_primitive_impl_ocl<fully_connected>::create<fully_connected_impl>, {- std::make_tuple(data_types::f32, format::yxfb),- std::make_tuple(data_types::f16, format::yxfb),- std::make_tuple(data_types::f32, format::bfyx),- std::make_tuple(data_types::f16, format::bfyx),- std::make_tuple(data_types::i32, format::bfyx),- std::make_tuple(data_types::f32, format::bfzyx),- std::make_tuple(data_types::f16, format::bfzyx),- std::make_tuple(data_types::f32, format::bfwzyx),- std::make_tuple(data_types::f16, format::bfwzyx),- std::make_tuple(data_types::f32, format::byxf),- std::make_tuple(data_types::f16, format::byxf),- std::make_tuple(data_types::i8, format::bfyx),- std::make_tuple(data_types::u8, format::bfyx),- std::make_tuple(data_types::i8, format::b_fs_yx_fsv32),- std::make_tuple(data_types::u8, format::b_fs_yx_fsv32),- std::make_tuple(data_types::i8, format::b_fs_yx_fsv4),- std::make_tuple(data_types::u8, format::b_fs_yx_fsv4),- std::make_tuple(data_types::f32, format::b_fs_yx_fsv4),- std::make_tuple(data_types::i8, format::b_fs_yx_fsv16),- std::make_tuple(data_types::u8, format::b_fs_yx_fsv16),- std::make_tuple(data_types::i8, format::bs_fs_yx_bsv16_fsv16),- std::make_tuple(data_types::u8, format::bs_fs_yx_bsv16_fsv16),- std::make_tuple(data_types::f16, format::fs_b_yx_fsv32),- std::make_tuple(data_types::f32, format::bs_fs_fsv8_bsv8),- std::make_tuple(data_types::f16, format::bs_fs_fsv8_bsv8),- std::make_tuple(data_types::f16, format::bs_fs_fsv8_bsv16),- std::make_tuple(data_types::i8, format::bfzyx),- std::make_tuple(data_types::u8, format::bfzyx),- });+ typed_primitive_impl_ocl<fully_connected>::create<fully_connected_impl>,+ {+ std::make_tuple(data_types::f32, format::yxfb),+ std::make_tuple(data_types::f16, format::yxfb),+ std::make_tuple(data_types::f32, format::bfyx),+ std::make_tuple(data_types::f16, format::bfyx),+ std::make_tuple(data_types::i32, format::bfyx),+ std::make_tuple(data_types::f32, format::bfzyx),+ std::make_tuple(data_types::f16, format::bfzyx),+ std::make_tuple(data_types::f32, format::bfwzyx),+ std::make_tuple(data_types::f16, format::bfwzyx),+ std::make_tuple(data_types::f32, format::byxf),+ std::make_tuple(data_types::f16, format::byxf),+ std::make_tuple(data_types::i8, format::bfyx),+ std::make_tuple(data_types::u8, format::bfyx),+ std::make_tuple(data_types::i8, format::b_fs_yx_fsv32),+ std::make_tuple(data_types::u8, format::b_fs_yx_fsv32),+ std::make_tuple(data_types::i8, format::b_fs_yx_fsv4),+ std::make_tuple(data_types::u8, format::b_fs_yx_fsv4),+ std::make_tuple(data_types::f32, format::b_fs_yx_fsv4),+ std::make_tuple(data_types::i8, format::b_fs_yx_fsv16),+ std::make_tuple(data_types::u8, format::b_fs_yx_fsv16),+ std::make_tuple(data_types::i8, format::bs_fs_yx_bsv16_fsv16),+ std::make_tuple(data_types::u8, format::bs_fs_yx_bsv16_fsv16),+ std::make_tuple(data_types::f16, format::fs_b_yx_fsv32),+ std::make_tuple(data_types::f32, format::bs_fs_fsv8_bsv8),+ std::make_tuple(data_types::f16, format::bs_fs_fsv8_bsv8),+ std::make_tuple(data_types::f16, format::bs_fs_fsv8_bsv16),+ std::make_tuple(data_types::i8, format::bfzyx),+ std::make_tuple(data_types::u8, format::bfzyx),+ });}} // namespace detaildiff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/gather.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/gather.cppindex ff8cd31b62a..1f580b1557e 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/gather.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/gather.cpp@@ -83,11 +83,13 @@ protected:kernel_arguments_data args = parent::get_arguments(instance);const auto& desc = instance.get_typed_desc<gather>();- if (desc->decompression_scale.is_valid())+ if (desc->decompression_scale.is_valid()) {args.inputs.push_back(instance.dep_memory_ptr(2));+ }- if (desc->decompression_zero_point.is_valid())+ if (desc->decompression_zero_point.is_valid()) {args.inputs.push_back(instance.dep_memory_ptr(3));+ }return args;}@@ -158,8 +160,9 @@ public:size_t num_outer_deps = fd.total_num_deps > 0 ? fd.total_num_deps - 1 : 0;for (size_t di = 0; di < num_outer_deps; di++) {size_t dep_idx = static_cast<size_t>(fd.outer_dep_start_idx) + di;- if (dep_idx >= updated_impl_params.input_layouts.size())+ if (dep_idx >= updated_impl_params.input_layouts.size()) {break;+ }auto& dep_layout = updated_impl_params.input_layouts[dep_idx];auto dep_pshape = dep_layout.get_partial_shape();if (dep_pshape.size() < output_pshape.size()) {diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/gather_elements.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/gather_elements.cppindex a37c0279c8d..a8ef71c6a5b 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/gather_elements.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/gather_elements.cpp@@ -19,24 +19,27 @@ static inline kernel_selector::gather_elements_axis convert_axis(int64_t axis, scase 0: return kernel_selector::gather_elements_axis::BATCH;case 1: return kernel_selector::gather_elements_axis::FEATURE;case 2:- if (rank == 6)+ if (rank == 6) {return kernel_selector::gather_elements_axis::W;- else if (rank == 5)+ } else if (rank == 5) {return kernel_selector::gather_elements_axis::Z;- else+ } else {return kernel_selector::gather_elements_axis::Y;+ }case 3:- if (rank == 6)+ if (rank == 6) {return kernel_selector::gather_elements_axis::Z;- else if (rank == 5)+ } else if (rank == 5) {return kernel_selector::gather_elements_axis::Y;- else+ } else {return kernel_selector::gather_elements_axis::X;+ }case 4:- if (rank == 6)+ if (rank == 6) {return kernel_selector::gather_elements_axis::Y;- else+ } else {return kernel_selector::gather_elements_axis::X;+ }case 5: return kernel_selector::gather_elements_axis::X;default: OPENVINO_THROW("Incorrect gather_elements axis.");}diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/gather_nd.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl/gather_nd.hppindex 7f733876137..5f2e524672b 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/gather_nd.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/gather_nd.hpp@@ -37,11 +37,13 @@ struct GatherNDImplementationManager : public ImplementationManager {const auto& in0_layout = node.get_input_layout(0);const auto& in1_layout = node.get_input_layout(1);const auto& out_layout = node.get_output_layout(0);- if (!one_of(in0_layout.format, supported_fmts) || !one_of(out_layout.format, supported_fmts))+ if (!one_of(in0_layout.format, supported_fmts) || !one_of(out_layout.format, supported_fmts)) {return false;+ }- if (!one_of(in0_layout.data_type, supported_in_types) || !one_of(in1_layout.data_type, supported_in_types))+ if (!one_of(in0_layout.data_type, supported_in_types) || !one_of(in1_layout.data_type, supported_in_types)) {return false;+ }return one_of(out_layout.data_type, supported_out_types);}diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/gemm.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/gemm.cppindex 32fb74b81ec..0bfdeddf09f 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/gemm.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/gemm.cpp@@ -3,14 +3,14 @@//#include "intel_gpu/op/gemm.hpp"-#include "intel_gpu/plugin/common_utils.hpp"-#include "intel_gpu/graph/kernel_impl_params.hpp"-#include "multi_stage_primitive.hpp"-#include "kv_cache_inst.h"-#include "gemm_inst.h"#include "gemm/gemm_kernel_base.h"#include "gemm/gemm_kernel_selector.h"+#include "gemm_inst.h"+#include "intel_gpu/graph/kernel_impl_params.hpp"+#include "intel_gpu/plugin/common_utils.hpp"+#include "kv_cache_inst.h"+#include "multi_stage_primitive.hpp"namespace cldnn {namespace ocl {@@ -98,8 +98,9 @@ protected:kernel_offset += _kernels_data[s].kernels.size();}for (size_t kd_idx = 0; kd_idx < _kernels_data[stage].kernels.size(); ++kd_idx) {- if (_kernels_data[stage].kernels[kd_idx].skip_execution)+ if (_kernels_data[stage].kernels[kd_idx].skip_execution) {continue;+ }size_t idx_final = kernel_offset + kd_idx;// If any user of the prim's users is CPU implementation or network's output, set prim as a output event (event won't be nullptr)@@ -135,19 +136,22 @@ protected:bool need_indirect_load(const gemm_inst& inst) const {auto desc = inst.get_typed_desc<gemm>();- if (!desc->indirect_a && !desc->indirect_b)+ if (!desc->indirect_a && !desc->indirect_b) {return false;+ }const auto& params = *inst.get_impl_params();const auto indirect_axis = desc->indirect_axis;- if (params.input_layouts[get_beam_table_id(desc)].get_partial_shape()[indirect_axis].get_length() == 1)+ if (params.input_layouts[get_beam_table_id(desc)].get_partial_shape()[indirect_axis].get_length() == 1) {return false;+ }const auto& deps = inst.dependencies();const auto& indirect_dep = deps[desc->indirect_a ? 0 : 1].first;- if (dynamic_cast<const kv_cache_inst*>(indirect_dep) == nullptr)+ if (dynamic_cast<const kv_cache_inst*>(indirect_dep) == nullptr) {return true;+ }auto state_layout = indirect_dep->get_impl_params()->get_input_layout(0);bool is_prefill = state_layout.count() == 0;@@ -157,8 +161,7 @@ protected:event::ptr execute_impl(const std::vector<event::ptr>& events, gemm_inst& instance) override {kernel_dump_info.clear_entries();- if (instance.get_input_layout(0).count() == 0 ||- instance.get_input_layout(1).count() == 0) {+ if (instance.get_input_layout(0).count() == 0 || instance.get_input_layout(1).count() == 0) {stream& stream = instance.get_network().get_stream();stream.enqueue_barrier();return instance.output_memory_ptr()->fill(stream, {}, false);@@ -200,11 +203,8 @@ public:auto input0_pshape = impl_param.input_layouts[0].get_partial_shape();auto input1_pshape = impl_param.input_layouts[1].get_partial_shape();- const auto is_broadcastable = input0_pshape.rank().is_static() &&- input1_pshape.rank().is_static() &&- input0_pshape.size() > 1 &&- input1_pshape.size() > 1 &&- (primitive->input_rank == primitive->weight_rank);+ const auto is_broadcastable = input0_pshape.rank().is_static() && input1_pshape.rank().is_static() && input0_pshape.size() > 1 &&+ input1_pshape.size() > 1 && (primitive->input_rank == primitive->weight_rank);if (is_broadcastable) {auto transpose_pshape = [](const ov::PartialShape pshape, const std::vector<int64_t>& order) {if (order.size() < pshape.size()) {@@ -220,16 +220,13 @@ public:transposed_pshape[i] = pshape[order[i]];}return transposed_pshape;-};size_t max_rank = input0_pshape.size();auto default_order = ov::intel_gpu::op::Gemm::default_order(max_rank);- auto input0_trans_pshape = (primitive->input0_transpose_order != default_order) ?- transpose_pshape(input0_pshape, primitive->input0_transpose_order) :- input0_pshape;- auto input1_trans_pshape = (primitive->input1_transpose_order != default_order) ?- transpose_pshape(input1_pshape, primitive->input1_transpose_order) :- input1_pshape;+ auto input0_trans_pshape =+ (primitive->input0_transpose_order != default_order) ? transpose_pshape(input0_pshape, primitive->input0_transpose_order) : input0_pshape;+ auto input1_trans_pshape =+ (primitive->input1_transpose_order != default_order) ? transpose_pshape(input1_pshape, primitive->input1_transpose_order) : input1_pshape;for (size_t i = 0; i < max_rank - 2; ++i) {if (input0_trans_pshape[i].is_static() && input1_trans_pshape[i].is_static()) {if (input1_trans_pshape[i].get_length() > input0_trans_pshape[i].get_length()) {@@ -252,8 +249,9 @@ public:}bool is_quantized = true;- for (const auto& input : impl_param.input_layouts)+ for (const auto& input : impl_param.input_layouts) {is_quantized &= data_type_traits::is_quantized(input.data_type);+ }if (is_quantized) {params.quantization = kernel_selector::QuantizationType::SYMMETRIC;@@ -265,12 +263,14 @@ public:if ((primitive->indirect_a || primitive->indirect_b) && !indirect) {// Need to adjust regular gemm kernel offset to skip beam table inputfor (auto& fd : params.fused_ops) {- if (!fd.has_outer_dep())+ if (!fd.has_outer_dep()) {continue;+ }auto& fused_op_inputs = fd.tensors;for (auto& fused_input : fused_op_inputs) {- if (fused_input.is_dynamic())+ if (fused_input.is_dynamic()) {fused_input.SetDynamicShapeOffset(fused_input.get_dynamic_shape_offset() + kernel_selector::DataTensor::max_rank());+ }}}for (auto& out : params.outputs) {@@ -286,8 +286,8 @@ public:const auto& primitive = impl_params.typed_desc<gemm>();auto updated_impl_params = canonicalize_fused_shapes(impl_params);- updated_impl_params.input_layouts = gemm_inst::transform_input_layouts(primitive, impl_params.input_layouts,- impl_params.get_program().is_new_shape_infer());+ updated_impl_params.input_layouts =+ gemm_inst::transform_input_layouts(primitive, impl_params.input_layouts, impl_params.get_program().is_new_shape_infer());updated_impl_params.output_layouts[0] = gemm_inst::transform_output_layout(primitive, updated_impl_params.input_layouts, impl_params.output_layouts[0]);for (auto& input_layout : updated_impl_params.input_layouts) {@@ -342,13 +342,9 @@ public:namespace detail {attach_gemm_impl::attach_gemm_impl() {- const std::vector<data_types> types{data_types::f16,- data_types::f32,- data_types::i8,- data_types::u8,- data_types::i32};+ const std::vector<data_types> types{data_types::f16, data_types::f32, data_types::i8, data_types::u8, data_types::i32};- const std::vector<format::type> formats {+ const std::vector<format::type> formats{format::bfyx,format::b_fs_yx_fsv16,format::b_fs_yx_fsv32,@@ -367,15 +363,13 @@ attach_gemm_impl::attach_gemm_impl() {implementation_map<gemm>::add(impl_types::ocl, shape_types::static_shape, gemm_impl::create, types, formats);- const std::vector<format::type> dyn_formats {+ const std::vector<format::type> dyn_formats{format::bfyx,format::bfzyx,format::bfwzyx,};- implementation_map<gemm>::add(impl_types::ocl,- shape_types::dynamic_shape,- gemm_impl::create, types, dyn_formats);+ implementation_map<gemm>::add(impl_types::ocl, shape_types::dynamic_shape, gemm_impl::create, types, dyn_formats);}} // namespace detaildiff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cppindex 1fc56896f9c..9ac739deac6 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cpp@@ -2,67 +2,63 @@// SPDX-License-Identifier: Apache-2.0//-#include "intel_gpu/graph/program.hpp"-#include "kernel_selector_helper.h"-#include "intel_gpu/runtime/device_info.hpp"-#include "kernel_selector_params.h"-#include "to_string_utils.h"-#include "program_node.h"++#include <chrono>+#include <string>+#include <type_traits>+#include <vector>++#include "activation_inst.h"+#include "eltwise_inst.h"+#include "impls/ocl/kernels_cache.hpp"+#include "intel_gpu/graph/program.hpp"#include "intel_gpu/graph/serialization/layout_serializer.hpp"#include "intel_gpu/graph/serialization/polymorphic_serializer.hpp"#include "intel_gpu/graph/serialization/string_serializer.hpp"#include "intel_gpu/graph/serialization/vector_serializer.hpp"-#include "intel_gpu/primitives/concatenation.hpp"#include "intel_gpu/primitives/convolution.hpp"#include "intel_gpu/primitives/crop.hpp"+#include "intel_gpu/primitives/cum_sum.hpp"+#include "intel_gpu/primitives/depth_to_space.hpp"#include "intel_gpu/primitives/eltwise.hpp"+#include "intel_gpu/primitives/embedding_bag.hpp"+#include "intel_gpu/primitives/extract_image_patches.hpp"#include "intel_gpu/primitives/fully_connected.hpp"#include "intel_gpu/primitives/normalize.hpp"#include "intel_gpu/primitives/reorder.hpp"#include "intel_gpu/primitives/reshape.hpp"+#include "intel_gpu/primitives/reverse_sequence.hpp"#include "intel_gpu/primitives/roi_pooling.hpp"-#include "intel_gpu/primitives/softmax.hpp"-#include "intel_gpu/primitives/depth_to_space.hpp"#include "intel_gpu/primitives/shuffle_channels.hpp"+#include "intel_gpu/primitives/softmax.hpp"#include "intel_gpu/primitives/strided_slice.hpp"-#include "intel_gpu/primitives/cum_sum.hpp"-#include "intel_gpu/primitives/reverse_sequence.hpp"-#include "intel_gpu/primitives/embedding_bag.hpp"-#include "intel_gpu/primitives/extract_image_patches.hpp"--#include "swiglu_inst.h"-#include "activation_inst.h"-#include "eltwise_inst.h"-#include "quantize_inst.h"-#include "reorder_inst.h"--#include "kernel_selector/kernels/swiglu/swiglu_kernel_base.h"+#include "intel_gpu/runtime/device_info.hpp"#include "kernel_selector/kernels/activation/activation_kernel_base.h"#include "kernel_selector/kernels/depth_to_space/depth_to_space_kernel_base.h"#include "kernel_selector/kernels/eltwise/eltwise_kernel_base.h"#include "kernel_selector/kernels/quantize/quantize_kernel_params.h"#include "kernel_selector/kernels/reorder/reorder_kernel_base.h"--#include "impls/ocl/kernels_cache.hpp"--#include <string>-#include <type_traits>-#include <vector>-#include <chrono>+#include "kernel_selector/kernels/swiglu/swiglu_kernel_base.h"+#include "kernel_selector_params.h"+#include "program_node.h"+#include "quantize_inst.h"+#include "reorder_inst.h"+#include "swiglu_inst.h"+#include "to_string_utils.h"namespace {using namespace cldnn;kernel_selector::dev_type get_device_type(cldnn::device_type type) {switch (type) {- case cldnn::device_type::integrated_gpu:- return kernel_selector::dev_type::integrated_gpu;- case cldnn::device_type::discrete_gpu:- return kernel_selector::dev_type::discrete_gpu;- default:- return kernel_selector::dev_type::integrated_gpu;+ case cldnn::device_type::integrated_gpu:+ return kernel_selector::dev_type::integrated_gpu;+ case cldnn::device_type::discrete_gpu:+ return kernel_selector::dev_type::discrete_gpu;+ default:+ return kernel_selector::dev_type::integrated_gpu;}}@@ -111,8 +107,7 @@ bool check_cm_jit_support(cldnn::engine& e, const cldnn::ExecutionConfig& config}// Add timestamp to avoid IGC uses a cached cm_check kernel.- auto timestamp = std::chrono::high_resolution_clock::now()- .time_since_epoch().count();+ auto timestamp = std::chrono::high_resolution_clock::now().time_since_epoch().count();kernel_string->options += " -DSEED=" + to_string(timestamp);try {@@ -133,12 +128,14 @@ static bool parse_driver_version(const std::string& driver_version, size_t num_cconst char* last = driver_version.data() + driver_version.size();for (size_t i = 0; i < num_components; i++) {auto [ptr, ec] = std::from_chars(first, last, components[i]);- if (ec != std::errc())+ if (ec != std::errc()) {return false;+ }if (i + 1 < num_components) {// Expect a '.' separator before the next component- if (ptr == last || *ptr != '.')+ if (ptr == last || *ptr != '.') {return false;+ }first = ptr + 1;}}@@ -152,8 +149,9 @@ static bool driver_version_supports_microkernels(const std::string& driver_versireturn false;return std::tie(v[0], v[1], v[2], v[3]) >= std::make_tuple(31, 0, 101, 6987);#else- if (!parse_driver_version(driver_version, 3, v))+ if (!parse_driver_version(driver_version, 3, v)) {return false;+ }return std::tie(v[0], v[1], v[2]) >= std::make_tuple(24, 22, 29735);#endif}@@ -209,8 +207,9 @@ bool query_microkernels_supported(cldnn::engine& e, const cldnn::ExecutionConfigbool query_register_file_size_option_supported(cldnn::engine& e, const cldnn::ExecutionConfig& config) {auto* device = e.get_device().get();- if (device->get_info().arch < gpu_arch::xe3)+ if (device->get_info().arch < gpu_arch::xe3) {return false;+ }static std::mutex m;std::lock_guard<std::mutex> lock(m);@@ -242,729 +241,727 @@ bool query_register_file_size_option_supported(cldnn::engine& e, const cldnn::Exkernel_selector::data_type to_data_type(data_types dt) {switch (dt) {- case cldnn::data_types::u2:- return kernel_selector::data_type::UINT2;- case cldnn::data_types::i4:- return kernel_selector::data_type::INT4;- case cldnn::data_types::u4:- return kernel_selector::data_type::UINT4;- case cldnn::data_types::i8:- return kernel_selector::data_type::INT8;- case cldnn::data_types::u8:- return kernel_selector::data_type::UINT8;- case cldnn::data_types::i16:- return kernel_selector::data_type::INT16;- case cldnn::data_types::u16:- return kernel_selector::data_type::UINT16;- case cldnn::data_types::i32:- return kernel_selector::data_type::INT32;- case cldnn::data_types::u32:- return kernel_selector::data_type::UINT32;- case cldnn::data_types::i64:- return kernel_selector::data_type::INT64;- case cldnn::data_types::f16:- return kernel_selector::data_type::F16;- case cldnn::data_types::f32:- return kernel_selector::data_type::F32;- case cldnn::data_types::bf16:- return kernel_selector::data_type::BF16;- case cldnn::data_types::f4e2m1:- return kernel_selector::data_type::F4E2M1;- case cldnn::data_types::f8e4m3:- return kernel_selector::data_type::F8E4M3;- case cldnn::data_types::f8e5m2:- return kernel_selector::data_type::F8E5M2;- case cldnn::data_types::f8e8m0:- return kernel_selector::data_type::F8E8M0;- default:- OPENVINO_THROW("[GPU] Unable to convert cldnn data type ", dt, " to kernel_selector data type");+ case cldnn::data_types::u2:+ return kernel_selector::data_type::UINT2;+ case cldnn::data_types::i4:+ return kernel_selector::data_type::INT4;+ case cldnn::data_types::u4:+ return kernel_selector::data_type::UINT4;+ case cldnn::data_types::i8:+ return kernel_selector::data_type::INT8;+ case cldnn::data_types::u8:+ return kernel_selector::data_type::UINT8;+ case cldnn::data_types::i16:+ return kernel_selector::data_type::INT16;+ case cldnn::data_types::u16:+ return kernel_selector::data_type::UINT16;+ case cldnn::data_types::i32:+ return kernel_selector::data_type::INT32;+ case cldnn::data_types::u32:+ return kernel_selector::data_type::UINT32;+ case cldnn::data_types::i64:+ return kernel_selector::data_type::INT64;+ case cldnn::data_types::f16:+ return kernel_selector::data_type::F16;+ case cldnn::data_types::f32:+ return kernel_selector::data_type::F32;+ case cldnn::data_types::bf16:+ return kernel_selector::data_type::BF16;+ case cldnn::data_types::f4e2m1:+ return kernel_selector::data_type::F4E2M1;+ case cldnn::data_types::f8e4m3:+ return kernel_selector::data_type::F8E4M3;+ case cldnn::data_types::f8e5m2:+ return kernel_selector::data_type::F8E5M2;+ case cldnn::data_types::f8e8m0:+ return kernel_selector::data_type::F8E8M0;+ default:+ OPENVINO_THROW("[GPU] Unable to convert cldnn data type ", dt, " to kernel_selector data type");}}data_types from_data_type(kernel_selector::data_type dt) {switch (dt) {- case kernel_selector::data_type::UINT2:- return cldnn::data_types::u2;- case kernel_selector::data_type::INT4:- return cldnn::data_types::i4;- case kernel_selector::data_type::UINT4:- return cldnn::data_types::u4;- case kernel_selector::data_type::INT8:- return cldnn::data_types::i8;- case kernel_selector::data_type::UINT8:- return cldnn::data_types::u8;- case kernel_selector::data_type::INT16:- return cldnn::data_types::i16;- case kernel_selector::data_type::UINT16:- return cldnn::data_types::u16;- case kernel_selector::data_type::INT32:- return cldnn::data_types::i32;- case kernel_selector::data_type::UINT32:- return cldnn::data_types::u32;- case kernel_selector::data_type::INT64:- return cldnn::data_types::i64;- case kernel_selector::data_type::F16:- return cldnn::data_types::f16;- case kernel_selector::data_type::F32:- return cldnn::data_types::f32;- case kernel_selector::data_type::F4E2M1:- return cldnn::data_types::f4e2m1;- case kernel_selector::data_type::F8E4M3:- return cldnn::data_types::f8e4m3;- case kernel_selector::data_type::F8E5M2:- return cldnn::data_types::f8e5m2;- case kernel_selector::data_type::F8E8M0:- return cldnn::data_types::f8e8m0;- default:- OPENVINO_THROW("[GPU] Unable to convert kernel_selector data type ", kernel_selector::toString(dt), " to cldnn data type");+ case kernel_selector::data_type::UINT2:+ return cldnn::data_types::u2;+ case kernel_selector::data_type::INT4:+ return cldnn::data_types::i4;+ case kernel_selector::data_type::UINT4:+ return cldnn::data_types::u4;+ case kernel_selector::data_type::INT8:+ return cldnn::data_types::i8;+ case kernel_selector::data_type::UINT8:+ return cldnn::data_types::u8;+ case kernel_selector::data_type::INT16:+ return cldnn::data_types::i16;+ case kernel_selector::data_type::UINT16:+ return cldnn::data_types::u16;+ case kernel_selector::data_type::INT32:+ return cldnn::data_types::i32;+ case kernel_selector::data_type::UINT32:+ return cldnn::data_types::u32;+ case kernel_selector::data_type::INT64:+ return cldnn::data_types::i64;+ case kernel_selector::data_type::F16:+ return cldnn::data_types::f16;+ case kernel_selector::data_type::F32:+ return cldnn::data_types::f32;+ case kernel_selector::data_type::F4E2M1:+ return cldnn::data_types::f4e2m1;+ case kernel_selector::data_type::F8E4M3:+ return cldnn::data_types::f8e4m3;+ case kernel_selector::data_type::F8E5M2:+ return cldnn::data_types::f8e5m2;+ case kernel_selector::data_type::F8E8M0:+ return cldnn::data_types::f8e8m0;+ default:+ OPENVINO_THROW("[GPU] Unable to convert kernel_selector data type ", kernel_selector::toString(dt), " to cldnn data type");}}kernel_selector::weights_type to_weights_type(data_types dt) {switch (dt) {- case cldnn::data_types::u2:- return kernel_selector::weights_type::UINT2;- case cldnn::data_types::u4:- return kernel_selector::weights_type::UINT4;- case cldnn::data_types::i4:- return kernel_selector::weights_type::INT4;- case cldnn::data_types::i8:- return kernel_selector::weights_type::INT8;- case cldnn::data_types::u8:- return kernel_selector::weights_type::UINT8;- case cldnn::data_types::f16:- return kernel_selector::weights_type::F16;- case cldnn::data_types::f32:- return kernel_selector::weights_type::F32;- case cldnn::data_types::i32:- return kernel_selector::weights_type::INT32;- case cldnn::data_types::bf16:- return kernel_selector::weights_type::BF16;- case cldnn::data_types::f4e2m1:- return kernel_selector::weights_type::F4E2M1;- case cldnn::data_types::f8e4m3:- return kernel_selector::weights_type::F8E4M3;- case cldnn::data_types::f8e5m2:- return kernel_selector::weights_type::F8E5M2;- case cldnn::data_types::f8e8m0:- return kernel_selector::weights_type::F8E8M0;- default:- OPENVINO_THROW("[GPU] Unable to convert cldnn data type ", dt, " to kernel_selector weights type");+ case cldnn::data_types::u2:+ return kernel_selector::weights_type::UINT2;+ case cldnn::data_types::u4:+ return kernel_selector::weights_type::UINT4;+ case cldnn::data_types::i4:+ return kernel_selector::weights_type::INT4;+ case cldnn::data_types::i8:+ return kernel_selector::weights_type::INT8;+ case cldnn::data_types::u8:+ return kernel_selector::weights_type::UINT8;+ case cldnn::data_types::f16:+ return kernel_selector::weights_type::F16;+ case cldnn::data_types::f32:+ return kernel_selector::weights_type::F32;+ case cldnn::data_types::i32:+ return kernel_selector::weights_type::INT32;+ case cldnn::data_types::bf16:+ return kernel_selector::weights_type::BF16;+ case cldnn::data_types::f4e2m1:+ return kernel_selector::weights_type::F4E2M1;+ case cldnn::data_types::f8e4m3:+ return kernel_selector::weights_type::F8E4M3;+ case cldnn::data_types::f8e5m2:+ return kernel_selector::weights_type::F8E5M2;+ case cldnn::data_types::f8e8m0:+ return kernel_selector::weights_type::F8E8M0;+ default:+ OPENVINO_THROW("[GPU] Unable to convert cldnn data type ", dt, " to kernel_selector weights type");}}data_types from_weights_type(kernel_selector::weights_type dt) {switch (dt) {- case kernel_selector::weights_type::UINT2:- return data_types::u2;- case kernel_selector::weights_type::INT4:- return data_types::i4;- case kernel_selector::weights_type::UINT4:- return data_types::u4;- case kernel_selector::weights_type::INT8:- return data_types::i8;- case kernel_selector::weights_type::UINT8:- return data_types::u8;- case kernel_selector::weights_type::F16:- return data_types::f16;- case kernel_selector::weights_type::F32:- return data_types::f32;- case kernel_selector::weights_type::INT32:- return data_types::i32;- case kernel_selector::weights_type::F4E2M1:- return data_types::f4e2m1;- case kernel_selector::weights_type::F8E4M3:- return data_types::f8e4m3;- case kernel_selector::weights_type::F8E5M2:- return data_types::f8e5m2;- case kernel_selector::weights_type::F8E8M0:- return data_types::f8e8m0;- default:- OPENVINO_THROW("[GPU] Unable to convert kernel_selector weights type ", kernel_selector::toString(dt), " to cldnn data type");+ case kernel_selector::weights_type::UINT2:+ return data_types::u2;+ case kernel_selector::weights_type::INT4:+ return data_types::i4;+ case kernel_selector::weights_type::UINT4:+ return data_types::u4;+ case kernel_selector::weights_type::INT8:+ return data_types::i8;+ case kernel_selector::weights_type::UINT8:+ return data_types::u8;+ case kernel_selector::weights_type::F16:+ return data_types::f16;+ case kernel_selector::weights_type::F32:+ return data_types::f32;+ case kernel_selector::weights_type::INT32:+ return data_types::i32;+ case kernel_selector::weights_type::F4E2M1:+ return data_types::f4e2m1;+ case kernel_selector::weights_type::F8E4M3:+ return data_types::f8e4m3;+ case kernel_selector::weights_type::F8E5M2:+ return data_types::f8e5m2;+ case kernel_selector::weights_type::F8E8M0:+ return data_types::f8e8m0;+ default:+ OPENVINO_THROW("[GPU] Unable to convert kernel_selector weights type ", kernel_selector::toString(dt), " to cldnn data type");}}kernel_selector::data_layout to_data_layout(format f) {switch (f) {- case format::bfyx:- return kernel_selector::data_layout::bfyx;- case format::yxfb:- return kernel_selector::data_layout::yxfb;- case format::byxf:- return kernel_selector::data_layout::byxf;- case format::byfx:- return kernel_selector::data_layout::byfx;- case format::bxfy:- return kernel_selector::data_layout::bxfy;- case format::fbyx:- return kernel_selector::data_layout::fbyx;- case format::fyxb:- return kernel_selector::data_layout::fyxb;- case format::b_fs_yx_fsv2:- return kernel_selector::data_layout::b_fs_yx_fsv2;- case format::b_fs_yx_fsv4:- return kernel_selector::data_layout::b_fs_yx_fsv4;- case format::b_fs_yx_fsv8:- return kernel_selector::data_layout::b_fs_yx_fsv8;- case format::b_fs_yx_fsv16:- return kernel_selector::data_layout::b_fs_yx_fsv16;- case format::b_fs_yx_fsv32:- return kernel_selector::data_layout::b_fs_yx_fsv32;- case format::b_fs_zyx_fsv2:- return kernel_selector::data_layout::b_fs_zyx_fsv2;- case format::b_fs_zyx_fsv4:- return kernel_selector::data_layout::b_fs_zyx_fsv4;- case format::b_fs_zyx_fsv8:- return kernel_selector::data_layout::b_fs_zyx_fsv8;- case format::b_fs_zyx_fsv32:- return kernel_selector::data_layout::b_fs_zyx_fsv32;- case format::bs_f_bsv16:- return kernel_selector::data_layout::bs_f_bsv16__af8;- case format::bs_fs_fsv8_bsv8:- return kernel_selector::data_layout::bs_f_bsv8__af8;- case format::winograd_2x3_s1_data:- return kernel_selector::data_layout::winograd_2x3_s1_data;- case format::bfzyx:- return kernel_selector::data_layout::bfzyx;- case format::bzyxf:- return kernel_selector::data_layout::bzyxf;- case format::ybfx:- return kernel_selector::data_layout::ybfx;- case format::fs_b_yx_fsv32:- return kernel_selector::data_layout::fs_b_yx_fsv32;- case format::bfwzyx:- return kernel_selector::data_layout::bfwzyx;- case format::bfuwzyx:- return kernel_selector::data_layout::bfuwzyx;- case format::bfvuwzyx:- return kernel_selector::data_layout::bfvuwzyx;- case format::b_fs_zyx_fsv16:- return kernel_selector::data_layout::b_fs_zyx_fsv16;- case format::bs_fs_yx_bsv16_fsv32:- return kernel_selector::data_layout::bs_fs_yx_bsv16_fsv32;- case format::bs_fs_zyx_bsv16_fsv32:- return kernel_selector::data_layout::bs_fs_zyx_bsv16_fsv32;- case format::bs_fs_zyx_bsv16_fsv16:- return kernel_selector::data_layout::bs_fs_zyx_bsv16_fsv16;- case format::bs_fs_yx_bsv16_fsv16:- return kernel_selector::data_layout::bs_fs_yx_bsv16_fsv16;- case format::bs_fs_zyx_bsv32_fsv16:- return kernel_selector::data_layout::bs_fs_zyx_bsv32_fsv16;- case format::bs_fs_yx_bsv32_fsv16:- return kernel_selector::data_layout::bs_fs_yx_bsv32_fsv16;- case format::bs_fs_yx_bsv4_fsv4:- return kernel_selector::data_layout::bs_fs_yx_bsv4_fsv4;- case format::bs_fs_yx_bsv8_fsv4:- return kernel_selector::data_layout::bs_fs_yx_bsv8_fsv4;- case format::bs_fs_zyx_bsv8_fsv4:- return kernel_selector::data_layout::bs_fs_zyx_bsv8_fsv4;- case format::bs_fs_yx_bsv16_fsv4:- return kernel_selector::data_layout::bs_fs_yx_bsv16_fsv4;- case format::bs_fs_zyx_bsv16_fsv4:- return kernel_selector::data_layout::bs_fs_zyx_bsv16_fsv4;- case format::bs_fs_yx_bsv16_fsv2:- return kernel_selector::data_layout::bs_fs_yx_bsv16_fsv2;- case format::bs_fs_zyx_bsv16_fsv2:- return kernel_selector::data_layout::bs_fs_zyx_bsv16_fsv2;- case format::bs_fs_yx_bsv16_fsv8:- return kernel_selector::data_layout::bs_fs_yx_bsv16_fsv8;- case format::bs_fs_zyx_bsv16_fsv8:- return kernel_selector::data_layout::bs_fs_zyx_bsv16_fsv8;- case format::bs_fs_yx_bsv8_fsv2:- return kernel_selector::data_layout::bs_fs_yx_bsv8_fsv2;- case format::bs_fs_zyx_bsv8_fsv2:- return kernel_selector::data_layout::bs_fs_zyx_bsv8_fsv2;- case format::bs_fs_yx_bsv4_fsv2:- return kernel_selector::data_layout::bs_fs_yx_bsv4_fsv2;- case format::bs_fs_yx_bsv32_fsv32:- return kernel_selector::data_layout::bs_fs_yx_bsv32_fsv32;- case format::bs_fs_zyx_bsv32_fsv32:- return kernel_selector::data_layout::bs_fs_zyx_bsv32_fsv32;- case format::nv12:- return kernel_selector::data_layout::nv12;- case format::image_2d_rgba:- return kernel_selector::data_layout::image_2d_rgba;- default:- OPENVINO_THROW("[GPU] Can't convert tensor format to kernel selector format as f=", f, " is not handled");+ case format::bfyx:+ return kernel_selector::data_layout::bfyx;+ case format::yxfb:+ return kernel_selector::data_layout::yxfb;+ case format::byxf:+ return kernel_selector::data_layout::byxf;+ case format::byfx:+ return kernel_selector::data_layout::byfx;+ case format::bxfy:+ return kernel_selector::data_layout::bxfy;+ case format::fbyx:+ return kernel_selector::data_layout::fbyx;+ case format::fyxb:+ return kernel_selector::data_layout::fyxb;+ case format::b_fs_yx_fsv2:+ return kernel_selector::data_layout::b_fs_yx_fsv2;+ case format::b_fs_yx_fsv4:+ return kernel_selector::data_layout::b_fs_yx_fsv4;+ case format::b_fs_yx_fsv8:+ return kernel_selector::data_layout::b_fs_yx_fsv8;+ case format::b_fs_yx_fsv16:+ return kernel_selector::data_layout::b_fs_yx_fsv16;+ case format::b_fs_yx_fsv32:+ return kernel_selector::data_layout::b_fs_yx_fsv32;+ case format::b_fs_zyx_fsv2:+ return kernel_selector::data_layout::b_fs_zyx_fsv2;+ case format::b_fs_zyx_fsv4:+ return kernel_selector::data_layout::b_fs_zyx_fsv4;+ case format::b_fs_zyx_fsv8:+ return kernel_selector::data_layout::b_fs_zyx_fsv8;+ case format::b_fs_zyx_fsv32:+ return kernel_selector::data_layout::b_fs_zyx_fsv32;+ case format::bs_f_bsv16:+ return kernel_selector::data_layout::bs_f_bsv16__af8;+ case format::bs_fs_fsv8_bsv8:+ return kernel_selector::data_layout::bs_f_bsv8__af8;+ case format::winograd_2x3_s1_data:+ return kernel_selector::data_layout::winograd_2x3_s1_data;+ case format::bfzyx:+ return kernel_selector::data_layout::bfzyx;+ case format::bzyxf:+ return kernel_selector::data_layout::bzyxf;+ case format::ybfx:+ return kernel_selector::data_layout::ybfx;+ case format::fs_b_yx_fsv32:+ return kernel_selector::data_layout::fs_b_yx_fsv32;+ case format::bfwzyx:+ return kernel_selector::data_layout::bfwzyx;+ case format::bfuwzyx:+ return kernel_selector::data_layout::bfuwzyx;+ case format::bfvuwzyx:+ return kernel_selector::data_layout::bfvuwzyx;+ case format::b_fs_zyx_fsv16:+ return kernel_selector::data_layout::b_fs_zyx_fsv16;+ case format::bs_fs_yx_bsv16_fsv32:+ return kernel_selector::data_layout::bs_fs_yx_bsv16_fsv32;+ case format::bs_fs_zyx_bsv16_fsv32:+ return kernel_selector::data_layout::bs_fs_zyx_bsv16_fsv32;+ case format::bs_fs_zyx_bsv16_fsv16:+ return kernel_selector::data_layout::bs_fs_zyx_bsv16_fsv16;+ case format::bs_fs_yx_bsv16_fsv16:+ return kernel_selector::data_layout::bs_fs_yx_bsv16_fsv16;+ case format::bs_fs_zyx_bsv32_fsv16:+ return kernel_selector::data_layout::bs_fs_zyx_bsv32_fsv16;+ case format::bs_fs_yx_bsv32_fsv16:+ return kernel_selector::data_layout::bs_fs_yx_bsv32_fsv16;+ case format::bs_fs_yx_bsv4_fsv4:+ return kernel_selector::data_layout::bs_fs_yx_bsv4_fsv4;+ case format::bs_fs_yx_bsv8_fsv4:+ return kernel_selector::data_layout::bs_fs_yx_bsv8_fsv4;+ case format::bs_fs_zyx_bsv8_fsv4:+ return kernel_selector::data_layout::bs_fs_zyx_bsv8_fsv4;+ case format::bs_fs_yx_bsv16_fsv4:+ return kernel_selector::data_layout::bs_fs_yx_bsv16_fsv4;+ case format::bs_fs_zyx_bsv16_fsv4:+ return kernel_selector::data_layout::bs_fs_zyx_bsv16_fsv4;+ case format::bs_fs_yx_bsv16_fsv2:+ return kernel_selector::data_layout::bs_fs_yx_bsv16_fsv2;+ case format::bs_fs_zyx_bsv16_fsv2:+ return kernel_selector::data_layout::bs_fs_zyx_bsv16_fsv2;+ case format::bs_fs_yx_bsv16_fsv8:+ return kernel_selector::data_layout::bs_fs_yx_bsv16_fsv8;+ case format::bs_fs_zyx_bsv16_fsv8:+ return kernel_selector::data_layout::bs_fs_zyx_bsv16_fsv8;+ case format::bs_fs_yx_bsv8_fsv2:+ return kernel_selector::data_layout::bs_fs_yx_bsv8_fsv2;+ case format::bs_fs_zyx_bsv8_fsv2:+ return kernel_selector::data_layout::bs_fs_zyx_bsv8_fsv2;+ case format::bs_fs_yx_bsv4_fsv2:+ return kernel_selector::data_layout::bs_fs_yx_bsv4_fsv2;+ case format::bs_fs_yx_bsv32_fsv32:+ return kernel_selector::data_layout::bs_fs_yx_bsv32_fsv32;+ case format::bs_fs_zyx_bsv32_fsv32:+ return kernel_selector::data_layout::bs_fs_zyx_bsv32_fsv32;+ case format::nv12:+ return kernel_selector::data_layout::nv12;+ case format::image_2d_rgba:+ return kernel_selector::data_layout::image_2d_rgba;+ default:+ OPENVINO_THROW("[GPU] Can't convert tensor format to kernel selector format as f=", f, " is not handled");}}cldnn::format from_data_layout(kernel_selector::data_layout l) {switch (l) {- case kernel_selector::data_layout::bf:- return cldnn::format::bfyx;- case kernel_selector::data_layout::fb:- return cldnn::format::fyxb;- case kernel_selector::data_layout::bfyx:- return cldnn::format::bfyx;- case kernel_selector::data_layout::yxfb:- return cldnn::format::yxfb;- case kernel_selector::data_layout::byxf:- return cldnn::format::byxf;- case kernel_selector::data_layout::byfx:- return cldnn::format::byfx;- case kernel_selector::data_layout::bxfy:- return cldnn::format::bxfy;- case kernel_selector::data_layout::fbyx:- return cldnn::format::fbyx;- case kernel_selector::data_layout::fyxb:- return cldnn::format::fyxb;- case kernel_selector::data_layout::b_fs_yx_fsv2:- return cldnn::format::b_fs_yx_fsv2;- case kernel_selector::data_layout::b_fs_yx_fsv4:- return cldnn::format::b_fs_yx_fsv4;- case kernel_selector::data_layout::b_fs_yx_fsv8:- return cldnn::format::b_fs_yx_fsv8;- case kernel_selector::data_layout::b_fs_yx_fsv16:- return cldnn::format::b_fs_yx_fsv16;- case kernel_selector::data_layout::b_fs_yx_fsv32:- return cldnn::format::b_fs_yx_fsv32;- case kernel_selector::data_layout::b_fs_zyx_fsv8:- return cldnn::format::b_fs_zyx_fsv8;- case kernel_selector::data_layout::b_fs_zyx_fsv32:- return cldnn::format::b_fs_zyx_fsv32;- case kernel_selector::data_layout::bs_f_bsv8__af8:- return cldnn::format::bs_fs_fsv8_bsv8;- case kernel_selector::data_layout::bs_f_bsv16__af8:- return cldnn::format::bs_f_bsv16;- case kernel_selector::data_layout::winograd_2x3_s1_data:- return cldnn::format::winograd_2x3_s1_data;- case kernel_selector::data_layout::bfzyx:- return cldnn::format::bfzyx;- case kernel_selector::data_layout::fs_b_yx_fsv32:- return cldnn::format::fs_b_yx_fsv32;- case kernel_selector::data_layout::bfwzyx:- return cldnn::format::bfwzyx;- case kernel_selector::data_layout::bfuwzyx:- return cldnn::format::bfuwzyx;- case kernel_selector::data_layout::bfvuwzyx:- return cldnn::format::bfvuwzyx;- case kernel_selector::data_layout::bs_fs_yx_bsv16_fsv16:- return cldnn::format::bs_fs_yx_bsv16_fsv16;- case kernel_selector::data_layout::bs_fs_zyx_bsv32_fsv16:- return cldnn::format::bs_fs_zyx_bsv32_fsv16;- case kernel_selector::data_layout::bs_fs_yx_bsv32_fsv16:- return cldnn::format::bs_fs_yx_bsv32_fsv16;- case kernel_selector::data_layout::bs_fs_yx_bsv4_fsv2:- return cldnn::format::bs_fs_yx_bsv4_fsv2;- case kernel_selector::data_layout::bs_fs_yx_bsv4_fsv4:- return cldnn::format::bs_fs_yx_bsv4_fsv4;- case kernel_selector::data_layout::bs_fs_yx_bsv8_fsv4:- return cldnn::format::bs_fs_yx_bsv8_fsv4;- case kernel_selector::data_layout::bs_fs_zyx_bsv8_fsv4:- return cldnn::format::bs_fs_zyx_bsv8_fsv4;- case kernel_selector::data_layout::bs_fs_yx_bsv16_fsv4:- return cldnn::format::bs_fs_yx_bsv16_fsv4;- case kernel_selector::data_layout::bs_fs_zyx_bsv16_fsv4:- return cldnn::format::bs_fs_zyx_bsv16_fsv4;- case kernel_selector::data_layout::bs_fs_yx_bsv16_fsv2:- return cldnn::format::bs_fs_yx_bsv16_fsv2;- case kernel_selector::data_layout::bs_fs_zyx_bsv16_fsv2:- return cldnn::format::bs_fs_zyx_bsv16_fsv2;- case kernel_selector::data_layout::bs_fs_yx_bsv16_fsv8:- return cldnn::format::bs_fs_yx_bsv16_fsv8;- case kernel_selector::data_layout::bs_fs_zyx_bsv16_fsv8:- return cldnn::format::bs_fs_zyx_bsv16_fsv8;- case kernel_selector::data_layout::bs_fs_yx_bsv8_fsv2:- return cldnn::format::bs_fs_yx_bsv8_fsv2;- case kernel_selector::data_layout::bs_fs_yx_bsv32_fsv32:- return cldnn::format::bs_fs_yx_bsv32_fsv32;- case kernel_selector::data_layout::bs_fs_zyx_bsv32_fsv32:- return cldnn::format::bs_fs_zyx_bsv32_fsv32;- case kernel_selector::data_layout::nv12:- return cldnn::format::nv12;- case kernel_selector::data_layout::image_2d_rgba:- return cldnn::format::image_2d_rgba;- default:- throw std::invalid_argument("Unable to convert data layout " + std::to_string(l) + " to tensor format");+ case kernel_selector::data_layout::bf:+ return cldnn::format::bfyx;+ case kernel_selector::data_layout::fb:+ return cldnn::format::fyxb;+ case kernel_selector::data_layout::bfyx:+ return cldnn::format::bfyx;+ case kernel_selector::data_layout::yxfb:+ return cldnn::format::yxfb;+ case kernel_selector::data_layout::byxf:+ return cldnn::format::byxf;+ case kernel_selector::data_layout::byfx:+ return cldnn::format::byfx;+ case kernel_selector::data_layout::bxfy:+ return cldnn::format::bxfy;+ case kernel_selector::data_layout::fbyx:+ return cldnn::format::fbyx;+ case kernel_selector::data_layout::fyxb:+ return cldnn::format::fyxb;+ case kernel_selector::data_layout::b_fs_yx_fsv2:+ return cldnn::format::b_fs_yx_fsv2;+ case kernel_selector::data_layout::b_fs_yx_fsv4:+ return cldnn::format::b_fs_yx_fsv4;+ case kernel_selector::data_layout::b_fs_yx_fsv8:+ return cldnn::format::b_fs_yx_fsv8;+ case kernel_selector::data_layout::b_fs_yx_fsv16:+ return cldnn::format::b_fs_yx_fsv16;+ case kernel_selector::data_layout::b_fs_yx_fsv32:+ return cldnn::format::b_fs_yx_fsv32;+ case kernel_selector::data_layout::b_fs_zyx_fsv8:+ return cldnn::format::b_fs_zyx_fsv8;+ case kernel_selector::data_layout::b_fs_zyx_fsv32:+ return cldnn::format::b_fs_zyx_fsv32;+ case kernel_selector::data_layout::bs_f_bsv8__af8:+ return cldnn::format::bs_fs_fsv8_bsv8;+ case kernel_selector::data_layout::bs_f_bsv16__af8:+ return cldnn::format::bs_f_bsv16;+ case kernel_selector::data_layout::winograd_2x3_s1_data:+ return cldnn::format::winograd_2x3_s1_data;+ case kernel_selector::data_layout::bfzyx:+ return cldnn::format::bfzyx;+ case kernel_selector::data_layout::fs_b_yx_fsv32:+ return cldnn::format::fs_b_yx_fsv32;+ case kernel_selector::data_layout::bfwzyx:+ return cldnn::format::bfwzyx;+ case kernel_selector::data_layout::bfuwzyx:+ return cldnn::format::bfuwzyx;+ case kernel_selector::data_layout::bfvuwzyx:+ return cldnn::format::bfvuwzyx;+ case kernel_selector::data_layout::bs_fs_yx_bsv16_fsv16:+ return cldnn::format::bs_fs_yx_bsv16_fsv16;+ case kernel_selector::data_layout::bs_fs_zyx_bsv32_fsv16:+ return cldnn::format::bs_fs_zyx_bsv32_fsv16;+ case kernel_selector::data_layout::bs_fs_yx_bsv32_fsv16:+ return cldnn::format::bs_fs_yx_bsv32_fsv16;+ case kernel_selector::data_layout::bs_fs_yx_bsv4_fsv2:+ return cldnn::format::bs_fs_yx_bsv4_fsv2;+ case kernel_selector::data_layout::bs_fs_yx_bsv4_fsv4:+ return cldnn::format::bs_fs_yx_bsv4_fsv4;+ case kernel_selector::data_layout::bs_fs_yx_bsv8_fsv4:+ return cldnn::format::bs_fs_yx_bsv8_fsv4;+ case kernel_selector::data_layout::bs_fs_zyx_bsv8_fsv4:+ return cldnn::format::bs_fs_zyx_bsv8_fsv4;+ case kernel_selector::data_layout::bs_fs_yx_bsv16_fsv4:+ return cldnn::format::bs_fs_yx_bsv16_fsv4;+ case kernel_selector::data_layout::bs_fs_zyx_bsv16_fsv4:+ return cldnn::format::bs_fs_zyx_bsv16_fsv4;+ case kernel_selector::data_layout::bs_fs_yx_bsv16_fsv2:+ return cldnn::format::bs_fs_yx_bsv16_fsv2;+ case kernel_selector::data_layout::bs_fs_zyx_bsv16_fsv2:+ return cldnn::format::bs_fs_zyx_bsv16_fsv2;+ case kernel_selector::data_layout::bs_fs_yx_bsv16_fsv8:+ return cldnn::format::bs_fs_yx_bsv16_fsv8;+ case kernel_selector::data_layout::bs_fs_zyx_bsv16_fsv8:+ return cldnn::format::bs_fs_zyx_bsv16_fsv8;+ case kernel_selector::data_layout::bs_fs_yx_bsv8_fsv2:+ return cldnn::format::bs_fs_yx_bsv8_fsv2;+ case kernel_selector::data_layout::bs_fs_yx_bsv32_fsv32:+ return cldnn::format::bs_fs_yx_bsv32_fsv32;+ case kernel_selector::data_layout::bs_fs_zyx_bsv32_fsv32:+ return cldnn::format::bs_fs_zyx_bsv32_fsv32;+ case kernel_selector::data_layout::nv12:+ return cldnn::format::nv12;+ case kernel_selector::data_layout::image_2d_rgba:+ return cldnn::format::image_2d_rgba;+ default:+ throw std::invalid_argument("Unable to convert data layout " + std::to_string(l) + " to tensor format");}}kernel_selector::weights_layout to_weights_layout(format f, bool is_grouped) {switch (f) {- case format::bfyx:- case format::oiyx:- return kernel_selector::weights_layout::oiyx;- case format::fbyx:- case format::ioyx:- return kernel_selector::weights_layout::ioyx;- case format::iyxo:- case format::fyxb:- return kernel_selector::weights_layout::iyxo;- case format::oyxi:- case format::byxf:- return kernel_selector::weights_layout::oyxi;- case format::oyix:- case format::byfx:- return kernel_selector::weights_layout::oyix;- case format::oxiy:- case format::bxfy:- return kernel_selector::weights_layout::oxiy;- case format::yxfb:- case format::yxio:- return kernel_selector::weights_layout::yxio;- case format::o_is_yx_isv4:- return kernel_selector::weights_layout::o_is_yx_isv4;- case format::o_is_yx_isv16:- return kernel_selector::weights_layout::o_is_yx_isv16;- case format::os_iyx_osv16:- return kernel_selector::weights_layout::os_iyx_osv16;- case format::os_is_yx_osv16_isv16:- return kernel_selector::weights_layout::os_is_yx_osv16_isv16;- case format::os_iyx_osv32:- return kernel_selector::weights_layout::os_iyx_osv32;- case format::os_iyx_osv32__ai32:- return kernel_selector::weights_layout::os_iyx_osv32__ai32;- case format::os_iyx_osv64:- return kernel_selector::weights_layout::os_iyx_osv64;- case format::image_2d_weights_c4_fyx_b:- return kernel_selector::weights_layout::image_2d_weights_c4_fyx_b;- case format::image_2d_weights_c1_b_fyx:- return kernel_selector::weights_layout::image_2d_weights_c1_b_fyx;- case format::winograd_2x3_s1_weights:- return kernel_selector::weights_layout::winograd_2x3_s1_weights;- case format::winograd_2x3_s1_fused_weights:- return kernel_selector::weights_layout::winograd_2x3_s1_fused_weights;- case format::winograd_6x3_s1_fused_weights:- return kernel_selector::weights_layout::winograd_6x3_s1_fused_weights;- case format::image_2d_weights_winograd_6x3_s1_fbxyb:- return kernel_selector::weights_layout::image_2d_weights_winograd_6x3_s1_fbxyb;- case format::image_2d_weights_winograd_6x3_s1_xfbyb:- return kernel_selector::weights_layout::image_2d_weights_winograd_6x3_s1_xfbyb;- case format::os_is_zyx_osa4_isa8_osv8_isv4:- return kernel_selector::weights_layout::os_is_zyx_osa4_isa8_osv8_isv4;- case format::os_is_yx_osa4_isa8_osv8_isv4:- return kernel_selector::weights_layout::os_is_yx_osa4_isa8_osv8_isv4;- case format::os_is_yx_isa8_osv8_isv4:- return kernel_selector::weights_layout::os_is_yx_isa8_osv8_isv4;- case format::os_is_yx_isa8_osv16_isv4:- return kernel_selector::weights_layout::os_is_yx_isa8_osv16_isv4;- case format::os_is_zyx_isa8_osv8_isv4:- return kernel_selector::weights_layout::os_is_zyx_isa8_osv8_isv4;- case format::os_is_zyx_isa8_osv16_isv4:- return kernel_selector::weights_layout::os_is_zyx_isa8_osv16_isv4;- case format::os_is_yx_osv8_isv4:- return kernel_selector::weights_layout::os_is_yx_osv8_isv4;- case format::os_is_yx_osa4_isa8_osv8_isv4_swizzled_by_4:- return kernel_selector::weights_layout::os_is_yx_osa4_isa8_osv8_isv4_swizzled_by_4;- case format::os_is_zyx_osa4_isa8_osv8_isv4_swizzled_by_4:- return kernel_selector::weights_layout::os_is_zyx_osa4_isa8_osv8_isv4_swizzled_by_4;- case format::os_is_yx_osa2_isa8_osv16_isv4_swizzled_by_2:- return kernel_selector::weights_layout::os_is_yx_osa2_isa8_osv16_isv4_swizzled_by_2;- case format::os_is_zyx_osa2_isa8_osv16_isv4_swizzled_by_2:- return kernel_selector::weights_layout::os_is_zyx_osa2_isa8_osv16_isv4_swizzled_by_2;- case format::os_is_yx_osv16_isv4:- return kernel_selector::weights_layout::os_is_yx_osv16_isv4;- case format::os_is_yx_osv32_isv4_swizzled_by_2:- return kernel_selector::weights_layout::os_is_yx_osv32_isv4_swizzled_by_2;- case format::os_is_yx_osv32_isv4:- return kernel_selector::weights_layout::os_is_yx_osv32_isv4;- case format::os_is_zyx_osv32_isv4:- return kernel_selector::weights_layout::os_is_zyx_osv32_isv4;- case format::os_is_yx_isv16_osv16:- return kernel_selector::weights_layout::os_is_yx_isv16_osv16;- case format::bfzyx:- return is_grouped ? kernel_selector::weights_layout::goiyx : kernel_selector::weights_layout::oizyx;- case format::bfwzyx: {- if (!is_grouped)- throw std::runtime_error("Invalid conversion of data format to weights format. bfwzyx can't be non-grouped as 4D spatials are not supported");- return kernel_selector::weights_layout::goizyx;+ case format::bfyx:+ case format::oiyx:+ return kernel_selector::weights_layout::oiyx;+ case format::fbyx:+ case format::ioyx:+ return kernel_selector::weights_layout::ioyx;+ case format::iyxo:+ case format::fyxb:+ return kernel_selector::weights_layout::iyxo;+ case format::oyxi:+ case format::byxf:+ return kernel_selector::weights_layout::oyxi;+ case format::oyix:+ case format::byfx:+ return kernel_selector::weights_layout::oyix;+ case format::oxiy:+ case format::bxfy:+ return kernel_selector::weights_layout::oxiy;+ case format::yxfb:+ case format::yxio:+ return kernel_selector::weights_layout::yxio;+ case format::o_is_yx_isv4:+ return kernel_selector::weights_layout::o_is_yx_isv4;+ case format::o_is_yx_isv16:+ return kernel_selector::weights_layout::o_is_yx_isv16;+ case format::os_iyx_osv16:+ return kernel_selector::weights_layout::os_iyx_osv16;+ case format::os_is_yx_osv16_isv16:+ return kernel_selector::weights_layout::os_is_yx_osv16_isv16;+ case format::os_iyx_osv32:+ return kernel_selector::weights_layout::os_iyx_osv32;+ case format::os_iyx_osv32__ai32:+ return kernel_selector::weights_layout::os_iyx_osv32__ai32;+ case format::os_iyx_osv64:+ return kernel_selector::weights_layout::os_iyx_osv64;+ case format::image_2d_weights_c4_fyx_b:+ return kernel_selector::weights_layout::image_2d_weights_c4_fyx_b;+ case format::image_2d_weights_c1_b_fyx:+ return kernel_selector::weights_layout::image_2d_weights_c1_b_fyx;+ case format::winograd_2x3_s1_weights:+ return kernel_selector::weights_layout::winograd_2x3_s1_weights;+ case format::winograd_2x3_s1_fused_weights:+ return kernel_selector::weights_layout::winograd_2x3_s1_fused_weights;+ case format::winograd_6x3_s1_fused_weights:+ return kernel_selector::weights_layout::winograd_6x3_s1_fused_weights;+ case format::image_2d_weights_winograd_6x3_s1_fbxyb:+ return kernel_selector::weights_layout::image_2d_weights_winograd_6x3_s1_fbxyb;+ case format::image_2d_weights_winograd_6x3_s1_xfbyb:+ return kernel_selector::weights_layout::image_2d_weights_winograd_6x3_s1_xfbyb;+ case format::os_is_zyx_osa4_isa8_osv8_isv4:+ return kernel_selector::weights_layout::os_is_zyx_osa4_isa8_osv8_isv4;+ case format::os_is_yx_osa4_isa8_osv8_isv4:+ return kernel_selector::weights_layout::os_is_yx_osa4_isa8_osv8_isv4;+ case format::os_is_yx_isa8_osv8_isv4:+ return kernel_selector::weights_layout::os_is_yx_isa8_osv8_isv4;+ case format::os_is_yx_isa8_osv16_isv4:+ return kernel_selector::weights_layout::os_is_yx_isa8_osv16_isv4;+ case format::os_is_zyx_isa8_osv8_isv4:+ return kernel_selector::weights_layout::os_is_zyx_isa8_osv8_isv4;+ case format::os_is_zyx_isa8_osv16_isv4:+ return kernel_selector::weights_layout::os_is_zyx_isa8_osv16_isv4;+ case format::os_is_yx_osv8_isv4:+ return kernel_selector::weights_layout::os_is_yx_osv8_isv4;+ case format::os_is_yx_osa4_isa8_osv8_isv4_swizzled_by_4:+ return kernel_selector::weights_layout::os_is_yx_osa4_isa8_osv8_isv4_swizzled_by_4;+ case format::os_is_zyx_osa4_isa8_osv8_isv4_swizzled_by_4:+ return kernel_selector::weights_layout::os_is_zyx_osa4_isa8_osv8_isv4_swizzled_by_4;+ case format::os_is_yx_osa2_isa8_osv16_isv4_swizzled_by_2:+ return kernel_selector::weights_layout::os_is_yx_osa2_isa8_osv16_isv4_swizzled_by_2;+ case format::os_is_zyx_osa2_isa8_osv16_isv4_swizzled_by_2:+ return kernel_selector::weights_layout::os_is_zyx_osa2_isa8_osv16_isv4_swizzled_by_2;+ case format::os_is_yx_osv16_isv4:+ return kernel_selector::weights_layout::os_is_yx_osv16_isv4;+ case format::os_is_yx_osv32_isv4_swizzled_by_2:+ return kernel_selector::weights_layout::os_is_yx_osv32_isv4_swizzled_by_2;+ case format::os_is_yx_osv32_isv4:+ return kernel_selector::weights_layout::os_is_yx_osv32_isv4;+ case format::os_is_zyx_osv32_isv4:+ return kernel_selector::weights_layout::os_is_zyx_osv32_isv4;+ case format::os_is_yx_isv16_osv16:+ return kernel_selector::weights_layout::os_is_yx_isv16_osv16;+ case format::bfzyx:+ return is_grouped ? kernel_selector::weights_layout::goiyx : kernel_selector::weights_layout::oizyx;+ case format::bfwzyx: {+ if (!is_grouped) {+ throw std::runtime_error("Invalid conversion of data format to weights format. bfwzyx "+ "can't be non-grouped as 4D spatials are not supported");}- case format::oizyx:- return kernel_selector::weights_layout::oizyx;- case format::iozyx:- return kernel_selector::weights_layout::iozyx;- case format::bs_fs_fsv8_bsv8:- case format::os_i_osv8__ai8:- return kernel_selector::weights_layout::os_i_osv8__ai8;- case format::os_i_osv16__ai8:- return kernel_selector::weights_layout::os_i_osv16__ai8;- case format::os_i_osv16:- return kernel_selector::weights_layout::os_i_osv16;- case format::os_is_yx_osv32_isv2:- return kernel_selector::weights_layout::os_is_yx_osv32_isv2;- case format::os_is_yx_osv64_isv2:- return kernel_selector::weights_layout::os_is_yx_osv64_isv2;- case format::os_is_zyx_isv16_osv16:- return kernel_selector::weights_layout::os_is_zyx_isv16_osv16;- case format::is_os_zyx_isv16_osv16:- return kernel_selector::weights_layout::is_os_zyx_isv16_osv16;- case format::os_is_zyx_osv32_isv16:- return kernel_selector::weights_layout::os_is_zyx_osv32_isv16;- case format::is_os_yx_isv16_osv16:- return kernel_selector::weights_layout::is_os_yx_isv16_osv16;- case format::i_yxs_os_yxsv2_osv16:- return kernel_selector::weights_layout::i_yxs_os_yxsv2_osv16;- case format::iy_xs_os_xsv2_osv8__ao32:- return kernel_selector::weights_layout::iy_xs_os_xsv2_osv8__ao32;- case format::iy_xs_os_xsv2_osv16__ao32:- return kernel_selector::weights_layout::iy_xs_os_xsv2_osv16__ao32;- case format::os_is_zyx_isv8_osv16_isv2:- return kernel_selector::weights_layout::os_is_zyx_isv8_osv16_isv2;- case format::os_is_yx_isv8_osv16_isv2:- return kernel_selector::weights_layout::os_is_yx_isv8_osv16_isv2;- case cldnn::format::os_iyx_osv8:- return kernel_selector::weights_layout::os_iyx_osv8;- case format::os_zyxi_osv16:- return kernel_selector::weights_layout::os_zyxi_osv16;- case format::goiyx:- return kernel_selector::weights_layout::goiyx;- case format::gioyx:- return kernel_selector::weights_layout::gioyx;- case format::goizyx:- return kernel_selector::weights_layout::goizyx;- case format::giozyx:- return kernel_selector::weights_layout::giozyx;- case format::g_os_iyx_osv8:- return kernel_selector::weights_layout::g_os_iyx_osv8;- case format::g_os_iyx_osv16:- return kernel_selector::weights_layout::g_os_iyx_osv16;- case format::g_os_iyx_osv32:- return kernel_selector::weights_layout::g_os_iyx_osv32;- case format::gs_oiyx_gsv16:- return kernel_selector::weights_layout::gs_oiyx_gsv16;- case format::gs_oizyx_gsv16:- return kernel_selector::weights_layout::gs_oizyx_gsv16;- case format::gs_oiyx_gsv32:- return kernel_selector::weights_layout::gs_oiyx_gsv32;- case format::gs_oi_yxs_gsv4_yxsv4:- return kernel_selector::weights_layout::gs_oi_yxs_gsv4_yxsv4;- case format::gs_oi_yxs_gsv16_yxsv4:- return kernel_selector::weights_layout::gs_oi_yxs_gsv16_yxsv4;- case format::gs_oi_yxs_gsv32_yxsv4:- return kernel_selector::weights_layout::gs_oi_yxs_gsv32_yxsv4;- case format::gyxio:- return kernel_selector::weights_layout::gyxio;- case format::gi_yxs_os_yxsv2_osv16:- return kernel_selector::weights_layout::gi_yxs_os_yxsv2_osv16;- case format::giy_xs_os_xsv2_osv8__ao32:- return kernel_selector::weights_layout::giy_xs_os_xsv2_osv8__ao32;- case format::g_is_os_zyx_isv16_osv16:- return kernel_selector::weights_layout::g_is_os_zyx_isv16_osv16;- case format::g_is_os_yx_isv16_osv16:- return kernel_selector::weights_layout::g_is_os_yx_isv16_osv16;- case format::g_os_is_zyx_isv8_osv16_isv2:- return kernel_selector::weights_layout::g_os_is_zyx_isv8_osv16_isv2;- case format::g_os_is_yx_isv8_osv16_isv2:- return kernel_selector::weights_layout::g_os_is_yx_isv8_osv16_isv2;- case format::g_os_is_zyx_isv16_osv16:- return kernel_selector::weights_layout::g_os_is_zyx_isv16_osv16;- case format::g_os_is_yx_osv16_isv4:- return kernel_selector::weights_layout::g_os_is_yx_osv16_isv4;- case format::os_is_zyx_osv16_isv16:- return kernel_selector::weights_layout::os_is_zyx_osv16_isv16;- case format::g_os_is_zyx_osv16_isv16:- return kernel_selector::weights_layout::g_os_is_zyx_osv16_isv16;- case format::g_os_zyx_is_osv16_isv4:- return kernel_selector::weights_layout::g_os_zyx_is_osv16_isv4;- case format::g_os_zyx_is_osv16_isv16:- return kernel_selector::weights_layout::g_os_zyx_is_osv16_isv16;- case format::g_os_zyx_is_osv16_isv32:- return kernel_selector::weights_layout::g_os_zyx_is_osv16_isv32;- case format::g_os_zyx_is_osv32_isv4:- return kernel_selector::weights_layout::g_os_zyx_is_osv32_isv4;- case format::g_os_zyx_is_osv32_isv16:- return kernel_selector::weights_layout::g_os_zyx_is_osv32_isv16;- case format::g_os_zyx_is_osv32_isv32:- return kernel_selector::weights_layout::g_os_zyx_is_osv32_isv32;- case format::g_os_is_yx_isv16_osv16:- return kernel_selector::weights_layout::g_os_is_yx_isv16_osv16;- default:- throw std::invalid_argument("Unable to convert tensor layout " + fmt_to_str(f) + " to weights layout");+ return kernel_selector::weights_layout::goizyx;+ }+ case format::oizyx:+ return kernel_selector::weights_layout::oizyx;+ case format::iozyx:+ return kernel_selector::weights_layout::iozyx;+ case format::bs_fs_fsv8_bsv8:+ case format::os_i_osv8__ai8:+ return kernel_selector::weights_layout::os_i_osv8__ai8;+ case format::os_i_osv16__ai8:+ return kernel_selector::weights_layout::os_i_osv16__ai8;+ case format::os_i_osv16:+ return kernel_selector::weights_layout::os_i_osv16;+ case format::os_is_yx_osv32_isv2:+ return kernel_selector::weights_layout::os_is_yx_osv32_isv2;+ case format::os_is_yx_osv64_isv2:+ return kernel_selector::weights_layout::os_is_yx_osv64_isv2;+ case format::os_is_zyx_isv16_osv16:+ return kernel_selector::weights_layout::os_is_zyx_isv16_osv16;+ case format::is_os_zyx_isv16_osv16:+ return kernel_selector::weights_layout::is_os_zyx_isv16_osv16;+ case format::os_is_zyx_osv32_isv16:+ return kernel_selector::weights_layout::os_is_zyx_osv32_isv16;+ case format::is_os_yx_isv16_osv16:+ return kernel_selector::weights_layout::is_os_yx_isv16_osv16;+ case format::i_yxs_os_yxsv2_osv16:+ return kernel_selector::weights_layout::i_yxs_os_yxsv2_osv16;+ case format::iy_xs_os_xsv2_osv8__ao32:+ return kernel_selector::weights_layout::iy_xs_os_xsv2_osv8__ao32;+ case format::iy_xs_os_xsv2_osv16__ao32:+ return kernel_selector::weights_layout::iy_xs_os_xsv2_osv16__ao32;+ case format::os_is_zyx_isv8_osv16_isv2:+ return kernel_selector::weights_layout::os_is_zyx_isv8_osv16_isv2;+ case format::os_is_yx_isv8_osv16_isv2:+ return kernel_selector::weights_layout::os_is_yx_isv8_osv16_isv2;+ case cldnn::format::os_iyx_osv8:+ return kernel_selector::weights_layout::os_iyx_osv8;+ case format::os_zyxi_osv16:+ return kernel_selector::weights_layout::os_zyxi_osv16;+ case format::goiyx:+ return kernel_selector::weights_layout::goiyx;+ case format::gioyx:+ return kernel_selector::weights_layout::gioyx;+ case format::goizyx:+ return kernel_selector::weights_layout::goizyx;+ case format::giozyx:+ return kernel_selector::weights_layout::giozyx;+ case format::g_os_iyx_osv8:+ return kernel_selector::weights_layout::g_os_iyx_osv8;+ case format::g_os_iyx_osv16:+ return kernel_selector::weights_layout::g_os_iyx_osv16;+ case format::g_os_iyx_osv32:+ return kernel_selector::weights_layout::g_os_iyx_osv32;+ case format::gs_oiyx_gsv16:+ return kernel_selector::weights_layout::gs_oiyx_gsv16;+ case format::gs_oizyx_gsv16:+ return kernel_selector::weights_layout::gs_oizyx_gsv16;+ case format::gs_oiyx_gsv32:+ return kernel_selector::weights_layout::gs_oiyx_gsv32;+ case format::gs_oi_yxs_gsv4_yxsv4:+ return kernel_selector::weights_layout::gs_oi_yxs_gsv4_yxsv4;+ case format::gs_oi_yxs_gsv16_yxsv4:+ return kernel_selector::weights_layout::gs_oi_yxs_gsv16_yxsv4;+ case format::gs_oi_yxs_gsv32_yxsv4:+ return kernel_selector::weights_layout::gs_oi_yxs_gsv32_yxsv4;+ case format::gyxio:+ return kernel_selector::weights_layout::gyxio;+ case format::gi_yxs_os_yxsv2_osv16:+ return kernel_selector::weights_layout::gi_yxs_os_yxsv2_osv16;+ case format::giy_xs_os_xsv2_osv8__ao32:+ return kernel_selector::weights_layout::giy_xs_os_xsv2_osv8__ao32;+ case format::g_is_os_zyx_isv16_osv16:+ return kernel_selector::weights_layout::g_is_os_zyx_isv16_osv16;+ case format::g_is_os_yx_isv16_osv16:+ return kernel_selector::weights_layout::g_is_os_yx_isv16_osv16;+ case format::g_os_is_zyx_isv8_osv16_isv2:+ return kernel_selector::weights_layout::g_os_is_zyx_isv8_osv16_isv2;+ case format::g_os_is_yx_isv8_osv16_isv2:+ return kernel_selector::weights_layout::g_os_is_yx_isv8_osv16_isv2;+ case format::g_os_is_zyx_isv16_osv16:+ return kernel_selector::weights_layout::g_os_is_zyx_isv16_osv16;+ case format::g_os_is_yx_osv16_isv4:+ return kernel_selector::weights_layout::g_os_is_yx_osv16_isv4;+ case format::os_is_zyx_osv16_isv16:+ return kernel_selector::weights_layout::os_is_zyx_osv16_isv16;+ case format::g_os_is_zyx_osv16_isv16:+ return kernel_selector::weights_layout::g_os_is_zyx_osv16_isv16;+ case format::g_os_zyx_is_osv16_isv4:+ return kernel_selector::weights_layout::g_os_zyx_is_osv16_isv4;+ case format::g_os_zyx_is_osv16_isv16:+ return kernel_selector::weights_layout::g_os_zyx_is_osv16_isv16;+ case format::g_os_zyx_is_osv16_isv32:+ return kernel_selector::weights_layout::g_os_zyx_is_osv16_isv32;+ case format::g_os_zyx_is_osv32_isv4:+ return kernel_selector::weights_layout::g_os_zyx_is_osv32_isv4;+ case format::g_os_zyx_is_osv32_isv16:+ return kernel_selector::weights_layout::g_os_zyx_is_osv32_isv16;+ case format::g_os_zyx_is_osv32_isv32:+ return kernel_selector::weights_layout::g_os_zyx_is_osv32_isv32;+ case format::g_os_is_yx_isv16_osv16:+ return kernel_selector::weights_layout::g_os_is_yx_isv16_osv16;+ default:+ throw std::invalid_argument("Unable to convert tensor layout " + fmt_to_str(f) + " to weights layout");}}cldnn::format::type from_weights_layout(kernel_selector::weights_layout l) {switch (l) {- case kernel_selector::weights_layout::oi:- return cldnn::format::oiyx;- case kernel_selector::weights_layout::oiyx:- return cldnn::format::oiyx;- case kernel_selector::weights_layout::oyxi:- return cldnn::format::oyxi;- case kernel_selector::weights_layout::oyix:- return cldnn::format::oyix;- case kernel_selector::weights_layout::oxiy:- return cldnn::format::oxiy;- case kernel_selector::weights_layout::io:- case kernel_selector::weights_layout::iyxo:- return cldnn::format::iyxo;- case kernel_selector::weights_layout::yxio:- return cldnn::format::yxio;- case kernel_selector::weights_layout::o_is_yx_isv4:- return cldnn::format::o_is_yx_isv4;- case kernel_selector::weights_layout::o_is_yx_isv16:- return cldnn::format::o_is_yx_isv16;- case kernel_selector::weights_layout::os_iyx_osv16:- return cldnn::format::os_iyx_osv16;- case kernel_selector::weights_layout::os_is_yx_isv16_osv16:- return cldnn::format::os_is_yx_isv16_osv16;- case kernel_selector::weights_layout::os_is_yx_osv16_isv16:- return cldnn::format::os_is_yx_osv16_isv16;- case kernel_selector::weights_layout::os_iyx_osv32:- return cldnn::format::os_iyx_osv32;- case kernel_selector::weights_layout::os_iyx_osv64:- return cldnn::format::os_iyx_osv64;- case kernel_selector::weights_layout::os_i_osv16:- return cldnn::format::os_i_osv16;- case kernel_selector::weights_layout::os_is_yx_osv32_isv2:- return cldnn::format::os_is_yx_osv32_isv2;- case kernel_selector::weights_layout::os_is_yx_osv64_isv2:- return cldnn::format::os_is_yx_osv64_isv2;- case kernel_selector::weights_layout::os_i_osv8__ai8:- return cldnn::format::os_i_osv8__ai8;- case kernel_selector::weights_layout::os_i_osv16__ai8:- return cldnn::format::os_i_osv16__ai8;- case kernel_selector::weights_layout::image_2d_weights_c4_fyx_b:- return cldnn::format::image_2d_weights_c4_fyx_b;- case kernel_selector::weights_layout::image_2d_weights_c1_b_fyx:- return cldnn::format::image_2d_weights_c1_b_fyx;- case kernel_selector::weights_layout::winograd_2x3_s1_weights:- return cldnn::format::winograd_2x3_s1_weights;- case kernel_selector::weights_layout::winograd_2x3_s1_fused_weights:- return cldnn::format::winograd_2x3_s1_fused_weights;- case kernel_selector::weights_layout::winograd_6x3_s1_fused_weights:- return cldnn::format::winograd_6x3_s1_fused_weights;- case kernel_selector::weights_layout::image_2d_weights_winograd_6x3_s1_fbxyb:- return cldnn::format::image_2d_weights_winograd_6x3_s1_fbxyb;- case kernel_selector::weights_layout::image_2d_weights_winograd_6x3_s1_xfbyb:- return cldnn::format::image_2d_weights_winograd_6x3_s1_xfbyb;- case kernel_selector::weights_layout::os_is_zyx_osa4_isa8_osv8_isv4:- return cldnn::format::os_is_zyx_osa4_isa8_osv8_isv4;- case kernel_selector::weights_layout::os_is_yx_osa4_isa8_osv8_isv4:- return cldnn::format::os_is_yx_osa4_isa8_osv8_isv4;- case kernel_selector::weights_layout::os_is_yx_isa8_osv8_isv4:- return cldnn::format::os_is_yx_isa8_osv8_isv4;- case kernel_selector::weights_layout::os_is_zyx_isa8_osv8_isv4:- return cldnn::format::os_is_zyx_isa8_osv8_isv4;- case kernel_selector::weights_layout::os_is_yx_isa8_osv16_isv4:- return cldnn::format::os_is_yx_isa8_osv16_isv4;- case kernel_selector::weights_layout::os_is_zyx_isa8_osv16_isv4:- return cldnn::format::os_is_zyx_isa8_osv16_isv4;- case kernel_selector::weights_layout::os_is_yx_osa4_isa8_osv8_isv4_swizzled_by_4:- return cldnn::format::os_is_yx_osa4_isa8_osv8_isv4_swizzled_by_4;- case kernel_selector::weights_layout::os_is_yx_osa2_isa8_osv16_isv4_swizzled_by_2:- return cldnn::format::os_is_yx_osa2_isa8_osv16_isv4_swizzled_by_2;- case kernel_selector::weights_layout::os_is_zyx_osa2_isa8_osv16_isv4_swizzled_by_2:- return cldnn::format::os_is_zyx_osa2_isa8_osv16_isv4_swizzled_by_2;- case kernel_selector::weights_layout::os_is_zyx_osa4_isa8_osv8_isv4_swizzled_by_4:- return cldnn::format::os_is_zyx_osa4_isa8_osv8_isv4_swizzled_by_4;- case kernel_selector::weights_layout::os_is_yx_osv32_isv4_swizzled_by_2:- return format::os_is_yx_osv32_isv4_swizzled_by_2;- case kernel_selector::weights_layout::os_is_yx_osv32_isv4:- return format::os_is_yx_osv32_isv4;- case kernel_selector::weights_layout::os_is_zyx_osv32_isv4:- return format::os_is_zyx_osv32_isv4;- case kernel_selector::weights_layout::oizyx:- return cldnn::format::oizyx;- case kernel_selector::weights_layout::iozyx:- return cldnn::format::iozyx;- case kernel_selector::weights_layout::os_is_zyx_isv16_osv16:- return cldnn::format::os_is_zyx_isv16_osv16;- case kernel_selector::weights_layout::is_os_zyx_isv16_osv16:- return cldnn::format::is_os_zyx_isv16_osv16;- case kernel_selector::weights_layout::is_os_yx_isv16_osv16:- return cldnn::format::is_os_yx_isv16_osv16;- case kernel_selector::weights_layout::os_is_yx_osv8_isv4:- return cldnn::format::os_is_yx_osv8_isv4;- case kernel_selector::weights_layout::os_is_zyx_isv8_osv16_isv2:- return cldnn::format::os_is_zyx_isv8_osv16_isv2;- case kernel_selector::weights_layout::os_zyxi_osv16:- return cldnn::format::os_zyxi_osv16;- case kernel_selector::weights_layout::goiyx:- return cldnn::format::goiyx;- case kernel_selector::weights_layout::goizyx:- return cldnn::format::goizyx;- case kernel_selector::weights_layout::g_os_iyx_osv8:- return cldnn::format::g_os_iyx_osv8;- case kernel_selector::weights_layout::g_os_iyx_osv16:- return cldnn::format::g_os_iyx_osv16;- case kernel_selector::weights_layout::g_os_iyx_osv32:- return cldnn::format::g_os_iyx_osv32;- case kernel_selector::weights_layout::gs_oiyx_gsv16:- return cldnn::format::gs_oiyx_gsv16;- case kernel_selector::weights_layout::gs_oizyx_gsv16:- return cldnn::format::gs_oizyx_gsv16;- case kernel_selector::weights_layout::gs_oiyx_gsv32:- return cldnn::format::gs_oiyx_gsv32;- case kernel_selector::weights_layout::gyxio:- return cldnn::format::gyxio;- case kernel_selector::weights_layout::g_is_os_zyx_isv16_osv16:- return cldnn::format::g_is_os_zyx_isv16_osv16;- case kernel_selector::weights_layout::g_is_os_yx_isv16_osv16:- return cldnn::format::g_is_os_yx_isv16_osv16;- case kernel_selector::weights_layout::g_os_is_zyx_isv8_osv16_isv2:- return cldnn::format::g_os_is_zyx_isv8_osv16_isv2;- case kernel_selector::weights_layout::g_os_is_yx_isv8_osv16_isv2:- return cldnn::format::g_os_is_yx_isv8_osv16_isv2;- case kernel_selector::weights_layout::g_os_is_zyx_isv16_osv16:- return cldnn::format::g_os_is_zyx_isv16_osv16;- case kernel_selector::weights_layout::os_is_yx_osv16_isv4:- return cldnn::format::os_is_yx_osv16_isv4;- case kernel_selector::weights_layout::os_is_zyx_osv16_isv16:- return cldnn::format::os_is_zyx_osv16_isv16;- case kernel_selector::weights_layout::g_os_is_zyx_osv16_isv16:- return cldnn::format::g_os_is_zyx_osv16_isv16;- case kernel_selector::weights_layout::g_os_zyx_is_osv16_isv4:- return cldnn::format::g_os_zyx_is_osv16_isv4;- case kernel_selector::weights_layout::g_os_zyx_is_osv16_isv16:- return cldnn::format::g_os_zyx_is_osv16_isv16;- case kernel_selector::weights_layout::g_os_zyx_is_osv16_isv32:- return cldnn::format::g_os_zyx_is_osv16_isv32;- case kernel_selector::weights_layout::g_os_zyx_is_osv32_isv4:- return cldnn::format::g_os_zyx_is_osv32_isv4;- case kernel_selector::weights_layout::g_os_zyx_is_osv32_isv16:- return cldnn::format::g_os_zyx_is_osv32_isv16;- case kernel_selector::weights_layout::g_os_zyx_is_osv32_isv32:- return cldnn::format::g_os_zyx_is_osv32_isv32;- case kernel_selector::weights_layout::gs_oi_yxs_gsv4_yxsv4:- return cldnn::format::gs_oi_yxs_gsv4_yxsv4;- case kernel_selector::weights_layout::gs_oi_yxs_gsv16_yxsv4:- return cldnn::format::gs_oi_yxs_gsv16_yxsv4;- case kernel_selector::weights_layout::gs_oi_yxs_gsv32_yxsv4:- return cldnn::format::gs_oi_yxs_gsv32_yxsv4;- case kernel_selector::weights_layout::g_os_is_yx_osv16_isv4:- return cldnn::format::g_os_is_yx_osv16_isv4;- case kernel_selector::weights_layout::g_os_is_yx_isv16_osv16:- return cldnn::format::g_os_is_yx_isv16_osv16;- case kernel_selector::weights_layout::os_iyx_osv8:- return cldnn::format::os_iyx_osv8;- case kernel_selector::weights_layout::os_iyx_osv32__ai32:- return cldnn::format::os_iyx_osv32__ai32;- case kernel_selector::weights_layout::iy_xs_os_xsv2_osv16__ao32:- return cldnn::format::iy_xs_os_xsv2_osv16__ao32;- case kernel_selector::weights_layout::iy_xs_os_xsv2_osv8__ao32:- return cldnn::format::iy_xs_os_xsv2_osv8__ao32;- case kernel_selector::weights_layout::i_yxs_os_yxsv2_osv16:- return cldnn::format::i_yxs_os_yxsv2_osv16;- case kernel_selector::weights_layout::os_is_zyx_osv32_isv16:- return cldnn::format::os_is_zyx_osv32_isv16;- case kernel_selector::weights_layout::os_is_zyx_osv64_isv16:- return cldnn::format::os_is_zyx_osv64_isv16;- case kernel_selector::weights_layout::os_is_yx_isv8_osv16_isv2:- return cldnn::format::os_is_yx_isv8_osv16_isv2;- case kernel_selector::weights_layout::os_iyx_osv16_rotate_180:- return cldnn::format::os_iyx_osv16;- case kernel_selector::weights_layout::gi_yxs_os_yxsv2_osv16:- return cldnn::format::gi_yxs_os_yxsv2_osv16;- case kernel_selector::weights_layout::giy_xs_os_xsv2_osv8__ao32:- return cldnn::format::giy_xs_os_xsv2_osv8__ao32;- case kernel_selector::weights_layout::giy_xs_os_xsv2_osv16__ao32:- return cldnn::format::giy_xs_os_xsv2_osv16__ao32;- case kernel_selector::weights_layout::ioyx:- return cldnn::format::ioyx;- case kernel_selector::weights_layout::giozyx:- return cldnn::format::giozyx;- default:- throw std::invalid_argument("Unable to convert kernel selector Weights layout " +- std::to_string(static_cast<int>(l)) + " to cldnn format");+ case kernel_selector::weights_layout::oi:+ return cldnn::format::oiyx;+ case kernel_selector::weights_layout::oiyx:+ return cldnn::format::oiyx;+ case kernel_selector::weights_layout::oyxi:+ return cldnn::format::oyxi;+ case kernel_selector::weights_layout::oyix:+ return cldnn::format::oyix;+ case kernel_selector::weights_layout::oxiy:+ return cldnn::format::oxiy;+ case kernel_selector::weights_layout::io:+ case kernel_selector::weights_layout::iyxo:+ return cldnn::format::iyxo;+ case kernel_selector::weights_layout::yxio:+ return cldnn::format::yxio;+ case kernel_selector::weights_layout::o_is_yx_isv4:+ return cldnn::format::o_is_yx_isv4;+ case kernel_selector::weights_layout::o_is_yx_isv16:+ return cldnn::format::o_is_yx_isv16;+ case kernel_selector::weights_layout::os_iyx_osv16:+ return cldnn::format::os_iyx_osv16;+ case kernel_selector::weights_layout::os_is_yx_isv16_osv16:+ return cldnn::format::os_is_yx_isv16_osv16;+ case kernel_selector::weights_layout::os_is_yx_osv16_isv16:+ return cldnn::format::os_is_yx_osv16_isv16;+ case kernel_selector::weights_layout::os_iyx_osv32:+ return cldnn::format::os_iyx_osv32;+ case kernel_selector::weights_layout::os_iyx_osv64:+ return cldnn::format::os_iyx_osv64;+ case kernel_selector::weights_layout::os_i_osv16:+ return cldnn::format::os_i_osv16;+ case kernel_selector::weights_layout::os_is_yx_osv32_isv2:+ return cldnn::format::os_is_yx_osv32_isv2;+ case kernel_selector::weights_layout::os_is_yx_osv64_isv2:+ return cldnn::format::os_is_yx_osv64_isv2;+ case kernel_selector::weights_layout::os_i_osv8__ai8:+ return cldnn::format::os_i_osv8__ai8;+ case kernel_selector::weights_layout::os_i_osv16__ai8:+ return cldnn::format::os_i_osv16__ai8;+ case kernel_selector::weights_layout::image_2d_weights_c4_fyx_b:+ return cldnn::format::image_2d_weights_c4_fyx_b;+ case kernel_selector::weights_layout::image_2d_weights_c1_b_fyx:+ return cldnn::format::image_2d_weights_c1_b_fyx;+ case kernel_selector::weights_layout::winograd_2x3_s1_weights:+ return cldnn::format::winograd_2x3_s1_weights;+ case kernel_selector::weights_layout::winograd_2x3_s1_fused_weights:+ return cldnn::format::winograd_2x3_s1_fused_weights;+ case kernel_selector::weights_layout::winograd_6x3_s1_fused_weights:+ return cldnn::format::winograd_6x3_s1_fused_weights;+ case kernel_selector::weights_layout::image_2d_weights_winograd_6x3_s1_fbxyb:+ return cldnn::format::image_2d_weights_winograd_6x3_s1_fbxyb;+ case kernel_selector::weights_layout::image_2d_weights_winograd_6x3_s1_xfbyb:+ return cldnn::format::image_2d_weights_winograd_6x3_s1_xfbyb;+ case kernel_selector::weights_layout::os_is_zyx_osa4_isa8_osv8_isv4:+ return cldnn::format::os_is_zyx_osa4_isa8_osv8_isv4;+ case kernel_selector::weights_layout::os_is_yx_osa4_isa8_osv8_isv4:+ return cldnn::format::os_is_yx_osa4_isa8_osv8_isv4;+ case kernel_selector::weights_layout::os_is_yx_isa8_osv8_isv4:+ return cldnn::format::os_is_yx_isa8_osv8_isv4;+ case kernel_selector::weights_layout::os_is_zyx_isa8_osv8_isv4:+ return cldnn::format::os_is_zyx_isa8_osv8_isv4;+ case kernel_selector::weights_layout::os_is_yx_isa8_osv16_isv4:+ return cldnn::format::os_is_yx_isa8_osv16_isv4;+ case kernel_selector::weights_layout::os_is_zyx_isa8_osv16_isv4:+ return cldnn::format::os_is_zyx_isa8_osv16_isv4;+ case kernel_selector::weights_layout::os_is_yx_osa4_isa8_osv8_isv4_swizzled_by_4:+ return cldnn::format::os_is_yx_osa4_isa8_osv8_isv4_swizzled_by_4;+ case kernel_selector::weights_layout::os_is_yx_osa2_isa8_osv16_isv4_swizzled_by_2:+ return cldnn::format::os_is_yx_osa2_isa8_osv16_isv4_swizzled_by_2;+ case kernel_selector::weights_layout::os_is_zyx_osa2_isa8_osv16_isv4_swizzled_by_2:+ return cldnn::format::os_is_zyx_osa2_isa8_osv16_isv4_swizzled_by_2;+ case kernel_selector::weights_layout::os_is_zyx_osa4_isa8_osv8_isv4_swizzled_by_4:+ return cldnn::format::os_is_zyx_osa4_isa8_osv8_isv4_swizzled_by_4;+ case kernel_selector::weights_layout::os_is_yx_osv32_isv4_swizzled_by_2:+ return format::os_is_yx_osv32_isv4_swizzled_by_2;+ case kernel_selector::weights_layout::os_is_yx_osv32_isv4:+ return format::os_is_yx_osv32_isv4;+ case kernel_selector::weights_layout::os_is_zyx_osv32_isv4:+ return format::os_is_zyx_osv32_isv4;+ case kernel_selector::weights_layout::oizyx:+ return cldnn::format::oizyx;+ case kernel_selector::weights_layout::iozyx:+ return cldnn::format::iozyx;+ case kernel_selector::weights_layout::os_is_zyx_isv16_osv16:+ return cldnn::format::os_is_zyx_isv16_osv16;+ case kernel_selector::weights_layout::is_os_zyx_isv16_osv16:+ return cldnn::format::is_os_zyx_isv16_osv16;+ case kernel_selector::weights_layout::is_os_yx_isv16_osv16:+ return cldnn::format::is_os_yx_isv16_osv16;+ case kernel_selector::weights_layout::os_is_yx_osv8_isv4:+ return cldnn::format::os_is_yx_osv8_isv4;+ case kernel_selector::weights_layout::os_is_zyx_isv8_osv16_isv2:+ return cldnn::format::os_is_zyx_isv8_osv16_isv2;+ case kernel_selector::weights_layout::os_zyxi_osv16:+ return cldnn::format::os_zyxi_osv16;+ case kernel_selector::weights_layout::goiyx:+ return cldnn::format::goiyx;+ case kernel_selector::weights_layout::goizyx:+ return cldnn::format::goizyx;+ case kernel_selector::weights_layout::g_os_iyx_osv8:+ return cldnn::format::g_os_iyx_osv8;+ case kernel_selector::weights_layout::g_os_iyx_osv16:+ return cldnn::format::g_os_iyx_osv16;+ case kernel_selector::weights_layout::g_os_iyx_osv32:+ return cldnn::format::g_os_iyx_osv32;+ case kernel_selector::weights_layout::gs_oiyx_gsv16:+ return cldnn::format::gs_oiyx_gsv16;+ case kernel_selector::weights_layout::gs_oizyx_gsv16:+ return cldnn::format::gs_oizyx_gsv16;+ case kernel_selector::weights_layout::gs_oiyx_gsv32:+ return cldnn::format::gs_oiyx_gsv32;+ case kernel_selector::weights_layout::gyxio:+ return cldnn::format::gyxio;+ case kernel_selector::weights_layout::g_is_os_zyx_isv16_osv16:+ return cldnn::format::g_is_os_zyx_isv16_osv16;+ case kernel_selector::weights_layout::g_is_os_yx_isv16_osv16:+ return cldnn::format::g_is_os_yx_isv16_osv16;+ case kernel_selector::weights_layout::g_os_is_zyx_isv8_osv16_isv2:+ return cldnn::format::g_os_is_zyx_isv8_osv16_isv2;+ case kernel_selector::weights_layout::g_os_is_yx_isv8_osv16_isv2:+ return cldnn::format::g_os_is_yx_isv8_osv16_isv2;+ case kernel_selector::weights_layout::g_os_is_zyx_isv16_osv16:+ return cldnn::format::g_os_is_zyx_isv16_osv16;+ case kernel_selector::weights_layout::os_is_yx_osv16_isv4:+ return cldnn::format::os_is_yx_osv16_isv4;+ case kernel_selector::weights_layout::os_is_zyx_osv16_isv16:+ return cldnn::format::os_is_zyx_osv16_isv16;+ case kernel_selector::weights_layout::g_os_is_zyx_osv16_isv16:+ return cldnn::format::g_os_is_zyx_osv16_isv16;+ case kernel_selector::weights_layout::g_os_zyx_is_osv16_isv4:+ return cldnn::format::g_os_zyx_is_osv16_isv4;+ case kernel_selector::weights_layout::g_os_zyx_is_osv16_isv16:+ return cldnn::format::g_os_zyx_is_osv16_isv16;+ case kernel_selector::weights_layout::g_os_zyx_is_osv16_isv32:+ return cldnn::format::g_os_zyx_is_osv16_isv32;+ case kernel_selector::weights_layout::g_os_zyx_is_osv32_isv4:+ return cldnn::format::g_os_zyx_is_osv32_isv4;+ case kernel_selector::weights_layout::g_os_zyx_is_osv32_isv16:+ return cldnn::format::g_os_zyx_is_osv32_isv16;+ case kernel_selector::weights_layout::g_os_zyx_is_osv32_isv32:+ return cldnn::format::g_os_zyx_is_osv32_isv32;+ case kernel_selector::weights_layout::gs_oi_yxs_gsv4_yxsv4:+ return cldnn::format::gs_oi_yxs_gsv4_yxsv4;+ case kernel_selector::weights_layout::gs_oi_yxs_gsv16_yxsv4:+ return cldnn::format::gs_oi_yxs_gsv16_yxsv4;+ case kernel_selector::weights_layout::gs_oi_yxs_gsv32_yxsv4:+ return cldnn::format::gs_oi_yxs_gsv32_yxsv4;+ case kernel_selector::weights_layout::g_os_is_yx_osv16_isv4:+ return cldnn::format::g_os_is_yx_osv16_isv4;+ case kernel_selector::weights_layout::g_os_is_yx_isv16_osv16:+ return cldnn::format::g_os_is_yx_isv16_osv16;+ case kernel_selector::weights_layout::os_iyx_osv8:+ return cldnn::format::os_iyx_osv8;+ case kernel_selector::weights_layout::os_iyx_osv32__ai32:+ return cldnn::format::os_iyx_osv32__ai32;+ case kernel_selector::weights_layout::iy_xs_os_xsv2_osv16__ao32:+ return cldnn::format::iy_xs_os_xsv2_osv16__ao32;+ case kernel_selector::weights_layout::iy_xs_os_xsv2_osv8__ao32:+ return cldnn::format::iy_xs_os_xsv2_osv8__ao32;+ case kernel_selector::weights_layout::i_yxs_os_yxsv2_osv16:+ return cldnn::format::i_yxs_os_yxsv2_osv16;+ case kernel_selector::weights_layout::os_is_zyx_osv32_isv16:+ return cldnn::format::os_is_zyx_osv32_isv16;+ case kernel_selector::weights_layout::os_is_zyx_osv64_isv16:+ return cldnn::format::os_is_zyx_osv64_isv16;+ case kernel_selector::weights_layout::os_is_yx_isv8_osv16_isv2:+ return cldnn::format::os_is_yx_isv8_osv16_isv2;+ case kernel_selector::weights_layout::os_iyx_osv16_rotate_180:+ return cldnn::format::os_iyx_osv16;+ case kernel_selector::weights_layout::gi_yxs_os_yxsv2_osv16:+ return cldnn::format::gi_yxs_os_yxsv2_osv16;+ case kernel_selector::weights_layout::giy_xs_os_xsv2_osv8__ao32:+ return cldnn::format::giy_xs_os_xsv2_osv8__ao32;+ case kernel_selector::weights_layout::giy_xs_os_xsv2_osv16__ao32:+ return cldnn::format::giy_xs_os_xsv2_osv16__ao32;+ case kernel_selector::weights_layout::ioyx:+ return cldnn::format::ioyx;+ case kernel_selector::weights_layout::giozyx:+ return cldnn::format::giozyx;+ default:+ throw std::invalid_argument("Unable to convert kernel selector Weights layout " + std::to_string(static_cast<int>(l)) + " to cldnn format");}}--kernel_selector::n_dims compute_tensor_dimensions(const layout& l,- const size_t num_channels,- const tensor view_offset) {+kernel_selector::n_dims compute_tensor_dimensions(const layout& l, const size_t num_channels, const tensor view_offset) {const auto& pad = l.data_padding;const auto& dynamic_pad_dims = layout::format_sizes(pad._dynamic_dims_mask, l.format);const auto& vals_original = l.get_partial_shape();@@ -974,10 +971,11 @@ kernel_selector::n_dims compute_tensor_dimensions(const layout& l,ov::PartialShape vals_ordered;const auto& axis_order = l.format.dims_order();for (size_t i = 0; i < axis_order.size(); i++) {- if (axis_order[i] >= vals_original.size())+ if (axis_order[i] >= vals_original.size()) {vals_ordered.push_back(ov::Dimension(1));- else+ } else {vals_ordered.push_back(vals_original[axis_order[i]]);+ }}const auto& lower_pad = layout::format_sizes(pad._lower_size, l.format);const auto& upper_pad = layout::format_sizes(pad._upper_size, l.format);@@ -1047,103 +1045,103 @@ layout from_weights_tensor(const kernel_selector::weights_tensor& l) {kernel_selector::activation_function get_kernel_selector_activation_param(activation_func activation) {switch (activation) {- case cldnn::activation_func::none:- return kernel_selector::activation_function::NONE;- case cldnn::activation_func::logistic:- return kernel_selector::activation_function::LOGISTIC;- case cldnn::activation_func::hyperbolic_tan:- return kernel_selector::activation_function::HYPERBOLIC_TAN;- case cldnn::activation_func::relu:- return kernel_selector::activation_function::RELU;- case cldnn::activation_func::relu_negative_slope:- return kernel_selector::activation_function::RELU_NEGATIVE_SLOPE;- case cldnn::activation_func::clamp:- return kernel_selector::activation_function::CLAMP;- case cldnn::activation_func::softrelu:- return kernel_selector::activation_function::SOFTRELU;- case cldnn::activation_func::abs:- return kernel_selector::activation_function::ABS;- case cldnn::activation_func::linear:- return kernel_selector::activation_function::LINEAR;- case cldnn::activation_func::square:- return kernel_selector::activation_function::SQUARE;- case cldnn::activation_func::sqrt:- return kernel_selector::activation_function::SQRT;- case cldnn::activation_func::elu:- return kernel_selector::activation_function::ELU;- case cldnn::activation_func::sin:- return kernel_selector::activation_function::SIN;- case cldnn::activation_func::asin:- return kernel_selector::activation_function::ASIN;- case cldnn::activation_func::sinh:- return kernel_selector::activation_function::SINH;- case cldnn::activation_func::asinh:- return kernel_selector::activation_function::ASINH;- case cldnn::activation_func::cos:- return kernel_selector::activation_function::COS;- case cldnn::activation_func::acos:- return kernel_selector::activation_function::ACOS;- case cldnn::activation_func::cosh:- return kernel_selector::activation_function::COSH;- case cldnn::activation_func::acosh:- return kernel_selector::activation_function::ACOSH;- case cldnn::activation_func::log:- return kernel_selector::activation_function::LOG;- case cldnn::activation_func::log2:- return kernel_selector::activation_function::LOG2;- case cldnn::activation_func::exp:- return kernel_selector::activation_function::EXP;- case cldnn::activation_func::tan:- return kernel_selector::activation_function::TAN;- case cldnn::activation_func::atan:- return kernel_selector::activation_function::ATAN;- case cldnn::activation_func::atanh:- return kernel_selector::activation_function::ATANH;- case cldnn::activation_func::floor:- return kernel_selector::activation_function::FLOOR;- case cldnn::activation_func::ceil:- return kernel_selector::activation_function::CEIL;- case cldnn::activation_func::negative:- return kernel_selector::activation_function::NEGATIVE;- case cldnn::activation_func::negation:- return kernel_selector::activation_function::NOT;- case cldnn::activation_func::pow:- return kernel_selector::activation_function::POW;- case cldnn::activation_func::erf:- return kernel_selector::activation_function::ERF;- case cldnn::activation_func::reciprocal:- return kernel_selector::activation_function::RECIPROCAL;- case cldnn::activation_func::selu:- return kernel_selector::activation_function::SELU;- case cldnn::activation_func::sign:- return kernel_selector::activation_function::SIGN;- case cldnn::activation_func::softplus:- return kernel_selector::activation_function::SOFTPLUS;- case cldnn::activation_func::softsign:- return kernel_selector::activation_function::SOFTSIGN;- case cldnn::activation_func::hard_sigmoid:- return kernel_selector::activation_function::HARD_SIGMOID;- case cldnn::activation_func::hsigmoid:- return kernel_selector::activation_function::HSIGMOID;- case cldnn::activation_func::swish:- return kernel_selector::activation_function::SWISH;- case cldnn::activation_func::hswish:- return kernel_selector::activation_function::HSWISH;- case cldnn::activation_func::mish:- return kernel_selector::activation_function::MISH;- case cldnn::activation_func::gelu:- return kernel_selector::activation_function::GELU;- case cldnn::activation_func::gelu_tanh:- return kernel_selector::activation_function::GELU_TANH;- case cldnn::activation_func::round_half_to_even:- return kernel_selector::activation_function::ROUND_HALF_TO_EVEN;- case cldnn::activation_func::round_half_away_from_zero:- return kernel_selector::activation_function::ROUND_HALF_AWAY_FROM_ZERO;- case cldnn::activation_func::erfinv:- return kernel_selector::activation_function::ERFINV;- default:- throw std::runtime_error("Unknown activation function");- break;+ case cldnn::activation_func::none:+ return kernel_selector::activation_function::NONE;+ case cldnn::activation_func::logistic:+ return kernel_selector::activation_function::LOGISTIC;+ case cldnn::activation_func::hyperbolic_tan:+ return kernel_selector::activation_function::HYPERBOLIC_TAN;+ case cldnn::activation_func::relu:+ return kernel_selector::activation_function::RELU;+ case cldnn::activation_func::relu_negative_slope:+ return kernel_selector::activation_function::RELU_NEGATIVE_SLOPE;+ case cldnn::activation_func::clamp:+ return kernel_selector::activation_function::CLAMP;+ case cldnn::activation_func::softrelu:+ return kernel_selector::activation_function::SOFTRELU;+ case cldnn::activation_func::abs:+ return kernel_selector::activation_function::ABS;+ case cldnn::activation_func::linear:+ return kernel_selector::activation_function::LINEAR;+ case cldnn::activation_func::square:+ return kernel_selector::activation_function::SQUARE;+ case cldnn::activation_func::sqrt:+ return kernel_selector::activation_function::SQRT;+ case cldnn::activation_func::elu:+ return kernel_selector::activation_function::ELU;+ case cldnn::activation_func::sin:+ return kernel_selector::activation_function::SIN;+ case cldnn::activation_func::asin:+ return kernel_selector::activation_function::ASIN;+ case cldnn::activation_func::sinh:+ return kernel_selector::activation_function::SINH;+ case cldnn::activation_func::asinh:+ return kernel_selector::activation_function::ASINH;+ case cldnn::activation_func::cos:+ return kernel_selector::activation_function::COS;+ case cldnn::activation_func::acos:+ return kernel_selector::activation_function::ACOS;+ case cldnn::activation_func::cosh:+ return kernel_selector::activation_function::COSH;+ case cldnn::activation_func::acosh:+ return kernel_selector::activation_function::ACOSH;+ case cldnn::activation_func::log:+ return kernel_selector::activation_function::LOG;+ case cldnn::activation_func::log2:+ return kernel_selector::activation_function::LOG2;+ case cldnn::activation_func::exp:+ return kernel_selector::activation_function::EXP;+ case cldnn::activation_func::tan:+ return kernel_selector::activation_function::TAN;+ case cldnn::activation_func::atan:+ return kernel_selector::activation_function::ATAN;+ case cldnn::activation_func::atanh:+ return kernel_selector::activation_function::ATANH;+ case cldnn::activation_func::floor:+ return kernel_selector::activation_function::FLOOR;+ case cldnn::activation_func::ceil:+ return kernel_selector::activation_function::CEIL;+ case cldnn::activation_func::negative:+ return kernel_selector::activation_function::NEGATIVE;+ case cldnn::activation_func::negation:+ return kernel_selector::activation_function::NOT;+ case cldnn::activation_func::pow:+ return kernel_selector::activation_function::POW;+ case cldnn::activation_func::erf:+ return kernel_selector::activation_function::ERF;+ case cldnn::activation_func::reciprocal:+ return kernel_selector::activation_function::RECIPROCAL;+ case cldnn::activation_func::selu:+ return kernel_selector::activation_function::SELU;+ case cldnn::activation_func::sign:+ return kernel_selector::activation_function::SIGN;+ case cldnn::activation_func::softplus:+ return kernel_selector::activation_function::SOFTPLUS;+ case cldnn::activation_func::softsign:+ return kernel_selector::activation_function::SOFTSIGN;+ case cldnn::activation_func::hard_sigmoid:+ return kernel_selector::activation_function::HARD_SIGMOID;+ case cldnn::activation_func::hsigmoid:+ return kernel_selector::activation_function::HSIGMOID;+ case cldnn::activation_func::swish:+ return kernel_selector::activation_function::SWISH;+ case cldnn::activation_func::hswish:+ return kernel_selector::activation_function::HSWISH;+ case cldnn::activation_func::mish:+ return kernel_selector::activation_function::MISH;+ case cldnn::activation_func::gelu:+ return kernel_selector::activation_function::GELU;+ case cldnn::activation_func::gelu_tanh:+ return kernel_selector::activation_function::GELU_TANH;+ case cldnn::activation_func::round_half_to_even:+ return kernel_selector::activation_function::ROUND_HALF_TO_EVEN;+ case cldnn::activation_func::round_half_away_from_zero:+ return kernel_selector::activation_function::ROUND_HALF_AWAY_FROM_ZERO;+ case cldnn::activation_func::erfinv:+ return kernel_selector::activation_function::ERFINV;+ default:+ throw std::runtime_error("Unknown activation function");+ break;}}@@ -1227,36 +1225,36 @@ void convert_fused_ops_to_legacy_activations(const kernel_impl_params& param_infbool use_legacy_fused_ops(const kernel_impl_params& param_info) {const auto& fused_ops = param_info.fused_desc;- if (fused_ops.size() != 1)+ if (fused_ops.size() != 1) {return false;+ }const auto& fused_op = fused_ops[0];- if (!fused_op.is_type<activation>())+ if (!fused_op.is_type<activation>()) {return false;+ }- if (!fused_op.deps.empty())+ if (!fused_op.deps.empty()) {return false;+ }-- std::vector<primitive_type_id> legacy_fusion_list = {- concatenation::type_id(),- convolution::type_id(),- crop::type_id(),- eltwise::type_id(),- fully_connected::type_id(),- normalize::type_id(),- reorder::type_id(),- reshape::type_id(),- roi_pooling::type_id(),- softmax::type_id(),- depth_to_space::type_id(),- shuffle_channels::type_id(),- strided_slice::type_id(),- cum_sum::type_id(),- reverse_sequence::type_id(),- embedding_bag::type_id(),- extract_image_patches::type_id()- };+ std::vector<primitive_type_id> legacy_fusion_list = {concatenation::type_id(),+ convolution::type_id(),+ crop::type_id(),+ eltwise::type_id(),+ fully_connected::type_id(),+ normalize::type_id(),+ reorder::type_id(),+ reshape::type_id(),+ roi_pooling::type_id(),+ softmax::type_id(),+ depth_to_space::type_id(),+ shuffle_channels::type_id(),+ strided_slice::type_id(),+ cum_sum::type_id(),+ reverse_sequence::type_id(),+ embedding_bag::type_id(),+ extract_image_patches::type_id()};if (std::find(legacy_fusion_list.begin(), legacy_fusion_list.end(), param_info.desc->type) == legacy_fusion_list.end()) {return false;@@ -1267,12 +1265,12 @@ bool use_legacy_fused_ops(const kernel_impl_params& param_info) {// The main distinguishing characteristic of old kernels is plain and winograd formats, so do fallback to legacy// only if this criteria is met.if (convolution::type_id() == param_info.desc->type) {- bool has_plain_formats = format::is_simple_data_format(param_info.get_input_layout().format) &&- format::is_simple_data_format(param_info.get_output_layout().format);- bool has_winograd_formats = format::is_winograd(param_info.get_input_layout().format) ||- format::is_winograd(param_info.get_output_layout().format);- if (!has_plain_formats && !has_winograd_formats)+ bool has_plain_formats =+ format::is_simple_data_format(param_info.get_input_layout().format) && format::is_simple_data_format(param_info.get_output_layout().format);+ bool has_winograd_formats = format::is_winograd(param_info.get_input_layout().format) || format::is_winograd(param_info.get_output_layout().format);+ if (!has_plain_formats && !has_winograd_formats) {return false;+ }}return true;@@ -1356,8 +1354,7 @@ void set_default_params(const kernel_impl_params& param_info, kernel_selector::bkernel_selector::fused_operation_desc desc;desc.op_params = convert_fuse_params(fused_prim.f_param);- OPENVINO_ASSERT(desc.op_params != nullptr, "[GPU] Invalid fused operation (", param_info.desc->id , ") of type ", param_info.desc->type_string());-+ OPENVINO_ASSERT(desc.op_params != nullptr, "[GPU] Invalid fused operation (", param_info.desc->id, ") of type ", param_info.desc->type_string());desc.dep_idx_start = fused_prim.outer_dep_start_idx;desc.dep_size = fused_prim.deps.size();@@ -1376,16 +1373,16 @@ void set_default_params(const kernel_impl_params& param_info, kernel_selector::bauto iter = prim_id_type_map.find(dep.first);if (iter != prim_id_type_map.end()) {auto& op_data = iter->second;- desc.dep_data[dep.second].dep_type = kernel_selector::DepType::INTERNAL;- desc.dep_data[dep.second].op_id = op_data.first;+ desc.dep_data[dep.second].dep_type = kernel_selector::DepType::INTERNAL;+ desc.dep_data[dep.second].op_id = op_data.first;desc.dep_data[dep.second].data_type = op_data.second;}}int idx = 0;for (const auto& dep : fused_prim.deps) {- desc.dep_data[dep.second].dep_type = kernel_selector::DepType::EXTERNAL;- desc.dep_data[dep.second].op_id = idx;+ desc.dep_data[dep.second].dep_type = kernel_selector::DepType::EXTERNAL;+ desc.dep_data[dep.second].op_id = idx;desc.dep_data[dep.second].data_type = desc.tensors[idx++].GetDType();}@@ -1420,20 +1417,15 @@ void set_weight_bias_zero_point_default_params(const kernel_impl_params& param_iset_weights_bias_default_params(param_info, params, has_group_dimension, is_shape_agnostic);if (param_info.weights_zero_points_layout) {- params.weights_zero_points.push_back(- convert_data_tensor(*param_info.weights_zero_points_layout)- .FlattenFeatureAndSpatials());+ params.weights_zero_points.push_back(convert_data_tensor(*param_info.weights_zero_points_layout).FlattenFeatureAndSpatials());}if (param_info.activations_zero_points_layout) {- params.activations_zero_points.push_back(- convert_data_tensor(*param_info.activations_zero_points_layout)- .FlattenFeatureAndSpatials());+ params.activations_zero_points.push_back(convert_data_tensor(*param_info.activations_zero_points_layout).FlattenFeatureAndSpatials());}if (param_info.compensation_layout) {- params.compensation.push_back(- convert_data_tensor(*param_info.compensation_layout).FlattenFeatureAndSpatials());+ params.compensation.push_back(convert_data_tensor(*param_info.compensation_layout).FlattenFeatureAndSpatials());}}diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/kernels_cache.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl/kernels_cache.hppindex 3ac060d4085..4e5fa972c2b 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/kernels_cache.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/kernels_cache.hpp@@ -145,8 +145,9 @@ public:void add_to_cached_kernels(const std::vector<kernel::ptr>& kernels);size_t get_kernel_batch_hash(const kernel_impl_params& params) const {- if (_kernel_batch_hash.find(params) != _kernel_batch_hash.end())+ if (_kernel_batch_hash.find(params) != _kernel_batch_hash.end()) {return _kernel_batch_hash.at(params);+ }return 0;}diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/kv_cache.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/kv_cache.cppindex 7d416e01cb4..bcf058b1e11 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/kv_cache.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/kv_cache.cpp@@ -28,8 +28,9 @@ namespace ocl {namespace {kernel_selector::concat_axis convert_axis(int64_t axis, size_t rank) {auto cldnn_axis = axis >= 0 ? axis : axis + static_cast<int64_t>(rank);- if (cldnn_axis >= static_cast<int64_t>(rank))+ if (cldnn_axis >= static_cast<int64_t>(rank)) {OPENVINO_THROW("kv_cache axis exceeds number of dimensions");+ }// Difference in dimension ordering between OV and GPU plugin,// reverse spatial dimensions after batch and feature.@@ -523,8 +524,9 @@ struct kv_cache_impl : multi_stage_primitive<kv_cache> {// asymmetric quantization (u4 range 0..15) regardless of the original quantization mode.const auto kv_cache_dt = impl_param.get_program().get_config().get_kv_cache_precision();params.is_int4_compressed = ov::element::Type(kv_cache_dt).bitwidth() == 4;- if (params.is_int4_compressed)+ if (params.is_int4_compressed) {params.use_asymmetric_quantization = true;+ }const auto& past_kv_cache_shape = impl_param.input_layouts[0].get_partial_shape();params.axis_offset = past_kv_cache_shape[primitive->concat_axis].is_static() ? past_kv_cache_shape[primitive->concat_axis].get_length() : 0;diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/multi_stage_primitive.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl/multi_stage_primitive.hppindex fce7666b3e9..126d1921d9e 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/multi_stage_primitive.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/multi_stage_primitive.hpp@@ -4,28 +4,27 @@#pragma once+#include <list>+#include <utility>+#include <vector>++#include "concatenation_inst.h"+#include "gather_inst.h"#include "intel_gpu/graph/network.hpp"+#include "intel_gpu/graph/program.hpp"#include "intel_gpu/graph/serialization/binary_buffer.hpp"#include "intel_gpu/graph/serialization/cl_kernel_data_serializer.hpp"#include "intel_gpu/graph/serialization/helpers.hpp"#include "intel_gpu/graph/serialization/set_serializer.hpp"#include "intel_gpu/graph/serialization/string_serializer.hpp"#include "intel_gpu/graph/serialization/vector_serializer.hpp"-#include "intel_gpu/graph/program.hpp"-#include "kernel_selector_common.h"+#include "kernel_selector_helper.h"#include "openvino/core/except.hpp"+#include "permute_inst.h"#include "primitive_inst.h"-#include "kernel_selector_helper.h"#include "register.hpp"#include "registry/implementation_map.hpp"-#include "concatenation_inst.h"-#include "gather_inst.h"-#include "permute_inst.h"--#include <vector>-#include <list>-#include <utility>namespace cldnn {namespace ocl {@@ -41,10 +40,7 @@ struct multi_stage_primitive : public typed_primitive_impl<PType> {multi_stage_primitive() : _kernels_data({}), _kernels({}) {}- multi_stage_primitive(const multi_stage_primitive<PType>& other)- : typed_primitive_impl<PType>()- , _kernels_data(other._kernels_data)- , _kernels({}) {+ multi_stage_primitive(const multi_stage_primitive<PType>& other) : typed_primitive_impl<PType>(), _kernels_data(other._kernels_data), _kernels({}) {_kernels.reserve(other._kernels.size());for (size_t k = 0; k < other._kernels.size(); ++k) {_kernels.emplace_back(other._kernels[k]->clone(other.can_share_kernels));@@ -56,14 +52,14 @@ struct multi_stage_primitive : public typed_primitive_impl<PType> {this->m_manager = other.m_manager;}- multi_stage_primitive(const std::vector<kernel_selector::kernel_data>& kd)- : typed_primitive_impl<PType>()- , _kernels_data(kd) {+ multi_stage_primitive(const std::vector<kernel_selector::kernel_data>& kd) : typed_primitive_impl<PType>(), _kernels_data(kd) {this->can_reuse_memory = false;this->_kernel_name = kd[0].kernelName;}- bool is_cpu() const final { return false; }+ bool is_cpu() const final {+ return false;+ }// Cache blob format:// [ kernel_selector::kernel_data ]@@ -107,13 +103,17 @@ protected:_kernels.clear();if (!_kernels_data.empty() && !_kernels_data[0].kernels.empty()) {auto compiled_kernels = kernels_cache.get_kernels(params);- size_t total_kernels = std::accumulate(_kernels_data.begin(), _kernels_data.end(), (size_t)0,- [](size_t acc, const kernel_selector::kernel_data& kd) {+ size_t total_kernels =+ std::accumulate(_kernels_data.begin(), _kernels_data.end(), (size_t)0, [](size_t acc, const kernel_selector::kernel_data& kd) {return acc + kd.kernels.size();});- OPENVINO_ASSERT(total_kernels == compiled_kernels.size(), "[GPU] Mismatch between number of expected and actually compiled kernels.\n",- "Expected: ", total_kernels, "\n"- "Got: ", compiled_kernels.size());+ OPENVINO_ASSERT(total_kernels == compiled_kernels.size(),+ "[GPU] Mismatch between number of expected and actually compiled kernels.\n",+ "Expected: ",+ total_kernels,+ "\n"+ "Got: ",+ compiled_kernels.size());_kernels.insert(_kernels.begin(), compiled_kernels.begin(), compiled_kernels.end());kernel_dump_info.set_batch_hash(std::to_string(kernels_cache.get_kernel_batch_hash(params)));}@@ -134,7 +134,7 @@ protected:return {kernels_cache.get_cached_kernel_ids(_kernels)};}- template<typename ImplType, typename KernelParamsType>+ template <typename ImplType, typename KernelParamsType>static std::unique_ptr<primitive_impl> make_deep_copy(const ImplType& impl_ocl) {auto prim_impl = std::make_unique<ImplType>(impl_ocl);for (auto& _kernel_data : (*prim_impl)._kernels_data) {@@ -153,8 +153,9 @@ protected:std::vector<BufferDescriptor> get_internal_buffer_descs(const kernel_impl_params&) const override {std::vector<BufferDescriptor> internal_buffers;for (const auto& kd : _kernels_data) {- if (kd.internalBuffers.empty())+ if (kd.internalBuffers.empty()) {continue;+ }auto dtype = from_data_type(kd.internalBufferDataType);const auto bpp = data_type_traits::size_of(dtype);@@ -249,7 +250,7 @@ protected:}virtual void update_dispatch_data(const kernel_impl_params& impl_params) {- OPENVINO_ASSERT(this->_is_dynamic, "[GPU] update_dispatch_data() is called for static shape implementation ", this-> _kernel_name);+ OPENVINO_ASSERT(this->_is_dynamic, "[GPU] update_dispatch_data() is called for static shape implementation ", this->_kernel_name);OPENVINO_ASSERT(false, "[GPU] update_dispatch_data() is not implemented for dynamic implemenation ", this->_kernel_name);}};diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/non_max_suppression.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/non_max_suppression.cppindex 2e40cf6563e..888af5730dd 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/non_max_suppression.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/non_max_suppression.cpp@@ -52,10 +52,12 @@ protected:args.outputs.push_back(instance.output_memory_ptr(i));}// // Legacy multi-output- if (instance.has_second_output())+ if (instance.has_second_output()) {args.outputs.push_back(instance.second_output_mem());- if (instance.has_third_output())+ }+ if (instance.has_third_output()) {args.outputs.push_back(instance.third_output_mem());+ }return args;}@@ -119,8 +121,9 @@ static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param, boffset += static_cast<size_t>(arg.has_iou_threshold());offset += static_cast<size_t>(arg.has_score_threshold());offset += static_cast<size_t>(arg.has_soft_nms_sigma());- if (is_third)+ if (is_third) {offset += static_cast<size_t>(arg.has_second_output());+ }return offset;};diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/permute.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/permute.cppindex ef5c0363620..b9a9788d202 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/permute.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/permute.cpp@@ -17,16 +17,18 @@ inline std::vector<uint16_t> convert_permute_order(const std::vector<uint16_t>&std::vector<uint16_t> ie_order_aligned = ie_order;// if order size is less than 4 - fill the rest with just copyrank = std::max(rank, (size_t)4);- for (auto o = ie_order_aligned.size(); o < rank; o++)+ for (auto o = ie_order_aligned.size(); o < rank; o++) {ie_order_aligned.push_back((uint16_t)o);+ }std::vector<uint16_t> cldnn_order;// 1. Switch permute order values for spatial dimsfor (auto const& o : ie_order_aligned) {- if (o >= 2)+ if (o >= 2) {cldnn_order.push_back(1 + static_cast<uint16_t>(ie_order_aligned.size()) - o);- else+ } else {cldnn_order.push_back(o);+ }}// 2. Swap spatial positionsdiff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/pooling.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/pooling.cppindex 4ed0ff229fc..bb2658cd980 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/pooling.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/pooling.cpp@@ -128,10 +128,11 @@ public:static_cast<size_t>(pads_end[spatial_rank - i - 1] + pads_begin[spatial_rank - i - 1] + input_layout.spatial(i));}- if (primitive->mode == pooling_mode::average && dynamic_mode)+ if (primitive->mode == pooling_mode::average && dynamic_mode) {pp.divMode = kernel_selector::kernel_divider_mode::DYNAMIC_WITH_PADDING;- else+ } else {pp.divMode = cldnn_2_kernel_divider_mode(primitive->mode);+ }uint32_t kernel_z = kernel.size() >= 3 ? static_cast<uint32_t>(kernel[kernel.size() - 3]) : 1;uint32_t kernel_y = kernel.size() >= 2 ? static_cast<uint32_t>(kernel[kernel.size() - 2]) : 1;diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/primitive_base.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl/primitive_base.hppindex 5fa34353b1e..a3cb5dd8d32 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/primitive_base.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/primitive_base.hpp@@ -190,8 +190,9 @@ protected:}std::vector<BufferDescriptor> get_internal_buffer_descs(const kernel_impl_params&) const override {- if (_kernel_data.internalBuffers.empty())+ if (_kernel_data.internalBuffers.empty()) {return {};+ }std::vector<BufferDescriptor> internal_buffers;auto dtype = from_data_type(_kernel_data.internalBufferDataType);@@ -238,8 +239,9 @@ protected:stream& stream = instance.get_network().get_stream();for (size_t k = 0; k < _kernels.size(); ++k) {- if (_kernel_data.kernels[k].skip_execution)+ if (_kernel_data.kernels[k].skip_execution) {continue;+ }stream.set_arguments(*_kernels[k], _kernel_data.kernels[k].params, args);}@@ -259,8 +261,9 @@ protected:"[GPU] KernelData count: ", _kernel_data.kernels.size(), "\n","[GPU] Likely some issue with empty tensor handling happened");for (size_t kd_idx = 0; kd_idx < _kernel_data.kernels.size(); ++kd_idx) {- if (_kernel_data.kernels[kd_idx].skip_execution)+ if (_kernel_data.kernels[kd_idx].skip_execution) {continue;+ }// If any user of the prim's users is CPU implementation or network's output, set prim as a output event (event won't be nullptr)bool needs_completion_event = instance.needs_completion_event();@@ -288,8 +291,9 @@ protected:kernel_dump_info.add_entry_point(_kernels[kd_idx]->get_id());}- if ((all_events.empty()) && (!tmp_events.empty()))+ if ((all_events.empty()) && (!tmp_events.empty())) {return stream.aggregate_events(tmp_events);+ }bool group_events = (all_events.size() > 1);return stream.aggregate_events(all_events, group_events);@@ -310,8 +314,9 @@ protected:}void set_kernels(cldnn::kernels_cache::compiled_kernels kernels) override {- if (is_cpu())+ if (is_cpu()) {return;+ }OPENVINO_ASSERT(kernels.size() == 1, "Only the kernels of the single primitive should be allowed.");auto& kernel_vec = kernels.begin()->second;_kernels.clear();diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/range.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/range.cppindex c260ed1a8c5..84ee8477d77 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/range.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/range.cpp@@ -34,8 +34,9 @@ struct range_impl : typed_primitive_impl_ocl<range> {static kernel_params_t get_kernel_params(const kernel_impl_params& impl_param, bool is_shape_agnostic = false) {auto params = get_default_params<kernel_selector::range_params>(impl_param, is_shape_agnostic);- for (int i : {1, 2})+ for (int i : {1, 2}) {params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(i)));+ }return params;}diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/reduce.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/reduce.cppindex 3def1e2b11c..165b7c58d11 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/reduce.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/reduce.cpp@@ -19,8 +19,9 @@ static std::vector<uint16_t> convert_axes(std::vector<int64_t> axes, size_t rankcontinue;}- if (axis < 0)+ if (axis < 0) {axis = axis + rank;+ }converted_axes.push_back(static_cast<uint16_t>(rank + 1 - axis));}diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/resample.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/resample.cppindex f596c93467a..3588ba5dd70 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/resample.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/resample.cpp@@ -86,10 +86,12 @@ inline std::vector<int32_t> convert_pads(const std::vector<size_t>& pad, size_tfor (auto p : pad) {new_pad.push_back(static_cast<int32_t>(p));}- if (new_pad.size() > 2)+ if (new_pad.size() > 2) {std::reverse(new_pad.begin() + 2, new_pad.end());- for (size_t i = new_pad.size(); i < rank || i < 4; ++i)+ }+ for (size_t i = new_pad.size(); i < rank || i < 4; ++i) {new_pad.push_back(0);+ }}return new_pad;@@ -102,24 +104,27 @@ inline kernel_selector::interpolate_axis convert_axis(int64_t axis, size_t rank)case 1:return kernel_selector::interpolate_axis::FEATURE;case 2:- if (rank == 6)+ if (rank == 6) {return kernel_selector::interpolate_axis::W;- else if (rank == 5)+ } else if (rank == 5) {return kernel_selector::interpolate_axis::Z;- else+ } else {return kernel_selector::interpolate_axis::Y;+ }case 3:- if (rank == 6)+ if (rank == 6) {return kernel_selector::interpolate_axis::Z;- else if (rank == 5)+ } else if (rank == 5) {return kernel_selector::interpolate_axis::Y;- else+ } else {return kernel_selector::interpolate_axis::X;+ }case 4:- if (rank == 6)+ if (rank == 6) {return kernel_selector::interpolate_axis::Y;- else+ } else {return kernel_selector::interpolate_axis::X;+ }case 5:return kernel_selector::interpolate_axis::X;default:diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/roi_pooling.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/roi_pooling.cppindex 53177a39aec..fc22d315214 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/roi_pooling.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/roi_pooling.cpp@@ -47,13 +47,14 @@ protected:kernel_arguments_data get_arguments(const typed_primitive_inst<roi_pooling>& instance) const override {kernel_arguments_data args;- if (instance.get_typed_desc<roi_pooling>()->mode == pooling_mode::deformable_bilinear && !instance.get_typed_desc<roi_pooling>()->no_trans)+ if (instance.get_typed_desc<roi_pooling>()->mode == pooling_mode::deformable_bilinear && !instance.get_typed_desc<roi_pooling>()->no_trans) {args.inputs = {instance.input_memory_ptr(),instance.rois_memory(),instance.trans_memory()};- else+ } else {args.inputs = {instance.input_memory_ptr(), instance.rois_memory()};+ }args.outputs = { instance.output_memory_ptr() };@@ -68,8 +69,9 @@ public:auto params = get_default_params<kernel_selector::roi_pooling_params>(impl_param);params.inputs.push_back(convert_data_tensor(rois_layout));- if (primitive->mode == pooling_mode::deformable_bilinear && !primitive->no_trans)+ if (primitive->mode == pooling_mode::deformable_bilinear && !primitive->no_trans) {params.inputs.push_back(convert_data_tensor(impl_param.get_input_layout(2)));+ }params.mode = cldnn_2_pool_type(primitive->mode);params.position_sensitive = primitive->position_sensitive;params.pooled_width = primitive->pooled_width;diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/scatter_elements_update.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl/scatter_elements_update.hppindex 08f7426af20..721ec1ceb9a 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/scatter_elements_update.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/scatter_elements_update.hpp@@ -49,11 +49,13 @@ struct ScatterElementsUpdateImplementationManager : public ImplementationManagerconst auto& in0_layout = node.get_input_layout(0);const auto& in1_layout = node.get_input_layout(1);const auto& out_layout = node.get_output_layout(0);- if (!one_of(in0_layout.format, supported_fmts) || !one_of(out_layout.format, supported_fmts))+ if (!one_of(in0_layout.format, supported_fmts) || !one_of(out_layout.format, supported_fmts)) {return false;+ }- if (!one_of(in0_layout.data_type, supported_in_types) || !one_of(in1_layout.data_type, supported_in_types))+ if (!one_of(in0_layout.data_type, supported_in_types) || !one_of(in1_layout.data_type, supported_in_types)) {return false;+ }return one_of(out_layout.data_type, supported_out_types);}diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/scatter_update.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl/scatter_update.hppindex 268112a1891..02d294f9c5f 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/scatter_update.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/scatter_update.hpp@@ -53,15 +53,18 @@ struct ScatterUpdateImplementationManager : public ImplementationManager {const auto& in1_layout = node.get_input_layout(1);const auto& out_layout = node.get_output_layout(0);if (m_shape_type == shape_types::dynamic_shape) {- if (!one_of(in0_layout.format, supported_dynamic_fmts) || !one_of(out_layout.format, supported_dynamic_fmts))+ if (!one_of(in0_layout.format, supported_dynamic_fmts) || !one_of(out_layout.format, supported_dynamic_fmts)) {return false;+ }} else {- if (!one_of(in0_layout.format, supported_static_fmts) || !one_of(out_layout.format, supported_static_fmts))+ if (!one_of(in0_layout.format, supported_static_fmts) || !one_of(out_layout.format, supported_static_fmts)) {return false;+ }}- if (!one_of(in0_layout.data_type, supported_in_types) || !one_of(in1_layout.data_type, supported_in_types))+ if (!one_of(in0_layout.data_type, supported_in_types) || !one_of(in1_layout.data_type, supported_in_types)) {return false;+ }return one_of(out_layout.data_type, supported_out_types);}diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/shuffle_channels.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/shuffle_channels.cppindex 4362d64aa23..a37efeb78c0 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/shuffle_channels.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/shuffle_channels.cpp@@ -30,8 +30,9 @@ struct shuffle_channels_impl : typed_primitive_impl_ocl<shuffle_channels> {const int32_t number_of_dims = 4;int32_t axis = primitive->axis;- if (axis < 0)+ if (axis < 0) {axis += number_of_dims;+ }params.group = primitive->group;params.axis = axis;diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/slice.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/slice.cppindex a2f042db035..f2f76924ad0 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/slice.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/slice.cpp@@ -160,8 +160,9 @@ private:const stream& stream = arg.get_program().get_stream();const auto& inputs = arg.get_dependencies();- if (inputs.size() <= idx)+ if (inputs.size() <= idx) {return false;+ }const SliceKernelRefNeededInputs kernel_needed_inputs = SliceKernelRefNeededInputs::Create(arg);if (kernel_needed_inputs.IsInputNeededInRuntime(idx)) {diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/softmax.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/softmax.cppindex 913f19a5cbf..d3c5214bbb9 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/softmax.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/softmax.cpp@@ -20,15 +20,17 @@ static inline kernel_selector::softmax_dim get_softmax_dim(int64_t axis, size_tcase 0: return kernel_selector::softmax_dim::BATCH;case 1: return kernel_selector::softmax_dim::FEATURE;case 2:- if (rank > 4)+ if (rank > 4) {return kernel_selector::softmax_dim::Z;- else+ } else {return kernel_selector::softmax_dim::Y;+ }case 3:- if (rank > 4)+ if (rank > 4) {return kernel_selector::softmax_dim::Y;- else+ } else {return kernel_selector::softmax_dim::X;+ }case 4: return kernel_selector::softmax_dim::X;default: OPENVINO_THROW("Invalid softmax axis ", axis);}diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/strided_slice.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/strided_slice.cppindex bb1e64e9547..03a8a0e6161 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/strided_slice.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/strided_slice.cpp@@ -27,14 +27,17 @@ void pad_vector_to_size(std::vector<T>& data, size_t size, DT value, const std::size_t dims_after = data.size() - ellipsis_pos1 - 1;size_t ellipsis_pos2 = size - dims_after - 1;;- for (size_t i = 0; i < ellipsis_pos1; i++)+ for (size_t i = 0; i < ellipsis_pos1; i++) {temp.push_back(data[i]);+ }- for (size_t i = ellipsis_pos1; i < ellipsis_pos2 + 1; i++)+ for (size_t i = ellipsis_pos1; i < ellipsis_pos2 + 1; i++) {temp.push_back(value);+ }- for (size_t i = 1; i < size - ellipsis_pos2; i++)+ for (size_t i = 1; i < size - ellipsis_pos2; i++) {temp.push_back(data[i + ellipsis_pos1]);+ }data = temp;} else {@@ -47,8 +50,9 @@ void pad_vector_to_size(std::vector<T>& data, size_t size, DT value, const std::template <typename T, typename MT>std::vector<T>& vector_assign_if_not_mask(std::vector<T>& dst, const T& src, const std::vector<MT>& mask) {for (size_t i = 0; i < dst.size(); ++i) {- if (mask[i])+ if (mask[i]) {dst[i] = src;+ }}return dst;}@@ -56,8 +60,9 @@ std::vector<T>& vector_assign_if_not_mask(std::vector<T>& dst, const T& src, contemplate <typename T, typename MT>std::vector<T>& vector_assign_if_not_mask(std::vector<T>& dst, const std::vector<T>& src, const std::vector<MT>& mask) {for (size_t i = 0; i < dst.size(); ++i) {- if (mask[i])+ if (mask[i]) {dst[i] = src[i];+ }}return dst;}@@ -117,8 +122,9 @@ public:auto get_index_end = [&]() {size_t offset = 1;- if ((begin.empty() || params.has_dynamic_tensors()) && params.begin_type == kernel_selector::base_params::ArgType::Input)+ if ((begin.empty() || params.has_dynamic_tensors()) && params.begin_type == kernel_selector::base_params::ArgType::Input) {offset++;+ }return offset;};if (!end.empty() && !params.has_dynamic_tensors()) {@@ -134,8 +140,9 @@ public:auto get_index_stride = [&]() {size_t offset = get_index_end();- if ((end.empty() || params.has_dynamic_tensors()) && params.end_type == kernel_selector::base_params::ArgType::Input)+ if ((end.empty() || params.has_dynamic_tensors()) && params.end_type == kernel_selector::base_params::ArgType::Input) {offset++;+ }return offset;};if (!strides.empty() && !params.has_dynamic_tensors()) {@@ -179,8 +186,9 @@ public:std::vector<size_t> logical_dims = params.inputs[0].LogicalDims();std::reverse(logical_dims.begin(), logical_dims.end()); // get dims in bfyx orderstd::vector<int32_t> out_shape;- for (const auto& dim : logical_dims)+ for (const auto& dim : logical_dims) {out_shape.push_back(static_cast<int32_t>(dim));+ }if (params.striding_params.size() == 3) {// If the ith bit of begin_mask is not set, begin[i] is ignored and the range of the appropriate dimension starts from 0.@@ -202,10 +210,12 @@ public:bool should_clamp_end = check_out_of_bounds(end);// Convert a negative value which means reverse indexing from the end- if (begin < 0)+ if (begin < 0) {begin += out_shape[dim]; // converted value can be negative if the original one was out of bounds- if (end < 0)+ }+ if (end < 0) {end += out_shape[dim];+ }bool is_stride_reverse = stride < 0;// Clamping@@ -223,12 +233,15 @@ public:// sub: begin=-1; end=100;// swap: begin=100; end=-1;// So the kernel will put the slices [99, 0] in reversed order as expected.- if (should_clamp_begin)+ if (should_clamp_begin) {begin--;- if (should_clamp_end)+ }+ if (should_clamp_end) {end--;- if (begin <= end)+ }+ if (begin <= end) {std::swap(begin, end);+ }}params.striding_params[0][dim] = begin;diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/col2im.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/col2im.hppindex 69f2c3a1152..a5cea51a387 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/col2im.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/col2im.hpp@@ -40,13 +40,15 @@ struct Col2Im : public ImplementationManager {}for (const auto& input : node.get_input_layouts()) {- if (input.data_padding)+ if (input.data_padding) {return false;+ }}for (const auto& output : node.get_output_layouts()) {- if (output.data_padding)+ if (output.data_padding) {return false;+ }}return true;diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul.cppindex 61c78588eaf..9eb74a7b099 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul.cpp@@ -36,8 +36,9 @@ namespace {inline bool is_prefill_stage(const RuntimeParams& params) {const auto& input_shape = params.input_layouts[0].get_partial_shape();const auto n_tokens = input_shape[1];- if (n_tokens.is_dynamic())+ if (n_tokens.is_dynamic()) {return false;+ }return n_tokens.get_length() > 1;}@@ -49,8 +50,9 @@ inline bool use_batched_prefill(const GatherMatmulRuntimeParams* rtp) {inline bool has_fused_swiglu(const kernel_impl_params& params) {for (const auto& fd : params.fused_desc) {- if (fd.is_type<swiglu>())+ if (fd.is_type<swiglu>()) {return true;+ }}return false;}diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul_gen_micro.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul_gen_micro.cppindex aa548a0d176..2bc5740c3d3 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul_gen_micro.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul_gen_micro.cpp@@ -24,8 +24,9 @@ void entryObserver(const gemmstone::kcatalog::Entry* entry, double score, gemmststatic bool has_fused_swiglu(const kernel_impl_params& params) {for (const auto& fd : params.fused_desc) {- if (fd.is_type<swiglu>())+ if (fd.is_type<swiglu>()) {return true;+ }}return false;}@@ -106,14 +107,16 @@ JitConstants GatherMatmulMicroGenerator::get_jit_constants(const kernel_impl_par}input_ids.push_back(static_cast<size_t>(scale_idx));- if (!cfg.is_weight_symmetric_quantized)+ if (!cfg.is_weight_symmetric_quantized) {input_ids.push_back(static_cast<size_t>(cfg.weight_zp_idx));+ }jit.make("WEIGHT_SCALE_DT", to_ocl_type(data_types::f16));- if (cfg.weight_group_size > 0)+ if (cfg.weight_group_size > 0) {jit.make("NUM_GROUPS", scale_shape[2]);- else+ } else {jit.make("NUM_GROUPS", 1);+ }// Scales are physically [E, G, N]; must match GatherMatmulBatchedGemmGenerator.jit.make("SCALE_ZP_NO_TRANSPOSE", 1);@@ -180,12 +183,14 @@ JitConstants GatherMatmulMicroGenerator::get_jit_constants(const kernel_impl_parjit.make("N_ACTIVATED_EXPERTS", "INPUT0_BATCH_NUM");jit.make("TOP_K", "INPUT2_FEATURE_NUM");- if (!m_is_prefill)+ if (!m_is_prefill) {jit.make("IS_GENERATE", 1);+ }auto slm_size = bgm_gemm.getSetting("slm_size");- if (slm_size > 0)+ if (slm_size > 0) {jit.make("USE_SLM", 1);+ }return jit;}@@ -347,8 +352,9 @@ std::string GatherMatmulMicroGenerator::get_build_options(const kernel_impl_paraArguments GatherMatmulMicroGenerator::get_arguments_desc(const kernel_impl_params& params) const {Arguments args;- if (params.is_dynamic())+ if (params.is_dynamic()) {args.push_back({ArgumentDescriptor::Types::SHAPE_INFO, 0});+ }auto cfg = get_config(params);args.push_back({ArgumentDescriptor::Types::INPUT, gather_matmul::BGMInputIdx::INPUT});@@ -364,8 +370,9 @@ Arguments GatherMatmulMicroGenerator::get_arguments_desc(const kernel_impl_paramif (cfg.is_weight_quantized) {args.push_back({ArgumentDescriptor::Types::INPUT, static_cast<uint32_t>(cfg.weight_scale_idx)});- if (!cfg.is_weight_symmetric_quantized)+ if (!cfg.is_weight_symmetric_quantized) {args.push_back({ArgumentDescriptor::Types::INPUT, static_cast<uint32_t>(cfg.weight_zp_idx)});+ }}return args;diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul_impl.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul_impl.hppindex fbe5548ece9..7ab795826ad 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul_impl.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gather_matmul_impl.hpp@@ -79,8 +79,9 @@ struct GatherMatmulImpl : public ImplementationManager {// ZP is a placeholder unless desc.has_zp. prepare_quantization may reorder scale/zp to byfx.static const std::vector<format> supported_quant_fmts = {format::bfyx, format::byfx};std::vector<size_t> quant_param_indices = {gather_matmul::BGMInputIdx::WEIGHT_SCALE};- if (desc.has_zp)+ if (desc.has_zp) {quant_param_indices.push_back(gather_matmul::BGMInputIdx::WEIGHT_ZP);+ }for (size_t idx : quant_param_indices) {const auto& layout = node.get_input_layout(idx);if (!one_of(layout.format, supported_quant_fmts) || !one_of(layout.data_type, supported_quant_param_types)) {diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_batched_gemm_gen.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_batched_gemm_gen.cppindex a0e89c9c8ee..627dceb9202 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_batched_gemm_gen.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_batched_gemm_gen.cpp@@ -17,8 +17,9 @@ namespace ov::intel_gpu::ocl {static bool has_fused_swiglu(const kernel_impl_params& params) {for (const auto& fd : params.fused_desc) {- if (fd.is_type<swiglu>())+ if (fd.is_type<swiglu>()) {return true;+ }}return false;}@@ -68,10 +69,11 @@ JitConstants GatherMatmulBatchedGemmGenerator::get_jit_constants(const kernel_im}jit.make("WEIGHT_SCALE_DT", to_ocl_type(data_types::f16));- if (cfg.weight_group_size > 0)+ if (cfg.weight_group_size > 0) {jit.make("NUM_GROUPS", scale_shape[2]);- else+ } else {jit.make("NUM_GROUPS", 1);+ }// Scales are physically [E, G, N]; must match GatherMatmulMicroGenerator.jit.make("SCALE_ZP_NO_TRANSPOSE", 1);@@ -119,8 +121,9 @@ JitConstants GatherMatmulBatchedGemmGenerator::get_jit_constants(const kernel_imjit.make("TOP_K", indices_jitter.dim(ChannelName::FEATURE));auto slm_size = bgm_gemm.getSetting("slm_size");- if (slm_size > 0)+ if (slm_size > 0) {jit.make("USE_SLM", 1);+ }if (has_fused_swiglu(params)) {size_t m_out = weight_shape[1] / 2;@@ -152,8 +155,9 @@ std::string GatherMatmulBatchedGemmGenerator::get_build_options(const kernel_impArguments GatherMatmulBatchedGemmGenerator::get_arguments_desc(const kernel_impl_params& params) const {Arguments args;- if (params.is_dynamic())+ if (params.is_dynamic()) {args.push_back({ArgumentDescriptor::Types::SHAPE_INFO, 0});+ }auto cfg = GatherMatmulMicroGenerator::get_config(params);// gathered_A (internal buffer 0)@@ -179,8 +183,9 @@ Arguments GatherMatmulBatchedGemmGenerator::get_arguments_desc(const kernel_implif (cfg.is_weight_quantized) {args.push_back({ArgumentDescriptor::Types::INPUT, static_cast<uint32_t>(cfg.weight_scale_idx)});- if (!cfg.is_weight_symmetric_quantized)+ if (!cfg.is_weight_symmetric_quantized) {args.push_back({ArgumentDescriptor::Types::INPUT, static_cast<uint32_t>(cfg.weight_zp_idx)});+ }}return args;diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_gather_gen.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_gather_gen.cppindex 9ae84697990..1ad0fc8885e 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_gather_gen.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_gather_gen.cpp@@ -29,8 +29,9 @@ JitConstants GatherMatmulGatherGenerator::get_jit_constants(const kernel_impl_paArguments GatherMatmulGatherGenerator::get_arguments_desc(const kernel_impl_params& params) const {Arguments args;- if (params.is_dynamic())+ if (params.is_dynamic()) {args.push_back({ArgumentDescriptor::Types::SHAPE_INFO, 0});+ }// input activations Aargs.push_back({ArgumentDescriptor::Types::INPUT, gather_matmul::BGMInputIdx::INPUT});diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_scatter_gen.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_scatter_gen.cppindex fb68548753e..7a049d76f23 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_scatter_gen.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_scatter_gen.cpp@@ -25,8 +25,9 @@ JitConstants GatherMatmulScatterGenerator::get_jit_constants(const kernel_impl_pArguments GatherMatmulScatterGenerator::get_arguments_desc(const kernel_impl_params& params) const {Arguments args;- if (params.is_dynamic())+ if (params.is_dynamic()) {args.push_back({ArgumentDescriptor::Types::SHAPE_INFO, 0});+ }args.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 8}); // PACKED_OUTargs.push_back({ArgumentDescriptor::Types::OUTPUT, 0});diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_sort_gen.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_sort_gen.cppindex bb567a3f6f5..19db671a9a6 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_sort_gen.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/gather_matmul/gathermatmul_sort_gen.cpp@@ -33,8 +33,9 @@ JitConstants GatherMatmulSortGenerator::get_jit_constants(const kernel_impl_paraArguments GatherMatmulSortGenerator::get_arguments_desc(const kernel_impl_params& params) const {Arguments args;- if (params.is_dynamic())+ if (params.is_dynamic()) {args.push_back({ArgumentDescriptor::Types::SHAPE_INFO, 0});+ }args.push_back({ArgumentDescriptor::Types::INPUT, gather_matmul::BGMInputIdx::INDICES});args.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1}); // group_expert_idsdiff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/expert_weight_providers.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/expert_weight_providers.cppindex 165b83715a7..38640ac9677 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/expert_weight_providers.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/expert_weight_providers.cpp@@ -82,11 +82,13 @@ std::optional<ExpertSlotLease> OffloadExpertWeightProvider::try_acquire_simultanconst auto slot = item.first;if (item.second) {- if (perf)+ if (perf) {perf->gpu_hits.fetch_add(1, std::memory_order_relaxed);+ }} else {- if (perf)+ if (perf) {perf->gpu_misses.fetch_add(1, std::memory_order_relaxed);+ }OPENVINO_ASSERT(_resident != nullptr, "OffloadExpertWeightProvider: resident buffers not bound");moe_otd::fill_weights_memory(stream, _config, _weight_bin_offsets, _weight_reader, *_resident, {expert}, {slot});_cache->set_filled(slot);@@ -106,11 +108,13 @@ size_t OffloadExpertWeightProvider::acquire_one(uint32_t expert, cldnn::stream&const auto slot = item.first;if (item.second) {- if (perf)+ if (perf) {perf->gpu_hits.fetch_add(1, std::memory_order_relaxed);+ }} else {- if (perf)+ if (perf) {perf->gpu_misses.fetch_add(1, std::memory_order_relaxed);+ }OPENVINO_ASSERT(_resident != nullptr, "OffloadExpertWeightProvider: resident buffers not bound");moe_otd::fill_weights_memory(stream, _config, _weight_bin_offsets, _weight_reader, *_resident, {expert}, {slot});_cache->set_filled(slot);diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/lru_cache.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/lru_cache.cppindex 5d55449d581..9f3eed86e29 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/lru_cache.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/lru_cache.cpp@@ -11,14 +11,16 @@ LRUCache::LRUCache(size_t max_total_experts) : m_max_total_experts(max_total_exp}void LRUCache::move_to_end(std::list<Node>::iterator it) {- if (std::next(it) == m_list.end())+ if (std::next(it) == m_list.end()) {return;+ }m_list.splice(m_list.end(), m_list, it);}void LRUCache::evict_one_unlocked() {- if (m_list.empty())+ if (m_list.empty()) {return;+ }auto& oldest = m_list.front();diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_3gemm_gen_micro.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_3gemm_gen_micro.cppindex 3b1e423e7f9..bddb02a5ddb 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_3gemm_gen_micro.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_3gemm_gen_micro.cpp@@ -135,8 +135,9 @@ JitConstants MoE3GemmMicroGenerator::get_jit_constants(const kernel_impl_params&}auto slm_size = moe_gemm.getSetting("slm_size");- if (slm_size > 0)+ if (slm_size > 0) {jit.make("USE_SLM", 1);+ }const bool enable_silu_mul = ENABLE_MOE_MICRO_GEMM_POST_PROC_SILU_MUL;if (enable_silu_mul && m_type == MoE3GemmMicroKernelType::MLP_GATE) {@@ -395,8 +396,9 @@ Arguments MoE3GemmMicroGenerator::get_arguments_desc(const kernel_impl_params& pargs.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, MOE_INTERNAL_BUFFER_GATE_OUTPUT}); // gate output{const bool enable_silu_mul = ENABLE_MOE_MICRO_GEMM_POST_PROC_SILU_MUL;- if (enable_silu_mul)+ if (enable_silu_mul) {args.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, MOE_INTERNAL_BUFFER_UP_OUTPUT});+ }}args.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, MOE_INTERNAL_BUFFER_ACTIVATED_EXPERT_IDS}); // experts_idsargs.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, MOE_INTERNAL_BUFFER_TOKEN_START_OFFSET_PER_EXPERT}); // input_offset_per_expert@@ -404,8 +406,9 @@ Arguments MoE3GemmMicroGenerator::get_arguments_desc(const kernel_impl_params& pargs.push_back({ArgumentDescriptor::Types::SCALAR, 0}); // margs.push_back({ArgumentDescriptor::Types::SCALAR, 1}); // kargs.push_back({ArgumentDescriptor::Types::INPUT, static_cast<int>(MOE3GemmInputIndex::SCALE_0)}); // scale- if (!is_weight_symmetric_quantized)+ if (!is_weight_symmetric_quantized) {args.push_back({ArgumentDescriptor::Types::INPUT, static_cast<int>(MOE3GemmInputIndex::ZP_0)}); // zp+ }break;case MoE3GemmMicroKernelType::MLP_UP:args.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, MOE_INTERNAL_BUFFER_GATE_UP_INPUT}); // gather input tensor@@ -417,8 +420,9 @@ Arguments MoE3GemmMicroGenerator::get_arguments_desc(const kernel_impl_params& pargs.push_back({ArgumentDescriptor::Types::SCALAR, 0}); // margs.push_back({ArgumentDescriptor::Types::SCALAR, 1}); // kargs.push_back({ArgumentDescriptor::Types::INPUT, static_cast<int>(MOE3GemmInputIndex::SCALE_1)}); // scale- if (!is_weight_symmetric_quantized)+ if (!is_weight_symmetric_quantized) {args.push_back({ArgumentDescriptor::Types::INPUT, static_cast<int>(MOE3GemmInputIndex::ZP_1)}); // zp+ }break;case MoE3GemmMicroKernelType::MLP_DOWN:args.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, MOE_INTERNAL_BUFFER_GATE_OUTPUT}); // intermediate_mem[6]@@ -430,8 +434,9 @@ Arguments MoE3GemmMicroGenerator::get_arguments_desc(const kernel_impl_params& pargs.push_back({ArgumentDescriptor::Types::SCALAR, 0}); // margs.push_back({ArgumentDescriptor::Types::SCALAR, 1}); // kargs.push_back({ArgumentDescriptor::Types::INPUT, static_cast<int>(MOE3GemmInputIndex::SCALE_2)}); // scale- if (!is_weight_symmetric_quantized)+ if (!is_weight_symmetric_quantized) {args.push_back({ArgumentDescriptor::Types::INPUT, static_cast<int>(MOE3GemmInputIndex::ZP_2)}); // zp+ }break;default:OPENVINO_THROW("Unsupported MoE3GemmMicroKernelType");diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_3gemm_swiglu_opt.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_3gemm_swiglu_opt.cppindex c27c2c5fe5f..d62cf1d7422 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_3gemm_swiglu_opt.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_3gemm_swiglu_opt.cpp@@ -239,8 +239,9 @@ protected:jit.make("INPUT1_TYPE", "int");jit.make("OUTPUT_TYPE", "half");jit.make("OPTIONAL_SHAPE_INFO_ARG", "");- if (m_use_grouped_gemm)+ if (m_use_grouped_gemm) {jit.make("ONEDNN_GROUPED_GEMM_USED", 1);+ }GPU_DEBUG_TRACE_DETAIL << "MoE3GemmSwigluPrefillGather::get_jit_constants(): hidden_size: " << hidden_size << ", block_size: " << block_size<< ", local_threads_count: " << local_threads_count << ", batches_per_thread: " << batches_per_thread@@ -284,8 +285,9 @@ protected:} else if (desc->_config.activation_type == ov::op::internal::MOE::Activation_type::GEGLU_ERF) {jit.make("GATE_ACT_GELU_ERF", 1);}- if (m_use_grouped_gemm)+ if (m_use_grouped_gemm) {jit.make("ONEDNN_GROUPED_GEMM_USED", 1);+ }return jit;}@@ -334,8 +336,9 @@ protected:jit.make("INPUT5_TYPE", "int"); // tokens len for expertsjit.make("INPUT6_TYPE", "int"); // expert idjit.make("OUTPUT_TYPE", "half"); // output- if (m_use_grouped_gemm)+ if (m_use_grouped_gemm) {jit.make("ONEDNN_GROUPED_GEMM_USED", 1);+ }return jit;}@@ -674,8 +677,9 @@ public:// --- Inline composition methods (replace virtual hooks) ---void bind_weights_on_first_exec(typed_primitive_inst<moe_3gemm_fused_compressed>& instance) {- if (!_weight_provider->is_offloaded())+ if (!_weight_provider->is_offloaded()) {return;+ }if (!_weight_provider->is_bound()) {instance._weights.gate_w = instance.input_memory_ptr(static_cast<size_t>(MOE3GemmInputIndex::WEIGHT_0));instance._weights.gate_z = instance.input_memory_ptr(static_cast<size_t>(MOE3GemmInputIndex::ZP_0));@@ -738,8 +742,9 @@ public:auto lease = _weight_provider->try_acquire_simultaneous(expert_ids, stream);if (!lease) {- if (auto* perf = moe_otd::get_perf_counters())+ if (auto* perf = moe_otd::get_perf_counters()) {perf->batched_fallbacks.fetch_add(1, std::memory_order_relaxed);+ }needs_fallback = true;return;}@@ -752,8 +757,9 @@ public:scratch._expert_index_buffer = engine.allocate_memory(layout, allocation_type::usm_host, false);}std::vector<uint32_t> slots_u32(lease->size());- for (size_t i = 0; i < lease->size(); i++)+ for (size_t i = 0; i < lease->size(); i++) {slots_u32[i] = static_cast<uint32_t>((*lease)[i]);+ }scratch._expert_index_buffer->copy_from(stream, slots_u32.data(), 0, 0, topk_bytes, true);set_otd_weight_pointers(instance, scratch);@@ -776,8 +782,9 @@ public:auto lease = _weight_provider->try_acquire_simultaneous(expert_ids, stream);if (!lease) {- if (auto* perf = moe_otd::get_perf_counters())+ if (auto* perf = moe_otd::get_perf_counters()) {perf->grouped_fallbacks.fetch_add(1, std::memory_order_relaxed);+ }needs_fallback = true;return;}@@ -790,16 +797,18 @@ public:scratch._expert_index_buffer = engine.allocate_memory(layout, allocation_type::usm_host, false);}std::vector<uint32_t> slots_u32(lease->size());- for (size_t i = 0; i < lease->size(); i++)+ for (size_t i = 0; i < lease->size(); i++) {slots_u32[i] = static_cast<uint32_t>((*lease)[i]);+ }scratch._expert_index_buffer->copy_from(stream, slots_u32.data(), 0, 0, topk_bytes, true);batch_mem_ptr = scratch._expert_index_buffer;needs_fallback = false;}bool on_load_expert_weights(size_t expert_no, typed_primitive_inst<moe_3gemm_fused_compressed>& instance, dnnl::stream& dnn_stream) {- if (!_weight_provider->is_offloaded())+ if (!_weight_provider->is_offloaded()) {return false;+ }dnn_stream.wait();@@ -847,8 +856,9 @@ public:std::vector<int32_t>& grouped_offsets_cpu,int& num_actually_used_experts,const std::vector<cldnn::event::ptr>& events) {- if (!_weight_provider->is_offloaded())+ if (!_weight_provider->is_offloaded()) {return false;+ }stream.finish(); // ensure routing kernel has written topk_ids@@ -862,15 +872,17 @@ public:if (!lease) {GPU_DEBUG_TRACE_DETAIL << "exec_prefill_grouped_gemm OTD: unique experts exceed resident_slots=" << resident_slot_count()<< ", falling back to per-expert onednn loop" << std::endl;- if (auto* perf = moe_otd::get_perf_counters())+ if (auto* perf = moe_otd::get_perf_counters()) {perf->grouped_fallbacks.fetch_add(1, std::memory_order_relaxed);+ }return false; // Caller checks is_offloaded() to distinguish from non-OTD}// Remap using lease slotsstd::vector<uint32_t> remapped(topk_count);- for (size_t i = 0; i < topk_count; i++)+ for (size_t i = 0; i < topk_count; i++) {remapped[i] = static_cast<uint32_t>((*lease)[i]);+ }// Build per-slot token lists sorted by LRU slot indexstd::vector<std::vector<int32_t>> slot_tokens(num_grouped_experts);@@ -893,8 +905,9 @@ public:tokens_lens_per_expert_cpu[experts_iter] = n;++experts_iter;++num_actually_used_experts;- for (auto t : slot_tokens[s])+ for (auto t : slot_tokens[s]) {tokens_per_expert_cpu[tokens_iter++] = t;+ }}}@@ -913,13 +926,15 @@ public:}void on_after_grouped_gemm(cldnn::stream& stream) {- if (_weight_provider->is_offloaded())+ if (_weight_provider->is_offloaded()) {stream.get_onednn_stream().wait();+ }}void on_after_exec_sync(cldnn::stream& stream) {- if (_weight_provider->is_offloaded())+ if (_weight_provider->is_offloaded()) {stream.finish();+ }}bool should_pre_zero_output() {@@ -933,8 +948,9 @@ public:}void on_before_grouped_gather(cldnn::stream& stream) {- if (_weight_provider->is_offloaded())+ if (_weight_provider->is_offloaded()) {stream.finish();+ }}ov::op::internal::MOE::Activation_type _activation_type = ov::op::internal::MOE::Activation_type::SWIGLU;@@ -1046,8 +1062,9 @@ public:void init_dnnl_weights(const std::shared_ptr<const moe_3gemm_fused_compressed>& cur_moe,cldnn::engine& engine,const struct moe_fusion_weights_base_addr& moe_fusion_wei_addr) {- if (_dnnl_weights.size() == cur_moe->_config.num_expert)+ if (_dnnl_weights.size() == cur_moe->_config.num_expert) {return;+ }init(cur_moe);_dnnl_weights.resize(cur_moe->_config.num_expert);@@ -1134,8 +1151,9 @@ public:}void init_shared_primitives(cldnn::engine& engine, const struct moe_fusion_weights_base_addr& addr, int batch) {- if (_shared_gate_proj && _shared_gate_proj->m_batch == batch)+ if (_shared_gate_proj && _shared_gate_proj->m_batch == batch) {return;+ }OPENVINO_ASSERT(addr.shared_weight[0], "MoE shared expert enabled (num_shared_expert > 0) but shared weight buffers are not bound");@@ -1601,8 +1619,9 @@ public:// scratch.up = up(x) * silu(gate(x)) for all (token, expert) pairsstd::vector<memory::ptr> args_gate_up ={batch_mem_ptr, mlp_gate_wei_mem, mlp_gate_scale_mem, mlp_gate_zp_mem, mlp_up_wei_mem, mlp_up_scale_mem, mlp_up_zp_mem};- if (_has_shared_expert)+ if (_has_shared_expert) {args_gate_up.insert(args_gate_up.end(), extra_args_gate_up.begin(), extra_args_gate_up.end());+ }args_gate_up.push_back(hidden_states_mem_ptr);auto ret_event = execute_stage(events,@@ -1615,12 +1634,14 @@ public:// scratch.y = down(scratch.up) * routing_weight for all (token, expert) pairsstd::vector<memory::ptr> args_down = {batch_mem_ptr, mlp_down_wei_mem, mlp_down_scale_mem, mlp_down_zp_mem};- if (_has_shared_expert)+ if (_has_shared_expert) {args_down.insert(args_down.end(), extra_args_down.begin(), extra_args_down.end());+ }args_down.push_back(scratch.up);args_down.push_back(routing_mem_ptr); // compact topk_weights [token_num * MAX_TOPK]- if (_has_shared_expert)+ if (_has_shared_expert) {args_down.push_back(scratch.routing_weights); // shared_gate_in [token_num]+ }ret_event = execute_stage({ret_event},instance,*stage_down,@@ -1970,8 +1991,9 @@ public:if (!_kernels.has(std::make_pair(n_token, 0))) {auto kernel = create_kernel(n_token, expert_no, instance);_kernels.add(std::make_pair(n_token, 0), kernel);- if (auto* perf = moe_otd::get_perf_counters())+ if (auto* perf = moe_otd::get_perf_counters()) {perf->created_onednn_kernels.fetch_add(1, std::memory_order_relaxed);+ }}auto& kernel = *_kernels.get(std::make_pair(n_token, 0));// Patch weight memory handles for the current expert's LRU slot.@@ -1993,8 +2015,9 @@ public:if (!_kernels.has(key)) {auto kernel = create_kernel(n_token, expert_no, instance);_kernels.add(key, kernel);- if (auto* perf = moe_otd::get_perf_counters())+ if (auto* perf = moe_otd::get_perf_counters()) {perf->created_onednn_kernels.fetch_add(1, std::memory_order_relaxed);+ }}return *_kernels.get(key);}@@ -2132,20 +2155,23 @@ public:gk->gate_pd = make_pd(K_gu, N_gu, _gate_up_group_size, gw_dt);gk->gate_prim = dnnl::matmul(gk->gate_pd);gk->gate_scale_md = make_quant_md(num_experts, K_gu, _gate_up_group_size, N_gu, dnnl::memory::data_type::f16);- if (has_zp)+ if (has_zp) {gk->gate_zp_md = make_quant_md(num_experts, K_gu, _gate_up_group_size, N_gu, gw_dt);+ }gk->up_pd = make_pd(K_gu, N_gu, _gate_up_group_size, uw_dt);gk->up_prim = dnnl::matmul(gk->up_pd);gk->up_scale_md = gk->gate_scale_md;- if (has_zp)+ if (has_zp) {gk->up_zp_md = gk->gate_zp_md;+ }gk->down_pd = make_pd(K_d, N_d, _down_group_size, dw_dt);gk->down_prim = dnnl::matmul(gk->down_pd);gk->down_scale_md = make_quant_md(num_experts, K_d, _down_group_size, N_d, dnnl::memory::data_type::f16);- if (has_zp)+ if (has_zp) {gk->down_zp_md = make_quant_md(num_experts, K_d, _down_group_size, N_d, dw_dt);+ }_grouped_kernels.add(key, gk);return *_grouped_kernels.get(key);@@ -2217,8 +2243,9 @@ public:auto n_token = static_cast<int>(expert_mask.batch[expert_no].size());// Be careful about possible overflow- if (n_token > std::numeric_limits<int64_t>::max() / max_topk)+ if (n_token > std::numeric_limits<int64_t>::max() / max_topk) {OPENVINO_THROW("n_token * max_topk overflow detected, n_token=", n_token, " max_topk=", max_topk);+ }int64_t routing_weights_size = static_cast<int64_t>(n_token * max_topk);onednn_kernel& kernel = get_kernel(n_token, static_cast<int>(expert_no), instance);@@ -2350,8 +2377,9 @@ public:tokens_lens_per_expert_cpu[experts_iter] = n;++experts_iter;++num_actually_used_experts;- for (auto t : expert_mask.batch[e])+ for (auto t : expert_mask.batch[e]) {tokens_per_expert_cpu[tokens_iter++] = t;+ }}}}@@ -2377,8 +2405,9 @@ public:// = exclusive end of expert k = grouped_offsets_cpu[k].{std::vector<int32_t> expert_start_offsets_per_id(static_cast<size_t>(num_grouped_experts - 1));- for (int e = 0; e < num_grouped_experts - 1; ++e)+ for (int e = 0; e < num_grouped_experts - 1; ++e) {expert_start_offsets_per_id[e] = grouped_offsets_cpu[e]; // end[e] == start[e+1]+ }intermediates_memories[MOE_INTERNAL_BUFFER_TOKEN_START_OFFSET_PER_EXPERT]->copy_from(stream, expert_start_offsets_per_id.data(), 0, 0, expert_start_offsets_per_id.size() * sizeof(int32_t), true);}diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_otd_runtime.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_otd_runtime.cppindex 5c6d9d9d4a6..fe247406ad2 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_otd_runtime.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_otd_runtime.cpp@@ -32,8 +32,9 @@ void OtdPerfCounters::dump() const {OtdPerfCounters* get_perf_counters() {static bool enabled = std::getenv("MOE_OTD_PERF_LOG") != nullptr;- if (!enabled)+ if (!enabled) {return nullptr;+ }static OtdPerfCounters counters;static bool registered = [] {@@ -193,8 +194,9 @@ void fill_weights_memory(cldnn::stream& exec_stream,for (uint32_t expert : experts_list) {auto make_tensor_fill_plan = [&](size_t base_offset, cldnn::memory_ptr mem, size_t expert_no, size_t lru_expert_no, const char* tensor_name) {tensor_fill_plan plan;- if (!mem)+ if (!mem) {return plan;+ }const auto total_bytes = mem->get_layout().bytes_count();OPENVINO_ASSERT(num_expert > 0, "Invalid expert count");plan.per_expert_size = total_bytes / num_expert;diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_router_fused_opt.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_router_fused_opt.cppindex 7ccd78be0e6..9f65bc66a91 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_router_fused_opt.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/moe/moe_router_fused_opt.cpp@@ -99,8 +99,9 @@ public:auto input_layout = instance.dependencies()[0].first->get_impl_params()->get_output_layout(instance.dependencies()[0].second);auto input_shape = input_layout.get_shape();size_t token_num = input_shape[0];- if (input_shape.size() >= 3)+ if (input_shape.size() >= 3) {token_num = input_shape[0] * input_shape[1];+ }size_t lws_size = config.num_expert;// Select routing stage and build inputsdiff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/pa_kv_reorder.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/pa_kv_reorder.hppindex a0a192719f9..d569bda8f36 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/pa_kv_reorder.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/pa_kv_reorder.hpp@@ -22,8 +22,9 @@ struct PA_KV_reorder : public ImplementationManager {[[nodiscard]] std::unique_ptr<primitive_impl> create_impl(const program_node& node, const RuntimeParams& params) const override;[[nodiscard]] bool validate_impl(const program_node& node) const override {- if (node.has_fused_primitives())+ if (node.has_fused_primitives()) {return false;+ }const auto desc = node.as<cldnn::pa_kv_reorder>().get_primitive();return !desc->has_xattention;diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/paged_gated_delta_net.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/paged_gated_delta_net.cppindex b4805fd8777..2e321693637 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/paged_gated_delta_net.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/paged_gated_delta_net.cpp@@ -141,8 +141,9 @@ protected:const auto& v_layout = params.input_layouts[paged_gated_delta_net::VALUE];auto read_pitch = [](const cldnn::layout& layout, size_t idx) -> int32_t {const auto& pitches = layout.get_pitches();- if (idx < pitches.size())+ if (idx < pitches.size()) {return static_cast<int32_t>(pitches[idx]);+ }return 1;};diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/paged_selective_ssm.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/paged_selective_ssm.hppindex ce29615d19a..676edb61b21 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/paged_selective_ssm.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/paged_selective_ssm.hpp@@ -39,20 +39,22 @@ struct PagedSelectiveSSMOpt : public cldnn::ImplementationManager {if (i < cldnn::paged_selective_ssm::RECURRENT_STATE_TABLE) {if (!cldnn::one_of(in_layout.data_type, supported_real_types))return false;- if (data_type.is_dynamic())+ if (data_type.is_dynamic()) {data_type = in_layout.data_type;- else if (data_type != in_layout.data_type)+ } else if (data_type != in_layout.data_type) {return false;+ }} else if (i == cldnn::paged_selective_ssm::RECURRENT_STATE_TABLE) {if (!cldnn::one_of(in_layout.data_type, supported_real_types))return false;} else {if (!cldnn::one_of(in_layout.data_type, supported_index_types))return false;- if (index_type.is_dynamic())+ if (index_type.is_dynamic()) {index_type = in_layout.data_type;- else if (index_type != in_layout.data_type)+ } else if (index_type != in_layout.data_type) {return false;+ }}}diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/rope_opt.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/rope_opt.cppindex e155be427be..2e33b564cdc 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/rope_opt.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/rope_opt.cpp@@ -36,8 +36,9 @@ size_t get_vec_size(const RuntimeParams& params) {// Some models use f32 precision for input1 (cos) and input2 (sin) for better accuracy.// If input0 is not f32, we set vec_size as 1 for simple type conversion.- if (input1.data_type == ov::element::f32 && input.data_type != input1.data_type)+ if (input1.data_type == ov::element::f32 && input.data_type != input1.data_type) {vec_size = 1;+ }if (desc->config.is_qwen) {auto count = desc->config.head_cnt * std::max(desc->config.rotary_ndims / 2ul, desc->config.head_size - desc->config.rotary_ndims);@@ -196,8 +197,9 @@ protected:size_t lws = 1;while (((val + 1) <= max_workgroup_size) && (gws >= (val + 1))) {val += 1;- if (gws % val == 0)+ if (gws % val == 0) {lws = val;+ }}return lws;};diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/paged_attention_opt.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/paged_attention_opt.cppindex 622e5127094..5bb420d99fb 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/paged_attention_opt.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/paged_attention_opt.cpp@@ -1263,10 +1263,11 @@ public:}if (has_alibi) {const size_t tensor_id = PagedAttentionInputIdx::ALIBI;- if (has_scale_input)+ if (has_scale_input) {jit.add(make_layout_jit_constants("INPUT5", params.input_layouts[tensor_id], in_offsets_map.at(tensor_id)));- else+ } else {jit.add(make_layout_jit_constants("INPUT4", params.input_layouts[tensor_id], in_offsets_map.at(tensor_id)));+ }}jit.add(make_layout_jit_constants("OUTPUT", params.output_layouts[0], out_offsets_map.at(0)));@@ -1561,11 +1562,13 @@ public:if (rt_params->stage == PagedAttentionStage::PREFILL) {#ifdef ENABLE_ONEDNN_FOR_GPU- if (rt_params->use_micro_sdpa)+ if (rt_params->use_micro_sdpa) {res_event = {execute_stage(res_event, instance, pa_sdpa_micro)};- else+ } else#endif+ {res_event = {execute_stage(res_event, instance, pa_sdpa_opt)};+ }} else if (rt_params->stage == PagedAttentionStage::GENERATE || rt_params->stage == PagedAttentionStage::MIXED) {const auto multi_tokens_mode = rt_params->stage == PagedAttentionStage::MIXED;auto num_of_partitions = rt_params->num_of_partitions;@@ -1573,11 +1576,13 @@ public:res_event = {execute_stage(res_event, instance, multi_tokens_mode ? pa_multi_token : pa_gqa_single_token)};} else {#ifdef ENABLE_ONEDNN_FOR_GPU- if (multi_tokens_mode && rt_params->use_micro_sdpa)+ if (multi_tokens_mode && rt_params->use_micro_sdpa) {res_event = {execute_stage(res_event, instance, pa_sdpa_micro_mixed)};- else+ } else#endif+ {res_event = {execute_stage(res_event, instance, multi_tokens_mode ? pa_multi_token : pa_single_token)};+ }}if (num_of_partitions > 1 && !rt_params->use_micro_sdpa) {res_event = {execute_stage(res_event, instance, multi_tokens_mode ? pa_multi_token_finalization : pa_single_token_finalization)};@@ -1737,10 +1742,11 @@ public:};size_t snap_kv_tokens = 0;- if (rt_params)+ if (rt_params) {snap_kv_tokens = rt_params->paged_attention_snap_kv_tokens;- else+ } else {snap_kv_tokens = get_snap_kv_tokens(desc->has_score_aggregation);+ }auto tokens_number = desc->has_score_aggregation ? snap_kv_tokens : subsequences_number;auto softmax_buf_elements_count = static_cast<int64_t>(tokens_number * desc->heads_num * num_of_partitions * partition_size) * element_size;diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_base.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_base.cppindex 9ddb67bde06..e144d10f927 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_base.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_base.cpp@@ -86,8 +86,9 @@ std::pair<int64_t, int64_t> SDPABase::get_gqa_params(const kernel_impl_params& pif (params.is_type<scaled_dot_product_attention>()) {auto desc = params.typed_desc<scaled_dot_product_attention>();auto transpose_pshape = [](const ov::PartialShape& pshape, const std::vector<int64_t>& order) {- if (order.empty())+ if (order.empty()) {return pshape;+ }auto transposed_pshape = ov::PartialShape::dynamic(pshape.rank());for (size_t i = 0; i < order.size(); i++) {@@ -136,8 +137,9 @@ sdpa_configuration SDPABase::get_sdpa_configuration(const kernel_impl_params& imsdpa_configuration config;auto transpose_pshape = [](const ov::PartialShape& pshape, const std::vector<int64_t>& order) {- if (order.empty())+ if (order.empty()) {return pshape;+ }auto transposed_pshape = ov::PartialShape::dynamic(pshape.rank());for (size_t i = 0; i < order.size(); i++) {@@ -159,11 +161,13 @@ sdpa_configuration SDPABase::get_sdpa_configuration(const kernel_impl_params& im}}- if (query_shape[query_shape.size() - 1].is_static())+ if (query_shape[query_shape.size() - 1].is_static()) {config.k_head_size = query_shape[query_shape.size() - 1].get_length();+ }- if (value_shape[value_shape.size() - 1].is_static())+ if (value_shape[value_shape.size() - 1].is_static()) {config.v_head_size = value_shape[value_shape.size() - 1].get_length();+ }// 4-bit KV-cache: physical V layout has head_size/2 due to u4 packing.// Use logical head size from query to get the correct un-halved value.diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_micro.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_micro.cppindex 971e4da61ef..1f0bab8988b 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_micro.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_micro.cpp@@ -456,121 +456,157 @@ sdpa_config_t xe3_q_h512_2nd = {32, 16, 32, 16, 16, 1, 16, 1};sdpa_config_t* choose_config_xehpg(int head_size, int seq, bool thin_q, bool quantized, bool is_pa, bool is_prefill) {if (head_size <= 32) {- if (seq <= 0 && is_pa)+ if (seq <= 0 && is_pa) {return &xehpg_h32_pa;+ }if (quantized && seq >= 128) {- if (thin_q)+ if (thin_q) {return &xehpg_q_h32_2nd;+ }return &xehpg_q_h32;}- if (thin_q)+ if (thin_q) {return &xehpg_h32_2nd;- if (seq <= 32)+ }+ if (seq <= 32) {return &xehpg_h32_s32;- if (seq <= 64)+ }+ if (seq <= 64) {return &xehpg_h32_s64;- if (seq <= 256)+ }+ if (seq <= 256) {return &xehpg_h32_s256;+ }return &xehpg_h32;}if (head_size <= 64) {- if (seq <= 0 && is_pa)+ if (seq <= 0 && is_pa) {return is_prefill ? &xehpg_h64 : &xehpg_h64_pa;+ }if (quantized) {if (thin_q) {- if (seq <= 64)+ if (seq <= 64) {return &xehpg_q_h64_s64_2nd;- if (seq <= 128)+ }+ if (seq <= 128) {return &xehpg_q_h64_s128_2nd;+ }return &xehpg_q_h64_2nd;}- if (seq <= 32)+ if (seq <= 32) {return &xehpg_q_h64_s32;- if (seq <= 64)+ }+ if (seq <= 64) {return &xehpg_q_h64_s64;- if (seq <= 128)+ }+ if (seq <= 128) {return &xehpg_q_h64_s128;+ }return &xehpg_q_h64;}- if (thin_q)+ if (thin_q) {return &xehpg_h64_2nd;- if (seq <= 64)+ }+ if (seq <= 64) {return &xehpg_h64_s64;- if (seq <= 128)+ }+ if (seq <= 128) {return &xehpg_h64_s128;+ }return &xehpg_h64;}if (head_size <= 128) {- if (seq <= 0 && is_pa)+ if (seq <= 0 && is_pa) {return is_prefill ? &xehpg_h128 : &xehpg_h128_pa;+ }if (quantized) {if (thin_q) {- if (seq <= 1)+ if (seq <= 1) {return &xehpg_q_h128_2nd;- if (seq <= 96)+ }+ if (seq <= 96) {return &xehpg_q_h128_s96_2nd;+ }return &xehpg_q_h128_2nd;}- if (seq <= 64)+ if (seq <= 64) {return &xehpg_q_h128_s64;- if (seq <= 512)+ }+ if (seq <= 512) {return &xehpg_q_h128_s512;+ }return &xehpg_q_h128;}if (thin_q) {- if (seq <= 256)+ if (seq <= 256) {return &xehpg_q_h128_2nd;+ }return &xehpg_h128_2nd;}- if (seq <= 32)+ if (seq <= 32) {return &xehpg_h128_s32;+ }return &xehpg_h128;}if (head_size <= 256) {- if (seq <= 0 && is_pa)+ if (seq <= 0 && is_pa) {return is_prefill ? &xehpg_h256 : &xehpg_h256_pa;+ }if (thin_q) {if (quantized) {- if (seq <= 96)+ if (seq <= 96) {return &xehpg_q_h256_s96_2nd;+ }return &xehpg_q_h256_2nd;}- if (seq <= 32)+ if (seq <= 32) {return &xehpg_h256_s32_2nd;- if (seq <= 64)+ }+ if (seq <= 64) {return &xehpg_h256_s64_2nd;+ }return &xehpg_h256_2nd;}if (quantized) {- if (seq <= 64)+ if (seq <= 64) {return &xehpg_q_h256_s64;- if (seq <= 512)+ }+ if (seq <= 512) {return &xehpg_q_h256_s512;+ }return &xehpg_q_h256;}- if (seq <= 32)+ if (seq <= 32) {return &xehpg_h256_s32;- if (seq <= 128)+ }+ if (seq <= 128) {return &xehpg_h256_s128;+ }return &xehpg_h256;}if (head_size <= 512) {- if (seq <= 0 && is_pa)+ if (seq <= 0 && is_pa) {return is_prefill ? &xehpg_h512 : &xehpg_h512_pa;+ }if (quantized) {if (thin_q) {- if (seq <= 64)+ if (seq <= 64) {return &xehpg_q_h512_s64_2nd;- if (seq <= 256)+ }+ if (seq <= 256) {return &xehpg_q_h512_s256_2nd;+ }return &xehpg_q_h512_2nd;}- if (seq <= 64)+ if (seq <= 64) {return &xehpg_q_h512_s64;- if (seq <= 128)+ }+ if (seq <= 128) {return &xehpg_q_h512_s128;- if (seq <= 256)+ }+ if (seq <= 256) {return &xehpg_q_h512_s256;+ }return &xehpg_q_h512;}if (thin_q) {@@ -583,59 +619,75 @@ sdpa_config_t* choose_config_xehpg(int head_size, int seq, bool thin_q, bool quasdpa_config_t* choose_config_xehpc(int head_size, int seq, bool thin_q, bool quantized, bool is_integrated, bool is_pa, bool is_prefill) {if (head_size <= 32) {- if (seq <= 0 && is_pa)+ if (seq <= 0 && is_pa) {return is_prefill ? &xehpc_h32 : &xehpc_h32_pa;- if (thin_q)+ }+ if (thin_q) {return &xehpc_h32_2nd;- if (seq <= 32)+ }+ if (seq <= 32) {return &xehpc_h32_s32;+ }return &xehpc_h32;}if (head_size <= 64) {- if (seq <= 0 && is_pa)+ if (seq <= 0 && is_pa) {return is_prefill ? &xehpc_h64 : (thin_q ? &xehpc_h64_pa_2nd : &xehpc_h64_pa);+ }if (thin_q) {if (quantized) {- if (seq <= 96)+ if (seq <= 96) {return &xehpc_q_h64_s96_2nd;- if (seq <= 256)+ }+ if (seq <= 256) {return &xehpc_q_h64_s256_2nd;- if (seq <= 1152)+ }+ if (seq <= 1152) {return &xehpc_q_h64_s1152_2nd;+ }return &xehpc_q_h64_2nd;}- if (seq <= 64)+ if (seq <= 64) {return &xehpc_h64_s64_2nd;+ }return &xehpc_h64_2nd;}if (quantized) {- if (seq <= 64)+ if (seq <= 64) {return &xehpc_q_h64_s64;- if (seq <= 384)+ }+ if (seq <= 384) {return &xehpc_q_h64_s384;- if (seq <= 1024)+ }+ if (seq <= 1024) {return &xehpc_q_h64_s1024;+ }return &xehpc_q_h64;}- if (seq <= 32)+ if (seq <= 32) {return &xehpc_h64_s32;- if (seq <= 64)+ }+ if (seq <= 64) {return &xehpc_h64_s64;+ }return &xehpc_h64;}if (head_size <= 128) {- if (seq <= 0 && is_pa)+ if (seq <= 0 && is_pa) {return is_prefill ? &xehpc_h128 : &xehpc_h128_pa;+ }if (quantized) {if (thin_q) {if (is_integrated) {return &xehpc_q_h128_2nd_integrated;}- if (seq <= 96)+ if (seq <= 96) {return &xehpc_q_h128_s96_2nd;- if (seq <= 512)+ }+ if (seq <= 512) {return &xehpc_q_h128_s512_2nd;+ }return &xehpc_q_h128_2nd;}if (is_integrated) {@@ -643,86 +695,112 @@ sdpa_config_t* choose_config_xehpc(int head_size, int seq, bool thin_q, bool quareturn &xehpc_q_h128_s128_integrated;}}- if (seq <= 32)+ if (seq <= 32) {return &xehpc_q_h128_s32;- if (seq <= 128)+ }+ if (seq <= 128) {return &xehpc_q_h128_s128;+ }return &xehpc_q_h128;}- if (is_integrated)+ if (is_integrated) {return &xehpc_q_h128_2nd_integrated;- if (thin_q)+ }+ if (thin_q) {return &xehpc_h128_2nd;- if (seq <= 32)+ }+ if (seq <= 32) {return &xehpc_h128_s32;- if (seq <= 64)+ }+ if (seq <= 64) {return &xehpc_h128_s64;+ }return &xehpc_h128;}if (head_size <= 256) {- if (seq <= 0 && is_pa)+ if (seq <= 0 && is_pa) {return is_prefill ? &xehpc_h256 : &xehpc_h256_pa;- if (thin_q)+ }+ if (thin_q) {return &xehpc_h256_2nd;- if (seq <= 64)+ }+ if (seq <= 64) {return &xehpc_h256_s64;+ }return &xehpc_h256;}if (head_size <= 512) {- if (seq <= 0 && is_pa)+ if (seq <= 0 && is_pa) {return is_prefill ? &xehpc_h512 : &xehpc_h512_pa;+ }if (thin_q) {if (quantized) {if (is_integrated) {- if (seq <= 64)+ if (seq <= 64) {return &xehpc_q_h512_s64_2nd_integrated;- if (seq <= 128)+ }+ if (seq <= 128) {return &xehpc_q_h512_s128_2nd_integrated;- if (seq <= 256)+ }+ if (seq <= 256) {return &xehpc_q_h512_s256_2nd_integrated;- if (seq <= 512)+ }+ if (seq <= 512) {return &xehpc_q_h512_s512_2nd_integrated;- if (seq <= 1024)+ }+ if (seq <= 1024) {return &xehpc_q_h512_s1024_2nd_integrated;+ }return &xehpc_q_h512_2nd_integrated;}- if (seq <= 512)+ if (seq <= 512) {return &xehpc_q_h512_s512_2nd;- if (seq <= 1024)+ }+ if (seq <= 1024) {return &xehpc_q_h512_s1024_2nd;+ }return &xehpc_q_h512_2nd;}if (is_integrated) {- if (seq <= 256)+ if (seq <= 256) {return &xehpc_h512_s256_2nd_integrated;- if (seq <= 1024)+ }+ if (seq <= 1024) {return &xehpc_h512_s1024_2nd_integrated;+ }return &xehpc_h512_2nd_integrated;}- if (seq <= 128)+ if (seq <= 128) {return &xehpc_h512_s128_2nd;- if (seq <= 512)+ }+ if (seq <= 512) {return &xehpc_h512_s512_2nd;- if (seq <= 1024)+ }+ if (seq <= 1024) {return &xehpc_h512_s1024_2nd;+ }return &xehpc_h512_2nd;}if (quantized) {- if (is_integrated)+ if (is_integrated) {return &xehpc_q_h512_integrated;- if (seq <= 128)+ }+ if (seq <= 128) {return &xehpc_q_h512_s128;+ }return &xehpc_q_h512;}if (is_integrated) {- if (seq <= 128)+ if (seq <= 128) {return &xehpc_h512_s128_integrated;+ }return &xehpc_h512_integrated;}- if (seq <= 64)+ if (seq <= 64) {return &xehpc_h512_s64;+ }return &xehpc_h512;}return nullptr;@@ -736,39 +814,52 @@ sdpa_config_t* choose_config_xe2(int head_size, int seq, bool thin_q, bool quantif (quantized) {if (thin_q) {if (is_integrated) {- if (seq <= 96)+ if (seq <= 96) {return &xe2_q_h64_s96_2nd_integrated;- if (seq <= 384)+ }+ if (seq <= 384) {return &xe2_q_h64_s384_2nd_integrated;+ }return &xe2_q_h64_2nd_integrated;}- if (seq <= 64)+ if (seq <= 64) {return &xe2_q_h64_s64_2nd;- if (seq <= 128)+ }+ if (seq <= 128) {return &xe2_q_h64_s128_2nd;- if (seq <= 384)+ }+ if (seq <= 384) {return &xe2_q_h64_s384_2nd;- if (seq <= 512)+ }+ if (seq <= 512) {return &xe2_q_h64_s512_2nd;- if (seq <= 768)+ }+ if (seq <= 768) {return &xe2_q_h64_s768_2nd;+ }return &xe2_q_h64_2nd;}- if (seq <= 32)+ if (seq <= 32) {return &xe2_q_h64_s32;+ }if (is_integrated) {- if (seq <= 128)+ if (seq <= 128) {return &xe2_q_h64_s128_integrated;+ }}- if (seq <= 128)+ if (seq <= 128) {return &xe2_q_h64_s128;- if (seq <= 384)+ }+ if (seq <= 384) {return &xe2_q_h64_s384;- if (seq <= 512)+ }+ if (seq <= 512) {return &xe2_q_h64_s512;+ }if (is_integrated) {- if (seq <= 1024)+ if (seq <= 1024) {return &xe2_q_h64_s1024_integrated;+ }}return &xe2_q_h64;}@@ -782,28 +873,37 @@ sdpa_config_t* choose_config_xe2(int head_size, int seq, bool thin_q, bool quantif (quantized) {if (is_integrated) {if (thin_q) {- if (seq < 384)+ if (seq < 384) {return &xe2_q_h256_s384_2nd_integrated;- if (seq < 512)+ }+ if (seq < 512) {return &xe2_q_h256_s512_2nd_integrated;- if (seq < 768)+ }+ if (seq < 768) {return &xe2_q_h256_s768_2nd_integrated;- if (seq < 1152)+ }+ if (seq < 1152) {return &xe2_q_h256_s1152_2nd_integrated;+ }return &xe2_q_h256_2nd_integrated;}- if (seq <= 64)+ if (seq <= 64) {return &xe2_q_h256_s64_integrated;- if (seq <= 128)+ }+ if (seq <= 128) {return &xe2_q_h256_s128_integrated;+ }}if (!thin_q) {- if (seq <= 64)+ if (seq <= 64) {return &xe2_q_h256_s64;- if (seq <= 128)+ }+ if (seq <= 128) {return &xe2_q_h256_s128;- if (seq <= 384)+ }+ if (seq <= 384) {return &xe2_q_h256_s384;+ }return &xe2_q_h256;}}@@ -910,11 +1010,13 @@ void SDPAMicroGenerator::init_sdpa_configuration(const kernel_impl_params& impl_const auto has_alibi = impl_param.get_input_layout(11).count() > 0;const auto has_scale_input = !desc->scale_val.has_value();sdpa_config.input_num = 7;- if (has_scale_input)+ if (has_scale_input) {sdpa_config.input_num++;+ }- if (has_alibi)+ if (has_alibi) {sdpa_config.input_num++;+ }}}@@ -1241,8 +1343,9 @@ JitConstants SDPAMicroGenerator::get_jit_constants(const kernel_impl_params& parconstexpr size_t packed_elems_per_uint = sizeof(uint32_t) / sizeof(ov::float16);constexpr size_t max_block_elems = 16; // max 16 elements per block load/store per itemconst auto q_block_elems = (d_max / packed_elems_per_uint) / sg_size;- if (ldq % 4 == 0 && q_block_elems <= max_block_elems)+ if (ldq % 4 == 0 && q_block_elems <= max_block_elems) {jit.make("BLOCK_Q", 1);+ }// TODO: Causes accuracy drop for static SD model. Enable back once the issue is resolved// const auto a_block_elems = static_cast<size_t>(gemm_vs.getSetting("sg_tile_m")) / sg_size;// if (lda % 4 == 0 && v_full && a_block_elems <= max_block_elems)@@ -1258,8 +1361,9 @@ JitConstants SDPAMicroGenerator::get_jit_constants(const kernel_impl_params& parconst bool use_block2d = lda % 16 == 0 && vbytes % 4 == 0 && block2d_compatible;GPU_DEBUG_TRACE_DETAIL << "BLOCK_2D_A check: sg_tile_m=" << sg_tile_m << " sg_size=" << sg_size << " lda=" << lda << " vbytes=" << vbytes<< " block2d_compatible=" << block2d_compatible << " => " << (use_block2d ? "enabled" : "disabled") << std::endl;- if (use_block2d)+ if (use_block2d) {jit.make("BLOCK_2D_A", 1);+ }}if (device_info.arch >= gpu_arch::xe_hpc) {@@ -1353,8 +1457,9 @@ Arguments SDPAMicroGenerator::get_arguments_desc(const kernel_impl_params& paramArguments args;sdpa_configuration config;init_sdpa_configuration(params, config);- if (params.is_dynamic())+ if (params.is_dynamic()) {args.push_back({ArgumentDescriptor::Types::SHAPE_INFO, 0});+ }auto data_inputs_num = micro_get_input_num(params, config);@@ -1380,11 +1485,13 @@ Arguments SDPAMicroGenerator::get_arguments_desc(const kernel_impl_params& paramargs.push_back({ArgumentDescriptor::Types::INPUT, 7}); // block_indicesargs.push_back({ArgumentDescriptor::Types::INPUT, 8}); // block_indices_begins}- if (!config.has_const_scale_val)+ if (!config.has_const_scale_val) {args.push_back({ArgumentDescriptor::Types::INPUT, PagedAttentionInputIdx::SCALE}); // scale+ }- if (desc->has_sink_input)+ if (desc->has_sink_input) {args.push_back({ArgumentDescriptor::Types::INPUT, PagedAttentionInputIdx::SINKS}); // sink+ }if (has_qq_bias && !m_is_prefill) {args.push_back({ArgumentDescriptor::Types::INPUT, PagedAttentionInputIdx::QQ_BIAS}); // qq_bias@@ -1404,14 +1511,17 @@ Arguments SDPAMicroGenerator::get_arguments_desc(const kernel_impl_params& paramargs.push_back({ArgumentDescriptor::Types::OUTPUT, 0}); // Aconst uint32_t attn_mask_idx = ScaledDotProductAttentionInputIdx::ATTN_MASK;- if (sdpa_has_runtime_attn_mask_input(params))+ if (sdpa_has_runtime_attn_mask_input(params)) {args.push_back({ArgumentDescriptor::Types::INPUT, attn_mask_idx}); // mask+ }const uint32_t scale_idx = ScaledDotProductAttentionInputIdx::SCALE;- if (config.input_num > scale_idx && !config.has_const_scale_val)+ if (config.input_num > scale_idx && !config.has_const_scale_val) {args.push_back({ArgumentDescriptor::Types::INPUT, scale_idx}); // Scale+ }const uint32_t sink_idx = ScaledDotProductAttentionInputIdx::SINK;- if (config.input_num > sink_idx)+ if (config.input_num > sink_idx) {args.push_back({ArgumentDescriptor::Types::INPUT, sink_idx}); // Sink+ }args.push_back({ArgumentDescriptor::Types::SCALAR, 0}); // Dargs.push_back({ArgumentDescriptor::Types::SCALAR, 1}); // K@@ -1422,12 +1532,14 @@ Arguments SDPAMicroGenerator::get_arguments_desc(const kernel_impl_params& paramconst bool is_asym_quantization = config.use_asymmetric_quantization;uint32_t input_idx = static_cast<uint32_t>(data_inputs_num);args.push_back({ArgumentDescriptor::Types::INPUT, input_idx + 0}); // K scales- if (is_asym_quantization)+ if (is_asym_quantization) {args.push_back({ArgumentDescriptor::Types::INPUT, input_idx + 2}); // K zp+ }args.push_back({ArgumentDescriptor::Types::INPUT, input_idx + 1}); // V scales- if (is_asym_quantization)+ if (is_asym_quantization) {args.push_back({ArgumentDescriptor::Types::INPUT, input_idx + 3}); // V zp+ }}return args;@@ -1454,8 +1566,9 @@ DispatchDataFunc SDPAMicroGenerator::get_dispatch_data_func() const {if (params.is_type<paged_attention>()) {auto* pa_rt_params = static_cast<PagedAttentionRuntimeParams*>(rt_params);- if (pa_rt_params->stage == PagedAttentionStage::GENERATE)+ if (pa_rt_params->stage == PagedAttentionStage::GENERATE) {head_num = micro_get_num_heads(params, 1);+ }}auto wg_tile_q = gemm_kq.getSetting("wg_tile_n");@@ -1542,8 +1655,9 @@ void SDPAMicroGenerator::init_microkernels(const kernel_impl_params& params,/* Retrieve pre-tuned kernel configuration */sdpa_config_t* config = nullptr;bool thin_q = (!n_queries.is_dynamic() && n_queries.get_length() <= 16) || !is_prefill;- if (is_paged_attention && !is_prefill)+ if (is_paged_attention && !is_prefill) {thin_q = is_gqa_single_token;+ }bool is_integrated = device_info.dev_type == device_type::integrated_gpu;bool is_quantized =diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_micro.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_micro.hppindex ed429dcbab2..16b449f96e4 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_micro.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_micro.hpp@@ -30,8 +30,9 @@ public:false),m_is_prefill(prefill),m_is_gqa_single_token(gqa_single_token) {- if (gqa_single_token)+ if (gqa_single_token) {OPENVINO_ASSERT(prefill == false, "prefill should be false when gqa_single_token is true");+ }}[[nodiscard]] std::string get_build_options(const kernel_impl_params& params) const override;diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_opt.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_opt.cppindex 0527de614f7..946fce8193f 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_opt.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_opt.cpp@@ -161,10 +161,12 @@ Arguments SDPAOptGeneratorBase::get_arguments_desc_impl(const kernel_impl_paramsconst size_t scale_idx = ScaledDotProductAttentionInputIdx::SCALE;const bool has_attn_mask_input = sdpa_has_runtime_attn_mask_input(params);for (uint32_t i = 0; i < data_inputs_num; i++) {- if (i == attn_mask_idx && !has_attn_mask_input)+ if (i == attn_mask_idx && !has_attn_mask_input) {continue;- if (i == scale_idx && desc->scale_val.has_value())+ }+ if (i == scale_idx && desc->scale_val.has_value()) {continue;+ }args.push_back({ArgumentDescriptor::Types::INPUT, i});}args.push_back({ArgumentDescriptor::Types::OUTPUT, 0});diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_opt.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_opt.hppindex c95e708559a..be3f10001af 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_opt.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_opt.hpp@@ -66,8 +66,9 @@ struct SDPAOpt : public ImplementationManager {if (desc->has_sink_input) {auto sink_layout = node.get_input_layout(ScaledDotProductAttentionInputIdx::SINK);auto q_heads_num = q_layout.get_partial_shape()[1].get_length();- if (sink_layout.count() != static_cast<size_t>(q_heads_num))+ if (sink_layout.count() != static_cast<size_t>(q_heads_num)) {OPENVINO_THROW("Currently only supporting per-head sink.Sink_layout : ", sink_layout.to_short_string(), " heads_num :", q_heads_num);+ }}const bool use_asymmetric_quantization =diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_ref.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_ref.hppindex 98e2315f569..7687afd3e74 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_ref.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_ref.hpp@@ -34,11 +34,13 @@ struct SDPARef : public ImplementationManager {const auto& k_layout = node.get_input_layout(1);const auto& v_layout = node.get_input_layout(2);const auto& out_layout = node.get_output_layout(0);- if (!everyone_is(format::bfyx, q_layout.format, k_layout.format, v_layout.format, out_layout.format))+ if (!everyone_is(format::bfyx, q_layout.format, k_layout.format, v_layout.format, out_layout.format)) {return false;+ }- if (!one_of(k_layout.data_type, supported_kv_types) || !one_of(v_layout.data_type, supported_kv_types))+ if (!one_of(k_layout.data_type, supported_kv_types) || !one_of(v_layout.data_type, supported_kv_types)) {return false;+ }return one_of(q_layout.data_type, supported_q_types) && one_of(out_layout.data_type, supported_q_types);}diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_utils.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_utils.hppindex 3c0f4596538..4e11c0608ec 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_utils.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_utils.hpp@@ -64,8 +64,9 @@ inline size_t get_key_cache_id(const cldnn::scaled_dot_product_attention& desc)return -1;}- if (desc.indirect_axis != -1)+ if (desc.indirect_axis != -1) {key_cache_id -= 1; // beam_table+ }if (desc.get_compression_zp_inputs_num() > 0) {key_cache_id -= 4;} else {@@ -82,8 +83,9 @@ inline size_t get_value_cache_id(const cldnn::scaled_dot_product_attention& descreturn -1;}- if (desc.indirect_axis != -1)+ if (desc.indirect_axis != -1) {value_cache_id -= 1; // beam_table+ }if (desc.get_compression_zp_inputs_num() > 0) {value_cache_id -= 3; // Scales and zp} else {@@ -114,8 +116,9 @@ inline std::vector<int64_t> extend_order_in_num_heads_dim(const std::vector<int6inline int64_t get_batch_size(const cldnn::layout& qkv, const std::vector<int64_t>& order) {const auto& dim = qkv.get_partial_shape()[order[0]];- if (dim.is_dynamic())+ if (dim.is_dynamic()) {return -1;+ }return dim.get_length();}@@ -127,16 +130,18 @@ inline int64_t get_num_heads(const cldnn::layout& qkv, const std::vector<int64_treturn 1;}const auto& dim = qkv.get_partial_shape()[order[order_rank - 3]];- if (dim.is_dynamic())+ if (dim.is_dynamic()) {return -1;+ }return dim.get_length();}inline int64_t get_head_size(const cldnn::layout& qkv, const std::vector<int64_t>& order) {const auto order_rank = order.size();const auto& dim = qkv.get_partial_shape()[order[order_rank - 1]];- if (dim.is_dynamic())+ if (dim.is_dynamic()) {return -1;+ }return dim.get_length();}diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/slice_scatter.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/slice_scatter.cppindex a3e3c85b813..733f4081bcf 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/slice_scatter.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/slice_scatter.cpp@@ -106,8 +106,9 @@ ParamConfig getParamConfig(const program_node& node, const RuntimeParams& paramsif (deps.size() > kAxes && deps[kAxes].first->is_constant()) {config.compile_time_axes = extractIntegerData(deps[kAxes].first->as<data>(), strm);for (auto& axis : config.compile_time_axes) {- if (axis < 0)+ if (axis < 0) {axis += static_cast<int64_t>(config.input_rank);+ }}} else if (deps.size() <= kAxes) {config.compile_time_axes.resize(config.input_rank);@@ -334,11 +335,13 @@ public:private:bool canCompileOpt() const {// Opt kernel requires all steps to be compile-time 1- if (m_config.compile_time_step.empty())+ if (m_config.compile_time_step.empty()) {return false;+ }for (auto s : m_config.compile_time_step) {- if (s != 1)+ if (s != 1) {return false;+ }}return true;}diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/slice_scatter.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/slice_scatter.hppindex d8518e63479..e696c8310bd 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/slice_scatter.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/slice_scatter.hpp@@ -34,14 +34,17 @@ struct SliceScatter : public ImplementationManager {const auto& in0_layout = node.get_input_layout(0);const auto& out_layout = node.get_output_layout(0);- if (!one_of(in0_layout.data_type, supported_types) || !one_of(out_layout.data_type, supported_types))+ if (!one_of(in0_layout.data_type, supported_types) || !one_of(out_layout.data_type, supported_types)) {return false;+ }- if (!one_of(in0_layout.format, supported_fmts) || !one_of(out_layout.format, supported_fmts))+ if (!one_of(in0_layout.format, supported_fmts) || !one_of(out_layout.format, supported_fmts)) {return false;+ }- if (out_layout.get_rank() > 5)+ if (out_layout.get_rank() > 5) {return false;+ }return !node.has_fused_primitives();}diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/utils/fused_ops_jitter.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/utils/fused_ops_jitter.cppindex f72648c717b..0161ccbe733 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/utils/fused_ops_jitter.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/utils/fused_ops_jitter.cpp@@ -264,8 +264,9 @@ JitConstants FusedOpsCodeGenerator::make_load_jit_constants(const FusedOpsConfigif (desc.is_type<eltwise>() && conf.load_type == FusedOpsConfiguration::LoadType::FEATURE_SHUFFLE) {std::string sub_group_local_id_str = "get_sub_group_local_id()";size_t found_sub = conf.bfzyx_idx_order[1].rfind(sub_group_local_id_str);- if (found_sub != std::string::npos)+ if (found_sub != std::string::npos) {fused_op_config.bfzyx_idx_order[1].replace(found_sub, sub_group_local_id_str.length(), fused_op_config.shuffle_var_name);+ }}for (auto op_input_id : get_required_inputs()) {diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/utils/kernel_generator.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/utils/kernel_generator.cppindex d2b0c38ec8e..42173d71d31 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/utils/kernel_generator.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/utils/kernel_generator.cpp@@ -124,14 +124,16 @@ std::string KernelGenerator::get_build_options(const RuntimeParams& params) consif (device_info.vendor_id == cldnn::INTEL_VENDOR_ID) {options = " -cl-mad-enable";- if (prog.get_config().get_enable_large_allocations())+ if (prog.get_config().get_enable_large_allocations()) {options += " -cl-intel-greater-than-4GB-buffer-required";+ }}- if (device_info.supports_work_group_collective_functions)+ if (device_info.supports_work_group_collective_functions) {options += " -cl-std=CL3.0";- else+ } else {options += " -cl-std=CL2.0";+ }return options;}diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/concatenation_onednn.cpp b/src/plugins/intel_gpu/src/graph/impls/onednn/concatenation_onednn.cppindex dcb9020d555..4f793311ba3 100644--- a/src/plugins/intel_gpu/src/graph/impls/onednn/concatenation_onednn.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/concatenation_onednn.cpp@@ -3,13 +3,13 @@//#include "concatenation_onednn.hpp"-#include "concatenation_inst.h"-#include "primitive_onednn_base.h"-#include "registry/implementation_manager.hpp"+#include <memory>#include <oneapi/dnnl/dnnl.hpp>-#include <memory>+#include "concatenation_inst.h"+#include "primitive_onednn_base.h"+#include "registry/implementation_manager.hpp"namespace cldnn {namespace onednn {@@ -54,9 +54,9 @@ protected:}static std::shared_ptr<dnnl::concat::primitive_desc> get_concatenation_primitive_descriptor(const kernel_impl_params& impl_params,- cldnn::engine& engine,- const dnnl::primitive_attr& attr,- const int64_t axis) {+ cldnn::engine& engine,+ const dnnl::primitive_attr& attr,+ const int64_t axis) {std::vector<dnnl::memory::desc> input_mds;for (size_t i = 0; i < impl_params.input_layouts.size(); i++) {auto input_layout = impl_params.get_input_layout(i);@@ -67,12 +67,7 @@ protected:auto output_layout = impl_params.get_output_layout();output_md = onednn::layout_to_memory_desc(output_layout, false, output_layout.format.is_blocked());- return std::make_shared<dnnl::concat::primitive_desc>(- engine.get_onednn_engine(),- output_md,- static_cast<int>(axis),- input_mds,- attr);+ return std::make_shared<dnnl::concat::primitive_desc>(engine.get_onednn_engine(), output_md, static_cast<int>(axis), input_mds, attr);}public:@@ -128,8 +123,9 @@ public:static std::unique_ptr<primitive_impl> create(const concatenation_node& arg, const kernel_impl_params& impl_params) {auto& engine = impl_params.prog->get_engine();const auto& config = impl_params.prog->get_config();- if (impl_params.can_be_optimized())+ if (impl_params.can_be_optimized()) {return std::make_unique<concatenation_onednn>(engine, config);+ }auto prim = impl_params.typed_desc<concatenation>();auto attr = impl_params.attrs_onednn;auto prim_desc = get_concatenation_primitive_descriptor(impl_params, impl_params.prog->get_engine(), *attr, prim->axis);diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/concatenation_onednn.hpp b/src/plugins/intel_gpu/src/graph/impls/onednn/concatenation_onednn.hppindex d22a747f6fb..a7fa82069fb 100644--- a/src/plugins/intel_gpu/src/graph/impls/onednn/concatenation_onednn.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/concatenation_onednn.hpp@@ -20,8 +20,9 @@ struct ConcatenationImplementationManager : public ImplementationManager {assert(node.is_type<concatenation>());const auto& config = node.get_program().get_config();const auto& info = node.get_program().get_engine().get_device_info();- if (!info.supports_immad || info.arch == gpu_arch::unknown || !config.get_use_onednn())+ if (!info.supports_immad || info.arch == gpu_arch::unknown || !config.get_use_onednn()) {return false;+ }// oneDNN classifies DNNL_ARG_MULTIPLE_SRC + i as an attribute argument once i sets the// DNNL_ARG_ATTR_PRECOMPUTED_REDUCTIONS bit, so a concat with more sources than that bit's@@ -58,32 +59,38 @@ struct ConcatenationImplementationManager : public ImplementationManager {const auto& out_layout = node.get_output_layout();- if (!one_of(out_layout.data_type, supported_types))+ if (!one_of(out_layout.data_type, supported_types)) {return false;+ }- if (out_layout.data_padding)+ if (out_layout.data_padding) {return false;+ }auto is_feature_aligned = [](const layout& l) {- if (!format::is_blocked(l.format))+ if (!format::is_blocked(l.format)) {return true;+ }const auto& order = format::internal_order(l.format);const size_t feature_dim_idx = order.find('f');- if (feature_dim_idx == std::string::npos)+ if (feature_dim_idx == std::string::npos) {return true;+ }auto feature_dim = l.get_partial_shape()[feature_dim_idx];- if (feature_dim.is_dynamic())+ if (feature_dim.is_dynamic()) {return false;+ }const auto& block_sizes = format::block_sizes(l.format);auto block_it = std::find_if(block_sizes.begin(), block_sizes.end(), [&](const auto& block) {return block.first == feature_dim_idx;});- if (block_it == block_sizes.end())+ if (block_it == block_sizes.end()) {return true;+ }const int feature_block_size = block_it->second;return feature_dim.get_length() % feature_block_size == 0;@@ -98,17 +105,21 @@ struct ConcatenationImplementationManager : public ImplementationManager {for (const auto& dep : node.get_dependencies()) {const auto& in_layout = dep.first->get_output_layout(false, dep.second);- if (!one_of(in_layout.data_type, supported_types))+ if (!one_of(in_layout.data_type, supported_types)) {return false;+ }- if (!is_supported_pad(in_layout))+ if (!is_supported_pad(in_layout)) {return false;+ }- if (!one_of(in_layout.format.value, supported_in_fmts))+ if (!one_of(in_layout.format.value, supported_in_fmts)) {return false;+ }- if (!is_feature_aligned(in_layout))+ if (!is_feature_aligned(in_layout)) {return false;+ }}return true;diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/convolution_onednn.cpp b/src/plugins/intel_gpu/src/graph/impls/onednn/convolution_onednn.cppindex e59b4e7d67a..bc0bca3b26e 100644--- a/src/plugins/intel_gpu/src/graph/impls/onednn/convolution_onednn.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/convolution_onednn.cpp@@ -344,8 +344,9 @@ public:if (prim->activations_zero_points.is_valid()) {auto& a_zp = impl_params->get_program().get_node_ptr(prim->id)->as<convolution>().activations_zero_points().as<data>();memory::ptr s32_mem = onednn::convert_zp_data_to_s32(a_zp.get_attached_memory_ptr());- if (s32_mem != nullptr)+ if (s32_mem != nullptr) {a_zp.attach_memory(s32_mem, false);+ }}bool has_wzp = prim->weights_zero_points.is_valid();if (has_wzp) {@@ -416,8 +417,9 @@ in_out_fmts_t ConvolutionImplementationManager::query_formats(const program_nodeauto prim_desc = get_convolution_primitive_descriptor(*node.get_kernel_impl_params(), dnnl::primitive_attr(), dnnl::memory::format_tag::any);for (size_t idx = 0 ; idx < node.get_dependencies().size() ; idx++) {- if (node.get_dependency(idx).is_constant())+ if (node.get_dependency(idx).is_constant()) {continue;+ }// Conv or deconv gets a preferred format for its data input based on source memory description// But an input format for fused post-ops should be same with an output format of conv/deconv@@ -435,8 +437,9 @@ in_out_fmts_t ConvolutionImplementationManager::query_formats(const program_node}// WA: Avoid b_fs_yx_fsv2 because Onednn tag aBcd2b is not declared.- if (src_fmt == format::b_fs_yx_fsv2)+ if (src_fmt == format::b_fs_yx_fsv2) {src_fmt = format::byxf;+ }// WA: shallow convolution needs to set input format by bfyx.// onednn recommended byxf for input format. It will insert reorder before shallow conv.@@ -475,8 +478,9 @@ in_out_fmts_t ConvolutionImplementationManager::query_formats(const program_node}// WA: Avoid b_fs_yx_fsv2 because Onednn tag aBcd2b is not declared.- if (out_fmts[0] == format::b_fs_yx_fsv2)+ if (out_fmts[0] == format::b_fs_yx_fsv2) {out_fmts[0] = format::byxf;+ }// Errata: Best impl for shallow input conv with zero-point ops is ocl:xe_lp.if (in_fmts[0] == format::bfyx) {diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/convolution_onednn.hpp b/src/plugins/intel_gpu/src/graph/impls/onednn/convolution_onednn.hppindex 1ba311b58fa..2185c17afc1 100644--- a/src/plugins/intel_gpu/src/graph/impls/onednn/convolution_onednn.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/convolution_onednn.hpp@@ -25,8 +25,9 @@ struct ConvolutionImplementationManager : public ImplementationManager {assert(node.is_type<convolution>());const auto& config = node.get_program().get_config();const auto& info = node.get_program().get_engine().get_device_info();- if (!info.supports_immad || info.arch == gpu_arch::unknown || !config.get_use_onednn())+ if (!info.supports_immad || info.arch == gpu_arch::unknown || !config.get_use_onednn()) {return false;+ }const auto& conv_node = node.as<convolution>();@@ -76,15 +77,18 @@ struct ConvolutionImplementationManager : public ImplementationManager {format::bs_fs_zyx_bsv32_fsv32,};- if (!one_of(in_fmt, supported_formats) || !one_of(out_fmt, supported_formats))+ if (!one_of(in_fmt, supported_formats) || !one_of(out_fmt, supported_formats)) {return false;+ }auto prim = conv_node.get_primitive();- if (prim->groups > 1 && !prim->grouped_weights_shape)+ if (prim->groups > 1 && !prim->grouped_weights_shape) {return false;+ }- if (!is_supported_pad(in_layout) || !is_supported_pad(out_layout))+ if (!is_supported_pad(in_layout) || !is_supported_pad(out_layout)) {return false;+ }bool f16_conv = everyone_is(data_types::f16, in_dt, wei_dt) && one_of(out_dt, {data_types::f16, data_types::bf16, data_types::f32, data_types::u8, data_types::i8});bool bf16_conv = everyone_is(data_types::bf16, in_dt, wei_dt) &&@@ -92,14 +96,17 @@ struct ConvolutionImplementationManager : public ImplementationManager {bool int8_conv = one_of(in_dt, {data_types::i8, data_types::u8}) && one_of(wei_dt, {data_types::i8, data_types::u8}) &&one_of(out_dt, {data_types::i32, data_types::f16, data_types::bf16, data_types::f32, data_types::u8, data_types::i8});- if (!f16_conv && !bf16_conv && !int8_conv)+ if (!f16_conv && !bf16_conv && !int8_conv) {return false;+ }- if (!is_supported_post_ops(conv_node))+ if (!is_supported_post_ops(conv_node)) {return false;+ }- if (prim->deformable_mode)+ if (prim->deformable_mode) {return false;+ }// oneDNN only supports asymmetric weights quantization by scalar zero-pointsreturn !conv_node.weights_zero_points_term() ||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.cppindex 5e4ce93dc8e..fcdf74c724d 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@@ -235,8 +235,9 @@ in_out_fmts_t DeconvolutionImplementationManager::query_formats(const program_noauto prim_desc = onednn::get_deconvolution_primitive_descriptor(*node.get_kernel_impl_params(), dnnl::primitive_attr(), dnnl::memory::format_tag::any);for (size_t idx = 0 ; idx < node.get_dependencies().size() ; idx++) {- if (node.get_dependency(idx).is_constant())+ if (node.get_dependency(idx).is_constant()) {continue;+ }// Conv or deconv gets a preferred format for its data input based on source memory description// But an input format for fused post-ops should be same with an output format of conv/deconv@@ -254,8 +255,9 @@ in_out_fmts_t DeconvolutionImplementationManager::query_formats(const program_no}// WA: Avoid b_fs_yx_fsv2 because Onednn tag aBcd2b is not declared.- if (src_fmt == format::b_fs_yx_fsv2)+ if (src_fmt == format::b_fs_yx_fsv2) {src_fmt = format::byxf;+ }in_fmts[idx] = src_fmt;}@@ -263,8 +265,9 @@ in_out_fmts_t DeconvolutionImplementationManager::query_formats(const program_noout_fmts[0] = onednn::find_data_format(prim_desc->dst_desc());// WA: Avoid b_fs_yx_fsv2 because Onednn tag aBcd2b is not declared.- if (out_fmts[0] == format::b_fs_yx_fsv2)+ if (out_fmts[0] == format::b_fs_yx_fsv2) {out_fmts[0] = format::byxf;+ }return {in_fmts, out_fmts};}diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/deconvolution_onednn.hpp b/src/plugins/intel_gpu/src/graph/impls/onednn/deconvolution_onednn.hppindex 07869f62da5..f7f933b49ae 100644--- a/src/plugins/intel_gpu/src/graph/impls/onednn/deconvolution_onednn.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/deconvolution_onednn.hpp@@ -21,8 +21,9 @@ struct DeconvolutionImplementationManager : public ImplementationManager {assert(node.is_type<deconvolution>());const auto& config = node.get_program().get_config();const auto& info = node.get_program().get_engine().get_device_info();- if (!info.supports_immad || info.arch == gpu_arch::unknown || !config.get_use_onednn())+ if (!info.supports_immad || info.arch == gpu_arch::unknown || !config.get_use_onednn()) {return false;+ }const auto& deconv_node = node.as<deconvolution>();static const std::vector<format::type> supported_formats = {@@ -70,21 +71,25 @@ struct DeconvolutionImplementationManager : public ImplementationManager {auto wei_dt = deconv_node.weights().get_output_layout(false).data_type;auto out_dt = output_layout.data_type;- if (!is_supported_pad(input_layout) || !is_supported_pad(output_layout))+ if (!is_supported_pad(input_layout) || !is_supported_pad(output_layout)) {return false;+ }- if (!one_of(in_fmt.value, supported_formats) || !one_of(out_fmt.value, supported_formats))+ if (!one_of(in_fmt.value, supported_formats) || !one_of(out_fmt.value, supported_formats)) {return false;+ }const auto& prim = deconv_node.get_primitive();- if (prim->groups != 1)+ if (prim->groups != 1) {return false;+ }auto spatial_dims_num = input_layout.get_partial_shape().size() - 2;- if (spatial_dims_num > 3)+ if (spatial_dims_num > 3) {return false;+ }bool f16_deconv = everyone_is(data_types::f16, in_dt, wei_dt) && one_of(out_dt, {data_types::f16, data_types::bf16, data_types::u8, data_types::i8});bool bf16_deconv = everyone_is(data_types::bf16, in_dt, wei_dt) &&@@ -94,8 +99,9 @@ struct DeconvolutionImplementationManager : public ImplementationManager {wei_dt == data_types::i8 &&one_of(out_dt, {data_types::i32, data_types::f16, data_types::bf16, data_types::f32, data_types::u8, data_types::i8});- if (!f16_deconv && !bf16_deconv && !f32_deconv && !u8s8_deconv)+ if (!f16_deconv && !bf16_deconv && !f32_deconv && !u8s8_deconv) {return false;+ }return is_supported_post_ops(deconv_node);}diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/fully_connected_onednn.hpp b/src/plugins/intel_gpu/src/graph/impls/onednn/fully_connected_onednn.hppindex f4df9ef1be7..4c21cd4e55c 100644--- a/src/plugins/intel_gpu/src/graph/impls/onednn/fully_connected_onednn.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/fully_connected_onednn.hpp@@ -28,8 +28,9 @@ struct FullyConnectedImplementationManager : public ImplementationManager {assert(node.is_type<fully_connected>());const auto& config = node.get_program().get_config();const auto& info = node.get_program().get_engine().get_device_info();- if (!info.supports_immad || info.arch == gpu_arch::unknown || !config.get_use_onednn())+ if (!info.supports_immad || info.arch == gpu_arch::unknown || !config.get_use_onednn()) {LOG_AND_RETURN_FALSE(node);+ }const auto& fc_node = node.as<fully_connected>();const auto& in_layout = fc_node.get_input_layout(0);@@ -39,17 +40,20 @@ struct FullyConnectedImplementationManager : public ImplementationManager {auto out_dt = out_layout.data_type;auto fc_prim = fc_node.get_primitive();- if (one_of(data_types::i64, {in0_dt, wei_dt}))+ if (one_of(data_types::i64, {in0_dt, wei_dt})) {LOG_AND_RETURN_FALSE(node);+ }if (!everyone_is(format::bfyx, in_layout.format, out_layout.format) &&!everyone_is(format::bfzyx, in_layout.format, out_layout.format) &&!everyone_is(format::bfwzyx, in_layout.format, out_layout.format) &&- !everyone_is(format::any, in_layout.format, out_layout.format))+ !everyone_is(format::any, in_layout.format, out_layout.format)) {LOG_AND_RETURN_FALSE(node);+ }- if (!is_supported_pad(in_layout) || !is_supported_pad(out_layout))+ if (!is_supported_pad(in_layout) || !is_supported_pad(out_layout)) {LOG_AND_RETURN_FALSE(node);+ }bool f16f16_case = everyone_is(data_types::f16, in0_dt, wei_dt) && one_of(out_dt, {data_types::f16, data_types::f32, data_types::i8});bool bf16bf16_case = everyone_is(data_types::bf16, in0_dt, wei_dt) &&@@ -64,8 +68,9 @@ struct FullyConnectedImplementationManager : public ImplementationManager {one_of(out_dt, {data_types::f16, data_types::bf16, data_types::f32, data_types::u8, data_types::i8});const bool fp_compressed_case = fc_prim->compressed_weights && one_of(in0_dt, {data_types::f8e4m3, data_types::f4e2m1, data_types::f8e5m2}) &&one_of(wei_dt, {data_types::f8e4m3, data_types::f4e2m1, data_types::f8e5m2}) && one_of(out_dt, {data_types::f16, data_types::f32});- if (!f16f16_case && !bf16bf16_case && !f32f32_case && !u8s8_case && !compressed_case && !fp_compressed_case)+ if (!f16f16_case && !bf16bf16_case && !f32f32_case && !u8s8_case && !compressed_case && !fp_compressed_case) {LOG_AND_RETURN_FALSE(node);+ }if (fc_prim->compressed_weights) {if (fc_prim->decompression_zero_point.is_valid()) {@@ -102,8 +107,9 @@ struct FullyConnectedImplementationManager : public ImplementationManager {size_t out_rank = node.get_output_layout().get_rank();for (size_t idx = 0 ; idx < node.get_dependencies().size() ; idx++) {- if (node.get_dependency(idx).is_constant())+ if (node.get_dependency(idx).is_constant()) {continue;+ }auto target_format = format::get_default_format(out_rank);diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/gated_mlp_onednn.hpp b/src/plugins/intel_gpu/src/graph/impls/onednn/gated_mlp_onednn.hppindex 747c84e9ea4..ef13564ded7 100644--- a/src/plugins/intel_gpu/src/graph/impls/onednn/gated_mlp_onednn.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/gated_mlp_onednn.hpp@@ -25,13 +25,15 @@ struct GatedMLPImplementationManager : public ImplementationManager {std::unique_ptr<primitive_impl> create_impl(const program_node& node, const kernel_impl_params& params) const override;bool validate_impl(const program_node& node) const override {- if (!node.is_type<gated_mlp>())+ if (!node.is_type<gated_mlp>()) {return false;+ }const auto& config = node.get_program().get_config();const auto& info = node.get_program().get_engine().get_device_info();- if (!config.get_use_onednn() || !info.supports_immad)+ if (!config.get_use_onednn() || !info.supports_immad) {LOG_AND_RETURN_FALSE_GATED(node);+ }const auto& gm_node = node.as<gated_mlp>();const auto& src_layout = gm_node.get_input_layout(0);@@ -40,14 +42,17 @@ struct GatedMLPImplementationManager : public ImplementationManager {const auto src_rank = src_layout.get_partial_shape().rank();const auto out_rank = out_layout.get_partial_shape().rank();if ((src_rank.is_static() && src_rank.get_length() < 2) ||- (out_rank.is_static() && out_rank.get_length() < 2))+ (out_rank.is_static() && out_rank.get_length() < 2)) {LOG_AND_RETURN_FALSE_GATED(node);+ }- if (!is_supported_pad(src_layout) || !is_supported_pad(out_layout))+ if (!is_supported_pad(src_layout) || !is_supported_pad(out_layout)) {LOG_AND_RETURN_FALSE_GATED(node);+ }- if (src_layout.data_type != data_types::f16 && src_layout.data_type != data_types::bf16 && src_layout.data_type != data_types::f32)+ if (src_layout.data_type != data_types::f16 && src_layout.data_type != data_types::bf16 && src_layout.data_type != data_types::f32) {LOG_AND_RETURN_FALSE_GATED(node);+ }return true;}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 81900159c76..60700dbeaf9 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@@ -50,8 +50,9 @@ protected:}void set_arguments_impl(gemm_inst& instance) override {- if (instance.can_be_optimized())+ if (instance.can_be_optimized()) {return;+ }if (instance.get_input_layout(0).count() == 0 ||instance.get_input_layout(1).count() == 0) {@@ -128,8 +129,9 @@ protected:if (in1_l.data_padding) {in1_strides = onednn::get_strides(in1_l.get_padded_dims());- if (prim->transpose_input1)+ if (prim->transpose_input1) {std::swap(in1_strides[in1_strides.size() - 1], in1_strides[in1_strides.size() - 2]);+ }}// Check whether transpose_order increase sequential or not.@@ -152,8 +154,9 @@ protected:}}size_t last_idx = transpose_order.size() - 1;- if (static_cast<size_t>(transpose_order[last_idx]) != last_idx - 1)+ if (static_cast<size_t>(transpose_order[last_idx]) != last_idx - 1) {return false;+ }return static_cast<size_t>(transpose_order[last_idx - 1]) == last_idx;};@@ -164,10 +167,12 @@ protected:std::vector<size_t> order(std::begin(transpose_order), std::end(transpose_order));if (dims.size() > order.size()) {size_t orders_to_add = dims.size() - order.size();- for (size_t i = 0; i < orders_to_add; ++i)+ for (size_t i = 0; i < orders_to_add; ++i) {order.insert(order.begin(), i);- for (size_t i = orders_to_add; i < order.size(); ++i)+ }+ for (size_t i = orders_to_add; i < order.size(); ++i) {order[i] = order[i] + orders_to_add;+ }}bool ret = false;diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/gemm_onednn.hpp b/src/plugins/intel_gpu/src/graph/impls/onednn/gemm_onednn.hppindex e9c7119393d..8a451f8b73d 100644--- a/src/plugins/intel_gpu/src/graph/impls/onednn/gemm_onednn.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/gemm_onednn.hpp@@ -22,8 +22,9 @@ struct GemmImplementationManager : public ImplementationManager {assert(node.is_type<gemm>());const auto& config = node.get_program().get_config();const auto& info = node.get_program().get_engine().get_device_info();- if (!info.supports_immad || info.arch == gpu_arch::unknown || !config.get_use_onednn())+ if (!info.supports_immad || info.arch == gpu_arch::unknown || !config.get_use_onednn()) {return false;+ }const auto& gemm_node = node.as<gemm>();const auto& gemm_prim = gemm_node.get_primitive();@@ -50,19 +51,23 @@ struct GemmImplementationManager : public ImplementationManager {format::bfwzyx,};- if (gemm_prim->alpha != 1.0f || gemm_prim->beta != 0.0f)+ if (gemm_prim->alpha != 1.0f || gemm_prim->beta != 0.0f) {return false;+ }- if (out_layout.data_padding)+ if (out_layout.data_padding) {return false;+ }- if (one_of(in0_dt, {data_types::f32, data_types::i64}) || one_of(in1_dt, {data_types::f32, data_types::i64}))+ if (one_of(in0_dt, {data_types::f32, data_types::i64}) || one_of(in1_dt, {data_types::f32, data_types::i64})) {return false;+ }if (!one_of(in0_layout.format.value, supported_formats) ||!one_of(in1_layout.format.value, supported_formats) ||- !one_of(out_layout.format.value, supported_formats))+ !one_of(out_layout.format.value, supported_formats)) {return false;+ }//format bxfy not on whitelist for fusable_output_order_onednn in gemm_inst.h what makes assert error later//skipped onednn implementation as ocl is faster@@ -78,11 +83,13 @@ struct GemmImplementationManager : public ImplementationManager {one_of(in1_dt, {data_types::i8, data_types::u8}) &&one_of(out_dt, {data_types::f16, data_types::bf16, data_types::f32, data_types::i32, data_types::i8, data_types::u8});- if (!f16f16_case && !bf16bf16_case && !u8s8_case)+ if (!f16f16_case && !bf16bf16_case && !u8s8_case) {return false;+ }- if (gemm_prim->indirect_a || gemm_prim->indirect_b)+ if (gemm_prim->indirect_a || gemm_prim->indirect_b) {return false;+ }return is_supported_post_ops(node);}@@ -93,8 +100,9 @@ struct GemmImplementationManager : public ImplementationManager {std::vector<format::type> out_fmts(node.get_outputs_count(), format::any);for (size_t idx = 0 ; idx < node.get_dependencies().size() ; idx++) {- if (node.get_dependency(idx).is_constant())+ if (node.get_dependency(idx).is_constant()) {continue;+ }size_t out_rank = node.get_output_layout().get_rank();auto target_format = format::get_default_format(out_rank);diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/grouped_gemm_onednn.hpp b/src/plugins/intel_gpu/src/graph/impls/onednn/grouped_gemm_onednn.hppindex 707740bdecc..6582e8f5baa 100644--- a/src/plugins/intel_gpu/src/graph/impls/onednn/grouped_gemm_onednn.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/grouped_gemm_onednn.hpp@@ -26,8 +26,9 @@ struct GroupedMatmulImplementationManager : public ImplementationManager {OPENVINO_ASSERT(node.is_type<grouped_matmul>());const auto& config = node.get_program().get_config();const auto& info = node.get_program().get_engine().get_device_info();- if (!info.supports_immad || info.arch == gpu_arch::unknown || !config.get_use_onednn())+ if (!info.supports_immad || info.arch == gpu_arch::unknown || !config.get_use_onednn()) {return false;+ }static const std::vector<format> supported_fmts = {format::bfyx,@@ -56,20 +57,25 @@ struct GroupedMatmulImplementationManager : public ImplementationManager {const auto* desc = node.as<grouped_matmul>().get_primitive().get();const bool compressed = (desc != nullptr) && desc->compressed_weights;- if (!one_of(in0.format, supported_fmts) || !one_of(in0.data_type, supported_activation_types))+ if (!one_of(in0.format, supported_fmts) || !one_of(in0.data_type, supported_activation_types)) {return false;- if (!one_of(in1.format, supported_fmts))+ }+ if (!one_of(in1.format, supported_fmts)) {return false;+ }if (compressed) {- if (!one_of(in1.data_type, supported_compressed_weight_types))+ if (!one_of(in1.data_type, supported_compressed_weight_types)) {return false;+ }} else if (!one_of(in1.data_type, supported_activation_types)) {return false;}- if (!one_of(off.format, supported_fmts) || !one_of(off.data_type, supported_offset_types))+ if (!one_of(off.format, supported_fmts) || !one_of(off.data_type, supported_offset_types)) {return false;- if (!one_of(out.format, supported_fmts) || !one_of(out.data_type, supported_activation_types))+ }+ if (!one_of(out.format, supported_fmts) || !one_of(out.data_type, supported_activation_types)) {return false;+ }// oneDNN does not support mixed fp16 x bf16 configurationsreturn compressed ||diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/grouped_matmul_helper.hpp b/src/plugins/intel_gpu/src/graph/impls/onednn/grouped_matmul_helper.hppindex d8b2215bcd3..bb0e4965311 100644--- a/src/plugins/intel_gpu/src/graph/impls/onednn/grouped_matmul_helper.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/grouped_matmul_helper.hpp@@ -53,8 +53,9 @@ struct onednn_matmul {}if (ic_group_size >= 0) {w_scale(ic_group_size);- if (has_zp)+ if (has_zp) {w_zp(ic_group_size);+ }fpmath_f16();}}@@ -97,8 +98,9 @@ struct onednn_matmul {}onednn_matmul& post_op_bin_mul(bool per_oc = true) {dnnl::memory::dim batch_size = m_M;- if (batch_size == DNNL_RUNTIME_DIM_VAL)+ if (batch_size == DNNL_RUNTIME_DIM_VAL) {batch_size = 1024 * 1024; // big enough fake static batch+ }dnnl::memory::desc bin_mul_md = dnnl::memory::desc(dnnl::memory::dims({batch_size, per_oc ? m_N : 1}), m_a_type, dnnl::memory::format_tag::ab);postops.append_binary(dnnl::algorithm::binary_mul, bin_mul_md);@@ -178,8 +180,9 @@ struct onednn_matmul {post_op_bin_mul(false);post_op_sum();}- if (t == type::with_gate_act)+ if (t == type::with_gate_act) {post_op_gate_activation(activation_algo);+ }if (t == type::with_gate_act_bin_mul) {bin_post_id = 1;post_op_gate_activation(activation_algo);diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/gru_seq_onednn.hpp b/src/plugins/intel_gpu/src/graph/impls/onednn/gru_seq_onednn.hppindex 19c7316fd32..c8f8105fdba 100644--- a/src/plugins/intel_gpu/src/graph/impls/onednn/gru_seq_onednn.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/gru_seq_onednn.hpp@@ -23,18 +23,21 @@ struct GRUSeqImplementationManager : public ImplementationManager {assert(node.is_type<gru_seq>());const auto& config = node.get_program().get_config();const auto& info = node.get_program().get_engine().get_device_info();- if (info.arch == gpu_arch::unknown || !config.get_use_onednn())+ if (info.arch == gpu_arch::unknown || !config.get_use_onednn()) {return false;+ }const auto& gru_seq_node = node.as<gru_seq>();const auto& in_layout = gru_seq_node.get_input_layout(0);const auto& out_layout = gru_seq_node.get_output_layout(0);if (node.get_input_layout(0).format != cldnn::format::bfyx && node.get_input_layout(0).format != cldnn::format::fbyx- && node.get_input_layout(0).format != cldnn::format::ybfx)+ && node.get_input_layout(0).format != cldnn::format::ybfx) {return false;+ }- if (!is_supported_pad(in_layout) || !is_supported_pad(out_layout))+ if (!is_supported_pad(in_layout) || !is_supported_pad(out_layout)) {return false;+ }auto in0_dt = node.get_input_layout(0).data_type;auto in1_dt = node.get_input_layout(1).data_type;diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/lstm_seq_onednn.hpp b/src/plugins/intel_gpu/src/graph/impls/onednn/lstm_seq_onednn.hppindex 290124326d3..bd8a45a44ef 100644--- a/src/plugins/intel_gpu/src/graph/impls/onednn/lstm_seq_onednn.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/lstm_seq_onednn.hpp@@ -24,18 +24,21 @@ struct LSTMSeqImplementationManager : public ImplementationManager {assert(node.is_type<lstm_seq>());const auto& config = node.get_program().get_config();const auto& info = node.get_program().get_engine().get_device_info();- if (info.arch == gpu_arch::unknown || !config.get_use_onednn())+ if (info.arch == gpu_arch::unknown || !config.get_use_onednn()) {return false;+ }const auto& lstm_seq_node = node.as<lstm_seq>();const auto& in_layout = lstm_seq_node.get_input_layout(0);const auto& out_layout = lstm_seq_node.get_output_layout(0);if (node.get_input_layout(0).format != cldnn::format::bfyx && node.get_input_layout(0).format != cldnn::format::fbyx- && node.get_input_layout(0).format != cldnn::format::ybfx)+ && node.get_input_layout(0).format != cldnn::format::ybfx) {return false;+ }- if (!is_supported_pad(in_layout) || !is_supported_pad(out_layout))+ if (!is_supported_pad(in_layout) || !is_supported_pad(out_layout)) {return false;+ }auto in0_dt = node.get_input_layout(0).data_type;auto in1_dt = node.get_input_layout(1).data_type;@@ -59,8 +62,9 @@ struct LSTMSeqImplementationManager : public ImplementationManager {bool f32s8f32_case = everyone_is(data_types::i8, in0_dt, in3_dt, in4_dt) && one_of(out0_dt, {data_types::i8, data_types::f32}) &&everyone_is(data_types::f32, in1_dt, in5_dt, out1_dt);- if (!cell_state_check)+ if (!cell_state_check) {return false;+ }return f16_case || f32_case || u8u8u8_case || f32u8f32_case || s8s8s8_case || f32s8f32_case;}@@ -71,14 +75,16 @@ struct LSTMSeqImplementationManager : public ImplementationManager {size_t out_rank = node.get_output_layout().get_rank();for (size_t idx = 0; idx < node.get_dependencies().size(); idx++) {- if (node.get_dependency(idx).is_constant())+ if (node.get_dependency(idx).is_constant()) {continue;+ }auto target_format = format::get_default_format(out_rank);- if (idx == 0)+ if (idx == 0) {in_fmts[idx] = format::fbyx;- else+ } else {in_fmts[idx] = target_format;+ }}out_fmts[0] = format::ybfx;diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/moe_gemm_onednn.hpp b/src/plugins/intel_gpu/src/graph/impls/onednn/moe_gemm_onednn.hppindex bb5284f34de..b8bbba80f01 100644--- a/src/plugins/intel_gpu/src/graph/impls/onednn/moe_gemm_onednn.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/moe_gemm_onednn.hpp@@ -34,8 +34,9 @@ struct MoEGemmImplementationManager : public ImplementationManager {OPENVINO_ASSERT(node.is_type<moe_gemm>());const auto& config = node.get_program().get_config();const auto& info = node.get_program().get_engine().get_device_info();- if (!info.supports_immad || info.arch == gpu_arch::unknown || !config.get_use_onednn())+ if (!info.supports_immad || info.arch == gpu_arch::unknown || !config.get_use_onednn()) {return false;+ }static const std::vector<format> supported_fmts = {format::bfyx,@@ -134,8 +135,9 @@ struct MoEGemmImplementationManager : public ImplementationManager {std::vector<format::type> out_fmts(node.get_outputs_count(), format::any);for (size_t idx = 0 ; idx < node.get_dependencies().size() ; idx++) {- if (node.get_dependency(idx).is_constant())+ if (node.get_dependency(idx).is_constant()) {continue;+ }size_t out_rank = node.get_output_layout().get_rank();auto target_format = format::get_default_format(out_rank);diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/pooling_onednn.hpp b/src/plugins/intel_gpu/src/graph/impls/onednn/pooling_onednn.hppindex 4a69ca9b2fa..93dd0158df0 100644--- a/src/plugins/intel_gpu/src/graph/impls/onednn/pooling_onednn.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/pooling_onednn.hpp@@ -21,16 +21,18 @@ struct PoolingImplementationManager : public ImplementationManager {assert(node.is_type<pooling>());const auto& config = node.get_program().get_config();const auto& info = node.get_program().get_engine().get_device_info();- if (!info.supports_immad || info.arch == gpu_arch::unknown || !config.get_use_onednn())+ if (!info.supports_immad || info.arch == gpu_arch::unknown || !config.get_use_onednn()) {return false;+ }const auto& in_layout = node.get_input_layout(0);const auto& out_layout = node.get_output_layout(0);auto in_dt = in_layout.data_type;auto out_dt = out_layout.data_type;- if (in_layout.data_padding || out_layout.data_padding)+ if (in_layout.data_padding || out_layout.data_padding) {return false;+ }static const std::vector<format::type> supported_formats = {format::any,@@ -70,11 +72,13 @@ struct PoolingImplementationManager : public ImplementationManager {bool u8s8_case = one_of(in_dt, {ov::element::i8, ov::element::u8}) &&one_of(out_dt, {ov::element::i8, ov::element::u8, ov::element::f32, ov::element::f16, ov::element::bf16});- if (!fp_case && !u8s8_case)+ if (!fp_case && !u8s8_case) {return false;+ }- if (!one_of(in_layout.format.value, supported_formats) || !one_of(out_layout.format.value, supported_formats))+ if (!one_of(in_layout.format.value, supported_formats) || !one_of(out_layout.format.value, supported_formats)) {return false;+ }return is_supported_post_ops(node);}diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/primitive_onednn_base.h b/src/plugins/intel_gpu/src/graph/impls/onednn/primitive_onednn_base.hindex 39b706f7a8f..0a79f9a8f0f 100644--- a/src/plugins/intel_gpu/src/graph/impls/onednn/primitive_onednn_base.h+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/primitive_onednn_base.h@@ -524,8 +524,9 @@ protected:void init_kernels(const kernels_cache&, const kernel_impl_params&) override { }void set_arguments_impl(typed_primitive_inst<PType>& instance) override {- if (instance.can_be_optimized())+ if (instance.can_be_optimized()) {return;+ }uint32_t net_id = instance.get_network().get_id();_args[net_id] = get_arguments(instance);}@@ -585,8 +586,9 @@ protected:// If oneDNN primitive is the output primitive or it's user is CPU implementation, then enqueue marker// with empty events wait list (which will trigger wait for all previously enqueued tasks) and// return it as oneDNN primitive's event as it is a single option for proper synchronization- if (instance.needs_completion_event())+ if (instance.needs_completion_event()) {event = stream.enqueue_marker({});+ }}}@@ -594,8 +596,9 @@ protected:}std::vector<BufferDescriptor> get_internal_buffer_descs(const kernel_impl_params&) const override {- if (_scratchpad_md.get_size() == 0)+ if (_scratchpad_md.get_size() == 0) {return {};+ }return {BufferDescriptor(_scratchpad_md.get_size(), cldnn::data_types::u8)};}};diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/reduce_onednn.cpp b/src/plugins/intel_gpu/src/graph/impls/onednn/reduce_onednn.cppindex 1961e550086..97e81f71693 100644--- a/src/plugins/intel_gpu/src/graph/impls/onednn/reduce_onednn.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/reduce_onednn.cpp@@ -19,8 +19,9 @@ static void reorder_unreduced_axis_no_fusion(const kernel_impl_params& impl_paraif (output_layout.get_partial_shape().size() < input_layout.get_partial_shape().size()) {output_layout.format = format::adjust_to_rank(output_layout.format, input_layout.get_partial_shape().size());auto new_p_shape = input_layout.get_partial_shape();- for (auto axis : axes)+ for (auto axis : axes) {new_p_shape[axis] = 1;+ }output_layout.set_partial_shape(new_p_shape);}} else {@@ -30,10 +31,11 @@ static void reorder_unreduced_axis_no_fusion(const kernel_impl_params& impl_parasize_t num_others = num_dims - num_spatial;for (size_t idx = 0; idx < axes.size(); idx++) {- if (axes[idx] < static_cast<int64_t>(num_others))+ if (axes[idx] < static_cast<int64_t>(num_others)) {in_dims[axes[idx]] = 1;- else+ } else {in_dims[(num_dims - axes[idx] - 1 + num_others)] = 1;+ }}auto output_tensor = output_layout.get_tensor();diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/reorder_onednn.cpp b/src/plugins/intel_gpu/src/graph/impls/onednn/reorder_onednn.cppindex 838f3148e0d..6e5f3687fbf 100644--- a/src/plugins/intel_gpu/src/graph/impls/onednn/reorder_onednn.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/reorder_onednn.cpp@@ -102,10 +102,11 @@ public:ib >> prim_cache;_scratchpad_md = _pd.scratchpad_desc();- if (!prim_cache.empty())+ if (!prim_cache.empty()) {_prim = dnnl::reorder(_pd, prim_cache);- else+ } else {_prim = dnnl::reorder(_pd);+ }#endif}diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/reorder_onednn.hpp b/src/plugins/intel_gpu/src/graph/impls/onednn/reorder_onednn.hppindex 999dea3cd89..83aefdced52 100644--- a/src/plugins/intel_gpu/src/graph/impls/onednn/reorder_onednn.hpp+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/reorder_onednn.hpp@@ -53,45 +53,55 @@ struct ReorderImplementationManager : public ImplementationManager {auto out_dt = output_layout.data_type;// custom layout is requested by onednn only, so we ignore other checks- if (output_fmt == format::custom)+ if (output_fmt == format::custom) {return true;+ }const auto& config = node.get_program().get_config();const auto& info = node.get_program().get_engine().get_device_info();- if (!info.supports_immad || info.arch == gpu_arch::unknown || !config.get_use_onednn())+ if (!info.supports_immad || info.arch == gpu_arch::unknown || !config.get_use_onednn()) {return false;+ }- if (!one_of(input_fmt.value, supported_formats) || !one_of(output_fmt.value, supported_formats))+ if (!one_of(input_fmt.value, supported_formats) || !one_of(output_fmt.value, supported_formats)) {return false;+ }// onednn doesn't support paddings- if (!is_supported_pad_for_reorder(input_layout) || !is_supported_pad_for_reorder(output_layout))+ if (!is_supported_pad_for_reorder(input_layout) || !is_supported_pad_for_reorder(output_layout)) {return false;+ }// Native impl works faster for this type of reorder- if (input_fmt == format::bfyx && output_fmt == format::bfyx)+ if (input_fmt == format::bfyx && output_fmt == format::bfyx) {return false;+ }// onednn reorder doesn't support different number of dimensions in input and output layouts- if (input_fmt.dimension() != output_fmt.dimension())+ if (input_fmt.dimension() != output_fmt.dimension()) {return false;+ }if (in_dt == data_types::u16 || in_dt == data_types::u32 || in_dt == data_types::i16 || in_dt == data_types::i64 || out_dt == data_types::u16- || out_dt == data_types::u32 || out_dt == data_types::i16 || out_dt == data_types::i64)+ || out_dt == data_types::u32 || out_dt == data_types::i16 || out_dt == data_types::i64) {return false;+ }// For mixed precision case, oneDNN is slower than clDNN- if (input_fmt == format::b_fs_yx_fsv16 && data_type_traits::is_i8_u8(in_dt))+ if (input_fmt == format::b_fs_yx_fsv16 && data_type_traits::is_i8_u8(in_dt)) {return false;- if (output_fmt == format::b_fs_yx_fsv16 && data_type_traits::is_i8_u8(in_dt))+ }+ if (output_fmt == format::b_fs_yx_fsv16 && data_type_traits::is_i8_u8(in_dt)) {return false;+ }return output_fmt != format::bfyx || out_dt != data_types::f32;}static bool is_supported_pad_for_reorder(const layout& layout) {// check to support the batch/spatial pad for onednn.- if (!is_supported_pad(layout))+ if (!is_supported_pad(layout)) {return false;+ }// Check feature padconst auto& pad = layout.data_padding;diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/utils.cpp b/src/plugins/intel_gpu/src/graph/impls/onednn/utils.cppindex 502b5bc0af0..f13ea6d63af 100644--- a/src/plugins/intel_gpu/src/graph/impls/onednn/utils.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/utils.cpp@@ -3,7 +3,9 @@//#include "utils.hpp"+#include <oneapi/dnnl/dnnl_debug.h>+#include <numeric>namespace cldnn {@@ -61,10 +63,12 @@ void copy_zp_data_to_s32(const memory::ptr& zp_memory, const memory::ptr& zp_s32cldnn::memory::ptr convert_zp_data_to_s32(const memory::ptr zp_memory) {auto zp_s32_layout = zp_memory->get_layout();const auto src_dtype = zp_s32_layout.data_type;- if (src_dtype == data_types::i32)+ if (src_dtype == data_types::i32) {return zp_memory;- if (!data_type_traits::is_i8_u8(src_dtype))+ }+ if (!data_type_traits::is_i8_u8(src_dtype)) {return nullptr;+ }auto* engine = zp_memory->get_engine();auto& stream = engine->get_service_stream();@@ -83,9 +87,12 @@ cldnn::memory::ptr convert_zp_data_to_s32(const memory::ptr zp_memory) {cldnn::format default_fmt_for_dims(size_t dims, bool is_grouped) {switch (dims) {- case 6: return is_grouped ? cldnn::format::goizyx : cldnn::format::bfwzyx;- case 5: return is_grouped ? cldnn::format::goiyx : cldnn::format::bfzyx;- default: return cldnn::format::bfyx;+ case 6:+ return is_grouped ? cldnn::format::goizyx : cldnn::format::bfwzyx;+ case 5:+ return is_grouped ? cldnn::format::goiyx : cldnn::format::bfzyx;+ default:+ return cldnn::format::bfyx;}}@@ -97,12 +104,18 @@ dnnl::memory::dims convert_tensor(cldnn::tensor t, size_t dims, bool is_grouped)dnnl::memory::format_tag get_default_data_format(const cldnn::layout& l) {switch (l.get_partial_shape().size()) {- case 2: return dnnl::memory::format_tag::ab;- case 3: return dnnl::memory::format_tag::abc;- case 4: return dnnl::memory::format_tag::abcd;- case 5: return dnnl::memory::format_tag::abcde;- case 6: return dnnl::memory::format_tag::abcdef;- default: OPENVINO_THROW("[GPU] Unsupported conversion from "+ l.to_short_string() + " to onednn format_tag");+ case 2:+ return dnnl::memory::format_tag::ab;+ case 3:+ return dnnl::memory::format_tag::abc;+ case 4:+ return dnnl::memory::format_tag::abcd;+ case 5:+ return dnnl::memory::format_tag::abcde;+ case 6:+ return dnnl::memory::format_tag::abcdef;+ default:+ OPENVINO_THROW("[GPU] Unsupported conversion from " + l.to_short_string() + " to onednn format_tag");}}@@ -151,109 +164,123 @@ dnnl::memory::dims get_strides(dnnl::memory::dims dims) {dnnl::memory::data_type convert_data_type(cldnn::data_types dt) {switch (dt) {- case cldnn::data_types::f32: return dnnl::memory::data_type::f32;- case cldnn::data_types::f16: return dnnl::memory::data_type::f16;- case cldnn::data_types::i8: return dnnl::memory::data_type::s8;- case cldnn::data_types::u8: return dnnl::memory::data_type::u8;- case cldnn::data_types::i32: return dnnl::memory::data_type::s32;- case cldnn::data_types::i4: return dnnl::memory::data_type::s4;- case cldnn::data_types::u4: return dnnl::memory::data_type::u4;- case cldnn::data_types::f4e2m1: return dnnl::memory::data_type::f4_e2m1;- case cldnn::data_types::f8e4m3: return dnnl::memory::data_type::f8_e4m3;- case cldnn::data_types::f8e5m2: return dnnl::memory::data_type::f8_e5m2;- case cldnn::data_types::f8e8m0: return dnnl::memory::data_type::e8m0;- case cldnn::data_types::bf16: return dnnl::memory::data_type::bf16;- default: throw std::invalid_argument("[clDNN] Unsupported conversion from cldnn to onednn type");+ case cldnn::data_types::f32:+ return dnnl::memory::data_type::f32;+ case cldnn::data_types::f16:+ return dnnl::memory::data_type::f16;+ case cldnn::data_types::i8:+ return dnnl::memory::data_type::s8;+ case cldnn::data_types::u8:+ return dnnl::memory::data_type::u8;+ case cldnn::data_types::i32:+ return dnnl::memory::data_type::s32;+ case cldnn::data_types::i4:+ return dnnl::memory::data_type::s4;+ case cldnn::data_types::u4:+ return dnnl::memory::data_type::u4;+ case cldnn::data_types::f4e2m1:+ return dnnl::memory::data_type::f4_e2m1;+ case cldnn::data_types::f8e4m3:+ return dnnl::memory::data_type::f8_e4m3;+ case cldnn::data_types::f8e5m2:+ return dnnl::memory::data_type::f8_e5m2;+ case cldnn::data_types::f8e8m0:+ return dnnl::memory::data_type::e8m0;+ case cldnn::data_types::bf16:+ return dnnl::memory::data_type::bf16;+ default:+ throw std::invalid_argument("[clDNN] Unsupported conversion from cldnn to onednn type");}}std::vector<std::pair<cldnn::format, dnnl::memory::format_tag>> format_map = {- /// weights format for onednnn- { cldnn::format::oiyx, dnnl::memory::format_tag::oihw },- { cldnn::format::ioyx, dnnl::memory::format_tag::iohw },- { cldnn::format::yxio, dnnl::memory::format_tag::hwio },- { cldnn::format::oizyx, dnnl::memory::format_tag::oidhw },- { cldnn::format::iozyx, dnnl::memory::format_tag::iodhw },- { cldnn::format::iyxo, dnnl::memory::format_tag::ihwo },- { cldnn::format::oyxi, dnnl::memory::format_tag::ohwi },- { cldnn::format::oyix, dnnl::memory::format_tag::acbd },- { cldnn::format::oxiy, dnnl::memory::format_tag::adbc },- { cldnn::format::goiyx, dnnl::memory::format_tag::goihw },- { cldnn::format::gioyx, dnnl::memory::format_tag::giohw },- { cldnn::format::gyxio, dnnl::memory::format_tag::ghwio },- { cldnn::format::giozyx, dnnl::memory::format_tag::giodhw },- { cldnn::format::goizyx, dnnl::memory::format_tag::goidhw },-- { cldnn::format::os_iyx_osv16, dnnl::memory::format_tag::Oihw16o },- { cldnn::format::gs_oiyx_gsv16, dnnl::memory::format_tag::Goihw16g },- { cldnn::format::gs_oiyx_gsv32, dnnl::memory::format_tag::Goihw32g },- { cldnn::format::gs_oizyx_gsv16, dnnl::memory::format_tag::Goidhw16g },- { cldnn::format::g_os_iyx_osv16, dnnl::memory::format_tag::gOihw16o },-- { cldnn::format::os_is_yx_osv16_isv16, dnnl::memory::format_tag::OIhw16o16i },- { cldnn::format::os_is_yx_isv16_osv16, dnnl::memory::format_tag::OIhw16i16o },- { cldnn::format::os_is_zyx_isv16_osv16, dnnl::memory::format_tag::OIdhw16i16o },- { cldnn::format::is_os_zyx_isv16_osv16, dnnl::memory::format_tag::IOdhw16i16o },- { cldnn::format::is_os_yx_isv16_osv16, dnnl::memory::format_tag::IOhw16i16o },-- { cldnn::format::g_os_is_zyx_isv16_osv16, dnnl::memory::format_tag::gIOdhw16i16o },-- { cldnn::format::bfyx, dnnl::memory::format_tag::nchw },- { cldnn::format::bfxy, dnnl::memory::format_tag::abdc },- { cldnn::format::byxf, dnnl::memory::format_tag::nhwc },- { cldnn::format::byfx, dnnl::memory::format_tag::acbd },- { cldnn::format::bxfy, dnnl::memory::format_tag::adbc },- { cldnn::format::fyxb, dnnl::memory::format_tag::bcda },- { cldnn::format::xbfy, dnnl::memory::format_tag::dabc },- { cldnn::format::fybx, dnnl::memory::format_tag::bcad },- { cldnn::format::ybfx, dnnl::memory::format_tag::cabd },- { cldnn::format::fbyx, dnnl::memory::format_tag::bacd },- { cldnn::format::bfzyx, dnnl::memory::format_tag::ncdhw },- { cldnn::format::bzyxf, dnnl::memory::format_tag::ndhwc },- { cldnn::format::bfwzyx, dnnl::memory::format_tag::abcdef },- { cldnn::format::b_fs_yx_fsv2, dnnl::memory::format_tag::undef },- { cldnn::format::b_fs_yx_fsv4, dnnl::memory::format_tag::aBcd4b },- { cldnn::format::b_fs_yx_fsv8, dnnl::memory::format_tag::aBcd8b },- { cldnn::format::b_fs_yx_fsv16, dnnl::memory::format_tag::nChw16c },- { cldnn::format::b_fs_yx_fsv32, dnnl::memory::format_tag::aBcd32b },- { cldnn::format::b_fs_zyx_fsv4, dnnl::memory::format_tag::aBcde4b },- { cldnn::format::b_fs_zyx_fsv8, dnnl::memory::format_tag::aBcde8b },- { cldnn::format::b_fs_zyx_fsv16, dnnl::memory::format_tag::nCdhw16c },- { cldnn::format::b_fs_zyx_fsv32, dnnl::memory::format_tag::aBcde32b },- { cldnn::format::bs_fs_yx_bsv16_fsv16, dnnl::memory::format_tag::NChw16n16c },- { cldnn::format::bs_fs_yx_bsv16_fsv32, dnnl::memory::format_tag::NChw16n32c },- { cldnn::format::bs_fs_yx_bsv32_fsv32, dnnl::memory::format_tag::NChw32n32c },- { cldnn::format::bs_fs_yx_bsv4_fsv4, dnnl::memory::format_tag::ABcd4a4b },- { cldnn::format::bs_fs_yx_bsv8_fsv4, dnnl::memory::format_tag::ABcd8a4b },- { cldnn::format::bs_fs_yx_bsv8_fsv2, dnnl::memory::format_tag::ABcd8a2b },- { cldnn::format::bs_fs_yx_bsv4_fsv2, dnnl::memory::format_tag::ABcd4a2b },- { cldnn::format::bs_fs_yx_bsv32_fsv16, dnnl::memory::format_tag::NChw32n16c },- { cldnn::format::bs_fs_zyx_bsv32_fsv16, dnnl::memory::format_tag::NCdhw32n16c },- { cldnn::format::bs_fs_zyx_bsv32_fsv32, dnnl::memory::format_tag::NCdhw32n32c },- { cldnn::format::bs_fs_zyx_bsv16_fsv16, dnnl::memory::format_tag::NCdhw16n16c },- // { cldnn::format::bs_fs_zyx_bsv16_fsv32, dnnl::memory::format_tag::NCdhw16n32c }, // TODO onednn3.0: Request NCdhw16n32c format- { cldnn::format::bs_fs_zyx_bsv8_fsv4, dnnl::memory::format_tag::ABcde8a4b },- { cldnn::format::bs_fs_zyx_bsv8_fsv2, dnnl::memory::format_tag::ABcde8a2b },+ /// weights format for onednnn+ {cldnn::format::oiyx, dnnl::memory::format_tag::oihw},+ {cldnn::format::ioyx, dnnl::memory::format_tag::iohw},+ {cldnn::format::yxio, dnnl::memory::format_tag::hwio},+ {cldnn::format::oizyx, dnnl::memory::format_tag::oidhw},+ {cldnn::format::iozyx, dnnl::memory::format_tag::iodhw},+ {cldnn::format::iyxo, dnnl::memory::format_tag::ihwo},+ {cldnn::format::oyxi, dnnl::memory::format_tag::ohwi},+ {cldnn::format::oyix, dnnl::memory::format_tag::acbd},+ {cldnn::format::oxiy, dnnl::memory::format_tag::adbc},+ {cldnn::format::goiyx, dnnl::memory::format_tag::goihw},+ {cldnn::format::gioyx, dnnl::memory::format_tag::giohw},+ {cldnn::format::gyxio, dnnl::memory::format_tag::ghwio},+ {cldnn::format::giozyx, dnnl::memory::format_tag::giodhw},+ {cldnn::format::goizyx, dnnl::memory::format_tag::goidhw},++ {cldnn::format::os_iyx_osv16, dnnl::memory::format_tag::Oihw16o},+ {cldnn::format::gs_oiyx_gsv16, dnnl::memory::format_tag::Goihw16g},+ {cldnn::format::gs_oiyx_gsv32, dnnl::memory::format_tag::Goihw32g},+ {cldnn::format::gs_oizyx_gsv16, dnnl::memory::format_tag::Goidhw16g},+ {cldnn::format::g_os_iyx_osv16, dnnl::memory::format_tag::gOihw16o},++ {cldnn::format::os_is_yx_osv16_isv16, dnnl::memory::format_tag::OIhw16o16i},+ {cldnn::format::os_is_yx_isv16_osv16, dnnl::memory::format_tag::OIhw16i16o},+ {cldnn::format::os_is_zyx_isv16_osv16, dnnl::memory::format_tag::OIdhw16i16o},+ {cldnn::format::is_os_zyx_isv16_osv16, dnnl::memory::format_tag::IOdhw16i16o},+ {cldnn::format::is_os_yx_isv16_osv16, dnnl::memory::format_tag::IOhw16i16o},++ {cldnn::format::g_os_is_zyx_isv16_osv16, dnnl::memory::format_tag::gIOdhw16i16o},++ {cldnn::format::bfyx, dnnl::memory::format_tag::nchw},+ {cldnn::format::bfxy, dnnl::memory::format_tag::abdc},+ {cldnn::format::byxf, dnnl::memory::format_tag::nhwc},+ {cldnn::format::byfx, dnnl::memory::format_tag::acbd},+ {cldnn::format::bxfy, dnnl::memory::format_tag::adbc},+ {cldnn::format::fyxb, dnnl::memory::format_tag::bcda},+ {cldnn::format::xbfy, dnnl::memory::format_tag::dabc},+ {cldnn::format::fybx, dnnl::memory::format_tag::bcad},+ {cldnn::format::ybfx, dnnl::memory::format_tag::cabd},+ {cldnn::format::fbyx, dnnl::memory::format_tag::bacd},+ {cldnn::format::bfzyx, dnnl::memory::format_tag::ncdhw},+ {cldnn::format::bzyxf, dnnl::memory::format_tag::ndhwc},+ {cldnn::format::bfwzyx, dnnl::memory::format_tag::abcdef},+ {cldnn::format::b_fs_yx_fsv2, dnnl::memory::format_tag::undef},+ {cldnn::format::b_fs_yx_fsv4, dnnl::memory::format_tag::aBcd4b},+ {cldnn::format::b_fs_yx_fsv8, dnnl::memory::format_tag::aBcd8b},+ {cldnn::format::b_fs_yx_fsv16, dnnl::memory::format_tag::nChw16c},+ {cldnn::format::b_fs_yx_fsv32, dnnl::memory::format_tag::aBcd32b},+ {cldnn::format::b_fs_zyx_fsv4, dnnl::memory::format_tag::aBcde4b},+ {cldnn::format::b_fs_zyx_fsv8, dnnl::memory::format_tag::aBcde8b},+ {cldnn::format::b_fs_zyx_fsv16, dnnl::memory::format_tag::nCdhw16c},+ {cldnn::format::b_fs_zyx_fsv32, dnnl::memory::format_tag::aBcde32b},+ {cldnn::format::bs_fs_yx_bsv16_fsv16, dnnl::memory::format_tag::NChw16n16c},+ {cldnn::format::bs_fs_yx_bsv16_fsv32, dnnl::memory::format_tag::NChw16n32c},+ {cldnn::format::bs_fs_yx_bsv32_fsv32, dnnl::memory::format_tag::NChw32n32c},+ {cldnn::format::bs_fs_yx_bsv4_fsv4, dnnl::memory::format_tag::ABcd4a4b},+ {cldnn::format::bs_fs_yx_bsv8_fsv4, dnnl::memory::format_tag::ABcd8a4b},+ {cldnn::format::bs_fs_yx_bsv8_fsv2, dnnl::memory::format_tag::ABcd8a2b},+ {cldnn::format::bs_fs_yx_bsv4_fsv2, dnnl::memory::format_tag::ABcd4a2b},+ {cldnn::format::bs_fs_yx_bsv32_fsv16, dnnl::memory::format_tag::NChw32n16c},+ {cldnn::format::bs_fs_zyx_bsv32_fsv16, dnnl::memory::format_tag::NCdhw32n16c},+ {cldnn::format::bs_fs_zyx_bsv32_fsv32, dnnl::memory::format_tag::NCdhw32n32c},+ {cldnn::format::bs_fs_zyx_bsv16_fsv16, dnnl::memory::format_tag::NCdhw16n16c},+ // { cldnn::format::bs_fs_zyx_bsv16_fsv32, dnnl::memory::format_tag::NCdhw16n32c }, // TODO onednn3.0: Request NCdhw16n32c format+ {cldnn::format::bs_fs_zyx_bsv8_fsv4, dnnl::memory::format_tag::ABcde8a4b},+ {cldnn::format::bs_fs_zyx_bsv8_fsv2, dnnl::memory::format_tag::ABcde8a2b},};dnnl::memory::format_tag convert_data_format(cldnn::format fmt) {- auto ret = std::find_if(format_map.begin(), format_map.end(),- [fmt](std::pair<cldnn::format, dnnl::memory::format_tag> &e) {- return e.first == fmt; });+ auto ret = std::find_if(format_map.begin(), format_map.end(), [fmt](std::pair<cldnn::format, dnnl::memory::format_tag>& e) {+ return e.first == fmt;+ });if (ret == format_map.end()) {- GPU_DEBUG_INFO << "[clDNN] Unsupported conversion from "+ fmt.to_string() + " to onednn format_tag. Any tag will be used instead." << std::endl;+ GPU_DEBUG_INFO << "[clDNN] Unsupported conversion from " + fmt.to_string() + " to onednn format_tag. Any tag will be used instead." << std::endl;return dnnl::memory::format_tag::any;}return ret->second;}- cldnn::format convert_data_format(dnnl::memory::format_tag fmt) {- auto ret = std::find_if(format_map.begin(), format_map.end(),- [fmt](std::pair<cldnn::format, dnnl::memory::format_tag> &e) {- return e.second == fmt; });- if (ret == format_map.end())+cldnn::format convert_data_format(dnnl::memory::format_tag fmt) {+ auto ret = std::find_if(format_map.begin(), format_map.end(), [fmt](std::pair<cldnn::format, dnnl::memory::format_tag>& e) {+ return e.second == fmt;+ });+ if (ret == format_map.end()) {throw std::invalid_argument("[clDNN] Unsupported onednn layout");+ }return ret->first;}@@ -273,61 +300,60 @@ int64_t get_offset(const cldnn::layout& l, dnnl::memory::desc&& desc) {}switch (desc.get_data_type()) {- case dnnl::memory::data_type::s4:- case dnnl::memory::data_type::u4:- case dnnl::memory::data_type::f4_e2m1:- return offset / 2;- case dnnl::memory::data_type::s8:- case dnnl::memory::data_type::u8:- case dnnl::memory::data_type::f8_e4m3:- case dnnl::memory::data_type::f8_e5m2:- case dnnl::memory::data_type::e8m0:- return offset;- case dnnl::memory::data_type::f16:- case dnnl::memory::data_type::bf16:- return (offset * 2);- case dnnl::memory::data_type::f32:- case dnnl::memory::data_type::s32:- return (offset * 4);- default:- throw std::runtime_error(std::string("Unsupported offset for dnnl_data_type_t ")- + dnnl_dt2str(static_cast<dnnl_data_type_t>(desc.get_data_type())));+ case dnnl::memory::data_type::s4:+ case dnnl::memory::data_type::u4:+ case dnnl::memory::data_type::f4_e2m1:+ return offset / 2;+ case dnnl::memory::data_type::s8:+ case dnnl::memory::data_type::u8:+ case dnnl::memory::data_type::f8_e4m3:+ case dnnl::memory::data_type::f8_e5m2:+ case dnnl::memory::data_type::e8m0:+ return offset;+ case dnnl::memory::data_type::f16:+ case dnnl::memory::data_type::bf16:+ return (offset * 2);+ case dnnl::memory::data_type::f32:+ case dnnl::memory::data_type::s32:+ return (offset * 4);+ default:+ throw std::runtime_error(std::string("Unsupported offset for dnnl_data_type_t ") + dnnl_dt2str(static_cast<dnnl_data_type_t>(desc.get_data_type())));}}// Static map for cldnn 4D format to onednn 3D format_tag conversionstatic const std::map<cldnn::format::type, dnnl::memory::format_tag> format_map_cldnn_4d_to_onednn_3d = {// Data formats- { cldnn::format::bfyx, dnnl::memory::format_tag::abc },- { cldnn::format::bfxy, dnnl::memory::format_tag::abc },- { cldnn::format::byxf, dnnl::memory::format_tag::acb },- { cldnn::format::byfx, dnnl::memory::format_tag::acb },- { cldnn::format::bxfy, dnnl::memory::format_tag::acb },- { cldnn::format::fbyx, dnnl::memory::format_tag::bac },- { cldnn::format::fyxb, dnnl::memory::format_tag::bca },- { cldnn::format::fybx, dnnl::memory::format_tag::bca },- { cldnn::format::xbfy, dnnl::memory::format_tag::cab },- { cldnn::format::ybfx, dnnl::memory::format_tag::cab },- { cldnn::format::yxfb, dnnl::memory::format_tag::cba },+ {cldnn::format::bfyx, dnnl::memory::format_tag::abc},+ {cldnn::format::bfxy, dnnl::memory::format_tag::abc},+ {cldnn::format::byxf, dnnl::memory::format_tag::acb},+ {cldnn::format::byfx, dnnl::memory::format_tag::acb},+ {cldnn::format::bxfy, dnnl::memory::format_tag::acb},+ {cldnn::format::fbyx, dnnl::memory::format_tag::bac},+ {cldnn::format::fyxb, dnnl::memory::format_tag::bca},+ {cldnn::format::fybx, dnnl::memory::format_tag::bca},+ {cldnn::format::xbfy, dnnl::memory::format_tag::cab},+ {cldnn::format::ybfx, dnnl::memory::format_tag::cab},+ {cldnn::format::yxfb, dnnl::memory::format_tag::cba},// Weight formats- { cldnn::format::oiyx, dnnl::memory::format_tag::abc },- { cldnn::format::ioyx, dnnl::memory::format_tag::bac },- { cldnn::format::yxio, dnnl::memory::format_tag::cab },- { cldnn::format::iyxo, dnnl::memory::format_tag::bca },- { cldnn::format::oyxi, dnnl::memory::format_tag::acb },- { cldnn::format::oyix, dnnl::memory::format_tag::acb },- { cldnn::format::oxiy, dnnl::memory::format_tag::acb },+ {cldnn::format::oiyx, dnnl::memory::format_tag::abc},+ {cldnn::format::ioyx, dnnl::memory::format_tag::bac},+ {cldnn::format::yxio, dnnl::memory::format_tag::cab},+ {cldnn::format::iyxo, dnnl::memory::format_tag::bca},+ {cldnn::format::oyxi, dnnl::memory::format_tag::acb},+ {cldnn::format::oyix, dnnl::memory::format_tag::acb},+ {cldnn::format::oxiy, dnnl::memory::format_tag::acb},};// Internal builder class for memory descriptor constructionclass MemoryDescriptorBuilder {public:explicit MemoryDescriptorBuilder(const cldnn::layout& l, dnnl::memory::format_tag target_fmt)- : _layout(l)- , _target_fmt(target_fmt)- , _flatten(false)- , _use_strides(false)- , _keep_rank(false) {}+ : _layout(l),+ _target_fmt(target_fmt),+ _flatten(false),+ _use_strides(false),+ _keep_rank(false) {}// Enables flattening mode to create a 1D memory descriptorMemoryDescriptorBuilder& as_flattened() {@@ -378,8 +404,9 @@ private:const auto& raw = _layout.get_tensor().raw;int64_t result = 1;for (size_t i = 0; i < raw.size(); ++i) {- if (i != skip_idx)+ if (i != skip_idx) {result *= static_cast<int64_t>(raw[i]);+ }}return result;};@@ -422,9 +449,7 @@ private:} else if (_flatten) {dims = flatten_tensor(_layout.get_tensor());} else {- auto shape_rank = _layout.is_dynamic() ?- static_cast<size_t>(_layout.get_partial_shape().rank().get_length()) :- _layout.get_shape().size();+ auto shape_rank = _layout.is_dynamic() ? static_cast<size_t>(_layout.get_partial_shape().rank().get_length()) : _layout.get_shape().size();// TODO: Consider refactoring// Converting 4D to 3D and updating format_tag within dims calculation breaks function atomicity.// This logic should be separated for better maintainability.@@ -457,57 +482,57 @@ private:dnnl::memory::dims strides;switch (fmt) {- case dnnl::memory::format_tag::ab:- strides.push_back(1);- strides.push_back(padded_dims[0]);- break;-- case dnnl::memory::format_tag::abc:- strides.push_back(1);- strides.push_back(padded_dims[0]);- strides.push_back(padded_dims[0] * padded_dims[1]);- break;-- case dnnl::memory::format_tag::acb:- strides.push_back(1);- strides.push_back(padded_dims[0]);- strides.push_back(padded_dims[0] * padded_dims[2]);- break;-- case dnnl::memory::format_tag::abdc:- strides.push_back(1);- strides.push_back(padded_dims[0]);- strides.push_back(padded_dims[0] * padded_dims[1]);- strides.push_back(padded_dims[0] * padded_dims[1] * padded_dims[3]);- break;-- case dnnl::memory::format_tag::abced:- strides.push_back(1);- strides.push_back(padded_dims[0]);- strides.push_back(padded_dims[0] * padded_dims[1]);- strides.push_back(padded_dims[0] * padded_dims[1] * padded_dims[2]);- strides.push_back(padded_dims[0] * padded_dims[1] * padded_dims[2] * padded_dims[4]);- break;-- case dnnl::memory::format_tag::abcdfe:- strides.push_back(1);- strides.push_back(padded_dims[0]);- strides.push_back(padded_dims[0] * padded_dims[1]);- strides.push_back(padded_dims[0] * padded_dims[1] * padded_dims[2]);- strides.push_back(padded_dims[0] * padded_dims[1] * padded_dims[2] * padded_dims[3]);- strides.push_back(padded_dims[0] * padded_dims[1] * padded_dims[2] * padded_dims[3] * padded_dims[5]);- break;-- case dnnl::memory::format_tag::ba:- strides.push_back(1);- strides.push_back(padded_dims[1]);- break;-- default: {- auto pitches = _layout.get_pitches();- strides.assign(pitches.begin(), pitches.end());- break;- }+ case dnnl::memory::format_tag::ab:+ strides.push_back(1);+ strides.push_back(padded_dims[0]);+ break;++ case dnnl::memory::format_tag::abc:+ strides.push_back(1);+ strides.push_back(padded_dims[0]);+ strides.push_back(padded_dims[0] * padded_dims[1]);+ break;++ case dnnl::memory::format_tag::acb:+ strides.push_back(1);+ strides.push_back(padded_dims[0]);+ strides.push_back(padded_dims[0] * padded_dims[2]);+ break;++ case dnnl::memory::format_tag::abdc:+ strides.push_back(1);+ strides.push_back(padded_dims[0]);+ strides.push_back(padded_dims[0] * padded_dims[1]);+ strides.push_back(padded_dims[0] * padded_dims[1] * padded_dims[3]);+ break;++ case dnnl::memory::format_tag::abced:+ strides.push_back(1);+ strides.push_back(padded_dims[0]);+ strides.push_back(padded_dims[0] * padded_dims[1]);+ strides.push_back(padded_dims[0] * padded_dims[1] * padded_dims[2]);+ strides.push_back(padded_dims[0] * padded_dims[1] * padded_dims[2] * padded_dims[4]);+ break;++ case dnnl::memory::format_tag::abcdfe:+ strides.push_back(1);+ strides.push_back(padded_dims[0]);+ strides.push_back(padded_dims[0] * padded_dims[1]);+ strides.push_back(padded_dims[0] * padded_dims[1] * padded_dims[2]);+ strides.push_back(padded_dims[0] * padded_dims[1] * padded_dims[2] * padded_dims[3]);+ strides.push_back(padded_dims[0] * padded_dims[1] * padded_dims[2] * padded_dims[3] * padded_dims[5]);+ break;++ case dnnl::memory::format_tag::ba:+ strides.push_back(1);+ strides.push_back(padded_dims[1]);+ break;++ default: {+ auto pitches = _layout.get_pitches();+ strides.assign(pitches.begin(), pitches.end());+ break;+ }}return strides;}@@ -545,8 +570,10 @@ dnnl::memory::desc layout_to_memory_desc(cldnn::layout l, bool use_default_formareturn md.build();}-std::tuple<dnnl::memory::desc, dnnl::memory::desc, dnnl::memory::desc>-get_conv_memory_descs(cldnn::layout input_layout, cldnn::layout weights_layout, cldnn::layout output_layout, dnnl::memory::format_tag target_fmt) {+std::tuple<dnnl::memory::desc, dnnl::memory::desc, dnnl::memory::desc> get_conv_memory_descs(cldnn::layout input_layout,+ cldnn::layout weights_layout,+ cldnn::layout output_layout,+ dnnl::memory::format_tag target_fmt) {bool need_blocked = input_layout.format.is_blocked() || output_layout.format.is_blocked();bool is_grouped = format::is_grouped(weights_layout.format);@@ -571,17 +598,18 @@ get_conv_memory_descs(cldnn::layout input_layout, cldnn::layout weights_layout,return {input_desc, weights_desc, output_desc};}-static void get_identical_order(std::vector<std::vector<size_t>>& orders, std::vector<size_t> order,- size_t first, size_t depth) {- if (depth == 0)+static void get_identical_order(std::vector<std::vector<size_t>>& orders, std::vector<size_t> order, size_t first, size_t depth) {+ if (depth == 0) {return;+ }- for (size_t idx = first; idx <= first + depth ; idx++) {+ for (size_t idx = first; idx <= first + depth; idx++) {std::swap(order[first], order[idx]);- if (first != idx)+ if (first != idx) {orders.push_back(order);+ }- get_identical_order(orders, order, first+1, depth-1);+ get_identical_order(orders, order, first + 1, depth - 1);std::swap(order[first], order[idx]);}}@@ -591,18 +619,17 @@ std::vector<std::vector<size_t>> get_candidate_orders(dnnl::memory::desc desc) {auto strides = desc.get_strides();std::vector<size_t> order(desc.get_ndims());std::iota(order.begin(), order.end(), 0);- std::sort(order.begin(), order.end(),- [&strides] (size_t ind_l, size_t ind_r) {- return (strides[ind_l] > strides[ind_r]);- });+ std::sort(order.begin(), order.end(), [&strides](size_t ind_l, size_t ind_r) {+ return (strides[ind_l] > strides[ind_r]);+ });orders.push_back(order);// Orders of those axes which have a same stride in memory::desc can be changed.// If y and x axes have same, then it can be bfyx or bfxy.- for (size_t idx = 0 ; idx+1 < order.size() ; idx++) {+ for (size_t idx = 0; idx + 1 < order.size(); idx++) {size_t depth = 0;- for (size_t next = idx+1 ; next < order.size() ; next++) {+ for (size_t next = idx + 1; next < order.size(); next++) {if (strides[order[idx]] == strides[order[next]]) {depth++;} else {@@ -619,9 +646,10 @@ std::vector<std::vector<size_t>> get_candidate_orders(dnnl::memory::desc desc) {}static bool compare_orders(std::vector<std::vector<size_t>> a, std::vector<size_t> b) {- for (size_t idx = 0 ; idx < a.size() ; idx++) {- if (std::equal(a[idx].begin(), a[idx].end(), b.begin()))+ for (size_t idx = 0; idx < a.size(); idx++) {+ if (std::equal(a[idx].begin(), a[idx].end(), b.begin())) {return true;+ }}return false;@@ -630,27 +658,27 @@ static bool compare_orders(std::vector<std::vector<size_t>> a, std::vector<size_cldnn::format find_data_format(dnnl::memory::desc desc) {auto order = get_candidate_orders(desc);- for (int32_t fmt_idx = format::bfyx ; fmt_idx < format::oiyx ; fmt_idx++) {+ for (int32_t fmt_idx = format::bfyx; fmt_idx < format::oiyx; fmt_idx++) {auto candidate_trait = format::traits(static_cast<format::type>(fmt_idx));- if (desc.get_ndims() == static_cast<int>(candidate_trait._order.size())- && desc.get_inner_nblks() == static_cast<int>(candidate_trait.block_sizes.size())- && compare_orders(order, candidate_trait._order)) {+ if (desc.get_ndims() == static_cast<int>(candidate_trait._order.size()) &&+ desc.get_inner_nblks() == static_cast<int>(candidate_trait.block_sizes.size()) && compare_orders(order, candidate_trait._order)) {bool is_match = true;- for (size_t idx = 0 ; idx < candidate_trait.block_sizes.size() ; idx++) {- if (desc.get_inner_blks()[idx] != static_cast<int>(candidate_trait.block_sizes[idx].second)- || desc.get_inner_idxs()[idx] != static_cast<int>(candidate_trait.block_sizes[idx].first)) {+ for (size_t idx = 0; idx < candidate_trait.block_sizes.size(); idx++) {+ if (desc.get_inner_blks()[idx] != static_cast<int>(candidate_trait.block_sizes[idx].second) ||+ desc.get_inner_idxs()[idx] != static_cast<int>(candidate_trait.block_sizes[idx].first)) {is_match = false;break;}}- if (is_match)+ if (is_match) {return static_cast<format::type>(fmt_idx);+ }}}if (desc.get_ndims() == 3 && desc.get_inner_nblks() == 0) {// Special case for 3D tensors without blocking- if (compare_orders(order, { {0, 1, 2} })) {+ if (compare_orders(order, {{0, 1, 2}})) {return static_cast<format::type>(format::bfyx);}if (compare_orders(order, {{0, 2, 1}})) {@@ -665,12 +693,11 @@ cldnn::format find_data_format(dnnl::memory::desc desc) {}std::stringstream msg;- msg << "Unsupported onednn dnnl::memory::desc find_data_format. "- << "ndims: " << desc.get_ndims()- << ", inner_nblks: " << desc.get_inner_nblks()+ msg << "Unsupported onednn dnnl::memory::desc find_data_format. " << "ndims: " << desc.get_ndims() << ", inner_nblks: " << desc.get_inner_nblks()<< ", inner_blks: ";- for (int i = 0; i < desc.get_inner_nblks(); i++)+ for (int i = 0; i < desc.get_inner_nblks(); i++) {msg << "(blk " << desc.get_inner_blks()[i] << ", idx " << desc.get_inner_idxs()[i] << ") ";+ }throw std::runtime_error(msg.str());}@@ -679,24 +706,23 @@ cldnn::format find_format(dnnl::memory::desc desc, bool is_grouped) {auto orders = get_candidate_orders(desc);format start_format = format::oiyx;- if (is_grouped)+ if (is_grouped) {start_format = format::goiyx;+ }- for (int32_t fmt_idx = start_format ; fmt_idx < format::format_num ; fmt_idx++) {+ for (int32_t fmt_idx = start_format; fmt_idx < format::format_num; fmt_idx++) {auto candidate_trait = format::traits(static_cast<format::type>(fmt_idx));- if (static_cast<size_t>(desc.get_ndims()) == candidate_trait._order.size()- && static_cast<size_t>(desc.get_inner_nblks()) == candidate_trait.block_sizes.size()- && compare_orders(orders, candidate_trait._order)) {+ if (static_cast<size_t>(desc.get_ndims()) == candidate_trait._order.size() &&+ static_cast<size_t>(desc.get_inner_nblks()) == candidate_trait.block_sizes.size() && compare_orders(orders, candidate_trait._order)) {// Compare all pairs of dimension number and block size to format_traits_map of all formatsbool is_match = true;- for (size_t idx = 0 ; idx < candidate_trait.block_sizes.size() ; idx++) {+ for (size_t idx = 0; idx < candidate_trait.block_sizes.size(); idx++) {auto block_idx = static_cast<dnnl_dim_t>(candidate_trait.block_sizes[idx].first);auto block_size = static_cast<dnnl_dim_t>(candidate_trait.block_sizes[idx].second);if (is_grouped && candidate_trait.is_group_char(candidate_trait.internal_order[block_idx])) {// inner_idx gets the index of group dimension in mem::desc when blocked axis is groupauto inner_idx = candidate_trait.order.find_first_of(candidate_trait.internal_order[block_idx]);- if (desc.get_inner_blks()[idx] != block_size ||- desc.get_inner_idxs()[idx] != static_cast<dnnl_dim_t>(inner_idx)) {+ if (desc.get_inner_blks()[idx] != block_size || desc.get_inner_idxs()[idx] != static_cast<dnnl_dim_t>(inner_idx)) {is_match = false;break;}@@ -708,35 +734,35 @@ cldnn::format find_format(dnnl::memory::desc desc, bool is_grouped) {break;}} else {- if (desc.get_inner_blks()[idx] != block_size ||- desc.get_inner_idxs()[idx] != block_idx) {+ if (desc.get_inner_blks()[idx] != block_size || desc.get_inner_idxs()[idx] != block_idx) {is_match = false;break;}}}- if (is_match)+ if (is_match) {return static_cast<format::type>(fmt_idx);+ }}}std::stringstream msg;- msg << "Unsupported " << (is_grouped ? "grouped" : "") << "onednn dnnl::memory::desc find_format. "- << "ndims: " << desc.get_ndims()- << ", inner_nblks: " << desc.get_inner_nblks()- << ", inner_blks: ";- for (int i = 0; i < desc.get_inner_nblks(); i++)+ msg << "Unsupported " << (is_grouped ? "grouped" : "") << "onednn dnnl::memory::desc find_format. " << "ndims: " << desc.get_ndims()+ << ", inner_nblks: " << desc.get_inner_nblks() << ", inner_blks: ";+ for (int i = 0; i < desc.get_inner_nblks(); i++) {msg << "(blk " << desc.get_inner_blks()[i] << ", idx " << desc.get_inner_idxs()[i] << ") ";+ }for (auto order : orders) {msg << ", strides_order : ";- for (const auto& value : order)+ for (const auto& value : order) {msg << value << " ";+ }}msg << ", stride_value : ";auto strides = desc.get_strides();- for (size_t idx = 0; idx < orders[0].size() ; idx++) {+ for (size_t idx = 0; idx < orders[0].size(); idx++) {msg << strides[idx] << " ";}@@ -746,27 +772,47 @@ cldnn::format find_format(dnnl::memory::desc desc, bool is_grouped) {// Currently, usage of alpha and beta between cldnn::pow and dnnl::eltwise::pow is different : d = pow(src, a) / d = a * pow(src, b)dnnl::algorithm convert_activation_func(cldnn::activation_func func) {switch (func) {- case cldnn::activation_func::relu: return dnnl::algorithm::eltwise_relu;- case cldnn::activation_func::relu_negative_slope: return dnnl::algorithm::eltwise_relu;- case cldnn::activation_func::gelu: return dnnl::algorithm::eltwise_gelu_erf;- case cldnn::activation_func::gelu_tanh: return dnnl::algorithm::eltwise_gelu_tanh;- case cldnn::activation_func::elu: return dnnl::algorithm::eltwise_elu;- case cldnn::activation_func::mish: return dnnl::algorithm::eltwise_mish;- case cldnn::activation_func::swish: return dnnl::algorithm::eltwise_swish;- case cldnn::activation_func::hswish: return dnnl::algorithm::eltwise_hardswish;- case cldnn::activation_func::abs: return dnnl::algorithm::eltwise_abs;- case cldnn::activation_func::exp: return dnnl::algorithm::eltwise_exp;- case cldnn::activation_func::logistic: return dnnl::algorithm::eltwise_logistic;- case cldnn::activation_func::clamp: return dnnl::algorithm::eltwise_clip;- case cldnn::activation_func::hyperbolic_tan: return dnnl::algorithm::eltwise_tanh;- case cldnn::activation_func::pow: return dnnl::algorithm::eltwise_pow;- case cldnn::activation_func::sqrt: return dnnl::algorithm::eltwise_sqrt;- case cldnn::activation_func::square: return dnnl::algorithm::eltwise_square;- case cldnn::activation_func::hard_sigmoid: return dnnl::algorithm::eltwise_hardsigmoid;- // Activations that are undef algorithms must be converted to other activations before pushing to post-op.- case cldnn::activation_func::hsigmoid: return dnnl::algorithm::undef;- case cldnn::activation_func::negative: return dnnl::algorithm::undef;- default: throw std::runtime_error("Unsupported activation func for onednn primitive " + std::to_string(static_cast<int>(func)));+ case cldnn::activation_func::relu:+ return dnnl::algorithm::eltwise_relu;+ case cldnn::activation_func::relu_negative_slope:+ return dnnl::algorithm::eltwise_relu;+ case cldnn::activation_func::gelu:+ return dnnl::algorithm::eltwise_gelu_erf;+ case cldnn::activation_func::gelu_tanh:+ return dnnl::algorithm::eltwise_gelu_tanh;+ case cldnn::activation_func::elu:+ return dnnl::algorithm::eltwise_elu;+ case cldnn::activation_func::mish:+ return dnnl::algorithm::eltwise_mish;+ case cldnn::activation_func::swish:+ return dnnl::algorithm::eltwise_swish;+ case cldnn::activation_func::hswish:+ return dnnl::algorithm::eltwise_hardswish;+ case cldnn::activation_func::abs:+ return dnnl::algorithm::eltwise_abs;+ case cldnn::activation_func::exp:+ return dnnl::algorithm::eltwise_exp;+ case cldnn::activation_func::logistic:+ return dnnl::algorithm::eltwise_logistic;+ case cldnn::activation_func::clamp:+ return dnnl::algorithm::eltwise_clip;+ case cldnn::activation_func::hyperbolic_tan:+ return dnnl::algorithm::eltwise_tanh;+ case cldnn::activation_func::pow:+ return dnnl::algorithm::eltwise_pow;+ case cldnn::activation_func::sqrt:+ return dnnl::algorithm::eltwise_sqrt;+ case cldnn::activation_func::square:+ return dnnl::algorithm::eltwise_square;+ case cldnn::activation_func::hard_sigmoid:+ return dnnl::algorithm::eltwise_hardsigmoid;+ // Activations that are undef algorithms must be converted to other activations before pushing to post-op.+ case cldnn::activation_func::hsigmoid:+ return dnnl::algorithm::undef;+ case cldnn::activation_func::negative:+ return dnnl::algorithm::undef;+ default:+ throw std::runtime_error("Unsupported activation func for onednn primitive " + std::to_string(static_cast<int>(func)));}}@@ -776,7 +822,7 @@ bool is_per_tensor(cldnn::data_node& node, int32_t& zp_val) {auto* engine = ptr->get_engine();auto& stream = engine->get_service_stream();auto num_elems = node.get_output_layout().count();- mem_lock<T, mem_lock_type::read> old_data {ptr, stream};+ mem_lock<T, mem_lock_type::read> old_data{ptr, stream};auto val = old_data[0];for (size_t i = 1; i < num_elems; i++) {if (val != old_data[i]) {@@ -793,7 +839,6 @@ template bool is_per_tensor<int8_t>(cldnn::data_node& node, int32_t& zp_val);template bool is_per_tensor<uint8_t>(cldnn::data_node& node, int32_t& zp_val);template bool is_per_tensor<int32_t>(cldnn::data_node& node, int32_t& zp_val);-static std::string get_external_order(const std::vector<size_t>& order, bool is_weights, bool is_grouped) {cldnn::format default_fmt = format::get_default_format(order.size(), is_weights, is_grouped);const auto& default_order = default_fmt.order();@@ -842,9 +887,7 @@ cldnn::format_traits convert_memory_desc_to_traits(const dnnl::memory::desc& desconst int group_num = is_grouped ? 1 : 0;const int spatial_size = std::max<int>(ndims - batch_num - feature_num - group_num, 0);- std::string internal_order = is_weights ?- (is_grouped ? "oixyz???g" : "oixyz") :- "bfxyzwuv";+ std::string internal_order = is_weights ? (is_grouped ? "oixyz???g" : "oixyz") : "bfxyzwuv";const size_t max_spatial = 2 + (is_weights ? 3 : 6);const size_t last_spatial_offset = 2 + spatial_size;@@ -883,27 +926,33 @@ cldnn::format_traits convert_memory_desc_to_traits(const dnnl::memory::desc& des* If the shape is expanded from 4D to 5D, the format of the input layout is also updated accordingly.*/bool keep_weights_reorder_shape_consistent(cldnn::layout& layout, const dnnl::memory::desc& desc) {- if (layout.is_dynamic())+ if (layout.is_dynamic()) {return false;+ }auto shape = layout.get_shape();auto dims = desc.get_dims();std::vector<ov::Dimension::value_type> target_dims;std::vector<ov::Dimension::value_type> filtered_target_dims;- std::transform(shape.begin(), shape.end(), std::back_inserter(target_dims),- [](size_t v) { return static_cast<ov::Dimension::value_type>(v); });- std::copy_if(target_dims.begin(), target_dims.end(), std::back_inserter(filtered_target_dims),- [](ov::Dimension::value_type i) { return i != 1; });+ std::transform(shape.begin(), shape.end(), std::back_inserter(target_dims), [](size_t v) {+ return static_cast<ov::Dimension::value_type>(v);+ });+ std::copy_if(target_dims.begin(), target_dims.end(), std::back_inserter(filtered_target_dims), [](ov::Dimension::value_type i) {+ return i != 1;+ });std::vector<ov::Dimension::value_type> desc_dims;std::vector<ov::Dimension::value_type> filtered_desc_dims;- std::transform(dims.cbegin(), dims.cend(), std::back_inserter(desc_dims),- [](dnnl::memory::dim v) { return static_cast<ov::Dimension::value_type>(v); });- std::copy_if(desc_dims.begin(), desc_dims.end(), std::back_inserter(filtered_desc_dims),- [](ov::Dimension::value_type i) { return i != 1; });+ std::transform(dims.cbegin(), dims.cend(), std::back_inserter(desc_dims), [](dnnl::memory::dim v) {+ return static_cast<ov::Dimension::value_type>(v);+ });+ std::copy_if(desc_dims.begin(), desc_dims.end(), std::back_inserter(filtered_desc_dims), [](ov::Dimension::value_type i) {+ return i != 1;+ });- if (filtered_target_dims != filtered_desc_dims)- return false; // We cannot keep the shapes consistent+ if (filtered_target_dims != filtered_desc_dims) {+ return false; // We cannot keep the shapes consistent+ }layout.set_partial_shape(desc_dims);if (layout.get_rank() == desc_dims.size()) {@@ -948,10 +997,10 @@ bool is_supported_post_ops(const program_node& node) {if (fo.is_type<activation>()) {// Some activations aren't implemented in oneDNNauto activation_prim = fo.typed_desc<activation>();- if (activation_prim->activation_function == activation_func::negative ||- activation_prim->activation_function == activation_func::negation ||- activation_prim->activation_function == activation_func::sign)+ if (activation_prim->activation_function == activation_func::negative || activation_prim->activation_function == activation_func::negation ||+ activation_prim->activation_function == activation_func::sign) {return false;+ }}}@@ -959,8 +1008,9 @@ bool is_supported_post_ops(const program_node& node) {}bool is_supported_pad(const layout& layout) {- if (!layout.data_padding)+ if (!layout.data_padding) {return true;+ }const auto& pad = layout.data_padding;// Check spatial padding@@ -983,8 +1033,8 @@ bool is_supported_pad(const layout& layout) {}int get_prelu_mask_from_layouts(const std::function<layout()>& get_output_layout,- const std::function<layout(int32_t)>& get_input_layout,- int32_t slope_input_idx) {+ const std::function<layout(int32_t)>& get_input_layout,+ int32_t slope_input_idx) {auto output_layout = get_output_layout();auto slope_layout = get_input_layout(slope_input_idx);auto input_layout = get_input_layout(0);@@ -994,23 +1044,32 @@ int get_prelu_mask_from_layouts(const std::function<layout()>& get_output_layoutbool is_scalar = true;for (size_t i = 0; i < slope_shape.size(); i++) {- if (slope_shape[i] != 1)+ if (slope_shape[i] != 1) {is_scalar = false;+ }}- if (is_scalar)+ if (is_scalar) {return 0;+ }return (1 << 1);}std::string dnnl_status_to_string(dnnl_status_t status) {switch (status) {- case dnnl_success: return "dnnl_success";- case dnnl_out_of_memory: return "dnnl_out_of_memory";- case dnnl_invalid_arguments: return "dnnl_invalid_arguments";- case dnnl_unimplemented: return "dnnl_unimplemented";- case dnnl_runtime_error: return "dnnl_runtime_error";- case dnnl_not_required: return "dnnl_not_required";- default: return "dnnl_status_unknown";+ case dnnl_success:+ return "dnnl_success";+ case dnnl_out_of_memory:+ return "dnnl_out_of_memory";+ case dnnl_invalid_arguments:+ return "dnnl_invalid_arguments";+ case dnnl_unimplemented:+ return "dnnl_unimplemented";+ case dnnl_runtime_error:+ return "dnnl_runtime_error";+ case dnnl_not_required:+ return "dnnl_not_required";+ default:+ return "dnnl_status_unknown";}}diff --git a/src/plugins/intel_gpu/src/graph/include/convolution_inst.h b/src/plugins/intel_gpu/src/graph/include/convolution_inst.hindex fe008ab2c43..b5762d6ff27 100644--- a/src/plugins/intel_gpu/src/graph/include/convolution_inst.h+++ b/src/plugins/intel_gpu/src/graph/include/convolution_inst.h@@ -34,8 +34,9 @@ public:int32_t get_deform_conv_dep_offset() const {auto offset = deformable_mode ? 1 : 0;- if (get_primitive()->input.size() == 3)+ if (get_primitive()->input.size() == 3) {offset++;+ }return offset;}@@ -62,22 +63,25 @@ public:}program_node& trans() const {- if (!deformable_mode)+ if (!deformable_mode) {throw std::range_error("trans input exists only in deformable mode");+ }return get_dependency(1);}program_node& mask() const {- if (!deformable_mode)+ if (!deformable_mode) {throw std::range_error("Mask input exists only in deformable mode");+ }return get_dependency(2);}bool bilinear_interpolation_pad() const {- if (!deformable_mode)+ if (!deformable_mode) {throw std::range_error("bilinear_interpolation_pad exists only in deformable mode");+ }return get_primitive()->bilinear_interpolation_pad;}@@ -98,14 +102,18 @@ public:std::unique_ptr<kernel_impl_params> get_kernel_impl_params(const std::vector<layout>& in_layouts, const std::vector<layout>& out_layouts) const override {auto params = parent::get_kernel_impl_params(in_layouts, out_layouts);params->weights_layout = optional_layout(weights().get_output_layout());- if (bias_term())+ if (bias_term()) {params->bias_layout = optional_layout(bias().get_output_layout());- if (weights_zero_points_term())+ }+ if (weights_zero_points_term()) {params->weights_zero_points_layout = optional_layout(weights_zero_points().get_output_layout());- if (activations_zero_points_term())+ }+ if (activations_zero_points_term()) {params->activations_zero_points_layout = optional_layout(activations_zero_points().get_output_layout());- if (compensation_term())+ }+ if (compensation_term()) {params->compensation_layout = optional_layout(compensation().get_output_layout());+ }return params;}@@ -129,8 +137,9 @@ public:static std::string to_string(convolution_node const& node);bool need_reset_input_memory(size_t idx = 0) const override {- if (idx != 0)+ if (idx != 0) {return false;+ }auto input_layout = _deps[0].first->_impl_params->get_output_layout(0);return static_cast<bool>(input_layout.data_padding);@@ -165,8 +174,9 @@ public:}memory::ptr trans_memory() const {- if (_deform_conv_dep_offset == 0)+ if (_deform_conv_dep_offset == 0) {throw std::range_error("trans input exists only in deformable mode");+ }return dep_memory_ptr(1);}diff --git a/src/plugins/intel_gpu/src/graph/include/deconvolution_inst.h b/src/plugins/intel_gpu/src/graph/include/deconvolution_inst.hindex 66544df083e..1b6e43b4945 100644--- a/src/plugins/intel_gpu/src/graph/include/deconvolution_inst.h+++ b/src/plugins/intel_gpu/src/graph/include/deconvolution_inst.h@@ -34,8 +34,9 @@ public:std::vector<size_t> get_shape_infer_dependencies() const override {auto prim = get_primitive();- if (!prim->output_shape_id.is_valid())+ if (!prim->output_shape_id.is_valid()) {return {};+ }return {prim->dependencies().size() - 1};}@@ -43,8 +44,9 @@ public:std::unique_ptr<kernel_impl_params> get_kernel_impl_params(const std::vector<layout>& in_layouts, const std::vector<layout>& out_layouts) const override {auto params = parent::get_kernel_impl_params(in_layouts, out_layouts);params->weights_layout = optional_layout(weights().get_output_layout());- if (bias_term())+ if (bias_term()) {params->bias_layout = optional_layout(bias().get_output_layout());+ }return params;}@@ -66,8 +68,9 @@ public:static std::string to_string(deconvolution_node const& node);bool need_reset_input_memory(size_t idx = 0) const override {- if (idx != 0)+ if (idx != 0) {return false;+ }auto input_layout = _deps[0].first->_impl_params->get_output_layout(0);return static_cast<bool>(input_layout.data_padding);diff --git a/src/plugins/intel_gpu/src/graph/include/dft_inst.h b/src/plugins/intel_gpu/src/graph/include/dft_inst.hindex c9557d341bf..356f6bb6bbf 100644--- a/src/plugins/intel_gpu/src/graph/include/dft_inst.h+++ b/src/plugins/intel_gpu/src/graph/include/dft_inst.h@@ -16,10 +16,13 @@ struct typed_program_node<dft> : public typed_program_node_base<dft> {public:using parent::parent;- program_node& input(size_t idx = 0) const { return get_dependency(idx); }+ program_node& input(size_t idx = 0) const {+ return get_dependency(idx);+ }std::vector<size_t> get_shape_infer_dependencies() const override {- if (this->get_dependencies().size() == 3)+ if (this->get_dependencies().size() == 3) {return {1, 2};+ }return {1};}};@@ -32,12 +35,12 @@ class typed_primitive_inst<dft> : public typed_primitive_inst_base<dft> {using parent::parent;public:- template<typename ShapeType>- static std::vector<layout> calc_output_layouts(dft_node const& /*node*/, kernel_impl_params const& impl_param);- static layout calc_output_layout(dft_node const& node, kernel_impl_params const& impl_param);- static std::string to_string(dft_node const& node);+ template <typename ShapeType>+ static std::vector<layout> calc_output_layouts(const dft_node& /*node*/, const kernel_impl_params& impl_param);+ static layout calc_output_layout(const dft_node& node, const kernel_impl_params& impl_param);+ static std::string to_string(const dft_node& node);- typed_primitive_inst(network& network, dft_node const& node);+ typed_primitive_inst(network& network, const dft_node& node);};using dft_inst = typed_primitive_inst<dft>;diff --git a/src/plugins/intel_gpu/src/graph/include/fully_connected_inst.h b/src/plugins/intel_gpu/src/graph/include/fully_connected_inst.hindex 4dae8560f17..77810dea9ae 100644--- a/src/plugins/intel_gpu/src/graph/include/fully_connected_inst.h+++ b/src/plugins/intel_gpu/src/graph/include/fully_connected_inst.h@@ -30,8 +30,9 @@ public:std::unique_ptr<kernel_impl_params> get_kernel_impl_params(const std::vector<layout>& in_layouts, const std::vector<layout>& out_layouts) const override {auto params = parent::get_kernel_impl_params(in_layouts, out_layouts);params->weights_layout = optional_layout(weights().get_output_layout());- if (bias_term())+ if (bias_term()) {params->bias_layout = optional_layout(bias().get_output_layout());+ }return params;}};diff --git a/src/plugins/intel_gpu/src/graph/include/gru_seq_inst.h b/src/plugins/intel_gpu/src/graph/include/gru_seq_inst.hindex 070615c9fcd..5f7377f24c9 100644--- a/src/plugins/intel_gpu/src/graph/include/gru_seq_inst.h+++ b/src/plugins/intel_gpu/src/graph/include/gru_seq_inst.h@@ -48,8 +48,9 @@ public:lstm_weights_order offset_order() const { return get_typed_desc<gru_seq>()->offset_order; }float clip() const {float clip_val = get_typed_desc<gru_seq>()->clip;- if (clip_val < 0)+ if (clip_val < 0) {throw std::range_error("Clip value < 0");+ }return clip_val;}uint32_t direction() const { return get_typed_desc<gru_seq>()->direction == ov::op::RecurrentSequenceDirection::FORWARD ? 0 : 1; }diff --git a/src/plugins/intel_gpu/src/graph/include/istft_inst.h b/src/plugins/intel_gpu/src/graph/include/istft_inst.hindex 36a156178db..f087b06b120 100644--- a/src/plugins/intel_gpu/src/graph/include/istft_inst.h+++ b/src/plugins/intel_gpu/src/graph/include/istft_inst.h@@ -21,8 +21,9 @@ public:return get_dependency(idx);}std::vector<size_t> get_shape_infer_dependencies() const override {- if (this->get_dependencies().size() == 5)+ if (this->get_dependencies().size() == 5) {return {2, 3, 4};+ }return {2, 3};}};@@ -35,11 +36,11 @@ class typed_primitive_inst<ISTFT> : public typed_primitive_inst_base<ISTFT> {using parent::parent;public:- typed_primitive_inst(network& network, ISTFT_node const& desc);+ typed_primitive_inst(network& network, const ISTFT_node& desc);template <typename ShapeType>- static std::vector<layout> calc_output_layouts(ISTFT_node const& node, kernel_impl_params const& impl_param);- static layout calc_output_layout(ISTFT_node const& node, kernel_impl_params const& impl_param);- static std::string to_string(ISTFT_node const& node);+ static std::vector<layout> calc_output_layouts(const ISTFT_node& node, const kernel_impl_params& impl_param);+ static layout calc_output_layout(const ISTFT_node& node, const kernel_impl_params& impl_param);+ static std::string to_string(const ISTFT_node& node);bool need_reset_output_memory() const override {return true;}diff --git a/src/plugins/intel_gpu/src/graph/include/kv_cache_inst.h b/src/plugins/intel_gpu/src/graph/include/kv_cache_inst.hindex 0dfc76816c1..ac94c93dc89 100644--- a/src/plugins/intel_gpu/src/graph/include/kv_cache_inst.h+++ b/src/plugins/intel_gpu/src/graph/include/kv_cache_inst.h@@ -77,8 +77,9 @@ public:}static int64_t get_max_pad(const layout& target_layout, size_t buffer_size, int64_t sequence_axis, std::string target_name = "") {- if (buffer_size == 0)+ if (buffer_size == 0) {return 0;+ }const size_t total_elements = target_layout.count();const int64_t concat_axis_size = target_layout.get_shape()[sequence_axis];const int64_t sequence_element_size = total_elements / concat_axis_size;diff --git a/src/plugins/intel_gpu/src/graph/include/layout_optimizer.h b/src/plugins/intel_gpu/src/graph/include/layout_optimizer.hindex 4b808ad1dfa..694443566b5 100644--- a/src/plugins/intel_gpu/src/graph/include/layout_optimizer.h+++ b/src/plugins/intel_gpu/src/graph/include/layout_optimizer.h@@ -4,22 +4,21 @@#pragma once-#include "intel_gpu/runtime/memory.hpp"-#include "intel_gpu/runtime/engine.hpp"-#include "intel_gpu/runtime/utils.hpp"-#include "intel_gpu/runtime/lru_cache.hpp"+#include <map>+#include <memory>+#include <utility>+#include <vector>-#include "data_inst.h"-#include "reorder_inst.h"#include "convolution_inst.h"+#include "data_inst.h"#include "deconvolution_inst.h"#include "detection_output_inst.h"+#include "intel_gpu/runtime/engine.hpp"+#include "intel_gpu/runtime/lru_cache.hpp"+#include "intel_gpu/runtime/memory.hpp"+#include "intel_gpu/runtime/utils.hpp"#include "quantize_inst.h"--#include <vector>-#include <memory>-#include <map>-#include <utility>+#include "reorder_inst.h"namespace cldnn {@@ -28,23 +27,26 @@ struct reorder_cache_key {primitive_id data_source;layout expected_layout;- friend bool operator==(reorder_cache_key const& lhs, reorder_cache_key const& rhs) {+ friend bool operator==(const reorder_cache_key& lhs, const reorder_cache_key& rhs) {bool ret = lhs.data_source == rhs.data_source && lhs.expected_layout == rhs.expected_layout;if (ret && lhs.expected_layout.format == cldnn::format::custom) {- ret &= (lhs.expected_layout.format.traits().block_sizes ==- rhs.expected_layout.format.traits().block_sizes);+ ret &= (lhs.expected_layout.format.traits().block_sizes == rhs.expected_layout.format.traits().block_sizes);}return ret;}- friend bool operator!=(reorder_cache_key const& lhs, reorder_cache_key const& rhs) { return !(lhs == rhs); }+ friend bool operator!=(const reorder_cache_key& lhs, const reorder_cache_key& rhs) {+ return !(lhs == rhs);+ }- friend bool operator<(reorder_cache_key const& lhs, reorder_cache_key const& rhs) {- if (lhs.data_source != rhs.data_source)+ friend bool operator<(const reorder_cache_key& lhs, const reorder_cache_key& rhs) {+ if (lhs.data_source != rhs.data_source) {return (lhs.data_source < rhs.data_source);- if (lhs.expected_layout != rhs.expected_layout)+ }+ if (lhs.expected_layout != rhs.expected_layout) {return (lhs.expected_layout < rhs.expected_layout);+ }return lhs.expected_layout.format.traits().block_sizes < rhs.expected_layout.format.traits().block_sizes;}};@@ -65,17 +67,11 @@ class reorder_factory {public:// pair.first is reorder (may be nullptr if reorder is not needed), pair.second tells if returned reorder was cached// (no need to add it to 'ouputs' etc.) for pair.first == nullptr, pair.second == true- std::pair<std::shared_ptr<reorder>, bool> get_reorder(primitive_id src_id,- int32_t src_port,- const layout& in_layout,- const layout& out_layout);+ std::pair<std::shared_ptr<reorder>, bool> get_reorder(primitive_id src_id, int32_t src_port, const layout& in_layout, const layout& out_layout);- std::pair<std::shared_ptr<reorder>, bool> get_reorder(primitive_id src_id,- const layout& in_layout,- const layout& out_layout);+ std::pair<std::shared_ptr<reorder>, bool> get_reorder(primitive_id src_id, const layout& in_layout, const layout& out_layout);- std::pair<std::shared_ptr<primitive>, bool> get_weights_reorder(primitive_id input_id,- std::shared_ptr<WeightsReorderParams> reorder_params);+ std::pair<std::shared_ptr<primitive>, bool> get_weights_reorder(primitive_id input_id, std::shared_ptr<WeightsReorderParams> reorder_params);private:std::map<reorder_cache_key, std::shared_ptr<reorder>> _cached_reorders;@@ -159,28 +155,22 @@ private:size_t _total_conv;std::map<std::pair<format::type, bool>, size_t> _optimized_conv_count;- format get_expected_format(convolution_node const& node);- format get_expected_format(deconvolution_node const& node);- format get_expected_format(quantize_node const& node);+ format get_expected_format(const convolution_node& node);+ format get_expected_format(const deconvolution_node& node);+ format get_expected_format(const quantize_node& node);void set_onednn_dyn_conv_preferred_format(convolution_node& node);bool is_depthwise(const convolution_node& node) const;- format imad_case(convolution_node const& node) const;+ format imad_case(const convolution_node& node) const;// custom_list// - first is i8_u8 formats as b_fs_yx_fsv32, bs_fs_yx_bsv32_fsv32.// - second is float formats as b_fs_yx_fsv16, bs_fs_yx_bsv32_fsv16.- bool is_mixed_layout(program_node& prev, program_node& next,- bool check_data_type = true, std::vector<std::pair<format, format>> custom_list = {}) const;-- bool convolution_bfyx_opt(const layout& output_layout,- const layout& weights_layout,- std::shared_ptr<const convolution> conv);- bool convolution_byxf_opt(const layout& input_layout,- const layout& output_layout,- const layout& weights_layout,- const convolution_node& node);+ bool is_mixed_layout(program_node& prev, program_node& next, bool check_data_type = true, std::vector<std::pair<format, format>> custom_list = {}) const;++ bool convolution_bfyx_opt(const layout& output_layout, const layout& weights_layout, std::shared_ptr<const convolution> conv);+ bool convolution_byxf_opt(const layout& input_layout, const layout& output_layout, const layout& weights_layout, const convolution_node& node);bool convolution_b_fs_yx_fsv16_opt(const layout& input_layout,const layout& output_layout,const layout& weights_layout,@@ -194,7 +184,7 @@ private:const layout& output_layout,const layout& weights_layout,std::shared_ptr<const convolution> conv);- bool convolution_bs_fs_yx_bsv32_fsv32_opt(const layout &input_layout,+ bool convolution_bs_fs_yx_bsv32_fsv32_opt(const layout& input_layout,const layout& output_layout,const layout& weights_layout,std::shared_ptr<const convolution> conv);@@ -203,14 +193,10 @@ private:const layout& weights_layout,std::shared_ptr<const convolution> conv,bool weak_restrictions = false);- bool deconvolution_b_fs_zyx_fsv16_opt(const layout &input_layout,- const layout &weights_layout,- std::shared_ptr<const deconvolution> conv);- bool deconvolution_b_fs_yx_fsv16_opt(const layout &input_layout,- const layout &weights_layout,- std::shared_ptr<const deconvolution> conv);- bool users_for_convolution_byxf_opt(program_node const& node, uint32_t depth);- bool deps_for_convolution_byxf_opt(program_node const& node, uint32_t depth);+ bool deconvolution_b_fs_zyx_fsv16_opt(const layout& input_layout, const layout& weights_layout, std::shared_ptr<const deconvolution> conv);+ bool deconvolution_b_fs_yx_fsv16_opt(const layout& input_layout, const layout& weights_layout, std::shared_ptr<const deconvolution> conv);+ bool users_for_convolution_byxf_opt(const program_node& node, uint32_t depth);+ bool deps_for_convolution_byxf_opt(const program_node& node, uint32_t depth);public:explicit layout_optimizer(bool output_size_handling_enabled = true);@@ -229,7 +215,9 @@ public:bool can_fuse_reorder_to_prev(program_node& prev, reorder_node& target_node, format fmt_prev, format fmt_next);void set_optimization_attribute(optimization_attributes_type attribute, int32_t val);- optimization_attributes get_optimization_attributes() { return _optimization_attributes; }+ optimization_attributes get_optimization_attributes() {+ return _optimization_attributes;+ }template <typename PT>void enable_onednn_for() {@@ -267,7 +255,7 @@ public:size_t get_optimized_conv_count(const std::pair<format::type, bool>& format);size_t get_total_conv_count();- bool should_select_b_fs_yx_fsv16_layout(convolution_node const& node, layout const& output_or_weights_layout);+ bool should_select_b_fs_yx_fsv16_layout(const convolution_node& node, const layout& output_or_weights_layout);void save(BinaryOutputBuffer& ob) const {_optimization_attributes.save(ob);diff --git a/src/plugins/intel_gpu/src/graph/include/loop_inst.h b/src/plugins/intel_gpu/src/graph/include/loop_inst.hindex 20afc2c4c3c..1f10ccb325f 100644--- a/src/plugins/intel_gpu/src/graph/include/loop_inst.h+++ b/src/plugins/intel_gpu/src/graph/include/loop_inst.h@@ -98,16 +98,21 @@ public:}// Update ids- if (get_trip_count_id() == prevID)+ if (get_trip_count_id() == prevID) {trip_count_id = newID;- if (get_initial_execution_id() == prevID)+ }+ if (get_initial_execution_id() == prevID) {initial_execution_id = newID;- if (get_current_iteration_id() == prevID)+ }+ if (get_current_iteration_id() == prevID) {current_iteration_id = newID;- if (get_execution_condition_id() == prevID)+ }+ if (get_execution_condition_id() == prevID) {execution_condition_id = newID;- if (get_num_iterations_id() == prevID)+ }+ if (get_num_iterations_id() == prevID) {num_iterations_id = newID;+ }}// current_iteration is necessary to calculate output layout in dynamic shapediff --git a/src/plugins/intel_gpu/src/graph/include/multiclass_nms_inst.h b/src/plugins/intel_gpu/src/graph/include/multiclass_nms_inst.hindex 0d40bea5ff6..e003b4bff9b 100644--- a/src/plugins/intel_gpu/src/graph/include/multiclass_nms_inst.h+++ b/src/plugins/intel_gpu/src/graph/include/multiclass_nms_inst.h@@ -32,8 +32,9 @@ public:}const program_node& roisnum() const {- if (!get_primitive()->has_roisnum)+ if (!get_primitive()->has_roisnum) {throw std::runtime_error("there is no roisnum input");+ }return get_dependency(2);}diff --git a/src/plugins/intel_gpu/src/graph/include/paged_attention_inst.h b/src/plugins/intel_gpu/src/graph/include/paged_attention_inst.hindex e0ceb504bdf..0c38327772d 100644--- a/src/plugins/intel_gpu/src/graph/include/paged_attention_inst.h+++ b/src/plugins/intel_gpu/src/graph/include/paged_attention_inst.h@@ -26,8 +26,9 @@ public:PagedAttentionInputIdx::XATTENTION_BLOCK_SIZE,PagedAttentionInputIdx::MAX_CONTEXT_LEN };- if (typed_desc()->has_score_aggregation)+ if (typed_desc()->has_score_aggregation) {input_ports.insert(PagedAttentionInputIdx::SCORE_AGGREGATION);+ }if (typed_desc()->has_adaptive_rkv) {input_ports.insert(PagedAttentionInputIdx::ADAPTIVE_RKV_START_SIZE);diff --git a/src/plugins/intel_gpu/src/graph/include/primitive_inst.h b/src/plugins/intel_gpu/src/graph/include/primitive_inst.hindex a01abf5560d..5d0e4052175 100644--- a/src/plugins/intel_gpu/src/graph/include/primitive_inst.h+++ b/src/plugins/intel_gpu/src/graph/include/primitive_inst.h@@ -276,14 +276,16 @@ public:void set_impl(std::unique_ptr<primitive_impl> impl) { _impl = std::move(impl); }memory& input_memory(size_t index = 0) const {- if (index >= inputs_memory_count())+ if (index >= inputs_memory_count()) {throw std::range_error("input offset too big");+ }return dep_memory(index);}memory::ptr input_memory_ptr(size_t index = 0) const {- if (index >= inputs_memory_count())+ if (index >= inputs_memory_count()) {throw std::range_error("input offset too big");+ }return dep_memory_ptr(index);}@@ -553,11 +555,13 @@ struct typed_primitive_impl : public primitive_impl {using primitive_impl::primitive_impl;event::ptr execute(const std::vector<event::ptr>& event, primitive_inst& instance) override {- if (instance.type() != PType::type_id())+ if (instance.type() != PType::type_id()) {throw std::invalid_argument("Implementation type does not match primitive type");- if (instance.get_impl() != this)+ }+ if (instance.get_impl() != this) {throw std::invalid_argument("Trying to execute primitive implementation with mismatching primitive instance");+ }return execute_impl(event, reinterpret_cast<typed_primitive_inst<PType>&>(instance));}@@ -567,11 +571,13 @@ struct typed_primitive_impl : public primitive_impl {}void set_arguments(primitive_inst& instance) override {- if (instance.type() != PType::type_id())+ if (instance.type() != PType::type_id()) {throw std::invalid_argument("Implementation type does not match primitive type");- if (instance.get_impl() != this)+ }+ if (instance.get_impl() != this) {throw std::invalid_argument("Trying to set_arguments for primitive implementation with mismatching primitive instance");+ }return set_arguments_impl(reinterpret_cast<typed_primitive_inst<PType>&>(instance));}@@ -579,9 +585,10 @@ struct typed_primitive_impl : public primitive_impl {void set_arguments(primitive_inst& instance, kernel_arguments_data& args) override {OPENVINO_ASSERT(instance.type() == PType::type_id(), "[GPU] Implementation type ", instance.type()," does not match primitive type ", PType::type_id());- if (instance.get_impl() != this)+ if (instance.get_impl() != this) {throw std::invalid_argument("Trying to set_arguments for primitive implementation with mismatching primitive instance");+ }return set_arguments_impl(reinterpret_cast<typed_primitive_inst<PType>&>(instance), args);}diff --git a/src/plugins/intel_gpu/src/graph/include/primitive_type_base.h b/src/plugins/intel_gpu/src/graph/include/primitive_type_base.hindex 8f47feeed6c..d826d2a4321 100644--- a/src/plugins/intel_gpu/src/graph/include/primitive_type_base.h+++ b/src/plugins/intel_gpu/src/graph/include/primitive_type_base.h@@ -4,29 +4,27 @@#pragma once-#include "registry/registry.hpp"+#include <memory>+#include <string>++#include "intel_gpu/graph/network.hpp"#include "intel_gpu/primitives/data.hpp"#include "intel_gpu/primitives/implementation_desc.hpp"+#include "intel_gpu/runtime/debug_configuration.hpp"#include "intel_gpu/runtime/internal_properties.hpp"#include "intel_gpu/runtime/layout.hpp"-#include "intel_gpu/runtime/debug_configuration.hpp"-#include "intel_gpu/runtime/utils.hpp"-#include "primitive_type.h"-#include "program_node.h"#include "layout_optimizer.h"#include "primitive_inst.h"-#include "intel_gpu/graph/network.hpp"+#include "primitive_type.h"+#include "program_node.h"#include "registry/implementation_manager.hpp"--#include <memory>-#include <string>+#include "registry/registry.hpp"namespace cldnn {template <class PType>struct primitive_type_base : primitive_type {- std::shared_ptr<cldnn::program_node> create_node(program& program,- const std::shared_ptr<primitive> prim) const override {+ std::shared_ptr<cldnn::program_node> create_node(program& program, const std::shared_ptr<primitive> prim) const override {OPENVINO_ASSERT(prim->type == this, "[GPU] primitive_type_base::create_node: primitive type mismatch");return std::make_shared<typed_program_node<PType>>(std::static_pointer_cast<PType>(prim), program);}@@ -36,11 +34,12 @@ struct primitive_type_base : primitive_type {return std::make_shared<typed_primitive_inst<PType>>(network, node);}- in_out_fmts_t query_preferred_formats(const cldnn::program_node& node, impl_types impl_type) const override {+ in_out_fmts_t query_preferred_formats(const cldnn::program_node& node, impl_types impl_type) const override {OPENVINO_ASSERT(node.type() == this, "[GPU] primitive_type_base::query_preferred_formats: primitive type mismatch");auto shape_type = ImplementationManager::get_shape_type(node);- if (auto factory = implementation_map<PType>::get(node.get_preferred_impl_type(), shape_type))+ if (auto factory = implementation_map<PType>::get(node.get_preferred_impl_type(), shape_type)) {return factory->query_formats(node);+ }return {};}@@ -48,15 +47,18 @@ struct primitive_type_base : primitive_type {OPENVINO_ASSERT(node.type() == this, "[GPU] primitive_type_base::choose_impl: primitive type mismatch");for (auto& impl : get_supported_implementations(node)) {impl_types impl_type = impl->get_impl_type();- if ((node.get_forced_impl_type() & impl_type) != impl_type)+ if ((node.get_forced_impl_type() & impl_type) != impl_type) {continue;+ }- if (impl_type == impl_types::onednn && !node.get_program().get_layout_optimizer().contains_onednn_impls_optimization_attribute(&node))+ if (impl_type == impl_types::onednn && !node.get_program().get_layout_optimizer().contains_onednn_impls_optimization_attribute(&node)) {continue;+ }shape_types supported_shape_type = impl->get_shape_type();- if ((requested_shape_type & supported_shape_type) != requested_shape_type && requested_shape_type != shape_types::any)+ if ((requested_shape_type & supported_shape_type) != requested_shape_type && requested_shape_type != shape_types::any) {continue;+ }return impl;}@@ -69,9 +71,18 @@ struct primitive_type_base : primitive_type {auto impl = choose_impl(node, ImplementationManager::get_shape_type(*params));const auto& p = node.get_primitive();- OPENVINO_ASSERT(impl != nullptr, "[GPU] Can't choose implementation for ", node.id(), " node (type=", p->type_string(), ")\n",- "[GPU] Original name: ", p->origin_op_name, "\n",- "[GPU] Original type: ", p->origin_op_type_name, "\n");+ OPENVINO_ASSERT(impl != nullptr,+ "[GPU] Can't choose implementation for ",+ node.id(),+ " node (type=",+ p->type_string(),+ ")\n",+ "[GPU] Original name: ",+ p->origin_op_name,+ "\n",+ "[GPU] Original type: ",+ p->origin_op_type_name,+ "\n");return impl->create(node, *params);}@@ -79,12 +90,14 @@ struct primitive_type_base : primitive_type {const auto& all_impls = get_all_implementations();for (auto& impl : all_impls) {impl_types impl_type = impl->get_impl_type();- if ((requested_impl_type & impl_type) != impl_type)+ if ((requested_impl_type & impl_type) != impl_type) {continue;+ }shape_types supported_shape_type = impl->get_shape_type();- if ((requested_shape_type & supported_shape_type) != requested_shape_type)+ if ((requested_shape_type & supported_shape_type) != requested_shape_type) {continue;+ }return impl;}@@ -92,7 +105,7 @@ struct primitive_type_base : primitive_type {return nullptr;}- std::set<impl_types> get_available_impl_types(const cldnn::program_node& node) const override {+ std::set<impl_types> get_available_impl_types(const cldnn::program_node& node) const override {OPENVINO_ASSERT(node.type() == this, "[GPU] primitive_type_base::get_available_impl_types: primitive type mismatch");auto supported_impls = get_supported_implementations(node);std::set<impl_types> supported_impl_types;@@ -105,8 +118,9 @@ struct primitive_type_base : primitive_type {std::shared_ptr<ImplementationManager> get(const ov::DiscreteTypeInfo& type_info) const override {for (auto& impl : get_all_implementations()) {- if (impl->get_type_info() == type_info)+ if (impl->get_type_info() == type_info) {return impl;+ }}return nullptr;}@@ -154,25 +168,30 @@ struct primitive_type_base : primitive_type {auto forced_impl_type = node.get_forced_impl_type();for (auto& impl : all_impls) {impl_types impl_type = impl->get_impl_type();- if (requested_impl_type != impl_types::any && (requested_impl_type & impl_type) != impl_type)+ if (requested_impl_type != impl_types::any && (requested_impl_type & impl_type) != impl_type) {continue;+ }shape_types supported_shape_type = impl->get_shape_type();- if (requested_shape_type != shape_types::any && (requested_shape_type & supported_shape_type) != requested_shape_type)+ if (requested_shape_type != shape_types::any && (requested_shape_type & supported_shape_type) != requested_shape_type) {continue;+ }if (forced_impl_type != impl_types::any) {// in case if we have forced impl, we don't do validation// and skip all other impl types here- if (forced_impl_type == impl->get_impl_type())+ if (forced_impl_type == impl->get_impl_type()) {return true;+ }continue;}- if (impl_type == impl_types::onednn && !node.get_program().get_layout_optimizer().contains_onednn_impls_optimization_attribute(&node))+ if (impl_type == impl_types::onednn && !node.get_program().get_layout_optimizer().contains_onednn_impls_optimization_attribute(&node)) {continue;+ }- if (!impl->validate(node))+ if (!impl->validate(node)) {continue;+ }return true;}@@ -207,7 +226,7 @@ struct primitive_type_base : primitive_type {return res;}- kernel_impl_params get_fake_aligned_params(kernel_impl_params const& orig_impl_param) const override {+ kernel_impl_params get_fake_aligned_params(const kernel_impl_params& orig_impl_param) const override {return typed_primitive_inst<PType>::get_fake_aligned_params(orig_impl_param);}diff --git a/src/plugins/intel_gpu/src/graph/include/program_helpers.h b/src/plugins/intel_gpu/src/graph/include/program_helpers.hindex be290a3ecca..3373cde690c 100644--- a/src/plugins/intel_gpu/src/graph/include/program_helpers.h+++ b/src/plugins/intel_gpu/src/graph/include/program_helpers.h@@ -92,10 +92,11 @@ struct program_helpers {template <class T, class... RestOfT, class Func, class... RestOfFuncs>static decltype(static_cast<void>(std::declval<Func>()(std::declval<typed_program_node<T>&>())))do_for_types(program_node& node, Func const& func, RestOfFuncs const&... rest) {- if (node.type() == T::type_id())+ if (node.type() == T::type_id()) {func(node.as<T>());- else+ } else {do_for_types<RestOfT...>(node, rest...);+ }}// helper functions for deconvolution optimizations@@ -169,8 +170,9 @@ struct pattern_match_optimization {}// Returns whether optimization invalidated the node and no futher optimizations should execute.bool match_and_optimize(program_node& node) {- if (!match(node))+ if (!match(node)) {return false;+ }return optimize(node);}@@ -193,8 +195,9 @@ struct pattern_match_optimization_typed : pattern_match_optimization<pattern_mat// Returns whether optimization can be performed for specified node.bool match(program_node& node) {- if (!node.is_type<Prim>())+ if (!node.is_type<Prim>()) {return false;+ }return static_cast<Impl*>(this)->match(node.as<Prim>());}// Should be overloaded by implementation class to match specified primitive.@@ -219,8 +222,9 @@ inline bool run_node_optimizations(program_node& /*node*/) {template <typename Opt, typename... Rest>bool run_node_optimizations(program_node& node, Opt&& opt, Rest&&... rest) {- if (opt.match_and_optimize(node))+ if (opt.match_and_optimize(node)) {return true;+ }return run_node_optimizations(node, std::forward<Rest>(rest)...);}diff --git a/src/plugins/intel_gpu/src/graph/include/program_node.h b/src/plugins/intel_gpu/src/graph/include/program_node.hindex 6a9c92eae9e..cbed4b401f4 100644--- a/src/plugins/intel_gpu/src/graph/include/program_node.h+++ b/src/plugins/intel_gpu/src/graph/include/program_node.h@@ -4,26 +4,25 @@#pragma once-#include "registry/implementation_manager.hpp"-#include "intel_gpu/primitives/primitive.hpp"-#include "intel_gpu/primitives/implementation_desc.hpp"-#include "intel_gpu/graph/program.hpp"+#include <algorithm>+#include <array>+#include <list>+#include <map>+#include <memory>+#include <set>+#include <thread>+#include <utility>+#include <vector>#include "intel_gpu/graph/fused_primitive_desc.hpp"#include "intel_gpu/graph/kernel_impl_params.hpp"-#include "intel_gpu/primitives/reorder.hpp"+#include "intel_gpu/graph/program.hpp"+#include "intel_gpu/primitives/implementation_desc.hpp"+#include "intel_gpu/primitives/primitive.hpp"#include "intel_gpu/primitives/read_value.hpp"+#include "intel_gpu/primitives/reorder.hpp"#include "intel_gpu/runtime/utils.hpp"--#include <set>-#include <array>-#include <vector>-#include <memory>-#include <list>-#include <algorithm>-#include <thread>-#include <map>-#include <utility>+#include "registry/implementation_manager.hpp"namespace cldnn {@@ -52,27 +51,33 @@ class xml_composite;to API level where all primitives store only ids of related ones.*/struct program_node {- friend struct program; // to be removed when possible- friend class compile_graph; // to be removed when possible- friend class graph_initializations; // to be removed when possible- friend class pre_replace_deconv; // to be removed when possible- friend class prepare_primitive_fusing; // to be removed when possible- friend class prepare_quantization; // to be removed when possible- friend class propagate_constants; // to be removed when possible+ friend struct program; // to be removed when possible+ friend class compile_graph; // to be removed when possible+ friend class graph_initializations; // to be removed when possible+ friend class pre_replace_deconv; // to be removed when possible+ friend class prepare_primitive_fusing; // to be removed when possible+ friend class prepare_quantization; // to be removed when possible+ friend class propagate_constants; // to be removed when possibletemplate <class PType>friend struct typed_program_node;program_node(std::shared_ptr<primitive> prim, program& prog);- program_node(program_node const&) = delete;+ program_node(const program_node&) = delete;virtual ~program_node() = default;public:- virtual const primitive_id& id() const { return desc->id; }- virtual primitive_type_id type() const { return desc->type; }- virtual std::shared_ptr<NodeFuseParams> get_fuse_params() const { return nullptr; }+ virtual const primitive_id& id() const {+ return desc->id;+ }+ virtual primitive_type_id type() const {+ return desc->type;+ }+ virtual std::shared_ptr<NodeFuseParams> get_fuse_params() const {+ return nullptr;+ }virtual std::vector<size_t> get_shape_infer_dependencies() const {// Default impl will request all deps for shape infer@@ -84,8 +89,9 @@ public:}bool is_shape_infer_dep() const {- if (!myprog.is_new_shape_infer())+ if (!myprog.is_new_shape_infer()) {return false;+ }for (auto* u : users) {for (auto dep_idx : u->get_shape_infer_dependencies()) {if (u->get_dependencies().size() <= dep_idx) {@@ -106,18 +112,21 @@ public:bool has_fused_dep() const {for (const auto& fused : get_fused_primitives()) {- if (fused.has_outer_dep())+ if (fused.has_outer_dep()) {return true;+ }}return false;}int32_t get_first_fused_dep_idx() const {- if (!has_fused_dep())+ if (!has_fused_dep()) {return -1;+ }for (const auto& fused : get_fused_primitives()) {- if (fused.has_outer_dep())+ if (fused.has_outer_dep()) {return fused.outer_dep_start_idx;+ }}return -1;}@@ -129,9 +138,14 @@ public:}virtual std::unique_ptr<kernel_impl_params> get_kernel_impl_params(const std::vector<layout>& in_layouts, const std::vector<layout>& out_layouts) const {- auto params = std::unique_ptr<kernel_impl_params>(new kernel_impl_params(get_program(), get_program().get_engine().get_device_info().dev_type,- get_program().get_stream_ptr(), get_primitive(),- get_unique_id(), in_layouts, out_layouts, get_fused_primitives()));+ auto params = std::unique_ptr<kernel_impl_params>(new kernel_impl_params(get_program(),+ get_program().get_engine().get_device_info().dev_type,+ get_program().get_stream_ptr(),+ get_primitive(),+ get_unique_id(),+ in_layouts,+ out_layouts,+ get_fused_primitives()));params->memory_deps = get_const_memory_deps();params->_can_be_optimized = this->optimized;params->_runtime_skippable = this->runtime_skippable;@@ -145,43 +159,68 @@ public:}}#ifdef ENABLE_ONEDNN_FOR_GPU- params->fused_desc_onednn = get_fused_primitives_onednn();- params->attrs_onednn = get_onednn_primitive_attributes();-#endif // ENABLE_ONEDNN_FOR_GPU+ params->fused_desc_onednn = get_fused_primitives_onednn();+ params->attrs_onednn = get_onednn_primitive_attributes();+#endif // ENABLE_ONEDNN_FOR_GPUreturn params;}template <class PType>bool is_type() const {- static_assert(- meta::is_primitive<PType>::value,- "Type argument for program_node::is_type should be a non-const, non-volatile type derived from primitive");+ static_assert(meta::is_primitive<PType>::value,+ "Type argument for program_node::is_type should be a non-const, non-volatile type derived from primitive");return type() == PType::type_id();}- program& get_program() { return myprog; }- program& get_program() const { return myprog; }- const ExecutionConfig& get_config() const { return myprog.get_config(); }+ program& get_program() {+ return myprog;+ }+ program& get_program() const {+ return myprog;+ }+ const ExecutionConfig& get_config() const {+ return myprog.get_config();+ }- primitive_impl* get_selected_impl() const { return selected_impl.get(); }+ primitive_impl* get_selected_impl() const {+ return selected_impl.get();+ }void set_selected_impl(std::unique_ptr<primitive_impl> impl);- void set_preferred_impl_type(impl_types impl) { impl_type = impl; }- impl_types get_preferred_impl_type() const { return impl_type; }+ void set_preferred_impl_type(impl_types impl) {+ impl_type = impl;+ }+ impl_types get_preferred_impl_type() const {+ return impl_type;+ }- void set_forced_impl_type(impl_types impl) { forced_impl_type = impl; }- impl_types get_forced_impl_type() const { return forced_impl_type; }+ void set_forced_impl_type(impl_types impl) {+ forced_impl_type = impl;+ }+ impl_types get_forced_impl_type() const {+ return forced_impl_type;+ }- std::vector<std::pair<program_node*, int32_t>> const& get_dependencies() const { return dependencies; }- program_node& get_dependency(size_t idx) const { return *dependencies.at(idx).first; }- std::pair<program_node*, int32_t> get_dependency_with_port(size_t idx) const { return dependencies.at(idx); }+ const std::vector<std::pair<program_node*, int32_t>>& get_dependencies() const {+ return dependencies;+ }+ program_node& get_dependency(size_t idx) const {+ return *dependencies.at(idx).first;+ }+ std::pair<program_node*, int32_t> get_dependency_with_port(size_t idx) const {+ return dependencies.at(idx);+ }// Count of original primitive inputs, i.e. it doesn't include fused dependencies- size_t get_inputs_count() const { return desc->input_size(); }+ size_t get_inputs_count() const {+ return desc->input_size();+ }// Count of original primitive outputs- size_t get_outputs_count() const { return desc->output_size(); }+ size_t get_outputs_count() const {+ return desc->output_size();+ }- std::vector<layout> const get_input_layouts() const;+ const std::vector<layout> get_input_layouts() const;const layout& get_input_layout(size_t idx = 0) const;const ov::PartialShape& get_input_pshape(size_t idx = 0) const;ov::PartialShape get_output_pshape(size_t idx = 0) const;@@ -198,8 +237,8 @@ public:void replace_dependency(size_t idx, std::pair<program_node*, int32_t> new_dep, bool remove_if_dangling = true);// searches for 'old_dep' in dependencies list of 'this' and replaces it with 'new_dep', calls// program::remove_if_dangling(old_dep)- void replace_dependency(program_node const& old_dep, program_node& new_dep, bool remove_if_dangling = true);- void replace_dependency(program_node const& old_dep, std::pair<program_node*, int32_t> new_dep, bool remove_if_dangling = true);+ void replace_dependency(const program_node& old_dep, program_node& new_dep, bool remove_if_dangling = true);+ void replace_dependency(const program_node& old_dep, std::pair<program_node*, int32_t> new_dep, bool remove_if_dangling = true);std::vector<primitive_id> get_dependencies_ids() const;@@ -218,36 +257,43 @@ public:// At least the following scenarios are not allocating from memory pool:// 1. constant nodes// 2. read_value nodes that are optimized out to reuse from Variables.- bool may_use_mempool() const { return !is_constant() && (!is_type<read_value>() || !optimized); }+ bool may_use_mempool() const {+ return !is_constant() && (!is_type<read_value>() || !optimized);+ }template <class PType>bool have_user_with_type() const {- for (auto const& usr : users) {- if (usr->is_type<PType>())+ for (const auto& usr : users) {+ if (usr->is_type<PType>()) {return true;+ }}return false;}bool is_detached(bool whole_branch = false);- std::list<program_node*> const& get_users() { return users; }+ const std::list<program_node*>& get_users() {+ return users;+ }// for const method, add const to stored successors/predecessors- std::list<const program_node*> const& get_users() const {+ const std::list<const program_node*>& get_users() const {return reinterpret_cast<const std::list<const program_node*>&>(users);}std::unique_ptr<json_composite> desc_to_json() const;// do not modify primitive directly to keep synchronisation with graph- std::shared_ptr<const primitive> get_primitive() const { return desc; }+ std::shared_ptr<const primitive> get_primitive() const {+ return desc;+ }// primitive modification functions- void set_output_padding(padding const& padd, size_t idx = 0) {+ void set_output_padding(const padding& padd, size_t idx = 0) {// changing output padding shouldn't cause any changes to other primitives// so just change itoutput_layouts[idx].data_padding = padd;}- void merge_output_padding(padding const& padd, size_t idx = 0) {+ void merge_output_padding(const padding& padd, size_t idx = 0) {set_output_padding(padding::max(padd, output_layouts[idx].data_padding), idx);}@@ -281,21 +327,36 @@ public:bool is_dynamic_output_layout(size_t idx = 0) const;bool is_dynamic_output_layout(size_t idx = 0);- bool is_padded() { return static_cast<bool>(get_output_layout().data_padding); }- bool is_padded() const { return static_cast<bool>(get_output_layout().data_padding); }+ bool is_padded() {+ return static_cast<bool>(get_output_layout().data_padding);+ }+ bool is_padded() const {+ return static_cast<bool>(get_output_layout().data_padding);+ }bool has_padded_dependency();bool has_padded_dependency() const;- bool is_input() const { return dependencies.empty(); }- bool is_endpoint() const { return users.empty(); }- void set_output(bool out) { output = out; }- bool is_output() const { return output; }+ bool is_input() const {+ return dependencies.empty();+ }+ bool is_endpoint() const {+ return users.empty();+ }+ void set_output(bool out) {+ output = out;+ }+ bool is_output() const {+ return output;+ }- bool is_valid_output_layout(size_t idx = 0) const { return valid_output_layouts[idx]; }+ bool is_valid_output_layout(size_t idx = 0) const {+ return valid_output_layouts[idx];+ }bool is_all_valid_output_layouts() const {for (auto l : valid_output_layouts) {- if (!l) return false;+ if (!l)+ return false;}return true;}@@ -305,59 +366,91 @@ public:user_mark = val;return ret;}- void unmark() { user_mark = 0; }- bool is_marked() const { return user_mark != 0; }+ void unmark() {+ user_mark = 0;+ }+ bool is_marked() const {+ return user_mark != 0;+ }- void set_in_shape_of_subgraph(bool val = true) { in_shape_of_subgraph = val; }- bool is_in_shape_of_subgraph() const { return in_shape_of_subgraph; }+ void set_in_shape_of_subgraph(bool val = true) {+ in_shape_of_subgraph = val;+ }+ bool is_in_shape_of_subgraph() const {+ return in_shape_of_subgraph;+ }// check/set if the node can be optimized out (removed from the network)- bool can_be_optimized() const { return optimized; }- void can_be_optimized(bool opt) { optimized = opt; }+ bool can_be_optimized() const {+ return optimized;+ }+ void can_be_optimized(bool opt) {+ optimized = opt;+ }// check/set if the node is runtime skippable- bool is_runtime_skippable() const { return runtime_skippable; }- void set_runtime_skippable(bool skippable) { runtime_skippable = skippable; }+ bool is_runtime_skippable() const {+ return runtime_skippable;+ }+ void set_runtime_skippable(bool skippable) {+ runtime_skippable = skippable;+ }// check/set if the node's buffer can be shared during the memory pool optimization- bool can_share_buffer() const { return share_buffer; }- void can_share_buffer(bool share) { share_buffer = share; }+ bool can_share_buffer() const {+ return share_buffer;+ }+ void can_share_buffer(bool share) {+ share_buffer = share;+ }// Sets padding support for all axisvoid support_padding_all(bool support);// Sets padding support for specified axis- void support_padding(int axis, bool support) { _support_padding_in_axis[axis] = support; }+ void support_padding(int axis, bool support) {+ _support_padding_in_axis[axis] = support;+ }// Checks if primitive supports any padding in specified axis- bool support_padding(int axis) const { return _support_padding_in_axis[axis]; }+ bool support_padding(int axis) const {+ return _support_padding_in_axis[axis];+ }// Checks whether with current format specified padding is supported;bool is_padding_supported(int axis, int padding) const;// Check if layout has padding in any spatial axisbool is_padded_spatial(size_t idx = 0) const;- primitive_id get_org_primitive_id() const { return org_id; }+ primitive_id get_org_primitive_id() const {+ return org_id;+ }- bool is_constant() const { return constant; }+ bool is_constant() const {+ return constant;+ }// returns true if this node is within main data flow of the network (i.e. it does not describe helper data like// convolution's weights etc.)- bool is_in_data_flow() const { return data_flow; }+ bool is_in_data_flow() const {+ return data_flow;+ }// conversion from generic to specifictemplate <class To, class..., class = typename std::enable_if<!std::is_same<To, primitive>::value>::type>typed_program_node<To>& as() {- if (type() != To::type_id())+ if (type() != To::type_id()) {throw std::invalid_argument("program_node: mismatching primitive's type");+ }return reinterpret_cast<typed_program_node<To>&>(*this);}template <class To, class..., class = typename std::enable_if<!std::is_same<To, primitive>::value>::type>- typed_program_node<To> const& as() const {- if (type() != To::type_id())+ const typed_program_node<To>& as() const {+ if (type() != To::type_id()) {throw std::invalid_argument("program_node: mismatching primitive's type");+ }- return reinterpret_cast<typed_program_node<To> const&>(*this);+ return reinterpret_cast<const typed_program_node<To>&>(*this);}template <class To>@@ -366,7 +459,7 @@ public:}template <class To>- operator typed_program_node<To> const&() const {+ operator const typed_program_node<To>&() const {return as<To>();}@@ -383,7 +476,9 @@ public:reused_memory_color = color;}- bool is_reusing_memory() { return has_reused_memory; }+ bool is_reusing_memory() {+ return has_reused_memory;+ }uint32_t get_reused_memory_color() {return reused_memory_color;}@@ -396,34 +491,43 @@ public:fused_prims.insert(fused_prims.end(), descs.begin(), descs.end());}- const std::vector<fused_primitive_desc>& get_fused_primitives() const { return fused_prims; }- std::vector<fused_primitive_desc>& get_fused_primitives() { return fused_prims; }+ const std::vector<fused_primitive_desc>& get_fused_primitives() const {+ return fused_prims;+ }+ std::vector<fused_primitive_desc>& get_fused_primitives() {+ return fused_prims;+ }void save(cldnn::BinaryOutputBuffer& ob) const;void load(cldnn::BinaryInputBuffer& ib);#ifdef ENABLE_ONEDNN_FOR_GPUconst std::shared_ptr<dnnl::primitive_attr>& get_onednn_primitive_attributes() const {- if (onednn_attrs == nullptr)+ if (onednn_attrs == nullptr) {const_cast<program_node*>(this)->init_onednn_primitive_attributes();+ }return onednn_attrs;}std::shared_ptr<dnnl::primitive_attr>& get_onednn_primitive_attributes() {- if (onednn_attrs == nullptr)+ if (onednn_attrs == nullptr) {init_onednn_primitive_attributes();+ }return onednn_attrs;}- const std::vector<fused_primitive_desc_onednn>& get_fused_primitives_onednn() const { return fused_prims_onednn; }- std::vector<fused_primitive_desc_onednn>& get_fused_primitives_onednn() { return fused_prims_onednn; }+ const std::vector<fused_primitive_desc_onednn>& get_fused_primitives_onednn() const {+ return fused_prims_onednn;+ }+ std::vector<fused_primitive_desc_onednn>& get_fused_primitives_onednn() {+ return fused_prims_onednn;+ }void init_onednn_primitive_attributes();- void create_onednn_primitive_attributes(- const std::vector<fused_primitive_desc>& cldnn_post_ops,- std::shared_ptr<dnnl::primitive_attr>& attrs,- std::vector<fused_primitive_desc_onednn>& fused_ops,- kernel_impl_params* impl_params) const;-#endif // ENABLE_ONEDNN_FOR_GPU+ void create_onednn_primitive_attributes(const std::vector<fused_primitive_desc>& cldnn_post_ops,+ std::shared_ptr<dnnl::primitive_attr>& attrs,+ std::vector<fused_primitive_desc_onednn>& fused_ops,+ kernel_impl_params* impl_params) const;+#endif // ENABLE_ONEDNN_FOR_GPUsize_t get_fused_inputs_count() const {size_t count = 0;@@ -433,18 +537,23 @@ public:return count;}- bool has_fused_primitives() const { return !get_fused_primitives().empty(); }+ bool has_fused_primitives() const {+ return !get_fused_primitives().empty();+ }layout get_fused_output_layout() const {auto fp = get_fused_primitives();- if (fp.empty())+ if (fp.empty()) {return layout(data_types::f32, format::bfyx, tensor());+ }return fp.back().output_layout;}bool need_lockable_memory() const;- size_t get_unique_id() const { return unique_id; }+ size_t get_unique_id() const {+ return unique_id;+ }void set_unique_id() {unique_id = cur_id++;@@ -454,13 +563,16 @@ public:unique_id = _id;}-static void reset_unique_id() {cur_id = 0;}- std::vector<format::type> get_preferred_input_fmts() const { return preferred_input_fmts; }- std::vector<format::type> get_preferred_output_fmts() const { return preferred_output_fmts; }+ std::vector<format::type> get_preferred_input_fmts() const {+ return preferred_input_fmts;+ }+ std::vector<format::type> get_preferred_output_fmts() const {+ return preferred_output_fmts;+ }format::type get_preferred_input_fmt(size_t idx = 0) const {return (idx < preferred_input_fmts.size()) ? preferred_input_fmts.at(idx) : format::any;}@@ -547,10 +659,11 @@ private:}dnnl::post_ops try_optimize_post_ops(std::vector<fused_primitive_desc_onednn>& cur_post_ops,- dnnl::post_ops& p_ops, const std::shared_ptr<dnnl::primitive_attr>& attr,- bool& optimization_is_completed) const;+ dnnl::post_ops& p_ops,+ const std::shared_ptr<dnnl::primitive_attr>& attr,+ bool& optimization_is_completed) const;-#endif // ENABLE_ONEDNN_FOR_GPU+#endif // ENABLE_ONEDNN_FOR_GPUsize_t num_outputs = 1;};@@ -578,7 +691,9 @@ public:}protected:- std::shared_ptr<PType> typed_desc() const { return std::static_pointer_cast<PType>(desc); }+ std::shared_ptr<PType> typed_desc() const {+ return std::static_pointer_cast<PType>(desc);+ }};/*@@ -592,7 +707,9 @@ template <class PType>struct typed_program_node : public typed_program_node_base<PType> {using typed_program_node_base<PType>::typed_program_node_base;- program_node& input(size_t index = 0) const { return program_node::get_dependency(index); }+ program_node& input(size_t index = 0) const {+ return program_node::get_dependency(index);+ }};inline void set_format_no_any(layout& l, format new_format) {@@ -606,11 +723,13 @@ inline void set_format_no_any(layout& l, format new_format) {template <typename RT>inline RT test_format(program_node& node, format fmt, std::function<RT(program_node& node)> f) {// Don't change anything for reorder- if (node.is_type<reorder>())+ if (node.is_type<reorder>()) {return f(node);+ }- if (!node.is_all_valid_output_layouts())+ if (!node.is_all_valid_output_layouts()) {node.recalc_output_layouts(false);+ }bool has_deps = !node.get_dependencies().empty();layout prev_input_layout = layout();@@ -643,11 +762,13 @@ inline RT test_format(program_node& node, format fmt, std::function<RT(program_ntemplate <typename RT>inline RT test_no_input_pad(program_node& node, std::function<RT(program_node& node)> f) {// Don't change anything for reorder- if (node.is_type<reorder>())+ if (node.is_type<reorder>()) {return f(node);+ }- if (!node.is_all_valid_output_layouts())+ if (!node.is_all_valid_output_layouts()) {node.recalc_output_layouts(false);+ }// Use a map keyed by (dep_node_ptr, port) to handle duplicate dependencies correctly.// When the same dependency appears multiple times (e.g., eltwise self-multiply),@@ -655,11 +776,13 @@ inline RT test_no_input_pad(program_node& node, std::function<RT(program_node& nstd::map<std::pair<program_node*, int32_t>, padding> original_padding;for (size_t i = 0; i < node.get_dependencies().size(); i++) {auto dep_with_port = node.get_dependency_with_port(i);- if (dep_with_port.first->is_constant())+ if (dep_with_port.first->is_constant()) {continue;+ }auto key = std::make_pair(dep_with_port.first, dep_with_port.second);- if (original_padding.count(key))+ if (original_padding.count(key)) {continue;+ }original_padding[key] = dep_with_port.first->get_output_layout(false, dep_with_port.second).data_padding;dep_with_port.first->set_output_padding(padding(), dep_with_port.second);}diff --git a/src/plugins/intel_gpu/src/graph/include/reduce_inst.h b/src/plugins/intel_gpu/src/graph/include/reduce_inst.hindex 3a7a5c5b590..ea346dfeb29 100644--- a/src/plugins/intel_gpu/src/graph/include/reduce_inst.h+++ b/src/plugins/intel_gpu/src/graph/include/reduce_inst.h@@ -34,8 +34,9 @@ public:static std::string to_string(reduce_node const& node);bool need_reset_input_memory(size_t idx = 0) const override {- if (idx != 0)+ if (idx != 0) {return false;+ }auto input_layout = _deps[0].first->_impl_params->get_output_layout(_deps[0].second);return !format::format::is_simple_data_format(input_layout.format) &&diff --git a/src/plugins/intel_gpu/src/graph/include/reshape_inst.h b/src/plugins/intel_gpu/src/graph/include/reshape_inst.hindex 3747e2d73d4..c13475e08d0 100644--- a/src/plugins/intel_gpu/src/graph/include/reshape_inst.h+++ b/src/plugins/intel_gpu/src/graph/include/reshape_inst.h@@ -36,8 +36,9 @@ public:if (prim->mode == reshape::reshape_mode::squeeze || prim->mode == reshape::reshape_mode::unsqueeze) {// For proper padding propagation we need to know output pattern at model loading stage// in case of squeeze/unsqueeze mode- if (prim->output_pattern.empty())+ if (prim->output_pattern.empty()) {return false;+ }if (input().is_type<crop>() && prim->mode == reshape::reshape_mode::squeeze) {const auto crop_axis = input().as<crop>().get_primitive()->axis;@@ -51,16 +52,19 @@ public:}// TODO: This function is to limit condition to a specific case (crop + reshape) among cases for the base mode- if (!input().is_type<crop>())+ if (!input().is_type<crop>()) {return false;+ }// oneDNN supports padded input of outer axis only for buffer fusing on static shape- if (!has_outer_padding_offset() && get_users().size() == 1 && get_users().front()->get_preferred_impl_type() == impl_types::onednn)+ if (!has_outer_padding_offset() && get_users().size() == 1 && get_users().front()->get_preferred_impl_type() == impl_types::onednn) {return false;+ }// MVN canonicalizes input strides and cannot tolerate dynamic padding offsets.- if (get_users().size() == 1 && get_users().front()->is_type<mvn>())+ if (get_users().size() == 1 && get_users().front()->is_type<mvn>()) {return false;+ }// vl_sdpa uses a CM kernel that receives raw SVM pointers. Generic dynamic// padding (e.g. from an inner-axis crop) cannot be applied through shape_info@@ -81,8 +85,9 @@ public:input_pshape[1].get_length() == 1 &&prim->output_partial_shape.size() >= 2 &&prim->output_partial_shape.size() + 1 == input_pshape.size();- if (!is_axis1_size1_squeeze)+ if (!is_axis1_size1_squeeze) {return false;+ }}auto axis = input().as<crop>().get_primitive()->axis;@@ -92,10 +97,12 @@ public:// Keep the same safeguard as for inner-axis crops: if the reshape output pattern is// not known at model loading time, do not enable runtime padding propagation.if (axis == 0 && !input_pshape[0].is_dynamic()) {- if (prim->output_pattern.empty())+ if (prim->output_pattern.empty()) {return false;- if (input_pshape[0].get_length() != 1)+ }+ if (input_pshape[0].get_length() != 1) {return false;+ }// Reject if the reshape preserves the batch=1 dim (spatial flatten, not batch squeeze).// output_pattern[0] == -1 means the first dim is inferred (batch absorbed/squeezed).// output_pattern[0] == 0 or 1 means batch=1 is explicitly kept.@@ -150,29 +157,33 @@ public:auto input_rank = input_pshape.size();auto input_last_dim = static_cast<int64_t>(input_rank - 1);- if (axis != input_last_dim || input_pshape[input_last_dim].is_dynamic())+ if (axis != input_last_dim || input_pshape[input_last_dim].is_dynamic()) {return false;+ }auto input_last_dim_val = input_pshape[input_last_dim].get_length();const auto& output_pshape = prim->output_partial_shape;// TODO: If the reshape's output shape is non constant, issue occurs// during shape inference due to execution order at runtime- if (prim->output_pattern.empty())+ if (prim->output_pattern.empty()) {return false;+ }// Iteratively check the total product of all static innermost dimensions// until the crop dimension value matches or the first dynamic dimension is encounteredint64_t mul = 1;size_t matched_trailing_dims = 0;for (size_t i = output_pshape.size(); i > 1 ; i--) {- if (output_pshape[i - 1].is_dynamic() || mul == input_last_dim_val)+ if (output_pshape[i - 1].is_dynamic() || mul == input_last_dim_val) {break;+ }mul *= output_pshape[i - 1].get_length();matched_trailing_dims++;}- if (input_last_dim_val != mul)+ if (input_last_dim_val != mul) {return false;+ }// Reject when reshape drops the cropped axis (e.g. [N,M,1] -> [N,M]): no output axis can// carry the cropped axis padding, so sibling crop outputs would all point to the same// base buffer region (aliased).@@ -186,53 +197,62 @@ public:}bool has_outer_padding_offset() const {- if (!has_padding())+ if (!has_padding()) {return false;+ }auto input_layout = input().get_output_layout(false);auto input_pad = input_layout.data_padding;for (size_t i = 0 ; i < input_layout.get_spatial_rank() ; i++) {- if (input_pad._lower_size[2 + i] != 0)+ if (input_pad._lower_size[2 + i] != 0) {return false;- if (input_pad._upper_size[2 + i] != 0)+ }+ if (input_pad._upper_size[2 + i] != 0) {return false;+ }}// Expected a padded input of only batch axis with 'bxxx' formatif (input_layout.format.dims_order()[0] != 0 ||input_pad._lower_size[1] != 0 ||- input_pad._upper_size[1] != 0)+ input_pad._upper_size[1] != 0) {return false;+ }// Outer padding exists. It might need to update padding size of output layoutreturn !format::is_multi_blocked(input_layout.format);}bool is_in_place() const {- if (this->is_output() || this->has_fused_primitives())+ if (this->is_output() || this->has_fused_primitives()) {return false;+ }- if (input().get_output_layout(false).data_padding.is_dynamic() && is_runtime_propagatable_padding())+ if (input().get_output_layout(false).data_padding.is_dynamic() && is_runtime_propagatable_padding()) {return true;+ }return !has_padding();}void adjust_output_padding() {- if (!has_padding())+ if (!has_padding()) {return;+ }auto input_layout = input().get_output_layout(false);auto output_layout = this->get_output_layout();if (input_layout.data_padding.is_dynamic()) {auto prim = typed_desc();// TODO: If outer padding exists, ouput padding propagation is not supported in the base mode- if (prim->mode == reshape::reshape_mode::base)+ if (prim->mode == reshape::reshape_mode::base) {return;+ }ov::PartialShape pattern_shape = { static_cast<int64_t>(prim->output_pattern.size()) };- if (pattern_shape.size() == 0)+ if (pattern_shape.size() == 0) {pattern_shape = {};+ }auto pattern_data = prim->output_pattern;auto pattern_tensor = make_tensor({pattern_shape, data_types::i64, format::bfyx}, static_cast<void*>(pattern_data.data()));diff --git a/src/plugins/intel_gpu/src/graph/include/slice_inst.h b/src/plugins/intel_gpu/src/graph/include/slice_inst.hindex c085440e565..09e6aa3a556 100644--- a/src/plugins/intel_gpu/src/graph/include/slice_inst.h+++ b/src/plugins/intel_gpu/src/graph/include/slice_inst.h@@ -80,8 +80,9 @@ inline const std::vector<size_t>& SliceKernelRefNeededInputs::GetNeededInputInde///////////////////////////////////////////////////////////////////inline bool SliceKernelRefNeededInputs::IsInputNeededInRuntime(InputIndices type) const {for (auto idx : neededIndexes) {- if (idx == type)+ if (idx == type) {return true;+ }}return false;}diff --git a/src/plugins/intel_gpu/src/graph/include/sliding_window_utils.hpp b/src/plugins/intel_gpu/src/graph/include/sliding_window_utils.hppindex 924f85a8261..b0102848413 100644--- a/src/plugins/intel_gpu/src/graph/include/sliding_window_utils.hpp+++ b/src/plugins/intel_gpu/src/graph/include/sliding_window_utils.hpp@@ -4,23 +4,21 @@#pragma once+#include <algorithm>+#include <cassert>+#include <stdexcept>+#include "intel_gpu/runtime/layout.hpp"#include "intel_gpu/runtime/tensor.hpp"-+#include "intel_gpu/runtime/utils.hpp"#include "openvino/core/coordinate_diff.hpp"#include "openvino/core/strides.hpp"-#include "intel_gpu/runtime/utils.hpp"--#include <algorithm>-#include <cassert>-#include <stdexcept>-namespace ov::intel_gpu {-using cldnn::tensor;-using cldnn::padding;using cldnn::layout;+using cldnn::padding;+using cldnn::tensor;/// @brief Sliding window output range computation mode.enum class swor_mode {@@ -67,13 +65,7 @@ tensor calc_sliding_window_output_range(const tensor& input_size,/// @brief Fall-back implementation.template <swor_mode RangeMode>-tensor calc_sliding_window_output_range(const tensor&,- const tensor&,- const tensor&,- const ov::Strides&,- const tensor&,- bool,- const tensor::value_type&) {+tensor calc_sliding_window_output_range(const tensor&, const tensor&, const tensor&, const ov::Strides&, const tensor&, bool, const tensor::value_type&) {static_assert(cldnn::meta::always_false<cldnn::meta::val_tuple<swor_mode, RangeMode>>::value,"Sliding window output range calculation mode is not supported. Please implement specialization ""for new swor_mode.");@@ -89,14 +81,22 @@ inline tensor calc_sliding_window_output_range<swor_mode::all>(const tensor& inpconst ov::Strides& dilation,bool sym_pad,const tensor::value_type& degen_val) {- if (input_size.spatial[0] <= 0 || input_size.spatial[1] <= 0 || input_size.spatial[2] <= 0)+ if (input_size.spatial[0] <= 0 || input_size.spatial[1] <= 0 || input_size.spatial[2] <= 0) {throw std::invalid_argument("Input data spatial sizes must be positive (>= 1).");- if (size.spatial[0] <= 0 || size.spatial[1] <= 0 || size.spatial[2] <= 0)+ }+ if (size.spatial[0] <= 0 || size.spatial[1] <= 0 || size.spatial[2] <= 0) {throw std::invalid_argument("Sliding window spatial sizes must be positive (>= 1).");- if (std::any_of(stride.begin(), stride.end(), [](size_t v) { return v <= 0; }))+ }+ if (std::any_of(stride.begin(), stride.end(), [](size_t v) {+ return v <= 0;+ })) {throw std::invalid_argument("Sliding window strides must be positive (>= 1).");- if (std::any_of(dilation.begin(), dilation.end(), [](size_t v) { return v <= 0; }))+ }+ if (std::any_of(dilation.begin(), dilation.end(), [](size_t v) {+ return v <= 0;+ })) {throw std::invalid_argument("Sliding window h/v input dialations must be positive (>= 1).");+ }auto off_factor = sym_pad ? -2 : -1;auto stride_z = stride.size() >= 3 ? stride[stride.size() - 3] : 1;@@ -111,31 +111,24 @@ inline tensor calc_sliding_window_output_range<swor_mode::all>(const tensor& inpauto pad_y = pad.size() >= 2 ? pad[pad.size() - 2] : 0;auto pad_x = !pad.empty() ? pad[pad.size() - 1] : 0;- tensor wnd_ext_size{0,- 0,- (size.spatial[0] - 1) * dilation_x + 1,- (size.spatial[1] - 1) * dilation_y + 1,- (size.spatial[2] - 1) * dilation_z + 1};+ tensor wnd_ext_size{0, 0, (size.spatial[0] - 1) * dilation_x + 1, (size.spatial[1] - 1) * dilation_y + 1, (size.spatial[2] - 1) * dilation_z + 1};// wes = (size - 1) * dilation + 1// lpos(i) = -pad + i * stride + wes - 1, for i = 0, 1, ...//// output_range = max {i | lpos(i) < input_size + pad} + 1, if sym_pad is true// output_range = max {i | lpos(i) < input_size} + 1, if sym_pad is false- auto output_range_x = static_cast<ov::Dimension::value_type>(- off_factor * pad_x + wnd_ext_size.spatial[0] <= input_size.spatial[0]- ? (input_size.spatial[0] - off_factor * pad_x - wnd_ext_size.spatial[0]) / stride_x + 1- : degen_val);- auto output_range_y = static_cast<ov::Dimension::value_type>(- off_factor * pad_y + wnd_ext_size.spatial[1] <= input_size.spatial[1]- ? (input_size.spatial[1] - off_factor * pad_y - wnd_ext_size.spatial[1]) / stride_y + 1- : degen_val);- auto output_range_z = static_cast<ov::Dimension::value_type>(- off_factor * pad_z + wnd_ext_size.spatial[2] <= input_size.spatial[2]- ? (input_size.spatial[2] - off_factor * pad_z - wnd_ext_size.spatial[2]) / stride_z + 1- : degen_val);+ auto output_range_x = static_cast<ov::Dimension::value_type>(off_factor * pad_x + wnd_ext_size.spatial[0] <= input_size.spatial[0]+ ? (input_size.spatial[0] - off_factor * pad_x - wnd_ext_size.spatial[0]) / stride_x + 1+ : degen_val);+ auto output_range_y = static_cast<ov::Dimension::value_type>(off_factor * pad_y + wnd_ext_size.spatial[1] <= input_size.spatial[1]+ ? (input_size.spatial[1] - off_factor * pad_y - wnd_ext_size.spatial[1]) / stride_y + 1+ : degen_val);+ auto output_range_z = static_cast<ov::Dimension::value_type>(off_factor * pad_z + wnd_ext_size.spatial[2] <= input_size.spatial[2]+ ? (input_size.spatial[2] - off_factor * pad_z - wnd_ext_size.spatial[2]) / stride_z + 1+ : degen_val);- return {0, 0, output_range_x, output_range_y, output_range_z};+ return {0, 0, output_range_x, output_range_y, output_range_z};}template <>@@ -146,14 +139,22 @@ inline tensor calc_sliding_window_output_range<swor_mode::exceed_once>(const tenconst ov::Strides& dilation,bool sym_pad,const tensor::value_type& degen_val) {- if (input_size.spatial[0] <= 0 || input_size.spatial[1] <= 0 || input_size.spatial[2] <= 0)+ if (input_size.spatial[0] <= 0 || input_size.spatial[1] <= 0 || input_size.spatial[2] <= 0) {throw std::invalid_argument("Input data spatial sizes must be positive (>= 1).");- if (size.spatial[0] <= 0 || size.spatial[1] <= 0 || size.spatial[2] <= 0)+ }+ if (size.spatial[0] <= 0 || size.spatial[1] <= 0 || size.spatial[2] <= 0) {throw std::invalid_argument("Sliding window spatial sizes must be positive (>= 1).");- if (std::any_of(stride.begin(), stride.end(), [](size_t v) { return v <= 0; }))+ }+ if (std::any_of(stride.begin(), stride.end(), [](size_t v) {+ return v <= 0;+ })) {throw std::invalid_argument("Sliding window strides must be positive (>= 1).");- if (std::any_of(dilation.begin(), dilation.end(), [](size_t v) { return v <= 0; }))+ }+ if (std::any_of(dilation.begin(), dilation.end(), [](size_t v) {+ return v <= 0;+ })) {throw std::invalid_argument("Sliding window h/v input dialations must be positive (>= 1).");+ }int64_t off_factor = sym_pad ? -2 : -1;int64_t stride_z = stride.size() >= 3 ? stride[stride.size() - 3] : 1;@@ -174,7 +175,6 @@ inline tensor calc_sliding_window_output_range<swor_mode::exceed_once>(const tenstd::max<tensor::value_type>((size.spatial[1] - 1) * dilation_y + 1, stride_y),std::max<tensor::value_type>((size.spatial[2] - 1) * dilation_z + 1, stride_z)};-// wes = (size - 1) * dilation + 1// fpos(i) = -pad + i * stride, for i = 0, 1, ...// lpos(i) = -pad + i * stride + wes - 1, for i = 0, 1, ...@@ -182,24 +182,18 @@ inline tensor calc_sliding_window_output_range<swor_mode::exceed_once>(const ten// output_range = max {i | lpos(i) < input_size + pad - 1 and fpos(i + 1) < input_size + pad} + 2, if// sym_pad is true output_range = max {i | lpos(i) < input_size - 1 and fpos(i + 1) < input_size} + 2,// if sym_pad is false- auto output_range_x = static_cast<ov::Dimension::value_type>(- off_factor * pad_x + extend.spatial[0] <= input_size.spatial[0] + stride_x - 1- ? (input_size.spatial[0] - off_factor * pad_x - extend.spatial[0] + stride_x - 1) /- stride_x +- 1- : degen_val);- auto output_range_y = static_cast<ov::Dimension::value_type>(- off_factor * pad_y + extend.spatial[1] <= input_size.spatial[1] + stride_y - 1- ? (input_size.spatial[1] - off_factor * pad_y - extend.spatial[1] + stride_y - 1) /- stride_y +- 1- : degen_val);- auto output_range_z = static_cast<ov::Dimension::value_type>(- off_factor * pad_z + extend.spatial[2] <= input_size.spatial[2] + stride_z - 1- ? (input_size.spatial[2] - off_factor * pad_z - extend.spatial[2] + stride_z - 1) /- stride_z +- 1- : degen_val);+ auto output_range_x =+ static_cast<ov::Dimension::value_type>(off_factor * pad_x + extend.spatial[0] <= input_size.spatial[0] + stride_x - 1+ ? (input_size.spatial[0] - off_factor * pad_x - extend.spatial[0] + stride_x - 1) / stride_x + 1+ : degen_val);+ auto output_range_y =+ static_cast<ov::Dimension::value_type>(off_factor * pad_y + extend.spatial[1] <= input_size.spatial[1] + stride_y - 1+ ? (input_size.spatial[1] - off_factor * pad_y - extend.spatial[1] + stride_y - 1) / stride_y + 1+ : degen_val);+ auto output_range_z =+ static_cast<ov::Dimension::value_type>(off_factor * pad_z + extend.spatial[2] <= input_size.spatial[2] + stride_z - 1+ ? (input_size.spatial[2] - off_factor * pad_z - extend.spatial[2] + stride_z - 1) / stride_z + 1+ : degen_val);return {0, 0, output_range_x, output_range_y, output_range_z};}@@ -212,14 +206,22 @@ inline tensor calc_sliding_window_output_range<swor_mode::any>(const tensor& inpconst ov::Strides& dilation,bool sym_pad,const tensor::value_type& degen_val) {- if (input_size.spatial[0] <= 0 || input_size.spatial[1] <= 0 || input_size.spatial[2] <= 0)+ if (input_size.spatial[0] <= 0 || input_size.spatial[1] <= 0 || input_size.spatial[2] <= 0) {throw std::invalid_argument("Input data spatial sizes must be positive (>= 1).");- if (size.spatial[0] <= 0 || size.spatial[1] <= 0 || size.spatial[2] <= 0)+ }+ if (size.spatial[0] <= 0 || size.spatial[1] <= 0 || size.spatial[2] <= 0) {throw std::invalid_argument("Sliding window spatial sizes must be positive (>= 1).");- if (std::any_of(stride.begin(), stride.end(), [](size_t v) { return v <= 0; }))+ }+ if (std::any_of(stride.begin(), stride.end(), [](size_t v) {+ return v <= 0;+ })) {throw std::invalid_argument("Sliding window h/v strides must be positive (>= 1).");- if (std::any_of(dilation.begin(), dilation.end(), [](size_t v) { return v <= 0; }))+ }+ if (std::any_of(dilation.begin(), dilation.end(), [](size_t v) {+ return v <= 0;+ })) {throw std::invalid_argument("Sliding window h/v input dialations must be positive (>= 1).");+ }auto stride_z = stride.size() >= 3 ? stride[stride.size() - 3] : 1;auto stride_y = stride.size() >= 2 ? stride[stride.size() - 2] : 1;@@ -236,17 +238,11 @@ inline tensor calc_sliding_window_output_range<swor_mode::any>(const tensor& inp// output_range = max {i | fpos(i) < input_size + pad} + 1, if sym_pad is true// output_range = max {i | fpos(i) < input_size} + 1, if sym_pad is falseauto output_range_x = static_cast<ov::Dimension::value_type>(- off_factor * pad_x <= input_size.spatial[0] - 1- ? (input_size.spatial[0] - off_factor * pad_x - 1) / stride_x + 1- : degen_val);+ off_factor * pad_x <= input_size.spatial[0] - 1 ? (input_size.spatial[0] - off_factor * pad_x - 1) / stride_x + 1 : degen_val);auto output_range_y = static_cast<ov::Dimension::value_type>(- off_factor * pad_y <= input_size.spatial[1] - 1- ? (input_size.spatial[1] - off_factor * pad_y - 1) / stride_y + 1- : degen_val);+ off_factor * pad_y <= input_size.spatial[1] - 1 ? (input_size.spatial[1] - off_factor * pad_y - 1) / stride_y + 1 : degen_val);auto output_range_z = static_cast<ov::Dimension::value_type>(- off_factor * pad_z <= input_size.spatial[2] - 1- ? (input_size.spatial[2] - off_factor * pad_z - 1) / stride_z + 1- : degen_val);+ off_factor * pad_z <= input_size.spatial[2] - 1 ? (input_size.spatial[2] - off_factor * pad_z - 1) / stride_z + 1 : degen_val);return {0, 0, output_range_x, output_range_y, output_range_z};}@@ -259,15 +255,8 @@ inline tensor calc_sliding_window_output_range<swor_mode::exceed_once_data>(consconst ov::Strides& dilation,bool sym_pad,const tensor::value_type& degen_val) {- auto output_range_exceed_once = calc_sliding_window_output_range<swor_mode::exceed_once>(input_size,- size,- pad,- stride,- dilation,- sym_pad,- degen_val);- auto output_range_exceed_any_data =- calc_sliding_window_output_range<swor_mode::any>(input_size, size, pad, stride, dilation, false, degen_val);+ auto output_range_exceed_once = calc_sliding_window_output_range<swor_mode::exceed_once>(input_size, size, pad, stride, dilation, sym_pad, degen_val);+ auto output_range_exceed_any_data = calc_sliding_window_output_range<swor_mode::any>(input_size, size, pad, stride, dilation, false, degen_val);return tensor::min(output_range_exceed_once, output_range_exceed_any_data);}@@ -280,34 +269,18 @@ inline tensor calc_sliding_window_output_range<swor_mode::max>(const tensor& inpconst ov::Strides& dilation,bool,const tensor::value_type& degen_val) {- auto output_range_all_sym =- calc_sliding_window_output_range<swor_mode::all>(input_size, size, pad, stride, dilation, true, degen_val);- auto output_range_all_asym =- calc_sliding_window_output_range<swor_mode::all>(input_size, size, pad, stride, dilation, false, degen_val);-- auto output_range_exceed_once_sym = calc_sliding_window_output_range<swor_mode::exceed_once>(input_size,- size,- pad,- stride,- dilation,- true,- degen_val);- auto output_range_exceed_once_asym = calc_sliding_window_output_range<swor_mode::exceed_once>(input_size,- size,- pad,- stride,- dilation,- false,- degen_val);-- auto output_range_any_sym =- calc_sliding_window_output_range<swor_mode::any>(input_size, size, pad, stride, dilation, true, degen_val);- auto output_range_any_asym =- calc_sliding_window_output_range<swor_mode::any>(input_size, size, pad, stride, dilation, false, degen_val);-- return tensor::max(tensor::max(tensor::max(output_range_all_sym, output_range_all_asym),- tensor::max(output_range_exceed_once_sym, output_range_exceed_once_asym)),- tensor::max(output_range_any_sym, output_range_any_asym));+ auto output_range_all_sym = calc_sliding_window_output_range<swor_mode::all>(input_size, size, pad, stride, dilation, true, degen_val);+ auto output_range_all_asym = calc_sliding_window_output_range<swor_mode::all>(input_size, size, pad, stride, dilation, false, degen_val);++ auto output_range_exceed_once_sym = calc_sliding_window_output_range<swor_mode::exceed_once>(input_size, size, pad, stride, dilation, true, degen_val);+ auto output_range_exceed_once_asym = calc_sliding_window_output_range<swor_mode::exceed_once>(input_size, size, pad, stride, dilation, false, degen_val);++ auto output_range_any_sym = calc_sliding_window_output_range<swor_mode::any>(input_size, size, pad, stride, dilation, true, degen_val);+ auto output_range_any_asym = calc_sliding_window_output_range<swor_mode::any>(input_size, size, pad, stride, dilation, false, degen_val);++ return tensor::max(+ tensor::max(tensor::max(output_range_all_sym, output_range_all_asym), tensor::max(output_range_exceed_once_sym, output_range_exceed_once_asym)),+ tensor::max(output_range_any_sym, output_range_any_asym));}/// @brief Calculates minumum needed input range (size) for sliding window to get at least specified @p output_size.@@ -332,14 +305,22 @@ inline tensor calc_sliding_window_needed_input_range(const tensor& output_size,const ov::Strides& dilation = {1, 1, 1, 1},bool sym_pad = true,const tensor::value_type& degen_val = 0) {- if (output_size.spatial[0] <= 0 || output_size.spatial[1] <= 0 || output_size.spatial[2] <= 0)+ if (output_size.spatial[0] <= 0 || output_size.spatial[1] <= 0 || output_size.spatial[2] <= 0) {throw std::invalid_argument("Output data spatial sizes must be positive (>= 1).");- if (size.spatial[0] <= 0 || size.spatial[1] <= 0 || size.spatial[2] <= 0)+ }+ if (size.spatial[0] <= 0 || size.spatial[1] <= 0 || size.spatial[2] <= 0) {throw std::invalid_argument("Sliding window spatial sizes must be positive (>= 1).");- if (std::any_of(stride.begin(), stride.end(), [](size_t v) { return v <= 0; }))+ }+ if (std::any_of(stride.begin(), stride.end(), [](size_t v) {+ return v <= 0;+ })) {throw std::invalid_argument("Sliding window h/v strides must be positive (>= 1).");- if (std::any_of(dilation.begin(), dilation.end(), [](size_t v) { return v <= 0; }))+ }+ if (std::any_of(dilation.begin(), dilation.end(), [](size_t v) {+ return v <= 0;+ })) {throw std::invalid_argument("Sliding window h/v input dialations must be positive (>= 1).");+ }auto off_factor = sym_pad ? -2 : -1;auto stride_z = stride.size() >= 3 ? stride[stride.size() - 3] : 1;@@ -354,25 +335,21 @@ inline tensor calc_sliding_window_needed_input_range(const tensor& output_size,auto pad_y = pad.size() >= 2 ? pad[pad.size() - 2] : 0;auto pad_x = !pad.empty() ? pad[pad.size() - 1] : 0;- tensor wnd_ext_size{0,- 0,- (size.spatial[0] - 1) * dilation_x + 1,- (size.spatial[1] - 1) * dilation_y + 1,- (size.spatial[2] - 1) * dilation_z + 1};+ tensor wnd_ext_size{0, 0, (size.spatial[0] - 1) * dilation_x + 1, (size.spatial[1] - 1) * dilation_y + 1, (size.spatial[2] - 1) * dilation_z + 1};- auto output_range_x =- off_factor * pad_x + (output_size.spatial[0] - 1) * stride_x + wnd_ext_size.spatial[0];- auto output_range_y =- off_factor * pad_y + (output_size.spatial[1] - 1) * stride_y + wnd_ext_size.spatial[1];- auto output_range_z =- off_factor * pad_z + (output_size.spatial[2] - 1) * stride_z + wnd_ext_size.spatial[2];+ auto output_range_x = off_factor * pad_x + (output_size.spatial[0] - 1) * stride_x + wnd_ext_size.spatial[0];+ auto output_range_y = off_factor * pad_y + (output_size.spatial[1] - 1) * stride_y + wnd_ext_size.spatial[1];+ auto output_range_z = off_factor * pad_z + (output_size.spatial[2] - 1) * stride_z + wnd_ext_size.spatial[2];- if (output_range_x <= 0)+ if (output_range_x <= 0) {output_range_x = degen_val;- if (output_range_y <= 0)+ }+ if (output_range_y <= 0) {output_range_y = degen_val;- if (output_range_z <= 0)+ }+ if (output_range_z <= 0) {output_range_z = degen_val;+ }return {0,0,@@ -410,18 +387,10 @@ inline padding calc_sliding_window_needed_input_padding(const layout& actual_inpconst tensor::value_type& degen_val = 0) {tensor needed_size;if (inverse) {- needed_size = calc_sliding_window_output_range<swor_mode::max>(output_size,- size,- pad,- stride,- dilation,- false /* not important */,- degen_val);+ needed_size = calc_sliding_window_output_range<swor_mode::max>(output_size, size, pad, stride, dilation, false /* not important */, degen_val);} else {- auto needed_size_sym =- calc_sliding_window_needed_input_range(output_size, size, pad, stride, dilation, true, degen_val);- auto needed_size_asym =- calc_sliding_window_needed_input_range(output_size, size, pad, stride, dilation, false, degen_val);+ auto needed_size_sym = calc_sliding_window_needed_input_range(output_size, size, pad, stride, dilation, true, degen_val);+ auto needed_size_asym = calc_sliding_window_needed_input_range(output_size, size, pad, stride, dilation, false, degen_val);needed_size = tensor::max(needed_size_sym, needed_size_asym);}@@ -434,19 +403,18 @@ inline padding calc_sliding_window_needed_input_padding(const layout& actual_inpauto spatial_rank = actual_input_layout.get_spatial_rank();OPENVINO_ASSERT(spatial_rank > 0 && spatial_rank <= 3);- if (spatial_rank >= 3)+ if (spatial_rank >= 3) {return padding({actual_lpad[0], actual_lpad[1], actual_lpad[2], actual_lpad[3], actual_lpad[4]},{actual_upad[0],actual_upad[1],std::max(needed_upad.spatial[2], actual_upad[2]),std::max(needed_upad.spatial[1], actual_upad[3]),std::max(needed_upad.spatial[0], actual_upad[4])});- if (spatial_rank >= 2)+ }+ if (spatial_rank >= 2) {return padding({actual_lpad[0], actual_lpad[1], actual_lpad[2], actual_lpad[3]},- {actual_upad[0],- actual_upad[1],- std::max(needed_upad.spatial[1], actual_upad[2]),- std::max(needed_upad.spatial[0], actual_upad[3])});+ {actual_upad[0], actual_upad[1], std::max(needed_upad.spatial[1], actual_upad[2]), std::max(needed_upad.spatial[0], actual_upad[3])});+ }return padding({actual_lpad[0], actual_lpad[1], actual_lpad[2]}, {actual_upad[0], actual_upad[1], std::max(needed_upad.spatial[0], actual_upad[2])});}diff --git a/src/plugins/intel_gpu/src/graph/kernel_impl_params.cpp b/src/plugins/intel_gpu/src/graph/kernel_impl_params.cppindex 33356d9bd2c..ca69a805bfa 100644--- a/src/plugins/intel_gpu/src/graph/kernel_impl_params.cpp+++ b/src/plugins/intel_gpu/src/graph/kernel_impl_params.cpp@@ -10,8 +10,9 @@ namespace cldnn {size_t kernel_impl_params::hash() const {size_t seed = 0;- if (desc != nullptr)+ if (desc != nullptr) {seed = desc->hash();+ }const size_t prime_number = 2654435761; // magic number to reduce hash collision rate.for (const auto& in : input_layouts) {seed = hash_combine(seed, in.hash() * prime_number);@@ -30,34 +31,42 @@ size_t kernel_impl_params::hash() const {}bool kernel_impl_params::operator==(const kernel_impl_params& rhs) const {- if ((desc != nullptr && rhs.desc == nullptr) || (desc == nullptr && rhs.desc != nullptr))+ if ((desc != nullptr && rhs.desc == nullptr) || (desc == nullptr && rhs.desc != nullptr)) {return false;+ }- if ((desc != nullptr && rhs.desc != nullptr) && *desc != *rhs.desc)+ if ((desc != nullptr && rhs.desc != nullptr) && *desc != *rhs.desc) {return false;+ }- if (rhs.input_layouts.size() != input_layouts.size())+ if (rhs.input_layouts.size() != input_layouts.size()) {return false;+ }- if (rhs.output_layouts.size() != output_layouts.size())+ if (rhs.output_layouts.size() != output_layouts.size()) {return false;+ }for (size_t i = 0; i < input_layouts.size(); i++) {- if (input_layouts[i] != rhs.input_layouts[i])+ if (input_layouts[i] != rhs.input_layouts[i]) {return false;+ }}for (size_t i = 0; i < output_layouts.size(); i++) {- if (output_layouts[i] != rhs.output_layouts[i])+ if (output_layouts[i] != rhs.output_layouts[i]) {return false;+ }}- if (fused_desc.size() != rhs.fused_desc.size())+ if (fused_desc.size() != rhs.fused_desc.size()) {return false;+ }for (size_t i = 0; i < rhs.fused_desc.size(); i++) {- if (fused_desc[i] != rhs.fused_desc[i])+ if (fused_desc[i] != rhs.fused_desc[i]) {return false;+ }}return true;diff --git a/src/plugins/intel_gpu/src/graph/kv_cache.cpp b/src/plugins/intel_gpu/src/graph/kv_cache.cppindex 246a36532ac..ad17d7c9e87 100644--- a/src/plugins/intel_gpu/src/graph/kv_cache.cpp+++ b/src/plugins/intel_gpu/src/graph/kv_cache.cpp@@ -23,18 +23,21 @@ kv_cache_inst::typed_primitive_inst(network& network, const kv_cache_node& node)}int64_t kv_cache_inst::compute_trim_length(const kernel_impl_params& impl_param, const kv_cache& desc) {- if (!desc.trim)+ if (!desc.trim) {return 0;+ }const size_t past_seq_len_idx = desc.indirect ? 3 : 2;const auto mem_dep_it = impl_param.memory_deps.find(past_seq_len_idx);- if (mem_dep_it == impl_param.memory_deps.end())+ if (mem_dep_it == impl_param.memory_deps.end()) {return 0;+ }const auto& past_seq_len_mem = mem_dep_it->second;const auto past_seq_len_layout = past_seq_len_mem->get_layout();- if (past_seq_len_layout.count() == 0)+ if (past_seq_len_layout.count() == 0) {return 0;+ }OPENVINO_ASSERT(past_seq_len_layout.count() == 1);cldnn::mem_lock<uint8_t, mem_lock_type::read> past_seq_len_mem_lock(past_seq_len_mem, impl_param.get_stream());@@ -180,8 +183,9 @@ void kv_cache_inst::update_shape_info_tensor(const kernel_impl_params& params) {if (bt_layout.is_dynamic()) {auto bt_shape = bt_layout.get_partial_shape();for (auto& d : bt_shape) {- if (d.is_dynamic())+ if (d.is_dynamic()) {d = 0;+ }}bt_layout.set_partial_shape(bt_shape);}@@ -200,8 +204,9 @@ void kv_cache_inst::update_shape_info_tensor(const kernel_impl_params& params) {void kv_cache_inst::release_variable() {// if there's variable state, it should hold a reference of tensor same as outputs- if (!get_network().has_variable(variable_id()))+ if (!get_network().has_variable(variable_id())) {return;+ }for (size_t i = 0; i < _outputs.size(); ++i) {auto& output = _outputs[i];output.reset();diff --git a/src/plugins/intel_gpu/src/graph/layout_optimizer.cpp b/src/plugins/intel_gpu/src/graph/layout_optimizer.cppindex 15e2055da28..5eee260e0c6 100644--- a/src/plugins/intel_gpu/src/graph/layout_optimizer.cpp+++ b/src/plugins/intel_gpu/src/graph/layout_optimizer.cpp@@ -166,10 +166,11 @@ int64_t cldnn::get_convolution_channel_count(const convolution_node& conv_node,auto weights_layout = conv_node.weights().get_output_layout();if (weights_layout.is_static()) {const auto& shape = weights_layout.get_partial_shape();- if (is_input)+ if (is_input) {channel_count = shape[conv_node.get_groups() > 1 ? 2 : 1].get_length();- else+ } else {channel_count = shape[conv_node.get_groups() > 1 ? 1 : 0].get_length();+ }}}return channel_count;@@ -1162,10 +1163,11 @@ format layout_optimizer::get_expected_format(convolution_node const& node) {}if (input_layout.is_dynamic() || output_layout.is_dynamic()) {- if (input_layout.get_partial_shape().size() <= 4)+ if (input_layout.get_partial_shape().size() <= 4) {expected_format = format::b_fs_yx_fsv16;- else if (input_layout.get_partial_shape().size() == 5)+ } else if (input_layout.get_partial_shape().size() == 5) {expected_format = format::b_fs_zyx_fsv16;+ }return expected_format;}@@ -1178,10 +1180,11 @@ format layout_optimizer::get_expected_format(convolution_node const& node) {if (use_onednn_impls && i8_u8_input) {// It is here because of post operation condition for onednn.// Use fsv32 for onednn friendliness.- if (node.get_input_layout(0).get_rank() == 4)+ if (node.get_input_layout(0).get_rank() == 4) {expected_format = cldnn::format::b_fs_yx_fsv32;- else+ } else {expected_format = cldnn::format::b_fs_zyx_fsv32;+ }} else if (input_layout.get_rank() == 4 && input_layout.feature() == 1 &&input_layout.spatial(0) == 1 && weights_layout.spatial(0) == 1 &&weights_layout.spatial(1) >= 256 && activation_only_fusion) {@@ -1200,10 +1203,11 @@ format layout_optimizer::get_expected_format(convolution_node const& node) {} else if ((_optimization_attributes.b_fs_zyx_fsv16_network != 0) &&convolution_b_fs_zyx_fsv16_opt(input_layout, output_layout, weights_layout, prim)) {if ((output_layout.data_type == data_types::f32 && output_layout.batch() % 16 == 0) ||- (output_layout.data_type == data_types::f16 && output_layout.batch() % 32 == 0))+ (output_layout.data_type == data_types::f16 && output_layout.batch() % 32 == 0)) {expected_format = cldnn::format::bs_fs_zyx_bsv16_fsv16;- else+ } else {expected_format = cldnn::format::b_fs_zyx_fsv16;+ }} else if (output_layout.format == format::bfzyx) {expected_format = cldnn::format::bfzyx;@@ -1243,10 +1247,11 @@ format layout_optimizer::get_expected_format(convolution_node const& node) {expected_format = cldnn::format::bs_fs_yx_bsv16_fsv16;} else if (layout_optimizer::convolution_bfyx_opt(output_layout, weights_layout, prim) || _output_size_handling_enabled || node.get_transposed()) {{- if (output_layout.format == format::b_fs_zyx_fsv16 || output_layout.format == format::bs_fs_zyx_bsv16_fsv16)+ if (output_layout.format == format::b_fs_zyx_fsv16 || output_layout.format == format::bs_fs_zyx_bsv16_fsv16) {expected_format = cldnn::format::bfzyx;- else+ } else {expected_format = cldnn::format::bfyx;+ }}} else {expected_format = cldnn::format::yxfb;@@ -1264,10 +1269,11 @@ format layout_optimizer::get_expected_format(deconvolution_node const& node) {auto expected_format = output_layout.format;if (input_layout.is_dynamic() || output_layout.is_dynamic()) {- if (input_layout.get_partial_shape().size() <= 4)+ if (input_layout.get_partial_shape().size() <= 4) {expected_format = format::b_fs_yx_fsv16;- else if (input_layout.get_partial_shape().size() == 5)+ } else if (input_layout.get_partial_shape().size() == 5) {expected_format = format::b_fs_zyx_fsv16;+ }return expected_format;}@@ -1282,10 +1288,11 @@ format layout_optimizer::get_expected_format(deconvolution_node const& node) {} else if ((_optimization_attributes.b_fs_zyx_fsv16_network != 0) &&deconvolution_b_fs_zyx_fsv16_opt(output_layout, weights_layout, prim)) {if ((output_layout.data_type == data_types::f32 && expected_shape[0] % 16 == 0) ||- (output_layout.data_type == data_types::f16 && expected_shape[0] % 32 == 0))+ (output_layout.data_type == data_types::f16 && expected_shape[0] % 32 == 0)) {expected_format = cldnn::format::bs_fs_zyx_bsv16_fsv16;- else+ } else {expected_format = cldnn::format::b_fs_zyx_fsv16;+ }} else if (((_optimization_attributes.b_fs_yx_fsv16_network) != 0) &&deconvolution_b_fs_yx_fsv16_opt(output_layout, weights_layout, prim)) {auto input_shape = input_layout.get_shape();@@ -1293,10 +1300,11 @@ format layout_optimizer::get_expected_format(deconvolution_node const& node) {auto output_features = expected_shape[1];float f_cost = static_cast<float>(input_features * output_features) / (align_to(input_features, 16) * align_to(output_features, 16));float stride_cost = 1 / static_cast<float>(prim->stride[prim->stride.size() - 1]);- if (f_cost * stride_cost > 0.1f)+ if (f_cost * stride_cost > 0.1f) {expected_format = cldnn::format::b_fs_yx_fsv16;- else+ } else {expected_format = cldnn::format::bfyx;+ }}return expected_format;}@@ -1309,12 +1317,13 @@ format layout_optimizer::get_expected_format(quantize_node const& node) {bool all_users_gemm = (!node.get_users().empty());for (const auto* user : node.get_users()) {- if (user->is_type<reorder>() || user->is_type<reshape>())+ if (user->is_type<reorder>() || user->is_type<reshape>()) {all_users_gemm &= only_gemm_users(*user);- else if (user->is_type<gemm>())+ } else if (user->is_type<gemm>()) {all_users_gemm &= true;- else+ } else {return false;+ }}return all_users_gemm;diff --git a/src/plugins/intel_gpu/src/graph/loop.cpp b/src/plugins/intel_gpu/src/graph/loop.cppindex 442b9ec2094..10d64306719 100644--- a/src/plugins/intel_gpu/src/graph/loop.cpp+++ b/src/plugins/intel_gpu/src/graph/loop.cpp@@ -96,8 +96,9 @@ static std::vector<layout> get_output_layouts(kernel_impl_params const& impl_parif (num_iterations == 0) {auto shape = loop_output_layout.get_partial_shape();for (size_t i = 0; i < shape.size(); i++) {- if (shape[i].is_dynamic())+ if (shape[i].is_dynamic()) {shape[i] = 0;+ }}loop_output_layout.set_partial_shape(shape);}@@ -419,8 +420,9 @@ loop_inst::concatenated_memory_mapping::ptr loop_inst::create_concat_memory_map(}void loop_inst::preprocess_output_memory(const int64_t num_iterations) {- if (concatenated_output_mem_mappings.empty())+ if (concatenated_output_mem_mappings.empty()) {concatenated_output_mem_mappings.reserve(_output_primitive_maps.size());+ }for (size_t i = 0; i < _output_primitive_maps.size(); ++i) {const auto& output_mapping = _output_primitive_maps.at(i);const auto& external_id = output_mapping.external_id;@@ -768,8 +770,9 @@ void loop_inst::reset_memory() {void loop_inst::update_output_layout() {- if (_node == nullptr)+ if (_node == nullptr) {return;+ }auto memory_deps = get_node().get_const_memory_deps();for (auto& i : get_node().get_shape_infer_dependencies()) {@@ -804,14 +807,16 @@ void loop_inst::handle_zero_iterations() {update_output_layout();for (const auto& output_mapping : _output_primitive_maps) {- if (output_mapping.axis >= 0)+ if (output_mapping.axis >= 0) {continue;+ }const auto back_edge = std::find_if(_back_edges.begin(), _back_edges.end(), [&](const loop::backedge_mapping& mapping) {return mapping.from == output_mapping.internal_id.pid;});- if (back_edge == _back_edges.end())+ if (back_edge == _back_edges.end()) {continue;+ }const auto input_map_ptrs = find_io_primitive_maps(_input_primitive_maps,_output_primitive_maps,@@ -835,12 +840,14 @@ void loop_inst::handle_zero_iterations() {}auto output_mem = _outputs[output_idx];- if (output_mem == initial_mem)+ if (output_mem == initial_mem) {continue;+ }if (_network.get_engine().is_the_same_buffer(*output_mem, *initial_mem)) {- if (output_mem->get_layout() != initial_layout)+ if (output_mem->get_layout() != initial_layout) {_outputs[output_idx] = initial_mem;+ }} else if (output_mem->get_layout() == initial_layout) {output_mem->copy_from(get_network().get_stream(), *initial_mem);} else {@@ -901,8 +908,9 @@ void loop_inst::concatenated_memory_mapping::slice_mem(const int64_t num_iterati// Set stride values of inner axes to get a continuous copy sizeauto strides = ov::Strides(lower_bounds.size(), 1);- for (size_t iter = inner_axis; iter < dims ; ++iter)+ for (size_t iter = inner_axis; iter < dims ; ++iter) {strides[iter] = upper_bounds[iter];+ }const auto strides_copy_size = elem_size * continuous_size;auto* const out_last = std::next(out_data, num_iters);@@ -1009,14 +1017,16 @@ int64_t loop_inst::get_num_iterations() {int64_t num_iterations = -1;bool is_default_num_iter = true;for (auto& input_map : _input_primitive_maps) {- if (input_map.axis == -1)+ if (input_map.axis == -1) {continue;+ }const auto& external_id = input_map.external_id;auto exteranl_input_inst = get_network().get_primitive(external_id.pid);auto concat_shape = exteranl_input_inst->get_output_layout(external_id.idx).get_partial_shape();- if (concat_shape[input_map.axis].get_length() == 0)+ if (concat_shape[input_map.axis].get_length() == 0) {continue;+ }const auto current_num_iterations = calculate_num_iterations(input_map, concat_shape);if (is_default_num_iter) {@@ -1028,15 +1038,17 @@ int64_t loop_inst::get_num_iterations() {}for (auto& output_map : _output_primitive_maps) {- if (output_map.axis == -1)+ if (output_map.axis == -1) {continue;+ }const auto& external_id = output_map.external_id;auto exteranl_output_inst = get_network().get_primitive(external_id.pid);auto concat_shape = exteranl_output_inst->get_output_layout(external_id.idx).get_partial_shape();- if (concat_shape[output_map.axis].is_dynamic() || concat_shape[output_map.axis].get_length() == 0)+ if (concat_shape[output_map.axis].is_dynamic() || concat_shape[output_map.axis].get_length() == 0) {continue;+ }const auto current_num_iterations = calculate_num_iterations(output_map, concat_shape);if (is_default_num_iter) {@@ -1044,9 +1056,10 @@ int64_t loop_inst::get_num_iterations() {num_iterations = current_num_iterations;}// only check num_terations when shape is not changed.- if (preproc_memories_done)+ if (preproc_memories_done) {OPENVINO_ASSERT(num_iterations == current_num_iterations,"iteration num shuld be same between ", num_iterations, " and ", current_num_iterations);+ }}return num_iterations;}diff --git a/src/plugins/intel_gpu/src/graph/lora.cpp b/src/plugins/intel_gpu/src/graph/lora.cppindex 72df163ce44..06775e1757b 100644--- a/src/plugins/intel_gpu/src/graph/lora.cpp+++ b/src/plugins/intel_gpu/src/graph/lora.cpp@@ -39,14 +39,17 @@ void lora_inst::update_output_memory() {is_empty_lora &= _impl_params->get_input_layout(i).count() == 0;}- if (!is_empty_lora)+ if (!is_empty_lora) {return;+ }- if (static_cast<bool>(_outputs[0]) && _network.get_engine().is_the_same_buffer(output_memory(), input_memory()))+ if (static_cast<bool>(_outputs[0]) && _network.get_engine().is_the_same_buffer(output_memory(), input_memory())) {return;+ }- if (_node != nullptr)+ if (_node != nullptr) {build_deps();+ }GPU_DEBUG_TRACE_DETAIL << id() << " : update_output_memory with mem of input " << get_node().get_dependency(0).id()<< " : " << input_memory_ptr()->buffer_ptr() << std::endl;diff --git a/src/plugins/intel_gpu/src/graph/matrix_nms.cpp b/src/plugins/intel_gpu/src/graph/matrix_nms.cppindex 6316fa0b882..b94e037b8d8 100644--- a/src/plugins/intel_gpu/src/graph/matrix_nms.cpp+++ b/src/plugins/intel_gpu/src/graph/matrix_nms.cpp@@ -1,5 +1,6 @@// Copyright (C) 2018-2026 Intel Corporation// SPDX-License-Identifier: Apache-2.0+//#include <json_object.h>@@ -32,15 +33,17 @@ std::vector<layout> matrix_nms_inst::calc_output_layouts(matrix_nms_node const&num_classes = std::max(int64_t{1}, num_classes - 1);}int64_t max_output_boxes_per_class = 0;- if (desc->attribs.nms_top_k >= 0)+ if (desc->attribs.nms_top_k >= 0) {max_output_boxes_per_class = std::min(num_boxes, static_cast<int64_t>(desc->attribs.nms_top_k));- else+ } else {max_output_boxes_per_class = num_boxes;+ }auto max_output_boxes_per_batch = max_output_boxes_per_class * num_classes;- if (desc->attribs.keep_top_k >= 0)+ if (desc->attribs.keep_top_k >= 0) {max_output_boxes_per_batch =std::min(max_output_boxes_per_batch, static_cast<int64_t>(desc->attribs.keep_top_k));+ }first_dim_shape = max_output_boxes_per_batch * scores_ps[0].get_length();}@@ -70,16 +73,19 @@ layout matrix_nms_inst::calc_output_layout(const matrix_nms_node& node, const keauto classes_num = scores_layout.feature();const auto boxes_num = boxes_layout.feature();- if (primitive->attribs.background_class >= 0 && primitive->attribs.background_class < classes_num)+ if (primitive->attribs.background_class >= 0 && primitive->attribs.background_class < classes_num) {classes_num = std::max<ov::Dimension::value_type>(1, classes_num - 1);+ }auto max_output_boxes_per_class{boxes_num};- if (primitive->attribs.nms_top_k >= 0)+ if (primitive->attribs.nms_top_k >= 0) {max_output_boxes_per_class = std::min<ov::Dimension::value_type>(max_output_boxes_per_class, primitive->attribs.nms_top_k);+ }auto max_output_boxes_per_batch = max_output_boxes_per_class * classes_num;- if (primitive->attribs.keep_top_k >= 0)+ if (primitive->attribs.keep_top_k >= 0) {max_output_boxes_per_batch = std::min<ov::Dimension::value_type>(max_output_boxes_per_batch, primitive->attribs.keep_top_k);+ }auto output_num = max_output_boxes_per_batch * batches_num;diff --git a/src/plugins/intel_gpu/src/graph/moe_gather.cpp b/src/plugins/intel_gpu/src/graph/moe_gather.cppindex 481d624db5c..19387fa7f86 100644--- a/src/plugins/intel_gpu/src/graph/moe_gather.cpp+++ b/src/plugins/intel_gpu/src/graph/moe_gather.cpp@@ -48,8 +48,9 @@ std::string moe_gather_inst::to_string(moe_gather_node const& node) {std::stringstream primitive_description;json_composite moe_gather_info;- if (desc->output_data_types[0].has_value())+ if (desc->output_data_types[0].has_value()) {moe_gather_info.add("out dt: ", dt_to_str(*desc->output_data_types[0]));+ }node_info->add("moe_gather info", moe_gather_info);node_info->dump(primitive_description);diff --git a/src/plugins/intel_gpu/src/graph/moe_gemm.cpp b/src/plugins/intel_gpu/src/graph/moe_gemm.cppindex f6cd9d8133a..a743f0a560a 100644--- a/src/plugins/intel_gpu/src/graph/moe_gemm.cpp+++ b/src/plugins/intel_gpu/src/graph/moe_gemm.cpp@@ -22,8 +22,9 @@ std::vector<layout> moe_gemm_inst::calc_output_layouts(moe_gemm_node const& /*nosize_t num_experts_per_token = desc->num_experts_per_token;auto input_layout = impl_param.get_input_layout(0);size_t input_rank = input_layout.get_partial_shape().size();- if (input_rank != 3)+ if (input_rank != 3) {OPENVINO_THROW("moe_gemm's input rank should be 3");+ }auto experts_layout = impl_param.get_input_layout(1);auto out_n_dim = input_rank - 1;auto output_shape = input_layout.get_partial_shape();@@ -64,8 +65,9 @@ std::string moe_gemm_inst::to_string(moe_gemm_node const& node) {std::stringstream primitive_description;json_composite moe_gemm_info;- if (desc->output_data_types[0].has_value())+ if (desc->output_data_types[0].has_value()) {moe_gemm_info.add("out dt: ", dt_to_str(*desc->output_data_types[0]));+ }node_info->dump(primitive_description);return primitive_description.str();diff --git a/src/plugins/intel_gpu/src/graph/moe_mask_gen.cpp b/src/plugins/intel_gpu/src/graph/moe_mask_gen.cppindex 687fb19512d..a2adf30c7d8 100644--- a/src/plugins/intel_gpu/src/graph/moe_mask_gen.cpp+++ b/src/plugins/intel_gpu/src/graph/moe_mask_gen.cpp@@ -57,8 +57,9 @@ std::string moe_mask_gen_inst::to_string(moe_mask_gen_node const& node) {json_composite moe_mask_gen_info;for (auto o : desc->output_data_types) {- if (o.has_value())+ if (o.has_value()) {moe_mask_gen_info.add("out dt: ", dt_to_str(*o));+ }}node_info->dump(primitive_description);@@ -110,8 +111,9 @@ std::string moe_mask_gen_reshape_inst::to_string(moe_mask_gen_reshape_node constjson_composite moe_mask_gen_reshape_info;for (auto o : desc->output_data_types) {- if (o.has_value())+ if (o.has_value()) {moe_mask_gen_reshape_info.add("out dt: ", dt_to_str(*o));+ }}node_info->dump(primitive_description);@@ -127,14 +129,17 @@ void moe_mask_gen_reshape_inst::on_execute() {}void moe_mask_gen_reshape_inst::update_output_memory() {- if (!can_be_optimized())+ if (!can_be_optimized()) {return;- if (_node != nullptr)+ }+ if (_node != nullptr) {build_deps();+ }_mem_allocated = false;- if (_impl_params->get_input_layout(0).is_dynamic())+ if (_impl_params->get_input_layout(0).is_dynamic()) {return;+ }for (size_t i = 0; i < _outputs.size(); ++i) {if (static_cast<bool>(_outputs[i]) && get_node().get_program().get_config().get_enable_memory_pool()) {_network.get_memory_pool().release_memory(_outputs[i].get(), get_node().get_unique_id(), get_node().id(), _network.get_id());diff --git a/src/plugins/intel_gpu/src/graph/moe_router_fused.cpp b/src/plugins/intel_gpu/src/graph/moe_router_fused.cppindex 6f0a8ab20e2..ff085521981 100644--- a/src/plugins/intel_gpu/src/graph/moe_router_fused.cpp+++ b/src/plugins/intel_gpu/src/graph/moe_router_fused.cpp@@ -19,8 +19,9 @@ layout moe_router_fused_inst::calc_output_layout(const moe_router_fused_node& /*auto input_layout = impl_param.get_input_layout(0);auto shape = input_layout.get_shape();size_t num_tokens = shape[0];- if (shape.size() == 3)+ if (shape.size() == 3) {num_tokens = shape[0] * shape[1];+ }size_t top_k = desc->_config.top_k;return layout(ov::Shape{num_tokens, top_k}, input_layout.data_type, format::bfyx);}diff --git a/src/plugins/intel_gpu/src/graph/moe_scatter_reduction.cpp b/src/plugins/intel_gpu/src/graph/moe_scatter_reduction.cppindex eb6a091ff34..2abf80c12b8 100644--- a/src/plugins/intel_gpu/src/graph/moe_scatter_reduction.cpp+++ b/src/plugins/intel_gpu/src/graph/moe_scatter_reduction.cpp@@ -25,9 +25,10 @@ std::vector<layout> moe_scatter_reduction_inst::calc_output_layouts(moe_scatter_const auto& input_shape = impl_param.input_layouts[0].get<ShapeType>();const auto& hidden_size = input_shape[input_shape.size() - 1];OPENVINO_ASSERT(hidden_size.is_static(), impl_param.desc->id, " hidden size dimension (shape[1]) must be static");- if (impl_param.input_layouts[0].is_dynamic())+ if (impl_param.input_layouts[0].is_dynamic()) {return {layout{ov::PartialShape{ov::Dimension::dynamic(), ov::Dimension::dynamic(), ov::Dimension(hidden_size)},impl_param.input_layouts[0].data_type, impl_param.input_layouts[0].format}};+ }if (desc->has_batch_dim) {const auto num_tokens = impl_param.input_layouts[0].get_shape()[1] / num_active_experts_per_token;const auto& out_shape = ov::PartialShape{1, ov::Dimension(num_tokens), ov::Dimension(hidden_size)};@@ -49,8 +50,9 @@ std::string moe_scatter_reduction_inst::to_string(moe_scatter_reduction_node conjson_composite moe_scatter_reduction_info;moe_scatter_reduction_info.add("input id", node.input().id());- if (desc->output_data_types[0].has_value())+ if (desc->output_data_types[0].has_value()) {moe_scatter_reduction_info.add("out dt: ", dt_to_str(*desc->output_data_types[0]));+ }node_info->add("moe_scatter_reduction_info", moe_scatter_reduction_info);node_info->dump(primitive_description);diff --git a/src/plugins/intel_gpu/src/graph/mutable_data.cpp b/src/plugins/intel_gpu/src/graph/mutable_data.cppindex 7a2d011ca83..840fc6dc511 100644--- a/src/plugins/intel_gpu/src/graph/mutable_data.cpp+++ b/src/plugins/intel_gpu/src/graph/mutable_data.cpp@@ -1,13 +1,14 @@// Copyright (C) 2018-2026 Intel Corporation// SPDX-License-Identifier: Apache-2.0//-#include "mutable_data_inst.h"-#include "primitive_type_base.h"+#include <algorithm>+#include <memory>+#include <string>+#include "intel_gpu/runtime/memory.hpp"#include "json_object.h"-#include <string>-#include <memory>-#include <algorithm>+#include "mutable_data_inst.h"+#include "primitive_type_base.h"namespace cldnn {GPU_DEFINE_PRIMITIVE_TYPE_ID(mutable_data)@@ -30,8 +31,7 @@ memory::ptr attach_or_copy_data(network& network, memory::ptr mem, bool reuse) {}} // namespace-mutable_data_node::typed_program_node(const std::shared_ptr<mutable_data> dprim, program& prog)- : parent(dprim, prog), mem(dprim->mem) {+mutable_data_node::typed_program_node(const std::shared_ptr<mutable_data> dprim, program& prog) : parent(dprim, prog), mem(dprim->mem) {recalc_output_layout(false);can_share_buffer(false);}@@ -46,7 +46,7 @@ void mutable_data_node::replace_memory(memory::ptr new_mem, bool invalidate_userrecalc_output_layout(invalidate_users_if_changed);}-std::string mutable_data_inst::to_string(mutable_data_node const& node) {+std::string mutable_data_inst::to_string(const mutable_data_node& node) {auto node_info = node.desc_to_json();std::stringstream primitive_description;@@ -74,12 +74,13 @@ event::ptr mutable_data_inst::set_output_memory(memory::ptr mem_new, bool check,}}auto ev = primitive_inst::set_output_memory(mem_new, check);- if (input_ev == nullptr)+ if (input_ev == nullptr) {return ev;+ }return _network.get_stream().group_events({ev, input_ev});}-mutable_data_inst::typed_primitive_inst(network& network, mutable_data_node const& node)+mutable_data_inst::typed_primitive_inst(network& network, const mutable_data_node& node): parent(network, node, attach_or_copy_data(network, node.get_attached_memory_ptr(), network.is_primary_stream())) {const auto& users = get_users();for (const auto& usr : users) {diff --git a/src/plugins/intel_gpu/src/graph/network.cpp b/src/plugins/intel_gpu/src/graph/network.cppindex a0f2ac5f3e1..029cce9be88 100644--- a/src/plugins/intel_gpu/src/graph/network.cpp+++ b/src/plugins/intel_gpu/src/graph/network.cpp@@ -2,61 +2,60 @@// SPDX-License-Identifier: Apache-2.0//-#include "intel_gpu/plugin/variable_state.hpp"+#include "intel_gpu/graph/network.hpp"++#include <algorithm>+#include <fstream>+#include <functional>+#include <map>+#include <memory>+#include <set>+#include <stack>+#include <string>+#include <utility>+#include <vector>++#include "condition_inst.h"+#include "convolution_inst.h"+#include "debug_helper.hpp"+#include "deconvolution_inst.h"+#include "fully_connected_inst.h"+#include "input_layout_inst.h"+#include "intel_gpu/graph/kernel_impl_params.hpp"+#include "intel_gpu/graph/program.hpp"+#include "intel_gpu/graph/serialization/map_serializer.hpp"#include "intel_gpu/plugin/output_memory_block.hpp"-#include "intel_gpu/primitives/read_value.hpp"-#include "intel_gpu/primitives/lora.hpp"+#include "intel_gpu/plugin/variable_state.hpp"#include "intel_gpu/primitives/data.hpp"-#include "intel_gpu/primitives/mutable_data.hpp"#include "intel_gpu/primitives/input_layout.hpp"--#include "intel_gpu/runtime/error_handler.hpp"-#include "intel_gpu/runtime/memory.hpp"-#include "intel_gpu/runtime/engine.hpp"-#include "intel_gpu/runtime/event.hpp"-#include "intel_gpu/runtime/stream.hpp"+#include "intel_gpu/primitives/lora.hpp"+#include "intel_gpu/primitives/mutable_data.hpp"+#include "intel_gpu/primitives/read_value.hpp"#include "intel_gpu/runtime/compilation_context.hpp"#include "intel_gpu/runtime/debug_configuration.hpp"+#include "intel_gpu/runtime/engine.hpp"+#include "intel_gpu/runtime/error_handler.hpp"+#include "intel_gpu/runtime/event.hpp"#include "intel_gpu/runtime/itt.hpp"+#include "intel_gpu/runtime/memory.hpp"+#include "intel_gpu/runtime/stream.hpp"+#include "kv_cache_inst.h"+#include "mutable_data_inst.h"#include "openvino/util/env_util.hpp"-#include "intel_gpu/graph/kernel_impl_params.hpp"-#include "intel_gpu/graph/program.hpp"-#include "intel_gpu/graph/network.hpp"-#include "intel_gpu/graph/serialization/map_serializer.hpp"--#include "primitive_inst.h"-#include "input_layout_inst.h"-#include "fully_connected_inst.h"#include "paged_attention_inst.h"-#include "convolution_inst.h"-#include "deconvolution_inst.h"-#include "mutable_data_inst.h"-#include "condition_inst.h"+#include "primitive_inst.h"+#include "program_dump_graph.h"+#include "program_helpers.h"#include "read_value_inst.h"#include "reshape_inst.h"-#include "kv_cache_inst.h"-#include "program_helpers.h"-#include "program_dump_graph.h"#include "to_string_utils.h"--#include <algorithm>-#include <string>-#include <vector>-#include <stack>-#include <memory>-#include <set>-#include <utility>-#include <map>-#include <functional>-#include <fstream>--#include "debug_helper.hpp"#ifdef GPU_DEBUG_CONFIG-#include <fstream>-#include <sys/stat.h>-#include <chrono>-#include <thread>-#include <filesystem>+# include <sys/stat.h>++# include <chrono>+# include <filesystem>+# include <fstream>+# include <thread>#endifnamespace cldnn {@@ -68,8 +67,9 @@ void dump_perf_data_raw(std::string dump_path, bool per_iter_mode, const std::listd::stringstream s;for (size_t i = 0; i < layouts.size(); i++) {s << layouts[i].to_short_string();- if (i != layouts.size() - 1)+ if (i != layouts.size() - 1) {s << ";";+ }}return s.str();};@@ -84,8 +84,7 @@ void dump_perf_data_raw(std::string dump_path, bool per_iter_mode, const std::liconst auto& perf_data = inst->get_profiling_data();const auto& perf_info = inst->get_profiling_info();std::vector<size_t> sorted_entries;- std::transform(perf_data.begin(), perf_data.end(), std::back_inserter(sorted_entries),- [](const std::pair<size_t, std::tuple<int64_t, size_t>>& e) {+ std::transform(perf_data.begin(), perf_data.end(), std::back_inserter(sorted_entries), [](const std::pair<size_t, std::tuple<int64_t, size_t>>& e) {return e.first;});std::sort(sorted_entries.begin(), sorted_entries.end(), [&](size_t a, size_t b) -> bool {@@ -97,11 +96,13 @@ void dump_perf_data_raw(std::string dump_path, bool per_iter_mode, const std::listatic_cast<std::underlying_type<instrumentation::pipeline_stage>::type>(b_info.stage);}- if (a_info.cache_hit != b_info.cache_hit)+ if (a_info.cache_hit != b_info.cache_hit) {return a_info.cache_hit;+ }- if (a_info.memalloc_info != b_info.memalloc_info)+ if (a_info.memalloc_info != b_info.memalloc_info) {return a_info.memalloc_info.length() < b_info.memalloc_info.length();+ }size_t total_out_size_a = 0;size_t total_out_size_b = 0;@@ -123,19 +124,15 @@ void dump_perf_data_raw(std::string dump_path, bool per_iter_mode, const std::listd::string in_l_str = layouts_to_str(key.input_layouts);std::string out_l_str = layouts_to_str(key.output_layouts);std::string stage_suffix;- if (key.cache_hit)+ if (key.cache_hit) {stage_suffix += " (cache_hit) ";- if (!key.memalloc_info.empty())+ }+ if (!key.memalloc_info.empty()) {stage_suffix += " (" + key.memalloc_info + ") ";- of << prim_id << ","- << inst->desc()->type_string() << ","- << key.stage << stage_suffix << ","- << net_in_l_str << ","- << in_l_str << ","- << out_l_str << ","- << (key.stage == instrumentation::pipeline_stage::inference ? key.impl_name : "undef") << ","- << num_iters << ","- << time_avg << "\n";+ }+ of << prim_id << "," << inst->desc()->type_string() << "," << key.stage << stage_suffix << "," << net_in_l_str << "," << in_l_str << ","+ << out_l_str << "," << (key.stage == instrumentation::pipeline_stage::inference ? key.impl_name : "undef") << "," << num_iters << ","+ << time_avg << "\n";}}}@@ -145,17 +142,17 @@ void dump_perf_data_raw(std::string dump_path, bool per_iter_mode, const std::li// benchmark_app --report_type average_counters and the CPU plugin's// OV_CPU_AVERAGE_COUNTERS feature, so that aggregate-average-counters.py and// other tooling can be reused across plugins.-void dump_average_counters(std::string dump_path,- uint32_t net_id,- const std::list<std::shared_ptr<primitive_inst>>& exec_order) {- if (dump_path.empty())+void dump_average_counters(std::string dump_path, uint32_t net_id, const std::list<std::shared_ptr<primitive_inst>>& exec_order) {+ if (dump_path.empty()) {return;+ }std::filesystem::path file_name{dump_path};file_name += "_" + std::to_string(net_id) + ".csv";std::ofstream file(file_name);- if (!file.is_open())+ if (!file.is_open()) {return;+ }const std::string header = "layerName;execStatus;layerType;execType;realTime (ms);cpuTime (ms);";file << header << "\n";@@ -167,8 +164,9 @@ void dump_average_counters(std::string dump_path,uint64_t total_us = 0;for (const auto& inst : exec_order) {- if (inst->is_constant())+ if (inst->is_constant()) {continue;+ }// Aggregate inference-stage entries only, mirroring the CPU plugin which// reports just the executed-kernel time. Other GPU pipeline stages@@ -182,8 +180,9 @@ void dump_average_counters(std::string dump_path,size_t max_iters_for_impl = 0;for (const auto& kv : perf_data) {const auto& key = perf_info.at(kv.first);- if (key.stage != instrumentation::pipeline_stage::inference)+ if (key.stage != instrumentation::pipeline_stage::inference) {continue;+ }const auto cur_time = static_cast<uint64_t>(std::get<0>(kv.second));const auto cur_iters = std::get<1>(kv.second);prim_total_us += cur_time;@@ -202,8 +201,7 @@ void dump_average_counters(std::string dump_path,const auto cpu_time = to_ms(avg_us);const auto real_time = cpu_time;- file << inst->id() << ";" << status << ";" << inst->desc()->type_string() << ";"- << impl_name << ";" << real_time << ";" << cpu_time << ";" << "\n";+ file << inst->id() << ";" << status << ";" << inst->desc()->type_string() << ";" << impl_name << ";" << real_time << ";" << cpu_time << ";" << "\n";total_us += avg_us;}@@ -228,15 +226,15 @@ Network will always have net_id = 0 when it will be cldnn internal micronetworkopt pass).*/network::network(program::ptr program, stream::ptr stream, bool is_internal, bool is_primary_stream)- : _program(program)- , _engine(program->get_engine())- , _stream(stream)- , _memory_pool(new memory_pool(program->get_engine(), program->get_config()))- , _internal(is_internal)- , _is_primary_stream(is_primary_stream)- , _enable_profiling(program->get_config().get_enable_profiling())- , _reset_arguments(true)- , _shape_predictor(new ShapePredictor(&program->get_engine(), program->get_config().get_shape_predictor_settings())) {+ : _program(program),+ _engine(program->get_engine()),+ _stream(stream),+ _memory_pool(new memory_pool(program->get_engine(), program->get_config())),+ _internal(is_internal),+ _is_primary_stream(is_primary_stream),+ _enable_profiling(program->get_config().get_enable_profiling()),+ _reset_arguments(true),+ _shape_predictor(new ShapePredictor(&program->get_engine(), program->get_config().get_shape_predictor_settings())) {if (!_internal) {net_id = get_unique_net_id();}@@ -252,7 +250,7 @@ network::network(program::ptr program, stream::ptr stream, bool is_internal, boo}network::network(program::ptr program, bool is_internal, bool is_primary_stream)- : network(program, program->get_engine().create_stream(program->get_config()), is_internal, is_primary_stream) {}+ : network(program, program->get_engine().create_stream(program->get_config()), is_internal, is_primary_stream) {}network::network(engine& engine,const topology& topo,@@ -271,16 +269,17 @@ network::network(engine& engine,network::network(program::ptr program, uint16_t stream_id): network(program, program->get_engine().create_stream(program->get_config()), false, stream_id == 0) {}-network::network(program::ptr program, stream::ptr stream, uint16_t stream_id)- : network(program, stream, false, stream_id == 0) {}+network::network(program::ptr program, stream::ptr stream, uint16_t stream_id) : network(program, stream, false, stream_id == 0) {}network::~network() {- if (_program != nullptr)+ if (_program != nullptr) {_program->cancel_compilation_context();+ }// Clear the command queue to prevent errors caused by remaining tasks.- if (_stream != nullptr)+ if (_stream != nullptr) {_stream->finish();+ }_memory_pool->clear_pool_for_network(net_id);std::string dump_path = GPU_DEBUG_VALUE_OR(get_config().get_dump_profiling_data_path(), "");@@ -321,7 +320,7 @@ network::ptr network::build_network(engine& engine,void network::validate_primitives() {GPU_DEBUG_DEFINE_MEM_LOGGER("validate_primitives");- for (auto const& prim : _exec_order) {+ for (const auto& prim : _exec_order) {prim->validate();}}@@ -333,24 +332,26 @@ void network::preallocate_shape_info_buffers() {/* Use 512 byte alignment for performance */const int alignment = 512;- for (auto const& prim : _exec_order) {+ for (const auto& prim : _exec_order) {const auto& node = prim->get_node();int64_t shape_elements = align_to(node.get_total_shape_info_size(), alignment);sum += shape_elements;}- if (sum == 0)+ if (sum == 0) {return;+ }auto& engine = get_engine();_shape_info_ptr = engine.allocate_memory(layout{{sum}, data_types::i32, format::bfyx}, false);size_t offset = 0;- for (auto const& prim : _exec_order) {+ for (const auto& prim : _exec_order) {const auto& node = prim->get_node();const int64_t shape_elements = node.get_total_shape_info_size();- if (shape_elements == 0)+ if (shape_elements == 0) {continue;+ }auto new_mem = engine.create_subbuffer(*_shape_info_ptr, layout{{shape_elements}, data_types::i32, format::bfyx}, offset);prim->set_shape_info_memory(new_mem);@@ -360,10 +361,11 @@ void network::preallocate_shape_info_buffers() {}void network::set_arguments() {- if (!_reset_arguments)+ if (!_reset_arguments) {return;+ }- for (auto const& prim : _exec_order) {+ for (const auto& prim : _exec_order) {if (!prim->is_dynamic()) {bool can_set_args = true;for (const auto& dep : prim->dependencies()) {@@ -377,14 +379,15 @@ void network::set_arguments() {// (dynamic) -> static optimizable reshape -> static optimizable reshape -> some_op// In that case, it is a limit about second reshape.auto prim = dep.first->get_impl_params()->desc;- if (dep.first->can_be_optimized() && (dep.first->is_dynamic() ||- dep.first->output_memory_ptr() == nullptr ||- prim->type == read_value::type_id()))+ if (dep.first->can_be_optimized() &&+ (dep.first->is_dynamic() || dep.first->output_memory_ptr() == nullptr || prim->type == read_value::type_id())) {can_set_args = false;+ }}- if (can_set_args)+ if (can_set_args) {prim->set_arguments();+ }}}_reset_arguments = false;@@ -421,8 +424,9 @@ event::ptr network::set_input_data(const primitive_id& id, memory::ptr data, boo// TODO: possibly remove or redesign _in_out_shared_mem_types solutionif (input->output_memory_ptr()) {const auto in_mem_type = input->output_memory_ptr()->get_internal_params().mem_type;- if (std::find(_in_out_shared_mem_types.begin(), _in_out_shared_mem_types.end(), in_mem_type) == _in_out_shared_mem_types.end())+ if (std::find(_in_out_shared_mem_types.begin(), _in_out_shared_mem_types.end(), in_mem_type) == _in_out_shared_mem_types.end()) {_in_out_shared_mem_types.push_back(in_mem_type);+ }}return ev;@@ -442,16 +446,17 @@ void network::calculate_weights_cache_capacity() {return layout.is_dynamic() ? 0 : layout.bytes_count();};- #define is_weightable(T) node.is_type<T>() && node.as<T>().weights().is_constant()- if (node.is_type<data>())+#define is_weightable(T) node.is_type<T>() && node.as<T>().weights().is_constant()+ if (node.is_type<data>()) {weights_size = get_size(node.get_output_layout());- else if (is_weightable(fully_connected))+ } else if (is_weightable(fully_connected)) {weights_size = get_size(node.as<fully_connected>().weights().get_output_layout());- else if (is_weightable(convolution))+ } else if (is_weightable(convolution)) {weights_size = get_size(node.as<convolution>().weights().get_output_layout());- else if (is_weightable(deconvolution))+ } else if (is_weightable(deconvolution)) {weights_size = get_size(node.as<deconvolution>().weights().get_output_layout());- #undef is_weightable+ }+#undef is_weightablereturn weights_size;};@@ -460,10 +465,11 @@ void network::calculate_weights_cache_capacity() {size_t weights_const_size = 0;size_t required_mem_size = 0;for (auto* node : _program->get_processing_order()) {- if (node->is_type<fully_connected>() || node->is_type<convolution>() || node->is_type<deconvolution>())+ if (node->is_type<fully_connected>() || node->is_type<convolution>() || node->is_type<deconvolution>()) {weights_const_size += get_buffer_size(*node);- else if (node->is_type<data>())+ } else if (node->is_type<data>()) {total_const_size += get_buffer_size(*node);+ }}// Sum all weights constants for each stream@@ -476,8 +482,9 @@ void network::calculate_weights_cache_capacity() {const size_t max_device_mem_size = _engine.get_device_info().max_global_mem_size;const size_t max_weights_cache_capacity = max_device_mem_size / required_mem_size;- if (max_weights_cache_capacity > 1)+ if (max_weights_cache_capacity > 1) {_weights_cache_capacity = std::min(max_weights_cache_capacity, required_weights_cache_capacity);+ }}}@@ -490,8 +497,9 @@ network::output_chains_map::iterator network::add_output_chain(std::shared_ptr<pauto add_mdata_chain = [&](primitive_inst* p_inst) {auto* mdata_ptr = dynamic_cast<mutable_data_inst*>(p_inst);- if (!mdata_ptr)+ if (!mdata_ptr) {return;+ }// special handling for mutable data, which can share// its attached memory with both its inputs and outputsfor (const auto& dep : p_inst->dependencies()) {@@ -507,7 +515,7 @@ network::output_chains_map::iterator network::add_output_chain(std::shared_ptr<p}}- //then users+ // then usersconst auto& user_ids = mdata_ptr->get_user_ids();for (const auto& id : user_ids) {auto* usr_prim = get_primitive(id).get();@@ -529,8 +537,7 @@ network::output_chains_map::iterator network::add_output_chain(std::shared_ptr<pconst auto* cand = candidates.top();candidates.pop();// Add cand inst to the chain when cand's output is not allocated yet.- if (!p_inst->outputs_allocated()- || (cand->outputs_allocated() && eng.is_the_same_buffer(*mem_orig, cand->output_memory()))) {+ if (!p_inst->outputs_allocated() || (cand->outputs_allocated() && eng.is_the_same_buffer(*mem_orig, cand->output_memory()))) {auto* nc_cand = const_cast<primitive_inst*>(cand);chain.push_back(nc_cand);add_mdata_chain(nc_cand);@@ -543,8 +550,7 @@ network::output_chains_map::iterator network::add_output_chain(std::shared_ptr<pif (dep.first->outputs_allocated()) {const auto& mem_dep = dep.first->output_memory();// Add dep inst to the chain when dep's output is not allocated yet.- if (!p_inst->outputs_allocated()- || eng.is_the_same_buffer(*mem_orig, mem_dep)) {+ if (!p_inst->outputs_allocated() || eng.is_the_same_buffer(*mem_orig, mem_dep)) {auto* nc_dep = const_cast<primitive_inst*>(dep.first);chain.push_back(nc_dep);add_mdata_chain(nc_dep);@@ -556,7 +562,7 @@ network::output_chains_map::iterator network::add_output_chain(std::shared_ptr<pstd::sort(chain.begin(), chain.end());chain.erase(std::unique(chain.begin(), chain.end()), chain.end());- return _output_chains.insert({ p_inst->id(), chain }).first;+ return _output_chains.insert({p_inst->id(), chain}).first;}std::vector<event::ptr> network::set_output_memory(const primitive_id& id, memory::ptr mem_new, bool is_remote) {@@ -565,8 +571,9 @@ std::vector<event::ptr> network::set_output_memory(const primitive_id& id, memorstd::shared_ptr<primitive_inst> p_inst = find_primitive(id);auto iter = std::find(_outputs.begin(), _outputs.end(), p_inst);- if (iter == _outputs.end())+ if (iter == _outputs.end()) {throw std::runtime_error("primitive: " + id + " is not a network output");+ }if (is_remote) {_output_remote_mem_ptrs[id] = mem_new;@@ -582,8 +589,9 @@ std::vector<event::ptr> network::set_output_memory(const primitive_id& id, memorfor (auto& prim : o_iter->second) {auto mem = mem_new;- if (!prim->is_dynamic() && mem_new && prim->output_memory_ptr())+ if (!prim->is_dynamic() && mem_new && prim->output_memory_ptr()) {mem = eng.reinterpret_buffer(*mem_new, prim->output_memory().get_layout());+ }ret_ev.push_back(prim->set_output_memory(mem, (!prim->is_dynamic() || !is_remote)));if (!_reset_arguments &&@@ -636,10 +644,12 @@ std::string network::get_implementation_info(const primitive_id& id) const {return kernel_name;}}- } catch (...) { }+ } catch (...) {+ }- if (_program == nullptr)+ if (_program == nullptr) {return "undef";+ }return _program->get_implementation_info(id);}@@ -662,9 +672,8 @@ void network::allocate_primitives() {auto& po = _program->get_processing_order();// Update the output memory address of optimized-out layer if it is not valid.- for (auto const& node : po) {- if (node->can_be_optimized() && !node->is_dynamic() &&- (node->get_dependencies().empty() || !node->get_dependency(0).is_type<read_value>())) {+ for (const auto& node : po) {+ if (node->can_be_optimized() && !node->is_dynamic() && (node->get_dependencies().empty() || !node->get_dependency(0).is_type<read_value>())) {auto opt_inst = _primitives.at(node->id());// build deps when prim_inst does not update dependencies yet.if (!node->get_dependencies().empty() && opt_inst->dependencies().empty()) {@@ -672,14 +681,15 @@ void network::allocate_primitives() {}// Skip if the dependency's memory is not yet allocated (e.g. lazy input_layout).// The output memory will be set up at runtime when the input becomes available.- if (!opt_inst->dependencies().empty() && opt_inst->dep_memory_ptr(0) == nullptr)+ if (!opt_inst->dependencies().empty() && opt_inst->dep_memory_ptr(0) == nullptr) {continue;+ }opt_inst->update_output_memory();}}// allocate intermediate buffers- for (auto const& node : po) {+ for (const auto& node : po) {auto prim = _primitives[node->id()];prim->allocate_internal_buffers();}@@ -691,21 +701,24 @@ void network::configure_primitives_second_output() {for (auto& inst : _primitives) {const auto& node = inst.second->get_node();- if (!node.is_type<mutable_data>())+ if (!node.is_type<mutable_data>()) {continue;+ }mutable_datas_ptrs[node.as<mutable_data>().get_attached_memory_ptr()].push_back(&node);}for (auto item : mutable_datas_ptrs) {- if (item.second.size() != 2)+ if (item.second.size() != 2) {continue;+ }auto is_first_node_input_md = [&](const cldnn::program_node* first, const cldnn::program_node* second) {for (const auto* user : first->get_users()) {for (const auto* next_user : user->get_users()) {- if (next_user == second)+ if (next_user == second) {return true;+ }}}return false;@@ -742,8 +755,8 @@ void network::build_exec_order() {return (node->is_dynamic() && node->is_type<concatenation>() && node->can_be_optimized());};auto is_allowed_pred_for_runtime_optimized_concat = [&](const program_node* node) {- return (!node->is_type<data>() && (!node->is_type<mutable_data>() || !node->get_dependencies().empty()) &&- node->get_users().size() == 1 && is_runtime_optimized_concat(node->get_users().front()));+ return (!node->is_type<data>() && (!node->is_type<mutable_data>() || !node->get_dependencies().empty()) && node->get_users().size() == 1 &&+ is_runtime_optimized_concat(node->get_users().front()));};for (const auto& node : _program->get_processing_order()) {if (!node->is_type<data>() && (!node->is_type<mutable_data>() || !node->get_dependencies().empty())) {@@ -817,8 +830,9 @@ void network::invalidate_ext_block_compute_nodes(const primitive_id& output_id)auto dep = find_primitive(dep_id);// Stop before runtime-skippable nodes: their can_be_optimized() may// have been re-evaluated at runtime — they are the compute boundary.- if (dep->get_node().is_runtime_skippable())+ if (dep->get_node().is_runtime_skippable()) {break;+ }cursor = dep;}// cursor is now the compute node — clear its output so it re-acquires from ext_block@@ -833,8 +847,9 @@ void network::register_output_memory_block(const primitive_id& id, ov::intel_gpuauto [it, inserted] = _output_memory_blocks.emplace(id, block);if (!inserted) {- if (it->second == block)+ if (it->second == block) {return; // Same block already registered — nothing to do+ }it->second = block;}}@@ -873,21 +888,19 @@ std::map<primitive_id, network_output> network::execute(const std::vector<event:reset_execution(false);std::vector<memory::ptr> in_out_mem;- bool shared_mem_found = std::any_of(_in_out_shared_mem_types.begin(),- _in_out_shared_mem_types.end(),- surfaces_lock::is_lock_needed);+ bool shared_mem_found = std::any_of(_in_out_shared_mem_types.begin(), _in_out_shared_mem_types.end(), surfaces_lock::is_lock_needed);if (shared_mem_found) {for (auto& inst : _inputs) {- if (inst->output_memory_ptr() &&- surfaces_lock::is_lock_needed(inst->output_memory_ptr()->get_internal_params().mem_type))+ if (inst->output_memory_ptr() && surfaces_lock::is_lock_needed(inst->output_memory_ptr()->get_internal_params().mem_type)) {in_out_mem.push_back(inst->output_memory_ptr());+ }}for (auto& inst : _outputs) {- if (inst->output_memory_ptr() &&- surfaces_lock::is_lock_needed(inst->output_memory_ptr()->get_internal_params().mem_type))+ if (inst->output_memory_ptr() && surfaces_lock::is_lock_needed(inst->output_memory_ptr()->get_internal_params().mem_type)) {in_out_mem.push_back(inst->output_memory_ptr());+ }}}@@ -918,8 +931,9 @@ std::map<primitive_id, network_output> network::execute(const std::vector<event:for (auto& inst : _outputs) {event::ptr ev = nullptr;const auto& id = inst->id();- if (get_stream().get_queue_type() == QueueTypes::out_of_order || _enable_profiling)+ if (get_stream().get_queue_type() == QueueTypes::out_of_order || _enable_profiling) {ev = inst->get_impl_params()->out_event;+ }result.emplace(id, network_output(ev, inst->output_memory_ptr(0), get_stream_ptr(), inst->get_output_layout(0)));}@@ -933,8 +947,9 @@ const event::ptr& network::get_primitive_event(const primitive_id& id) const {bool network::has_event(const primitive_id& id) const {auto it = _primitives.find(id);- if (it == _primitives.end())+ if (it == _primitives.end()) {return false;+ }return it->second->get_impl_params()->out_event != nullptr;}@@ -963,8 +978,9 @@ void network::execute_impl(const std::vector<event::ptr>& events) {inst->execute();executed_prims++;- if (needs_flushing && executed_prims % flush_frequency == 0)+ if (needs_flushing && executed_prims % flush_frequency == 0) {get_stream().flush();+ }}// Using output of previous network as input to another one may cause hazard (in OOOQ mode) if user would not@@ -981,29 +997,32 @@ void network::execute_impl(const std::vector<event::ptr>& events) {std::vector<primitive_id> network::get_input_ids() const {std::vector<primitive_id> ret;ret.reserve(_inputs.size());- for (auto const& input : _inputs) ret.push_back(input->id());+ for (const auto& input : _inputs)+ ret.push_back(input->id());return ret;}std::vector<layout> network::get_input_layouts() const {std::vector<layout> ret;ret.reserve(_inputs.size());- for (auto const& input : _inputs)+ for (const auto& input : _inputs) {ret.push_back(input->output_memory_ptr() ? input->output_memory_ptr()->get_layout() : input->get_output_layout());+ }return ret;}std::vector<primitive_id> network::get_output_ids() const {std::vector<primitive_id> ret;ret.reserve(_outputs.size());- for (auto const& output : _outputs) ret.push_back(output->id());+ for (const auto& output : _outputs)+ ret.push_back(output->id());return ret;}std::vector<primitive_id> network::get_executed_primitive_ids() const {std::vector<primitive_id> ret;ret.reserve(_exec_order.size());- for (auto const& executed_primitive : _exec_order) {+ for (const auto& executed_primitive : _exec_order) {ret.push_back(executed_primitive->id());}return ret;@@ -1012,18 +1031,21 @@ std::vector<primitive_id> network::get_executed_primitive_ids() const {std::vector<primitive_id> network::get_all_primitive_ids() const {std::vector<primitive_id> ret;ret.reserve(_primitives.size());- for (auto const& primitive : _primitives)- if (primitive.second->can_be_optimized())+ for (const auto& primitive : _primitives) {+ if (primitive.second->can_be_optimized()) {ret.push_back("_optimized_");- else+ } else {ret.push_back(primitive.second->id());+ }+ }return ret;}std::vector<primitive_id> network::get_all_primitive_org_ids() const {std::vector<primitive_id> ret;ret.reserve(_primitives.size());- for (auto const& primitive : _primitives) ret.push_back(primitive.second->org_id());+ for (const auto& primitive : _primitives)+ ret.push_back(primitive.second->org_id());return ret;}@@ -1051,8 +1073,9 @@ std::map<primitive_id, primitive_id> network::get_ext_id_mapping() const {}std::shared_ptr<primitive_inst> network::get_primitive(const primitive_id& id) {- if (!_primitives.count(id))+ if (!_primitives.count(id)) {allocate_primitive_instance(_program->get_node(id));+ }return _primitives.at(id);}@@ -1078,9 +1101,10 @@ std::vector<std::pair<primitive_inst*, int>> network::get_primitives(const std::return result;}-void network::allocate_primitive_instance(program_node const& node) {- if (_primitives.count(node.id()))+void network::allocate_primitive_instance(const program_node& node) {+ if (_primitives.count(node.id())) {return;+ }GPU_DEBUG_TRACE_DETAIL << node.id() << ": allocate primitive instance" << std::endl;@@ -1115,20 +1139,22 @@ void network::allocate_primitive_instance(program_node const& node) {inst->set_flag(ExecutionFlags::MEMORY_CHANGED);}-_primitives[node.id()] = inst;if (node.is_type<input_layout>()) {- if (inst->output_memory_ptr())+ if (inst->output_memory_ptr()) {_in_out_shared_mem_types.push_back(inst->output_memory_ptr()->get_internal_params().mem_type);+ }_inputs.push_back(inst);}if (node.is_output()) {- if (inst->output_memory_ptr())+ if (inst->output_memory_ptr()) {_in_out_shared_mem_types.push_back(inst->output_memory_ptr()->get_internal_params().mem_type);+ }_outputs.push_back(inst);- if (node.is_type<data>())+ if (node.is_type<data>()) {_data_outputs.push_back(inst);+ }}bool is_lora_state = false;@@ -1153,8 +1179,7 @@ void network::allocate_primitive_instance(program_node const& node) {if (is_lora_state) {const auto& lora_prim = node.get_users().front()->as<lora>().get_primitive();for (size_t state_idx : {2, 4, 5, 7, 8, 10}) {- if (state_idx < lora_prim->input.size() &&- lora_prim->input[state_idx].pid == node.id()) {+ if (state_idx < lora_prim->input.size() && lora_prim->input[state_idx].pid == node.id()) {transpose_required = lora_prim->transposed_states;}}@@ -1172,40 +1197,43 @@ void network::allocate_primitive_instance(program_node const& node) {}}-void network::transfer_memory_to_device(std::shared_ptr<primitive_inst> instance, program_node const& node) {+void network::transfer_memory_to_device(std::shared_ptr<primitive_inst> instance, const program_node& node) {OV_ITT_SCOPED_TASK(ov::intel_gpu::itt::domains::intel_gpu_plugin, "NetworkImpl::TransferMemory");auto& inst_mem = instance->output_memory();auto alloc_type = inst_mem.get_allocation_type();const auto& users = node.get_users();- if (users.size() == 1- && users.front()->is_type<reshape>()- && users.front()->is_dynamic())- return;+ if (users.size() == 1 && users.front()->is_type<reshape>() && users.front()->is_dynamic()) {+ return;+ }if (node.is_type<data>() && node.as<data>().get_primitive()->skip_device_transfer()) {return;}// Do not transfer memory if a user requires lockable memory.// If memory is used in both gpu and cpu implementations, primitive itself is responsible for correct allocation type- if (node.need_lockable_memory())+ if (node.need_lockable_memory()) {return;+ }- if (!get_engine().supports_allocation(allocation_type::usm_device))+ if (!get_engine().supports_allocation(allocation_type::usm_device)) {return;+ }- if (!get_engine().get_device_info().has_separate_cache)+ if (!get_engine().get_device_info().has_separate_cache) {return;+ }- if (node.is_shape_infer_dep())+ if (node.is_shape_infer_dep()) {return;+ }- if (inst_mem.count() == 0)+ if (inst_mem.count() == 0) {return;+ }if (alloc_type == allocation_type::usm_host || alloc_type == allocation_type::usm_shared) {// usm_device memory does not provide performance benefits on the integrated Xe2+ platforms- if (get_engine().get_device_info().arch >= gpu_arch::xe2 &&- get_engine().get_device_info().dev_type == device_type::integrated_gpu) {+ if (get_engine().get_device_info().arch >= gpu_arch::xe2 && get_engine().get_device_info().dev_type == device_type::integrated_gpu) {return;}@@ -1223,17 +1251,17 @@ void network::set_variable(const std::string& name, const std::shared_ptr<ov::in_variables_states[name] = variable;}-bool network::has_variable(const std::string &variable_id) const {+bool network::has_variable(const std::string& variable_id) const {return _variables_states.find(variable_id) != _variables_states.end();}-ov::intel_gpu::VariableStateBase& network::get_variable(const std::string &variable_id) const {+ov::intel_gpu::VariableStateBase& network::get_variable(const std::string& variable_id) const {auto it = _variables_states.find(variable_id);OPENVINO_ASSERT(it != _variables_states.end(), "[GPU] ", variable_id, " variable not found");return *it->second;}-const ov::intel_gpu::VariableStateInfo& network::get_variable_info(const std::string &variable_id) const {+const ov::intel_gpu::VariableStateInfo& network::get_variable_info(const std::string& variable_id) const {auto it = _variables_state_info.find(variable_id);OPENVINO_ASSERT(it != _variables_state_info.end(), "[GPU] ", variable_id, " variable info not found");return it->second;@@ -1266,5 +1294,4 @@ void network::set_reuse_variable_mem(bool reuse) {_reuse_variable_mem = reuse;}-} // namespace cldnndiff --git a/src/plugins/intel_gpu/src/graph/nodes_ordering.cpp b/src/plugins/intel_gpu/src/graph/nodes_ordering.cppindex 82d894dec4c..40231d295ff 100644--- a/src/plugins/intel_gpu/src/graph/nodes_ordering.cpp+++ b/src/plugins/intel_gpu/src/graph/nodes_ordering.cpp@@ -2,17 +2,19 @@// SPDX-License-Identifier: Apache-2.0//+#include <algorithm>+#include <map>+#include <vector>+#include "intel_gpu/graph/program.hpp"#include "program_node.h"-#include <vector>-#include <map>-#include <algorithm>namespace cldnn {// helper method for calc_processing ordervoid program::nodes_ordering::calc_processing_order_visit(program_node* node) {- if (node->is_marked())+ if (node->is_marked()) {return;+ }for (auto* user : node->users) {calc_processing_order_visit(user);}diff --git a/src/plugins/intel_gpu/src/graph/non_max_suppression.cpp b/src/plugins/intel_gpu/src/graph/non_max_suppression.cppindex ce3c659a5c1..430dc83623a 100644--- a/src/plugins/intel_gpu/src/graph/non_max_suppression.cpp+++ b/src/plugins/intel_gpu/src/graph/non_max_suppression.cpp@@ -144,15 +144,18 @@ void non_max_suppression_gather_inst::on_execute() {}void non_max_suppression_gather_inst::update_output_memory() {- if (!can_be_optimized())+ if (!can_be_optimized()) {return;+ }for (size_t i = 0; i < inputs_memory_count(); i++) {- if (get_node().get_program().is_new_shape_infer() && input_memory_ptr(i) == nullptr)+ if (get_node().get_program().is_new_shape_infer() && input_memory_ptr(i) == nullptr) {return;+ }- if (output_memory_ptr(i) != nullptr && _network.get_engine().is_the_same_buffer(output_memory(i), input_memory(i)))+ if (output_memory_ptr(i) != nullptr && _network.get_engine().is_the_same_buffer(output_memory(i), input_memory(i))) {return;+ }// Can_be_optimized nodes are allocating from memory_pool too. In this case,// we need release the legacy output memory from memory pool explicitly.diff --git a/src/plugins/intel_gpu/src/graph/normalize.cpp b/src/plugins/intel_gpu/src/graph/normalize.cppindex 93952fb3ec8..77d3a3cde75 100644--- a/src/plugins/intel_gpu/src/graph/normalize.cpp+++ b/src/plugins/intel_gpu/src/graph/normalize.cpp@@ -49,8 +49,9 @@ std::string normalize_inst::to_string(normalize_node const& node) {}normalize_inst::typed_primitive_inst(network& network, normalize_node const& node) : parent(network, node) {- if (node.input().is_dynamic() || node.scale().is_dynamic())+ if (node.input().is_dynamic() || node.scale().is_dynamic()) {return;+ }/// Scale f dimension should be 1 (if all channels have the same scale) or equal to input feature size (one scale per channel).auto scale_layout = node.scale().get_output_layout();auto scale_size = scale_layout.get_tensor();diff --git a/src/plugins/intel_gpu/src/graph/one_hot.cpp b/src/plugins/intel_gpu/src/graph/one_hot.cppindex bc93feb4dc7..15d34dfe066 100644--- a/src/plugins/intel_gpu/src/graph/one_hot.cpp+++ b/src/plugins/intel_gpu/src/graph/one_hot.cpp@@ -16,10 +16,12 @@ namespace cldnn {GPU_DEFINE_PRIMITIVE_TYPE_ID(one_hot)static bool is_output_bfzyx(const layout& input, int64_t axis) {- if (input.format == format::bfzyx)+ if (input.format == format::bfzyx) {return true;- if (axis == 4)+ }+ if (axis == 4) {return true;+ }auto in_dims = input.get_tensor().sizes(format::bfyx);return in_dims[3] != 1;}@@ -36,8 +38,9 @@ layout one_hot_inst::calc_output_layout(one_hot_node const& node, kernel_impl_pa"Incorrect parameters configuration: one_hot_axis should be less or equal to 4.");}- if (is_output_bfzyx(input_layout, desc->one_hot_axis))+ if (is_output_bfzyx(input_layout, desc->one_hot_axis)) {format = format::bfzyx;+ }return {dt, format, desc->shape};}@@ -111,8 +114,9 @@ std::string one_hot_inst::to_string(one_hot_node const& node) {one_hot_inst::typed_primitive_inst(network& network, one_hot_node const& node) : parent(network, node) {auto input_layout = node.get_input_layout();- if (input_layout.is_dynamic())+ if (input_layout.is_dynamic()) {return;+ }const auto& input_sizes = input_layout.get_tensor();const auto& output_sizes = argument->shape;@@ -133,8 +137,9 @@ one_hot_inst::typed_primitive_inst(network& network, one_hot_node const& node) :const auto& one_hot_axis = node.get_primitive()->one_hot_axis;for (int64_t i = 0, j = 0; j < static_cast<int64_t>(output_dims.size()) - 1; ++i, ++j) {- if (j == one_hot_axis)+ if (j == one_hot_axis) {++j;+ }if (input_dims[i] != output_dims[j]) {CLDNN_ERROR_MESSAGE(node.id(), "Incorrect parameters configuration: shape does not fit input size.");}diff --git a/src/plugins/intel_gpu/src/graph/pass_manager.cpp b/src/plugins/intel_gpu/src/graph/pass_manager.cppindex 4068982af19..36944c9f7fe 100644--- a/src/plugins/intel_gpu/src/graph/pass_manager.cpp+++ b/src/plugins/intel_gpu/src/graph/pass_manager.cpp@@ -70,8 +70,9 @@ void pass_manager::run(program& p, base_pass& pass) {}std::string dump_file_name;- if (pass_count < 10)+ if (pass_count < 10) {dump_file_name += "0";+ }dump_file_name += std::to_string(pass_count) + "_" + pass.get_name();p.dump_program(dump_file_name.c_str(), true);pass_count++;diff --git a/src/plugins/intel_gpu/src/graph/permute.cpp b/src/plugins/intel_gpu/src/graph/permute.cppindex d91ed138ad1..fe805905f09 100644--- a/src/plugins/intel_gpu/src/graph/permute.cpp+++ b/src/plugins/intel_gpu/src/graph/permute.cpp@@ -125,8 +125,9 @@ permute_inst::typed_primitive_inst(network& network, permute_node const& node) :auto required_order_values_size = static_cast<uint32_t>(permute_order.size());for (decltype(required_order_values_size) i = 0; i < required_order_values_size; i++) {- if (!(std::find(permute_order.begin(), permute_order.end(), i) != permute_order.end()))+ if (!(std::find(permute_order.begin(), permute_order.end(), i) != permute_order.end())) {CLDNN_ERROR_MESSAGE(node.id(), "Permute order does not contain all of required values.");+ }}update_output_memory();@@ -138,17 +139,20 @@ void permute_inst::on_execute() {void permute_inst::update_output_memory() {- if (!can_be_optimized() || _impl_params->is_dynamic())+ if (!can_be_optimized() || _impl_params->is_dynamic()) {return;+ }build_deps();- if (input_memory_ptr() == nullptr)+ if (input_memory_ptr() == nullptr) {return;+ }if (!_outputs.empty() && static_cast<bool>(_outputs[0])- && _network.get_engine().is_the_same_buffer(output_memory(), input_memory()))+ && _network.get_engine().is_the_same_buffer(output_memory(), input_memory())) {return;+ }GPU_DEBUG_TRACE_DETAIL << id() << " : update_output_memory with mem of input " << get_node().get_dependency(0).id()<< " : " << input_memory_ptr()->buffer_ptr() << std::endl;diff --git a/src/plugins/intel_gpu/src/graph/primitive_inst.cpp b/src/plugins/intel_gpu/src/graph/primitive_inst.cppindex c0300efdf85..45fed92c13b 100644--- a/src/plugins/intel_gpu/src/graph/primitive_inst.cpp+++ b/src/plugins/intel_gpu/src/graph/primitive_inst.cpp@@ -2,71 +2,70 @@// SPDX-License-Identifier: Apache-2.0//+#include "primitive_inst.h"++#include <algorithm>+#include <memory>#include <sstream>+#include <string>+#include <vector>-#include "intel_gpu/graph/kernel_impl_params.hpp"-#include "intel_gpu/primitives/implementation_desc.hpp"-#include "intel_gpu/runtime/stream.hpp"-#include "program_helpers.h"-#include "primitive_inst.h"-#include "data_inst.h"-#include "mutable_data_inst.h"-#include "input_layout_inst.h"#include "arg_max_min_inst.h"-#include "fully_connected_inst.h"+#include "assign_inst.h"+#include "broadcast_inst.h"+#include "condition_inst.h"#include "convolution_inst.h"#include "crop_inst.h"-#include "pooling_inst.h"-#include "permute_inst.h"-#include "resample_inst.h"-#include "non_max_suppression_inst.h"-#include "reshape_inst.h"-#include "reorder_inst.h"-#include "eltwise_inst.h"-#include "loop_inst.h"+#include "data_inst.h"#include "deconvolution_inst.h"-#include "shape_of_inst.h"-#include "softmax_inst.h"-#include "strided_slice_inst.h"-#include "scatter_elements_update_inst.h"-#include "scatter_nd_update_inst.h"-#include "scatter_update_inst.h"-#include "gemm_inst.h"-#include "assign_inst.h"-#include "read_value_inst.h"-#include "kv_cache_inst.h"-#include "condition_inst.h"-#include "paged_attention_inst.h"-#include "gather_inst.h"-#include "broadcast_inst.h"#include "dynamic_quantize_inst.h"-#include "swiglu_inst.h"+#include "eltwise_inst.h"#include "experimental_detectron_roi_feature_extractor_inst.hpp"-#include "lora_inst.h"-#include "registry/implementation_manager.hpp"-#include "registry/registry.hpp"+#include "fully_connected_inst.h"+#include "gather_inst.h"+#include "gemm_inst.h"#include "graph_optimizer/prepare_buffer_fusing.h"-+#include "input_layout_inst.h"+#include "intel_gpu/graph/kernel_impl_params.hpp"+#include "intel_gpu/graph/network.hpp"+#include "intel_gpu/graph/serialization/set_serializer.hpp"#include "intel_gpu/plugin/common_utils.hpp"#include "intel_gpu/plugin/multi_tensor_variable_state.hpp"#include "intel_gpu/plugin/sync_infer_request.hpp"-#include "intel_gpu/graph/network.hpp"-#include "intel_gpu/graph/serialization/set_serializer.hpp"+#include "intel_gpu/primitives/implementation_desc.hpp"+#include "intel_gpu/runtime/compilation_context.hpp"+#include "intel_gpu/runtime/debug_configuration.hpp"#include "intel_gpu/runtime/engine.hpp"#include "intel_gpu/runtime/memory.hpp"-#include "intel_gpu/runtime/debug_configuration.hpp"-#include "intel_gpu/runtime/compilation_context.hpp"+#include "intel_gpu/runtime/stream.hpp"#include "intel_gpu/runtime/tensor_accessor.hpp"-#include "json_object.h"-#include <string>-#include <vector>-#include <memory>-#include <algorithm>+#include "kv_cache_inst.h"+#include "loop_inst.h"+#include "lora_inst.h"+#include "mutable_data_inst.h"+#include "non_max_suppression_inst.h"+#include "paged_attention_inst.h"+#include "permute_inst.h"+#include "pooling_inst.h"+#include "program_helpers.h"+#include "read_value_inst.h"+#include "registry/implementation_manager.hpp"+#include "registry/registry.hpp"+#include "reorder_inst.h"+#include "resample_inst.h"+#include "reshape_inst.h"+#include "scatter_elements_update_inst.h"+#include "scatter_nd_update_inst.h"+#include "scatter_update_inst.h"+#include "shape_of_inst.h"+#include "softmax_inst.h"+#include "strided_slice_inst.h"+#include "swiglu_inst.h"#include "utils.hpp"#ifdef ENABLE_ONEDNN_FOR_GPU-#include <impls/onednn/utils.hpp>+# include <impls/onednn/utils.hpp>#endifnamespace cldnn {@@ -75,8 +74,9 @@ namespace {template <typename T>bool is_optimized_output_user(const T user) {if (user->can_be_optimized()) {- if (user->is_output())+ if (user->is_output()) {return true;+ }auto users = user->get_users();for (const auto& u : users) {@@ -89,8 +89,9 @@ bool is_optimized_output_user(const T user) {return false;}bool is_output_buffer(const primitive_inst* prim, bool runtime_alloc) {- if (prim->is_output())+ if (prim->is_output()) {return true;+ }// Try to recursively find any optimized out user which is also network outputif (runtime_alloc) {@@ -119,8 +120,7 @@ bool is_user_cpu(const program_node* user) {}}}- bool is_cpu = user->get_selected_impl() ? user->get_selected_impl()->is_cpu()- : user->get_preferred_impl_type() == impl_types::cpu;+ bool is_cpu = user->get_selected_impl() ? user->get_selected_impl()->is_cpu() : user->get_preferred_impl_type() == impl_types::cpu;return is_cpu;}@@ -134,19 +134,21 @@ bool has_cpu_user_not_shape_of(const program_node* user) {}return false;}- if (auto* impl = user->get_selected_impl())- // Use requires_lockable_input() rather than is_cpu() directly. Some impls are- // registered as CPU but do not actually access their inputs from the host- // (e.g. assign, which only enqueues USM memcpy).- // Those impls opt out of forcing their producer into lockable memory.+ if (auto* impl = user->get_selected_impl()) {+ // Use requires_lockable_input() rather than is_cpu() directly. Some impls+ // are registered as CPU but do not actually access their inputs from the+ // host (e.g. assign, which only enqueues USM memcpy). Those impls opt out+ // of forcing their producer into lockable memory.return impl->requires_lockable_input() && !user->is_type<shape_of>();+ }return false;}bool has_any_cpu_user_not_shape_of(const std::list<const program_node*>& users) {for (const auto& user : users) {- if (has_cpu_user_not_shape_of(user))+ if (has_cpu_user_not_shape_of(user)) {return true;+ }}return false;}@@ -158,44 +160,39 @@ primitive_id tag_port_number(const primitive_id& in, size_t port = 0) {bool is_any_user_cpu(const std::list<const program_node*>& users) {for (const auto& user : users) {- if (is_user_cpu(user))+ if (is_user_cpu(user)) {return true;+ }}return false;}static memory::ptr get_memory_from_pool(engine& _engine,- uint32_t net_id,- memory_pool& pool,- const program_node& _node,- const layout& layout,- allocation_type type,- bool reusable_across_network,- const memory_restricter<uint32_t>& memory_dependencies,- bool reset = true,- memory* curr_memory = nullptr) {- OPENVINO_ASSERT(!layout.is_dynamic() || layout.has_upper_bound(),- "[GPU] Can't allocate output for dynamic layout without upper bound");+ uint32_t net_id,+ memory_pool& pool,+ const program_node& _node,+ const layout& layout,+ allocation_type type,+ bool reusable_across_network,+ const memory_restricter<uint32_t>& memory_dependencies,+ bool reset = true,+ memory* curr_memory = nullptr) {+ OPENVINO_ASSERT(!layout.is_dynamic() || layout.has_upper_bound(), "[GPU] Can't allocate output for dynamic layout without upper bound");// Use layout with max tensor for dynamic shape with upper boundif (_node.get_program().get_config().get_enable_memory_pool()) {- if (curr_memory != nullptr)+ if (curr_memory != nullptr) {pool.release_memory(curr_memory, _node.get_unique_id(), _node.id(), net_id);- return pool.get_memory(layout,- _node.id(),- _node.get_unique_id(),- net_id,- memory_dependencies,- type,- reusable_across_network,- reset,- _node.is_dynamic());+ }+ return pool+ .get_memory(layout, _node.id(), _node.get_unique_id(), net_id, memory_dependencies, type, reusable_across_network, reset, _node.is_dynamic());}return pool.get_memory(layout, type, reset);}std::shared_ptr<kernel_impl_params> primitive_impl::get_weights_reorder_kernel_params() const {- if (!need_weights_reorder())+ if (!need_weights_reorder()) {return nullptr;+ }auto reorder_kernel_params = std::make_shared<kernel_impl_params>();auto prim = std::make_shared<reorder>("", input_info(), _weights_reorder_params);@@ -220,7 +217,9 @@ kernel_impl_params primitive_impl::static_canonicalize_shapes(const kernel_impl_return updated_impl_params;}-uint32_t primitive_inst::get_network_id() const { return get_network().get_id(); }+uint32_t primitive_inst::get_network_id() const {+ return get_network().get_id();+}void primitive_inst::check_memory_compatibility(const memory& mem, const layout& l) const {// The layout with empty tensor (scalar) is regarded as 1 dimension with value 1@@ -231,23 +230,33 @@ void primitive_inst::check_memory_compatibility(const memory& mem, const layout&}const auto& mem_layout = mem.get_layout();- OPENVINO_ASSERT((mem_layout == l)- || l.is_dynamic()- || (mem_layout.get_partial_shape().size() == 0 && single_value_layout),- "[GPU] Unexpected layout of input memory for ", id(), " node!\n",- "Node layout: ", l.to_short_string(), "\n",- "Memory layout: ", mem_layout.to_short_string());+ OPENVINO_ASSERT((mem_layout == l) || l.is_dynamic() || (mem_layout.get_partial_shape().size() == 0 && single_value_layout),+ "[GPU] Unexpected layout of input memory for ",+ id(),+ " node!\n",+ "Node layout: ",+ l.to_short_string(),+ "\n",+ "Memory layout: ",+ mem_layout.to_short_string());// check shared image/buffer compatibility, if applicableauto params = mem.get_internal_params();if (params.mem_type != shared_mem_type::shared_mem_empty) {auto& net_engine = get_network().get_engine();auto& mem_engine = *mem.get_engine();- OPENVINO_ASSERT(mem.is_allocated_by(net_engine), "[GPU] Can't set memory due to engines mismatch. ",- "Network was created for ", &net_engine, " (",- net_engine.get_device_info().dev_name, ") engine",- " while memory object was allocated for ", &mem_engine, " (",- mem_engine.get_device_info().dev_name, ")");+ OPENVINO_ASSERT(mem.is_allocated_by(net_engine),+ "[GPU] Can't set memory due to engines mismatch. ",+ "Network was created for ",+ &net_engine,+ " (",+ net_engine.get_device_info().dev_name,+ ") engine",+ " while memory object was allocated for ",+ &mem_engine,+ " (",+ mem_engine.get_device_info().dev_name,+ ")");switch (params.mem_type) {case shared_mem_type::shared_mem_vasurface:@@ -277,8 +286,9 @@ event::ptr primitive_inst::set_output_memory(memory::ptr mem_new, bool check, siconst auto& ol = _impl_params->get_output_layout(idx);- if (check)+ if (check) {check_memory_compatibility(*mem_new, ol);+ }if (is_constant()) {ev = mem_new->copy_from(get_network().get_stream(), *_outputs[idx], false);@@ -293,9 +303,8 @@ void primitive_inst::update_shape() {OV_ITT_SCOPED_TASK(ov::intel_gpu::itt::domains::intel_gpu_plugin, openvino::itt::handle("update_shape: " + id()));GPU_DEBUG_PROFILED_STAGE(instrumentation::pipeline_stage::shape_inference);if (_update_shape_done_by_other) {- _update_shape_done_by_other = false; // reset- GPU_DEBUG_TRACE_DETAIL << id() << ": update shape is done by other: "- << _impl_params->output_layouts[0].to_short_string() << std::endl;+ _update_shape_done_by_other = false; // reset+ GPU_DEBUG_TRACE_DETAIL << id() << ": update shape is done by other: " << _impl_params->output_layouts[0].to_short_string() << std::endl;return;}bool input_shape_changed = false;@@ -304,8 +313,7 @@ void primitive_inst::update_shape() {auto new_shape = _deps[i].first->_impl_params->get_output_layout(idx);if (_impl_params->get_input_layout(i) != new_shape) {GPU_DEBUG_TRACE_DETAIL << id() << ": update shape dep [" << i << "] : " << _deps[i].first->id()- << " was: " << _impl_params->get_input_layout(i).to_short_string()- << " now: " << new_shape.to_short_string() << std::endl;+ << " was: " << _impl_params->get_input_layout(i).to_short_string() << " now: " << new_shape.to_short_string() << std::endl;_impl_params->input_layouts[i] = new_shape;input_shape_changed = true;}@@ -341,8 +349,9 @@ void primitive_inst::update_shape() {}};- if (_impl_params->state_layouts.empty())+ if (_impl_params->state_layouts.empty()) {_impl_params->state_layouts.resize(1);+ }// Initial variable shape is taken from variable itselfauto new_layout = variable.get_layout();@@ -412,26 +421,29 @@ void primitive_inst::update_shape() {if (memory_deps.count(i) > 0) {continue;}- if (i >= _deps.size())+ if (i >= _deps.size()) {continue;+ }if (_deps[i].first->get_node().is_in_shape_of_subgraph() &&- (_deps[i].first->get_node().get_selected_impl() ? _deps[i].first->get_node().get_selected_impl()->is_cpu()- : _deps[i].first->get_node().get_preferred_impl_type() == impl_types::cpu)) {+ (_deps[i].first->get_node().get_selected_impl() ? _deps[i].first->get_node().get_selected_impl()->is_cpu()+ : _deps[i].first->get_node().get_preferred_impl_type() == impl_types::cpu)) {bool can_skip = true;const auto& insts = _deps[i].first->_dependant_shape_of_insts;for (const auto& inst : insts) {can_skip &= !inst->get_flag(ExecutionFlags::SHAPE_CHANGED);}- if (can_skip)+ if (can_skip) {continue;+ }}input_shape_changed = true;}- if (!get_node().is_type<kv_cache>() && !get_node().is_type<strided_slice>() && !input_shape_changed && _impl_params->get_output_layout().is_static())+ if (!get_node().is_type<kv_cache>() && !get_node().is_type<strided_slice>() && !input_shape_changed && _impl_params->get_output_layout().is_static()) {return;+ }std::vector<event::ptr> dependencies_events;auto queue_type = get_network().get_stream().get_queue_type();@@ -457,8 +469,8 @@ void primitive_inst::update_shape() {continue;}- if (!get_node().is_type<shape_of>() &&- !(dep->get_node().get_selected_impl() ? dep->get_node().get_selected_impl()->is_cpu() : dep->get_node().get_preferred_impl_type() == impl_types::cpu)) {+ if (!get_node().is_type<shape_of>() && !(dep->get_node().get_selected_impl() ? dep->get_node().get_selected_impl()->is_cpu()+ : dep->get_node().get_preferred_impl_type() == impl_types::cpu)) {has_runtime_deps = true;// Events may be not created for in-order queue, so take them for OOO queue only@@ -493,8 +505,7 @@ void primitive_inst::update_shape() {}if (impl_layout != new_layout) {- GPU_DEBUG_TRACE_DETAIL << id() << ": update shape: was: " << impl_layout.to_short_string()- << " now: " << new_layout.to_short_string() << std::endl;+ GPU_DEBUG_TRACE_DETAIL << id() << ": update shape: was: " << impl_layout.to_short_string() << " now: " << new_layout.to_short_string() << std::endl;set_flag(ExecutionFlags::SHAPE_CHANGED);}@@ -524,7 +535,7 @@ void primitive_inst::update_shape() {_impl_params->output_layouts[1] = compressed_cache_variable->get_compression_scale_state()->get_layout();if (compressed_cache_variable->has_zp_state()) {- _impl_params->output_layouts[2] = compressed_cache_variable->get_compression_zp_state()->get_layout();+ _impl_params->output_layouts[2] = compressed_cache_variable->get_compression_zp_state()->get_layout();}}}@@ -546,32 +557,35 @@ void primitive_inst::update_shape() {auto var_mem_size = get_network().get_variable(desc->variable_info.variable_id).get_actual_mem_size();// Need to trigger realloc_if_needed- if (var_mem_size < _impl_params->get_output_layout(0).get_linear_size())+ if (var_mem_size < _impl_params->get_output_layout(0).get_linear_size()) {set_flag(ExecutionFlags::SHAPE_CHANGED);+ }}if (get_node().is_type<dynamic_quantize>() && get_flag(ExecutionFlags::SHAPE_CHANGED)) {- auto &layout = _impl_params->get_output_layout(0);+ auto& layout = _impl_params->get_output_layout(0);OPENVINO_ASSERT(one_of(layout.data_type, {data_types::f16, data_types::i8, data_types::u8, data_types::f4e2m1, data_types::f8e4m3, data_types::f8e5m2}),- "[GPU] Unsupported data type of dynamic_quantize: ", layout.data_type);- if (layout.data_type == data_types::f16)+ "[GPU] Unsupported data type of dynamic_quantize: ",+ layout.data_type);+ if (layout.data_type == data_types::f16) {set_can_be_optimized(true);- else+ } else {set_can_be_optimized(false);+ }}// required to zero out the number of valid boxes (third output) when NMS is not executedif (get_node().is_type<non_max_suppression>()) {if (!_impl_params->output_layouts[0].count() && _outputs.size() == 3 && _outputs[2]) {const bool out_of_order_queue = queue_type == QueueTypes::out_of_order;- auto dep_events = out_of_order_queue ? std::vector<event::ptr>{get_network().get_stream().enqueue_marker(_impl_params->dep_events)}- : std::vector<event::ptr>{};+ auto dep_events =+ out_of_order_queue ? std::vector<event::ptr>{get_network().get_stream().enqueue_marker(_impl_params->dep_events)} : std::vector<event::ptr>{};add_dep_event(_outputs[2]->fill(get_network().get_stream(), dep_events));}}}-kernel_impl_params primitive_inst::get_fake_aligned_params_if_possible(program_node const& node, kernel_impl_params const& orig_impl_param) {+kernel_impl_params primitive_inst::get_fake_aligned_params_if_possible(const program_node& node, const kernel_impl_params& orig_impl_param) {// disable if fake alignment is not necessaryif (node.is_output()) {GPU_DEBUG_TRACE_DETAIL << " Disable fake alignment : " << node.id() << " is output node" << std::endl;@@ -580,18 +594,16 @@ kernel_impl_params primitive_inst::get_fake_aligned_params_if_possible(program_nauto updated_params = get_node().type()->get_fake_aligned_params(orig_impl_param);- const auto &dev_info = get_node().get_program().get_engine().get_device_info();+ const auto& dev_info = get_node().get_program().get_engine().get_device_info();// The target HW of this patch is limited because of performance concernif ((dev_info.supports_immad && dev_info.dev_type == device_type::integrated_gpu) || dev_info.gfx_ver.major >= 20) {// Check whether the input node has enough space for output data. Otherwise, fake alignment is not possible due to page fault// i.e. predecessor node was supposed be increased already- if (get_node().is_type<fully_connected>() && !dependencies().empty() && dep_memory(0).get_layout().is_static()- && dep_memory(0).count() < updated_params.input_layouts[0].count()) {- GPU_DEBUG_TRACE_DETAIL << "Roll back fake_aligned params for " << id()- << " allocated: " << dep_memory(0).count()- << " required: " << updated_params.input_layouts[0].count()- << std::endl;+ if (get_node().is_type<fully_connected>() && !dependencies().empty() && dep_memory(0).get_layout().is_static() &&+ dep_memory(0).count() < updated_params.input_layouts[0].count()) {+ GPU_DEBUG_TRACE_DETAIL << "Roll back fake_aligned params for " << id() << " allocated: " << dep_memory(0).count()+ << " required: " << updated_params.input_layouts[0].count() << std::endl;updated_params = *_impl_params;}}@@ -600,18 +612,16 @@ kernel_impl_params primitive_inst::get_fake_aligned_params_if_possible(program_n// Check if all dependencies and its predecessors are CPU or constantstatic bool check_all_deps_cpu(const primitive_inst* inst) {- return std::all_of(inst->dependencies().begin(), inst->dependencies().end(),- [&](const std::pair<const primitive_inst*, int32_t>& dep) {- if (dep.first->is_constant() ||- (dep.first->get_impl() != nullptr && dep.first->get_impl()->is_cpu())) {- return true;- }- // Check if the dependency can be optimized- if (dep.first->can_be_optimized()) {- return check_all_deps_cpu(dep.first);- }- return false;- });+ return std::all_of(inst->dependencies().begin(), inst->dependencies().end(), [&](const std::pair<const primitive_inst*, int32_t>& dep) {+ if (dep.first->is_constant() || (dep.first->get_impl() != nullptr && dep.first->get_impl()->is_cpu())) {+ return true;+ }+ // Check if the dependency can be optimized+ if (dep.first->can_be_optimized()) {+ return check_all_deps_cpu(dep.first);+ }+ return false;+ });}bool primitive_inst::all_dependencies_cpu_impl() const {@@ -623,15 +633,17 @@ bool primitive_inst::need_reset_output_memory() const {// Check users of optimized_out inst, as the optimized out inst will not be able to// reset it's memoryif (user_inst->can_be_optimized()) {- if (user_inst->need_reset_output_memory())+ if (user_inst->need_reset_output_memory()) {return true;+ }continue;}const auto dependency_idx = user_inst->get_node().get_dependency_index(get_node());- if (user_inst->need_reset_input_memory(dependency_idx))+ if (user_inst->need_reset_input_memory(dependency_idx)) {return true;+ }// OneDNN requires zero-filled input for padded areaconst bool is_user_onednn_impl = user_inst->get_node().get_preferred_impl_type() == impl_types::onednn;@@ -642,19 +654,20 @@ bool primitive_inst::need_reset_output_memory() const {auto in_channel_count = get_convolution_channel_count(conv_node, output_layout, true);// If the channel count is dynamic, we cannot verify feature alignment,// so we conservatively do the reset and return true for this condition.- if (in_channel_count == -1)+ if (in_channel_count == -1) {return true;+ }auto get_feature_block_size = [](format fmt) {- int feature_block_size = 1;- for (const auto& e : fmt.block_sizes()) {- if (e.first == 1) {- OPENVINO_ASSERT(feature_block_size == 1, "UNSUPPORTED: multi-blocking for feature axis is not considered");- feature_block_size = e.second;- }- }- return feature_block_size;- };+ int feature_block_size = 1;+ for (const auto& e : fmt.block_sizes()) {+ if (e.first == 1) {+ OPENVINO_ASSERT(feature_block_size == 1, "UNSUPPORTED: multi-blocking for feature axis is not considered");+ feature_block_size = e.second;+ }+ }+ return feature_block_size;+ };const auto fmt = output_layout.format;auto feature_block_size = get_feature_block_size(fmt);@@ -678,26 +691,26 @@ void primitive_inst::realloc_intermediates() {GPU_DEBUG_PROFILED_STAGE(instrumentation::pipeline_stage::memory_allocation);// intermediate memory allocation is required for primitives consisting of multiple kernels in dynamic case- if (_impl == nullptr || _outputs.empty() || _outputs[0] == nullptr)+ if (_impl == nullptr || _outputs.empty() || _outputs[0] == nullptr) {return;+ }- if (get_node().is_type<input_layout>())+ if (get_node().is_type<input_layout>()) {return;+ }const auto& buffer_descs = _impl->get_internal_buffer_descs(*_impl_params);- if (buffer_descs.empty())+ if (buffer_descs.empty()) {return;+ }GPU_DEBUG_CODE(std::string memalloc_info);for (size_t i = 0; i < buffer_descs.size(); ++i) {auto need_lockable = buffer_descs[i].m_lockable;- auto alloc_type = i < _intermediates_memory.size() ? _intermediates_memory[i]->get_allocation_type()- : allocation_type::unknown;+ auto alloc_type = i < _intermediates_memory.size() ? _intermediates_memory[i]->get_allocation_type() : allocation_type::unknown;bool can_reuse = true;- can_reuse &= alloc_type != allocation_type::unknown &&- buffer_descs[i].m_layout.bytes_count() <= _max_intermediates_memory_sizes[i];- can_reuse &= (need_lockable && alloc_type != cldnn::allocation_type::usm_device) ||- (!need_lockable && alloc_type != cldnn::allocation_type::usm_host);+ can_reuse &= alloc_type != allocation_type::unknown && buffer_descs[i].m_layout.bytes_count() <= _max_intermediates_memory_sizes[i];+ can_reuse &= (need_lockable && alloc_type != cldnn::allocation_type::usm_device) || (!need_lockable && alloc_type != cldnn::allocation_type::usm_host);if (can_reuse) {_intermediates_memory[i] = get_network().get_engine().reinterpret_buffer(*_intermediates_memory[i], buffer_descs[i].m_layout);@@ -714,9 +727,8 @@ void primitive_inst::realloc_intermediates() {_intermediates_memory.push_back(allocate_internal_buffer(buffer_descs[i].m_layout, i, need_reset, need_lockable, buffer_descs[i].m_shareable));_max_intermediates_memory_sizes.push_back(_intermediates_memory[i]->size());}- GPU_DEBUG_CODE(memalloc_info +=- (((_intermediates_memory.size() > 1) ? ("i" + to_string(i) + ":") : "") +- (_intermediates_memory[i]->from_memory_pool ? "from_pool" : "new_alloc")));+ GPU_DEBUG_CODE(memalloc_info += (((_intermediates_memory.size() > 1) ? ("i" + to_string(i) + ":") : "") ++ (_intermediates_memory[i]->from_memory_pool ? "from_pool" : "new_alloc")));}}GPU_DEBUG_PROFILED_STAGE_MEMALLOC_INFO(memalloc_info);@@ -743,8 +755,7 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {// In-place concat optimization is rejected now, but a previous execution with this optimization// may have the same memory aliased to its deps' outputs and itself's output. In this case, we// need to reallocate the memory for this node to avoid memory corruption.- GPU_DEBUG_TRACE_DETAIL << id() << ": reallocate memory for concat " << concat_inst->id()- << " after rejected in-place concat" << std::endl;+ GPU_DEBUG_TRACE_DETAIL << id() << ": reallocate memory for concat " << concat_inst->id() << " after rejected in-place concat" << std::endl;clear_output_memory();}}@@ -757,10 +768,8 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {if (users.size() == 1 && users.front()->get_node().is_type<reorder>() && users.front()->can_be_optimized()) {auto* reorder_inst = users.front();- if (reorder_inst->is_output()- && reorder_inst->output_memory_ptr()- && get_network().has_output_remote_memory_ptr(reorder_inst->id())- && get_network().get_engine().is_the_same_buffer(get_network().get_output_remote_memory(reorder_inst->id()), reorder_inst->output_memory())) {+ if (reorder_inst->is_output() && reorder_inst->output_memory_ptr() && get_network().has_output_remote_memory_ptr(reorder_inst->id()) &&+ get_network().get_engine().is_the_same_buffer(get_network().get_output_remote_memory(reorder_inst->id()), reorder_inst->output_memory())) {if (actual_layouts[0].get_linear_size() <= reorder_inst->get_max_output_layout_count()) {this->_outputs[0] = reorder_inst->_outputs[0];GPU_DEBUG_TRACE_DETAIL << id() << ": use reorder user's remote tensor memory " << this->_outputs[0]->buffer_ptr() << std::endl;@@ -772,8 +781,9 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {}// input_layout node is supposed to always use external memory in dynamic case- if (get_node().is_type<input_layout>())+ if (get_node().is_type<input_layout>()) {return;+ }// Forward probe: walk through single-user optimized chains to find an output// node with an external output memory block (ext_block). If found, use the@@ -789,12 +799,9 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {if (ext_block) {ext_block->resize(actual_layouts[0]);_outputs[0] = ext_block->memory();- _max_output_layout_count[0] = _outputs[0]->get_mem_tracker()->size()- / cldnn::data_type_traits::size_of(actual_layouts[0].data_type);- GPU_DEBUG_TRACE_DETAIL << id() << ": use ext output memory block via forward probe -> "- << next->id() << " - "- << actual_layouts[0].get_linear_size() << "/" << _max_output_layout_count[0]- << std::endl;+ _max_output_layout_count[0] = _outputs[0]->get_mem_tracker()->size() / cldnn::data_type_traits::size_of(actual_layouts[0].data_type);+ GPU_DEBUG_TRACE_DETAIL << id() << ": use ext output memory block via forward probe -> " << next->id() << " - "+ << actual_layouts[0].get_linear_size() << "/" << _max_output_layout_count[0] << std::endl;GPU_DEBUG_PROFILED_STAGE_MEMALLOC_INFO("ext_output_block_via_forward_probe");return;}@@ -802,8 +809,9 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {}// Stop at runtime-skippable nodes: their can_be_optimized() is// tentative and may flip to false once their prepare_primitive runs.- if (next->get_node().is_runtime_skippable())+ if (next->get_node().is_runtime_skippable()) {break;+ }cursor = next;}}@@ -822,9 +830,8 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {// otherwise clear _outputs for the cases when mem was reused previouslyif (_impl_params->can_be_optimized()) {GPU_DEBUG_TRACE_DETAIL << id() << " : realloc_if_needed: Set kvcache output memory as variable memory " << variable.get_memory()->buffer_ptr()- << " (ptr: " << variable.get_memory()->buffer_ptr()- << ", actual_size: " << variable.get_actual_mem_size()/8 << " bytes"- << ", variable layout " << variable.get_layout().to_short_string() << ")" << std::endl;+ << " (ptr: " << variable.get_memory()->buffer_ptr() << ", actual_size: " << variable.get_actual_mem_size() / 8+ << " bytes" << ", variable layout " << variable.get_layout().to_short_string() << ")" << std::endl;_outputs[0] = variable.get_memory();@@ -837,8 +844,9 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {}// To record shape predictor- for (size_t j = 0; j < _impl_params->output_layouts.size(); ++j)+ for (size_t j = 0; j < _impl_params->output_layouts.size(); ++j) {sp.predict_preallocation_shape(id(), _impl_params->output_layouts[j], true, j);+ }GPU_DEBUG_PROFILED_STAGE_MEMALLOC_INFO("can_be_optimized");return;}@@ -849,9 +857,7 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {_max_output_layout_count[j] = 0;}} else {- GPU_DEBUG_TRACE_DETAIL- << id() << " : realloc_if_needed: can_be_optimized = false and memories are not being shared"- << std::endl;+ GPU_DEBUG_TRACE_DETAIL << id() << " : realloc_if_needed: can_be_optimized = false and memories are not being shared" << std::endl;if (!get_network().is_reuse_variable_mem()) {GPU_DEBUG_TRACE_DETAIL << "Update output mem with new variable mem" << std::endl;_outputs[0] = variable.get_memory();@@ -888,7 +894,7 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {_max_output_layout_count[0] = variable.get_actual_mem_size() / dt_sizes_in_B[0];if (auto* compressed_cache_variable = dynamic_cast<ov::intel_gpu::VariableStateIndirectKVCacheCompressed*>(&variable)) {- const size_t scale_idx = get_node().is_type<read_value>() ? 1 : 2; // kv_cache or read_value+ const size_t scale_idx = get_node().is_type<read_value>() ? 1 : 2; // kv_cache or read_value_max_output_layout_count[scale_idx] = compressed_cache_variable->get_compression_scale_state()->get_actual_mem_size() / dt_sizes_in_B[1];if (compressed_cache_variable->has_zp_state()) {_max_output_layout_count[scale_idx + 1] = compressed_cache_variable->get_compression_zp_state()->get_actual_mem_size() / dt_sizes_in_B[2];@@ -901,26 +907,26 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {// Update output layout with respect to FC's fake alignmentauto updated_layouts = actual_layouts;- std::vector<cldnn::primitive_inst *> user_insts;+ std::vector<cldnn::primitive_inst*> user_insts;{const auto& user_insts_origin = get_user_insts();for (const auto& user : user_insts_origin) {auto uid = user->id();- if (user->get_node().is_type<fully_connected>() && user->is_dynamic() && user->_deps[0].first == this- && std::find_if(user_insts_origin.begin(), user_insts_origin.end(), [&](cldnn::primitive_inst * uu){+ if (user->get_node().is_type<fully_connected>() && user->is_dynamic() && user->_deps[0].first == this &&+ std::find_if(user_insts_origin.begin(), user_insts_origin.end(), [&](cldnn::primitive_inst* uu) {for (auto dep_inst : uu->_deps) {- if (dep_inst.first->id() == uid)+ if (dep_inst.first->id() == uid) {return true;+ }}return false;}) != user_insts_origin.end()) {- user_insts.insert(user_insts.begin(), user);+ user_insts.insert(user_insts.begin(), user);} else {user_insts.push_back(user);}}- OPENVINO_ASSERT(user_insts.size() == user_insts_origin.size(), "Should have same size between ",- user_insts.size(), " and ", user_insts_origin.size());+ OPENVINO_ASSERT(user_insts.size() == user_insts_origin.size(), "Should have same size between ", user_insts.size(), " and ", user_insts_origin.size());}for (auto* user : user_insts) {auto is_fused_prim_of_user = [&](primitive_id id) -> bool {@@ -928,7 +934,7 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {if (p.has_outer_dep()) {const auto start_idx = p.outer_dep_start_idx;// exclude fused_node from total_num_deps- const auto end_idx = p.outer_dep_start_idx + p.total_num_deps -1;+ const auto end_idx = p.outer_dep_start_idx + p.total_num_deps - 1;for (size_t idx = start_idx; idx < end_idx; idx++) {if (user->get_node().get_dependency(idx).id() == id) {return true;@@ -949,7 +955,7 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {break;}}- GPU_DEBUG_TRACE_DETAIL << id() <<"'s " << dep_idx << "-th output is " << user->id() << "'s input" << std::endl;+ GPU_DEBUG_TRACE_DETAIL << id() << "'s " << dep_idx << "-th output is " << user->id() << "'s input" << std::endl;GPU_DEBUG_TRACE_DETAIL << "Check fc user " << user->id() << "'s fake alignment-ed input size" << std::endl;// Setting update_shape_done_by_other to false before running update_shape,// since update_Shape is already called in realloc_if_needed of current node's dep node@@ -958,27 +964,26 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {bool prev_shape_changed = user->get_flag(ExecutionFlags::SHAPE_CHANGED);user->update_shape();// Set again shape_change status if shape is changed in the prev udpate_shape() for this user node.- if (prev_shape_changed)+ if (prev_shape_changed) {user->set_flag(ExecutionFlags::SHAPE_CHANGED);+ }user->_update_shape_done_by_other = true;auto fc_impl_params = *user->_impl_params;auto fc_input_layout = user->get_node().type()->get_fake_aligned_params(fc_impl_params).input_layouts[0];if (fc_input_layout.bytes_count() > updated_layouts[dep_idx].bytes_count()) {- GPU_DEBUG_TRACE_DETAIL << id() << ": increase output layout allocation size from "- << actual_layouts[dep_idx].to_short_string() << " -> "- << fc_input_layout.to_short_string() << " to meet the input buffer alignment requirements for FC\n";+ GPU_DEBUG_TRACE_DETAIL << id() << ": increase output layout allocation size from " << actual_layouts[dep_idx].to_short_string() << " -> "+ << fc_input_layout.to_short_string() << " to meet the input buffer alignment requirements for FC\n";updated_layouts[dep_idx] = fc_input_layout;}// dynamic quantization is only applied to activation of FCif (get_node().is_type<dynamic_quantize>()) {const auto& desc = get_node().as<dynamic_quantize>().get_primitive();- auto dyn_quan_scale_layout =- dynamic_quantize_inst::__calc_output_layouts<ov::PartialShape>(get_node().as<dynamic_quantize>(),- updated_layouts[dep_idx],- desc->attrs);- GPU_DEBUG_TRACE_DETAIL << "update layout of dynamic quantize scale parameter layout "- << dyn_quan_scale_layout[1].to_short_string() << std::endl;+ auto dyn_quan_scale_layout = dynamic_quantize_inst::__calc_output_layouts<ov::PartialShape>(get_node().as<dynamic_quantize>(),+ updated_layouts[dep_idx],+ desc->attrs);+ GPU_DEBUG_TRACE_DETAIL << "update layout of dynamic quantize scale parameter layout " << dyn_quan_scale_layout[1].to_short_string()+ << std::endl;updated_params.output_layouts[1] = dyn_quan_scale_layout[1];}}@@ -991,9 +996,8 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {cldnn::memory::ptr target_mem_ptr) {for (const auto& user_inst : curr_inst->get_user_insts()) {auto curr_output_memory_ptr = user_inst->output_memory_ptr(0);- if (user_inst->can_be_optimized()- && (curr_output_memory_ptr- && get_network().get_engine().is_the_same_buffer(*curr_output_memory_ptr, *target_mem_ptr))) {+ if (user_inst->can_be_optimized() &&+ (curr_output_memory_ptr && get_network().get_engine().is_the_same_buffer(*curr_output_memory_ptr, *target_mem_ptr))) {user_inst->clear_output_memory();reset_user_output_memory(user_inst, target_mem_ptr);}@@ -1008,16 +1012,14 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {// Ex.// * iter0: node1(executed) -> node2(skipped) -> node3(skipped)// * iter1: node1(skipped) -> node2(skipped) -> node3(executed)- if (_outputs[0] && dep_memory_ptr(0)- && !get_network().get_engine().is_the_same_buffer(dep_memory(0), output_memory(0))) {+ if (_outputs[0] && dep_memory_ptr(0) && !get_network().get_engine().is_the_same_buffer(dep_memory(0), output_memory(0))) {reset_user_output_memory(this, dep_memory_ptr(0));}return;}if (_outputs[0] && dep_memory_ptr(0) && get_network().get_engine().is_the_same_buffer(dep_memory(0), output_memory(0))) {if (mem_allocated()) {- get_network().get_memory_pool().release_memory(_outputs[0].get(),- get_node().get_unique_id(), id(), get_network_id());+ get_network().get_memory_pool().release_memory(_outputs[0].get(), get_node().get_unique_id(), id(), get_network_id());_mem_allocated = false;}clear_output_memory();@@ -1047,8 +1049,9 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {std::vector<size_t> current_buf_shape;current_buf_shape.reserve(current_dims.size());- std::transform(current_dims.begin(), current_dims.end(),- std::back_inserter(current_buf_shape), [](const tensor::value_type& el) { return static_cast<size_t>(el); });+ std::transform(current_dims.begin(), current_dims.end(), std::back_inserter(current_buf_shape), [](const tensor::value_type& el) {+ return static_cast<size_t>(el);+ });orig_layout = layout(ov::PartialShape(current_buf_shape), orig_layout.data_type, orig_layout.format);};@@ -1072,8 +1075,7 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {const auto& desc = get_node().as<kv_cache>().get_primitive();auto prealloc_shape = updated_layouts[i].get_shape();const auto shape_rank = prealloc_shape.size();- const auto seq_axis = i == 0 ? kv_cache_inst::get_sequence_axis(desc->concat_axis, shape_rank)- : kv_cache_inst::get_scale_zp_sequence_axis();+ const auto seq_axis = i == 0 ? kv_cache_inst::get_sequence_axis(desc->concat_axis, shape_rank) : kv_cache_inst::get_scale_zp_sequence_axis();prealloc_shape[seq_axis] += tmp_prealloc_count;required_buffer_size = std::accumulate(prealloc_shape.begin(), prealloc_shape.end(), size_t(1), std::multiplies<size_t>());@@ -1085,8 +1087,8 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {}if (reclaim) {GPU_DEBUG_TRACE_DETAIL << id() << ": Updated output[" << i << "] size " << updated_layouts[i].get_linear_size()- << " is much smaller than current memory size! " << _max_output_layout_count[i]- << "Reset memory of output " << i << std::endl;+ << " is much smaller than current memory size! " << _max_output_layout_count[i] << "Reset memory of output " << i+ << std::endl;_max_output_layout_count[i] = 0;}}@@ -1103,8 +1105,8 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {if (get_node().is_type<kv_cache>() && i != 1) {const auto& desc = get_node().as<kv_cache>().get_primitive();const auto shape_rank = updated_layouts[i].get_shape().size();- const int32_t seq_axis = static_cast<int32_t>(i == 0 ? kv_cache_inst::get_sequence_axis(desc->concat_axis, shape_rank)- : kv_cache_inst::get_scale_zp_sequence_axis());+ const int32_t seq_axis =+ static_cast<int32_t>(i == 0 ? kv_cache_inst::get_sequence_axis(desc->concat_axis, shape_rank) : kv_cache_inst::get_scale_zp_sequence_axis());prealloc_info = sp.predict_preallocation_shape(id(), updated_layouts[i], false, i, tmp_prealloc_count, seq_axis);} else {@@ -1125,33 +1127,28 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {if (ext_block) {ext_block->resize(updated_params.output_layouts[i]);_outputs[i] = get_network().get_engine().reinterpret_buffer(*ext_block->memory(), actual_layouts[i]);- _max_output_layout_count[i] = ext_block->memory()->get_mem_tracker()->size()- / cldnn::data_type_traits::size_of(actual_layouts[i].data_type);- GPU_DEBUG_TRACE_DETAIL << id() << ": ext output memory block for output[" << i << "] - "- << actual_layouts[i].get_linear_size() << "/" << _max_output_layout_count[i]- << std::endl;+ _max_output_layout_count[i] = ext_block->memory()->get_mem_tracker()->size() / cldnn::data_type_traits::size_of(actual_layouts[i].data_type);+ GPU_DEBUG_TRACE_DETAIL << id() << ": ext output memory block for output[" << i << "] - " << actual_layouts[i].get_linear_size() << "/"+ << _max_output_layout_count[i] << std::endl;GPU_DEBUG_PROFILED_STAGE_MEMALLOC_INFO("ext_output_block");continue;}}if (can_reuse_buffer) {- GPU_DEBUG_TRACE_DETAIL << id() << ": reuse previously allocated output buffer[" << i << "] - "- << actual_layouts[i].get_linear_size() << "/" << _max_output_layout_count[i]- << std::endl;+ GPU_DEBUG_TRACE_DETAIL << id() << ": reuse previously allocated output buffer[" << i << "] - " << actual_layouts[i].get_linear_size() << "/"+ << _max_output_layout_count[i] << std::endl;if (get_node().is_type<kv_cache>() && i != 1) {// kv_cache has already assigned memory.// No need to reinterpret output memory but need to update paddingconst auto& desc = get_node().as<kv_cache>().get_primitive();auto& present_layout = _impl_params->output_layouts[i];const auto present_layout_rank = present_layout.get_partial_shape().size();- const auto sequence_axis = i == 0 ? kv_cache_inst::get_sequence_axis(desc->concat_axis, present_layout_rank)- : kv_cache_inst::get_scale_zp_sequence_axis();+ const auto sequence_axis =+ i == 0 ? kv_cache_inst::get_sequence_axis(desc->concat_axis, present_layout_rank) : kv_cache_inst::get_scale_zp_sequence_axis();- auto max_pad = kv_cache_inst::get_max_pad(present_layout,- _max_output_layout_count[i],- sequence_axis,- i == 0 ? "present_layout" : "present_scales_layout");+ auto max_pad =+ kv_cache_inst::get_max_pad(present_layout, _max_output_layout_count[i], sequence_axis, i == 0 ? "present_layout" : "present_scales_layout");kv_cache_inst::update_pad(present_layout, max_pad, sequence_axis);GPU_DEBUG_TRACE_DETAIL << i << ". " << _impl_params->output_layouts[i].to_string() << std::endl;set_flag(ExecutionFlags::SHAPE_CHANGED);@@ -1161,10 +1158,8 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {GPU_DEBUG_PROFILED_STAGE_MEMALLOC_INFO("reuse_buffer");} else {GPU_DEBUG_TRACE_DETAIL << id() << ": realloc output memory. " << std::endl;- GPU_DEBUG_TRACE_DETAIL << " outputs[" << i << "] " << get_node().id()- << " Current buffer_size=" << _max_output_layout_count[i]- << " Requested buffer_size=" << updated_layouts[i].get_linear_size()- << std::endl;+ GPU_DEBUG_TRACE_DETAIL << " outputs[" << i << "] " << get_node().id() << " Current buffer_size=" << _max_output_layout_count[i]+ << " Requested buffer_size=" << updated_layouts[i].get_linear_size() << std::endl;_outputs[i] = allocate_output(get_network().get_engine(),get_network().get_memory_pool(),*_node,@@ -1180,8 +1175,8 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {_max_output_layout_count[i] = updated_params.output_layouts[i].get_linear_size();set_flag(ExecutionFlags::MEMORY_CHANGED);GPU_DEBUG_CODE(std::string memalloc_info);- GPU_DEBUG_CODE(memalloc_info += (((_outputs.size() > 1) ? ("o" + to_string(i) + ":") : "") +- (_outputs[i]->from_memory_pool ? "from_pool" : "new_alloc"));)+ GPU_DEBUG_CODE(memalloc_info +=+ (((_outputs.size() > 1) ? ("o" + to_string(i) + ":") : "") + (_outputs[i]->from_memory_pool ? "from_pool" : "new_alloc"));)GPU_DEBUG_PROFILED_STAGE_MEMALLOC_INFO(memalloc_info);}}@@ -1192,10 +1187,8 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {auto& variable = get_network().get_variable(desc->variable_info.variable_id);auto present_layout = _impl_params->output_layouts[0];auto present_layout_rank = present_layout.get_partial_shape().size();- const auto sequence_axis =- kv_cache_inst::get_sequence_axis(desc->concat_axis, present_layout_rank);- GPU_DEBUG_TRACE_DETAIL << id() << " is kv_cache => set the variable with newly allocated output memory"- << std::endl;+ const auto sequence_axis = kv_cache_inst::get_sequence_axis(desc->concat_axis, present_layout_rank);+ GPU_DEBUG_TRACE_DETAIL << id() << " is kv_cache => set the variable with newly allocated output memory" << std::endl;bool axis_is_outer_most = true;for (auto dim = 0; dim < sequence_axis; ++dim) {if (present_layout.get_shape()[dim] > 1) {@@ -1205,10 +1198,7 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {}if (static_cast<int>(present_layout.data_padding._dynamic_dims_mask[sequence_axis]) == 1) {// Apply padding of variable to make it be optimized in the next iteration- auto max_pad = kv_cache_inst::get_max_pad(present_layout,- _max_output_layout_count[0],- sequence_axis,- "present_layout");+ auto max_pad = kv_cache_inst::get_max_pad(present_layout, _max_output_layout_count[0], sequence_axis, "present_layout");if (max_pad > 0) {if (auto* compressed_cache_variable = dynamic_cast<ov::intel_gpu::VariableStateIndirectKVCacheCompressed*>(&variable)) {auto present_scales_layout = _impl_params->output_layouts[2];@@ -1239,8 +1229,7 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {update_impl(use_async_compilation());}GPU_DEBUG_TRACE_DETAIL << id() << ": Update variable " << variable.get_name()- << "'s memory with allocated kv cache output: "- << present_layout.to_short_string() << " is_set = " << variable.is_set()+ << "'s memory with allocated kv cache output: " << present_layout.to_short_string() << " is_set = " << variable.is_set()<< std::endl;variable.set_memory(_outputs[0], present_layout);_impl_params->_can_be_optimized = true;@@ -1264,8 +1253,8 @@ void primitive_inst::realloc_outputs(bool prev_execution_skipped) {}} else {GPU_DEBUG_TRACE_DETAIL << id() << ": Update variable " << variable.get_name()- << "'s layout with allocated kv cache output: " << present_layout.to_short_string()- << " (is_set = " << variable.is_set() << ") " << std::endl;+ << "'s layout with allocated kv cache output: " << present_layout.to_short_string() << " (is_set = " << variable.is_set()+ << ") " << std::endl;variable.set_layout(present_layout);if (auto* compressed_cache_variable = dynamic_cast<ov::intel_gpu::VariableStateIndirectKVCacheCompressed*>(&variable)) {@@ -1299,22 +1288,21 @@ bool primitive_inst::use_async_compilation() {if (fc_node.get_primitive()->compressed_weights) {auto weights_dt = fc_node.weights().get_output_layout().data_type;auto input_shape = _impl_params->get_input_layout().get_shape();- auto batch_size = std::accumulate(input_shape.begin(),- input_shape.end() - 1,- size_t{1},- std::multiplies<size_t>());+ auto batch_size = std::accumulate(input_shape.begin(), input_shape.end() - 1, size_t{1}, std::multiplies<size_t>());// Disable async compilation for all int4 FC, except in the case of batch_size == 1- if (one_of(weights_dt, {data_types::i4, data_types::u4}) && batch_size != 1)+ if (one_of(weights_dt, {data_types::i4, data_types::u4}) && batch_size != 1) {compile_fc_impls = false;+ }} else {auto input_dt = fc_node.input().get_output_layout().data_type;auto weights_dt = fc_node.weights().get_output_layout().data_type;auto output_dt = fc_node.input().get_output_layout().data_type;// Disable async compilation for int8 quantize FC- if (one_of(weights_dt, {data_types::i8, data_types::u8})- && (one_of(input_dt, {data_types::i8, data_types::u8}) || one_of(output_dt, {data_types::i8, data_types::u8})))+ if (one_of(weights_dt, {data_types::i8, data_types::u8}) &&+ (one_of(input_dt, {data_types::i8, data_types::u8}) || one_of(output_dt, {data_types::i8, data_types::u8}))) {compile_fc_impls = false;+ }}}@@ -1322,13 +1310,16 @@ bool primitive_inst::use_async_compilation() {if (compile_gemm_impls) {// Do not async-compile if opt_gemm is chosen for iGPU// Do async-compile if it is to be executed from onednn- compile_gemm_impls = (get_node().get_selected_impl() != nullptr) && get_node().get_selected_impl()->get_kernel_name().find("gemm_ref") != std::string::npos;- compile_gemm_impls |= _impls_factory->has(impl_types::onednn) && (get_node().get_selected_impl() != nullptr) && !get_node().get_selected_impl()->is_onednn();+ compile_gemm_impls =+ (get_node().get_selected_impl() != nullptr) && get_node().get_selected_impl()->get_kernel_name().find("gemm_ref") != std::string::npos;+ compile_gemm_impls |=+ _impls_factory->has(impl_types::onednn) && (get_node().get_selected_impl() != nullptr) && !get_node().get_selected_impl()->is_onednn();}bool compile_conv_impls = get_node().is_type<convolution>();if (compile_conv_impls) {- compile_conv_impls = !_impls_factory->has(impl_types::onednn) && (get_node().get_selected_impl() != nullptr) && !get_node().get_selected_impl()->is_onednn();+ compile_conv_impls =+ !_impls_factory->has(impl_types::onednn) && (get_node().get_selected_impl() != nullptr) && !get_node().get_selected_impl()->is_onednn();}return (compile_conv_impls || compile_fc_impls || compile_gemm_impls ||@@ -1343,9 +1334,7 @@ void primitive_inst::fill_shape_info_data(const layout& runtime_layout, const la}const auto& pshape = runtime_layout.get_partial_shape();auto shape_info_fmt = format::get_default_format(layout::max_rank());- auto shape_with_max_rank = layout::transform(pshape,- format::get_default_format(pshape.size()),- shape_info_fmt).to_shape();+ auto shape_with_max_rank = layout::transform(pshape, format::get_default_format(pshape.size()), shape_info_fmt).to_shape();for (size_t j = 0; j < shape_with_max_rank.size(); ++j) {GPU_DEBUG_TRACE_DETAIL << " shape_info[" << offset << "] = " << shape_with_max_rank[j] << std::endl;shape_info_ptr[offset++] = static_cast<int32_t>(shape_with_max_rank[j]);@@ -1356,11 +1345,9 @@ void primitive_inst::fill_shape_info_data(const layout& runtime_layout, const laconst auto& upper_pads = data_padding._upper_size;for (size_t j = 0; j < shape_with_max_rank.size(); ++j) {if (static_cast<int>(dynamic_pad[j]) == 1) {- GPU_DEBUG_TRACE_DETAIL << " shape_info[" << offset << "] = " << lower_pads[j]- << "(pad_before for " << j << "-th dim)" << std::endl;+ GPU_DEBUG_TRACE_DETAIL << " shape_info[" << offset << "] = " << lower_pads[j] << "(pad_before for " << j << "-th dim)" << std::endl;shape_info_ptr[offset++] = static_cast<int32_t>(lower_pads[j]); // pad_before- GPU_DEBUG_TRACE_DETAIL << " shape_info[" << offset << "] = " << upper_pads[j]- << "(pad_after for " << j << "-th dim)" << std::endl;+ GPU_DEBUG_TRACE_DETAIL << " shape_info[" << offset << "] = " << upper_pads[j] << "(pad_after for " << j << "-th dim)" << std::endl;shape_info_ptr[offset++] = static_cast<int32_t>(upper_pads[j]); // pad_after}}@@ -1400,7 +1387,7 @@ void primitive_inst::update_shape_info_tensor(const kernel_impl_params& params)void primitive_inst::update_impl(bool use_async_compilation) {OV_ITT_SCOPED_TASK(ov::intel_gpu::itt::domains::intel_gpu_plugin, openvino::itt::handle("update_impl: " + id()));GPU_DEBUG_PROFILED_STAGE(instrumentation::pipeline_stage::update_implementation);- auto prev_impl_str = _impl != nullptr ? _impl->get_kernel_name() : "nullptr";+ auto prev_impl_str = _impl != nullptr ? _impl->get_kernel_name() : "nullptr";// no need to update impl for optimized out primitiveif (_impl != nullptr && can_be_optimized()) {@@ -1421,10 +1408,7 @@ void primitive_inst::update_impl(bool use_async_compilation) {if (_impls_factory->has(impl_types::onednn)) {auto attrs_onednn = std::make_shared<dnnl::primitive_attr>();std::vector<cldnn::fused_primitive_desc_onednn> fused_desc_onednn;- get_node().create_onednn_primitive_attributes(_impl_params->fused_desc,- attrs_onednn,- fused_desc_onednn,- _impl_params.get());+ get_node().create_onednn_primitive_attributes(_impl_params->fused_desc, attrs_onednn, fused_desc_onednn, _impl_params.get());_impl_params->attrs_onednn = attrs_onednn;{auto& fused_prims_onednn = _impl_params->fused_desc_onednn;@@ -1447,7 +1431,7 @@ void primitive_inst::update_paddings() {};if (get_node().is_type<read_value>() || get_node().is_type<kv_cache>()) {auto variable_id = get_node().is_type<read_value>() ? (get_node().as<read_value>().get_primitive()->variable_id)- : (get_node().as<kv_cache>().get_primitive()->variable_info.variable_id);+ : (get_node().as<kv_cache>().get_primitive()->variable_info.variable_id);auto& variable = get_network().get_variable(variable_id);// Reset paddings for read_value and users with dynamic pad when variable is reset// to avoid wrong pad used for some nodes due to pad propagation logic (which uses previous iter pad values)@@ -1476,10 +1460,11 @@ void primitive_inst::update_paddings() {}if (get_node().is_type<gather>() && _impl_params->output_layouts[0].data_padding.is_dynamic()) {- if (can_be_optimized())+ if (can_be_optimized()) {_impl_params->output_layouts[0] = _impl_params->input_layouts[0];- else+ } else {reset_pad(*_impl_params, _node);+ }return;}// Reset paddings used in the previous iteration for crop before executing do_runtime_in_place_crop@@ -1497,11 +1482,13 @@ void primitive_inst::do_runtime_skip_reorder() {GPU_DEBUG_IF(get_config().get_disable_runtime_skip_reorder()) {return;}- if (can_be_optimized())+ if (can_be_optimized()) {return;+ }- if (!_impl_params->fused_desc.empty())+ if (!_impl_params->fused_desc.empty()) {return;+ }// set successive reorder can_be_optimized if layouts are samefor (auto* u : get_user_insts()) {@@ -1515,8 +1502,8 @@ void primitive_inst::do_runtime_skip_reorder() {}if (alloc_type == allocation_type::usm_device && u->is_output()) {u->set_can_be_optimized(false);- GPU_DEBUG_TRACE_DETAIL << "[do runtime skip reorder] user " << u->id()- << " cannot be optimized for that " << u->id() << " is reorder and output node" << std::endl;+ GPU_DEBUG_TRACE_DETAIL << "[do runtime skip reorder] user " << u->id() << " cannot be optimized for that " << u->id()+ << " is reorder and output node" << std::endl;continue;}GPU_DEBUG_TRACE_DETAIL << "[do runtime skip reorder] update shape for user " << u->id() << std::endl;@@ -1529,8 +1516,9 @@ void primitive_inst::do_runtime_skip_reorder() {for (auto& user : users) {GPU_DEBUG_TRACE_DETAIL << "[do runtime skip reorder] add " << id() << " to restriction list of " << user->id() << std::endl;user->_runtime_memory_dependencies.insert(static_cast<uint32_t>(get_node().get_unique_id()));- if (user->can_be_optimized())+ if (user->can_be_optimized()) {update_memory_dependencies(user->get_user_insts());+ }}};@@ -1540,11 +1528,11 @@ void primitive_inst::do_runtime_skip_reorder() {} else {u->set_can_be_optimized(false);GPU_DEBUG_TRACE_DETAIL << "[do runtime skip reorder] user " << u->id()- << " cannot be optimized for the mismatch between input layout and output layout" << std::endl;- GPU_DEBUG_TRACE_DETAIL << "[do runtime skip reorder] * input_layout : "- << u->_impl_params->get_input_layout().to_short_string() << std::endl;- GPU_DEBUG_TRACE_DETAIL << "[do runtime skip reorder] * output_layout : "- << u->_impl_params->get_output_layout().to_short_string() << std::endl;+ << " cannot be optimized for the mismatch between input layout and output layout" << std::endl;+ GPU_DEBUG_TRACE_DETAIL << "[do runtime skip reorder] * input_layout : " << u->_impl_params->get_input_layout().to_short_string()+ << std::endl;+ GPU_DEBUG_TRACE_DETAIL << "[do runtime skip reorder] * output_layout : " << u->_impl_params->get_output_layout().to_short_string()+ << std::endl;}}}@@ -1553,8 +1541,9 @@ void primitive_inst::do_runtime_skip_reorder() {void primitive_inst::do_runtime_in_place_kv_cache() {OV_ITT_SCOPED_TASK(ov::intel_gpu::itt::domains::intel_gpu_plugin, openvino::itt::handle("do_runtime_in_place_kv_cache: " + id()));- if (!get_node().is_type<kv_cache>())+ if (!get_node().is_type<kv_cache>()) {return;+ }auto& kv_inst = downcast<kv_cache_inst>(*this);_impl_params->_can_be_optimized = false;@@ -1576,8 +1565,9 @@ void primitive_inst::do_runtime_in_place_kv_cache() {}auto sequence_axis = kv_cache_inst::get_sequence_axis(desc->concat_axis, past_layout.get_partial_shape().size());- if (static_cast<int>(present_layout.data_padding._dynamic_dims_mask[sequence_axis]) != 1)+ if (static_cast<int>(present_layout.data_padding._dynamic_dims_mask[sequence_axis]) != 1) {return;+ }GPU_DEBUG_TRACE_DETAIL << "[do runtime kv_cache opt] " << id() << " initial present_layout : " << present_layout.to_string() << std::endl;GPU_DEBUG_TRACE_DETAIL << "[do runtime kv_cache opt] " << id() << " initial past_layout : " << past_layout.to_string() << std::endl;@@ -1604,8 +1594,8 @@ void primitive_inst::do_runtime_in_place_kv_cache() {auto& present_scales_layout = _impl_params->output_layouts[2];const auto sequence_axis = kv_cache_inst::get_scale_zp_sequence_axis();kv_cache_inst::update_pad(present_scales_layout, max_pad - new_seq_len, sequence_axis);- GPU_DEBUG_TRACE_DETAIL << "[do runtime_in_place_kv_cache] " << id()- << " Updated present_scale_layout's pad : " << present_scales_layout.to_string() << std::endl;+ GPU_DEBUG_TRACE_DETAIL << "[do runtime_in_place_kv_cache] " << id() << " Updated present_scale_layout's pad : " << present_scales_layout.to_string()+ << std::endl;compressed_cache_variable->get_compression_scale_state()->set_layout(present_scales_layout);if (desc->get_compression_zp_inputs_num() > 0) {@@ -1618,8 +1608,8 @@ void primitive_inst::do_runtime_in_place_kv_cache() {}}- GPU_DEBUG_TRACE_DETAIL << "[do_runtime_in_place_kv_cache] " << id() << "Updated variable with present_layout"- << variable.get_layout().to_string() << " is_set = " << variable.is_set() << std::endl;+ GPU_DEBUG_TRACE_DETAIL << "[do_runtime_in_place_kv_cache] " << id() << "Updated variable with present_layout" << variable.get_layout().to_string()+ << " is_set = " << variable.is_set() << std::endl;if (past_layout.data_padding._upper_size[sequence_axis] > 0 && variable.is_set()) {kv_cache_inst::update_pad(past_layout, max_pad, sequence_axis);_impl_params->_can_be_optimized = true;@@ -1642,12 +1632,11 @@ void primitive_inst::do_runtime_in_place_kv_cache() {void primitive_inst::do_runtime_skip_gather() {// Check pattern- if (!get_node().is_type<gather>()- || !get_node().is_runtime_skippable()- || _impl_params->has_fused_primitives()- || _impl_params->get_input_layout(0).data_type != _impl_params->get_output_layout().data_type- || get_node().get_dependency(1).is_constant() || get_node().get_dependency(1).is_type<data>())+ if (!get_node().is_type<gather>() || !get_node().is_runtime_skippable() || _impl_params->has_fused_primitives() ||+ _impl_params->get_input_layout(0).data_type != _impl_params->get_output_layout().data_type || get_node().get_dependency(1).is_constant() ||+ get_node().get_dependency(1).is_type<data>()) {return;+ }GPU_DEBUG_TRACE_DETAIL << "[do_runtime_skip_gather] " << id() << " : check optimizability" << std::endl;@@ -1677,7 +1666,7 @@ void primitive_inst::do_runtime_skip_gather() {}// If the overhead for checking the index is bigger than doing gather itself, it does not make sense for skipping- const int MAX_INDICES_SIZE = 10*1024;+ const int MAX_INDICES_SIZE = 10 * 1024;if (input_shape[axis] > MAX_INDICES_SIZE) {GPU_DEBUG_TRACE_DETAIL << "--- Cannot optimize because data length along with the axis is too big" << input_shape[axis] << std::endl;set_can_be_optimized(false);@@ -1685,16 +1674,18 @@ void primitive_inst::do_runtime_skip_gather() {}if (input_shape[axis] != 1) {auto queue_type = get_network().get_stream().get_queue_type();- if (queue_type == QueueTypes::out_of_order)+ if (queue_type == QueueTypes::out_of_order) {get_network().get_stream().wait_for_events({_deps[1].first->get_impl_params()->out_event});- else+ } else {get_network().get_stream().finish();+ }mem_lock<int32_t, mem_lock_type::read> idx_data(dep_memory_ptr(1), get_network().get_stream());for (int64_t i = 0; i < static_cast<int32_t>(idx_shape[0]); ++i) {if (idx_data[i] != i) {GPU_DEBUG_TRACE_DETAIL << "--- Cannot optimize because idx_data [" << i << "] (" << idx_data[i] << ") != " << i << std::endl;- if (_impl_params->output_layouts[0].data_padding.is_dynamic())+ if (_impl_params->output_layouts[0].data_padding.is_dynamic()) {_impl_params->output_layouts[0].data_padding = padding();+ }// for runtime skippable nodes, if previous iter is skipped while this iter not, its output memory needs to be revalidate// as memory opt/release may be applied for these nodes to reduce memory footprint in previous itersif (can_be_optimized()) {@@ -1718,12 +1709,10 @@ void primitive_inst::do_runtime_skip_gather() {void primitive_inst::do_runtime_skip_permute() {OV_ITT_SCOPED_TASK(ov::intel_gpu::itt::domains::intel_gpu_plugin, openvino::itt::handle("do_runtime_skip_permute: " + id()));// Check pattern- if (!get_node().is_type<permute>()- || is_output()- || !get_node().is_runtime_skippable()- || _impl_params->has_fused_primitives()- || _impl_params->get_input_layout(0).data_type != _impl_params->get_output_layout().data_type)+ if (!get_node().is_type<permute>() || is_output() || !get_node().is_runtime_skippable() || _impl_params->has_fused_primitives() ||+ _impl_params->get_input_layout(0).data_type != _impl_params->get_output_layout().data_type) {return;+ }GPU_DEBUG_TRACE_DETAIL << "[do_runtime_skip_permute] " << id() << " : check optimizability" << std::endl;auto desc = get_node().as<permute>().get_primitive();@@ -1759,8 +1748,9 @@ void primitive_inst::do_runtime_skip_permute() {void primitive_inst::do_runtime_skip_strided_slice() {OV_ITT_SCOPED_TASK(ov::intel_gpu::itt::domains::intel_gpu_plugin, openvino::itt::handle("do_runtime_skip_strided_slice: " + id()));// Check pattern- if (!get_node().is_type<strided_slice>() || !get_node().is_runtime_skippable())+ if (!get_node().is_type<strided_slice>() || !get_node().is_runtime_skippable()) {return;+ }GPU_DEBUG_TRACE_DETAIL << "[do_runtime_skip_strided_slice] " << id() << " : check optimizability" << std::endl;auto input_layout = _impl_params->get_input_layout(0);@@ -1769,8 +1759,8 @@ void primitive_inst::do_runtime_skip_strided_slice() {// Check runtime shape (need to reset can_be_optimized)if (input_layout != output_layout) {set_can_be_optimized(false);- GPU_DEBUG_TRACE_DETAIL << "--- Cannot optimize because input layout(" << input_layout.to_short_string()- << ") != output layout(" << output_layout.to_short_string() << ")" << std::endl;+ GPU_DEBUG_TRACE_DETAIL << "--- Cannot optimize because input layout(" << input_layout.to_short_string() << ") != output layout("+ << output_layout.to_short_string() << ")" << std::endl;return;}@@ -1783,8 +1773,9 @@ void primitive_inst::do_runtime_skip_strided_slice() {void primitive_inst::do_runtime_skip_broadcast() {OV_ITT_SCOPED_TASK(ov::intel_gpu::itt::domains::intel_gpu_plugin, openvino::itt::handle("do_runtime_skip_broadcast: " + id()));// Check pattern- if (!get_node().is_type<broadcast>() || !get_node().is_runtime_skippable())+ if (!get_node().is_type<broadcast>() || !get_node().is_runtime_skippable()) {return;+ }GPU_DEBUG_TRACE_DETAIL << "[do_runtime_skip_broadcast] " << id() << " : check optimizability" << std::endl;auto input_layout = _impl_params->get_input_layout(0);@@ -1793,8 +1784,8 @@ void primitive_inst::do_runtime_skip_broadcast() {// Check runtime shape (need to reset can_be_optimized)if (input_layout != output_layout) {set_can_be_optimized(false);- GPU_DEBUG_TRACE_DETAIL << "--- Cannot optimize because input layout(" << input_layout.to_short_string()- << ") != output layout(" << output_layout.to_short_string() << ")" << std::endl;+ GPU_DEBUG_TRACE_DETAIL << "--- Cannot optimize because input layout(" << input_layout.to_short_string() << ") != output layout("+ << output_layout.to_short_string() << ")" << std::endl;return;}@@ -1805,7 +1796,7 @@ void primitive_inst::do_runtime_skip_broadcast() {}void primitive_inst::do_runtime_in_place_concat() {- auto has_subgraph_dependency = [](std::vector<std::pair<const cldnn::primitive_inst*, int>> dependencies) {+ auto has_subgraph_dependency = [](std::vector<std::pair<const cldnn::primitive_inst*, int>> dependencies) {for (auto dependency : dependencies) {if (dependency.first && dependency.first->get_node().is_in_shape_of_subgraph()) {return true;@@ -1820,12 +1811,14 @@ void primitive_inst::do_runtime_in_place_concat() {if (_update_shape_done_by_other) {return;}- if (get_users().size() != 1) return;+ if (get_users().size() != 1)+ return;auto* concat_inst = get_user_insts().front();- if (!concat_inst->get_node().is_type<concatenation>() || !concat_inst->get_node().can_be_optimized() || !concat_inst->get_node().is_runtime_skippable())+ if (!concat_inst->get_node().is_type<concatenation>() || !concat_inst->get_node().can_be_optimized() || !concat_inst->get_node().is_runtime_skippable()) {return;+ }if (has_subgraph_dependency(concat_inst->dependencies())) {concat_inst->set_can_be_optimized(false);@@ -1858,8 +1851,9 @@ void primitive_inst::do_runtime_in_place_concat() {preds_layouts.push_back(pred.first->_impl_params->get_output_layout());}- if (!concat_inst->get_flag(ExecutionFlags::SHAPE_CHANGED))+ if (!concat_inst->get_flag(ExecutionFlags::SHAPE_CHANGED)) {return;+ }// Reset the allocation flag when the output shape has changed, to allow buffer reallocation// by predecessors or by the concat primitive itself if in-place optimization is not possible@@ -1892,8 +1886,9 @@ void primitive_inst::do_runtime_in_place_concat() {}++dep_idx;}- if (padding_reverted)+ if (padding_reverted) {concat_inst->set_flag(ExecutionFlags::SHAPE_CHANGED);+ }return;}@@ -1905,18 +1900,18 @@ void primitive_inst::do_runtime_in_place_concat() {if (dep.first->_impl_params->output_layouts[0] != preds_layouts[i]) {dep.first->set_flag(ExecutionFlags::SHAPE_CHANGED);dep.first->_impl_params->output_layouts[0] = preds_layouts[i];- GPU_DEBUG_TRACE_DETAIL << "[In place concat] Update padding of pred " << i << " : "- << dep.first->_impl_params->output_layouts[0].to_string() << std::endl;+ GPU_DEBUG_TRACE_DETAIL << "[In place concat] Update padding of pred " << i << " : " << dep.first->_impl_params->output_layouts[0].to_string()+ << std::endl;}- if (i < concat_inst->_impl_params->input_layouts.size() &&- concat_inst->_impl_params->input_layouts[i].data_padding != preds_layouts[i].data_padding) {+ if (i < concat_inst->_impl_params->input_layouts.size() && concat_inst->_impl_params->input_layouts[i].data_padding != preds_layouts[i].data_padding) {concat_inst->_impl_params->input_layouts[i].data_padding = preds_layouts[i].data_padding;- GPU_DEBUG_TRACE_DETAIL << "[In place concat] Update padding of input " << i << " : "- << concat_inst->_impl_params->input_layouts[i].to_string() << std::endl;+ GPU_DEBUG_TRACE_DETAIL << "[In place concat] Update padding of input " << i << " : " << concat_inst->_impl_params->input_layouts[i].to_string()+ << std::endl;}++i;}- concat_inst->_impl_params->output_layouts[0] = concat_layout; // TODO : Once this primitive_inst::can_be_optimized, consolidate it to impl_params->optimized+ concat_inst->_impl_params->output_layouts[0] =+ concat_layout; // TODO : Once this primitive_inst::can_be_optimized, consolidate it to impl_params->optimizedconcat_inst->set_can_be_optimized(true);GPU_DEBUG_TRACE_DETAIL << "[In place concat] " << concat_inst->id() << ": can_be_optimized " << std::endl;@@ -1925,11 +1920,10 @@ void primitive_inst::do_runtime_in_place_concat() {void primitive_inst::do_runtime_skip_scatter_update() {OV_ITT_SCOPED_TASK(ov::intel_gpu::itt::domains::intel_gpu_plugin, openvino::itt::handle("do_runtime_skip_scatter_update: " + id()));// Check pattern- if ((!get_node().is_type<scatter_update>()- && !get_node().is_type<scatter_elements_update>()- && !get_node().is_type<scatter_nd_update>())- || !get_node().is_runtime_skippable())+ if ((!get_node().is_type<scatter_update>() && !get_node().is_type<scatter_elements_update>() && !get_node().is_type<scatter_nd_update>()) ||+ !get_node().is_runtime_skippable()) {return;+ }GPU_DEBUG_TRACE_DETAIL << "[do_runtime_skip_scatter_update] " << id() << " : check optimizability" << std::endl;const auto& input_layout = _impl_params->get_input_layout(0);@@ -1943,9 +1937,11 @@ void primitive_inst::do_runtime_skip_scatter_update() {set_flag(ExecutionFlags::SHAPE_CHANGED);}set_can_be_optimized(false);- GPU_DEBUG_TRACE_DETAIL << "--- Cannot optimize because idx_layout (" << idx_layout.to_short_string()- << ") and update_layout(" << update_layout.to_short_string() << ") are not zero"- "or input layout is different than output layout" << std::endl;+ GPU_DEBUG_TRACE_DETAIL << "--- Cannot optimize because idx_layout (" << idx_layout.to_short_string() << ") and update_layout("+ << update_layout.to_short_string()+ << ") are not zero"+ "or input layout is different than output layout"+ << std::endl;return;}@@ -2028,11 +2024,15 @@ void primitive_inst::do_runtime_in_place_crop() {continue;}}- if (!crop_in_place_optimization::update_in_place_crop_padding_along_feature(- u->get_node(), crop_layout, pred_layout, user_info, offsets, crop_axis, true)) {+ if (!crop_in_place_optimization::update_in_place_crop_padding_along_feature(u->get_node(),+ crop_layout,+ pred_layout,+ user_info,+ offsets,+ crop_axis,+ true)) {u->set_can_be_optimized(false);- GPU_DEBUG_TRACE_DETAIL << "[In place crop] " << u->id()- << " cannot be optimized due to padding indivisibility" << std::endl;+ GPU_DEBUG_TRACE_DETAIL << "[In place crop] " << u->id() << " cannot be optimized due to padding indivisibility" << std::endl;continue;}// Install the padded crop layout and propagate the reshape@@ -2048,9 +2048,15 @@ void primitive_inst::do_runtime_in_place_crop() {reshape_inst->_impl_params->output_layouts[0] = user_info.second;reshape_inst->set_flag(ExecutionFlags::SHAPE_CHANGED);}- GPU_DEBUG_TRACE_DETAIL << "[In place crop] " << u->id() << " update_in_place_crop_padding_along_feature " << offsets << ", " << crop_axis << std::endl;+ GPU_DEBUG_TRACE_DETAIL << "[In place crop] " << u->id() << " update_in_place_crop_padding_along_feature " << offsets << ", " << crop_axis+ << std::endl;} else if (crop_in_place_optimization::can_crop_be_optimized_simple_data_format(crop_layout, pred_layout)) {- if (!crop_in_place_optimization::update_in_place_crop_padding_simple_data_format(crop_layout, pred_layout, user_info, offsets, crop_axis, true)) {+ if (!crop_in_place_optimization::update_in_place_crop_padding_simple_data_format(crop_layout,+ pred_layout,+ user_info,+ offsets,+ crop_axis,+ true)) {u->set_can_be_optimized(false);GPU_DEBUG_TRACE_DETAIL << "[In place crop] " << u->id() << " cannot be optimized due to padding indivisibility" << std::endl;continue;@@ -2060,7 +2066,8 @@ void primitive_inst::do_runtime_in_place_crop() {reshape_inst->_impl_params->output_layouts[0] = user_info.second;reshape_inst->set_flag(ExecutionFlags::SHAPE_CHANGED);}- GPU_DEBUG_TRACE_DETAIL << "[In place crop] " << u->id() << " update_in_place_crop_padding_simple_data_format " << offsets << ", " << crop_axis << std::endl;+ GPU_DEBUG_TRACE_DETAIL << "[In place crop] " << u->id() << " update_in_place_crop_padding_simple_data_format " << offsets << ", "+ << crop_axis << std::endl;} else {u->set_can_be_optimized(false);GPU_DEBUG_TRACE_DETAIL << "[In place crop] " << u->id() << " cannot be optimized " << std::endl;@@ -2076,8 +2083,9 @@ void primitive_inst::do_runtime_in_place_crop() {void primitive_inst::do_runtime_skip_lora() {OV_ITT_SCOPED_TASK(ov::intel_gpu::itt::domains::intel_gpu_plugin, openvino::itt::handle("do_runtime_skip_lora: " + id()));- if (!get_node().is_type<lora>() || !get_node().is_runtime_skippable())+ if (!get_node().is_type<lora>() || !get_node().is_runtime_skippable()) {return;+ }bool is_empty_lora = true;for (size_t i = 2; i < _impl_params->input_layouts.size(); ++i) {@@ -2095,8 +2103,9 @@ void primitive_inst::do_runtime_skip_lora() {void primitive_inst::do_runtime_skip_resample() {OV_ITT_SCOPED_TASK(ov::intel_gpu::itt::domains::intel_gpu_plugin, openvino::itt::handle("do_runtime_skip_resample: " + id()));- if (!get_node().is_type<resample>() || !get_node().is_runtime_skippable())+ if (!get_node().is_type<resample>() || !get_node().is_runtime_skippable()) {return;+ }const auto& input_layout = _impl_params->get_input_layout(0);const auto& output_layout = _impl_params->get_output_layout();@@ -2116,13 +2125,15 @@ bool primitive_inst::has_inner_networks() const {}void primitive_inst::add_dep_events(const std::vector<event::ptr>& events) {- for (auto ev : events)+ for (auto ev : events) {add_dep_event(std::move(ev));+ }}void primitive_inst::add_dep_event(event::ptr ev) {- if (ev)+ if (ev) {_impl_params->dep_events.push_back(ev);+ }}void primitive_inst::set_out_event(event::ptr&& ev) {@@ -2160,14 +2171,13 @@ void primitive_inst::prepare_primitive() {GPU_DEBUG_TRACE_DETAIL << "-----------------------------------------------------------------" << std::endl;GPU_DEBUG_TRACE_DETAIL << "Execute " << id() << " (type: " << _impl_params->desc->type_string() << ") " << std::endl;for (size_t i = 0; i < _deps.size(); ++i) {- GPU_DEBUG_TRACE_DETAIL << "- inputs[" << i << "] : " << _deps[i].first->id() << std::endl;+ GPU_DEBUG_TRACE_DETAIL << "- inputs[" << i << "] : " << _deps[i].first->id() << std::endl;}GPU_DEBUG_TRACE_DETAIL << "-----------------------------------------------------------------" << std::endl;// If it is optimized out or skipped for zero dimension at the previous iteration,// Set this flag true to reset output memory in realloc_if_needed.- const bool prev_execution_skipped = can_be_optimized()- || (_impl_params->output_layouts[0].is_static() && _impl_params->output_layouts[0].count() == 0);+ const bool prev_execution_skipped = can_be_optimized() || (_impl_params->output_layouts[0].is_static() && _impl_params->output_layouts[0].count() == 0);const auto orig_outputs = _outputs;if ((is_dynamic() || get_node().is_in_shape_of_subgraph()) && !has_inner_networks()) {do_runtime_in_place_concat();@@ -2195,7 +2205,7 @@ void primitive_inst::prepare_primitive() {}if (get_flag(ExecutionFlags::SKIP)) {- _update_shape_done_by_other = false; // reset+ _update_shape_done_by_other = false; // resetreturn;}@@ -2251,10 +2261,12 @@ void primitive_inst::prepare_primitive() {}OPENVINO_ASSERT(_impl_params->get_output_layout().is_static(),- "[GPU] Can't execute ", primitive_id, " primitive as output layout is dynamic in runtime");+ "[GPU] Can't execute ",+ primitive_id,+ " primitive as output layout is dynamic in runtime");}- _update_shape_done_by_other = false; // reset- OPENVINO_ASSERT(_impl != nullptr, "[GPU] Implementation is nullptr for ", primitive_id, " primitive");+ _update_shape_done_by_other = false; // reset+ OPENVINO_ASSERT(_impl != nullptr, "[GPU] Implementation is nullptr for ", primitive_id, " primitive");// Re-acquire output memory when _outputs[0] was cleared by// invalidate_ext_block_compute_nodes (double-buffer flip).@@ -2291,8 +2303,9 @@ void primitive_inst::prepare_primitive() {if (!get_node().is_type<condition>() && !get_node().is_type<loop>()) {for (size_t i = 0; i < _outputs.size(); ++i) {- if (!orig_outputs[i] && !_outputs[i])+ if (!orig_outputs[i] && !_outputs[i]) {continue;+ }if ((!orig_outputs[i] && _outputs[i]) || (orig_outputs[i] && !_outputs[i])) {set_flag(ExecutionFlags::MEMORY_CHANGED);@@ -2304,8 +2317,7 @@ void primitive_inst::prepare_primitive() {}}}- GPU_DEBUG_TRACE << id() << ": execute " << _impl->get_kernel_name() << " (is_dynamic=" << _impl->is_dynamic()- << ", "+ GPU_DEBUG_TRACE << id() << ": execute " << _impl->get_kernel_name() << " (is_dynamic=" << _impl->is_dynamic() << ", "<< "can_be_optimized=" << can_be_optimized() << ")" << std::endl;const bool out_of_order_queue = get_network().get_stream().get_queue_type() == QueueTypes::out_of_order;@@ -2372,8 +2384,9 @@ void primitive_inst::execute() {}auto port_id = tag_port_number(d.first->id(), d.second);GPU_DEBUG_TRACE_DETAIL << "set_input_data " << port_id << " " << actual_mem << std::endl;- if (actual_mem)+ if (actual_mem) {_unfused_subgraph->set_input_data(port_id, std::move(actual_mem));+ }}}GPU_DEBUG_TRACE_DETAIL << "[Start] Executing unfused subgraph of " << id() << std::endl;@@ -2394,14 +2407,13 @@ void primitive_inst::execute() {set_out_event(_impl->execute(_impl_params->dep_events, *this));- GPU_DEBUG_IF(!get_config().get_dump_profiling_data_path().empty() ||- !get_config().get_average_counters().empty()) {+ GPU_DEBUG_IF(!get_config().get_dump_profiling_data_path().empty() || !get_config().get_average_counters().empty()) {auto ev = _impl_params->out_event;get_network().get_stream().wait_for_events({ev});if (ev != nullptr) {auto profiling_info = ev->get_profiling_info();- for (const auto &interval : profiling_info) {+ for (const auto& interval : profiling_info) {if (interval.stage == cldnn::instrumentation::profiling_stage::executing) {GPU_DEBUG_CODE(stage_prof.set_custom_stage_duration(interval.value->value()));}@@ -2433,39 +2445,39 @@ void primitive_inst::configure_shape_of_dependencies() {}primitive_inst::primitive_inst(network& network)- : _network(network)- , _node(nullptr)- , _impl_params(std::make_unique<kernel_impl_params>())- , _impl(nullptr)- , _outputs({})- , _reordered_weights_cache(network.get_weights_cache_capacity())- , _mem_allocated(false)- , _type(nullptr) {}--primitive_inst::primitive_inst(network & network, program_node const& node, bool allocate_memory)- : _network(network)- , _node(&node)- , _node_output_layout(node.get_output_layout())- , _use_shared_kernels(node.get_program().get_config().get_enable_kernels_reuse())- , _impl_params(node.get_kernel_impl_params())- , _impl(node.get_selected_impl() ? node.get_selected_impl()->clone() : nullptr)- , _runtime_memory_dependencies(&node.get_memory_dependencies())- , _outputs({})- , _reordered_weights_cache(network.get_weights_cache_capacity())- , _is_dynamic(node.is_dynamic())- , _type(node.type())- , _id(node.id())- , _org_id(node.get_org_primitive_id())- , _is_input(node.is_input())- , _is_output(node.is_output())- , _inputs_memory_count(node.get_inputs_count())- , _outputs_memory_count(node.get_outputs_count())- , _fused_mem_count(node.get_fused_inputs_count())- , _fused_mem_offset((_fused_mem_count > 0 && node.get_first_fused_dep_idx() > 0) ? static_cast<uint64_t>(node.get_first_fused_dep_idx()) : 0)- , _can_be_optimized(node.can_be_optimized())- , _can_share_buffer(node.can_share_buffer())- , _is_constant(node.is_constant())- , _needs_completion_event(is_any_user_cpu(node.get_users()) || node.is_output()) {+ : _network(network),+ _node(nullptr),+ _impl_params(std::make_unique<kernel_impl_params>()),+ _impl(nullptr),+ _outputs({}),+ _reordered_weights_cache(network.get_weights_cache_capacity()),+ _mem_allocated(false),+ _type(nullptr) {}++primitive_inst::primitive_inst(network& network, const program_node& node, bool allocate_memory)+ : _network(network),+ _node(&node),+ _node_output_layout(node.get_output_layout()),+ _use_shared_kernels(node.get_program().get_config().get_enable_kernels_reuse()),+ _impl_params(node.get_kernel_impl_params()),+ _impl(node.get_selected_impl() ? node.get_selected_impl()->clone() : nullptr),+ _runtime_memory_dependencies(&node.get_memory_dependencies()),+ _outputs({}),+ _reordered_weights_cache(network.get_weights_cache_capacity()),+ _is_dynamic(node.is_dynamic()),+ _type(node.type()),+ _id(node.id()),+ _org_id(node.get_org_primitive_id()),+ _is_input(node.is_input()),+ _is_output(node.is_output()),+ _inputs_memory_count(node.get_inputs_count()),+ _outputs_memory_count(node.get_outputs_count()),+ _fused_mem_count(node.get_fused_inputs_count()),+ _fused_mem_offset((_fused_mem_count > 0 && node.get_first_fused_dep_idx() > 0) ? static_cast<uint64_t>(node.get_first_fused_dep_idx()) : 0),+ _can_be_optimized(node.can_be_optimized()),+ _can_share_buffer(node.can_share_buffer()),+ _is_constant(node.is_constant()),+ _needs_completion_event(is_any_user_cpu(node.get_users()) || node.is_output()) {// When dynamic shape node has huge upper boundary which causes bigger mem size than system max allocable mem size, do not allocate in build time.auto output_layout = node.get_output_layout();auto& engine = network.get_engine();@@ -2476,8 +2488,9 @@ primitive_inst::primitive_inst(network & network, program_node const& node, boolif (!_mem_allocated && (node.is_dynamic() && _outputs_memory_count > 1)) {auto available_allocate_memory = [&](std::vector<cldnn::layout>& layouts) -> bool {for (auto& l : layouts) {- if (l.is_static())+ if (l.is_static()) {return true;+ }}return false;};@@ -2502,10 +2515,10 @@ primitive_inst::primitive_inst(network & network, program_node const& node, boolauto& eltw_node = node.get_dependency(reused_eltwmem_idx);const auto& eltw_inst = _network.get_primitive(eltw_node.id());if (eltw_node.is_type<input_layout>() && !eltw_inst->outputs_allocated()) {- auto eltw_mem = _network.get_engine().allocate_memory(eltw_node.get_output_layout(),- _network.get_engine().get_preferred_memory_allocation_type(),- /*reset*/false);- eltw_inst->set_output_memory(eltw_mem, /*check*/false);+ auto eltw_mem = _network.get_engine().allocate_memory(eltw_node.get_output_layout(),+ _network.get_engine().get_preferred_memory_allocation_type(),+ /*reset*/ false);+ eltw_inst->set_output_memory(eltw_mem, /*check*/ false);}auto& eltw_mem = eltw_inst->output_memory();auto new_mem = eltw_mem.get_engine()->reinterpret_buffer(eltw_mem, node.get_output_layout());@@ -2514,11 +2527,12 @@ primitive_inst::primitive_inst(network & network, program_node const& node, bool// TODO: Remove WA for arg_max_min node.// For now it's required to handle the case when only second output of TopK primitive is used in plugin,// but kernels always write both outputs to the same memory object which leads to wrong result.- if (user_count == 1 && mutable_data_count == 1 && !node.is_type<arg_max_min>() &&- !node.is_type<experimental_detectron_roi_feature_extractor>()) {- for (const auto& user : node.get_users())- if (user->is_type<mutable_data>())+ if (user_count == 1 && mutable_data_count == 1 && !node.is_type<arg_max_min>() && !node.is_type<experimental_detectron_roi_feature_extractor>()) {+ for (const auto& user : node.get_users()) {+ if (user->is_type<mutable_data>()) {_outputs[0] = user->as<mutable_data>().get_attached_memory_ptr();+ }+ }} else {_outputs = allocate_outputs();}@@ -2542,16 +2556,19 @@ primitive_inst::primitive_inst(network & network, program_node const& node, bool}memory::ptr primitive_inst::allocate_internal_buffer(const layout& layout, size_t idx, bool reset, bool lockable, bool shareable) {- if (_impl == nullptr || _outputs.empty() || _outputs[0] == nullptr)+ if (_impl == nullptr || _outputs.empty() || _outputs[0] == nullptr) {return nullptr;+ }auto device_mem_acc = [&](size_t a, std::pair<primitive_inst*, int32_t> b) {- if (!b.first->mem_allocated()) return a;+ if (!b.first->mem_allocated())+ return a;auto res = a;for (size_t i = 0; i < b.first->outputs_memory_count(); ++i) {if (b.first->output_memory(i).get_allocation_type() == allocation_type::usm_device ||- b.first->output_memory(i).get_allocation_type() == allocation_type::cl_mem)+ b.first->output_memory(i).get_allocation_type() == allocation_type::cl_mem) {return a + b.first->output_memory().size();+ }}return res;};@@ -2565,8 +2582,9 @@ memory::ptr primitive_inst::allocate_internal_buffer(const layout& layout, size_auto total_device_mem_size = std::accumulate(inst_deps.begin(), inst_deps.end(), size_t(0), device_mem_acc);for (const auto& output : _outputs) {- if (output->get_allocation_type() == allocation_type::usm_device)+ if (output->get_allocation_type() == allocation_type::usm_device) {total_device_mem_size += output->size();+ }}int64_t available_device_mem_size = engine.get_device_info().max_global_mem_size - total_device_mem_size;@@ -2574,8 +2592,7 @@ memory::ptr primitive_inst::allocate_internal_buffer(const layout& layout, size_// check if there is any device mem inputif (engine.supports_allocation(allocation_type::usm_device)) {for (const auto& dep : inst_deps) {- if (dep.first->output_memory_ptr() &&- dep.first->output_memory_ptr()->get_allocation_type() == allocation_type::usm_device) {+ if (dep.first->output_memory_ptr() && dep.first->output_memory_ptr()->get_allocation_type() == allocation_type::usm_device) {input_device_mem = true;break;}@@ -2583,49 +2600,50 @@ memory::ptr primitive_inst::allocate_internal_buffer(const layout& layout, size_}// allocate intermediate memory for the updated layout of bufferauto alloc_type = allocation_type::unknown;- GPU_DEBUG_LOG << "[" << get_node().id() << ": internal buf " << idx << "] "- << layout.to_short_string() << " lockable=" << lockable << std::endl;+ GPU_DEBUG_LOG << "[" << get_node().id() << ": internal buf " << idx << "] " << layout.to_short_string() << " lockable=" << lockable << std::endl;if ((int64_t)available_device_mem_size - (int64_t)layout.bytes_count() >= 0 &&(input_device_mem || get_node().get_preferred_impl_type() == impl_types::onednn) && !lockable) {// scratchpad memory type enforces to device mem.- GPU_DEBUG_LOG << " input is device mem and available device mem size (" << available_device_mem_size- << ") > requested memory (" << layout.bytes_count() << " )" << std::endl;+ GPU_DEBUG_LOG << " input is device mem and available device mem size (" << available_device_mem_size << ") > requested memory (" << layout.bytes_count()+ << " )" << std::endl;alloc_type = engine.get_preferred_memory_allocation_type();} else {- GPU_DEBUG_LOG << " input is not device mem or available device mem size ("- << available_device_mem_size << ") <= requested memory (" << layout.bytes_count() << " )" << std::endl;+ GPU_DEBUG_LOG << " input is not device mem or available device mem size (" << available_device_mem_size << ") <= requested memory ("+ << layout.bytes_count() << " )" << std::endl;alloc_type = engine.get_lockable_preferred_memory_allocation_type();}GPU_DEBUG_LOG << "=> allocate to " << alloc_type << std::endl;- auto ret_mem =- get_memory_from_pool(get_network().get_engine(),- get_network_id(),- get_network().get_memory_pool(),- *_node,- layout,- alloc_type,- shareable,- _runtime_memory_dependencies,- reset,- _intermediates_memory.size() > idx ? _intermediates_memory[idx].get() : nullptr);- GPU_DEBUG_LOG << " [" << get_network().get_id() << ":" << get_node().id() << ": internal buf " << idx << "] " << alloc_type- << " " << ret_mem->buffer_ptr() << std::endl;+ auto ret_mem = get_memory_from_pool(get_network().get_engine(),+ get_network_id(),+ get_network().get_memory_pool(),+ *_node,+ layout,+ alloc_type,+ shareable,+ _runtime_memory_dependencies,+ reset,+ _intermediates_memory.size() > idx ? _intermediates_memory[idx].get() : nullptr);+ GPU_DEBUG_LOG << " [" << get_network().get_id() << ":" << get_node().id() << ": internal buf " << idx << "] " << alloc_type << " " << ret_mem->buffer_ptr()+ << std::endl;return ret_mem;}void primitive_inst::allocate_internal_buffers(bool reset) {- if (_impl == nullptr || _outputs.empty() || _outputs[0] == nullptr)+ if (_impl == nullptr || _outputs.empty() || _outputs[0] == nullptr) {return;+ }const auto& buffer_descs = _impl->get_internal_buffer_descs(*_impl_params);- if (buffer_descs.empty())+ if (buffer_descs.empty()) {return;+ }// allocate intermediate memory for the updated layout of bufferstd::vector<memory::ptr> intermediates_memory;for (size_t i = 0; i < buffer_descs.size(); ++i) {- if (buffer_descs[i].m_layout.get_linear_size() == 0)+ if (buffer_descs[i].m_layout.get_linear_size() == 0) {continue;+ }intermediates_memory.push_back(allocate_internal_buffer(buffer_descs[i].m_layout, i, reset, buffer_descs[i].m_lockable, buffer_descs[i].m_shareable));_max_intermediates_memory_sizes.push_back(intermediates_memory[i]->size());}@@ -2635,18 +2653,21 @@ void primitive_inst::allocate_internal_buffers(bool reset) {void primitive_inst::update_weights() {OV_ITT_SCOPED_TASK(ov::intel_gpu::itt::domains::intel_gpu_plugin, openvino::itt::handle("update_weights: " + id()));GPU_DEBUG_PROFILED_STAGE(instrumentation::pipeline_stage::update_weights);- if (!_impl)+ if (!_impl) {return;+ }bool weightable_node = get_node().is_type<fully_connected>() || get_node().is_type<convolution>() || get_node().is_type<deconvolution>();- if (!weightable_node)+ if (!weightable_node) {return;+ }auto& engine = get_network().get_engine();auto reorder_kernel_params = _impl->get_weights_reorder_kernel_params();- if (reorder_kernel_params)+ if (reorder_kernel_params) {reorder_kernel_params->prog = get_network().get_program().get();+ }auto weights_idx = get_node().get_primitive()->input.size();auto original_weights_memory = dep_memory_ptr(weights_idx);@@ -2658,25 +2679,24 @@ void primitive_inst::update_weights() {_reordered_weights_cache.add(original_layout, original_weights_memory);_impl_params->weights_layout = optional_layout(original_layout);GPU_DEBUG_TRACE_DETAIL << id() << ": add original weights memory " << original_layout.to_short_string() << " to weights cache; "- << "cache_size=" << _reordered_weights_cache.size() << "/" << _reordered_weights_cache.capacity() << std::endl;+ << "cache_size=" << _reordered_weights_cache.size() << "/" << _reordered_weights_cache.capacity() << std::endl;} else {// Set original partial shape, because it may be lost during kernel_selector::weights_tensor -> layout conversion- auto expected_layout =- reorder_kernel_params->get_output_layout().clone_with_other_shape(original_layout.get_partial_shape());+ auto expected_layout = reorder_kernel_params->get_output_layout().clone_with_other_shape(original_layout.get_partial_shape());_impl_params->weights_layout = optional_layout(expected_layout);if (_reordered_weights_cache.has(expected_layout) &&// WA: for custom format, we need to check traits to know what it really represents(expected_layout.format != cldnn::format::custom ||- expected_layout.format.traits() == _reordered_weights_cache.get(expected_layout)->get_layout().format.traits())) {+ expected_layout.format.traits() == _reordered_weights_cache.get(expected_layout)->get_layout().format.traits())) {GPU_DEBUG_PROFILED_STAGE_CACHE_HIT(true);GPU_DEBUG_TRACE_DETAIL << id() << ": reuse weights for " << expected_layout.to_short_string() << std::endl;return;}if (original_layout.compatible(expected_layout)) {GPU_DEBUG_PROFILED_STAGE_CACHE_HIT(true);- GPU_DEBUG_TRACE_DETAIL << id() << ": reinterpret original weights memory from " << original_layout.to_short_string()- << " to " << expected_layout.to_short_string() << std::endl;+ GPU_DEBUG_TRACE_DETAIL << id() << ": reinterpret original weights memory from " << original_layout.to_short_string() << " to "+ << expected_layout.to_short_string() << std::endl;_reordered_weights_cache.add(expected_layout, engine.reinterpret_buffer(*original_weights_memory, expected_layout));return;}@@ -2708,46 +2728,44 @@ void primitive_inst::update_weights() {cache.add(*reorder_kernel_params, reorder_impl->clone());}- auto& stream = get_network().get_stream();+ auto& stream = get_network().get_stream();- bool can_reuse = false;- memory::ptr weights_memory = nullptr;- if (_reordered_weights_cache.is_full()) {- weights_memory = _reordered_weights_cache.get_lru_element().second;- can_reuse = weights_memory->size() <= expected_layout.bytes_count() && (weights_memory->buffer_ptr() != original_weights_memory->buffer_ptr());- }+ bool can_reuse = false;+ memory::ptr weights_memory = nullptr;+ if (_reordered_weights_cache.is_full()) {+ weights_memory = _reordered_weights_cache.get_lru_element().second;+ can_reuse = weights_memory->size() <= expected_layout.bytes_count() && (weights_memory->buffer_ptr() != original_weights_memory->buffer_ptr());+ }- if (can_reuse) {- GPU_DEBUG_TRACE_DETAIL << id() << ": reuse weights memory for new layout " << expected_layout.to_short_string() << std::endl;- weights_memory = engine.reinterpret_buffer(*weights_memory, expected_layout);- } else {- GPU_DEBUG_TRACE_DETAIL << id() << ": allocate weights memory" << std::endl;- auto alloc_type = engine.get_preferred_memory_allocation_type();- weights_memory = engine.allocate_memory(expected_layout, alloc_type);- }+ if (can_reuse) {+ GPU_DEBUG_TRACE_DETAIL << id() << ": reuse weights memory for new layout " << expected_layout.to_short_string() << std::endl;+ weights_memory = engine.reinterpret_buffer(*weights_memory, expected_layout);+ } else {+ GPU_DEBUG_TRACE_DETAIL << id() << ": allocate weights memory" << std::endl;+ auto alloc_type = engine.get_preferred_memory_allocation_type();+ weights_memory = engine.allocate_memory(expected_layout, alloc_type);+ }- _reordered_weights_cache.add(expected_layout, weights_memory);- GPU_DEBUG_TRACE_DETAIL << id() << ": update weights cache: " << expected_layout.to_short_string() << " cache_size="- << _reordered_weights_cache.size() << "/" << _reordered_weights_cache.capacity() << std::endl;+ _reordered_weights_cache.add(expected_layout, weights_memory);+ GPU_DEBUG_TRACE_DETAIL << id() << ": update weights cache: " << expected_layout.to_short_string() << " cache_size=" << _reordered_weights_cache.size()+ << "/" << _reordered_weights_cache.capacity() << std::endl;- kernel_arguments_data args;- args.inputs.push_back(original_weights_memory);- args.outputs.push_back(weights_memory);+ kernel_arguments_data args;+ args.inputs.push_back(original_weights_memory);+ args.outputs.push_back(weights_memory);- auto* reorder_impl = reorder_inst->get_impl();- reorder_impl->set_arguments(*reorder_inst, args);- add_dep_event(reorder_impl->execute({}, *reorder_inst));+ auto* reorder_impl = reorder_inst->get_impl();+ reorder_impl->set_arguments(*reorder_inst, args);+ add_dep_event(reorder_impl->execute({}, *reorder_inst));- GPU_DEBUG_IF(!get_config().get_dump_profiling_data_path().empty() ||- !get_config().get_average_counters().empty()) {- stream.wait_for_events(_impl_params->dep_events);- }+ GPU_DEBUG_IF(!get_config().get_dump_profiling_data_path().empty() || !get_config().get_average_counters().empty()) {+ stream.wait_for_events(_impl_params->dep_events);+ }- return;+ return;}GPU_DEBUG_PROFILED_STAGE_CACHE_HIT(true);-}static bool user_requesting_mem_reuse_false(const program_node& node) {@@ -2784,8 +2802,9 @@ memory::ptr primitive_inst::allocate_output(engine& _engine,auto device_mem_acc = [&](size_t a, const cldnn::layout& l) {// Input shape may be dynamic is some cases (shape_of). It means that output shape of node doesn't depend on input shape// and out memory can be allocated on program build stage.- if (l.is_static())+ if (l.is_static()) {return a + l.bytes_count();+ }return a;};@@ -2794,58 +2813,48 @@ memory::ptr primitive_inst::allocate_output(engine& _engine,auto layout = out_layout.clone_with_other_shape(out_layout.get_partial_shape().get_max_shape());bool usm_device_allocatable = true;const auto& total_device_input_mem_size = std::accumulate(impl_params.input_layouts.begin(), impl_params.input_layouts.end(), (uint64_t)0, device_mem_acc);- if (total_device_input_mem_size > device_info.max_global_mem_size)+ if (total_device_input_mem_size > device_info.max_global_mem_size) {usm_device_allocatable = false;+ }- bool reusable_across_network = (runtime_alloc && node.is_dynamic_output_layout())- || !user_requesting_mem_reuse_false(node);+ bool reusable_across_network = (runtime_alloc && node.is_dynamic_output_layout()) || !user_requesting_mem_reuse_false(node);// Do not use memory pool for nodes from shape_of subgraphs, because such nodes mostly use CPU impls and may be executed in parallel with predecessors// GPU kernels and cause accuracy problems. This significantly improves performance (because provides an ability not to synchronize shape_of subgraphs// execution with other nodes) at the cost of tiny increase in memory consumption.- if (node.is_in_shape_of_subgraph())+ if (node.is_in_shape_of_subgraph()) {reusable_across_network = false;+ }- if (reusable_across_network && node.get_program().is_body_program() && is_output_buffer && runtime_alloc)+ if (reusable_across_network && node.get_program().is_body_program() && is_output_buffer && runtime_alloc) {reusable_across_network = false;+ }// For outputs, cpu prim we want to have lockable alloc type// Also if the successor of a node is an cpu, then memory needs to be lockable.- bool is_cpu = node.get_selected_impl() ? node.get_selected_impl()->is_cpu() :- node.get_preferred_impl_type() == impl_types::cpu;+ bool is_cpu = node.get_selected_impl() ? node.get_selected_impl()->is_cpu() : node.get_preferred_impl_type() == impl_types::cpu;auto total_output_bytes = layout.bytes_count();- auto use_lockable_memory =- (is_output_buffer && ov::intel_gpu::can_use_usm_host(_engine, total_output_bytes)) ||- is_cpu || has_any_cpu_user_not_shape_of(node.get_users()) ||- !_engine.supports_allocation(allocation_type::usm_device) ||- (node.is_shape_infer_dep() && device_info.dev_type == device_type::integrated_gpu);+ auto use_lockable_memory = (is_output_buffer && ov::intel_gpu::can_use_usm_host(_engine, total_output_bytes)) || is_cpu ||+ has_any_cpu_user_not_shape_of(node.get_users()) || !_engine.supports_allocation(allocation_type::usm_device) ||+ (node.is_shape_infer_dep() && device_info.dev_type == device_type::integrated_gpu);const auto& lockable_mem_type = _engine.get_lockable_preferred_memory_allocation_type(layout.format.is_image_2d());- auto alloc_type = use_lockable_memory ? lockable_mem_type- : !usm_device_allocatable ? lockable_mem_type : allocation_type::usm_device;+ auto alloc_type = use_lockable_memory ? lockable_mem_type : !usm_device_allocatable ? lockable_mem_type : allocation_type::usm_device;if (is_internal) {bool is_reorder_weights = node.is_type<reorder>() && node.as<reorder>().get_primitive()->weights_reorder_params;if (node.can_be_optimized() || is_reorder_weights) {GPU_DEBUG_LOG << "[" << node.id() << ": output]" << std::endl;// Use usm_device memory for weights reordering when available.- if (is_internal && is_reorder_weights &&- _engine.supports_allocation(allocation_type::usm_device))+ if (is_internal && is_reorder_weights && _engine.supports_allocation(allocation_type::usm_device)) {alloc_type = allocation_type::usm_device;- return get_memory_from_pool(_engine,- net_id,- pool,- node,- layout,- alloc_type,- false,- memory_dependencies,- reset,- curr_memory);+ }+ return get_memory_from_pool(_engine, net_id, pool, node, layout, alloc_type, false, memory_dependencies, reset, curr_memory);}- if ((node.is_output() && is_reorder_weights) || (!node.is_output() && node.is_type<input_layout>()))+ if ((node.is_output() && is_reorder_weights) || (!node.is_output() && node.is_type<input_layout>())) {reset = false;+ }GPU_DEBUG_LOG << "[" << node.id() << ": constant]" << std::endl;return _engine.allocate_memory(layout, alloc_type, reset);}@@ -2870,33 +2879,35 @@ std::vector<memory::ptr> primitive_inst::allocate_outputs(kernel_impl_params* upauto is_output = is_output_buffer(this, runtime_alloc);outputs.push_back(allocate_output(get_network().get_engine(),- get_network().get_memory_pool(),- get_node(),- impl_params,- _runtime_memory_dependencies,- get_network_id(),- get_network().is_internal(),- i,- reset_mem,- is_output,- current_memory_ptr,- runtime_alloc));+ get_network().get_memory_pool(),+ get_node(),+ impl_params,+ _runtime_memory_dependencies,+ get_network_id(),+ get_network().is_internal(),+ i,+ reset_mem,+ is_output,+ current_memory_ptr,+ runtime_alloc));}}return outputs;}-std::vector<primitive_inst*> primitive_inst::build_exec_deps(std::vector<std::pair<primitive_inst*, int32_t>> const& deps) {+std::vector<primitive_inst*> primitive_inst::build_exec_deps(const std::vector<std::pair<primitive_inst*, int32_t>>& deps) {std::vector<primitive_inst*> exec_deps;exec_deps.reserve(deps.size());- for (const auto& dep : deps)- if (dep.first->get_impl() != nullptr || dep.first->is_dynamic())+ for (const auto& dep : deps) {+ if (dep.first->get_impl() != nullptr || dep.first->is_dynamic()) {exec_deps.push_back(dep.first);+ }+ }return exec_deps;}-std::string primitive_inst::generic_to_string(program_node const& node, const char* type_name) {+std::string primitive_inst::generic_to_string(const program_node& node, const char* type_name) {auto node_info = node.desc_to_json();std::stringstream primitive_description;@@ -2946,8 +2957,9 @@ cldnn::network::ptr primitive_inst::get_unfused_subgraph() {auto port_dep_id = tag_port_number(dep_id, dep.second);// Update input primitive name of prim_of_fused_node- if (dep_idx < prim_of_fused_node->dependencies().size())+ if (dep_idx < prim_of_fused_node->dependencies().size()) {prim_of_fused_node->get_dependency(dep_idx) = {port_dep_id, 0};+ }GPU_DEBUG_TRACE_DETAIL << " add primitive for outer_dep: " << port_dep_id << "\n";@@ -3012,8 +3024,9 @@ cldnn::network::ptr primitive_inst::get_unfused_subgraph() {}}- if (has_primitive_id(outer_dep_ids_with_port, in.pid))+ if (has_primitive_id(outer_dep_ids_with_port, in.pid)) {in = tag_port_number(in.pid, in.idx);+ }GPU_DEBUG_TRACE_DETAIL << " input of prim " << prim->id << " - idx" << i << " " << in << "\n";}@@ -3022,12 +3035,10 @@ cldnn::network::ptr primitive_inst::get_unfused_subgraph() {added_prim_ids.push_back(prim->id);}- ExecutionConfig subgraph_config{- ov::intel_gpu::allow_static_input_reorder(true),- ov::intel_gpu::allow_new_shape_infer(true),- ov::enable_profiling(get_network().get_config().get_enable_profiling()),- ov::intel_gpu::use_onednn(get_network().get_config().get_use_onednn())- };+ ExecutionConfig subgraph_config{ov::intel_gpu::allow_static_input_reorder(true),+ ov::intel_gpu::allow_new_shape_infer(true),+ ov::enable_profiling(get_network().get_config().get_enable_profiling()),+ ov::intel_gpu::use_onednn(get_network().get_config().get_use_onednn())};auto prog = program::build_program(get_network().get_engine(),t,subgraph_config,@@ -3041,32 +3052,38 @@ cldnn::network::ptr primitive_inst::get_unfused_subgraph() {return _unfused_subgraph;}-#define LOG_AND_RETURN_FALSE(node) do { \- GPU_DEBUG_TRACE_DETAIL << (node)->id() << " : it is an invalid fusion" << std::endl; \- return false; \-} while (0)+#define LOG_AND_RETURN_FALSE(node) \+ do { \+ GPU_DEBUG_TRACE_DETAIL << (node)->id() << " : it is an invalid fusion" << std::endl; \+ return false; \+ } while (0)bool primitive_inst::is_valid_fusion() const {- if (!is_dynamic())+ if (!is_dynamic()) {return true;+ }const auto& fuse_descriptors = _impl_params->fused_desc;- if (fuse_descriptors.empty())+ if (fuse_descriptors.empty()) {return true;+ }std::vector<fused_primitive_desc> fused_eltwise_prims;for (const auto& fd : fuse_descriptors) {if (fd.is_type<eltwise>() || fd.is_type<activation>()) {fused_eltwise_prims.push_back(fd);} else {- if (fd.is_type<reorder>() || fd.is_type<quantize>())+ if (fd.is_type<reorder>() || fd.is_type<quantize>()) {continue;+ }if (fd.is_type<swiglu>()) {OPENVINO_ASSERT(get_node().is_type<fully_connected>() && get_node().get_preferred_impl_type() == impl_types::ocl);- if (!get_node().get_selected_impl())+ if (!get_node().get_selected_impl()) {LOG_AND_RETURN_FALSE(_node);+ }// TODO : support ref kernel too- if (get_node().get_selected_impl()->get_kernel_name().find("fully_connected_gpu_bf_tiled") != std::string::npos)+ if (get_node().get_selected_impl()->get_kernel_name().find("fully_connected_gpu_bf_tiled") != std::string::npos) {return true;+ }LOG_AND_RETURN_FALSE(_node);}@@ -3074,20 +3091,21 @@ bool primitive_inst::is_valid_fusion() const {}}- if (fused_eltwise_prims.empty())+ if (fused_eltwise_prims.empty()) {return true;+ }if (get_node().is_type<fully_connected>() || get_node().is_type<gemm>() || get_node().is_type<convolution>()) {- if (_impl_params->input_layouts[0].count() == 0 ||- _impl_params->input_layouts[1].count() == 0) {+ if (_impl_params->input_layouts[0].count() == 0 || _impl_params->input_layouts[1].count() == 0) {LOG_AND_RETURN_FALSE(_node);}}if (get_node().is_type<fully_connected>() && get_node().get_preferred_impl_type() == impl_types::ocl) {// TODO: Only fc_bf_tiled_kernel & ref kernel are verified for fused eltwise. To support more fc kernels for eltwise fusion- if (!get_node().get_selected_impl())+ if (!get_node().get_selected_impl()) {LOG_AND_RETURN_FALSE(_node);+ }if (!data_type_traits::is_i8_u8(get_node().get_input_layout(0).data_type) &&(get_node().get_selected_impl()->get_kernel_name().find("fully_connected_gpu_bf_tiled") == std::string::npos) &&(get_node().get_selected_impl()->get_kernel_name().find("fully_connected_gpu_bfyx_ref") == std::string::npos)) {@@ -3095,13 +3113,14 @@ bool primitive_inst::is_valid_fusion() const {}}- const auto& out_pshape = (_unfused_subgraph != nullptr && !get_flag(ExecutionFlags::SHAPE_CHANGED)) ?- _unfused_subgraph->get_primitive(get_node().id())->get_output_layout().get_partial_shape() :- _impl_params->get_output_layout().get_partial_shape();+ const auto& out_pshape = (_unfused_subgraph != nullptr && !get_flag(ExecutionFlags::SHAPE_CHANGED))+ ? _unfused_subgraph->get_primitive(get_node().id())->get_output_layout().get_partial_shape()+ : _impl_params->get_output_layout().get_partial_shape();for (auto& fd : fused_eltwise_prims) {auto outer_dep_idx = fd.outer_dep_start_idx;- if (outer_dep_idx < 0) // no outer dep+ if (outer_dep_idx < 0) { // no outer depcontinue;+ }OPENVINO_ASSERT(fd.total_num_deps == 2, "[GPU] Unexpected count of dependencies in dynamic fusion for eltwise or activation");OPENVINO_ASSERT(outer_dep_idx < 0 || static_cast<int32_t>(_deps.size()) > outer_dep_idx, "[GPU] Invalid fused dependency idx");const auto& outer_dep = _deps[outer_dep_idx];@@ -3109,8 +3128,9 @@ bool primitive_inst::is_valid_fusion() const {const auto& outer_dep_pshape = outer_dep.first->_impl_params->get_output_layout().get_partial_shape();auto merged_shape = out_pshape;bool can_broadcast = true;- if (fd.is_type<eltwise>())+ if (fd.is_type<eltwise>()) {can_broadcast = ov::PartialShape::broadcast_merge_into(merged_shape, outer_dep_pshape, fd.typed_desc<eltwise>()->broadcast_spec);+ }#ifdef ENABLE_ONEDNN_FOR_GPU// WA for OneDNN binary add fusions: we need to broadcast batch dimension to avoid situation with@@ -3125,35 +3145,35 @@ bool primitive_inst::is_valid_fusion() const {auto gemm_dims = onednn::convert_tensor(gemm_layout.get_tensor(), cldnn::format::dimension(gemm_layout.format));auto data_dims = onednn::convert_tensor(data_layout.get_tensor(), cldnn::format::dimension(data_layout.format));- if (gemm_dims[0] != data_dims[0] && gemm_dims[1] != 1)+ if (gemm_dims[0] != data_dims[0] && gemm_dims[1] != 1) {LOG_AND_RETURN_FALSE(_node);+ }}#endif// We check that broadcasting of extra input is possible and it doesn't change output shape. If it output shape is changed, then// some dimension of dep_pshape is greater than out_pshape- if (!can_broadcast || merged_shape != out_pshape)+ if (!can_broadcast || merged_shape != out_pshape) {LOG_AND_RETURN_FALSE(_node);+ }}return true;}void primitive_inst::add_profiling_data(instrumentation::pipeline_stage stage, bool cache_hit, std::string memalloc_info, int64_t time, bool per_iter_mode) {- instrumentation::perf_counter_key key {- get_network().get_input_layouts(),- _impl_params->input_layouts,- _impl_params->output_layouts,- get_implementation_name(),- stage,+ instrumentation::perf_counter_key key{get_network().get_input_layouts(),+ _impl_params->input_layouts,+ _impl_params->output_layouts,+ get_implementation_name(),+ stage,#ifdef GPU_DEBUG_CONFIG- per_iter_mode ? get_network().get_current_iteration_num() : 0,+ per_iter_mode ? get_network().get_current_iteration_num() : 0,#else- 0,+ 0,#endif- cache_hit,- memalloc_info- };+ cache_hit,+ memalloc_info};auto hash = instrumentation::perf_counter_hash()(key);auto& d = _profiling_data[hash];@@ -3171,16 +3191,16 @@ std::string primitive_inst::get_implementation_name() const {try {auto kernel_name = _impl ? _impl->get_kernel_name() : "";return !kernel_name.empty() ? kernel_name : "undef";- } catch (...) { }+ } catch (...) {+ }return "undef";}-ImplementationsFactory::ImplementationsFactory(const program_node* node)- : m_node(node)- , m_available_impls(node->type()->get_supported_implementations(*node))- , m_static_impls_cache(node->get_program().get_implementations_cache()) {+ : m_node(node),+ m_available_impls(node->type()->get_supported_implementations(*node)),+ m_static_impls_cache(node->get_program().get_implementations_cache()) {if (node->get_selected_impl() && node->get_selected_impl()->is_dynamic()) {m_dynamic_impls_cache.emplace_back(node->get_selected_impl()->clone());}@@ -3192,15 +3212,18 @@ std::shared_ptr<primitive_impl> ImplementationsFactory::get_primitive_impl_for_pauto find_impl = [this](const program_node* node, const kernel_impl_params& params, shape_types shape_type) -> std::unique_ptr<primitive_impl> {OPENVINO_ASSERT(node != nullptr);for (auto& impl_manager : m_available_impls) {- if ((impl_manager->get_shape_type() & shape_type) != shape_type)+ if ((impl_manager->get_shape_type() & shape_type) != shape_type) {continue;+ }- if (!impl_manager->support_shapes(params))+ if (!impl_manager->support_shapes(params)) {continue;+ }auto impl = impl_manager->create(*node, params);- if (impl)+ if (impl) {return impl;+ }}return nullptr;@@ -3237,15 +3260,17 @@ std::shared_ptr<primitive_impl> ImplementationsFactory::get_primitive_impl_for_pif (use_async_compilation && ((inst.get_impl() && inst.get_impl()->is_dynamic()) || inst.get_flag(ExecutionFlags::SHAPE_CHANGED))) {auto& compilation_context = prog.get_compilation_context();compilation_context.push_task(updated_params, [&inst, &compilation_context, updated_params, find_impl]() {- if (compilation_context.is_stopped())+ if (compilation_context.is_stopped()) {return;+ }auto& _program = *inst.get_network().get_program();auto& cache = _program.get_implementations_cache();{// Check existense in the cache one more time as several iterations of model execution could happens and multiple compilation// tasks created for same shapes- if (cache.has(updated_params))+ if (cache.has(updated_params)) {return;+ }}std::unique_ptr<primitive_impl> impl = find_impl(&inst.get_node(), updated_params, shape_types::static_shape);@@ -3254,8 +3279,9 @@ std::shared_ptr<primitive_impl> ImplementationsFactory::get_primitive_impl_for_pauto kernels = _program.get_kernels_cache().compile(updated_params, impl->get_kernels_source());impl->set_kernels(kernels);}- if (impl)+ if (impl) {cache.add(updated_params, std::move(impl));+ }});}@@ -3289,8 +3315,9 @@ std::shared_ptr<primitive_impl> ImplementationsFactory::get_primitive_impl_for_pauto static_impl = find_impl(node, updated_params, shape_types::static_shape);if (!static_impl) {auto stringify_layouts = [](const std::vector<layout>& layouts) {- if (layouts.empty())+ if (layouts.empty()) {return std::string("<none>");+ }std::ostringstream oss;oss << layouts[0].to_short_string();@@ -3303,17 +3330,17 @@ std::shared_ptr<primitive_impl> ImplementationsFactory::get_primitive_impl_for_pstd::ostringstream available_impls_oss;available_impls_oss << "available_impls: " << m_available_impls.size() << " [";for (size_t i = 0; i < m_available_impls.size(); ++i) {- if (i > 0)+ if (i > 0) {available_impls_oss << ",";+ }const auto& m = m_available_impls[i];- available_impls_oss << " {type=" << static_cast<int>(m->get_impl_type())- << ", shape=" << static_cast<int>(m->get_shape_type()) << "}";+ available_impls_oss << " {type=" << static_cast<int>(m->get_impl_type()) << ", shape=" << static_cast<int>(m->get_shape_type()) << "}";}available_impls_oss << " ]";- OPENVINO_ASSERT(false, "No static impl " + node->id() + ". " + available_impls_oss.str() +- ". Input: " + stringify_layouts(updated_params.input_layouts) +- ". Output: " + stringify_layouts(updated_params.output_layouts));+ OPENVINO_ASSERT(false,+ "No static impl " + node->id() + ". " + available_impls_oss.str() + ". Input: " + stringify_layouts(updated_params.input_layouts) ++ ". Output: " + stringify_layouts(updated_params.output_layouts));}static_impl->set_node_params(*node);if (!inst.can_be_optimized()) {diff --git a/src/plugins/intel_gpu/src/graph/prior_box.cpp b/src/plugins/intel_gpu/src/graph/prior_box.cppindex 0a94a1d2e2b..40384e30245 100644--- a/src/plugins/intel_gpu/src/graph/prior_box.cpp+++ b/src/plugins/intel_gpu/src/graph/prior_box.cpp@@ -220,8 +220,9 @@ void calculate_prior_box_output(memory::ptr output_mem, stream& stream, layout cstd::string vector_to_string(const std::vector<float>& vec) {std::stringstream result;- for (size_t i = 0; i < vec.size(); i++)+ for (size_t i = 0; i < vec.size(); i++) {result << vec.at(i) << ", ";+ }return result.str();}@@ -229,8 +230,9 @@ std::vector<float> normalized_aspect_ratio(const std::vector<float>& aspect_ratistd::set<float> unique_ratios;for (auto ratio : aspect_ratio) {unique_ratios.insert(static_cast<float>(std::round(ratio * 1e6) / 1e6));- if (flip)+ if (flip) {unique_ratios.insert(static_cast<float>(std::round(1 / ratio * 1e6) / 1e6));+ }}unique_ratios.insert(1);return std::vector<float>(unique_ratios.begin(), unique_ratios.end());@@ -281,8 +283,9 @@ tensor get_output_shape(ov::Dimension::value_type height, ov::Dimension::value_t} // namespacevoid prior_box_node::calc_result() {- if (result != nullptr)+ if (result != nullptr) {return;+ }auto& argument = *typed_desc();@@ -400,16 +403,17 @@ void prior_box_node::calc_result() {result = get_program().get_engine().allocate_memory(get_output_layout());// perform calculations- if (get_output_layout().data_type == data_types::f16)+ if (get_output_layout().data_type == data_types::f16) {calculate_prior_box_output<ov::element_type_traits<data_types::f16>::value_type>(result,get_program().get_stream(),get_input_layout(),*typed_desc());- else+ } else {calculate_prior_box_output<ov::element_type_traits<data_types::f32>::value_type>(result,get_program().get_stream(),get_input_layout(),*typed_desc());+ }}layout prior_box_inst::calc_output_layout(prior_box_node const& node, kernel_impl_params const& impl_param) {diff --git a/src/plugins/intel_gpu/src/graph/program.cpp b/src/plugins/intel_gpu/src/graph/program.cppindex 7654ca70243..4ae1a3d1468 100644--- a/src/plugins/intel_gpu/src/graph/program.cpp+++ b/src/plugins/intel_gpu/src/graph/program.cpp@@ -1019,9 +1019,9 @@ void program::remove_all_connections(program_node& node) {void program::rename(program_node& node, primitive_id const& new_id) {if (nodes_map.count(new_id))throw std::runtime_error("Trying to rename program_node but node with id " + new_id + " already exists");- if (node.is_output())- throw std::invalid_argument(- "Trying to rename an output node. If you intend to do that, please clear 'output' flag manually.");+ if (node.is_output()) {+ throw std::invalid_argument("Trying to rename an output node. If you intend to do that, please clear 'output' flag manually.");+ }auto node_itr = nodes_map.find(node.id());if (node_itr == nodes_map.end()) return;@@ -1056,9 +1056,9 @@ void program::replace(program_node& old_node, program_node& new_node) {if (!new_node.dependencies.empty() || !new_node.users.empty())throw std::invalid_argument("Node which is about to replace other node should be detached");- if (new_node.is_output())- throw std::invalid_argument(- "Replacement node shouldn't be marked as an output since it's impossible to rename such node.");+ if (new_node.is_output()) {+ throw std::invalid_argument("Replacement node shouldn't be marked as an output since it's impossible to rename such node.");+ }auto id = old_node.id();new_node.output_layouts = old_node.get_output_layouts();@@ -1546,13 +1546,14 @@ void program::set_layout_optimizer_attributes(layout_optimizer& lo) {#endifauto input_size = node->get_input_layout(0).get_tensor();auto ifm = static_cast<uint32_t>(input_size.feature[0]);- if (conv.get_primitive()->groups == ifm && conv.get_primitive()->groups >= 16)+ if (conv.get_primitive()->groups == ifm && conv.get_primitive()->groups >= 16) {total_dw_conv_layers++;- else if (conv.get_primitive()->groups == ifm && conv.get_primitive()->groups < 16)+ } else if (conv.get_primitive()->groups == ifm && conv.get_primitive()->groups < 16) {total_dw_splitted_conv_layers++; // this counter is needed due to compatibility with b_fs_yx_fsv16// heuristics- else if (conv.get_primitive()->groups > 1)+ } else if (conv.get_primitive()->groups > 1) {total_grouped_conv_layers++;+ }if (input_size.spatial[0] == 1 && input_size.spatial[1] == 1)total_1x1_fm_conv_layers++;@@ -1565,10 +1566,11 @@ void program::set_layout_optimizer_attributes(layout_optimizer& lo) {total_asym_quantized_conv_layers++;}if (prim.type() == cldnn::deconvolution::type_id()) {- if (lo.is_format_optimized(prim.as<deconvolution>(), format::b_fs_zyx_fsv16))+ if (lo.is_format_optimized(prim.as<deconvolution>(), format::b_fs_zyx_fsv16)) {opt_deconv_layers_b_fs_zyx_fsv16 += 1;- else if (lo.is_format_supported(prim.as<deconvolution>(), format::b_fs_yx_fsv16))+ } else if (lo.is_format_supported(prim.as<deconvolution>(), format::b_fs_yx_fsv16)) {opt_deconv_layers_b_fs_yx_fsv16 += 1;+ }total_deconv_layers++;}diff --git a/src/plugins/intel_gpu/src/graph/program_dump_graph.cpp b/src/plugins/intel_gpu/src/graph/program_dump_graph.cppindex 989ef7139db..67642a45fc6 100644--- a/src/plugins/intel_gpu/src/graph/program_dump_graph.cpp+++ b/src/plugins/intel_gpu/src/graph/program_dump_graph.cpp@@ -3,17 +3,17 @@//#include "program_dump_graph.h"-#include "intel_gpu/runtime/debug_configuration.hpp"-#include "to_string_utils.h"-#include "json_object.h"++#include <algorithm>+#include <string>+#include <vector>#include "condition_inst.h"#include "data_inst.h"#include "dynamic_quantize_inst.h"--#include <algorithm>-#include <vector>-#include <string>+#include "intel_gpu/runtime/debug_configuration.hpp"+#include "json_object.h"+#include "to_string_utils.h"namespace cldnn {namespace {@@ -136,14 +136,18 @@ static const std::vector<std::string> colors = {"yellowgreen",};-void close_stream(std::ofstream& graph) { graph.close(); }+void close_stream(std::ofstream& graph) {+ graph.close();+}-std::string get_node_id(const program_node* ptr) { return "node_" + std::to_string(reinterpret_cast<uintptr_t>(ptr)); }+std::string get_node_id(const program_node* ptr) {+ return "node_" + std::to_string(reinterpret_cast<uintptr_t>(ptr));+}void dump_full_node(std::ofstream& out, const program_node* node) {try {out << node->type()->to_string(*node);- } catch(const std::exception& e) {+ } catch (const std::exception& e) {auto node_info = std::shared_ptr<json_composite>(new json_composite());node_info->add("id", node->id());node_info->add("ptr", "node_" + std::to_string(reinterpret_cast<uintptr_t>(node)));@@ -219,9 +223,11 @@ void dump_graph_init(std::ofstream& graph,std::ostringstream oss;if (ptr->is_type<dynamic_quantize>()) {auto dyn_quan = ptr->as<dynamic_quantize>().get_primitive();- oss << "\n" << "group_sizes: " << ov::util::join<std::ostream>(cldnn::convert_vector<int64_t>(dyn_quan->attrs.group_sizes));+ oss << "\n"+ << "group_sizes: " << ov::util::join<std::ostream>(cldnn::convert_vector<int64_t>(dyn_quan->attrs.group_sizes));if (dyn_quan->attrs.precomputed_reduction) {- oss << "\n" << "precomputed_reduction_dt: " << dyn_quan->attrs.precomputed_reduction_dt;+ oss << "\n"+ << "precomputed_reduction_dt: " << dyn_quan->attrs.precomputed_reduction_dt;}}return oss.str();@@ -230,13 +236,12 @@ void dump_graph_init(std::ofstream& graph,graph << "digraph cldnn_program {\n";for (const auto& node : program.get_processing_order()) {#ifdef __clang__-#pragma clang diagnostic push-#pragma clang diagnostic ignored "-Wpotentially-evaluated-expression"+# pragma clang diagnostic push+# pragma clang diagnostic ignored "-Wpotentially-evaluated-expression"#endifstd::string node_type_name = node->get_primitive()->type_string();const auto& inst = get_primitive_inst ? get_primitive_inst(node->id()) : nullptr;- graph << " " << get_node_id(node) << "[label=\"" << node->id() << ":"- << "\\ntype: " << node_type_name+ graph << " " << get_node_id(node) << "[label=\"" << node->id() << ":" << "\\ntype: " << node_type_name<< "\\nprocessing number: " << program.get_processing_order().get_processing_number(node)<< "\\n color:" << (node->is_reusing_memory() ? std::to_string(node->get_reused_memory_color()) : "none")<< ((inst ? inst->can_be_optimized() : node->can_be_optimized()) ? "\\n optimized out" : "");@@ -264,7 +269,7 @@ void dump_graph_init(std::ofstream& graph,graph << "\n" + dump_prim_additional_info(node);graph << "\"";#ifdef __clang__-#pragma clang diagnostic pop+# pragma clang diagnostic pop#endifif (node->is_type<condition>()) {@@ -282,7 +287,7 @@ void dump_graph_init(std::ofstream& graph,// To print duplicated connection port between two nodes.// <user_node, user's input port>- std::set<std::pair<program_node *, int>> marked_connection;+ std::set<std::pair<program_node*, int>> marked_connection;for (const auto& user : node->get_users()) {bool doubled = true;@@ -296,21 +301,23 @@ void dump_graph_init(std::ofstream& graph,++it;}- if (it == user->get_dependencies().end())+ if (it == user->get_dependencies().end()) {doubled = false;- graph << " " << get_node_id(node) << " -> " << get_node_id(user)- << " [label=\"" << it->second << " -> " << std::distance(user->get_dependencies().begin(), it) << "\"]";-+ }+ graph << " " << get_node_id(node) << " -> " << get_node_id(user) << " [label=\"" << it->second << " -> "+ << std::distance(user->get_dependencies().begin(), it) << "\"]";bool data_flow = node->is_in_data_flow() && user->is_in_data_flow();if (data_flow) {- if (doubled)+ if (doubled) {graph << " [color=red]";- else+ } else {graph << " [color=red, style=dashed, label=\"usr\"]";+ }} else {- if (!doubled)+ if (!doubled) {graph << " [style=dashed, label=\"usr\"]";+ }}graph << ";\n";}@@ -320,8 +327,7 @@ void dump_graph_init(std::ofstream& graph,continue;}- graph << " " << get_node_id(node) << " -> " << get_node_id(dep.first)- << " [style=dashed, label=\"dep\", constraint=false];\n";+ graph << " " << get_node_id(node) << " -> " << get_node_id(dep.first) << " [style=dashed, label=\"dep\", constraint=false];\n";}}graph << "}\n";@@ -329,15 +335,17 @@ void dump_graph_init(std::ofstream& graph,}void dump_graph_processing_order(std::ofstream& graph, const program& program) {- for (auto* node : program.get_processing_order())+ for (auto* node : program.get_processing_order()) {graph << reinterpret_cast<uintptr_t>(node) << " (" << node->id() << ")\n";+ }graph << '\n';close_stream(graph);}void dump_graph_optimized(std::ofstream& graph, const program& program) {- for (const auto& prim_id : program.get_optimized_out())+ for (const auto& prim_id : program.get_optimized_out()) {graph << prim_id << "\n";+ }graph << '\n';close_stream(graph);}diff --git a/src/plugins/intel_gpu/src/graph/program_node.cpp b/src/plugins/intel_gpu/src/graph/program_node.cppindex 17a94e8ebfc..4788d22c69a 100644--- a/src/plugins/intel_gpu/src/graph/program_node.cpp+++ b/src/plugins/intel_gpu/src/graph/program_node.cpp@@ -3,44 +3,48 @@//#include "program_node.h"-#include "program_helpers.h"-#include "primitive_inst.h"-#include "loop_inst.h"-#include "shape_of_inst.h"+#include "activation_inst.h"-#include "reorder_inst.h"+#include "intel_gpu/runtime/debug_configuration.hpp"+#include "loop_inst.h"+#include "primitive_inst.h"+#include "program_helpers.h"#include "quantize_inst.h"+#include "reorder_inst.h"+#include "shape_of_inst.h"#include "swiglu_inst.h"-#include "intel_gpu/runtime/debug_configuration.hpp"#ifdef ENABLE_ONEDNN_FOR_GPU-#include "convolution_inst.h"-#include "gemm_inst.h"-#include "fully_connected_inst.h"-#include "deconvolution_inst.h"-#include "pooling_inst.h"-#include "reduce_inst.h"-#include <impls/onednn/utils.hpp>-#endif // ENABLE_ONEDNN_FOR_GPU+# include <impls/onednn/utils.hpp>++# include "convolution_inst.h"+# include "deconvolution_inst.h"+# include "fully_connected_inst.h"+# include "gemm_inst.h"+# include "pooling_inst.h"+# include "reduce_inst.h"+#endif // ENABLE_ONEDNN_FOR_GPU-#include "to_string_utils.h"-#include "json_object.h"-#include <vector>#include <memory>-#include <utility>-#include <string>#include <set>+#include <string>+#include <utility>+#include <vector>++#include "json_object.h"+#include "to_string_utils.h"using namespace cldnn;static size_t get_shape_data_size(const layout& l) {- if (l.is_static())+ if (l.is_static()) {return 0;+ }- size_t size = layout::max_rank(); // all dimensions are stored+ size_t size = layout::max_rank(); // all dimensions are storedconst auto& dynamic_pad = l.data_padding._dynamic_dims_mask;for (size_t j = 0; j < layout::max_rank(); ++j) {if (static_cast<int>(dynamic_pad[j]) == 1) {- size += 2; // lower + upper+ size += 2; // lower + upper}}@@ -50,10 +54,14 @@ static size_t get_shape_data_size(const layout& l) {thread_local size_t program_node::cur_id = 0;program_node::program_node(std::shared_ptr<primitive> prim, program& prog)- : desc(prim), myprog(prog), preferred_input_fmts({}), preferred_output_fmts({}), org_id(prim ? (prim->id) : std::string()) {+ : desc(prim),+ myprog(prog),+ preferred_input_fmts({}),+ preferred_output_fmts({}),+ org_id(prim ? (prim->id) : std::string()) {if (prim) {num_outputs = prim->num_outputs;- for (size_t i = 0 ; i < num_outputs; ++i) {+ for (size_t i = 0; i < num_outputs; ++i) {layout output_layout = layout{ov::PartialShape{}, data_types::f32, format::bfyx};output_layout.data_padding = prim->get_output_padding(i);output_layouts.push_back(output_layout);@@ -63,10 +71,12 @@ program_node::program_node(std::shared_ptr<primitive> prim, program& prog)}void program_node::replace_dependency(size_t idx, std::pair<program_node*, int32_t> new_dep, bool remove_if_dangling) {- if (idx >= dependencies.size())+ if (idx >= dependencies.size()) {return;- if (dependencies[idx].first == new_dep.first)+ }+ if (dependencies[idx].first == new_dep.first) {return;+ }if (is_type<loop>()) {loop_node& loop = *this;@@ -78,15 +88,16 @@ void program_node::replace_dependency(size_t idx, std::pair<program_node*, int32dependencies[idx].first->users.erase(it);}- if (remove_if_dangling)+ if (remove_if_dangling) {myprog.remove_if_dangling(*dependencies[idx].first);+ }dependencies[idx].first = new_dep.first;dependencies[idx].second = new_dep.second;new_dep.first->users.push_back(this);}-std::vector<layout> const program_node::get_input_layouts() const {+const std::vector<layout> program_node::get_input_layouts() const {std::vector<layout> layouts;for (size_t i = 0; i < dependencies.size(); i++) {auto input_layout = get_input_layout(i);@@ -105,8 +116,9 @@ const ov::PartialShape& program_node::get_input_pshape(size_t idx) const {}ov::PartialShape program_node::get_output_pshape(size_t idx) const {- if (!is_valid_output_layout(idx))+ if (!is_valid_output_layout(idx)) {return calc_output_layouts()[idx].get_partial_shape();+ }return get_output_layout(idx).get_partial_shape();}@@ -170,38 +182,43 @@ void program_node::replace_dependency(size_t idx, program_node& new_dep, bool rereturn replace_dependency(idx, std::make_pair(&new_dep, 0), remove_if_dangling);}-void program_node::replace_dependency(program_node const& old_dep, std::pair<program_node*, int32_t> new_dep, bool remove_if_dangling) {- for (size_t i = 0; i < dependencies.size(); ++i)- if (dependencies[i].first == &old_dep)+void program_node::replace_dependency(const program_node& old_dep, std::pair<program_node*, int32_t> new_dep, bool remove_if_dangling) {+ for (size_t i = 0; i < dependencies.size(); ++i) {+ if (dependencies[i].first == &old_dep) {return replace_dependency(i, new_dep, remove_if_dangling);+ }+ }}-void program_node::replace_dependency(program_node const& old_dep, program_node& new_dep, bool remove_if_dangling) {+void program_node::replace_dependency(const program_node& old_dep, program_node& new_dep, bool remove_if_dangling) {return replace_dependency(old_dep, std::make_pair(&new_dep, 0), remove_if_dangling);}std::vector<primitive_id> program_node::get_dependencies_ids() const {std::vector<primitive_id> dep_ids;- for (const auto& dependency : dependencies)+ for (const auto& dependency : dependencies) {dep_ids.push_back(dependency.first->get_primitive()->id);+ }return dep_ids;}void program_node::remove_dependency(size_t idx) {- if (idx >= dependencies.size())+ if (idx >= dependencies.size()) {return;+ }dependencies[idx].first->users.remove(this);myprog.remove_if_dangling(*dependencies[idx].first);dependencies.erase(dependencies.begin() + idx);}-const std::vector<uint32_t>& program_node::get_memory_dependencies() const { return memory_dependencies; }+const std::vector<uint32_t>& program_node::get_memory_dependencies() const {+ return memory_dependencies;+}void program_node::add_memory_dependency(std::vector<size_t> prim_list) {for (size_t val : prim_list) {- OPENVINO_ASSERT(val <= std::numeric_limits<uint32_t>::max(),- "[GPU] Memory dependency id is out of uint32_t range: ", std::to_string(val));+ OPENVINO_ASSERT(val <= std::numeric_limits<uint32_t>::max(), "[GPU] Memory dependency id is out of uint32_t range: ", std::to_string(val));const auto v32 = static_cast<uint32_t>(val);auto it = std::lower_bound(memory_dependencies.begin(), memory_dependencies.end(), v32);if (it == memory_dependencies.end() || *it != v32) {@@ -315,8 +332,8 @@ std::unique_ptr<json_composite> program_node::desc_to_json() const {impls.push_back("null");} else {#ifdef __clang__-#pragma clang diagnostic push-#pragma clang diagnostic ignored "-Wpotentially-evaluated-expression"+# pragma clang diagnostic push+# pragma clang diagnostic ignored "-Wpotentially-evaluated-expression"#endifimpls.push_back(selected_impl->get_kernel_name());@@ -329,7 +346,7 @@ std::unique_ptr<json_composite> program_node::desc_to_json() const {node_info->add("cl dump_ info", cl_dump_info);}#ifdef __clang__-#pragma clang diagnostic pop+# pragma clang diagnostic pop#endif}node_info->add("implementation", impls);@@ -344,16 +361,19 @@ std::unique_ptr<json_composite> program_node::desc_to_json() const {}void program_node::remove_dependency(program_node& node) {- for (size_t i = 0; i < dependencies.size(); ++i)- if (dependencies[i].first == &node)+ for (size_t i = 0; i < dependencies.size(); ++i) {+ if (dependencies[i].first == &node) {remove_dependency(i);+ }+ }}size_t program_node::get_user_index(const program_node& node) const {size_t idx = 0;for (const auto& user : users) {- if (user == &node)+ if (user == &node) {return idx;+ }idx++;}@@ -361,23 +381,28 @@ size_t program_node::get_user_index(const program_node& node) const {}int32_t program_node::get_dependency_output_port(const program_node& node) const {- for (size_t i = 0; i < dependencies.size(); ++i)- if (dependencies[i].first == &node)+ for (size_t i = 0; i < dependencies.size(); ++i) {+ if (dependencies[i].first == &node) {return dependencies[i].second;+ }+ }OPENVINO_THROW("[GPU] Search invalid dependency output port" + node.id() + " node");}size_t program_node::get_dependency_index(const program_node& node) const {- for (size_t i = 0; i < dependencies.size(); ++i)- if (dependencies[i].first == &node)+ for (size_t i = 0; i < dependencies.size(); ++i) {+ if (dependencies[i].first == &node) {return i;+ }+ }OPENVINO_THROW("[GPU] Search invalid dependency node" + node.id() + " node");}bool program_node::is_detached(bool whole_branch) {- if (!users.empty())+ if (!users.empty()) {return false;+ }return whole_branch || dependencies.empty();}@@ -401,16 +426,18 @@ std::vector<layout> program_node::calc_output_layouts() const {bool allow_new_shape_infer = get_program().is_new_shape_infer();if (allow_new_shape_infer) {auto out_layouts = type()->calc_output_layouts(*this, *get_kernel_impl_params());- if (!out_layouts.empty())+ if (!out_layouts.empty()) {return out_layouts;+ }}return {type()->calc_output_layout(*this, *get_kernel_impl_params())};}const layout& program_node::get_output_layout(bool invalidate_users_if_changed, size_t idx) {- if (valid_output_layouts[idx])+ if (valid_output_layouts[idx]) {return output_layouts[idx];+ }auto new_layouts = calc_output_layouts();set_output_layouts(new_layouts, invalidate_users_if_changed);@@ -418,15 +445,17 @@ const layout& program_node::get_output_layout(bool invalidate_users_if_changed,}const layout& program_node::get_output_layout(size_t idx) const {- if (!valid_output_layouts[idx])+ if (!valid_output_layouts[idx]) {throw std::runtime_error("Output layout not calculated for " + id() + " node");+ }return output_layouts[idx];}const std::vector<layout>& program_node::get_output_layouts(bool invalidate_users_if_changed) {- if (is_all_valid_output_layouts())+ if (is_all_valid_output_layouts()) {return output_layouts;+ }auto new_layouts = calc_output_layouts();set_output_layouts(new_layouts, invalidate_users_if_changed);@@ -449,12 +478,18 @@ layout program_node::get_non_padded_output_layout(bool invalidate_users_if_changbool program_node::set_output_layout(layout& new_layout, bool invalidate_users_if_changed, size_t idx) {merge_output_padding(new_layout.data_padding, idx);- OPENVINO_ASSERT(idx < output_layouts.size(), id(), " has invalid index : index is ", std::to_string(idx),- " but output_layouts length is ", std::to_string(output_layouts.size()));+ OPENVINO_ASSERT(idx < output_layouts.size(),+ id(),+ " has invalid index : index is ",+ std::to_string(idx),+ " but output_layouts length is ",+ std::to_string(output_layouts.size()));new_layout.data_padding = output_layouts[idx].data_padding;bool changed = (new_layout != output_layouts[idx]);- if (changed && invalidate_users_if_changed) // output_layout has changed! invalidate users+ if (changed && invalidate_users_if_changed) { // output_layout has changed!+ // invalidate usersinvalidate_users();+ }output_layouts[idx] = new_layout;valid_output_layouts[idx] = true;@@ -485,26 +520,30 @@ bool program_node::recalc_output_layouts(bool invalidate_users_if_changed) {bool program_node::is_dynamic() const {for (const auto& input : get_dependencies()) {- if (input.first->is_dynamic_output_layout(input.second))+ if (input.first->is_dynamic_output_layout(input.second)) {return true;+ }}for (size_t i = 0; i < output_layouts.size(); ++i) {- if (output_layouts[i].is_dynamic())+ if (output_layouts[i].is_dynamic()) {return true;+ }}return false;}bool program_node::is_dynamic() {for (const auto& input : get_dependencies()) {- if (input.first->is_dynamic_output_layout(input.second))+ if (input.first->is_dynamic_output_layout(input.second)) {return true;+ }}for (size_t i = 0; i < output_layouts.size(); ++i) {- if (output_layouts[i].is_dynamic())+ if (output_layouts[i].is_dynamic()) {return true;+ }}return false;}@@ -544,8 +583,9 @@ std::set<size_t> program_node::get_lockable_input_ids() const {const bool has_cpu_impl = get_preferred_impl_type() == impl_types::cpu || ((impl != nullptr) && impl->is_cpu());if (has_cpu_impl && !is_type<shape_of>()) {std::set<size_t> dependencies_indexes;- for (size_t i = 0; i < get_dependencies().size(); i++)+ for (size_t i = 0; i < get_dependencies().size(); i++) {dependencies_indexes.insert(i);+ }return dependencies_indexes;}@@ -556,8 +596,9 @@ std::map<size_t, memory::ptr> program_node::get_const_memory_deps() const {std::map<size_t, memory::ptr> mem_deps;for (auto& i : get_shape_infer_dependencies()) {// Some primitives may have flexible count of deps (e.g. reshape), thus allow skipping some deps- if (i >= get_dependencies().size())+ if (i >= get_dependencies().size()) {continue;+ }// exclude fused dependencyif (is_fused_dep(i)) {@@ -577,8 +618,9 @@ void program_node::invalidate_users() const {for (const auto& user : users) {for (size_t i = 0; i < user->valid_output_layouts.size(); ++i) {if (user->valid_output_layouts[i]) {- if (user->get_preferred_output_fmt() != format::any)+ if (user->get_preferred_output_fmt() != format::any) {continue;+ }user->valid_output_layouts[i] = false;user->invalidate_users();}@@ -591,30 +633,35 @@ void program_node::support_padding_all(bool support) {}bool program_node::is_padding_supported(int axis, int padding) const {- if (!support_padding(axis))+ if (!support_padding(axis)) {return false;+ }auto fmt = output_layouts[0].format;// WA for known cases of padding not supported in implementationsif (fmt == format::b_fs_yx_fsv16) {- if (axis == 0 || (axis == 1 && padding % 16 != 0))+ if (axis == 0 || (axis == 1 && padding % 16 != 0)) {return false;+ }}- if (fmt == format::fs_b_yx_fsv32 && (axis == 0))+ if (fmt == format::fs_b_yx_fsv32 && (axis == 0)) {return false;+ }auto block_sizes_dims = format::per_axis_block_size(fmt);for (const auto& block : block_sizes_dims) {size_t block_axis = block.first;int block_size = block.second;- if (axis != static_cast<int>(block_axis))+ if (axis != static_cast<int>(block_axis)) {continue;+ }- if (padding % block_size != 0)+ if (padding % block_size != 0) {return false;+ }}return true;@@ -624,10 +671,14 @@ bool program_node::is_padded_spatial(size_t idx) const {const auto& layout = get_output_layout(idx);const auto& lower_size = layout.data_padding._lower_size;const auto& upper_size = layout.data_padding._upper_size;- return std::any_of(std::begin(lower_size) + 2, std::begin(lower_size) + 2 + layout.get_spatial_rank(),- [](const tensor::value_type& el) { return el != 0; }) ||- std::any_of(std::begin(upper_size) + 2, std::begin(upper_size) + 2 + layout.get_spatial_rank(),- [](const tensor::value_type& el) { return el != 0; });+ return std::any_of(std::begin(lower_size) + 2,+ std::begin(lower_size) + 2 + layout.get_spatial_rank(),+ [](const tensor::value_type& el) {+ return el != 0;+ }) ||+ std::any_of(std::begin(upper_size) + 2, std::begin(upper_size) + 2 + layout.get_spatial_rank(), [](const tensor::value_type& el) {+ return el != 0;+ });}void program_node::set_selected_impl(std::unique_ptr<primitive_impl> impl) {@@ -649,15 +700,17 @@ void program_node::init_preferred_fmt(size_t dep_node, size_t user_node) {}void program_node::set_preferred_input_fmt(size_t idx, format::type type) {- if (idx >= preferred_input_fmts.size())- preferred_input_fmts.resize(idx+1, format::any);+ if (idx >= preferred_input_fmts.size()) {+ preferred_input_fmts.resize(idx + 1, format::any);+ }preferred_input_fmts.at(idx) = type;}void program_node::set_preferred_output_fmt(size_t idx, format::type type) {- if (idx >= preferred_output_fmts.size())- preferred_output_fmts.resize(idx+1, format::any);+ if (idx >= preferred_output_fmts.size()) {+ preferred_output_fmts.resize(idx + 1, format::any);+ }preferred_output_fmts.at(idx) = type;}@@ -827,7 +880,7 @@ void program_node::save(cldnn::BinaryOutputBuffer& ob) const {ob << fused_prim.dims;ob << make_data(&fused_prim.dt, sizeof(dnnl::memory::data_type));}-#endif // ENABLE_ONEDNN_FOR_GPU+#endif // ENABLE_ONEDNN_FOR_GPU}void program_node::load(cldnn::BinaryInputBuffer& ib) {@@ -843,7 +896,7 @@ void program_node::load(cldnn::BinaryInputBuffer& ib) {preferred_input_fmts.clear();for (size_t i = 0; i < preferred_input_fmts_size; ++i) {ib >> format_type_int;- preferred_input_fmts.push_back((format::type) format_type_int);+ preferred_input_fmts.push_back((format::type)format_type_int);}}@@ -855,7 +908,7 @@ void program_node::load(cldnn::BinaryInputBuffer& ib) {preferred_output_fmts.clear();for (size_t i = 0; i < preferred_output_fmts_size; ++i) {ib >> format_type_int;- preferred_output_fmts.push_back((format::type) format_type_int);+ preferred_output_fmts.push_back((format::type)format_type_int);}}@@ -1000,10 +1053,28 @@ void program_node::load(cldnn::BinaryInputBuffer& ib) {ib >> out_scale;ib >> out_shift;- f_desc.f_param = std::make_shared<QuantizeFuseParams>(out_layout, scale_shift_opt, need_post_scale, need_post_shift,- need_pre_shift, need_clamp, need_min_clamp, need_max_clamp, per_tensor_input_range,- per_tensor_input_scale, per_tensor_input_shift, per_tensor_output_range, per_tensor_output_scale,- per_tensor_output_shift, in_lo, in_hi, in_scale, in_shift, out_lo, out_hi, out_scale, out_shift);+ f_desc.f_param = std::make_shared<QuantizeFuseParams>(out_layout,+ scale_shift_opt,+ need_post_scale,+ need_post_shift,+ need_pre_shift,+ need_clamp,+ need_min_clamp,+ need_max_clamp,+ per_tensor_input_range,+ per_tensor_input_scale,+ per_tensor_input_shift,+ per_tensor_output_range,+ per_tensor_output_scale,+ per_tensor_output_shift,+ in_lo,+ in_hi,+ in_scale,+ in_shift,+ out_lo,+ out_hi,+ out_scale,+ out_shift);} else if (f_param_type == swiglu::type_id()) {ib >> exist_prim;std::shared_ptr<swiglu> param_desc;@@ -1050,9 +1121,8 @@ void program_node::load(cldnn::BinaryInputBuffer& ib) {ib >> input_type;ib >> idx;- auto input_desc = fused_primitive_desc::InputDescriptor{static_cast<FusedInputType>(input_type),- idx,- static_cast<ov::element::Type_t>(element_type)};+ auto input_desc =+ fused_primitive_desc::InputDescriptor{static_cast<FusedInputType>(input_type), idx, static_cast<ov::element::Type_t>(element_type)};f_desc.inputs.emplace_back(input_desc);}@@ -1077,112 +1147,101 @@ void program_node::load(cldnn::BinaryInputBuffer& ib) {if (impl_type != impl_types::onednn) {onednn_attrs = std::make_shared<dnnl::primitive_attr>();}-#endif // ENABLE_ONEDNN_FOR_GPU+#endif // ENABLE_ONEDNN_FOR_GPU}- /* ----------------------------------------- */- /* Onednn fused operations integration logic */- /* ----------------------------------------- */+/* ----------------------------------------- */+/* Onednn fused operations integration logic */+/* ----------------------------------------- */#ifdef ENABLE_ONEDNN_FOR_GPUdnnl::post_ops program_node::try_optimize_post_ops(std::vector<fused_primitive_desc_onednn>& cur_post_ops,- dnnl::post_ops& p_ops, const std::shared_ptr<dnnl::primitive_attr>& attr,- bool& optimization_is_completed) const {+ dnnl::post_ops& p_ops,+ const std::shared_ptr<dnnl::primitive_attr>& attr,+ bool& optimization_is_completed) const {// Create new dnnl::post_ops object which will be filled inside the optimization processdnnl::post_ops optimized_p_ops;// Add new post-op into optimized_p_ops structureauto add_post_op = [&](onednn_post_op_type type, const dnnl::post_ops& cur_p_ops, dnnl::post_ops& new_p_ops, int idx) {- GPU_DEBUG_TRACE << "add_post_op: " << type- << ", idx: " << idx- << ", cur_p_ops: " << cur_p_ops.len()- << ", new_p_ops: " << new_p_ops.len() << std::endl;+ GPU_DEBUG_TRACE << "add_post_op: " << type << ", idx: " << idx << ", cur_p_ops: " << cur_p_ops.len() << ", new_p_ops: " << new_p_ops.len() << std::endl;switch (type) {- case onednn_post_op_type::eltwise_act:- case onednn_post_op_type::eltwise_clip:- case onednn_post_op_type::eltwise_linear:- case onednn_post_op_type::eltwise_round:- case onednn_post_op_type::eltwise_hardsigmoid:- {- dnnl::algorithm alg;- float alpha, beta;- cur_p_ops.get_params_eltwise(idx, alg, alpha, beta);- new_p_ops.append_eltwise(alg, alpha, beta);- break;- }+ case onednn_post_op_type::eltwise_act:+ case onednn_post_op_type::eltwise_clip:+ case onednn_post_op_type::eltwise_linear:+ case onednn_post_op_type::eltwise_round:+ case onednn_post_op_type::eltwise_hardsigmoid: {+ dnnl::algorithm alg;+ float alpha, beta;+ cur_p_ops.get_params_eltwise(idx, alg, alpha, beta);+ new_p_ops.append_eltwise(alg, alpha, beta);+ break;+ }- case onednn_post_op_type::binary_add:- case onednn_post_op_type::binary_sub:- case onednn_post_op_type::binary_mul:- case onednn_post_op_type::binary_max:- case onednn_post_op_type::binary_min:- case onednn_post_op_type::binary_div:- {- dnnl::algorithm alg;- dnnl::memory::desc desc;- cur_p_ops.get_params_binary(idx, alg, desc);- new_p_ops.append_binary(alg, desc);- break;- }+ case onednn_post_op_type::binary_add:+ case onednn_post_op_type::binary_sub:+ case onednn_post_op_type::binary_mul:+ case onednn_post_op_type::binary_max:+ case onednn_post_op_type::binary_min:+ case onednn_post_op_type::binary_div: {+ dnnl::algorithm alg;+ dnnl::memory::desc desc;+ cur_p_ops.get_params_binary(idx, alg, desc);+ new_p_ops.append_binary(alg, desc);+ break;+ }- case onednn_post_op_type::binary_relu:- {- int mask;- cur_p_ops.get_params_prelu(idx, mask);- new_p_ops.append_prelu(mask);- break;- }+ case onednn_post_op_type::binary_relu: {+ int mask;+ cur_p_ops.get_params_prelu(idx, mask);+ new_p_ops.append_prelu(mask);+ break;+ }- case onednn_post_op_type::scale:- {- break;- }+ case onednn_post_op_type::scale: {+ break;+ }- case onednn_post_op_type::sum:- {- float scale;- dnnl::memory::data_type data_type;- cur_p_ops.get_params_sum(idx, scale, data_type);- // Only conv supports data type specification in append_sum. Other primitives(deconv, fc) do not support it.- if (is_type<convolution>()) {- new_p_ops.append_sum(scale, 0/*zero_point*/, data_type);- } else {- new_p_ops.append_sum(scale);- }- break;+ case onednn_post_op_type::sum: {+ float scale;+ dnnl::memory::data_type data_type;+ cur_p_ops.get_params_sum(idx, scale, data_type);+ // Only conv supports data type specification in append_sum. Other primitives(deconv, fc) do not support it.+ if (is_type<convolution>()) {+ new_p_ops.append_sum(scale, 0 /*zero_point*/, data_type);+ } else {+ new_p_ops.append_sum(scale);}+ break;+ }- case onednn_post_op_type::optimized:- case onednn_post_op_type::optimized_sum:- case onednn_post_op_type::optimized_eltwise_act:- case onednn_post_op_type::optimized_eltwise_linear:- case onednn_post_op_type::optimized_eltwise_clip:- case onednn_post_op_type::optimized_eltwise_round:- {- // Current operation already has been optimized => don't need extra actions- break;- }+ case onednn_post_op_type::optimized:+ case onednn_post_op_type::optimized_sum:+ case onednn_post_op_type::optimized_eltwise_act:+ case onednn_post_op_type::optimized_eltwise_linear:+ case onednn_post_op_type::optimized_eltwise_clip:+ case onednn_post_op_type::optimized_eltwise_round: {+ // Current operation already has been optimized => don't need extra actions+ break;+ }- default:- throw std::runtime_error("Unsupported onednn post-operation type");+ default:+ throw std::runtime_error("Unsupported onednn post-operation type");}};// Check that post-op type is any optimizedauto type_is_any_optimized = [](onednn_post_op_type type) -> bool {- return type == onednn_post_op_type::optimized ||- type == onednn_post_op_type::optimized_sum ||- type == onednn_post_op_type::optimized_eltwise_act ||- type == onednn_post_op_type::optimized_eltwise_linear ||- type == onednn_post_op_type::optimized_eltwise_clip ||+ return type == onednn_post_op_type::optimized || type == onednn_post_op_type::optimized_sum || type == onednn_post_op_type::optimized_eltwise_act ||+ type == onednn_post_op_type::optimized_eltwise_linear || type == onednn_post_op_type::optimized_eltwise_clip ||type == onednn_post_op_type::optimized_eltwise_round;};// Check that post-op type is eltwiseauto type_is_eltwise = [](onednn_post_op_type type) -> bool {- return type == onednn_post_op_type::eltwise_round || type == onednn_post_op_type::eltwise_linear ||- type == onednn_post_op_type::eltwise_clip || type == onednn_post_op_type::eltwise_act;+ return type == onednn_post_op_type::eltwise_round || type == onednn_post_op_type::eltwise_linear || type == onednn_post_op_type::eltwise_clip ||+ type == onednn_post_op_type::eltwise_act;};// Check that post-op type is binary_add or binary_mul@@ -1191,26 +1250,42 @@ dnnl::post_ops program_node::try_optimize_post_ops(std::vector<fused_primitive_d};// Simple post-op type checks- auto type_is_optimized = [](onednn_post_op_type type) -> bool { return type == onednn_post_op_type::optimized; };- auto type_is_eltwise_linear = [](onednn_post_op_type type) -> bool { return type == onednn_post_op_type::eltwise_linear; };+ auto type_is_optimized = [](onednn_post_op_type type) -> bool {+ return type == onednn_post_op_type::optimized;+ };+ auto type_is_eltwise_linear = [](onednn_post_op_type type) -> bool {+ return type == onednn_post_op_type::eltwise_linear;+ };auto type_is_optimized_eltwise = [](onednn_post_op_type type) -> bool {- return type == onednn_post_op_type::optimized_eltwise_act || type == onednn_post_op_type::optimized_eltwise_linear ||- type == onednn_post_op_type::optimized_eltwise_round || type == onednn_post_op_type::optimized_eltwise_clip;+ return type == onednn_post_op_type::optimized_eltwise_act || type == onednn_post_op_type::optimized_eltwise_linear ||+ type == onednn_post_op_type::optimized_eltwise_round || type == onednn_post_op_type::optimized_eltwise_clip;+ };+ auto type_is_binary_add = [](onednn_post_op_type type) -> bool {+ return type == onednn_post_op_type::binary_add;+ };+ auto type_is_binary_mul = [](onednn_post_op_type type) -> bool {+ return type == onednn_post_op_type::binary_mul;+ };+ auto type_is_optimized_sum = [](onednn_post_op_type type) -> bool {+ return type == onednn_post_op_type::optimized_sum;+ };+ auto type_is_scale = [](onednn_post_op_type type) -> bool {+ return type == onednn_post_op_type::scale;};- auto type_is_binary_add = [](onednn_post_op_type type) -> bool { return type == onednn_post_op_type::binary_add; };- auto type_is_binary_mul = [](onednn_post_op_type type) -> bool { return type == onednn_post_op_type::binary_mul; };- auto type_is_optimized_sum = [](onednn_post_op_type type) -> bool { return type == onednn_post_op_type::optimized_sum; };- auto type_is_scale = [](onednn_post_op_type type) -> bool { return type == onednn_post_op_type::scale; };auto get_eltwise_type = [](onednn_post_op_type type) {switch (type) {- case onednn_post_op_type::optimized_eltwise_act: return onednn_post_op_type::eltwise_act;- case onednn_post_op_type::optimized_eltwise_clip: return onednn_post_op_type::eltwise_clip;- case onednn_post_op_type::optimized_eltwise_linear: return onednn_post_op_type::eltwise_linear;- case onednn_post_op_type::optimized_eltwise_round: return onednn_post_op_type::eltwise_round;- default:- throw std::runtime_error("Unsupported optimized eltwise post-operation type");- break;+ case onednn_post_op_type::optimized_eltwise_act:+ return onednn_post_op_type::eltwise_act;+ case onednn_post_op_type::optimized_eltwise_clip:+ return onednn_post_op_type::eltwise_clip;+ case onednn_post_op_type::optimized_eltwise_linear:+ return onednn_post_op_type::eltwise_linear;+ case onednn_post_op_type::optimized_eltwise_round:+ return onednn_post_op_type::eltwise_round;+ default:+ throw std::runtime_error("Unsupported optimized eltwise post-operation type");+ break;}};@@ -1239,23 +1314,27 @@ dnnl::post_ops program_node::try_optimize_post_ops(std::vector<fused_primitive_dGPU_DEBUG_TRACE << "================================================" << std::endl;GPU_DEBUG_TRACE << " " << id() << ", num of post_ops " << p_ops.len() << std::endl;GPU_DEBUG_TRACE << " * p_ops: " << std::endl;- for (int i = 0; i < p_ops.len(); i++)+ for (int i = 0; i < p_ops.len(); i++) {GPU_DEBUG_TRACE << " " << i << ": " << static_cast<int>(p_ops.kind(i)) << std::endl;+ }GPU_DEBUG_TRACE << " * cur_post_ops: " << std::endl;- for (size_t i = 0; i < cur_post_ops.size(); i++)+ for (size_t i = 0; i < cur_post_ops.size(); i++) {GPU_DEBUG_TRACE << " " << i << ": " << cur_post_ops[i].op_type << std::endl;+ }remove_optimized_prefix(cur_post_ops);GPU_DEBUG_TRACE << "remove optimized prefix ------------------------" << std::endl;GPU_DEBUG_TRACE << " " << id() << ", num of post_ops " << p_ops.len() << std::endl;GPU_DEBUG_TRACE << " * p_ops: " << std::endl;- for (int i = 0; i < p_ops.len(); i++)+ for (int i = 0; i < p_ops.len(); i++) {GPU_DEBUG_TRACE << " " << i << ": " << static_cast<int>(p_ops.kind(i)) << std::endl;+ }GPU_DEBUG_TRACE << " * cur_post_ops: " << std::endl;- for (size_t i = 0; i < cur_post_ops.size(); i++)+ for (size_t i = 0; i < cur_post_ops.size(); i++) {GPU_DEBUG_TRACE << " " << i << ": " << cur_post_ops[i].op_type << std::endl;+ }GPU_DEBUG_TRACE << "----------------------------------->>>>>>>>>>>>>" << std::endl;// Get post-ops size for current node@@ -1263,13 +1342,17 @@ dnnl::post_ops program_node::try_optimize_post_ops(std::vector<fused_primitive_dauto get_optimized_eltwise_type = [](onednn_post_op_type type) {switch (type) {- case onednn_post_op_type::eltwise_linear: return onednn_post_op_type::optimized_eltwise_linear;- case onednn_post_op_type::eltwise_act: return onednn_post_op_type::optimized_eltwise_act;- case onednn_post_op_type::eltwise_round: return onednn_post_op_type::optimized_eltwise_round;- case onednn_post_op_type::eltwise_clip: return onednn_post_op_type::optimized_eltwise_clip;- default:- throw std::runtime_error("Unsupported optimized eltwise post-operation type");- break;+ case onednn_post_op_type::eltwise_linear:+ return onednn_post_op_type::optimized_eltwise_linear;+ case onednn_post_op_type::eltwise_act:+ return onednn_post_op_type::optimized_eltwise_act;+ case onednn_post_op_type::eltwise_round:+ return onednn_post_op_type::optimized_eltwise_round;+ case onednn_post_op_type::eltwise_clip:+ return onednn_post_op_type::optimized_eltwise_clip;+ default:+ throw std::runtime_error("Unsupported optimized eltwise post-operation type");+ break;}};@@ -1283,8 +1366,9 @@ dnnl::post_ops program_node::try_optimize_post_ops(std::vector<fused_primitive_d// Ignore optimized operations for "previous" operation in our operation pairwhile (type_is_any_optimized(prev_type) && prev_post_op_idx < post_ops_size - 1) {prev_post_op_idx++;- if (prev_post_op_idx == cur_post_op_idx && cur_post_op_idx < post_ops_size - 1)+ if (prev_post_op_idx == cur_post_op_idx && cur_post_op_idx < post_ops_size - 1) {cur_post_op_idx++;+ }prev_type = cur_post_ops[prev_post_op_idx].op_type;cur_type = cur_post_ops[cur_post_op_idx].op_type;}@@ -1315,15 +1399,12 @@ dnnl::post_ops program_node::try_optimize_post_ops(std::vector<fused_primitive_d}// Post-ops combinations which can be simplified- auto eltw_and_eltw = type_is_eltwise(cur_type) && type_is_eltwise(prev_type);- auto bin_and_eltw = type_is_binary_add_or_mul(cur_type) && type_is_eltwise_linear(prev_type);- auto eltw_and_bin = type_is_eltwise_linear(cur_type) && type_is_binary_add_or_mul(prev_type);+ auto eltw_and_eltw = type_is_eltwise(cur_type) && type_is_eltwise(prev_type);+ auto bin_and_eltw = type_is_binary_add_or_mul(cur_type) && type_is_eltwise_linear(prev_type);+ auto eltw_and_bin = type_is_eltwise_linear(cur_type) && type_is_binary_add_or_mul(prev_type);auto eltw_and_scale = type_is_eltwise_linear(cur_type) && type_is_scale(prev_type);- auto can_try_optimize = eltw_and_eltw ||- bin_and_eltw ||- eltw_and_bin ||- eltw_and_scale;+ auto can_try_optimize = eltw_and_eltw || bin_and_eltw || eltw_and_bin || eltw_and_scale;bool cur_ops_pair_is_optimized = false;@@ -1387,16 +1468,17 @@ dnnl::post_ops program_node::try_optimize_post_ops(std::vector<fused_primitive_d// Eltwise operations can use runtime non-constant data buffers, so check that memory buffers consist of constant data onlyauto bin_ops_can_be_optimized =- cur_node.is_type<data>() && cur_node.is_constant() && cur_node.get_users().size() == 1 &&- desc.get_data_type() == dnnl_f32;+ cur_node.is_type<data>() && cur_node.is_constant() && cur_node.get_users().size() == 1 && desc.get_data_type() == dnnl_f32;auto bin_add_and_eltw = alpha == 1.0f && type_is_binary_add(cur_type) && bin_ops_can_be_optimized;auto bin_mul_and_eltw = beta == 0.f && type_is_binary_mul(cur_type) && bin_ops_can_be_optimized;if (bin_add_and_eltw || bin_mul_and_eltw) {memory::ptr cur_bin_mem_ptr = cur_node.as<data>().get_attached_memory_ptr();- if (cur_bin_mem_ptr == nullptr)- throw std::runtime_error("OneDNN post-ops optimization error: nonexistent node for bin + eltw");+ if (cur_bin_mem_ptr == nullptr) {+ throw std::runtime_error("OneDNN post-ops optimization error: nonexistent "+ "node for bin + eltw");+ }// Update all binary coefficientsif (!get_program().is_loaded_from_cache()) {@@ -1431,16 +1513,17 @@ dnnl::post_ops program_node::try_optimize_post_ops(std::vector<fused_primitive_d// Eltwise operations can use runtime non-constant data buffers, so check that memory buffers consist of constant data onlyauto bin_ops_can_be_optimized =- prev_node.is_type<data>() && prev_node.is_constant() && prev_node.get_users().size() == 1 &&- desc.get_data_type() == dnnl_f32;+ prev_node.is_type<data>() && prev_node.is_constant() && prev_node.get_users().size() == 1 && desc.get_data_type() == dnnl_f32;auto eltw_and_bin_add = alpha == 1.0f && type_is_binary_add(prev_type) && bin_ops_can_be_optimized;auto eltw_and_bin_mul = beta == 0.f && type_is_binary_mul(prev_type) && bin_ops_can_be_optimized;if (eltw_and_bin_add || eltw_and_bin_mul) {memory::ptr prev_bin_mem_ptr = prev_node.as<data>().get_attached_memory_ptr();- if (prev_bin_mem_ptr == nullptr)- throw std::runtime_error("OneDNN post-ops optimization error: nonexistent node for eltw + bin");+ if (prev_bin_mem_ptr == nullptr) {+ throw std::runtime_error("OneDNN post-ops optimization error: nonexistent "+ "node for eltw + bin");+ }// Update all binary coefficientsif (!get_program().is_loaded_from_cache()) {@@ -1474,8 +1557,10 @@ dnnl::post_ops program_node::try_optimize_post_ops(std::vector<fused_primitive_d// Eltwise can be inserted into the output_scale if cur_beta is equal to 0.fif (beta == 0.f && prev_node.get_output_layout().data_type == data_types::f32) {memory::ptr prev_scale_mem_ptr = prev_node.as<data>().get_attached_memory_ptr();- if (prev_scale_mem_ptr == nullptr)- throw std::runtime_error("OneDNN post-ops optimization error: nonexistent node for eltw + scale");+ if (prev_scale_mem_ptr == nullptr) {+ throw std::runtime_error("OneDNN post-ops optimization error: nonexistent "+ "node for eltw + scale");+ }// Update all scale coefficientsif (!get_program().is_loaded_from_cache()) {@@ -1516,18 +1601,18 @@ dnnl::post_ops program_node::try_optimize_post_ops(std::vector<fused_primitive_d}GPU_DEBUG_TRACE << ">>>>>>>>>>>>>-----------------------------------" << std::endl;- for (size_t i = 0; i < cur_post_ops.size(); i++)+ for (size_t i = 0; i < cur_post_ops.size(); i++) {GPU_DEBUG_TRACE << " " << i << ": " << cur_post_ops[i].op_type << std::endl;+ }GPU_DEBUG_TRACE << "------------------------------------------------" << std::endl;return optimized_p_ops;}-void program_node::create_onednn_primitive_attributes(- const std::vector<fused_primitive_desc>& cldnn_post_ops,- std::shared_ptr<dnnl::primitive_attr>& attrs,- std::vector<fused_primitive_desc_onednn>& fused_ops,- kernel_impl_params* impl_params = nullptr) const {+void program_node::create_onednn_primitive_attributes(const std::vector<fused_primitive_desc>& cldnn_post_ops,+ std::shared_ptr<dnnl::primitive_attr>& attrs,+ std::vector<fused_primitive_desc_onednn>& fused_ops,+ kernel_impl_params* impl_params = nullptr) const {dnnl::post_ops post_ops;size_t memory_offset = 0;@@ -1535,15 +1620,15 @@ void program_node::create_onednn_primitive_attributes(size_t empty_mem = 0xff;// Change scratchpad mode to user- if (attrs->get_scratchpad_mode() == dnnl::scratchpad_mode::library)+ if (attrs->get_scratchpad_mode() == dnnl::scratchpad_mode::library) {attrs->set_scratchpad_mode(dnnl::scratchpad_mode::user);+ }const auto& get_input_layout = [&](int32_t idx) -> cldnn::layout {if (impl_params != nullptr) {return impl_params->get_input_layout(idx);}return get_dependency(idx).get_output_layout();-};const auto& get_output_layout = [&]() -> cldnn::layout {@@ -1551,33 +1636,29 @@ void program_node::create_onednn_primitive_attributes(return impl_params->get_output_layout();}return this->get_output_layout();-};// Add information about post-operation into the list, update indices- auto update_onednn_post_op_list = [&](onednn_post_op_type type, size_t m_dep,+ auto update_onednn_post_op_list = [&](onednn_post_op_type type,+ size_t m_dep,dnnl::memory::format_tag tag = dnnl::memory::format_tag::undef,bool flatten = false,dnnl::memory::dims dims = {},dnnl::memory::data_type dt = dnnl::memory::data_type::undef) {- fused_primitive_desc_onednn cur_op_desc = { type, memory_offset, m_dep, tag, flatten, dims, dt };+ fused_primitive_desc_onednn cur_op_desc = {type, memory_offset, m_dep, tag, flatten, dims, dt};fused_ops.push_back(cur_op_desc);- auto has_memory_buffers = type == onednn_post_op_type::binary_add ||- type == onednn_post_op_type::binary_sub ||- type == onednn_post_op_type::binary_mul ||- type == onednn_post_op_type::binary_max ||- type == onednn_post_op_type::binary_min ||- type == onednn_post_op_type::binary_relu ||- type == onednn_post_op_type::binary_div ||- type == onednn_post_op_type::scale ||- type == onednn_post_op_type::sum;-- if (has_memory_buffers)+ auto has_memory_buffers = type == onednn_post_op_type::binary_add || type == onednn_post_op_type::binary_sub ||+ type == onednn_post_op_type::binary_mul || type == onednn_post_op_type::binary_max ||+ type == onednn_post_op_type::binary_min || type == onednn_post_op_type::binary_relu ||+ type == onednn_post_op_type::binary_div || type == onednn_post_op_type::scale || type == onednn_post_op_type::sum;++ if (has_memory_buffers) {memory_offset++;+ }};- auto resize_layout_for_fc = [](const program_node *node, layout& in_layout) {+ 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();@@ -1591,12 +1672,12 @@ void program_node::create_onednn_primitive_attributes(const auto& desc = cldnn_post_ops[idx];if (desc.is_type<activation>()) {auto fused_desc = desc.typed_desc<activation>();- if (fused_desc->activation_function == cldnn::activation_func::relu_negative_slope- && fused_desc->additional_params_input.is_valid()) {+ if (fused_desc->activation_function == cldnn::activation_func::relu_negative_slope && fused_desc->additional_params_input.is_valid()) {auto dep_idx = desc.outer_dep_start_idx;auto prelu_mask = onednn::get_prelu_mask_from_layouts(get_output_layout, get_input_layout, dep_idx);- if (is_type<fully_connected>() && this->as<fully_connected>().get_primitive()->input_size > 2 && prelu_mask == 2)- prelu_mask = 4; // 3d fc has per_oc mask is 4+ if (is_type<fully_connected>() && this->as<fully_connected>().get_primitive()->input_size > 2 && prelu_mask == 2) {+ prelu_mask = 4; // 3d fc has per_oc mask is 4+ }post_ops.append_prelu(prelu_mask);update_onednn_post_op_list(onednn_post_op_type::binary_relu, dep_idx);} else if (fused_desc->activation_function == cldnn::activation_func::hard_sigmoid) {@@ -1605,23 +1686,29 @@ void program_node::create_onednn_primitive_attributes(} else if (fused_desc->activation_function == cldnn::activation_func::hsigmoid) {// hard_sigmoid(x,a,b) = clamp(ax+b, 0, 1)// hsigmoid(x) = clamp(val+3, 0, 6) / 6 = clamp(val/6+0.5, 0, 1) = hard_sigmoid(val, 1/6, 1/2)- post_ops.append_eltwise(dnnl::algorithm::eltwise_hardsigmoid, 1.f/6, 1.f/2);+ post_ops.append_eltwise(dnnl::algorithm::eltwise_hardsigmoid, 1.f / 6, 1.f / 2);update_onednn_post_op_list(onednn_post_op_type::eltwise_hardsigmoid, empty_mem);} else if (fused_desc->activation_function == cldnn::activation_func::negative) {post_ops.append_eltwise(dnnl::algorithm::eltwise_linear, -1, 0);update_onednn_post_op_list(onednn_post_op_type::eltwise_linear, empty_mem);} else {dnnl::algorithm alg = onednn::convert_activation_func(fused_desc->activation_function);- if (alg == dnnl::algorithm::undef)- OPENVINO_THROW("Activations that are undef algorithms must be converted to other activations before "+ if (alg == dnnl::algorithm::undef) {+ OPENVINO_THROW("Activations that are undef algorithms must "+ "be converted to other activations before ""pushing to post-op.");+ }// Usage of alpha and beta between cldnn::pow and dnnl::eltwise::pow is different : d = pow(src, a) / d = a * pow(src, b)- if (alg == dnnl::algorithm::eltwise_pow)+ if (alg == dnnl::algorithm::eltwise_pow) {post_ops.append_eltwise(alg, 1.0f, fused_desc->additional_params.a);- else if (alg == dnnl::algorithm::eltwise_hardswish) // mapping val * min(max(0, val + 3), 6) / 6 to val * max(min(1, alpha * val + beta), 0)- post_ops.append_eltwise(alg, 1/6.f, 0.5f);- else+ } else if (alg == dnnl::algorithm::eltwise_hardswish) { // mapping val * min(max(0,+ // val + 3), 6) / 6 to val *+ // max(min(1, alpha * val ++ // beta), 0)+ post_ops.append_eltwise(alg, 1 / 6.f, 0.5f);+ } else {post_ops.append_eltwise(alg, fused_desc->additional_params.a, fused_desc->additional_params.b);+ }update_onednn_post_op_list(onednn_post_op_type::eltwise_act, empty_mem);}@@ -1664,8 +1751,7 @@ void program_node::create_onednn_primitive_attributes(} else if (is_type<reduce>()) {auto mem_desc = onednn::layout_to_memory_desc_blocked(in, dnnl::memory::format_tag::undef);post_ops.append_binary(alg, mem_desc);- update_onednn_post_op_list(op_type, dep_idx, onednn::convert_data_format(in.format), false,- mem_desc.get_dims(), mem_desc.get_data_type());+ update_onednn_post_op_list(op_type, dep_idx, onednn::convert_data_format(in.format), false, mem_desc.get_dims(), mem_desc.get_data_type());} else {auto mem_desc = cldnn::format::is_blocked(get_output_layout().format)? onednn::layout_to_memory_desc_blocked(in, dnnl::memory::format_tag::undef)@@ -1679,7 +1765,7 @@ void program_node::create_onednn_primitive_attributes(auto fusing_type = onednn_add_fusing_helpers::get_add_fusing_type(*this, cldnn_post_ops[idx]);if (fusing_type == add_fusing_type::sum && num_sum_post_ops == 0) {if (is_type<convolution>()) {- post_ops.append_sum(1.0f, 0/*zero-point*/, onednn::convert_data_type(in.data_type));+ post_ops.append_sum(1.0f, 0 /*zero-point*/, onednn::convert_data_type(in.data_type));} else {post_ops.append_sum(1.0f);}@@ -1723,8 +1809,12 @@ void program_node::create_onednn_primitive_attributes(dnnl::memory::desc in_scale_desc = onednn::layout_to_memory_desc(in_scale, is_fc_or_gemm, is_output_blocked);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,- in_scale_desc.get_dims(), in_scale_desc.get_data_type());+ update_onednn_post_op_list(onednn_post_op_type::binary_mul,+ dep_idx - 1,+ onednn::get_default_data_format(in_scale),+ false,+ in_scale_desc.get_dims(),+ in_scale_desc.get_data_type());}if (q_param->_need_pre_shift) {@@ -1737,8 +1827,12 @@ void program_node::create_onednn_primitive_attributes(dnnl::memory::desc in_shift_desc = onednn::layout_to_memory_desc(in_shift, is_fc_or_gemm, is_output_blocked);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,- in_shift_desc.get_dims(), in_shift_desc.get_data_type());+ update_onednn_post_op_list(onednn_post_op_type::binary_add,+ dep_idx - 1,+ onednn::get_default_data_format(in_shift),+ false,+ in_shift_desc.get_dims(),+ in_shift_desc.get_data_type());}}}@@ -1756,8 +1850,7 @@ void program_node::create_onednn_primitive_attributes(// 3. post-scale & post-shift{- if (q_param->_need_post_scale && q_param->_need_post_shift &&- q_param->_per_tensor_output_scale && q_param->_per_tensor_output_shift) {+ if (q_param->_need_post_scale && q_param->_need_post_shift && q_param->_per_tensor_output_scale && q_param->_per_tensor_output_shift) {post_ops.append_eltwise(dnnl::algorithm::eltwise_linear, q_param->_out_scale, q_param->_out_shift);update_onednn_post_op_list(onednn_post_op_type::eltwise_linear, empty_mem);} else {@@ -1771,8 +1864,12 @@ void program_node::create_onednn_primitive_attributes(dnnl::memory::desc out_scale_desc = onednn::layout_to_memory_desc(out_scale, is_fc_or_gemm, is_output_blocked);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,- out_scale_desc.get_dims(), out_scale_desc.get_data_type());+ update_onednn_post_op_list(onednn_post_op_type::binary_mul,+ dep_idx - 1,+ onednn::get_default_data_format(out_scale),+ false,+ out_scale_desc.get_dims(),+ out_scale_desc.get_data_type());}}@@ -1785,8 +1882,12 @@ void program_node::create_onednn_primitive_attributes(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,- out_shift_desc.get_dims(), out_shift_desc.get_data_type());+ update_onednn_post_op_list(onednn_post_op_type::binary_add,+ dep_idx - 1,+ onednn::get_default_data_format(out_shift),+ false,+ out_shift_desc.get_dims(),+ out_shift_desc.get_data_type());}}}@@ -1801,7 +1902,7 @@ void program_node::create_onednn_primitive_attributes(update_onednn_post_op_list(onednn_post_op_type::eltwise_clip, empty_mem);}}- // ********************************* Rare case with input range usage ********************************* //+ // ********************************* Rare case with input range usage ********************************* //} else {// 1. clamp{@@ -1816,11 +1917,19 @@ void program_node::create_onednn_primitive_attributes(dnnl::memory::desc in_hi_desc = onednn::layout_to_memory_desc(in_hi, onednn::get_default_data_format(in_hi));post_ops.append_binary(clamp_max, in_lo_desc);- update_onednn_post_op_list(onednn_post_op_type::binary_max, dep_idx - 2, onednn::get_default_data_format(in_lo), false,- in_lo_desc.get_dims(), in_lo_desc.get_data_type());+ update_onednn_post_op_list(onednn_post_op_type::binary_max,+ dep_idx - 2,+ onednn::get_default_data_format(in_lo),+ false,+ in_lo_desc.get_dims(),+ in_lo_desc.get_data_type());post_ops.append_binary(clamp_min, in_hi_desc);- update_onednn_post_op_list(onednn_post_op_type::binary_min, dep_idx - 1, onednn::get_default_data_format(in_hi), false,- in_hi_desc.get_dims(), in_hi_desc.get_data_type());+ update_onednn_post_op_list(onednn_post_op_type::binary_min,+ dep_idx - 1,+ onednn::get_default_data_format(in_hi),+ false,+ in_hi_desc.get_dims(),+ in_hi_desc.get_data_type());}}@@ -1838,8 +1947,12 @@ void program_node::create_onednn_primitive_attributes(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,- in_scale_desc.get_dims(), in_scale_desc.get_data_type());+ update_onednn_post_op_list(onednn_post_op_type::binary_mul,+ dep_idx - 1,+ onednn::get_default_data_format(in_scale),+ false,+ in_scale_desc.get_dims(),+ in_scale_desc.get_data_type());}if (q_param->_need_pre_shift) {@@ -1851,8 +1964,12 @@ void program_node::create_onednn_primitive_attributes(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,- in_shift_desc.get_dims(), in_shift_desc.get_data_type());+ update_onednn_post_op_list(onednn_post_op_type::binary_add,+ dep_idx - 1,+ onednn::get_default_data_format(in_shift),+ false,+ in_shift_desc.get_dims(),+ in_shift_desc.get_data_type());}}}@@ -1866,8 +1983,7 @@ void program_node::create_onednn_primitive_attributes(// 4. post-scale & post-shift{- if (q_param->_need_post_scale && q_param->_need_post_shift &&- q_param->_per_tensor_output_scale && q_param->_per_tensor_output_shift) {+ if (q_param->_need_post_scale && q_param->_need_post_shift && q_param->_per_tensor_output_scale && q_param->_per_tensor_output_shift) {post_ops.append_eltwise(dnnl::algorithm::eltwise_linear, q_param->_out_scale, q_param->_out_shift);update_onednn_post_op_list(onednn_post_op_type::eltwise_linear, empty_mem);} else {@@ -1880,8 +1996,12 @@ void program_node::create_onednn_primitive_attributes(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,- out_scale_desc.get_dims(), out_scale_desc.get_data_type());+ update_onednn_post_op_list(onednn_post_op_type::binary_mul,+ dep_idx - 1,+ onednn::get_default_data_format(out_scale),+ false,+ out_scale_desc.get_dims(),+ out_scale_desc.get_data_type());}}@@ -1894,8 +2014,12 @@ void program_node::create_onednn_primitive_attributes(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,- out_shift_desc.get_dims(), out_shift_desc.get_data_type());+ update_onednn_post_op_list(onednn_post_op_type::binary_add,+ dep_idx - 1,+ onednn::get_default_data_format(out_shift),+ false,+ out_shift_desc.get_dims(),+ out_shift_desc.get_data_type());}}}@@ -1917,7 +2041,7 @@ void program_node::create_onednn_primitive_attributes(// We do it in the cycle because some optimization cases can be simplified again from time to timedo {GPU_DEBUG_IF(get_config().get_disable_onednn_post_ops_opt())- break;+ break;optimized_post_ops = try_optimize_post_ops(fused_ops, optimized_post_ops, attrs, optimization_is_finished);} while (!optimization_is_finished);@@ -1941,4 +2065,4 @@ void program_node::init_onednn_primitive_attributes() {add_onednn_fused_primitives(fused_ops);add_onednn_attrs(attrs);}-#endif // ENABLE_ONEDNN_FOR_GPU+#endif // ENABLE_ONEDNN_FOR_GPUdiff --git a/src/plugins/intel_gpu/src/graph/proposal.cpp b/src/plugins/intel_gpu/src/graph/proposal.cppindex b1dec352fa5..e543f493837 100644--- a/src/plugins/intel_gpu/src/graph/proposal.cpp+++ b/src/plugins/intel_gpu/src/graph/proposal.cpp@@ -75,8 +75,9 @@ static inline std::string stringify_vector(std::vector<float> v) {for (size_t i = 0; i < v.size(); ++i) {s << v.at(i);- if (i + 1 < v.size())+ if (i + 1 < v.size()) {s << ", ";+ }}s << " }";diff --git a/src/plugins/intel_gpu/src/graph/quantize.cpp b/src/plugins/intel_gpu/src/graph/quantize.cppindex d9555f9966e..3ce5997ec5d 100644--- a/src/plugins/intel_gpu/src/graph/quantize.cpp+++ b/src/plugins/intel_gpu/src/graph/quantize.cpp@@ -18,8 +18,9 @@ layout quantize_inst::calc_output_layout(quantize_node const& node, kernel_impl_auto input_layout = impl_param.get_input_layout();auto output_format = input_layout.format;auto out_dt = input_layout.data_type;- if (desc->output_data_types[0])+ if (desc->output_data_types[0]) {out_dt = *desc->output_data_types[0];+ }return layout{out_dt, output_format, input_layout.get_tensor()};}diff --git a/src/plugins/intel_gpu/src/graph/read_value.cpp b/src/plugins/intel_gpu/src/graph/read_value.cppindex 230823d1e0f..b4adf6bc57d 100644--- a/src/plugins/intel_gpu/src/graph/read_value.cpp+++ b/src/plugins/intel_gpu/src/graph/read_value.cpp@@ -41,8 +41,9 @@ void read_value_inst::on_execute() {void read_value_inst::release_variable() {// readvalue simply assign outputs from variablestate,// does not need to keep reference in outputs after execution- if (!can_be_optimized() || !get_network().has_variable(variable_id()))+ if (!can_be_optimized() || !get_network().has_variable(variable_id())) {return;+ }for (size_t i = 0; i < _outputs.size(); ++i) {auto& output = _outputs[i];output.reset();@@ -50,8 +51,9 @@ void read_value_inst::release_variable() {}void read_value_inst::update_output_memory() {- if (!can_be_optimized() || !get_network().has_variable(variable_id()))+ if (!can_be_optimized() || !get_network().has_variable(variable_id())) {return;+ }const auto& variable = get_network().get_variable(variable_id());GPU_DEBUG_TRACE_DETAIL << id() << " Update output memory with variable " << variable_id() << std::endl;diff --git a/src/plugins/intel_gpu/src/graph/reduce.cpp b/src/plugins/intel_gpu/src/graph/reduce.cppindex 6eae20a51d2..3cbf2e790dc 100644--- a/src/plugins/intel_gpu/src/graph/reduce.cpp+++ b/src/plugins/intel_gpu/src/graph/reduce.cpp@@ -2,14 +2,10 @@// SPDX-License-Identifier: Apache-2.0//-#include "reduce_inst.h"--#include "primitive_type_base.h"-#include "json_object.h"-#include <vector>#include <string>+#include <vector>-#include "reduce_shape_inference.hpp"+#include "json_object.h"#include "openvino/op/reduce_l1.hpp"#include "openvino/op/reduce_l2.hpp"#include "openvino/op/reduce_logical_and.hpp"@@ -19,6 +15,9 @@#include "openvino/op/reduce_min.hpp"#include "openvino/op/reduce_prod.hpp"#include "openvino/op/reduce_sum.hpp"+#include "primitive_type_base.h"+#include "reduce_inst.h"+#include "reduce_shape_inference.hpp"namespace cldnn {GPU_DEFINE_PRIMITIVE_TYPE_ID(reduce)@@ -31,8 +30,9 @@ static std::vector<uint16_t> convert_axes(std::vector<int64_t> axes, size_t rankcontinue;}- if (axis < 0)+ if (axis < 0) {axis = axis + rank;+ }converted_axes.push_back(static_cast<uint16_t>(rank + 1 - axis));}@@ -40,7 +40,7 @@ static std::vector<uint16_t> convert_axes(std::vector<int64_t> axes, size_t rankreturn converted_axes;}-layout reduce_inst::calc_output_layout(reduce_node const& node, kernel_impl_params const& impl_param) {+layout reduce_inst::calc_output_layout(const reduce_node& node, const kernel_impl_params& impl_param) {auto desc = impl_param.typed_desc<reduce>();auto input_layout = impl_param.get_input_layout();@@ -60,23 +60,28 @@ layout reduce_inst::calc_output_layout(reduce_node const& node, kernel_impl_para// Get unreduced from b-f and x-w rangefor (size_t b_f_index = 0; b_f_index < 2; b_f_index++) {bool index_to_remove = std::find(reduce_axes.begin(), reduce_axes.end(), b_f_index) != reduce_axes.end();- if (!index_to_remove)+ if (!index_to_remove) {updated_dims.push_back(in_dims[b_f_index]);+ }}for (size_t x_w_index = format_dim - 1; x_w_index >= 2; x_w_index--) {bool index_to_remove = std::find(reduce_axes.begin(), reduce_axes.end(), x_w_index) != reduce_axes.end();- if (!index_to_remove)+ if (!index_to_remove) {updated_dims.push_back(in_dims[x_w_index]);+ }}- if (input_format.dimension() == 4 && reduce_axes.size() == 1)+ if (input_format.dimension() == 4 && reduce_axes.size() == 1) {updated_dims.push_back(1);- if (updated_dims.size() > 2)+ }+ if (updated_dims.size() > 2) {std::reverse(updated_dims.begin() + 2, updated_dims.end());+ }// Fill updated dims to format_dim size- while (updated_dims.size() < format_dim)+ while (updated_dims.size() < format_dim) {updated_dims.push_back(1);+ }in_dims = std::move(updated_dims);}@@ -90,30 +95,31 @@ layout reduce_inst::calc_output_layout(reduce_node const& node, kernel_impl_para}}- if (desc->output_data_types[0])+ if (desc->output_data_types[0]) {output_type = *desc->output_data_types[0];+ }- if (impl_param.has_fused_primitives())+ if (impl_param.has_fused_primitives()) {output_type = impl_param.get_output_element_type();+ }- if (format_dim == 6)+ if (format_dim == 6) {return layout{output_type, input_format, tensor(batch(in_dims[0]), feature(in_dims[1]), spatial(in_dims[2], in_dims[3], in_dims[4], in_dims[5]))};- if (format_dim == 5)+ }+ if (format_dim == 5) {return layout{output_type, input_format, tensor(batch(in_dims[0]), feature(in_dims[1]), spatial(in_dims[2], in_dims[3], in_dims[4]))};+ }return layout{output_type, input_format, tensor(batch(in_dims[0]), feature(in_dims[1]), spatial(in_dims[2], in_dims[3]))};}-template<typename ShapeType>-std::vector<layout> reduce_inst::calc_output_layouts(reduce_node const& /*node*/, kernel_impl_params const& impl_param) {+template <typename ShapeType>+std::vector<layout> reduce_inst::calc_output_layouts(const reduce_node& /*node*/, const kernel_impl_params& impl_param) {auto desc = impl_param.typed_desc<reduce>();auto input0_layout = impl_param.get_input_layout(0);// get 'output_shapes' by shape_infer of ngraph- std::vector<ShapeType> input_shapes = {- input0_layout.get<ShapeType>(),- ShapeType{0}- };+ std::vector<ShapeType> input_shapes = {input0_layout.get<ShapeType>(), ShapeType{0}};std::vector<ShapeType> output_shapes = {ShapeType()};@@ -126,100 +132,93 @@ std::vector<layout> reduce_inst::calc_output_layouts(reduce_node const& /*node*/auto mode = desc->mode;auto keep_dims = desc->keep_dims;switch (mode) {- case reduce_mode::max:- {- ov::op::v1::ReduceMax op;- op.set_keep_dims(keep_dims);- output_shapes = shape_infer(&op, input_shapes, ta);- break;- }- case reduce_mode::min:- {- ov::op::v1::ReduceMin op;- op.set_keep_dims(keep_dims);- output_shapes = shape_infer(&op, input_shapes, ta);- break;- }- case reduce_mode::mean:- {- ov::op::v1::ReduceMean op;- op.set_keep_dims(keep_dims);- output_shapes = shape_infer(&op, input_shapes, ta);- break;- }- case reduce_mode::prod:- {- ov::op::v1::ReduceProd op;- op.set_keep_dims(keep_dims);- output_shapes = shape_infer(&op, input_shapes, ta);- break;- }- case reduce_mode::sum:- {- ov::op::v1::ReduceSum op;- op.set_keep_dims(keep_dims);- output_shapes = shape_infer(&op, input_shapes, ta);- break;- }- case reduce_mode::logical_and:- {- ov::op::v1::ReduceLogicalAnd op;- op.set_keep_dims(keep_dims);- output_shapes = shape_infer(&op, input_shapes, ta);- break;- }- case reduce_mode::logical_or:- {- ov::op::v1::ReduceLogicalOr op;- op.set_keep_dims(keep_dims);- output_shapes = shape_infer(&op, input_shapes, ta);- break;- }- case reduce_mode::l1:- {- ov::op::v4::ReduceL1 op;- op.set_keep_dims(keep_dims);- output_shapes = shape_infer(&op, input_shapes, ta);- break;- }- case reduce_mode::l2:- {- ov::op::v4::ReduceL2 op;- op.set_keep_dims(keep_dims);- output_shapes = shape_infer(&op, input_shapes, ta);- break;- }- case reduce_mode::sum_square:- // not implemented- case reduce_mode::log_sum:- // not implemented- case reduce_mode::log_sum_exp:- // not implemented- default:- OPENVINO_ASSERT(false, "Not supported reduce mode");+ case reduce_mode::max: {+ ov::op::v1::ReduceMax op;+ op.set_keep_dims(keep_dims);+ output_shapes = shape_infer(&op, input_shapes, ta);+ break;+ }+ case reduce_mode::min: {+ ov::op::v1::ReduceMin op;+ op.set_keep_dims(keep_dims);+ output_shapes = shape_infer(&op, input_shapes, ta);+ break;+ }+ case reduce_mode::mean: {+ ov::op::v1::ReduceMean op;+ op.set_keep_dims(keep_dims);+ output_shapes = shape_infer(&op, input_shapes, ta);+ break;+ }+ case reduce_mode::prod: {+ ov::op::v1::ReduceProd op;+ op.set_keep_dims(keep_dims);+ output_shapes = shape_infer(&op, input_shapes, ta);+ break;+ }+ case reduce_mode::sum: {+ ov::op::v1::ReduceSum op;+ op.set_keep_dims(keep_dims);+ output_shapes = shape_infer(&op, input_shapes, ta);+ break;+ }+ case reduce_mode::logical_and: {+ ov::op::v1::ReduceLogicalAnd op;+ op.set_keep_dims(keep_dims);+ output_shapes = shape_infer(&op, input_shapes, ta);+ break;+ }+ case reduce_mode::logical_or: {+ ov::op::v1::ReduceLogicalOr op;+ op.set_keep_dims(keep_dims);+ output_shapes = shape_infer(&op, input_shapes, ta);+ break;+ }+ case reduce_mode::l1: {+ ov::op::v4::ReduceL1 op;+ op.set_keep_dims(keep_dims);+ output_shapes = shape_infer(&op, input_shapes, ta);+ break;+ }+ case reduce_mode::l2: {+ ov::op::v4::ReduceL2 op;+ op.set_keep_dims(keep_dims);+ output_shapes = shape_infer(&op, input_shapes, ta);+ break;+ }+ case reduce_mode::sum_square:+ // not implemented+ case reduce_mode::log_sum:+ // not implemented+ case reduce_mode::log_sum_exp:+ // not implemented+ default:+ OPENVINO_ASSERT(false, "Not supported reduce mode");}auto input_type = input0_layout.data_type;auto output_type = input_type;std::vector<reduce_mode> reduce_bool_modes = {reduce_mode::logical_and, reduce_mode::logical_or};- if (std::find(reduce_bool_modes.begin(), reduce_bool_modes.end(), mode) != reduce_bool_modes.end())+ if (std::find(reduce_bool_modes.begin(), reduce_bool_modes.end(), mode) != reduce_bool_modes.end()) {output_type = data_types::i8;- else if (input_type == data_types::i8 || input_type == data_types::u8)+ } else if (input_type == data_types::i8 || input_type == data_types::u8) {output_type = data_types::f32;+ }output_type = desc->output_data_types[0].value_or(output_type);- if (impl_param.has_fused_primitives())+ if (impl_param.has_fused_primitives()) {output_type = impl_param.get_output_element_type();+ }auto output_format = format::adjust_to_rank(input0_layout.format, output_shapes[0].size());- return { layout{output_shapes[0], output_type, output_format} };+ return {layout{output_shapes[0], output_type, output_format}};}-template std::vector<layout> reduce_inst::calc_output_layouts<ov::PartialShape>(reduce_node const& node, const kernel_impl_params& impl_param);+template std::vector<layout> reduce_inst::calc_output_layouts<ov::PartialShape>(const reduce_node& node, const kernel_impl_params& impl_param);-std::string reduce_inst::to_string(reduce_node const& node) {+std::string reduce_inst::to_string(const reduce_node& node) {auto desc = node.get_primitive();auto node_info = node.desc_to_json();@@ -237,6 +236,6 @@ std::string reduce_inst::to_string(reduce_node const& node) {return primitive_description.str();}-reduce_inst::typed_primitive_inst(network& network, reduce_node const& node) : parent(network, node) {}+reduce_inst::typed_primitive_inst(network& network, const reduce_node& node) : parent(network, node) {}} // namespace cldnndiff --git a/src/plugins/intel_gpu/src/graph/registry/implementation_manager.cpp b/src/plugins/intel_gpu/src/graph/registry/implementation_manager.cppindex 5360f164740..0f9090dc27d 100644--- a/src/plugins/intel_gpu/src/graph/registry/implementation_manager.cpp+++ b/src/plugins/intel_gpu/src/graph/registry/implementation_manager.cpp@@ -40,8 +40,9 @@ shape_types ImplementationManager::get_shape_type(const program_node& node) {bool ImplementationManager::is_supported(const program_node& node, const std::set<key_type>& supported_keys, shape_types supported_shape_type) {auto key_in = implementation_key()(!node.get_dependencies().empty() ? node.get_input_layout(0) : layout{ov::PartialShape{}, data_types::f32, format::any});- if (!supported_keys.empty() && supported_keys.find(key_in) == supported_keys.end())+ if (!supported_keys.empty() && supported_keys.find(key_in) == supported_keys.end()) {return false;+ }// calc_output_layouts() if layout is not valid looks redundant, but some tests fail w/o it due to// layout invalidation on get_input_layout() calldiff --git a/src/plugins/intel_gpu/src/graph/registry/implementation_manager.hpp b/src/plugins/intel_gpu/src/graph/registry/implementation_manager.hppindex f5134123622..f9a0d6a958d 100644--- a/src/plugins/intel_gpu/src/graph/registry/implementation_manager.hpp+++ b/src/plugins/intel_gpu/src/graph/registry/implementation_manager.hpp@@ -43,8 +43,9 @@ public:std::unique_ptr<primitive_impl> create(const program_node& node, const kernel_impl_params& params) const;std::unique_ptr<primitive_impl> create(const kernel_impl_params& params) const;bool validate(const program_node& node) const {- if (!validate_impl(node))+ if (!validate_impl(node)) {return false;+ }if (m_vf) {return m_vf(node);}diff --git a/src/plugins/intel_gpu/src/graph/registry/implementation_map.hpp b/src/plugins/intel_gpu/src/graph/registry/implementation_map.hppindex 00d5f9cb1d7..b83be1b0c4b 100644--- a/src/plugins/intel_gpu/src/graph/registry/implementation_map.hpp+++ b/src/plugins/intel_gpu/src/graph/registry/implementation_map.hpp@@ -41,12 +41,14 @@ public:const auto& l = list_type::instance();for (auto& entry : l) {impl_types impl_type = std::get<0>(entry);- if ((preferred_impl_type & impl_type) != impl_type)+ if ((preferred_impl_type & impl_type) != impl_type) {continue;+ }shape_types supported_shape_type = std::get<1>(entry);- if ((target_shape_type & supported_shape_type) != target_shape_type)+ if ((target_shape_type & supported_shape_type) != target_shape_type) {continue;+ }return std::get<2>(entry);}diff --git a/src/plugins/intel_gpu/src/graph/reorder.cpp b/src/plugins/intel_gpu/src/graph/reorder.cppindex 567b3a69f9e..ac131e7fac7 100644--- a/src/plugins/intel_gpu/src/graph/reorder.cpp+++ b/src/plugins/intel_gpu/src/graph/reorder.cpp@@ -35,16 +35,19 @@ layout reorder_inst::calc_output_layout(reorder_node const& node, kernel_impl_paauto out_shape = input_layout.get_partial_shape();out_shape[c_dim] = 3;- if (desc->input_size() == 1)+ if (desc->input_size() == 1) {out_shape[h_dim] = out_shape[h_dim] * 2 / 3;+ }- if (ofmt != ifmt)+ if (ofmt != ifmt) {return layout(out_shape, odt, ofmt, op);+ }CLDNN_ERROR_MESSAGE(desc->id, "No image_nv12 to image_nv12 reorder is supported");} else if (ofmt.is_winograd() && ifmt.is_winograd()) {- if (ofmt == ifmt)+ if (ofmt == ifmt) {return layout(odt, ofmt, input_layout.get_tensor(), op);+ }CLDNN_ERROR_MESSAGE(desc->id, "Reordering between winograd weights and data formats is unsupported");} else if (ifmt == format::image_2d_rgba) {@@ -137,8 +140,9 @@ layout reorder_inst::calc_output_layout(reorder_node const& node, kernel_impl_pa// computations of output tile (for given filter size and stride)auto output_width = input_layout.spatial(0) / input_tile_width * output_tile_width;- if (input_layout.spatial(0) % input_tile_width != 0) // leftovers+ if (input_layout.spatial(0) % input_tile_width != 0) { // leftovers++output_width; // output tile is 2 by default, so we can have only 1 value as leftover+ }return layout(odt,ofmt,@@ -231,8 +235,9 @@ reorder_inst::typed_primitive_inst(network& network, reorder_node const& node) :, _req_reinterpr(node.requires_reinterpret()) {update_output_memory();- if (is_dynamic())+ if (is_dynamic()) {return;+ }auto input_layout = node.get_input_layout();auto output_layout = node.get_output_layout();@@ -269,22 +274,26 @@ void reorder_inst::on_execute() {}void reorder_inst::update_output_memory() {- if (!can_be_optimized())+ if (!can_be_optimized()) {return;+ }if (static_cast<bool>(_outputs[0])&& _network.get_engine().is_the_same_buffer(output_memory(), input_memory())- && output_memory().get_layout().identical(get_output_layout()))+ && output_memory().get_layout().identical(get_output_layout())) {return;+ }- if (_node != nullptr)+ if (_node != nullptr) {build_deps();+ }// Do not update output memory when reorder is optimized out// but input memory is not allocated yet because input is dynamic.// Since dep's _outputs may be empty, Check whether input memory is null by dep's outputs_allocated()- if (!dependencies().front().first->outputs_allocated())+ if (!dependencies().front().first->outputs_allocated()) {return;+ }GPU_DEBUG_TRACE_DETAIL << id() << " : update_output_memory with mem of input " << get_node().get_dependency(0).id()<< " : " << input_memory_ptr()->buffer_ptr() << std::endl;diff --git a/src/plugins/intel_gpu/src/graph/resample.cpp b/src/plugins/intel_gpu/src/graph/resample.cppindex 9e158403ae8..dad81a8c04f 100644--- a/src/plugins/intel_gpu/src/graph/resample.cpp+++ b/src/plugins/intel_gpu/src/graph/resample.cpp@@ -17,19 +17,23 @@ namespace {void rebind_onednn_reuse_optimized_dst_if_needed(primitive_inst& inst) {auto output = inst.output_memory_ptr();- if (!output)+ if (!output) {return;+ }auto& engine = inst.get_network().get_engine();for (auto* user_inst : inst.get_user_insts()) {auto reused_eltwmem_idx = onednn_add_fusing_helpers::get_reused_eltwmem_idx(user_inst->get_node());- if (reused_eltwmem_idx < 0)+ if (reused_eltwmem_idx < 0) {continue;+ }- if (user_inst->dependencies().at(reused_eltwmem_idx).first != &inst)+ if (user_inst->dependencies().at(reused_eltwmem_idx).first != &inst) {continue;- if (engine.is_the_same_buffer(*user_inst->output_memory_ptr(), *output))+ }+ if (engine.is_the_same_buffer(*user_inst->output_memory_ptr(), *output)) {continue;+ }auto new_mem = engine.reinterpret_buffer(*output, user_inst->get_output_layout());user_inst->set_output_memory(new_mem, false);}@@ -37,27 +41,26 @@ void rebind_onednn_reuse_optimized_dst_if_needed(primitive_inst& inst) {} // namespace-layout resample_inst::calc_output_layout(resample_node const& node, kernel_impl_params const& impl_param) {+layout resample_inst::calc_output_layout(const resample_node& node, const kernel_impl_params& impl_param) {auto desc = impl_param.typed_desc<resample>();auto input_layout = impl_param.get_input_layout();auto output_type = input_layout.data_type;- if ((input_layout.data_type == data_types::i8 || input_layout.data_type == data_types::u8)- && desc->operation_type != resample::InterpolateOp::InterpolateMode::NEAREST- && desc->operation_type != resample::InterpolateOp::InterpolateMode::LINEAR_ONNX) {+ if ((input_layout.data_type == data_types::i8 || input_layout.data_type == data_types::u8) &&+ desc->operation_type != resample::InterpolateOp::InterpolateMode::NEAREST &&+ desc->operation_type != resample::InterpolateOp::InterpolateMode::LINEAR_ONNX) {output_type = data_types::f32;}if (impl_param.has_fused_primitives()) {output_type = impl_param.get_output_element_type();}- return desc->sizes.empty() ? layout({output_type, input_layout.format, desc->output_size}) :- layout({desc->sizes, output_type, input_layout.format});+ return desc->sizes.empty() ? layout({output_type, input_layout.format, desc->output_size}) : layout({desc->sizes, output_type, input_layout.format});}namespace v4 {-template<typename ShapeType>-static std::vector<layout> calc_output_layouts(resample_node const& /*node*/, const kernel_impl_params& impl_param) {+template <typename ShapeType>+static std::vector<layout> calc_output_layouts(const resample_node& /*node*/, const kernel_impl_params& impl_param) {auto desc = impl_param.typed_desc<resample>();auto input_layout = impl_param.get_input_layout(0);auto input_shape = input_layout.get<ShapeType>();@@ -66,8 +69,7 @@ static std::vector<layout> calc_output_layouts(resample_node const& /*node*/, coov::op::v4::Interpolate op;op.set_attrs(desc->get_attrs());- ShapeType sizes_shape = desc->sizes.empty() ? ov::Shape{ input_rank }- : ov::Shape{ desc->sizes.size() };+ ShapeType sizes_shape = desc->sizes.empty() ? ov::Shape{input_rank} : ov::Shape{desc->sizes.size()};ShapeType scales_shape = desc->scales.empty() ? ov::Shape{input_rank} : ov::Shape{desc->scales.size()};std::vector<ShapeType> input_shapes = {input_shape, sizes_shape, scales_shape};@@ -102,13 +104,13 @@ static std::vector<layout> calc_output_layouts(resample_node const& /*node*/, cooutput_type = impl_param.get_output_element_type();}- return { layout{output_shapes[0], output_type, format::adjust_to_rank(input_layout.format, output_shapes[0].size())} };+ return {layout{output_shapes[0], output_type, format::adjust_to_rank(input_layout.format, output_shapes[0].size())}};}-} // namespace v4+} // namespace v4namespace v11 {-template<typename ShapeType>-static std::vector<layout> calc_output_layouts(resample_node const& /*node*/, const kernel_impl_params& impl_param) {+template <typename ShapeType>+static std::vector<layout> calc_output_layouts(const resample_node& /*node*/, const kernel_impl_params& impl_param) {auto desc = impl_param.typed_desc<resample>();auto input_layout = impl_param.get_input_layout(0);auto input_shape = input_layout.get<ShapeType>();@@ -119,11 +121,11 @@ static std::vector<layout> calc_output_layouts(resample_node const& /*node*/, coShapeType sizes_or_scales_shape;if (!desc->sizes.empty()) {- sizes_or_scales_shape = ov::Shape{ desc->sizes.size() };+ sizes_or_scales_shape = ov::Shape{desc->sizes.size()};} else if (!desc->scales.empty()) {- sizes_or_scales_shape = ov::Shape{ desc->scales.size() };+ sizes_or_scales_shape = ov::Shape{desc->scales.size()};} else {- sizes_or_scales_shape = ov::Shape{ input_rank };+ sizes_or_scales_shape = ov::Shape{input_rank};}std::vector<ShapeType> input_shapes = {input_shape, sizes_or_scales_shape};@@ -153,43 +155,46 @@ static std::vector<layout> calc_output_layouts(resample_node const& /*node*/, coif (impl_param.has_fused_primitives()) {output_type = impl_param.get_output_element_type();}- return { layout{output_shapes[0], output_type, format::adjust_to_rank(input_layout.format, output_shapes[0].size())} };+ return {layout{output_shapes[0], output_type, format::adjust_to_rank(input_layout.format, output_shapes[0].size())}};}-} // namespace v11+} // namespace v11-template<typename ShapeType>-std::vector<layout> resample_inst::calc_output_layouts(resample_node const& node, const kernel_impl_params& impl_param) {+template <typename ShapeType>+std::vector<layout> resample_inst::calc_output_layouts(const resample_node& node, const kernel_impl_params& impl_param) {using Mode = ov::op::util::InterpolateBase::InterpolateMode;auto desc = impl_param.typed_desc<resample>();- if (desc->operation_type == Mode::BILINEAR_PILLOW || desc->operation_type == Mode::BICUBIC_PILLOW)+ if (desc->operation_type == Mode::BILINEAR_PILLOW || desc->operation_type == Mode::BICUBIC_PILLOW) {return v11::calc_output_layouts<ShapeType>(node, impl_param);+ }return v4::calc_output_layouts<ShapeType>(node, impl_param);}-template std::vector<layout> resample_inst::calc_output_layouts<ov::PartialShape>(resample_node const& node, const kernel_impl_params& impl_param);+template std::vector<layout> resample_inst::calc_output_layouts<ov::PartialShape>(const resample_node& node, const kernel_impl_params& impl_param);-std::string resample_inst::to_string(resample_node const& node) {+std::string resample_inst::to_string(const resample_node& node) {auto desc = node.get_primitive();auto node_info = node.desc_to_json();std::stringstream primitive_description;json_composite resample_info;- if (desc->operation_type == resample::InterpolateOp::InterpolateMode::NEAREST)+ if (desc->operation_type == resample::InterpolateOp::InterpolateMode::NEAREST) {resample_info.add("resample_type:", "nearest_neighbor");- else if (desc->operation_type == resample::InterpolateOp::InterpolateMode::LINEAR)+ } else if (desc->operation_type == resample::InterpolateOp::InterpolateMode::LINEAR) {resample_info.add("resample_type:", "caffe_bilinear_interp");- else if (desc->operation_type == resample::InterpolateOp::InterpolateMode::CUBIC)+ } else if (desc->operation_type == resample::InterpolateOp::InterpolateMode::CUBIC) {resample_info.add("resample_type:", "cubic");- else if (desc->operation_type == resample::InterpolateOp::InterpolateMode::LINEAR_ONNX)+ } else if (desc->operation_type == resample::InterpolateOp::InterpolateMode::LINEAR_ONNX) {resample_info.add("resample_type:", "linear_onnx");- else+ } else {resample_info.add("resample_type:", "not supported sample type");+ }- if (desc->shape_calc_mode == resample::InterpolateOp::ShapeCalcMode::SIZES)+ if (desc->shape_calc_mode == resample::InterpolateOp::ShapeCalcMode::SIZES) {resample_info.add("shape_calculation_mode:", "sizes");- else+ } else {resample_info.add("shape_calculation_mode:", "scales");+ }if (desc->shape_calc_mode == resample::InterpolateOp::ShapeCalcMode::SCALES) {std::string axesAndScalesDump;@@ -198,39 +203,45 @@ std::string resample_inst::to_string(resample_node const& node) {axesAndScalesDump += delim;delim = ", ";axesAndScalesDump += std::to_string(desc->axes[i]) + ": ";- if (desc->scales.size() > i)+ if (desc->scales.size() > i) {axesAndScalesDump += std::to_string(desc->scales[i]);+ }}resample_info.add("scales:", axesAndScalesDump);}- if (desc->coord_trans_mode == resample::InterpolateOp::CoordinateTransformMode::HALF_PIXEL)+ if (desc->coord_trans_mode == resample::InterpolateOp::CoordinateTransformMode::HALF_PIXEL) {resample_info.add("coordinate_transformation_mode:", "half_pixel");- else if (desc->coord_trans_mode == resample::InterpolateOp::CoordinateTransformMode::PYTORCH_HALF_PIXEL)+ } else if (desc->coord_trans_mode == resample::InterpolateOp::CoordinateTransformMode::PYTORCH_HALF_PIXEL) {resample_info.add("coordinate_transformation_mode:", "pytorch_half_pixel");- else if (desc->coord_trans_mode == resample::InterpolateOp::CoordinateTransformMode::TF_HALF_PIXEL_FOR_NN)+ } else if (desc->coord_trans_mode == resample::InterpolateOp::CoordinateTransformMode::TF_HALF_PIXEL_FOR_NN) {resample_info.add("coordinate_transformation_mode:", "tf_half_pixel_for_nn");- else if (desc->coord_trans_mode == resample::InterpolateOp::CoordinateTransformMode::ALIGN_CORNERS)+ } else if (desc->coord_trans_mode == resample::InterpolateOp::CoordinateTransformMode::ALIGN_CORNERS) {resample_info.add("coordinate_transformation_mode:", "align_corners");- else+ } else {resample_info.add("coordinate_transformation_mode:", "asymmetric");+ }- if (desc->round_mode == resample::InterpolateOp::NearestMode::ROUND_PREFER_FLOOR)+ if (desc->round_mode == resample::InterpolateOp::NearestMode::ROUND_PREFER_FLOOR) {resample_info.add("nearest_mode:", "round_prefer_floor");- if (desc->round_mode == resample::InterpolateOp::NearestMode::ROUND_PREFER_CEIL)+ }+ if (desc->round_mode == resample::InterpolateOp::NearestMode::ROUND_PREFER_CEIL) {resample_info.add("nearest_mode:", "round_prefer_ceil");- if (desc->round_mode == resample::InterpolateOp::NearestMode::FLOOR)+ }+ if (desc->round_mode == resample::InterpolateOp::NearestMode::FLOOR) {resample_info.add("nearest_mode:", "floor");- if (desc->round_mode == resample::InterpolateOp::NearestMode::CEIL)+ }+ if (desc->round_mode == resample::InterpolateOp::NearestMode::CEIL) {resample_info.add("nearest_mode:", "ceil");- else+ } else {resample_info.add("nearest_mode:", "simple");+ }resample_info.add("output_size", desc->output_size);- resample_info.add("output padding lower size", std::vector<tensor::value_type>(desc->output_paddings[0]._lower_size.begin(),- desc->output_paddings[0]._lower_size.end()));- resample_info.add("output padding upper size", std::vector<tensor::value_type>(desc->output_paddings[0]._upper_size.begin(),- desc->output_paddings[0]._upper_size.end()));+ resample_info.add("output padding lower size",+ std::vector<tensor::value_type>(desc->output_paddings[0]._lower_size.begin(), desc->output_paddings[0]._lower_size.end()));+ resample_info.add("output padding upper size",+ std::vector<tensor::value_type>(desc->output_paddings[0]._upper_size.begin(), desc->output_paddings[0]._upper_size.end()));node_info->add("resample_info", resample_info);node_info->dump(primitive_description);@@ -238,21 +249,22 @@ std::string resample_inst::to_string(resample_node const& node) {return primitive_description.str();}-resample_inst::typed_primitive_inst(network& network, resample_node const& node) : parent(network, node) {-}+resample_inst::typed_primitive_inst(network& network, const resample_node& node) : parent(network, node) {}void resample_inst::on_execute() {update_output_memory();}void resample_inst::update_output_memory() {- if (!can_be_optimized() || _impl_params->is_dynamic())+ if (!can_be_optimized() || _impl_params->is_dynamic()) {return;+ }build_deps();- if (input_memory_ptr() == nullptr)+ if (input_memory_ptr() == nullptr) {return;+ }// compile time: resample's input/output memory is not the same// runtime : resample's input/output memory should be the same (case 1),@@ -265,8 +277,7 @@ void resample_inst::update_output_memory() {// Can_be_optimized nodes are allocating from memory_pool too. In this case,// we need release the legacy output memory from memory pool explicitly.- if (static_cast<bool>(_outputs[0]) &&- get_node().get_program().get_config().get_enable_memory_pool()) {+ if (static_cast<bool>(_outputs[0]) && get_node().get_program().get_config().get_enable_memory_pool()) {get_network().get_memory_pool().release_memory(_outputs[0].get(), get_node().get_unique_id(), get_node().id(), get_network_id());}_outputs[0] = _network.get_engine().reinterpret_buffer(input_memory(), _impl_params->get_output_layout());diff --git a/src/plugins/intel_gpu/src/graph/reshape.cpp b/src/plugins/intel_gpu/src/graph/reshape.cppindex c497f3a4edf..ab0af932e14 100644--- a/src/plugins/intel_gpu/src/graph/reshape.cpp+++ b/src/plugins/intel_gpu/src/graph/reshape.cpp@@ -20,8 +20,9 @@ namespace cldnn {GPU_DEFINE_PRIMITIVE_TYPE_ID(reshape)padding propagate_padding(const layout& in_layout, const ov::PartialShape& out_shape, reshape::reshape_mode mode, const ov::ITensorAccessor& ta) {- if (mode == reshape::reshape_mode::base)+ if (mode == reshape::reshape_mode::base) {return padding();+ }auto in_pad = in_layout.data_padding;if (!in_pad.is_dynamic()) {@@ -92,8 +93,9 @@ padding propagate_padding(const layout& in_layout, const ov::PartialShape& out_s// If we have a non-squeezable case (pad along removed axis), then out padding is reset// and kernel must be executedauto rm_axis = *rm_iter;- if (pad_lower[rm_axis] != 0 || pad_upper[rm_axis] != 0 || pad_mask[rm_axis] != 0 )+ if (pad_lower[rm_axis] != 0 || pad_upper[rm_axis] != 0 || pad_mask[rm_axis] != 0 ) {return padding();+ }}}}@@ -136,8 +138,9 @@ layout reshape_inst::calc_output_layout(reshape_node const& node, kernel_impl_pa}shape_count *= sizes[i];}- if (need_recalc)+ if (need_recalc) {sizes[need_recalc] = static_cast<int64_t>(input_layout.count()) / shape_count;+ }return layout{input_layout.data_type, input_layout.format, tensor(sizes)};}@@ -238,12 +241,14 @@ std::vector<layout> reshape_inst::calc_output_layouts(reshape_node const& node,std::unordered_map<size_t, size_t> countMap1, countMap2;for (auto num : vec1) {- if (num != 1)+ if (num != 1) {countMap1[num]++;+ }}for (auto num : vec2) {- if (num != 1)+ if (num != 1) {countMap2[num]++;+ }}return countMap1 == countMap2;@@ -252,14 +257,16 @@ std::vector<layout> reshape_inst::calc_output_layouts(reshape_node const& node,auto candidate_layout = layout {output_shapes[0], input_layout.data_type, format::adjust_to_rank(output_format, output_shapes[0].size()), out_pad};if ((!node.is_dynamic()) && areVectorsCompatible(impl_param.get_output_layout().get_shape(), output_shapes[0].get_shape())) {if (impl_param.get_output_layout().format != output_format && !candidate_layout.compatible(input_layout)) {- if (!impl_param.get_output_layout(false).compatible(candidate_layout))+ if (!impl_param.get_output_layout(false).compatible(candidate_layout)) {output_format = impl_param.get_output_layout().format;+ }}}auto new_out_pad = out_pad;- if (new_out_pad == padding())+ if (new_out_pad == padding()) {new_out_pad = impl_param.get_output_layout(0).data_padding;+ }return { layout {output_shapes[0], input_layout.data_type, format::adjust_to_rank(output_format, output_shapes[0].size()), new_out_pad} };}@@ -297,13 +304,14 @@ reshape_inst::typed_primitive_inst(network& network, reshape_node const& node) :"output layout data type",output_layout.data_type,"");- if (output_layout.is_static() && input_layout.is_static())+ if (output_layout.is_static() && input_layout.is_static()) {CLDNN_ERROR_NOT_EQUAL(node.id(),"Output layout count",output_layout.count(),"input layout count",input_layout.count(),"Output layout of reshape primitive changes size of input buffer");+ }// if reshape operated in-place, postpone creation of the output until network run,// then create new memory object as the reinterpreted output of the previous primitive@@ -315,8 +323,9 @@ reshape_inst::typed_primitive_inst(network& network, reshape_node const& node) :update_output_memory();}} else {- if (!_exec_deps.empty() && input_memory_ptr())+ if (!_exec_deps.empty() && input_memory_ptr()) {update_output_memory();+ }}}@@ -325,16 +334,19 @@ void reshape_inst::on_execute() {}void reshape_inst::update_output_memory() {- if (!can_be_optimized())+ if (!can_be_optimized()) {return;+ }if (_outputs[0] && _network.get_engine().is_the_same_buffer(output_memory(), input_memory()) &&- output_memory().get_layout() == _impl_params->get_output_layout())+ output_memory().get_layout() == _impl_params->get_output_layout()) {return;+ }build_deps(); // reshape need deps- if (input_memory_ptr() == nullptr)+ if (input_memory_ptr() == nullptr) {return;+ }// Can_be_optimized nodes are allocating from memory_pool too. In this case,// we need release the legacy output memory from memory pool explicitly.diff --git a/src/plugins/intel_gpu/src/graph/scaled_dot_product_attention.cpp b/src/plugins/intel_gpu/src/graph/scaled_dot_product_attention.cppindex 461a49ecc12..1c60cceef3f 100644--- a/src/plugins/intel_gpu/src/graph/scaled_dot_product_attention.cpp+++ b/src/plugins/intel_gpu/src/graph/scaled_dot_product_attention.cpp@@ -20,8 +20,9 @@ layout scaled_dot_product_attention_inst::calc_output_layout(scaled_dot_product_kernel_impl_params const& impl_param) {auto desc = impl_param.typed_desc<scaled_dot_product_attention>();auto transpose_shape = [](const ov::PartialShape& shape, const std::vector<int64_t>& order) {- if (order.empty())+ if (order.empty()) {return shape;+ }auto shape_transposed = ov::PartialShape(shape);auto rank_diff = shape.size() - order.size();diff --git a/src/plugins/intel_gpu/src/graph/scatter_elements_update.cpp b/src/plugins/intel_gpu/src/graph/scatter_elements_update.cppindex f9532a4f940..8abc976751f 100644--- a/src/plugins/intel_gpu/src/graph/scatter_elements_update.cpp+++ b/src/plugins/intel_gpu/src/graph/scatter_elements_update.cpp@@ -30,8 +30,9 @@ layout scatter_elements_update_inst::calc_output_layout(scatter_elements_update_output_type = impl_param.get_output_element_type();}- if (axis < 0 || axis >= input_number_of_dims)+ if (axis < 0 || axis >= input_number_of_dims) {CLDNN_ERROR_MESSAGE(desc->id, "Incorrect axis value for ScatterElementsUpdate: Axis must be positive and less than the input tensor dimension.");+ }return layout{output_shape, output_type, input_format};}@@ -62,17 +63,20 @@ void scatter_elements_update_inst::on_execute() {}void scatter_elements_update_inst::update_output_memory() {- if (!can_be_optimized() || _impl_params->is_dynamic())+ if (!can_be_optimized() || _impl_params->is_dynamic()) {return;+ }if (!_outputs.empty() && static_cast<bool>(_outputs[0])- && _network.get_engine().is_the_same_buffer(output_memory(), input_memory()))+ && _network.get_engine().is_the_same_buffer(output_memory(), input_memory())) {return;+ }build_deps();- if (input_memory_ptr() == nullptr)+ if (input_memory_ptr() == nullptr) {return;+ }// Can_be_optimized nodes are allocating from memory_pool too. In this case,// we need release the legacy output memory from memory pool explicitly.diff --git a/src/plugins/intel_gpu/src/graph/scatter_nd_update.cpp b/src/plugins/intel_gpu/src/graph/scatter_nd_update.cppindex 5d2925a9aa1..a3b5486219d 100644--- a/src/plugins/intel_gpu/src/graph/scatter_nd_update.cpp+++ b/src/plugins/intel_gpu/src/graph/scatter_nd_update.cpp@@ -74,17 +74,20 @@ void scatter_nd_update_inst::on_execute() {}void scatter_nd_update_inst::update_output_memory() {- if (!can_be_optimized() || _impl_params->is_dynamic())+ if (!can_be_optimized() || _impl_params->is_dynamic()) {return;+ }if (!_outputs.empty() && static_cast<bool>(_outputs[0])- && _network.get_engine().is_the_same_buffer(output_memory(), input_memory()))+ && _network.get_engine().is_the_same_buffer(output_memory(), input_memory())) {return;+ }build_deps();- if (input_memory_ptr() == nullptr)+ if (input_memory_ptr() == nullptr) {return;+ }// Can_be_optimized nodes are allocating from memory_pool too. In this case,// we need release the legacy output memory from memory pool explicitly.diff --git a/src/plugins/intel_gpu/src/graph/scatter_update.cpp b/src/plugins/intel_gpu/src/graph/scatter_update.cppindex dc92e3e72b6..7eeb97e4296 100644--- a/src/plugins/intel_gpu/src/graph/scatter_update.cpp+++ b/src/plugins/intel_gpu/src/graph/scatter_update.cpp@@ -53,18 +53,22 @@ void scatter_update_inst::on_execute() {}void scatter_update_inst::update_output_memory() {- if (!can_be_optimized() || _impl_params->is_dynamic())+ if (!can_be_optimized() || _impl_params->is_dynamic()) {return;+ }if (!_outputs.empty() && static_cast<bool>(_outputs[0])- && _network.get_engine().is_the_same_buffer(output_memory(), input_memory()))+ && _network.get_engine().is_the_same_buffer(output_memory(), input_memory())) {return;+ }- if (_node != nullptr)+ if (_node != nullptr) {build_deps();+ }- if (input_memory_ptr() == nullptr)+ if (input_memory_ptr() == nullptr) {return;+ }// Can_be_optimized nodes are allocating from memory_pool too. In this case,// we need release the legacy output memory from memory pool explicitly.diff --git a/src/plugins/intel_gpu/src/graph/select.cpp b/src/plugins/intel_gpu/src/graph/select.cppindex 5e1b35fc04b..4eb0c6bd4ed 100644--- a/src/plugins/intel_gpu/src/graph/select.cpp+++ b/src/plugins/intel_gpu/src/graph/select.cpp@@ -85,8 +85,9 @@ select_inst::typed_primitive_inst(network& network, select_node const& node) : pif (dep0_out_layout.is_dynamic() ||dep1_out_layout.is_dynamic() ||- dep2_out_layout.is_dynamic())+ dep2_out_layout.is_dynamic()) {return;+ }CLDNN_ERROR_LESS_THAN(node.id(),"Number of inputs",diff --git a/src/plugins/intel_gpu/src/graph/shape_of.cpp b/src/plugins/intel_gpu/src/graph/shape_of.cppindex 3651fc2b202..1cb8f54a5fd 100644--- a/src/plugins/intel_gpu/src/graph/shape_of.cpp+++ b/src/plugins/intel_gpu/src/graph/shape_of.cpp@@ -50,8 +50,9 @@ std::string shape_of_inst::to_string(shape_of_node const& node) {std::stringstream primitive_description;json_composite shape_of_info;- if (desc->output_data_types[0].has_value())+ if (desc->output_data_types[0].has_value()) {shape_of_info.add("out dt: ", dt_to_str(*desc->output_data_types[0]));+ }node_info->add("shape_of info", shape_of_info);node_info->dump(primitive_description);diff --git a/src/plugins/intel_gpu/src/graph/shuffle_channels.cpp b/src/plugins/intel_gpu/src/graph/shuffle_channels.cppindex 0407dacdb07..a1b7c6a2ef4 100644--- a/src/plugins/intel_gpu/src/graph/shuffle_channels.cpp+++ b/src/plugins/intel_gpu/src/graph/shuffle_channels.cpp@@ -22,21 +22,25 @@ layout shuffle_channels_inst::calc_output_layout(shuffle_channels_node const& noconst int32_t group = desc->group;int32_t axis = desc->axis;- if (axis < 0)+ if (axis < 0) {axis += number_of_dims;+ }- if (axis < 0 || axis >= number_of_dims)+ if (axis < 0 || axis >= number_of_dims) {CLDNN_ERROR_MESSAGE(desc->id, "Incorrect axis value! Actual axis is" + std::to_string(group));+ }- if (group < 1)+ if (group < 1) {CLDNN_ERROR_MESSAGE(desc->id,"Invalid group size value (should equal at least one). Actual block size is" + std::to_string(group));+ }- if (input_layout.get_tensor().sizes(format::bfyx)[axis] % group != 0)+ if (input_layout.get_tensor().sizes(format::bfyx)[axis] % group != 0) {CLDNN_ERROR_MESSAGE(desc->id,"Group parameter must evenly divide the channel dimension. Actual group size is " + std::to_string(group));+ }return layout{input_layout.data_type, input_format, input_layout.get_tensor()};}diff --git a/src/plugins/intel_gpu/src/graph/slice.cpp b/src/plugins/intel_gpu/src/graph/slice.cppindex c361b5f496d..ad59de847e2 100644--- a/src/plugins/intel_gpu/src/graph/slice.cpp+++ b/src/plugins/intel_gpu/src/graph/slice.cpp@@ -22,12 +22,15 @@ SliceKernelRefNeededInputs SliceKernelRefNeededInputs::Create(const slice_node&const bool step_in_runtime = !node_inputs[InputIndices::kStep].first->is_constant();inputs.neededIndexes.push_back(InputIndices::kData);- if (start_in_runtime)+ if (start_in_runtime) {inputs.neededIndexes.push_back(InputIndices::kStart);- if (step_in_runtime)+ }+ if (step_in_runtime) {inputs.neededIndexes.push_back(InputIndices::kStep);- if (axes_in_runtime)+ }+ if (axes_in_runtime) {inputs.neededIndexes.push_back(InputIndices::kAxes);+ }// NOTE: stop is never needed as it is passed implicitely via output shape.diff --git a/src/plugins/intel_gpu/src/graph/slice_scatter.cpp b/src/plugins/intel_gpu/src/graph/slice_scatter.cppindex 3467a1a298b..d26bb3c5ee8 100644--- a/src/plugins/intel_gpu/src/graph/slice_scatter.cpp+++ b/src/plugins/intel_gpu/src/graph/slice_scatter.cpp@@ -27,12 +27,15 @@ SliceScatterKernelRefNeededInputs SliceScatterKernelRefNeededInputs::Create(consconst bool step_in_runtime = !node_inputs[InputIndices::kStep].first->is_constant();const bool axes_in_runtime = ((node_inputs.size() > InputIndices::kAxes) && !node_inputs[InputIndices::kAxes].first->is_constant());- if (start_in_runtime)+ if (start_in_runtime) {inputs.neededIndexes.push_back(InputIndices::kStart);- if (step_in_runtime)+ }+ if (step_in_runtime) {inputs.neededIndexes.push_back(InputIndices::kStep);- if (axes_in_runtime)+ }+ if (axes_in_runtime) {inputs.neededIndexes.push_back(InputIndices::kAxes);+ }// NOTE: stop/end is never needed at runtime as it is passed implicitly via the updates shape.@@ -41,8 +44,9 @@ SliceScatterKernelRefNeededInputs SliceScatterKernelRefNeededInputs::Create(consbool SliceScatterKernelRefNeededInputs::IsInputNeededInRuntime(InputIndices type) const {for (const auto& idx : neededIndexes) {- if (idx == static_cast<size_t>(type))+ if (idx == static_cast<size_t>(type)) {return true;+ }}return false;}@@ -64,16 +68,19 @@ void slice_scatter_inst::on_execute() {}void slice_scatter_inst::update_output_memory() {- if (!can_be_optimized() || _impl_params->is_dynamic())+ if (!can_be_optimized() || _impl_params->is_dynamic()) {return;+ }build_deps();- if (input_memory_ptr() == nullptr)+ if (input_memory_ptr() == nullptr) {return;+ }- if (!_outputs.empty() && static_cast<bool>(_outputs[0]) && _network.get_engine().is_the_same_buffer(output_memory(), input_memory()))+ if (!_outputs.empty() && static_cast<bool>(_outputs[0]) && _network.get_engine().is_the_same_buffer(output_memory(), input_memory())) {return;+ }if (static_cast<bool>(_outputs[0]) && get_node().get_program().get_config().get_enable_memory_pool()) {_network.get_memory_pool().release_memory(_outputs[0].get(), get_node().get_unique_id(), get_node().id(), _network.get_id());diff --git a/src/plugins/intel_gpu/src/graph/softmax.cpp b/src/plugins/intel_gpu/src/graph/softmax.cppindex 1e3b775400d..d09e9a2281e 100644--- a/src/plugins/intel_gpu/src/graph/softmax.cpp+++ b/src/plugins/intel_gpu/src/graph/softmax.cpp@@ -16,8 +16,9 @@ layout softmax_inst::calc_output_layout(softmax_node const& node, kernel_impl_paauto output_layout = impl_param.get_input_layout();- if (impl_param.has_fused_primitives())+ if (impl_param.has_fused_primitives()) {output_layout.data_type = impl_param.get_output_element_type();+ }return output_layout;}diff --git a/src/plugins/intel_gpu/src/graph/space_to_batch.cpp b/src/plugins/intel_gpu/src/graph/space_to_batch.cppindex 0bd902c7cd9..9baedc4a168 100644--- a/src/plugins/intel_gpu/src/graph/space_to_batch.cpp+++ b/src/plugins/intel_gpu/src/graph/space_to_batch.cpp@@ -24,8 +24,9 @@ layout space_to_batch_inst::calc_output_layout(space_to_batch_node const& node,auto output_type = desc->output_data_types[0].value_or(input_layout.data_type);- if (impl_param.has_fused_primitives())+ if (impl_param.has_fused_primitives()) {output_type = impl_param.get_output_element_type();+ }const size_t spatial_num = format::spatial_num(input_format);@@ -33,29 +34,35 @@ layout space_to_batch_inst::calc_output_layout(space_to_batch_node const& node,const auto& pads_begin = desc->pads_begin;const auto& pads_end = desc->pads_end;- if (block_shape.batch[0] != 1)+ if (block_shape.batch[0] != 1) {CLDNN_ERROR_MESSAGE(desc->id,"block_shape[0] is expected to be 1. Actual block_shape[0] is " +std::to_string(block_shape.batch[0]));+ }- if (pads_begin.batch[0] != 0)+ if (pads_begin.batch[0] != 0) {CLDNN_ERROR_MESSAGE(desc->id,"pads_begin[0] is expected to be 0. Actual pads_begin[0] is " +std::to_string(pads_begin.batch[0]));+ }- if (pads_end.batch[0] != 0)+ if (pads_end.batch[0] != 0) {CLDNN_ERROR_MESSAGE(desc->id,"pads_end[0] is expected to be 0. Actual pads_end[0] is " +std::to_string(pads_end.batch[0]));+ }- if ((input_layout.feature() + pads_begin.feature[0] + pads_end.feature[0]) % block_shape.feature[0] != 0)+ if ((input_layout.feature() + pads_begin.feature[0] + pads_end.feature[0]) % block_shape.feature[0] != 0) {CLDNN_ERROR_MESSAGE(desc->id,"Input feature shape after padding must be divisible by block_shape");+ }- for (size_t i = 0; i < spatial_num; ++i)- if ((input_layout.spatial(i) + pads_begin.spatial[i] + pads_end.spatial[i]) % block_shape.spatial[i] != 0)+ for (size_t i = 0; i < spatial_num; ++i) {+ if ((input_layout.spatial(i) + pads_begin.spatial[i] + pads_end.spatial[i]) % block_shape.spatial[i] != 0) {CLDNN_ERROR_MESSAGE(desc->id,"Input spatial shapes after padding must be divisible by block_shape");+ }+ }return layout{output_type, input_format, desc->out_size};}@@ -141,8 +148,9 @@ std::vector<layout> space_to_batch_inst::calc_output_layouts(space_to_batch_node}auto output_type = desc->output_data_types[0].value_or(input0_layout.data_type);- if (impl_param.has_fused_primitives())+ if (impl_param.has_fused_primitives()) {output_type = impl_param.get_output_element_type();+ }return { layout{output_shapes[0], output_type, input0_layout.format} };}diff --git a/src/plugins/intel_gpu/src/graph/space_to_depth.cpp b/src/plugins/intel_gpu/src/graph/space_to_depth.cppindex 840c702f530..916071bdf20 100644--- a/src/plugins/intel_gpu/src/graph/space_to_depth.cpp+++ b/src/plugins/intel_gpu/src/graph/space_to_depth.cpp@@ -24,8 +24,9 @@ std::vector<layout> space_to_depth_inst::calc_output_layouts(space_to_depth_nodeauto input_layout = impl_param.get_input_layout(0);auto output_type = desc->output_data_types[0].value_or(input_layout.data_type);- if (impl_param.has_fused_primitives())+ if (impl_param.has_fused_primitives()) {output_type = impl_param.get_output_element_type();+ }auto output_format = input_layout.format;@@ -58,30 +59,34 @@ layout space_to_depth_inst::calc_output_layout(space_to_depth_node const& node,output_type = impl_param.get_output_element_type();}- if (depth_mode != SpaceToDepth::SpaceToDepthMode::DEPTH_FIRST && depth_mode != SpaceToDepth::SpaceToDepthMode::BLOCKS_FIRST)+ if (depth_mode != SpaceToDepth::SpaceToDepthMode::DEPTH_FIRST && depth_mode != SpaceToDepth::SpaceToDepthMode::BLOCKS_FIRST) {CLDNN_ERROR_MESSAGE(desc->id,"Invalid mode for spaceToDepth: must be \"blocks_first\" or \"depth_first\" only");+ }- if (block_size == 0)+ if (block_size == 0) {CLDNN_ERROR_MESSAGE(desc->id,"Invalid spaceToDepth block_size value (should be >= 1). Actual block size is" +std::to_string(block_size));+ }- if (input_layout.spatial(0) % block_size != 0 || input_layout.spatial(1) % block_size != 0)+ if (input_layout.spatial(0) % block_size != 0 || input_layout.spatial(1) % block_size != 0) {CLDNN_ERROR_MESSAGE(desc->id,"Sizes of spatials x, y must be divisible by block size. Actual spatial sizes are " +std::to_string(input_layout.spatial(0)) + ", " + std::to_string(input_layout.spatial(1)) +" (x, y). Actual block size is " + std::to_string(block_size));+ }if (input_layout.format.dimension() == 5) {- if (input_layout.spatial(2) % block_size != 0)+ if (input_layout.spatial(2) % block_size != 0) {CLDNN_ERROR_MESSAGE(desc->id,"Sizes of spatials z must be divisible by block size. Actual spatial sizes are " +std::to_string(input_layout.spatial(2)) +" (z). Block size is " + std::to_string(block_size));+ }const size_t feature = input_layout.feature() * block_size * block_size * block_size;const size_t z = input_layout.spatial(2) / block_size;diff --git a/src/plugins/intel_gpu/src/graph/strided_slice.cpp b/src/plugins/intel_gpu/src/graph/strided_slice.cppindex e435b429fc4..d1bfe89ad81 100644--- a/src/plugins/intel_gpu/src/graph/strided_slice.cpp+++ b/src/plugins/intel_gpu/src/graph/strided_slice.cpp@@ -46,8 +46,9 @@ std::vector<layout> strided_slice_inst::calc_output_layouts(strided_slice_node c|| (strides_data.empty() && !constant_mem.count(3))) {auto num_of_axis_mask_bit = [] (std::vector<int64_t> mask) -> size_t {size_t count = 0;- for (size_t i = 0; i < mask.size(); i++)+ for (size_t i = 0; i < mask.size(); i++) {if (mask[i]) count++;+ }return count;};@@ -57,10 +58,11 @@ std::vector<layout> strided_slice_inst::calc_output_layouts(strided_slice_node cauto num_of_shrink_axis_bit = num_of_axis_mask_bit(desc->shrink_axis_mask);auto output_len = input0_len;- if (num_of_new_axis_bit)+ if (num_of_new_axis_bit) {output_len += num_of_new_axis_bit;- else if (num_of_shrink_axis_bit)+ } else if (num_of_shrink_axis_bit) {output_len -= num_of_shrink_axis_bit;+ }auto output_shape = ov::PartialShape::dynamic(output_len);if (input0_layout.is_dynamic()) {@@ -194,16 +196,19 @@ void strided_slice_inst::on_execute() {void strided_slice_inst::update_output_memory() {OPENVINO_ASSERT(!_outputs.empty(), "outputs is empty.");OPENVINO_ASSERT(_node != nullptr, "_node should not be nullptr.");- if (!can_be_optimized())+ if (!can_be_optimized()) {return;+ }build_deps();- if (input_memory_ptr() == nullptr)+ if (input_memory_ptr() == nullptr) {return;+ }- if (static_cast<bool>(_outputs[0]) && _network.get_engine().is_the_same_buffer(output_memory(), input_memory()))+ if (static_cast<bool>(_outputs[0]) && _network.get_engine().is_the_same_buffer(output_memory(), input_memory())) {return;+ }GPU_DEBUG_TRACE_DETAIL << id() << " : update_output_memory with mem of input " << get_node().get_dependency(0).id()<< " : " << input_memory_ptr()->buffer_ptr() << std::endl;diff --git a/src/plugins/intel_gpu/src/graph/topology.cpp b/src/plugins/intel_gpu/src/graph/topology.cppindex 43e5c737ffc..90886ed522d 100644--- a/src/plugins/intel_gpu/src/graph/topology.cpp+++ b/src/plugins/intel_gpu/src/graph/topology.cpp@@ -30,14 +30,16 @@ const std::shared_ptr<primitive>& topology::at(primitive_id id) const {}void topology::change_input_layout(const primitive_id& id, const layout& new_layout) {- if (new_layout.format < format::any || new_layout.format >= format::format_num)+ if (new_layout.format < format::any || new_layout.format >= format::format_num) {throw std::invalid_argument("Unknown format of layout.");+ }if (new_layout.data_type != data_types::f16 && new_layout.data_type != data_types::f32 &&new_layout.data_type != data_types::i8 && new_layout.data_type != data_types::u1 &&new_layout.data_type != data_types::u8 && new_layout.data_type != data_types::i32 &&- new_layout.data_type != data_types::i64)+ new_layout.data_type != data_types::i64) {throw std::invalid_argument("Unknown data_type of layout.");+ }const auto& inp_layout = this->at(id);if (inp_layout->type != input_layout::type_id()) {diff --git a/src/plugins/intel_gpu/src/kernel_selector/auto_tuner.cpp b/src/plugins/intel_gpu/src/kernel_selector/auto_tuner.cppindex d32bdaccd5b..060ae9a5297 100644--- a/src/plugins/intel_gpu/src/kernel_selector/auto_tuner.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/auto_tuner.cpp@@ -159,16 +159,19 @@ TuningCache::Entry TuningCache::LoadKernel_v1(const Params& params, uint32_t comauto computeUnitsStr = std::to_string(computeUnitsCount);auto v1It = impl->cache.FindMember(version1Marker);- if (v1It == impl->cache.MemberEnd())+ if (v1It == impl->cache.MemberEnd()) {return result;+ }auto computeUnitsIt = v1It->value.FindMember(computeUnitsStr.c_str());- if (computeUnitsIt == v1It->value.MemberEnd())+ if (computeUnitsIt == v1It->value.MemberEnd()) {return result;+ }auto hashIt = computeUnitsIt->value.FindMember(hashStr.c_str());- if (hashIt == computeUnitsIt->value.MemberEnd())+ if (hashIt == computeUnitsIt->value.MemberEnd()) {return result;+ }auto& prog = hashIt->value;return std::make_tuple(prog[0].GetString(), prog[1].GetInt());@@ -182,20 +185,24 @@ TuningCache::Entry TuningCache::LoadKernel_v2(const Params& params, uint32_t comauto computeUnitsStr = std::to_string(computeUnitsCount);auto v2It = impl->cache.FindMember(version2Marker);- if (v2It == impl->cache.MemberEnd())+ if (v2It == impl->cache.MemberEnd()) {return result;+ }auto computeUnitsIt = v2It->value.FindMember(computeUnitsStr.c_str());- if (computeUnitsIt == v2It->value.MemberEnd())+ if (computeUnitsIt == v2It->value.MemberEnd()) {return result;+ }auto kTypeIt = computeUnitsIt->value.FindMember(kTypeStr.c_str());- if (kTypeIt == computeUnitsIt->value.MemberEnd())+ if (kTypeIt == computeUnitsIt->value.MemberEnd()) {return result;+ }auto paramIt = kTypeIt->value.FindMember(paramStr.c_str());- if (paramIt == kTypeIt->value.MemberEnd())+ if (paramIt == kTypeIt->value.MemberEnd()) {return result;+ }auto& prog = paramIt->value;return std::make_tuple(prog[0].GetString(), prog[1].GetInt());@@ -205,8 +212,9 @@ std::tuple<std::string, int> AutoTuner::LoadKernelOffline(const Params& params)std::lock_guard<std::mutex> lock(mutex);static const uint32_t defaultComputeUnits = 24;TuningCache* deviceCache = TuningCache::get();- if (!deviceCache)+ if (!deviceCache) {return {};+ }auto result = deviceCache->LoadKernel(params);if (std::get<0>(result).empty() && params.engineInfo.computeUnitsCount != defaultComputeUnits) {result = deviceCache->LoadKernel(params, defaultComputeUnits);diff --git a/src/plugins/intel_gpu/src/kernel_selector/common_tools.h b/src/plugins/intel_gpu/src/kernel_selector/common_tools.hindex ce430a214ba..4b2de246cf8 100644--- a/src/plugins/intel_gpu/src/kernel_selector/common_tools.h+++ b/src/plugins/intel_gpu/src/kernel_selector/common_tools.h@@ -3,14 +3,17 @@//#pragma once-#include "common_types.h"-#include <type_traits>#include <stdexcept>+#include <type_traits>++#include "common_types.h"#include "intel_gpu/runtime/debug_configuration.hpp"-#define DO_NOT_USE_THIS_KERNEL(id) do { \- GPU_DEBUG_TRACE << "Do not use this kernel: " << (id) << std::endl; \- return false; } while (0);+#define DO_NOT_USE_THIS_KERNEL(id) \+ do { \+ GPU_DEBUG_TRACE << "Do not use this kernel: " << (id) << std::endl; \+ return false; \+ } while (0);namespace kernel_selector {////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////@@ -18,50 +21,52 @@ namespace kernel_selector {////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////inline uint32_t BytesPerElement(Datatype dt) {switch (dt) {- case Datatype::INT8:- case Datatype::UINT8:- return 1;- case Datatype::F16:- case Datatype::BF16:- case Datatype::INT16:- case Datatype::UINT16:- return 2;- case Datatype::F32:- case Datatype::INT32:- case Datatype::UINT32:- return 4;- case Datatype::INT64:- return 8;- default:- throw std::runtime_error("[GPU] BytesPerElement doesn't support given precision");+ case Datatype::INT8:+ case Datatype::UINT8:+ return 1;+ case Datatype::F16:+ case Datatype::BF16:+ case Datatype::INT16:+ case Datatype::UINT16:+ return 2;+ case Datatype::F32:+ case Datatype::INT32:+ case Datatype::UINT32:+ return 4;+ case Datatype::INT64:+ return 8;+ default:+ throw std::runtime_error("[GPU] BytesPerElement doesn't support given precision");}}inline uint32_t BytesPerElement(WeightsType wt) {switch (wt) {- case WeightsType::INT8:- case WeightsType::UINT8:- return 1;- case WeightsType::F16:- case WeightsType::BF16:- return 2;- case WeightsType::F32:- case WeightsType::INT32:- return 4;- default:- throw std::runtime_error("[GPU] BytesPerElement doesn't support given precision");+ case WeightsType::INT8:+ case WeightsType::UINT8:+ return 1;+ case WeightsType::F16:+ case WeightsType::BF16:+ return 2;+ case WeightsType::F32:+ case WeightsType::INT32:+ return 4;+ default:+ throw std::runtime_error("[GPU] BytesPerElement doesn't support given precision");}}inline Datatype GetComputeDatatype(Datatype dt) {- if (dt == Datatype::BF16)+ if (dt == Datatype::BF16) {return Datatype::F32;+ }return dt;}inline WeightsType GetComputeWeightsType(WeightsType dt) {- if (dt == WeightsType::BF16)+ if (dt == WeightsType::BF16) {return WeightsType::F32;+ }return dt;}@@ -69,20 +74,20 @@ inline uint8_t GetActivationAdditionalParamsNumber(ActivationFunction func) {uint8_t paramsNum = 0;switch (func) {- case ActivationFunction::LINEAR:- case ActivationFunction::CLAMP:- case ActivationFunction::HARD_SIGMOID:- case ActivationFunction::SELU:- paramsNum = 2;- break;- case ActivationFunction::RELU_NEGATIVE_SLOPE:- case ActivationFunction::ELU:- case ActivationFunction::POW:- case ActivationFunction::SWISH:- paramsNum = 1;- break;- default:- break;+ case ActivationFunction::LINEAR:+ case ActivationFunction::CLAMP:+ case ActivationFunction::HARD_SIGMOID:+ case ActivationFunction::SELU:+ paramsNum = 2;+ break;+ case ActivationFunction::RELU_NEGATIVE_SLOPE:+ case ActivationFunction::ELU:+ case ActivationFunction::POW:+ case ActivationFunction::SWISH:+ paramsNum = 1;+ break;+ default:+ break;}return paramsNum;@@ -106,8 +111,7 @@ typename std::enable_if<std::is_integral<T>::value, bool>::type IsAligned(T sizetemplate <typename T1, typename T2>constexpr auto CeilDiv(T1 val, T2 divider) ->typename std::enable_if<std::is_integral<T1>::value && std::is_integral<T2>::value,- decltype(std::declval<typename std::make_unsigned<T1>::type>() /- std::declval<typename std::make_unsigned<T2>::type>())>::type {+ decltype(std::declval<typename std::make_unsigned<T1>::type>() / std::declval<typename std::make_unsigned<T2>::type>())>::type {typedef typename std::make_unsigned<T1>::type UT1;typedef typename std::make_unsigned<T2>::type UT2;typedef decltype(std::declval<UT1>() / std::declval<UT2>()) RetT;@@ -118,8 +122,7 @@ constexpr auto CeilDiv(T1 val, T2 divider) ->template <typename T1, typename T2>constexpr auto RoundUp(T1 val, T2 rounding) ->typename std::enable_if<std::is_integral<T1>::value && std::is_integral<T2>::value,- decltype(std::declval<typename std::make_unsigned<T1>::type>() /- std::declval<typename std::make_unsigned<T2>::type>())>::type {+ decltype(std::declval<typename std::make_unsigned<T1>::type>() / std::declval<typename std::make_unsigned<T2>::type>())>::type {typedef typename std::make_unsigned<T1>::type UT1;typedef typename std::make_unsigned<T2>::type UT2;typedef decltype(std::declval<UT1>() / std::declval<UT2>()) RetT;diff --git a/src/plugins/intel_gpu/src/kernel_selector/jitter.cpp b/src/plugins/intel_gpu/src/kernel_selector/jitter.cppindex a739d9c6b7f..3e3076503fe 100644--- a/src/plugins/intel_gpu/src/kernel_selector/jitter.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/jitter.cpp@@ -814,15 +814,17 @@ class WeightTensorJitConstant : public TensorBaseTJitConstant<WeightsType, Weigh)V0G0N";this->macroName = MacroName(tensor_name, layout_name, macroNameArgs);this->calcFunction = FuncBody(layout_name, funcArgs, body);- if (l == WeightsLayout::os_is_yx_osv16_isv16)+ if (l == WeightsLayout::os_is_yx_osv16_isv16) {this->macroBody = FuncCall(layout_name, {"o", "i", "0", "y", "x",Cat("_SIZE_X"), Cat("_SIZE_Y"), "1", Cat("_IFM_NUM"), Cat("_OFM_NUM"), "16", "16"});- else if (l == WeightsLayout::os_is_zyx_osv32_isv16)+ } else if (l == WeightsLayout::os_is_zyx_osv32_isv16) {this->macroBody = FuncCall(layout_name, {"o", "i", "z", "y", "x",Cat("_SIZE_X"), Cat("_SIZE_Y"), Cat("_SIZE_Z"), Cat("_IFM_NUM"), Cat("_OFM_NUM"), "32", "16"});- else if (l == WeightsLayout::os_is_zyx_osv64_isv16)- this->macroBody = FuncCall(layout_name, {"o", "i", "z", "y", "x",- Cat("_SIZE_X"), Cat("_SIZE_Y"), Cat("_SIZE_Z"), Cat("_IFM_NUM"), Cat("_OFM_NUM"), "64", "16"});+ } else if (l == WeightsLayout::os_is_zyx_osv64_isv16) {+ this->macroBody =+ FuncCall(layout_name,+ {"o", "i", "z", "y", "x", Cat("_SIZE_X"), Cat("_SIZE_Y"), Cat("_SIZE_Z"), Cat("_IFM_NUM"), Cat("_OFM_NUM"), "64", "16"});+ }} else if (l == WeightsLayout::g_os_zyx_is_osv16_isv16 || l == WeightsLayout::g_os_zyx_is_osv16_isv32 ||l == WeightsLayout::g_os_zyx_is_osv32_isv16 || l == WeightsLayout::g_os_zyx_is_osv32_isv32) {args macroNameArgs = {"prefix", "g", "o", "i", "z", "y", "x"};@@ -900,10 +902,11 @@ class WeightTensorJitConstant : public TensorBaseTJitConstant<WeightsType, Weigh)V0G0N";this->macroName = MacroName(tensor_name, layout_name, macroNameArgs);this->calcFunction = FuncBody(layout_name, funcArgs, body);- if (l == WeightsLayout::os_is_yx_osv16_isv4)+ if (l == WeightsLayout::os_is_yx_osv16_isv4) {this->macroBody = FuncCall(layout_name, {"o", "i", "y", "x", Cat("_IFM_PITCH"), Cat("_OFM_PITCH"), Cat("_SIZE_X"), "16"});- else if (l == WeightsLayout::os_is_yx_osv32_isv4)+ } else if (l == WeightsLayout::os_is_yx_osv32_isv4) {this->macroBody = FuncCall(layout_name, {"o", "i", "y", "x", Cat("_IFM_PITCH"), Cat("_OFM_PITCH"), Cat("_SIZE_X"), "32"});+ }} else {// throw error?}@@ -997,16 +1000,17 @@ JitDefinitions WeightTensorJitConstant::GetDefinitions() const {bool is_grouped_4d_layout = is_common_nd_layout(grouped_4d_channels, layout);if (is_grouped_4d_layout) {index_macro_name = _name + "_GET_INDEX(g, o, i, y, x)";- if (layout == WeightsLayout::goiyx || layout == WeightsLayout::gioyx)+ if (layout == WeightsLayout::goiyx || layout == WeightsLayout::gioyx) {index_func_val = called_func_name + "(" + _name + ", g, o, i, 0, y, x)";- else if (layout == WeightsLayout::g_os_is_yx_isv16_osv16)+ } else if (layout == WeightsLayout::g_os_is_yx_isv16_osv16) {index_func_val = called_func_name + "(" + _name + ", g, o, i, 0, y, x, 16)";- else if (layout == WeightsLayout::g_os_iyx_osv8)+ } else if (layout == WeightsLayout::g_os_iyx_osv8) {index_func_val = called_func_name + "(" + _name + ", g, o, i, y, x, 8)";- else if (layout == WeightsLayout::g_os_iyx_osv16)+ } else if (layout == WeightsLayout::g_os_iyx_osv16) {index_func_val = called_func_name + "(" + _name + ", g, o, i, y, x, 16)";- else if (layout == WeightsLayout::g_is_os_yx_isv16_osv16)+ } else if (layout == WeightsLayout::g_is_os_yx_isv16_osv16) {index_func_val = called_func_name + "(" + _name + ", g, o, i, 0, y, x, 16)";+ }} else {assert(0);}@@ -1022,12 +1026,13 @@ JitDefinitions WeightTensorJitConstant::GetDefinitions() const {bool is_grouped_5d_layout = is_common_nd_layout(grouped_5d_channels, layout);if (is_grouped_5d_layout) {index_macro_name = _name + "_GET_INDEX(g, o, i, z, y, x)";- if (layout == WeightsLayout::goizyx || layout == WeightsLayout::giozyx)+ if (layout == WeightsLayout::goizyx || layout == WeightsLayout::giozyx) {index_func_val = called_func_name + "(" + _name + ", g, o, i, z, y, x)";- else if (layout == WeightsLayout::g_os_is_zyx_isv16_osv16)+ } else if (layout == WeightsLayout::g_os_is_zyx_isv16_osv16) {index_func_val = called_func_name + "(" + _name + ", g, o, i, z, y, x, 16)";- else if (layout == WeightsLayout::g_is_os_zyx_isv16_osv16)+ } else if (layout == WeightsLayout::g_is_os_zyx_isv16_osv16) {index_func_val = called_func_name + "(" + _name + ", g, o, i, z, y, x, 16)";+ }} else {assert(0);}@@ -1043,21 +1048,20 @@ JitDefinitions WeightTensorJitConstant::GetDefinitions() const {bool is_common_4d_layout = is_common_nd_layout(base_4d_channels, layout);if (is_common_4d_layout) {index_macro_name = _name + "_GET_INDEX(o, i, y, x)";- if (layout == WeightsLayout::oiyx || layout == WeightsLayout::ioyx ||- layout == WeightsLayout::oyxi || layout == WeightsLayout::oyix ||- layout == WeightsLayout::oxiy || layout == WeightsLayout::iyxo ||- layout == WeightsLayout::yxio)+ if (layout == WeightsLayout::oiyx || layout == WeightsLayout::ioyx || layout == WeightsLayout::oyxi || layout == WeightsLayout::oyix ||+ layout == WeightsLayout::oxiy || layout == WeightsLayout::iyxo || layout == WeightsLayout::yxio) {index_func_val = called_func_name + "(" + _name + ", 0, o, i, 0, y, x)";- else if (layout == WeightsLayout::os_is_yx_isv16_osv16)+ } else if (layout == WeightsLayout::os_is_yx_isv16_osv16) {index_func_val = called_func_name + "(" + _name + ", 0, o, i, 0, y, x, 16)";- else if (layout == WeightsLayout::os_iyx_osv16)+ } else if (layout == WeightsLayout::os_iyx_osv16) {index_func_val = called_func_name + "(" + _name + ", 0, o, i, y, x, 16)";- else if (layout == WeightsLayout::os_iyx_osv32 || layout == WeightsLayout::os_iyx_osv32__ai32)+ } else if (layout == WeightsLayout::os_iyx_osv32 || layout == WeightsLayout::os_iyx_osv32__ai32) {index_func_val = called_func_name + "(" + _name + ", 0, o, i, y, x, 32)";- else if (layout == WeightsLayout::is_os_yx_isv16_osv16)+ } else if (layout == WeightsLayout::is_os_yx_isv16_osv16) {index_func_val = called_func_name + "(" + _name + ", 0, o, i, 0, y, x, 16)";- else if (layout == WeightsLayout::os_is_yx_osv16_isv16)+ } else if (layout == WeightsLayout::os_is_yx_osv16_isv16) {index_func_val = called_func_name + "(" + _name + ", o, i, 0, y, x)";+ }} else {assert(0);}@@ -1072,14 +1076,15 @@ JitDefinitions WeightTensorJitConstant::GetDefinitions() const {bool is_common_5d_layout = is_common_nd_layout(base_5d_channels, layout);if (is_common_5d_layout) {index_macro_name = _name + "_GET_INDEX(o, i, z, y, x)";- if (layout == WeightsLayout::oizyx || layout == WeightsLayout::iozyx)+ if (layout == WeightsLayout::oizyx || layout == WeightsLayout::iozyx) {index_func_val = called_func_name + "(" + _name + ", 0, o, i, z, y, x)";- else if (layout == WeightsLayout::os_is_zyx_isv16_osv16)+ } else if (layout == WeightsLayout::os_is_zyx_isv16_osv16) {index_func_val = called_func_name + "(" + _name + ", 0, o, i, z, y, x, 16)";- else if (layout == WeightsLayout::is_os_zyx_isv16_osv16)+ } else if (layout == WeightsLayout::is_os_zyx_isv16_osv16) {index_func_val = called_func_name + "(" + _name + ", 0, o, i, z, y, x, 16)";- else if (layout == WeightsLayout::os_is_zyx_osv32_isv16 || layout == WeightsLayout::os_is_zyx_osv64_isv16)+ } else if (layout == WeightsLayout::os_is_zyx_osv32_isv16 || layout == WeightsLayout::os_is_zyx_osv64_isv16) {index_func_val = called_func_name + "(" + _name + ", o, i, z, y, x)";+ }} else {assert(0);}@@ -1199,10 +1204,11 @@ JitConstants MakeActivationJitConstants(ActivationFunction activation_function,jitConstants.AddConstant(MakeJitConstant(macro_def, log(one + exp(input)).str()));break;case ActivationFunction::ABS:- if (out_dt == Datatype::F32 || out_dt == Datatype::F16)+ if (out_dt == Datatype::F32 || out_dt == Datatype::F16) {jitConstants.AddConstant(MakeJitConstant(macro_def, "(fabs(input))"));- else+ } else {jitConstants.AddConstant(MakeJitConstant(macro_def, "(abs(input))"));+ }break;case ActivationFunction::LINEAR: {const JitTerm m = disable_type_conversion ? "m"_jit : to_type("m"_jit);@@ -1264,16 +1270,18 @@ JitConstants MakeActivationJitConstants(ActivationFunction activation_function,jitConstants.AddConstant(MakeJitConstant(macro_def, "(atanh(input))"));break;case ActivationFunction::FLOOR:- if (out_dt == Datatype::F32 || out_dt == Datatype::F16)+ if (out_dt == Datatype::F32 || out_dt == Datatype::F16) {jitConstants.AddConstant(MakeJitConstant(macro_def, "(floor(input))"));- else+ } else {jitConstants.AddConstant(MakeJitConstant(macro_def, "(input)"));+ }break;case ActivationFunction::CEIL:- if (out_dt == Datatype::F32 || out_dt == Datatype::F16)+ if (out_dt == Datatype::F32 || out_dt == Datatype::F16) {jitConstants.AddConstant(MakeJitConstant(macro_def, "(ceil(input))"));- else+ } else {jitConstants.AddConstant(MakeJitConstant(macro_def, "(input)"));+ }break;case ActivationFunction::NEGATIVE:jitConstants.AddConstant(MakeJitConstant(macro_def, "(-input)"));@@ -2184,12 +2192,13 @@ JitConstants FusedOpsCodeGenerator::MakeOpJitConstants(const FusedOpsConfigurati// Output clampif (p->has_clamp) {- if (p->has_min_clamp && p->has_max_clamp)+ if (p->has_min_clamp && p->has_max_clamp) {op_decls += "\\\n\t" + tmp_var + " = clamp(" + tmp_var + ", " + out_lo + ", " + out_hi + ");";- else if (p->has_min_clamp)+ } else if (p->has_min_clamp) {op_decls += "\\\n\t" + tmp_var + " = max(" + tmp_var + ", " + out_lo + ");";- else+ } else {op_decls += "\\\n\t" + tmp_var + " = min(" + tmp_var + ", " + out_hi + ");";+ }}// Output conversion with rounding and saturation@@ -2203,12 +2212,13 @@ JitConstants FusedOpsCodeGenerator::MakeOpJitConstants(const FusedOpsConfigurati// Input clampif (p->has_clamp) {- if (p->has_min_clamp && p->has_max_clamp)+ if (p->has_min_clamp && p->has_max_clamp) {op_decls += "\\\n\t" + tmp_type_str + " " + tmp_var + " = clamp(" + in_converted + ", " + in_lo + ", " + in_hi + ");";- else if (p->has_min_clamp)+ } else if (p->has_min_clamp) {op_decls += "\\\n\t" + tmp_type_str + " " + tmp_var + " = max(" + in_converted + ", " + in_lo + ");";- else+ } else {op_decls += "\\\n\t" + tmp_type_str + " " + tmp_var + " = min(" + in_converted + ", " + in_hi + ");";+ }} else {op_decls += "\\\n\t" + tmp_type_str + " " + tmp_var + " = " + in_converted + ";";}@@ -2401,9 +2411,9 @@ std::string FusedOpsCodeGenerator::GetJitLoad(const FusedOpsConfiguration& conf,std::string offset = conf.bfzyx_idx_order[0];if (safe_load)offset = "(" + offset + " % " + toCodeString(input_tensor.LogicalSize()) + ")";- if (vec_size > 1)- return "((const __global " + toCLType(input_dt) + toCodeString(vec_size) + "*)(" +- GetInputPtrName(input_id) + " + " + offset + "))[0]";+ if (vec_size > 1) {+ return "((const __global " + toCLType(input_dt) + toCodeString(vec_size) + "*)(" + GetInputPtrName(input_id) + " + " + offset + "))[0]";+ }return GetInputPtrName(input_id) + "[" + offset + "]";} // TODO: Need to add smarter vectors handling:// 1. Boundary checks for safe load@@ -2460,9 +2470,9 @@ std::string FusedOpsCodeGenerator::GetInputPtrName(size_t input_id) const {}std::string FusedOpsCodeGenerator::GetInputVarName(size_t input_id, bool is_shuffled, std::string shuffle_var) const {- if (is_shuffled)- return "_sub_group_shuffle(" + GetTypeStr() + toCodeString(desc.op_id) + "_data" +- toCodeString(input_id) + ", " + shuffle_var + ")";+ if (is_shuffled) {+ return "_sub_group_shuffle(" + GetTypeStr() + toCodeString(desc.op_id) + "_data" + toCodeString(input_id) + ", " + shuffle_var + ")";+ }return GetTypeStr() + toCodeString(desc.op_id) + "_data" + toCodeString(input_id);}diff --git a/src/plugins/intel_gpu/src/kernel_selector/jitter.h b/src/plugins/intel_gpu/src/kernel_selector/jitter.hindex f3abde4adb6..21480832099 100644--- a/src/plugins/intel_gpu/src/kernel_selector/jitter.h+++ b/src/plugins/intel_gpu/src/kernel_selector/jitter.h@@ -78,8 +78,9 @@ inline std::string toVectorMulString(const std::vector<std::string>& vec) {ss << "(";for (size_t i = 0; i < vec.size(); i++) {ss << vec[i];- if (i != vec.size() - 1)+ if (i != vec.size() - 1) {ss << "*";+ }}ss << ")";return ss.str();@@ -119,10 +120,12 @@ inline std::string toVectorInitString(const VecT& vec,Func fetchFunc) {std::stringstream ss;ss << "{ ";- for (size_t i = 0; i < vec.size(); i++)+ for (size_t i = 0; i < vec.size(); i++) {ss << toCodeString(fetchFunc(vec[i])) << ",";- for (size_t i = vec.size(); i < maxDim; i++)+ }+ for (size_t i = vec.size(); i < maxDim; i++) {ss << padFillingVal << ",";+ }ss << " } ";return ss.str();}@@ -134,8 +137,9 @@ inline std::string toVectorString(const VecT& vec,ValT padFillingVal,Func fetchFunc) {std::stringstream ss;- if (!vectorType.empty())+ if (!vectorType.empty()) {ss << "(" << vectorType << " [])";+ }ss << toVectorInitString(vec, vectorType, maxDim, padFillingVal, fetchFunc);return ss.str();}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernel_base.cppindex c86ef506515..f7106e82620 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernel_base.cpp@@ -27,10 +27,11 @@ std::string toString(const kernel_selector::CommonDispatchData& dispatchData) {void KernelBase::CheckDispatchData(const std::string& kernelName, const kernel_selector::CommonDispatchData& dispatchData,const EngineInfo& engineInfo) {const auto maxWorkGroupSize = engineInfo.maxWorkGroupSize;- if (dispatchData.gws.size() != 3 || dispatchData.lws.size() != 3)+ if (dispatchData.gws.size() != 3 || dispatchData.lws.size() != 3) {throw std::runtime_error("ERROR: Invalid dispatch data for kernel: " + kernelName + ": " +": LWS and GWS size is expected to be equal to 3. Actual: " +toString(dispatchData));+ }if (dispatchData.lws[0] * dispatchData.lws[1] * dispatchData.lws[2] > maxWorkGroupSize) {throw std::runtime_error("ERROR: Invalid dispatch data for kernel: " + kernelName +@@ -38,16 +39,18 @@ void KernelBase::CheckDispatchData(const std::string& kernelName, const kernel_stoString(dispatchData));}for (size_t i = 0; i < dispatchData.gws.size(); i++) {- if (dispatchData.gws[i] == 0 || dispatchData.lws[i] == 0)+ if (dispatchData.gws[i] == 0 || dispatchData.lws[i] == 0) {throw std::runtime_error("ERROR: Invalid dispatch data for kernel: " + kernelName +": Dispatch data cannot contain zeros. Actual: " +toString(dispatchData));+ }if (!engineInfo.supports_non_uniform_work_group) {- if (dispatchData.gws[i] % dispatchData.lws[i] != 0)+ if (dispatchData.gws[i] % dispatchData.lws[i] != 0) {throw std::runtime_error("ERROR: Invalid dispatch data for kernel: " + kernelName +": GWS must be divisible by corresponding LWS. Actual: " +toString(dispatchData));+ }}}}@@ -64,9 +67,11 @@ Datatype KernelBase::GetUnitType(const base_params& params) const {Datatype types_prioritized[] ={Datatype::INT8, Datatype::F16, Datatype::BF16, Datatype::INT32, Datatype::INT64, Datatype::UINT8, Datatype::UINT32};- for (Datatype type : types_prioritized)- if (IsTypeUsedIn(type, params))+ for (Datatype type : types_prioritized) {+ if (IsTypeUsedIn(type, params)) {return type;+ }+ }return Datatype::F32;}@@ -140,8 +145,9 @@ JitConstants KernelBase::MakeFusedOpsJitConstants(const kernel_selector::base_paJitConstants jit = {};// TODO: multiple output support- if (conf.empty())+ if (conf.empty()) {return jit;+ }if (std::all_of(params.fused_ops.cbegin(), params.fused_ops.cend(),[](fused_operation_desc desc) { return desc.GetType() == KernelType::REORDER; })) {@@ -160,8 +166,9 @@ JitConstants KernelBase::MakeFusedOpsJitConstants(const kernel_selector::base_paDatatype last_fused_out_dtype = c.input_dt;for (size_t i = 0; i < params.fused_ops.size(); i++) {// Reorder is not processed by jitter- if (params.fused_ops[i].GetType() == FusedOpType::REORDER)+ if (params.fused_ops[i].GetType() == FusedOpType::REORDER) {continue;+ }auto fused_dep_codegen = FusedOpsCodeGenerator(params.fused_ops[i]);jit.Merge(fused_dep_codegen.MakeLoadJitConstants(c, params.outputs[0]));@@ -171,14 +178,17 @@ JitConstants KernelBase::MakeFusedOpsJitConstants(const kernel_selector::base_pacan_all_use_preload &= can_use_preload;bool can_preload_eltwise = true;if (params.fused_ops[i].GetType() == FusedOpType::ELTWISE &&- c.load_type == FusedOpsConfiguration::LoadType::FEATURE_SHUFFLE)+ c.load_type == FusedOpsConfiguration::LoadType::FEATURE_SHUFFLE) {can_preload_eltwise = false;+ }fused_ops += "\\\n\tFUSED_OP" + toCodeString(i) + "_LOAD" + c.suffix;fused_ops += "\\\n\tFUSED_OP" + toCodeString(i) + "_ACTION" + c.suffix;- if (can_use_preload && can_preload_eltwise)+ if (can_use_preload && can_preload_eltwise) {fused_ops_preload += "\\\n\tFUSED_OP" + toCodeString(i) + "_LOAD" + c.suffix;- if (c.allow_for_partial_preload && (!can_use_preload || !can_preload_eltwise))+ }+ if (c.allow_for_partial_preload && (!can_use_preload || !can_preload_eltwise)) {fused_ops_calc += "\\\n\tFUSED_OP" + toCodeString(i) + "_LOAD" + c.suffix;+ }fused_ops_calc += "\\\n\tFUSED_OP" + toCodeString(i) + "_ACTION" + c.suffix;last_fused_out_dtype = params.fused_ops[i].output_tensor.GetDType();}@@ -188,8 +198,9 @@ JitConstants KernelBase::MakeFusedOpsJitConstants(const kernel_selector::base_pajit.AddConstant(MakeJitConstant("FUSED_OPS_CALC" + c.suffix, fused_ops_calc));// Convert dtype, only if last fused op has a different one from kernel outputif (!params.outputs.empty() && params.outputs[0].GetDType() != last_fused_out_dtype) {- if (last_fused_out_dtype == Datatype::BF16)+ if (last_fused_out_dtype == Datatype::BF16) {out_name = "CONVERT_AS_BFLOAT16_FLOAT(" + out_name + ", " + toCodeString(c.vec_size) + ")";+ }out_name = "TO_OUTPUT_VECTOR_TYPE(" + out_name + ", " + toCodeString(c.vec_size) + ")";}jit.AddConstant(MakeJitConstant("FUSED_OPS_RESULT" + c.suffix, out_name));@@ -211,8 +222,9 @@ JitConstants KernelBase::MakeFusedOpsDeclsJitConstants(const kernel_selector::baconst std::vector<FusedOpsConfiguration> &conf) const {JitConstants jit = {};- if (conf.empty())+ if (conf.empty()) {return jit;+ }std::string input_decls;std::string input_args;@@ -240,8 +252,9 @@ JitConstants KernelBase::MakeFusedOpsDeclsJitConstants(const kernel_selector::babool KernelBase::IsFusedPrimitiveSupported(const fused_operation_desc& fused_op) const {for (auto& supported_op : GetSupportedFusedOps()) {- if (fused_op.GetType() == supported_op)+ if (fused_op.GetType() == supported_op) {return true;+ }}return false;@@ -277,14 +290,17 @@ DeviceFeaturesKey KernelBase::get_common_subgroups_device_features_key(const Par}}- if (requires_blocked_read_write)+ if (requires_blocked_read_write) {k.requires_blocked_read_write();+ }- if (requires_blocked_read_write_short)+ if (requires_blocked_read_write_short) {k.requires_blocked_read_write_short();+ }- if (requires_blocked_read_write_char)+ if (requires_blocked_read_write_char) {k.requires_blocked_read_write_char();+ }k.requires_subgroups();k.requires_reqd_subgroup_size();diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernel_base_opencl.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernel_base_opencl.cppindex e32efcdacf4..54710dce36e 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernel_base_opencl.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernel_base_opencl.cpp@@ -76,8 +76,9 @@ std::string KernelBaseOpenCL::GetEntryPoint(const std::string& templateName,kernelID += "_" + params.uniqueID + "_" + std::to_string(partID) + "_" + std::to_string(params.stage_id);// Add "__sa" suffix for shape agnostic kernels- if (params.is_shape_agnostic)+ if (params.is_shape_agnostic) {kernelID += "__sa";+ }return kernelID;}@@ -132,8 +133,9 @@ Arguments KernelBaseOpenCL::GetArgsDesc(uint32_t num_of_input,bool is_dynamic) const {Arguments args;- if (is_dynamic)+ if (is_dynamic) {args.push_back({ArgumentDescriptor::Types::SHAPE_INFO, 0});+ }for (uint32_t i = 0; i < num_of_input; i++) {args.push_back({ArgumentDescriptor::Types::INPUT, i});@@ -173,18 +175,22 @@ std::shared_ptr<KernelString> KernelBaseOpenCL::GetKernelString(const std::strinkernel_string->undefs = jit.second;if (engine_info.vendor_id == cldnn::INTEL_VENDOR_ID) {kernel_string->options = exe_mode + " -cl-mad-enable";- if (engine_info.bOptHintsSupport)+ if (engine_info.bOptHintsSupport) {kernel_string->options += " -DOPT_HINTS_SUPPORTED=1";- if (engine_info.enable_large_allocations)+ }+ if (engine_info.enable_large_allocations) {kernel_string->options += " -cl-intel-greater-than-4GB-buffer-required";- if (engine_info.supports_register_file_size_option)+ }+ if (engine_info.supports_register_file_size_option) {kernel_string->options += " -ze-exp-register-file-size 128";+ }}- if (engine_info.supports_work_group_collective_functions)+ if (engine_info.supports_work_group_collective_functions) {kernel_string->options += " -cl-std=CL3.0";- else+ } else {kernel_string->options += " -cl-std=CL2.0";+ }kernel_string->entry_point = entry_point;kernel_string->batch_compilation = true;@@ -216,8 +222,9 @@ void KernelBaseOpenCL::FillCLKernelData(clKernelData& kernel,uint32_t number_of_inputs_for_fused_prims,int number_of_outputs,bool is_dynamic) const {- if (!is_dynamic && !kernel.skip_execution)+ if (!is_dynamic && !kernel.skip_execution) {KernelBase::CheckDispatchData(kernelMapName, dispatchData, engine_info);+ }kernel.code.kernelString = GetKernelString(kernelMapName, jit, entryPoint, engine_info, exeMode);kernel.params.workGroups.global = dispatchData.gws;kernel.params.workGroups.local = dispatchData.lws;diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernel_selector.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernel_selector.cppindex 71dd9c09913..5aa2208beb6 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernel_selector.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernel_selector.cpp@@ -2,27 +2,29 @@// SPDX-License-Identifier: Apache-2.0//-#include "kernel_base.h"-#include "kernel_selector_common.h"#include "kernel_selector.h"-#include "kernel_selector_params.h"-#include <type_traits>-#include <sstream>+#include <fstream>+#include <iostream>+#include <set>+#include <sstream>#include <string>-#include <vector>#include <tuple>-#include <set>-#include <iostream>+#include <type_traits>+#include <vector>+#include "intel_gpu/runtime/debug_configuration.hpp"+#include "kernel_base.h"+#include "kernel_selector_common.h"+#include "kernel_selector_params.h"// #define ENABLE_ENV// #define ENABLE_ENV_PRINT#ifdef ENABLE_ENV_PRINT-#define ENV_PRINTF(...) printf(__VA_ARGS__)+# define ENV_PRINTF(...) printf(__VA_ARGS__)#else-#define ENV_PRINTF(...)+# define ENV_PRINTF(...)#endif // ENABLE_ENV_PRINT#define ENABLE_OFFLINE_TUNING_CACHE 1@@ -71,7 +73,6 @@ KernelData kernel_selector_base::get_best_kernel(const Params& params) const {return kernels[0];}-KernelsData kernel_selector_base::GetNaiveBestKernel(const KernelList& all_impls, const Params& params) const {KernelsData kernelsData;std::string kernelName;@@ -90,7 +91,7 @@ KernelsData kernel_selector_base::GetNaiveBestKernel(const KernelList& all_impls}} catch (std::runtime_error& ex) {// we have to handle it in order to avoid exception in KernelSelector as much we can- kernelName = (implementation != nullptr)? implementation->GetName() : "[impl is null]";+ kernelName = (implementation != nullptr) ? implementation->GetName() : "[impl is null]";GPU_DEBUG_TRACE << "layerID: " << params.layerID << " kernel: " << kernelName << " - " << ex.what() << std::endl;}}@@ -147,8 +148,9 @@ KernelsData kernel_selector_base::GetAutoTuneBestKernel(const Params& params, Kestd::shared_ptr<KernelBase> kernel_selector_base::GetImplementation(std::string& kernel_name) const {for (const auto& impl : implementations) {- if (impl->GetName().compare(kernel_name) == 0)+ if (impl->GetName().compare(kernel_name) == 0) {return impl;+ }}return nullptr;}@@ -169,25 +171,24 @@ KernelList kernel_selector_base::GetAllImplementations(const Params& params, Kerbool forceImplementation = !params.forceImplementation.empty();for (const auto& impl : implementations) {const ParamsKey implKey = impl->GetSupportedKey();- if (!implKey.Support(requireKey))+ if (!implKey.Support(requireKey)) {continue;+ }auto required_device_features_key = impl->get_required_device_features_key(params);- if (!device_features_key.supports(required_device_features_key))+ if (!device_features_key.supports(required_device_features_key)) {continue;+ }- if (forceImplementation && params.forceImplementation != impl->GetName())+ if (forceImplementation && params.forceImplementation != impl->GetName()) {continue;+ }sortedImpls.emplace(impl->GetKernelsPriority(params), impl);}- std::transform(- sortedImpls.begin(),- sortedImpls.end(),- std::back_inserter(result),- [](const PriorityPair& impl) {- return std::move(impl.second);- });+ std::transform(sortedImpls.begin(), sortedImpls.end(), std::back_inserter(result), [](const PriorityPair& impl) {+ return std::move(impl.second);+ });} else {GPU_DEBUG_COUT << "No implementation for " << params.layerID << " because of kernel type mismatch" << std::endl;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_params.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_params.cppindex 453d719b897..fa2821e09ea 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_params.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_params.cpp@@ -479,23 +479,31 @@ void ParamsKey::EnableQuantization(QuantizationType q) {}bool ParamsKey::Support(const ParamsKey& k) const {- if (!((key.restrict.raw & k.key.restrict.raw) == k.key.restrict.raw)) // check if this kernel supports this params+ if (!((key.restrict.raw & k.key.restrict.raw) == k.key.restrict.raw)) { // check if this kernel supports this paramsreturn false;- if (!((key.inputType.raw & k.key.inputType.raw) == k.key.inputType.raw))+ }+ if (!((key.inputType.raw & k.key.inputType.raw) == k.key.inputType.raw)) {return false;- if (!((key.outputType.raw & k.key.outputType.raw) == k.key.outputType.raw))+ }+ if (!((key.outputType.raw & k.key.outputType.raw) == k.key.outputType.raw)) {return false;- if (!((key.inputWeightsType.raw & k.key.inputWeightsType.raw) == k.key.inputWeightsType.raw))+ }+ if (!((key.inputWeightsType.raw & k.key.inputWeightsType.raw) == k.key.inputWeightsType.raw)) {return false;- if (!((key.outputWeightsType.raw & k.key.outputWeightsType.raw) == k.key.outputWeightsType.raw))+ }+ if (!((key.outputWeightsType.raw & k.key.outputWeightsType.raw) == k.key.outputWeightsType.raw)) {return false;- if ((key.inputLayout & k.key.inputLayout) == 0 && key.inputLayout != k.key.inputLayout)+ }+ if ((key.inputLayout & k.key.inputLayout) == 0 && key.inputLayout != k.key.inputLayout) {return false;- if ((key.outputLayout & k.key.outputLayout) == 0 && key.outputLayout != k.key.outputLayout)+ }+ if ((key.outputLayout & k.key.outputLayout) == 0 && key.outputLayout != k.key.outputLayout) {return false;+ }if ((key.weightsInputLayout & k.key.weightsInputLayout) == 0 &&- key.weightsInputLayout != k.key.weightsInputLayout)+ key.weightsInputLayout != k.key.weightsInputLayout) {return false;+ }return (key.weightsOutputLayout & k.key.weightsOutputLayout) != 0 ||key.weightsOutputLayout == k.key.weightsOutputLayout;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_params.h b/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_params.hindex 2442a427710..55046523fe9 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_params.h+++ b/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_params.h@@ -644,8 +644,9 @@ struct fused_operation_desc {template<typename T>std::shared_ptr<T> GetOpParams() const {auto p = std::dynamic_pointer_cast<T>(op_params);- if (!p)+ if (!p) {throw std::runtime_error("Invalid dynamic cast of fused operation parameters");+ }return p;}@@ -693,8 +694,9 @@ struct base_params : public Params {if (tensor.is_dynamic()) {offset += DataTensor::max_rank();for (auto dim : tensor.GetDims()) {- if (dim.pad.is_dynamic)+ if (dim.pad.is_dynamic) {offset += Tensor::Pad::NumPadOffsetsPerDim();+ }}}};@@ -702,8 +704,9 @@ struct base_params : public Params {update_offset(in);}for (auto& fd : fused_ops) {- if (!fd.has_outer_dep())+ if (!fd.has_outer_dep()) {continue;+ }auto& fused_op_inputs = fd.tensors;for (auto& fused_input : fused_op_inputs) {update_offset(fused_input);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_utils.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_utils.cppindex 75dd272be6c..72a7176ab96 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_utils.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_utils.cpp@@ -38,8 +38,9 @@ static WeightsFormatSupportType CheckWeights(const weight_bias_params& newParamsbool rotate) {// validate if weights type is image and if device supports requested sizesif (Tensor::IsImageType(reqLayouts)) {- if (!CheckImageSize(newParams, reqLayouts))+ if (!CheckImageSize(newParams, reqLayouts)) {return UNSUPPORTED;+ }}const auto& tensor = newParams.weights;@@ -81,8 +82,9 @@ std::vector<size_t> GetImageSizes(const kernel_selector::WeightsTensor& dimensio}bool CheckImageSize(const weight_bias_params& newParams, const WeightsLayout layout) {- if (!newParams.engineInfo.supports_image)+ if (!newParams.engineInfo.supports_image) {return false;+ }auto image_sizes = GetImageSizes(newParams.weights, layout);return image_sizes[0] != 0 && image_sizes[1] != 0 && image_sizes[0] <= newParams.engineInfo.maxImage2dWidth &&@@ -130,20 +132,26 @@ JitConstants GetTensorFriendlyWorkGroupsJit(const DataTensor& t) {int idx = 0;for (size_t i = 0; i < t.GetDims().size(); i++) {- if (b == static_cast<int>(i))+ if (b == static_cast<int>(i)) {gws_batch = idx++;- if (f == static_cast<int>(i))+ }+ if (f == static_cast<int>(i)) {gws_feature = idx++;- if (x == static_cast<int>(i))+ }+ if (x == static_cast<int>(i)) {gws_spatial = idx++;+ }}- if (-1 == gws_batch)+ if (-1 == gws_batch) {gws_batch = idx++;- if (-1 == gws_feature)+ }+ if (-1 == gws_feature) {gws_feature = idx++;- if (-1 == gws_spatial)+ }+ if (-1 == gws_spatial) {gws_spatial = idx++;+ }JitConstants jit{MakeJitConstant("GWS_BATCH", gws_batch),@@ -214,8 +222,9 @@ std::vector<size_t> GetOptimalLocalWorkGroupSizes(std::vector<size_t> gws, const}auto calculate_optimized_priority_order = [&]() -> void {- while (axis_by_gws[layout_order[first_axis_idx]] == unused_axis)+ while (axis_by_gws[layout_order[first_axis_idx]] == unused_axis) {first_axis_idx++;+ }for (size_t gws_idx = 0; gws_idx < gws_dims_num; gws_idx++) {for (size_t axis_idx = first_axis_idx; axis_idx < axis_num; axis_idx++) {@@ -411,8 +420,9 @@ std::vector<size_t> GetOptimalLocalWorkGroupSizes(std::vector<size_t> gws, constlws[priority_order[i]] = lws_values[lws_idx];} else {lws[priority_order[i]] = i == 2 && gws[priority_order[0]] != 1 ? 1 : lws_values[lws_idx];- if (total_gws > 100 && total_lws < 8 && i == 2)+ if (total_gws > 100 && total_lws < 8 && i == 2) {lws[priority_order[i]] = lws_values[lws_idx];+ }}total_lws *= lws_values[lws_idx];@@ -473,21 +483,24 @@ bool CheckInputsOutputNoPitchSameDims(const base_params& params) {auto block_layout = block_layouts.find(params.inputs[0].GetLayout());if (block_layout != block_layouts.end()) {auto block_size = block_layout->second;- if (params.inputs[0].Batch().v % block_size.first != 0 || params.inputs[0].Feature().v % block_size.second != 0)+ if (params.inputs[0].Batch().v % block_size.first != 0 || params.inputs[0].Feature().v % block_size.second != 0) {return false;+ }}if (!params.fused_ops.empty()) {for (auto fused_op : params.fused_ops) {for (size_t in = 0; in < fused_op.tensors.size(); in++) {- if (fused_op.tensors[in].LogicalSize() == 1)+ if (fused_op.tensors[in].LogicalSize() == 1) {continue;+ }auto layout = block_layouts.find(fused_op.tensors[in].GetLayout());if (layout != block_layouts.end()) {auto block_size = layout->second;- if (fused_op.tensors[in].Batch().v % block_size.first != 0 || fused_op.tensors[in].Feature().v % block_size.second != 0)+ if (fused_op.tensors[in].Batch().v % block_size.first != 0 || fused_op.tensors[in].Feature().v % block_size.second != 0) {return false;+ }}no_pitch_same_dims = no_pitch_same_dims && (params.inputs[0] == fused_op.tensors[in]);@@ -501,8 +514,9 @@ bool CheckInputsOutputNoPitchSameDims(const base_params& params) {auto layout = block_layouts.find(params.inputs[i].GetLayout());if (layout != block_layouts.end()) {auto block_size = layout->second;- if (params.inputs[i].Batch().v % block_size.first != 0 || params.inputs[i].Feature().v % block_size.second != 0)+ if (params.inputs[i].Batch().v % block_size.first != 0 || params.inputs[i].Feature().v % block_size.second != 0) {return false;+ }}}// TODO : check for multiple outputsdiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/activation/activation_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/activation/activation_kernel_base.cppindex 1b28681e173..5fd5b3c4691 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/activation/activation_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/activation/activation_kernel_base.cpp@@ -3,10 +3,12 @@//#include "activation_kernel_base.h"-#include "kernel_selector_utils.h"+#include <string>#include <vector>+#include "kernel_selector_utils.h"+namespace kernel_selector {ActivationKernelBase::DispatchData ActivationKernelBase::SetDefault(const activation_params& arg) const {@@ -29,10 +31,10 @@ ActivationKernelBase::DispatchData ActivationKernelBase::SetDefault(const activadispatchData.lws = {1, 16, 16};} else {dispatchData.gws = {out.X().v, out.Y().v * out.Z().v * out.W().v * out.U().v * out.V().v, out.Feature().v * out.Batch().v};- std::vector<std::vector<Tensor::DataChannelName>> dims_by_gws = {{Tensor::DataChannelName::X},- {Tensor::DataChannelName::Y, Tensor::DataChannelName::Z, Tensor::DataChannelName::W,- Tensor::DataChannelName::U, Tensor::DataChannelName::V},- {Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH}};+ std::vector<std::vector<Tensor::DataChannelName>> dims_by_gws = {+ {Tensor::DataChannelName::X},+ {Tensor::DataChannelName::Y, Tensor::DataChannelName::Z, Tensor::DataChannelName::W, Tensor::DataChannelName::U, Tensor::DataChannelName::V},+ {Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH}};dispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, arg.engineInfo, in_layout, out_layout, dims_by_gws);}@@ -73,8 +75,9 @@ bool ActivationKernelBase::Validate(const Params& p) const {const activation_params& orgParams = static_cast<const activation_params&>(p);for (const auto& fused_op : orgParams.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}return true;@@ -107,9 +110,19 @@ KernelsData ActivationKernelBase::GetCommonKernelsData(const Params& params) conGetUpdateDispatchDataFunc(kd);auto& kernel = kd.kernels[0];- FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point,- EXE_MODE_DEFAULT, false, false, 1,- GetFusedPrimitiveInputsCount(params), 1, newParams.is_shape_agnostic);+ FillCLKernelData(kernel,+ dispatchData,+ params.engineInfo,+ kernelName,+ jit,+ entry_point,+ EXE_MODE_DEFAULT,+ false,+ false,+ 1,+ GetFusedPrimitiveInputsCount(params),+ 1,+ newParams.is_shape_agnostic);if (!newParams.inputActivationParams.empty()) {kernel.params.arguments.push_back({ArgumentDescriptor::Types::SLOPE, 0});diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/activation/activation_kernel_opt.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/activation/activation_kernel_opt.cppindex ba3a0600549..8a21f658daa 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/activation/activation_kernel_opt.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/activation/activation_kernel_opt.cpp@@ -82,21 +82,25 @@ bool ActivationKernelOpt::Validate(const Params& p) const {DO_NOT_USE_THIS_KERNEL(p.layerID);}- if (params.outputs[0].GetDims().size() > 5)+ if (params.outputs[0].GetDims().size() > 5) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (params.outputs[0].GetLayout() != params.inputs[0].GetLayout())+ if (params.outputs[0].GetLayout() != params.inputs[0].GetLayout()) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }if (!params.fused_ops.empty() &&- (params.outputs[0].GetLayout() != DataLayout::bfyx && params.outputs[0].GetLayout() != DataLayout::bfzyx))+ (params.outputs[0].GetLayout() != DataLayout::bfyx && params.outputs[0].GetLayout() != DataLayout::bfzyx)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }auto input_dt = params.inputs[0].GetDType();if (input_dt == Datatype::INT8 || input_dt == Datatype::INT32) {for (auto act : params.activations) {- if (act.function == ActivationFunction::ABS)+ if (act.function == ActivationFunction::ABS) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/activation/activation_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/activation/activation_kernel_ref.cppindex 7ca48df183a..45bd54b86e2 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/activation/activation_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/activation/activation_kernel_ref.cpp@@ -61,10 +61,12 @@ KernelsPriority ActivationKernelRef::GetKernelsPriority(const Params& /*params*/}bool ActivationKernelRef::Validate(const Params& p) const {- if (!Parent::Validate(p)) DO_NOT_USE_THIS_KERNEL(p.layerID);+ if (!Parent::Validate(p)) { DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const auto& params = static_cast<const activation_params&>(p);- if (params.inputs[0].GetDims().size() != params.outputs[0].GetDims().size())+ if (params.inputs[0].GetDims().size() != params.outputs[0].GetDims().size()) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_axis.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_axis.cppindex 63733dbf1f0..e549cf767e2 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_axis.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_axis.cpp@@ -92,8 +92,9 @@ bool ArgMaxMinKernelAxis::Validate(const Params& p) const {const arg_max_min_params& params = static_cast<const arg_max_min_params&>(p);if (params.inputs.size() > 1) {- if (params.inputs[1].PitchesDifferFromLogicalDims() || params.outputs[0].PitchesDifferFromLogicalDims())+ if (params.inputs[1].PitchesDifferFromLogicalDims() || params.outputs[0].PitchesDifferFromLogicalDims()) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}return true;@@ -205,13 +206,15 @@ JitConstants ArgMaxMinKernelAxis::GetJitConstants(const arg_max_min_params& paraconst size_t operation_num = getOperationNumber(params);jit.AddConstant(MakeJitConstant("OPERATION_NUM", operation_num));}- if (params.argMaxMinSortType == ArgMaxMinSortType::VALUE)+ if (params.argMaxMinSortType == ArgMaxMinSortType::VALUE) {jit.AddConstant(MakeJitConstant("SORT_BY_VALUE", 1));- else+ } else {jit.AddConstant(MakeJitConstant("SORT_BY_INDEX", 1));+ }- if (params.values_first)+ if (params.values_first) {jit.AddConstant(MakeJitConstant("TOP_K_ORDER", 1));+ }if (params.has_dynamic_tensors() || getSortSize(params) * params.inputs[0].ElementSize() > 4096) {jit.AddConstant(MakeJitConstant("USE_INTERNAL_BUFFERS", 1));diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_opt.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_opt.cppindex 9dbb5d9f667..10d2c44c8d0 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_opt.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_opt.cpp@@ -45,10 +45,11 @@ KernelsData ArgMaxMinKernelOpt::GetKernelsData(const Params& params) const {KernelData kd = KernelData::Default<arg_max_min_params>(params, kernelAmount);for (int i = 0; i < kernelAmount; i++) {DataTensor input;- if (i == 0)+ if (i == 0) {input = orgParams.inputs[0];- else+ } else {input = orgParams.outputs[0];+ }auto newParams = orgParams;newParams.inputs.resize(1);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_topk_radix.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_topk_radix.cppindex 75616aeac09..91501e88c5a 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_topk_radix.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_topk_radix.cpp@@ -70,35 +70,42 @@ ParamsKey ArgMaxMinKernelTopKRadix::GetSupportedKey() const {}bool ArgMaxMinKernelTopKRadix::Validate(const Params& p) const {- if (!ArgMaxMinKernelBase::Validate(p))+ if (!ArgMaxMinKernelBase::Validate(p)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const auto& params = static_cast<const arg_max_min_params&>(p);// Only f16 input for radix approach (bit manipulation)- if (params.inputs[0].GetDType() != Datatype::F16)+ if (params.inputs[0].GetDType() != Datatype::F16) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (params.argMaxMinSortType != ArgMaxMinSortType::VALUE)+ if (params.argMaxMinSortType != ArgMaxMinSortType::VALUE) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const size_t sort_size = GetSortSize(params);- if (sort_size < 2)+ if (sort_size < 2) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }// Combined key uses (i & 0xFFFF) as tiebreaker, so N must fit in 16 bits- if (sort_size > 65535)+ if (sort_size > 65535) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }// PADDED_K (next power of 2 >= topK) must fit in SLM:// sort_keys[PADDED_K] + sort_idxs[PADDED_K] + histogram[256] + scalarssize_t padded_k = 1;- while (padded_k < params.topK)+ while (padded_k < params.topK) {padded_k <<= 1;+ }const size_t slm_needed = padded_k * 2 * sizeof(uint32_t) + 256 * sizeof(uint32_t) + 24;- if (slm_needed > params.engineInfo.maxLocalMemSize)+ if (slm_needed > params.engineInfo.maxLocalMemSize) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}@@ -150,18 +157,21 @@ JitConstants ArgMaxMinKernelTopKRadix::GetJitConstants(const arg_max_min_params&jit.AddConstant(MakeJitConstant("OPERATION_NUM", GetOperationNumber(params)));}- if (params.argMaxMinSortType == ArgMaxMinSortType::VALUE)+ if (params.argMaxMinSortType == ArgMaxMinSortType::VALUE) {jit.AddConstant(MakeJitConstant("SORT_BY_VALUE", 1));+ }- if (params.values_first)+ if (params.values_first) {jit.AddConstant(MakeJitConstant("TOP_K_ORDER", 1));+ }return jit;}KernelsData ArgMaxMinKernelTopKRadix::GetKernelsData(const Params& params) const {- if (!Validate(params))+ if (!Validate(params)) {return {};+ }const auto& orgParams = static_cast<const arg_max_min_params&>(params);auto dispatchData = SetDefault(orgParams);@@ -196,8 +206,9 @@ KernelsPriority ArgMaxMinKernelTopKRadix::GetKernelsPriority(const Params& p) co// For k=1 (pure argmax/argmin) or small sort sizes, the axis kernel's// simple reduction is more efficient — especially when there are many// independent operations that amplify per-WG overhead.- if (params.topK == 1 || sort_size < 256)+ if (params.topK == 1 || sort_size < 256) {return FORCE_PRIORITY_5;+ }return FORCE_PRIORITY_1;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/batch_to_space/batch_to_space_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/batch_to_space/batch_to_space_kernel_base.cppindex 070d544b34c..0fc669aa6a6 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/batch_to_space/batch_to_space_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/batch_to_space/batch_to_space_kernel_base.cpp@@ -3,9 +3,11 @@//#include "batch_to_space_kernel_base.h"-#include "kernel_selector_utils.h"+#include <string>+#include "kernel_selector_utils.h"+namespace kernel_selector {bool BatchToSpaceKernelBase::Validate(const Params& p) const {@@ -15,12 +17,14 @@ bool BatchToSpaceKernelBase::Validate(const Params& p) const {const batch_to_space_params& params = static_cast<const batch_to_space_params&>(p);for (const auto& fused_op : params.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}- if (params.inputs[0].Dimentions() > 6)+ if (params.inputs[0].Dimentions() > 6) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}@@ -30,17 +34,17 @@ CommonDispatchData BatchToSpaceKernelBase::SetDefault(const batch_to_space_paramCommonDispatchData dispatchData;if (out.GetLayout() == DataLayout::b_fs_yx_fsv16 && out.Feature().v % 16 == 0) {- dispatchData.gws = { out.Batch().v, out.Feature().v, out.Y().v * out.X().v };- dispatchData.lws = { 1, 16, 1 };+ dispatchData.gws = {out.Batch().v, out.Feature().v, out.Y().v * out.X().v};+ dispatchData.lws = {1, 16, 1};} else {auto in_layout = params.inputs[0].GetLayout();auto out_layout = out.GetLayout();- std::vector<std::vector<Tensor::DataChannelName>> dims_by_gws = {{ Tensor::DataChannelName::BATCH },- { Tensor::DataChannelName::FEATURE },- { Tensor::DataChannelName::X, Tensor::DataChannelName::Y,- Tensor::DataChannelName::Z, Tensor::DataChannelName::W }};+ std::vector<std::vector<Tensor::DataChannelName>> dims_by_gws = {+ {Tensor::DataChannelName::BATCH},+ {Tensor::DataChannelName::FEATURE},+ {Tensor::DataChannelName::X, Tensor::DataChannelName::Y, Tensor::DataChannelName::Z, Tensor::DataChannelName::W}};- dispatchData.gws = { out.Batch().v, out.Feature().v, out.W().v * out.Z().v * out.Y().v * out.X().v };+ dispatchData.gws = {out.Batch().v, out.Feature().v, out.W().v * out.Z().v * out.Y().v * out.X().v};dispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo, in_layout, out_layout, dims_by_gws);}@@ -112,10 +116,20 @@ KernelsData BatchToSpaceKernelBase::GetCommonKernelsData(const Params& params) cauto& kernel = kd.kernels[0];- FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point,- "", false, false, static_cast<int>(newParams.inputs.size()),- GetFusedPrimitiveInputsCount(params), 1, newParams.is_shape_agnostic);-- return { kd };+ FillCLKernelData(kernel,+ dispatchData,+ params.engineInfo,+ kernelName,+ jit,+ entry_point,+ "",+ false,+ false,+ static_cast<int>(newParams.inputs.size()),+ GetFusedPrimitiveInputsCount(params),+ 1,+ newParams.is_shape_agnostic);++ return {kd};}} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/broadcast/broadcast_kernel_opt.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/broadcast/broadcast_kernel_opt.cppindex 17f63aa5e36..2803facf57d 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/broadcast/broadcast_kernel_opt.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/broadcast/broadcast_kernel_opt.cpp@@ -3,11 +3,12 @@//#include "broadcast_kernel_opt.h"-#include "kernel_selector_utils.h"#include <numeric>#include <vector>+#include "kernel_selector_utils.h"+namespace kernel_selector {static constexpr size_t kOptVecSize = 8;@@ -89,13 +90,13 @@ OptChoices PickStaticChoices(const broadcast_params& p) {CommonDispatchData ComputeDispatch(const OptChoices& c) {CommonDispatchData dispatchData;if (c.x_broadcast_block_write) {- dispatchData.gws = { 16, c.num_rows, 1 };- dispatchData.lws = { 16, 1, 1 };+ dispatchData.gws = {16, c.num_rows, 1};+ dispatchData.lws = {16, 1, 1};} else {const size_t work_items_per_row = (c.out_x + kOptVecSize - 1) / kOptVecSize;const size_t gws_x = std::min(work_items_per_row, kWIsPerRow);- dispatchData.gws = { gws_x, c.num_rows, 1 };- dispatchData.lws = { gws_x, 1, 1 };+ dispatchData.gws = {gws_x, c.num_rows, 1};+ dispatchData.lws = {gws_x, 1, 1};}return dispatchData;}@@ -118,18 +119,21 @@ bool BroadcastKernelOpt::Validate(const Params& params) const {const auto& input = p.inputs[0];const auto& output = p.outputs[0];- if (input.GetLayout() != output.GetLayout())+ if (input.GetLayout() != output.GetLayout()) {return false;+ }- if (!p.fused_ops.empty())+ if (!p.fused_ops.empty()) {return false;+ }// This kernel does pure value-broadcast with no type cast. Broadcast-with-convert// (input dtype != output dtype) is handled by the ref kernel via TO_OUTPUT_TYPE.// The params-key already routes mismatches to ref (this kernel does not enable// different_types); this guard makes that invariant explicit.- if (input.GetDType() != output.GetDType())+ if (input.GetDType() != output.GetDType()) {return false;+ }// The kernel maps output axis i directly to input axis i (no permutation). Two distinct// cases can violate that, so both guards are required:@@ -138,13 +142,15 @@ bool BroadcastKernelOpt::Validate(const Params& params) const {// 2. Explicit mode (axes_mapping set) leaves broadcast_axes empty, so input_order looks// like identity [0,1,2,...], but canonicalize_shapes places the input dim elsewhere —// caught by the is_explicit_mode flag.- if (p.is_explicit_mode)+ if (p.is_explicit_mode) {return false;+ }std::vector<uint16_t> identity_order(p.input_order.size());std::iota(identity_order.begin(), identity_order.end(), 0);- if (p.input_order != identity_order)+ if (p.input_order != identity_order) {return false;+ }if (input.is_dynamic() || output.is_dynamic()) {// Dynamic numpy-mode: the kernel processes one output row (X) per work-group and@@ -158,37 +164,39 @@ bool BroadcastKernelOpt::Validate(const Params& params) const {// broadcast — the only numpy-valid options. Any other statically known X is a// non-row-coherent pattern -> reject.const bool y_known = !input.Y().is_dynamic && !output.Y().is_dynamic;- if (!y_known || input.Y().v != output.Y().v)+ if (!y_known || input.Y().v != output.Y().v) {return false;+ }const bool x_known = !input.X().is_dynamic && !output.X().is_dynamic;return !x_known || input.X().v == output.X().v || input.X().v == 1;}- if (output.X().v < kMinXForOpt)+ if (output.X().v < kMinXForOpt) {return false;+ }// X-broadcast splat: input.X==1, output.X>=32.bool is_x_broadcast = (input.X().v == 1) && (output.X().v > 1);- if (is_x_broadcast)+ if (is_x_broadcast) {return true;+ }// Standard vectorized path requires X dimensions to match.- if (input.X().v != output.X().v)+ if (input.X().v != output.X().v) {return false;+ }// Don't use opt kernel for Y-only broadcast — ref kernel's Y-blocking is faster- bool is_y_only_broadcast = (input.Batch().v == output.Batch().v)- && (input.Feature().v == output.Feature().v)- && (input.Y().v != output.Y().v);- if (is_y_only_broadcast)+ bool is_y_only_broadcast = (input.Batch().v == output.Batch().v) && (input.Feature().v == output.Feature().v) && (input.Y().v != output.Y().v);+ if (is_y_only_broadcast) {return false;+ }// Only use opt kernel when batch-repeat gives benefit (large input, batch broadcast)// Otherwise ref kernel is faster due to lower per-element overheadconst size_t input_bytes = input.LogicalSize() * BytesPerElement(input.GetDType());- const bool has_batch_repeat = (input.Batch().v == 1) && (output.Batch().v > 1)- && (input_bytes > kBatchRepeatInputBytesThreshold);+ const bool has_batch_repeat = (input.Batch().v == 1) && (output.Batch().v > 1) && (input_bytes > kBatchRepeatInputBytesThreshold);return has_batch_repeat;}@@ -205,8 +213,7 @@ void BroadcastKernelOpt::GetUpdateDispatchDataFunc(KernelData& kd) const {OptChoices c;const auto& output = prim_params.outputs[0];c.out_x = output.X().v;- c.num_rows = output.Y().v * output.Z().v * output.W().v- * output.Feature().v * output.Batch().v;+ c.num_rows = output.Y().v * output.Z().v * output.W().v * output.Feature().v * output.Batch().v;const auto dispatchData = ComputeDispatch(c);OPENVINO_ASSERT(kd.kernels.size() == 1, "[GPU] Invalid kernels size for update dispatch data func");kd.kernels[0].params.workGroups.global = dispatchData.gws;@@ -220,8 +227,9 @@ KernelsData BroadcastKernelOpt::GetKernelsData(const Params& params) const {const auto& prim_params = static_cast<const broadcast_params&>(params);- if (!Validate(params))+ if (!Validate(params)) {return {};+ }OptChoices choices;if (!prim_params.has_dynamic_tensors()) {@@ -249,7 +257,12 @@ KernelsData BroadcastKernelOpt::GetKernelsData(const Params& params) const {auto jit = CreateJit(kernelName, cldnn_jit, entry_point);auto& kernel = k_data.kernels[0];- FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point,+ FillCLKernelData(kernel,+ dispatchData,+ params.engineInfo,+ kernelName,+ jit,+ entry_point,EXE_MODE_DEFAULT,false,false,diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_b_fs_yx_fsv16.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_b_fs_yx_fsv16.cppindex 295c992d807..c89b2d37f59 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_b_fs_yx_fsv16.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_b_fs_yx_fsv16.cpp@@ -45,11 +45,13 @@ size_t getTileXY(const concatenation_params& params) {auto tileXYMultiple = input.X().v;bool noInputPad = input.X().pad.Total() == 0;bool noOutputPad = params.outputs[0].X().pad.Total() == 0;- if (noInputPad && noOutputPad)+ if (noInputPad && noOutputPad) {tileXYMultiple = input.X().v * input.Y().v;+ }- while (tileXYMultiple % tileXY != 0)+ while (tileXYMultiple % tileXY != 0) {tileXY /= 2;+ }return tileXY;}@@ -100,8 +102,9 @@ bool ConcatenationKernel_b_fs_yx_fsv16::Validate(const Params& p) const {}}- if (params.axis != ConcatAxis::FEATURE)+ if (params.axis != ConcatAxis::FEATURE) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_b_fs_yx_fsv32.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_b_fs_yx_fsv32.cppindex e3abcd9cbe6..e5453d346f7 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_b_fs_yx_fsv32.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_b_fs_yx_fsv32.cpp@@ -43,8 +43,9 @@ bool ConcatenationKernel_b_fs_yx_fsv32::Validate(const Params& p) const {const concatenation_params& params = static_cast<const concatenation_params&>(p);- if (params.axis != ConcatAxis::FEATURE)+ if (params.axis != ConcatAxis::FEATURE) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }// All inputs must have the same layoutauto same_layout = params.inputs[0].GetLayout();diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_base.cppindex 37e9182db74..46db8e86952 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_base.cpp@@ -2,33 +2,35 @@// SPDX-License-Identifier: Apache-2.0//-#include <iostream>-#include "tensor_type.h"#include "concatenation_kernel_base.h"+#include <algorithm>+#include <iostream>#include <vector>+#include "tensor_type.h"+namespace kernel_selector {Tensor::DataChannelName ConcatenationKernelBase::GetConcatChannel(const concatenation_params& params) const {switch (params.axis) {- case ConcatAxis::X:- return Tensor::DataChannelName::X;- case ConcatAxis::Y:- return Tensor::DataChannelName::Y;- case ConcatAxis::Z:- return Tensor::DataChannelName::Z;- case ConcatAxis::W:- return Tensor::DataChannelName::W;- case ConcatAxis::U:- return Tensor::DataChannelName::U;- case ConcatAxis::V:- return Tensor::DataChannelName::V;- case ConcatAxis::FEATURE:- return Tensor::DataChannelName::FEATURE;- case ConcatAxis::BATCH:- return Tensor::DataChannelName::BATCH;- default:- return Tensor::DataChannelName::X;+ case ConcatAxis::X:+ return Tensor::DataChannelName::X;+ case ConcatAxis::Y:+ return Tensor::DataChannelName::Y;+ case ConcatAxis::Z:+ return Tensor::DataChannelName::Z;+ case ConcatAxis::W:+ return Tensor::DataChannelName::W;+ case ConcatAxis::U:+ return Tensor::DataChannelName::U;+ case ConcatAxis::V:+ return Tensor::DataChannelName::V;+ case ConcatAxis::FEATURE:+ return Tensor::DataChannelName::FEATURE;+ case ConcatAxis::BATCH:+ return Tensor::DataChannelName::BATCH;+ default:+ return Tensor::DataChannelName::X;}}@@ -44,8 +46,9 @@ bool ConcatenationKernelBase::Validate(const Params& p) const {const concatenation_params& params = static_cast<const concatenation_params&>(p);for (const auto& fused_op : params.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}if (GetConcatChannelIndex(params) == -1) {@@ -57,8 +60,14 @@ bool ConcatenationKernelBase::Validate(const Params& p) const {JitConstants ConcatenationKernelBase::GetJitConstants(const concatenation_params& params) const {const auto& inputs = params.original_input_layouts;- bool is_dynamic = std::any_of(inputs.begin(), inputs.end(), [](const DataTensor& t) { return t.is_dynamic(); }) ||- std::any_of(params.outputs.begin(), params.outputs.end(), [](const DataTensor& t) { return t.is_dynamic(); });+ bool is_dynamic = std::any_of(inputs.begin(),+ inputs.end(),+ [](const DataTensor& t) {+ return t.is_dynamic();+ }) ||+ std::any_of(params.outputs.begin(), params.outputs.end(), [](const DataTensor& t) {+ return t.is_dynamic();+ });JitConstants jit = MakeBaseParamsJitConstants(params, !is_dynamic);jit.AddConstants({@@ -84,10 +93,10 @@ ConcatenationKernelBase::DispatchData ConcatenationKernelBase::SetDefault(constconst auto& dims = params.inputs[0].GetDims();auto layout = params.inputs[0].GetLayout();- std::vector<int> idx = { DataTensor::Channelndex(layout, Tensor::DataChannelName::BATCH),- DataTensor::Channelndex(layout, Tensor::DataChannelName::FEATURE),- DataTensor::Channelndex(layout, Tensor::DataChannelName::Y),- DataTensor::Channelndex(layout, Tensor::DataChannelName::X) };+ std::vector<int> idx = {DataTensor::Channelndex(layout, Tensor::DataChannelName::BATCH),+ DataTensor::Channelndex(layout, Tensor::DataChannelName::FEATURE),+ DataTensor::Channelndex(layout, Tensor::DataChannelName::Y),+ DataTensor::Channelndex(layout, Tensor::DataChannelName::X)};// Determine global work sizes.dispatchData.gws[0] = idx[2] != -1 ? dims[idx[2]].v : 1; // Y@@ -178,7 +187,7 @@ KernelsData ConcatenationKernelBase::GetCommonKernelsData(const Params& params)if (is_dynamic) {kernel.params.arguments.push_back({ArgumentDescriptor::Types::SHAPE_INFO, 0});}- kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, (uint32_t) i});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, (uint32_t)i});kernel.params.arguments.push_back({ArgumentDescriptor::Types::OUTPUT, 0});ScalarDescriptor s;diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_depth_bfyx_no_pitch.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_depth_bfyx_no_pitch.cppindex f131f640f7e..1f9cdf54f31 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_depth_bfyx_no_pitch.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_depth_bfyx_no_pitch.cpp@@ -52,8 +52,9 @@ bool ConcatenationKernel_depth_bfyx_no_pitch::Validate(const Params& p) const {for (size_t i = 0; i < params.inputs.size(); i++) {for (size_t b = 0; b < params.outputs[0].Batch().v; b++) {- if ((output_offset + b * params.inputs[i].Batch().pitch) % 2 != 0)+ if ((output_offset + b * params.inputs[i].Batch().pitch) % 2 != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}output_offset += params.inputs[i].Batch().pitch;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_fs_b_yx_fsv32.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_fs_b_yx_fsv32.cppindex 507fdd1748e..47bd3a738a1 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_fs_b_yx_fsv32.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_fs_b_yx_fsv32.cpp@@ -40,8 +40,9 @@ bool ConcatenationKernel_fs_b_yx_fsv32::Validate(const Params& p) const {const concatenation_params& params = static_cast<const concatenation_params&>(p);- if (params.axis != ConcatAxis::FEATURE)+ if (params.axis != ConcatAxis::FEATURE) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }// all inputs have to have same layoutauto same_layout = params.inputs[0].GetLayout();diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convert_color/convert_color_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convert_color/convert_color_kernel_base.cppindex 7bcff0344ef..68cda2a1e14 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convert_color/convert_color_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convert_color/convert_color_kernel_base.cpp@@ -15,8 +15,9 @@ bool ConvertColorKernelBase::Validate(const Params& p) const {const convert_color_params& params = static_cast<const convert_color_params&>(p);- if (params.inputs[0].Dimentions() > 4)+ if (params.inputs[0].Dimentions() > 4) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv16.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv16.cppindex 011f5486f18..4eedd25d650 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv16.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv16.cpp@@ -3,10 +3,12 @@//#include "convolution_kernel_b_fs_yx_fsv16.h"++#include <algorithm>+#include <vector>+#include "kernel_selector_utils.h"#include "reorder/reorder_kernel_base.h"-#include <vector>-#include <algorithm>namespace kernel_selector {@@ -23,38 +25,39 @@ bool post_reorder_fused(const convolution_params& params) {} // namespaceConvolutionKernel_b_fs_yx_fsv16::ConvolutionKernel_b_fs_yx_fsv16() : ConvolutionKernelBase("convolution_gpu_bfyx_f16") {- std::vector<size_t> outputBlockWidths = { 2, 4, 8 };+ std::vector<size_t> outputBlockWidths = {2, 4, 8};std::vector<std::string> executionModes = ConvolutionKernelBase::autoTuneOptions;for (auto w : outputBlockWidths) {for (auto exeMode : executionModes) {- autoTuneOptions.emplace_back(AutoTuneOption{ w, exeMode });+ autoTuneOptions.emplace_back(AutoTuneOption{w, exeMode});}}}-ConvolutionKernel_b_fs_yx_fsv16::AutoTuneOption ConvolutionKernel_b_fs_yx_fsv16::GetAutoTuneOptions(const Params& params,- int /*autoTuneIndex*/) const {+ConvolutionKernel_b_fs_yx_fsv16::AutoTuneOption ConvolutionKernel_b_fs_yx_fsv16::GetAutoTuneOptions(const Params& params, int /*autoTuneIndex*/) const {const convolution_params& cp = static_cast<const convolution_params&>(params);auto x = cp.outputs[0].X().v;auto f = cp.outputs[0].Feature().v;if (x * f <= 256) {- if (x <= 8 || x * f <= 128)- return { 2, EXE_MODE_DEFAULT };+ if (x <= 8 || x * f <= 128) {+ return {2, EXE_MODE_DEFAULT};+ }return {4, EXE_MODE_DEFAULT};}if (x * f <= 1536) {- return { 4, EXE_MODE_DEFAULT };+ return {4, EXE_MODE_DEFAULT};}- if (x >= 8 && x < 12 && x * f < 2600)+ if (x >= 8 && x < 12 && x * f < 2600) {return {4, EXE_MODE_DEFAULT};- if (x < 12 && x * f < 8192)+ }+ if (x < 12 && x * f < 8192) {return {8, EXE_MODE_DEFAULT};+ }return {8, EXE_MODE_AGE_BASED};}-float ConvolutionKernel_b_fs_yx_fsv16::EstimateOccupancy(const convolution_params& params,- const ConvolutionTuningData& tuning_data) const {+float ConvolutionKernel_b_fs_yx_fsv16::EstimateOccupancy(const convolution_params& params, const ConvolutionTuningData& tuning_data) const {auto tuneOptions = GetAutoTuneOptions(params, 0);auto blockWidth = tuneOptions.blockWidth;@@ -77,13 +80,15 @@ ConvolutionKernel_b_fs_yx_fsv16::ConvolutionTuningData ConvolutionKernel_b_fs_yxsize_t max_slm_div_factor = params.engineInfo.maxWorkGroupSize / tuning_data.sub_group_size;- bool slm_exception = params.outputs[0].X().v == 3 && params.outputs[0].Y().v == 3 && params.outputs[0].ElementSize() == 4- && params.outputs[0].Feature().v <= 512;+ bool slm_exception =+ params.outputs[0].X().v == 3 && params.outputs[0].Y().v == 3 && params.outputs[0].ElementSize() == 4 && params.outputs[0].Feature().v <= 512;- if (params.engineInfo.deviceType == dev_type::integrated_gpu && params.engineInfo.supports_imad && !slm_exception)+ if (params.engineInfo.deviceType == dev_type::integrated_gpu && params.engineInfo.supports_imad && !slm_exception) {while (ic_blocks % (tuning_data.slm_div_factor * 2) == 0 && (tuning_data.slm_div_factor * 2 <= max_slm_div_factor) &&- EstimateOccupancy(params, tuning_data) < 4.0)+ EstimateOccupancy(params, tuning_data) < 4.0) {tuning_data.slm_div_factor *= 2;+ }+ }tuning_data.work_group_size = tuning_data.slm_div_factor * tuning_data.sub_group_size;@@ -128,8 +133,7 @@ DeviceFeaturesKey ConvolutionKernel_b_fs_yx_fsv16::get_required_device_features_return k;}-ConvolutionKernelBase::DispatchData ConvolutionKernel_b_fs_yx_fsv16::SetDefault(const convolution_params& params,- int autoTuneIndex) const {+ConvolutionKernelBase::DispatchData ConvolutionKernel_b_fs_yx_fsv16::SetDefault(const convolution_params& params, int autoTuneIndex) const {DispatchData dispatchData = ConvolutionKernelBase::SetDefault(params);ConvolutionTuningData tuning_data = GetTuningParams(params);@@ -158,7 +162,7 @@ ConvolutionKernelBase::DispatchData ConvolutionKernel_b_fs_yx_fsv16::SetDefault(KernelsPriority ConvolutionKernel_b_fs_yx_fsv16::GetKernelsPriority(const Params& params) const {const auto& p = static_cast<const convolution_params&>(params);- return p.outputs[0].Batch().v == 1 ? FORCE_PRIORITY_2 : FORCE_PRIORITY_7;+ return p.outputs[0].Batch().v == 1 ? FORCE_PRIORITY_2 : FORCE_PRIORITY_7;}bool ConvolutionKernel_b_fs_yx_fsv16::Validate(const Params& p) const {@@ -179,43 +183,42 @@ bool ConvolutionKernel_b_fs_yx_fsv16::Validate(const Params& p) const {auto multipleGroupsInputPreload = (tuning_data.feature_block_size % outFeaturesPerGroup == 0) &&(tuning_data.feature_block_size % inFeaturesPerGroup == 0) &&(tuning_data.feature_block_size / outFeaturesPerGroup > 1) &&- (tuning_data.feature_block_size / inFeaturesPerGroup > 1) &&- (outFeaturesPerGroup != 1) &&- (inFeaturesPerGroup != 1);+ (tuning_data.feature_block_size / inFeaturesPerGroup > 1) && (outFeaturesPerGroup != 1) && (inFeaturesPerGroup != 1);auto grouped = inFeaturesPerGroup % tuning_data.sub_group_size == 0 &&(outFeaturesPerGroup % tuning_data.sub_group_size == 0 || tuning_data.sub_group_size % outFeaturesPerGroup == 0);- if (!multipleGroupsInputPreload && !grouped)+ if (!multipleGroupsInputPreload && !grouped) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}// Check that padding before features doesn't miss-align the blocks- if (input.Feature().pad.before % tuning_data.feature_block_size != 0 || output.Feature().pad.before % tuning_data.feature_block_size != 0)+ if (input.Feature().pad.before % tuning_data.feature_block_size != 0 || output.Feature().pad.before % tuning_data.feature_block_size != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }// Not supporting batch padding for different format (reorder-fused case)if (input.GetLayout() == DataLayout::b_fs_yx_fsv16 && output.GetLayout() == DataLayout::bfyx) {- if (output.Batch().pad.before != 0 || output.Batch().pad.after != 0)+ if (output.Batch().pad.before != 0 || output.Batch().pad.after != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}- if (!params.bias.empty() && params.bias[0].GetDType() != input.GetDType())+ if (!params.bias.empty() && params.bias[0].GetDType() != input.GetDType()) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}-JitConstants ConvolutionKernel_b_fs_yx_fsv16::GetJitConstants(const convolution_params& params,- const DispatchData& dispatchData) const {+JitConstants ConvolutionKernel_b_fs_yx_fsv16::GetJitConstants(const convolution_params& params, const DispatchData& dispatchData) const {auto input = params.inputs[0];auto output = params.outputs[0];auto jit = Parent::GetJitConstants(params, dispatchData);ConvolutionTuningData tuning_data = GetTuningParams(params);- if (post_reorder_fused(params) &&- input.GetLayout() == DataLayout::b_fs_yx_fsv16 &&- output.GetLayout() == DataLayout::bfyx) {+ if (post_reorder_fused(params) && input.GetLayout() == DataLayout::b_fs_yx_fsv16 && output.GetLayout() == DataLayout::bfyx) {jit.AddConstant(MakeJitConstant("OUTPUT_FORMAT_BFYX", 1));}@@ -226,42 +229,47 @@ JitConstants ConvolutionKernel_b_fs_yx_fsv16::GetJitConstants(const convolution_orig_output_layout = params.fused_ops.back().GetOpParams<reorder_fuse_params>()->input_layout;}auto input_dt = GetActivationType(params);- FusedOpsConfiguration conf_vec = { "_VEC",- {"b", "(feature_block * 16)", "y", "x"},- "dst",- input_dt,- blockWidth,- LoadType::LT_ALIGNED_READ,- BoundaryCheck::ENABLED,- IndexType::TENSOR_COORD,- Tensor::DataChannelName::X,- {}, false, "", orig_output_layout };- FusedOpsConfiguration conf_scalar = { "_SCALAR",- {"b", "(feature_block * 16)", "y", "(x + i)"},- "dst[i]",- input_dt,- 1,- LoadType::LT_ALIGNED_READ,- BoundaryCheck::ENABLED,- IndexType::TENSOR_COORD,- Tensor::DataChannelName::X,- {}, false, "", orig_output_layout };+ FusedOpsConfiguration conf_vec = {"_VEC",+ {"b", "(feature_block * 16)", "y", "x"},+ "dst",+ input_dt,+ blockWidth,+ LoadType::LT_ALIGNED_READ,+ BoundaryCheck::ENABLED,+ IndexType::TENSOR_COORD,+ Tensor::DataChannelName::X,+ {},+ false,+ "",+ orig_output_layout};+ FusedOpsConfiguration conf_scalar = {"_SCALAR",+ {"b", "(feature_block * 16)", "y", "(x + i)"},+ "dst[i]",+ input_dt,+ 1,+ LoadType::LT_ALIGNED_READ,+ BoundaryCheck::ENABLED,+ IndexType::TENSOR_COORD,+ Tensor::DataChannelName::X,+ {},+ false,+ "",+ orig_output_layout};jit.Merge(MakeFusedOpsJitConstants(params, {conf_vec, conf_scalar}));}- size_t input_line_size = std::min(params.stride.x * (blockWidth - 1) + (params.weights.X().v - 1)*params.dilation.x + 1,- input.X().v + input.X().pad.Total());+ size_t input_line_size =+ std::min(params.stride.x * (blockWidth - 1) + (params.weights.X().v - 1) * params.dilation.x + 1, input.X().v + input.X().pad.Total());auto outFeaturesPerGroup = output.Feature().v / params.groups;auto inFeaturesPerGroup = input.Feature().v / params.groups;- auto multipleGroupsInputPreload = (params.groups > 1) &&- (tuning_data.feature_block_size % outFeaturesPerGroup == 0) &&+ auto multipleGroupsInputPreload = (params.groups > 1) && (tuning_data.feature_block_size % outFeaturesPerGroup == 0) &&(tuning_data.feature_block_size % inFeaturesPerGroup == 0) &&- (tuning_data.feature_block_size / outFeaturesPerGroup > 1) &&- (tuning_data.feature_block_size / inFeaturesPerGroup > 1);+ (tuning_data.feature_block_size / outFeaturesPerGroup > 1) && (tuning_data.feature_block_size / inFeaturesPerGroup > 1);- if (multipleGroupsInputPreload)+ if (multipleGroupsInputPreload) {jit.AddConstant(MakeJitConstant("MULTIPLE_GROUPS_INPUT_PRELOAD", 1));+ }jit.AddConstant(MakeJitConstant("OUTPUT_X_BLOCK_SIZE", blockWidth));jit.AddConstant(MakeJitConstant("INPUT_LINE_SIZE", input_line_size));@@ -280,8 +288,7 @@ JitConstants ConvolutionKernel_b_fs_yx_fsv16::GetJitConstants(const convolution_return jit;}-KernelsData ConvolutionKernel_b_fs_yx_fsv16::GetTunedKernelsDataByIndex(const Params& params,- const int autoTuneIndex) const {+KernelsData ConvolutionKernel_b_fs_yx_fsv16::GetTunedKernelsDataByIndex(const Params& params, const int autoTuneIndex) const {auto tuneOptions = GetAutoTuneOptions(params, autoTuneIndex);return GetCommonKernelsData(params, tuneOptions.exeMode, autoTuneIndex);}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv16_1x1.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv16_1x1.cppindex 8e7e70734e3..8db8bdfdbc7 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv16_1x1.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv16_1x1.cpp@@ -3,13 +3,15 @@//#include "convolution_kernel_b_fs_yx_fsv16_1x1.h"-#include "kernel_selector_utils.h"+#include <string>+#include "kernel_selector_utils.h"+namespace kernel_selector {ConvolutionKernel_b_fs_yx_fsv16_1x1::ConvolutionKernel_b_fs_yx_fsv16_1x1() : ConvolutionKernelBase("convolution_gpu_bfyx_f16_1x1") {- std::vector<size_t> outputBlockWidths = { 1, 2, 4, 8 };+ std::vector<size_t> outputBlockWidths = {1, 2, 4, 8};std::vector<std::string> executionModes = ConvolutionKernelBase::autoTuneOptions;for (auto w : outputBlockWidths) {@@ -27,15 +29,16 @@ ConvolutionKernel_b_fs_yx_fsv16_1x1::AutoTuneOption ConvolutionKernel_b_fs_yx_fsauto f = params.outputs[0].Feature().v;if (x == 1 && y == 1) {- return { 1, EXE_MODE_DEFAULT };+ return {1, EXE_MODE_DEFAULT};}if (x * f <= 256) {- if (x < 8 || x * f <= 128)- return { 2, EXE_MODE_DEFAULT };+ if (x < 8 || x * f <= 128) {+ return {2, EXE_MODE_DEFAULT};+ }return {4, EXE_MODE_DEFAULT};}if (x * f <= 1536) {- return { 4, EXE_MODE_DEFAULT };+ return {4, EXE_MODE_DEFAULT};}return {8, EXE_MODE_DEFAULT};@@ -44,8 +47,7 @@ ConvolutionKernel_b_fs_yx_fsv16_1x1::AutoTuneOption ConvolutionKernel_b_fs_yx_fsreturn {8, EXE_MODE_DEFAULT};}-float ConvolutionKernel_b_fs_yx_fsv16_1x1::EstimateOccupancy(const convolution_params& params,- const ConvolutionTuningData& tuning_data) const {+float ConvolutionKernel_b_fs_yx_fsv16_1x1::EstimateOccupancy(const convolution_params& params, const ConvolutionTuningData& tuning_data) const {auto tuneOptions = GetAutoTuneOptions(params, 0);auto blockWidth = tuneOptions.blockWidth;@@ -72,8 +74,9 @@ ConvolutionKernel_b_fs_yx_fsv16_1x1::ConvolutionTuningData ConvolutionKernel_b_fsize_t max_slm_div_factor = params.engineInfo.maxWorkGroupSize / tuning_data.sub_group_size;while (ic_blocks % (tuning_data.slm_div_factor * 2) == 0 && (tuning_data.slm_div_factor * 2 <= max_slm_div_factor) &&- EstimateOccupancy(params, tuning_data) < 4.0)+ EstimateOccupancy(params, tuning_data) < 4.0) {tuning_data.slm_div_factor *= 2;+ }}}@@ -108,8 +111,7 @@ DeviceFeaturesKey ConvolutionKernel_b_fs_yx_fsv16_1x1::get_required_device_featureturn k;}-ConvolutionKernelBase::DispatchData ConvolutionKernel_b_fs_yx_fsv16_1x1::SetDefault(const convolution_params& params,- int autoTuneIndex) const {+ConvolutionKernelBase::DispatchData ConvolutionKernel_b_fs_yx_fsv16_1x1::SetDefault(const convolution_params& params, int autoTuneIndex) const {DispatchData dispatchData = ConvolutionKernelBase::SetDefault(params);ConvolutionTuningData tuning_data = GetTuningParams(params);@@ -178,15 +180,14 @@ bool ConvolutionKernel_b_fs_yx_fsv16_1x1::Validate(const Params& p) const {const bool bPadding = (!input.Feature().pad.is_dynamic && input.Feature().pad.before % tuning_data.feature_block_size != 0) ||(!output.Feature().pad.is_dynamic && output.Feature().pad.before % tuning_data.feature_block_size != 0);- if (bOutputSizes || bFilterSize || bStride || bPadding) {+ if (bOutputSizes || bFilterSize || bStride || bPadding) {DO_NOT_USE_THIS_KERNEL(p.layerID);}return true;}-JitConstants ConvolutionKernel_b_fs_yx_fsv16_1x1::GetJitConstants(const convolution_params& params,- const DispatchData& dispatchData) const {+JitConstants ConvolutionKernel_b_fs_yx_fsv16_1x1::GetJitConstants(const convolution_params& params, const DispatchData& dispatchData) const {auto jit = Parent::GetJitConstants(params, dispatchData);ConvolutionTuningData tuning_data = GetTuningParams(params);@@ -194,16 +195,16 @@ JitConstants ConvolutionKernel_b_fs_yx_fsv16_1x1::GetJitConstants(const convolutauto blockWidth = dispatchData.cldnnStyle.blockWidth;if (!params.fused_ops.empty()) {auto input_dt = GetUnitType(params);- FusedOpsConfiguration conf_vec = { "_VEC",- {"b", "(feature_block * 16)", "y", "x"},- "dst",- input_dt,- blockWidth,- LoadType::LT_ALIGNED_READ,- BoundaryCheck::ENABLED,- IndexType::TENSOR_COORD,- Tensor::DataChannelName::X };- FusedOpsConfiguration conf_scalar1 = { "_SCALAR",+ FusedOpsConfiguration conf_vec = {"_VEC",+ {"b", "(feature_block * 16)", "y", "x"},+ "dst",+ input_dt,+ blockWidth,+ LoadType::LT_ALIGNED_READ,+ BoundaryCheck::ENABLED,+ IndexType::TENSOR_COORD,+ Tensor::DataChannelName::X};+ FusedOpsConfiguration conf_scalar1 = {"_SCALAR",{"b", "(feature_block * 16)", "yi", "xi"},"dst[i]",input_dt,@@ -211,8 +212,8 @@ JitConstants ConvolutionKernel_b_fs_yx_fsv16_1x1::GetJitConstants(const convolutLoadType::LT_ALIGNED_READ,BoundaryCheck::ENABLED,IndexType::TENSOR_COORD,- Tensor::DataChannelName::X };- FusedOpsConfiguration conf_scalar2 = { "_SCALAR_B1",+ Tensor::DataChannelName::X};+ FusedOpsConfiguration conf_scalar2 = {"_SCALAR_B1",{"b", "(feature_block * 16)", "0", "0"},"dst",input_dt,@@ -220,8 +221,8 @@ JitConstants ConvolutionKernel_b_fs_yx_fsv16_1x1::GetJitConstants(const convolutLoadType::LT_ALIGNED_READ,BoundaryCheck::ENABLED,IndexType::TENSOR_COORD,- Tensor::DataChannelName::X };- jit.Merge(MakeFusedOpsJitConstants(params, { conf_vec, conf_scalar1, conf_scalar2 }));+ Tensor::DataChannelName::X};+ jit.Merge(MakeFusedOpsJitConstants(params, {conf_vec, conf_scalar1, conf_scalar2}));}jit.AddConstant(MakeJitConstant("X_BLOCK_SIZE", blockWidth));@@ -241,10 +242,7 @@ JitConstants ConvolutionKernel_b_fs_yx_fsv16_1x1::GetJitConstants(const convolutif (t.PitchesDifferFromLogicalDims()) {padded_output = true;}- if ((t.X().v > 1) ||- (t.Y().v > 1) ||- (t.Z().v > 1) ||- (t.W().v > 1)) {+ if ((t.X().v > 1) || (t.Y().v > 1) || (t.Z().v > 1) || (t.W().v > 1)) {non_unit_fused_op_spatial = true;}}@@ -307,7 +305,7 @@ JitConstants ConvolutionKernel_b_fs_yx_fsv16_1x1::GetJitConstants(const convolutreturn jit;}- KernelsData ConvolutionKernel_b_fs_yx_fsv16_1x1::GetKernelsData(const Params& params) const {+KernelsData ConvolutionKernel_b_fs_yx_fsv16_1x1::GetKernelsData(const Params& params) const {size_t num_kernels = params.is_shape_agnostic ? 4 : 1;KernelData kd = KernelData::Default<convolution_params>(params, num_kernels);convolution_params& newParams = *static_cast<convolution_params*>(kd.params.get());@@ -317,12 +315,7 @@ JitConstants ConvolutionKernel_b_fs_yx_fsv16_1x1::GetJitConstants(const convolut}auto preferredWeightsLayout = GetPreferredWeightsLayout(newParams);- bool succeed = UpdateWeightsParams(newParams,- preferredWeightsLayout,- kd.weightsReorderParams,- GetSupportedKey(),- newParams.groups,- newParams.transposed);+ bool succeed = UpdateWeightsParams(newParams, preferredWeightsLayout, kd.weightsReorderParams, GetSupportedKey(), newParams.groups, newParams.transposed);bool bSupportedWeightsLayout = newParams.weights.GetLayout() == preferredWeightsLayout;const bool bWeightsOK = bSupportedWeightsLayout || newParams.allowStaticInputReordering;@@ -333,13 +326,15 @@ JitConstants ConvolutionKernel_b_fs_yx_fsv16_1x1::GetJitConstants(const convolutif (NeedPaddedInput()) {if (newParams.has_dynamic_inputs()) {- if (!CheckConvolutionExplicitPaddings(newParams))+ if (!CheckConvolutionExplicitPaddings(newParams)) {return {};+ }} else {kd.reorderInput = ConvolutionUpdateInputParams(newParams);- if (kd.reorderInput && !newParams.allowInputReordering)+ if (kd.reorderInput && !newParams.allowInputReordering) {return {};+ }}}@@ -372,34 +367,40 @@ JitConstants ConvolutionKernel_b_fs_yx_fsv16_1x1::GetJitConstants(const convolutauto& kernel = kd.kernels[i];FillCLKernelData(kernel,- dispatchData,- params.engineInfo,- finalKernelName,- jit,- entryPoint,- EXE_MODE_DEFAULT,- true,- !newParams.bias.empty(),- 1, 0, 1,- newParams.is_shape_agnostic);+ dispatchData,+ params.engineInfo,+ finalKernelName,+ jit,+ entryPoint,+ EXE_MODE_DEFAULT,+ true,+ !newParams.bias.empty(),+ 1,+ 0,+ 1,+ newParams.is_shape_agnostic);if (newParams.deformable_mode) {kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 1});- if (newParams.deformable_mask_enabled)+ if (newParams.deformable_mask_enabled) {kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 2});+ }}- if (!newParams.weights_zero_points.empty())+ if (!newParams.weights_zero_points.empty()) {kernel.params.arguments.push_back({ArgumentDescriptor::Types::WEIGHTS_ZERO_POINTS, 1});- if (!newParams.activations_zero_points.empty())+ }+ if (!newParams.activations_zero_points.empty()) {kernel.params.arguments.push_back({ArgumentDescriptor::Types::ACTIVATIONS_ZERO_POINTS, 1});- if (!newParams.compensation.empty())+ }+ if (!newParams.compensation.empty()) {kernel.params.arguments.push_back({ArgumentDescriptor::Types::COMPENSATION, 1});+ }uint32_t fused_deps_total = 0;for (auto& fused_dep : newParams.fused_ops) {for (int i = 0; i < static_cast<int>(fused_dep.dep_size); i++) {- kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INPUT_OF_FUSED_PRIMITIVE, fused_deps_total });+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT_OF_FUSED_PRIMITIVE, fused_deps_total});fused_deps_total++;}}@@ -407,7 +408,7 @@ JitConstants ConvolutionKernel_b_fs_yx_fsv16_1x1::GetJitConstants(const convolutkd.autoTuneIndex = -1;return {kd};- }+}void ConvolutionKernel_b_fs_yx_fsv16_1x1::GetUpdateDispatchDataFunc(KernelData& kd) const {if (kd.kernels.size() == 1) {diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv16_depthwise.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv16_depthwise.cppindex 66b64f728d3..f1f0a0ef19e 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv16_depthwise.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv16_depthwise.cpp@@ -48,15 +48,18 @@ DeviceFeaturesKey ConvolutionKernel_b_fs_yx_fsv16_depthwise::get_required_devicebool ConvolutionKernel_b_fs_yx_fsv16_depthwise::Validate(const Params& p) const {const convolution_params& cp = static_cast<const convolution_params&>(p);- if (cp.groups == 1)+ if (cp.groups == 1) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (cp.inputs[0].Feature().v != cp.groups || cp.outputs[0].Feature().v != cp.groups)+ if (cp.inputs[0].Feature().v != cp.groups || cp.outputs[0].Feature().v != cp.groups) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }// Check that padding features doesn't miss-align the blocks- if (cp.inputs[0].Feature().pad.before % feature_block_size != 0 || cp.outputs[0].Feature().pad.before % feature_block_size != 0)+ if (cp.inputs[0].Feature().pad.before % feature_block_size != 0 || cp.outputs[0].Feature().pad.before % feature_block_size != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv16_imad_1x1.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv16_imad_1x1.cppindex 206500e0382..e32ff95a4d8 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv16_imad_1x1.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv16_imad_1x1.cpp@@ -24,11 +24,13 @@ Convolution_kernel_b_fs_yx_fsv16_imad_1x1::Convolution_kernel_b_fs_yx_fsv16_imadconstexpr size_t max_block_elements = 32;for (size_t bs = 1; bs <= 2 * simd; ++bs) {for (size_t bf = 1; bf <= 4; ++bf) {- if (bs * bf > max_block_elements)+ if (bs * bf > max_block_elements) {continue;+ }for (size_t split = 1; split <= 8; ++split) {- if (bf > split)+ if (bf > split) {continue;+ }for (auto exe : ConvolutionKernelBase::autoTuneOptions) {all_tune_params.push_back(AutoTuneParams{ bs, bf, split, exe });}@@ -170,8 +172,9 @@ KernelsPriority Convolution_kernel_b_fs_yx_fsv16_imad_1x1::GetKernelsPriority(co}// Better to use kernel with 4 input features in a loop- if (static_cast<float>(p.weights.IFM().v) / static_cast<float>(Align(p.weights.IFM().v, fsv)) < 0.5f)+ if (static_cast<float>(p.weights.IFM().v) / static_cast<float>(Align(p.weights.IFM().v, fsv)) < 0.5f) {priority = FORCE_PRIORITY_4;+ }return priority;}@@ -190,25 +193,30 @@ bool Convolution_kernel_b_fs_yx_fsv16_imad_1x1::Validate(const Params& params) cDO_NOT_USE_THIS_KERNEL(params.layerID);}- if (conv_params.groups != 1)+ if (conv_params.groups != 1) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }if (conv_params.quantization == QuantizationType::ASYMMETRIC_DATA_AND_WEIGHTS) {if ((conv_params.activations_zero_points.empty() || conv_params.weights_zero_points.empty()) &&- (conv_params.compensation.empty()))+ (conv_params.compensation.empty())) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }} else if (conv_params.quantization == QuantizationType::ASYMMETRIC_DATA) {if ((conv_params.activations_zero_points.empty()) &&- (conv_params.compensation.empty()))+ (conv_params.compensation.empty())) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }} else if (conv_params.quantization == QuantizationType::ASYMMETRIC_WEIGHTS) {- if (conv_params.weights_zero_points.empty())+ if (conv_params.weights_zero_points.empty()) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }} else {if (!conv_params.activations_zero_points.empty() ||!conv_params.weights_zero_points.empty() ||- !conv_params.compensation.empty())+ !conv_params.compensation.empty()) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}return true;@@ -217,10 +225,12 @@ bool Convolution_kernel_b_fs_yx_fsv16_imad_1x1::Validate(const Params& params) cWeightsLayout Convolution_kernel_b_fs_yx_fsv16_imad_1x1::GetPreferredWeightsLayout(const convolution_params& params) const {// TODO Auto tune index is needed in GetPreferredWeightsLayout to select correct weights layoutauto tparams = GetAutoTuneParams(params, -1);- if (tparams.out_block_features == 2)+ if (tparams.out_block_features == 2) {return WeightsLayout::os_is_zyx_osv32_isv16;- if (tparams.out_block_features == 4)+ }+ if (tparams.out_block_features == 4) {return WeightsLayout::os_is_zyx_osv64_isv16;+ }return WeightsLayout::os_is_yx_osv16_isv16;}@@ -238,8 +248,9 @@ Convolution_kernel_b_fs_yx_fsv16_imad_1x1::GetAutoTuneParams(const convolution_psize_t total_spatial = params.outputs[0].X().v * params.outputs[0].Y().v;// Try two features per work-item- if (params.outputs[0].Feature().v % 32 == 0 || params.outputs[0].Feature().v > 32 * 2)+ if (params.outputs[0].Feature().v % 32 == 0 || params.outputs[0].Feature().v > 32 * 2) {block_features = 2;+ }// Non strict inequality here leads to some regressions, ie: [1, 64, 19, 19] (*) [384, 64, 1, 1]bool can_split = params.weights.IFM().v > 4 * fsv;@@ -266,11 +277,13 @@ Convolution_kernel_b_fs_yx_fsv16_imad_1x1::GetAutoTuneParams(const convolution_pbool c_block_write = (overhang == 0 && !output_pad) || params.outputs[0].X().v % block == 0;// Kernel work-around for spills/inefficient loop order- if (can_split && !c_occupancy && block > 14 && block_features > 1)+ if (can_split && !c_occupancy && block > 14 && block_features > 1) {break;+ }- if (preserve_occupancy && !c_occupancy)+ if (preserve_occupancy && !c_occupancy) {break;+ }if (overhang <= min_overhang && (!block_write_found || c_block_write)) {best_block = block;@@ -291,8 +304,9 @@ Convolution_kernel_b_fs_yx_fsv16_imad_1x1::GetAutoTuneParams(const convolution_pstd::vector<size_t> check_split = { 4 };size_t ifm_blocks = CeilDiv(params.weights.IFM().v, fsv);for (auto split : check_split) {- if (split > ifm_blocks)+ if (split > ifm_blocks) {break;+ }auto tmp_tune = AutoTuneParams{ block_spatial, block_features, split, exe_mode };@@ -306,8 +320,9 @@ Convolution_kernel_b_fs_yx_fsv16_imad_1x1::GetAutoTuneParams(const convolution_p}// Increasing split will only increase memory and work-group size, don't check bigger split- if (!c_slm || !c_lws || c_occupancy)+ if (!c_slm || !c_lws || c_occupancy) {break;+ }}}}@@ -327,8 +342,9 @@ Convolution_kernel_b_fs_yx_fsv16_imad_1x1::GetAutoTuneParams(const convolution_pif (c_mul) {block_spatial = block;- if (c_occupancy)+ if (c_occupancy) {break;+ }}}}@@ -378,8 +394,9 @@ KernelsData Convolution_kernel_b_fs_yx_fsv16_imad_1x1::GetTunedKernelsDataByIndeint autoTuneIndex) const {auto conv_params = static_cast<const convolution_params&>(params);auto tune_params = GetAutoTuneParams(conv_params, autoTuneIndex);- if (!ValidateAutoTuneParams(conv_params, tune_params))+ if (!ValidateAutoTuneParams(conv_params, tune_params)) {return {};+ }return GetCommonKernelsData(params, tune_params.exe_mode, autoTuneIndex);}@@ -393,8 +410,9 @@ KernelsData Convolution_kernel_b_fs_yx_fsv16_imad_1x1::GetKernelsDataForAutoTunefor (size_t i = 0; i < all_tune_params.size(); i++) {auto tune_params = GetAutoTuneParams(conv_params, static_cast<int>(i));- if (!ValidateAutoTuneParams(conv_params, tune_params))+ if (!ValidateAutoTuneParams(conv_params, tune_params)) {continue;+ }KernelsData kd = GetTunedKernelsDataByIndex(params, static_cast<int>(i));if (!kd.empty()) {res.emplace_back(kd[0]);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv4_int8.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv4_int8.cppindex fbba283466c..8e1e535f3ad 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv4_int8.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv4_int8.cpp@@ -3,9 +3,10 @@//#include "convolution_kernel_b_fs_yx_fsv4_int8.h"-#include <vector>-#include <utility>+#include <algorithm>+#include <utility>+#include <vector>namespace kernel_selector {constexpr size_t sub_group_size = 16;@@ -58,8 +59,9 @@ ConvolutionKernelBase::DispatchData ConvolutionKernel_b_fs_yx_fsv4_int8::SetDefaKernelsPriority ConvolutionKernel_b_fs_yx_fsv4_int8::GetKernelsPriority(const Params& params) const {const auto& p = static_cast<const convolution_params&>(params);- if (p.outputs[0].X().v > 512 && p.filterSize.x == 5 && p.filterSize.y == 5)+ if (p.outputs[0].X().v > 512 && p.filterSize.x == 5 && p.filterSize.y == 5) {return FORCE_PRIORITY_2;+ }return FORCE_PRIORITY_9;}@@ -69,8 +71,9 @@ bool ConvolutionKernel_b_fs_yx_fsv4_int8::Validate(const Params& p) const {}const auto& params = static_cast<const convolution_params&>(p);- if ((params.inputs[0].X().v % 64) != 0u)+ if ((params.inputs[0].X().v % 64) != 0u) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }bool bFilterSize = (params.filterSize.x == 5 && params.filterSize.y == 5) ||(params.filterSize.x == 3 && params.filterSize.y == 3 && (params.inputs[0].Feature().v % 4) == 0) ||@@ -95,15 +98,15 @@ JitConstants ConvolutionKernel_b_fs_yx_fsv4_int8::GetJitConstants(const convolutif (!params.fused_ops.empty()) {auto input_dt = GetActivationType(params);- FusedOpsConfiguration conf0 = { "_0", {"batch", "FILTER_OFM_MAX * iter + ofm + 0", "idy", "idx"}, "res0", input_dt, 1 };- FusedOpsConfiguration conf1 = { "_1", {"batch", "FILTER_OFM_MAX * iter + ofm + 1", "idy", "idx"}, "res1", input_dt, 1 };- FusedOpsConfiguration conf2 = { "_2", {"batch", "FILTER_OFM_MAX * iter + ofm + 2", "idy", "idx"}, "res2", input_dt, 1 };- FusedOpsConfiguration conf3 = { "_3", {"batch", "FILTER_OFM_MAX * iter + ofm + 3", "idy", "idx"}, "res3", input_dt, 1 };- FusedOpsConfiguration conf4 = { "_4", {"batch", "FILTER_OFM_MAX * iter + ofm + 0", "idy", "idx"}, "res4", input_dt, 1 };- FusedOpsConfiguration conf5 = { "_5", {"batch", "FILTER_OFM_MAX * iter + ofm + 1", "idy", "idx"}, "res5", input_dt, 1 };- FusedOpsConfiguration conf6 = { "_6", {"batch", "FILTER_OFM_MAX * iter + ofm + 2", "idy", "idx"}, "res6", input_dt, 1 };- FusedOpsConfiguration conf7 = { "_7", {"batch", "FILTER_OFM_MAX * iter + ofm + 3", "idy", "idx"}, "res7", input_dt, 1 };- jit.Merge(MakeFusedOpsJitConstants(params, { conf0, conf1, conf2, conf3, conf4, conf5, conf6, conf7 }));+ FusedOpsConfiguration conf0 = {"_0", {"batch", "FILTER_OFM_MAX * iter + ofm + 0", "idy", "idx"}, "res0", input_dt, 1};+ FusedOpsConfiguration conf1 = {"_1", {"batch", "FILTER_OFM_MAX * iter + ofm + 1", "idy", "idx"}, "res1", input_dt, 1};+ FusedOpsConfiguration conf2 = {"_2", {"batch", "FILTER_OFM_MAX * iter + ofm + 2", "idy", "idx"}, "res2", input_dt, 1};+ FusedOpsConfiguration conf3 = {"_3", {"batch", "FILTER_OFM_MAX * iter + ofm + 3", "idy", "idx"}, "res3", input_dt, 1};+ FusedOpsConfiguration conf4 = {"_4", {"batch", "FILTER_OFM_MAX * iter + ofm + 0", "idy", "idx"}, "res4", input_dt, 1};+ FusedOpsConfiguration conf5 = {"_5", {"batch", "FILTER_OFM_MAX * iter + ofm + 1", "idy", "idx"}, "res5", input_dt, 1};+ FusedOpsConfiguration conf6 = {"_6", {"batch", "FILTER_OFM_MAX * iter + ofm + 2", "idy", "idx"}, "res6", input_dt, 1};+ FusedOpsConfiguration conf7 = {"_7", {"batch", "FILTER_OFM_MAX * iter + ofm + 3", "idy", "idx"}, "res7", input_dt, 1};+ jit.Merge(MakeFusedOpsJitConstants(params, {conf0, conf1, conf2, conf3, conf4, conf5, conf6, conf7}));}return jit;diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv_16_32_imad_dw.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv_16_32_imad_dw.cppindex 023d3fb8f80..9e336488da8 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv_16_32_imad_dw.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_yx_fsv_16_32_imad_dw.cpp@@ -4,15 +4,15 @@#include "convolution_kernel_b_fs_yx_fsv_16_32_imad_dw.hpp"-#include <vector>-#include <string>#include <algorithm>+#include <string>+#include <vector>namespace kernel_selector {ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw(): ConvolutionKernelBase("convolution_gpu_b_fs_yx_fsv_16_32_imad_dw") {- std::vector<size_t> simd_sizes = { 8, 16 };+ std::vector<size_t> simd_sizes = {8, 16};std::vector<std::string> exe_modes = ConvolutionKernelBase::autoTuneOptions;// TODO: can be potentially improved for GPUs with support of LWS > 256@@ -21,15 +21,17 @@ ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::ConvolutionKernel_b_fs_yx_fsv_16_32for (auto simd : simd_sizes) {for (size_t tile_x = 1; tile_x <= 32; ++tile_x) {- if (simd * tile_x > max_block_size)+ if (simd * tile_x > max_block_size) {continue;+ }for (size_t lws0 = 1; lws0 <= 32; ++lws0) {for (size_t lws1 = 1; lws1 <= 32; ++lws1) {- if (lws0 * lws1 * simd > max_lws_size)+ if (lws0 * lws1 * simd > max_lws_size) {continue;+ }for (auto exe_mode : exe_modes) {- all_tune_params.push_back(AutoTuneParams{ simd, tile_x, lws0, lws1, false, exe_mode });- all_tune_params.push_back(AutoTuneParams{ simd, tile_x, lws0, lws1, true, exe_mode });+ all_tune_params.push_back(AutoTuneParams{simd, tile_x, lws0, lws1, false, exe_mode});+ all_tune_params.push_back(AutoTuneParams{simd, tile_x, lws0, lws1, true, exe_mode});}}}@@ -70,34 +72,38 @@ ParamsKey kernel_selector::ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::GetSuppoDeviceFeaturesKey ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::get_required_device_features_key(const Params& params) const {auto k = get_common_subgroups_device_features_key(params);- k.requires_blocked_read_write(); // for weights loading+ k.requires_blocked_read_write(); // for weights loadingreturn k;}bool ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::Validate(const Params& params) const {- if (!Parent::Validate(params))+ if (!Parent::Validate(params)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }auto conv_params = static_cast<const convolution_params&>(params);- if (conv_params.inputs[0].GetLayout() != conv_params.outputs[0].GetLayout())+ if (conv_params.inputs[0].GetLayout() != conv_params.outputs[0].GetLayout()) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }- if (conv_params.inputs[0].Feature().is_dynamic || conv_params.outputs[0].Feature().is_dynamic)+ if (conv_params.inputs[0].Feature().is_dynamic || conv_params.outputs[0].Feature().is_dynamic) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }- if (conv_params.groups != conv_params.outputs[0].Feature().v || conv_params.groups != conv_params.inputs[0].Feature().v)+ if (conv_params.groups != conv_params.outputs[0].Feature().v || conv_params.groups != conv_params.inputs[0].Feature().v) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }// Incorrect choose of TILE_X leads to accuracy issue- if (conv_params.outputs[0].X().is_dynamic)+ if (conv_params.outputs[0].X().is_dynamic) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }// For asymmetric data, kernel needs compensation optimizationif (conv_params.compensation.empty() &&- (conv_params.quantization == QuantizationType::ASYMMETRIC_DATA ||- conv_params.quantization == QuantizationType::ASYMMETRIC_DATA_AND_WEIGHTS)) {+ (conv_params.quantization == QuantizationType::ASYMMETRIC_DATA || conv_params.quantization == QuantizationType::ASYMMETRIC_DATA_AND_WEIGHTS)) {DO_NOT_USE_THIS_KERNEL(params.layerID);}@@ -105,13 +111,14 @@ bool ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::Validate(const Params& params)}WeightsLayout ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::GetPreferredWeightsLayout(const convolution_params& params) const {- if (params.outputs[0].GetLayout() == DataLayout::b_fs_yx_fsv16)+ if (params.outputs[0].GetLayout() == DataLayout::b_fs_yx_fsv16) {return WeightsLayout::gs_oi_yxs_gsv16_yxsv4;+ }return WeightsLayout::gs_oi_yxs_gsv32_yxsv4;}-ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::AutoTuneParams-ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::GetAutoTuneParams(const convolution_params& params, int index) const {+ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::AutoTuneParams ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::GetAutoTuneParams(const convolution_params& params,+ int index) const {if (index >= 0 && index < static_cast<int>(all_tune_params.size())) {return all_tune_params[index];}@@ -143,16 +150,12 @@ ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::GetAutoTuneParams(const convolutionbool stride_1x1 = params.stride.x == 1 && params.stride.y == 1;bool stride_2x2 = params.stride.x == 2 && params.stride.y == 2;// Filter 3x3 with stride 1x1- if (fsv == 16 && filter_3x3 && stride_1x1 && dilation_1x1 &&- !output.X().is_dynamic && output.X().v == 75 &&- !output.Y().is_dynamic && output.Y().v == 75) {+ if (fsv == 16 && filter_3x3 && stride_1x1 && dilation_1x1 && !output.X().is_dynamic && output.X().v == 75 && !output.Y().is_dynamic && output.Y().v == 75) {try_to_select(16, 15, 1, 4, true, EXE_MODE_DEFAULT);}// Filter 3x3 with stride 2x2- if (fsv == 16 && filter_3x3 && stride_2x2 && dilation_1x1 &&- !output.X().is_dynamic && output.X().v == 75 &&- !output.Y().is_dynamic && output.Y().v == 75) {+ if (fsv == 16 && filter_3x3 && stride_2x2 && dilation_1x1 && !output.X().is_dynamic && output.X().v == 75 && !output.Y().is_dynamic && output.Y().v == 75) {try_to_select(16, 15, 1, 16, true, EXE_MODE_DEFAULT);}@@ -160,8 +163,7 @@ ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::GetAutoTuneParams(const convolutionbool use_slm_x = (params.filterSize.x - 1) * params.dilation.x + 1 >= params.stride.x;bool use_slm_y = (params.filterSize.y - 1) * params.dilation.y + 1 >= params.stride.y;// Small spatials are inefficent with SLM due to additional overhead- bool use_slm_size = !output.X().is_dynamic && output.X().v >= default_tile_x &&- !output.Y().is_dynamic && output.Y().v >= default_tile_x;+ bool use_slm_size = !output.X().is_dynamic && output.X().v >= default_tile_x && !output.Y().is_dynamic && output.Y().v >= default_tile_x;if (!selected && use_slm_y && use_slm_x && use_slm_size) {size_t tile_x = default_tile_x / 2;@@ -169,10 +171,11 @@ ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::GetAutoTuneParams(const convolutionsize_t lws0 = 1;// First try to select optimal group size in y dimension as it provides most data reusefor (size_t c_lws1 = 4; c_lws1 <= 8; ++c_lws1) {- if (Pad(output.Y().v, c_lws1) < Pad(output.Y().v, lws1))+ if (Pad(output.Y().v, c_lws1) < Pad(output.Y().v, lws1)) {lws1 = c_lws1;- else if (Pad(output.Y().v, c_lws1) == Pad(output.Y().v, lws1) && c_lws1 % 2 == 0)+ } else if (Pad(output.Y().v, c_lws1) == Pad(output.Y().v, lws1) && c_lws1 % 2 == 0) {lws1 = c_lws1;+ }}// For best hw utilization work-group size should be multiple of 2, so if y isn't force it in xif (lws1 % 2 != 0) {@@ -181,8 +184,7 @@ ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::GetAutoTuneParams(const convolution// Local memory allocation works at 1kb granularityauto calc_slm_size_kb = [&](size_t tile_x, size_t lws0, size_t lws1) {size_t slm_x = (tile_x * lws0 - 1) * params.stride.x + (params.filterSize.x - 1) * params.dilation.x;- size_t slm_y = (lws1 == 1) ? params.filterSize.x- : (lws1 - 1) * params.stride.y + (params.filterSize.y - 1) * params.dilation.y + 1;+ size_t slm_y = (lws1 == 1) ? params.filterSize.x : (lws1 - 1) * params.stride.y + (params.filterSize.y - 1) * params.dilation.y + 1;return CeilDiv(slm_x * slm_y * fsv, 1024);};// Try to select optimal tile size with SLM and lws restrictions@@ -198,11 +200,13 @@ ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::GetAutoTuneParams(const convolution}}- if (tile_selected && CeilDiv(output.X().v, tile_x) == 2)+ if (tile_selected && CeilDiv(output.X().v, tile_x) == 2) {lws0 = 2;+ }- if (tile_selected)+ if (tile_selected) {try_to_select(16, tile_x, lws0, lws1, true, EXE_MODE_DEFAULT);+ }}if (!selected) {@@ -227,20 +231,19 @@ ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::GetAutoTuneParams(const convolutionreturn tune_params;}-bool ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::ValidateAutoTuneParams(const convolution_params& params,- const AutoTuneParams& tparams) const {+bool ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::ValidateAutoTuneParams(const convolution_params& params, const AutoTuneParams& tparams) const {bool valid_tune_params = true;- if (!IsSIMDSizeSupported(params.engineInfo, tparams.simd))+ if (!IsSIMDSizeSupported(params.engineInfo, tparams.simd)) {return false;+ }auto total_lws = tparams.simd * tparams.lws0 * tparams.lws1;valid_tune_params &= total_lws <= params.engineInfo.maxWorkGroupSize;size_t slm_preload_tile_x = (tparams.tile_x * tparams.lws0 - 1) * params.stride.x + (params.filterSize.x - 1) * params.dilation.x + 1;- size_t slm_preload_tile_y = (tparams.lws1 == 1)- ? params.filterSize.y- : (tparams.lws1 - 1) * params.stride.y + (params.filterSize.y - 1) * params.dilation.y + 1;+ size_t slm_preload_tile_y =+ (tparams.lws1 == 1) ? params.filterSize.y : (tparams.lws1 - 1) * params.stride.y + (params.filterSize.y - 1) * params.dilation.y + 1;size_t fsv = params.outputs[0].GetLayout() == DataLayout::b_fs_yx_fsv16 ? 16 : 32;auto total_slm = tparams.preload_input_slm ? slm_preload_tile_x * slm_preload_tile_y * fsv : 0;valid_tune_params &= total_slm <= params.engineInfo.maxLocalMemSize;@@ -262,8 +265,8 @@ bool ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::ValidateAutoTuneParams(const creturn valid_tune_params;}-ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::DispatchData-ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::SetDefault(const convolution_params& params, int autoTuneIndex) const {+ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::DispatchData ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::SetDefault(const convolution_params& params,+ int autoTuneIndex) const {DispatchData dispatchData;const auto& out = params.outputs[0];@@ -276,14 +279,12 @@ ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::SetDefault(const convolution_paramsfsv = 32;}- dispatchData.gws = {- Align(CeilDiv(out.X().v, tune_params.tile_x), tune_params.lws0),- Align(out.Y().v, tune_params.lws1),- CeilDiv(out.Feature().v, fsv) * tune_params.simd * out.Batch().v- };- dispatchData.lws = { tune_params.lws0, tune_params.lws1, tune_params.simd };+ dispatchData.gws = {Align(CeilDiv(out.X().v, tune_params.tile_x), tune_params.lws0),+ Align(out.Y().v, tune_params.lws1),+ CeilDiv(out.Feature().v, fsv) * tune_params.simd * out.Batch().v};+ dispatchData.lws = {tune_params.lws0, tune_params.lws1, tune_params.simd};- dispatchData.gemmStyle = { 0, 0, 0, 0, 0, 0 };+ dispatchData.gemmStyle = {0, 0, 0, 0, 0, 0};dispatchData.cldnnStyle.blockWidth = tune_params.tile_x;dispatchData.cldnnStyle.prefetch = static_cast<size_t>(tune_params.preload_input_slm);@@ -298,18 +299,13 @@ KernelsPriority ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::GetKernelsPriority(}bool ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::HasPaddedInput(const convolution_params& params) const {- if (params.outputs[0].X().is_dynamic ||- params.outputs[0].Y().is_dynamic ||- params.outputs[0].Z().is_dynamic) {+ if (params.outputs[0].X().is_dynamic || params.outputs[0].Y().is_dynamic || params.outputs[0].Z().is_dynamic) {return false;}- const auto inputLimitX = (params.outputs[0].X().v - 1) * params.stride.x- + (params.filterSize.x - 1) * params.dilation.x + 1;- const auto inputLimitY = (params.outputs[0].Y().v - 1) * params.stride.y- + (params.filterSize.y - 1) * params.dilation.y + 1;- const auto inputLimitZ = (params.outputs[0].Z().v - 1) * params.stride.z- + (params.filterSize.z - 1) * params.dilation.z + 1;+ const auto inputLimitX = (params.outputs[0].X().v - 1) * params.stride.x + (params.filterSize.x - 1) * params.dilation.x + 1;+ const auto inputLimitY = (params.outputs[0].Y().v - 1) * params.stride.y + (params.filterSize.y - 1) * params.dilation.y + 1;+ const auto inputLimitZ = (params.outputs[0].Z().v - 1) * params.stride.z + (params.filterSize.z - 1) * params.dilation.z + 1;bool has_pad = true;has_pad &= params.padding_begin.x <= params.inputs[0].X().pad.before;@@ -323,18 +319,13 @@ bool ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::HasPaddedInput(const convoluti}bool ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::ParamsHavePadding(const convolution_params& params) const {- if (params.outputs[0].X().is_dynamic ||- params.outputs[0].Y().is_dynamic ||- params.outputs[0].Z().is_dynamic) {+ if (params.outputs[0].X().is_dynamic || params.outputs[0].Y().is_dynamic || params.outputs[0].Z().is_dynamic) {return true;}- const auto inputLimitX = (params.outputs[0].X().v - 1) * params.stride.x- + (params.filterSize.x - 1) * params.dilation.x + 1;- const auto inputLimitY = (params.outputs[0].Y().v - 1) * params.stride.y- + (params.filterSize.y - 1) * params.dilation.y + 1;- const auto inputLimitZ = (params.outputs[0].Z().v - 1) * params.stride.z- + (params.filterSize.z - 1) * params.dilation.z + 1;+ const auto inputLimitX = (params.outputs[0].X().v - 1) * params.stride.x + (params.filterSize.x - 1) * params.dilation.x + 1;+ const auto inputLimitY = (params.outputs[0].Y().v - 1) * params.stride.y + (params.filterSize.y - 1) * params.dilation.y + 1;+ const auto inputLimitZ = (params.outputs[0].Z().v - 1) * params.stride.z + (params.filterSize.z - 1) * params.dilation.z + 1;bool needs_pad = false;needs_pad |= params.padding_begin.x != 0;@@ -362,16 +353,14 @@ JitConstants ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::GetJitConstants(constmem_consts.AddConstant(MakeJitConstant("FILTER_BLOCKED", filter_blocked));mem_consts.AddConstant(MakeJitConstant("PRELOAD_INPUT_TO_SLM", dispatchData.cldnnStyle.prefetch));- auto needs_boundary_check = ParamsHavePadding(params) &&- (!HasPaddedInput(params) ||- params.quantization == QuantizationType::ASYMMETRIC_DATA ||- params.quantization == QuantizationType::ASYMMETRIC_DATA_AND_WEIGHTS);+ auto needs_boundary_check = ParamsHavePadding(params) && (!HasPaddedInput(params) || params.quantization == QuantizationType::ASYMMETRIC_DATA ||+ params.quantization == QuantizationType::ASYMMETRIC_DATA_AND_WEIGHTS);mem_consts.AddConstant(MakeJitConstant("CHECK_BOUNDARY", needs_boundary_check));if (!params.fused_ops.empty()) {auto input_dt = GetActivationType(params);auto conf_1 = FusedOpsConfiguration("_1",- { "b", "fused_ops_f", "y", "fused_ops_x" },+ {"b", "fused_ops_f", "y", "fused_ops_x"},"fused_ops_in",input_dt,1,@@ -385,18 +374,18 @@ JitConstants ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::GetJitConstants(constauto conf_4 = conf_1;conf_4.suffix = "_4";conf_4.vec_size = 4;- mem_consts.Merge(MakeFusedOpsJitConstants(params, { conf_1, conf_2, conf_4 }));+ mem_consts.Merge(MakeFusedOpsJitConstants(params, {conf_1, conf_2, conf_4}));}return mem_consts;}-KernelsData ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::GetTunedKernelsDataByIndex(const Params& params,- int autoTuneIndex) const {+KernelsData ConvolutionKernel_b_fs_yx_fsv_16_32_imad_dw::GetTunedKernelsDataByIndex(const Params& params, int autoTuneIndex) const {auto convParams = static_cast<const convolution_params&>(params);auto tuneParams = GetAutoTuneParams(convParams, autoTuneIndex);- if (!ValidateAutoTuneParams(convParams, tuneParams))+ if (!ValidateAutoTuneParams(convParams, tuneParams)) {return {};+ }return GetCommonKernelsData(params, tuneParams.exeMode, autoTuneIndex);}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_zyx_fsv16.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_zyx_fsv16.cppindex db670846209..9e014d684c1 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_zyx_fsv16.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_zyx_fsv16.cpp@@ -3,10 +3,12 @@//#include "convolution_kernel_b_fs_zyx_fsv16.h"-#include "kernel_selector_utils.h"+#include <algorithm>#include <string>+#include "kernel_selector_utils.h"+namespace kernel_selector {static const size_t sub_group_size = 16;@@ -15,55 +17,56 @@ static const size_t feature_block_size = 16;constexpr float large_conv_threshold = 1.0e9f;namespace {-FusedOpsConfiguration GenerateFusedOpsConfiguration_f16(size_t conf_id, std::string input_name, Datatype dt,- bool is_vector) {+FusedOpsConfiguration GenerateFusedOpsConfiguration_f16(size_t conf_id, std::string input_name, Datatype dt, bool is_vector) {std::vector<std::string> idx_order;std::string suffix = (is_vector ? "_VEC" : "_SCALAR") + toCodeString(conf_id);std::string input_var_name = input_name + toCodeString(conf_id) + (is_vector ? "" : "[i]");size_t vec_size = is_vector ? 8 : 1;- if (is_vector)+ if (is_vector) {idx_order = {"(mb)", "(oc*OC_BLOCK + g*OC)", "od", "oh", "(ow + " + toCodeString(conf_id * 8) + ")"};- else+ } else {idx_order = {"(mb)", "(oc*OC_BLOCK + g*OC + local_id)", "od", "oh", "(ow + " + toCodeString(conf_id * 8) + " + i)"};+ }- return { suffix,- idx_order,- input_var_name,- dt,- vec_size,- is_vector ? FusedOpsConfiguration::LoadType::LT_ALIGNED_READ : FusedOpsConfiguration::LoadType::LT_UNALIGNED,- FusedOpsConfiguration::BoundaryCheck::ENABLED,- FusedOpsConfiguration::IndexType::TENSOR_COORD,- Tensor::DataChannelName::X };+ return {suffix,+ idx_order,+ input_var_name,+ dt,+ vec_size,+ is_vector ? FusedOpsConfiguration::LoadType::LT_ALIGNED_READ : FusedOpsConfiguration::LoadType::LT_UNALIGNED,+ FusedOpsConfiguration::BoundaryCheck::ENABLED,+ FusedOpsConfiguration::IndexType::TENSOR_COORD,+ Tensor::DataChannelName::X};}-FusedOpsConfiguration GenerateFusedOpsConfiguration_bsv16_fsv16(size_t conf_id, std::string input_name, Datatype dt,- size_t dims, bool is_vector) {+FusedOpsConfiguration GenerateFusedOpsConfiguration_bsv16_fsv16(size_t conf_id, std::string input_name, Datatype dt, size_t dims, bool is_vector) {std::string suffix = (is_vector ? "_VEC" : "_SCALAR") + toCodeString(conf_id);std::string input_var_name = input_name + toCodeString(conf_id) + (is_vector ? "" : "[i]");size_t vec_size = is_vector ? 8 : 1;std::vector<std::string> idx_order;if (is_vector) {- if (dims == 5)+ if (dims == 5) {idx_order = {"(mb + " + toCodeString(conf_id * 8) + ")", "(oc*16)", "od", "oh", "ow"};- else+ } else {idx_order = {"(mb + " + toCodeString(conf_id * 8) + ")", "(oc*16)", "oh", "ow"};+ }} else {- if (dims == 5)+ if (dims == 5) {idx_order = {"(mb + " + toCodeString(conf_id * 8) + ")", "(oc*16 + local_id)", "od", "oh", "(ow + i)"};- else+ } else {idx_order = {"(mb + " + toCodeString(conf_id * 8) + ")", "(oc*16 + local_id)", "oh", "(ow + i)"};+ }}- return { suffix,- idx_order,- input_var_name,- dt,- vec_size,- is_vector ? FusedOpsConfiguration::LoadType::LT_ALIGNED_READ : FusedOpsConfiguration::LoadType::LT_UNALIGNED,- FusedOpsConfiguration::BoundaryCheck::ENABLED,- FusedOpsConfiguration::IndexType::TENSOR_COORD,- Tensor::DataChannelName::BATCH };+ return {suffix,+ idx_order,+ input_var_name,+ dt,+ vec_size,+ is_vector ? FusedOpsConfiguration::LoadType::LT_ALIGNED_READ : FusedOpsConfiguration::LoadType::LT_UNALIGNED,+ FusedOpsConfiguration::BoundaryCheck::ENABLED,+ FusedOpsConfiguration::IndexType::TENSOR_COORD,+ Tensor::DataChannelName::BATCH};}} // namespace@@ -98,8 +101,7 @@ DeviceFeaturesKey ConvolutionKernel_b_fs_zyx_fsv16::get_required_device_featuresreturn k;}-ConvolutionKernelBase::DispatchData ConvolutionKernel_b_fs_zyx_fsv16::SetDefault(const convolution_params& params,- int autoTuneIndex) const {+ConvolutionKernelBase::DispatchData ConvolutionKernel_b_fs_zyx_fsv16::SetDefault(const convolution_params& params, int autoTuneIndex) const {DispatchData dispatchData = ConvolutionKernelBase::SetDefault(params, autoTuneIndex);const auto& out = params.outputs[0];@@ -113,24 +115,22 @@ ConvolutionKernelBase::DispatchData ConvolutionKernel_b_fs_zyx_fsv16::SetDefaultauto g = params.groups;const bool is_1stconv = input.Feature().v == 3 && input.GetLayout() == DataLayout::bfzyx;- const bool ver_16mb16c = !is_1stconv &&- ((out.GetDType() == Datatype::F16 && b % 32 == 0) ||- (out.GetDType() == Datatype::F32 && b % 16 == 0));+ const bool ver_16mb16c = !is_1stconv && ((out.GetDType() == Datatype::F16 && b % 32 == 0) || (out.GetDType() == Datatype::F32 && b % 16 == 0));// Use 32 pixel per work item for large conv for performance in fp32 1d convfloat workload = static_cast<float>(f * std::sqrt(y) * std::pow(params.filterSize.y, 1.5));- const bool is_1d_large_conv = (out.GetDType() == Datatype::F32 && b % 32 == 0) &&- (x == 1 && z == 1) && // check 1d conv- (workload > large_conv_threshold) && // check large conv- params.engineInfo.arch == kernel_selector::gpu_arch::xe_hpg; // this case requires in xe microarchitecture only+ const bool is_1d_large_conv = (out.GetDType() == Datatype::F32 && b % 32 == 0) && (x == 1 && z == 1) && // check 1d conv+ (workload > large_conv_threshold) && // check large conv+ params.engineInfo.arch == kernel_selector::gpu_arch::xe_hpg; // this case requires in xe microarchitecture onlyif (is_1stconv) {auto oh_block = 1;auto ow_block = 8;while (ow_block > 1) {- if (params.stride.x * ow_block + params.weights.X().v * params.dilation.x > 32)+ if (params.stride.x * ow_block + params.weights.X().v * params.dilation.x > 32) {ow_block--;- else+ } else {break;+ }}dispatchData.cldnnStyle.blockWidth = ow_block;if (out.GetDType() == Datatype::F16) {@@ -152,7 +152,7 @@ ConvolutionKernelBase::DispatchData ConvolutionKernel_b_fs_zyx_fsv16::SetDefaultdispatchData.gws[2] = b * f / ocb;}} else if (ver_16mb16c) {- f = (g > 1) ? f/g : Align(f, 16);+ f = (g > 1) ? f / g : Align(f, 16);dispatchData.lws[0] = sub_group_size;dispatchData.lws[1] = 1;dispatchData.lws[2] = 1;@@ -168,16 +168,18 @@ ConvolutionKernelBase::DispatchData ConvolutionKernel_b_fs_zyx_fsv16::SetDefaultauto div = 16;while (div > 1) {- if (x % div == 0)+ if (x % div == 0) {break;+ }div--;}auto ow_block = std::max(8, div);auto ocb = 128;while (ocb > 16) {- if (f % ocb == 0)+ if (f % ocb == 0) {break;+ }ocb /= 2;}@@ -211,18 +213,21 @@ bool ConvolutionKernel_b_fs_zyx_fsv16::Validate(const Params& p) const {const auto& input = params.inputs[0];const auto& output = params.outputs[0];- if (output.GetDType() != use_data_type)+ if (output.GetDType() != use_data_type) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }if (input.GetLayout() == DataLayout::bfzyx) {- if (input.Feature().v != 3 || output.Feature().v % feature_block_size != 0)+ if (input.Feature().v != 3 || output.Feature().v % feature_block_size != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);- if (output.GetDType() == Datatype::F16 && (output.Feature().v % 32 != 0))+ }+ if (output.GetDType() == Datatype::F16 && (output.Feature().v % 32 != 0)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }} else {- if ((params.groups > 1) && (input.Feature().v / params.groups) % feature_block_size != 0 &&- (input.Feature().v / params.groups) != 8)+ if ((params.groups > 1) && (input.Feature().v / params.groups) % feature_block_size != 0 && (input.Feature().v / params.groups) != 8) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}// Check that padding before features doesn't miss-align the blocks@@ -234,7 +239,7 @@ bool ConvolutionKernel_b_fs_zyx_fsv16::Validate(const Params& p) const {if (!params.fused_ops.empty()) {const bool is_1stconv = input.Feature().v == 3 && input.GetLayout() == DataLayout::bfzyx;const bool ver_16mb16c = !is_1stconv && ((output.GetDType() == Datatype::F16 && output.Batch().v % 32 == 0) ||- (output.GetDType() == Datatype::F32 && output.Batch().v % 16 == 0));+ (output.GetDType() == Datatype::F32 && output.Batch().v % 16 == 0));if (!ver_16mb16c && is_1stconv && output.GetDType() == Datatype::F16) {DO_NOT_USE_THIS_KERNEL(p.layerID);@@ -244,8 +249,7 @@ bool ConvolutionKernel_b_fs_zyx_fsv16::Validate(const Params& p) const {return true;}-JitConstants ConvolutionKernel_b_fs_zyx_fsv16::GetJitConstants(const convolution_params& params,- const DispatchData& dispatchData) const {+JitConstants ConvolutionKernel_b_fs_zyx_fsv16::GetJitConstants(const convolution_params& params, const DispatchData& dispatchData) const {auto input = params.inputs[0];auto output = params.outputs[0];auto jit = Parent::GetJitConstants(params, dispatchData);@@ -256,24 +260,26 @@ JitConstants ConvolutionKernel_b_fs_zyx_fsv16::GetJitConstants(const convolution// Use 32 pixel per work item for large conv for performance in fp32 1d convfloat workload = static_cast<float>(output.Feature().v * std::sqrt(output.Y().v) * std::pow(params.filterSize.y, 1.5));const bool is_1d_large_conv = (output.GetDType() == Datatype::F32 && output.Batch().v % 32 == 0) &&- (output.X().v == 1 && output.Z().v == 1) && // check 1d conv- (workload > large_conv_threshold) && // check large conv- params.engineInfo.arch == kernel_selector::gpu_arch::xe_hpg; // this case requires in xe microarchitecture only+ (output.X().v == 1 && output.Z().v == 1) && // check 1d conv+ (workload > large_conv_threshold) && // check large conv+ params.engineInfo.arch == kernel_selector::gpu_arch::xe_hpg; // this case requires in xe microarchitecture onlyif (ver_16mb16c) {jit.AddConstant(MakeJitConstant("VER_16MB16C", 1));- if (is_1d_large_conv)+ if (is_1d_large_conv) {jit.AddConstant(MakeJitConstant("VER_32MB_LARGE_1D", 1));+ }} else {jit.AddConstant(MakeJitConstant("VER_8OW16C", 1));}jit.AddConstant(MakeJitConstant("OC_BLOCK", 16));jit.AddConstant(MakeJitConstant("NCHW", 1));- if (input.GetLayout() == DataLayout::bs_fs_yx_bsv16_fsv16)+ if (input.GetLayout() == DataLayout::bs_fs_yx_bsv16_fsv16) {jit.AddConstant(MakeJitConstant("CASE_3D", 0));- else+ } else {jit.AddConstant(MakeJitConstant("CASE_3D", 1));+ }jit.AddConstant(MakeJitConstant("LWS_0", dispatchData.lws[0]));jit.AddConstant(MakeJitConstant("LWS_1", dispatchData.lws[1]));@@ -283,8 +289,7 @@ JitConstants ConvolutionKernel_b_fs_zyx_fsv16::GetJitConstants(const convolutionif (output.GetDType() == Datatype::F16) {jit.AddConstant(MakeJitConstant("OCB", 1));} else {- jit.AddConstant(MakeJitConstant("OCB",- (output.Feature().v % 32 == 0) ? 32 : 16));+ jit.AddConstant(MakeJitConstant("OCB", (output.Feature().v % 32 == 0) ? 32 : 16));}} else if (ver_16mb16c) {jit.AddConstant(MakeJitConstant("OCB", 1));@@ -299,14 +304,16 @@ JitConstants ConvolutionKernel_b_fs_zyx_fsv16::GetJitConstants(const convolutionjit.AddConstant(MakeJitConstant("MB_BLOCK", 16));} else {int mb_block;- if (output.GetDType() == Datatype::F16)+ if (output.GetDType() == Datatype::F16) {mb_block = (is_1stconv && output.Batch().v % 32 == 0) ? 16 : 1;- else+ } else {mb_block = (is_1stconv && output.Batch().v % 16 == 0) ? 16 : 1;+ }// If batch dim of output layout is not blocked format, mb_block should be set as 1.- if (mb_block == 16 && output.GetLayout() == DataLayout::b_fs_zyx_fsv16)+ if (mb_block == 16 && output.GetLayout() == DataLayout::b_fs_zyx_fsv16) {mb_block = 1;+ }jit.AddConstant(MakeJitConstant("MB_BLOCK", mb_block));}@@ -334,8 +341,8 @@ JitConstants ConvolutionKernel_b_fs_zyx_fsv16::GetJitConstants(const convolutionFusedOpsConfiguration conf_vec3 = GenerateFusedOpsConfiguration_bsv16_fsv16(3, "blockC0", input_dt, dims_num, true);FusedOpsConfiguration conf_scalar2 = GenerateFusedOpsConfiguration_bsv16_fsv16(2, "blockC0", input_dt, dims_num, false);FusedOpsConfiguration conf_scalar3 = GenerateFusedOpsConfiguration_bsv16_fsv16(3, "blockC0", input_dt, dims_num, false);- jit.Merge(MakeFusedOpsJitConstants(params, {conf_vec0, conf_vec1, conf_vec2, conf_vec3,- conf_scalar0, conf_scalar1, conf_scalar2, conf_scalar3}));+ jit.Merge(+ MakeFusedOpsJitConstants(params, {conf_vec0, conf_vec1, conf_vec2, conf_vec3, conf_scalar0, conf_scalar1, conf_scalar2, conf_scalar3}));}} else {FusedOpsConfiguration conf_vec0 = GenerateFusedOpsConfiguration_bsv16_fsv16(0, "C0", input_dt, dims_num, true);@@ -346,8 +353,7 @@ JitConstants ConvolutionKernel_b_fs_zyx_fsv16::GetJitConstants(const convolutionFusedOpsConfiguration conf_scalar1 = GenerateFusedOpsConfiguration_bsv16_fsv16(1, "C0", input_dt, dims_num, false);FusedOpsConfiguration conf_scalar2 = GenerateFusedOpsConfiguration_bsv16_fsv16(2, "C0", input_dt, dims_num, false);FusedOpsConfiguration conf_scalar3 = GenerateFusedOpsConfiguration_bsv16_fsv16(3, "C0", input_dt, dims_num, false);- jit.Merge(MakeFusedOpsJitConstants(params, {conf_vec0, conf_vec1, conf_vec2, conf_vec3,- conf_scalar0, conf_scalar1, conf_scalar2, conf_scalar3}));+ jit.Merge(MakeFusedOpsJitConstants(params, {conf_vec0, conf_vec1, conf_vec2, conf_vec3, conf_scalar0, conf_scalar1, conf_scalar2, conf_scalar3}));}} else if ((!is_1stconv || output.GetDType() == Datatype::F32) && !params.fused_ops.empty()) {FusedOpsConfiguration conf_vec0 = GenerateFusedOpsConfiguration_f16(0, "blockC0", input_dt, true);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_zyx_fsv16.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_zyx_fsv16.hindex 16d9f04aa97..cd7ff5ac8bf 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_zyx_fsv16.h+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_zyx_fsv16.h@@ -4,18 +4,19 @@#pragma once-#include "convolution_kernel_base.h"#include <vector>+#include "convolution_kernel_base.h"+namespace kernel_selector {class ConvolutionKernel_b_fs_zyx_fsv16 : public ConvolutionKernelBase {public:using Parent = ConvolutionKernelBase;- explicit ConvolutionKernel_b_fs_zyx_fsv16(Datatype use_data_type) :- ConvolutionKernelBase(use_data_type == Datatype::F32 ? "gen9_common_conv_fwd_data_f32" : "gen9_common_conv_fwd_data_f16"),- use_data_type(use_data_type) {}+ explicit ConvolutionKernel_b_fs_zyx_fsv16(Datatype use_data_type)+ : ConvolutionKernelBase(use_data_type == Datatype::F32 ? "gen9_common_conv_fwd_data_f32" : "gen9_common_conv_fwd_data_f16"),+ use_data_type(use_data_type) {}~ConvolutionKernel_b_fs_zyx_fsv16() override = default;@@ -31,13 +32,15 @@ protected:return WeightsLayout::os_zyxi_osv16;}if (use_data_type == Datatype::F32 && params.inputs[0].Batch().v % 16 == 0) {- if (is_3d_case)+ if (is_3d_case) {return (params.groups > 1) ? WeightsLayout::g_is_os_zyx_isv16_osv16 : WeightsLayout::is_os_zyx_isv16_osv16;+ }return (params.groups > 1) ? WeightsLayout::g_is_os_yx_isv16_osv16 : WeightsLayout::is_os_yx_isv16_osv16;}if (use_data_type == Datatype::F16 && params.inputs[0].Batch().v % 32 == 0) {- if (is_3d_case)+ if (is_3d_case) {return (params.groups > 1) ? WeightsLayout::g_os_is_zyx_isv8_osv16_isv2 : WeightsLayout::os_is_zyx_isv8_osv16_isv2;+ }return (params.groups > 1) ? WeightsLayout::g_os_is_yx_isv8_osv16_isv2 : WeightsLayout::os_is_yx_isv8_osv16_isv2;}return (params.groups > 1) ? WeightsLayout::g_os_is_zyx_isv16_osv16 : WeightsLayout::os_is_zyx_isv16_osv16;@@ -47,9 +50,7 @@ protected:JitConstants GetJitConstants(const convolution_params& params, const DispatchData& dispatchData) const override;std::vector<FusedOpType> GetSupportedFusedOps() const override {- return { FusedOpType::ELTWISE,- FusedOpType::QUANTIZE,- FusedOpType::ACTIVATION };+ return {FusedOpType::ELTWISE, FusedOpType::QUANTIZE, FusedOpType::ACTIVATION};}// This class is base one for FP16 and FP32 classesdiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_zyx_fsv16_imad.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_zyx_fsv16_imad.cppindex ef70d98e31c..822a37e664f 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_zyx_fsv16_imad.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_b_fs_zyx_fsv16_imad.cpp@@ -3,12 +3,14 @@//#include "convolution_kernel_b_fs_zyx_fsv16_imad.h"-#include "kernel_selector_utils.h"-#include "common_tools.h"-#include <vector>-#include <string>-#include <iostream>+#include <algorithm>+#include <iostream>+#include <string>+#include <vector>++#include "common_tools.h"+#include "kernel_selector_utils.h"//// Kernel specific constants@@ -27,12 +29,14 @@ static size_t getOutBlock_X(const size_t output_size_x, const size_t stride_x, csize_t output_block_width = 0;size_t max_block_size = std::min((min_in_block_simds * simd - 1 - (filter_size_x - 1) * dilation_x) / stride_x + 1, output_size_x);- if (output_size_x <= max_block_size)+ if (output_size_x <= max_block_size) {return output_size_x;+ }for (size_t block = 4; block <= max_block_size; ++block) {- if (output_size_x % block == 0)+ if (output_size_x % block == 0) {output_block_width = block;+ }}if (output_block_width == 0 && output_size_x < max_block_size * 3) {size_t min_overhang = max_block_size;@@ -53,8 +57,7 @@ static size_t getOutBlock_X(const size_t output_size_x, const size_t stride_x, cnamespace kernel_selector {-Convolution_kernel_b_fs_zyx_fsv16_imad::BlockParams-Convolution_kernel_b_fs_zyx_fsv16_imad::GetBlockParams(const convolution_params& params) const {+Convolution_kernel_b_fs_zyx_fsv16_imad::BlockParams Convolution_kernel_b_fs_zyx_fsv16_imad::GetBlockParams(const convolution_params& params) const {size_t max_block_width = 1;if (!params.outputs[0].X().is_dynamic) {max_block_width = getOutBlock_X(params.outputs[0].X().v, params.stride.x, params.filterSize.x, params.dilation.x);@@ -80,7 +83,7 @@ Convolution_kernel_b_fs_zyx_fsv16_imad::GetBlockParams(const convolution_params&size_t in_block_depth = 1;// Estimate basic block params ratio- auto test_block_params = BlockParams{ block_width, 1, 1, simd, in_block_width, 1, 1, 1 };+ auto test_block_params = BlockParams{block_width, 1, 1, simd, in_block_width, 1, 1, 1};// Use default block parameters for asymmetric weights quantization for devices with immad support due to unoptimized tuningif ((params.quantization == QuantizationType::ASYMMETRIC_DATA_AND_WEIGHTS || params.quantization == QuantizationType::ASYMMETRIC_WEIGHTS) &&@@ -96,17 +99,18 @@ Convolution_kernel_b_fs_zyx_fsv16_imad::GetBlockParams(const convolution_params&if (params.is_shape_agnostic) {max_slm_split = 2;} else if (params.engineInfo.deviceType == dev_type::integrated_gpu && params.engineInfo.computeUnitsCount == 96) {- bool split_exception_1 = params.outputs[0].X().v == 3 && params.outputs[0].Y().v == 3 && params.outputs[0].Z().v == 1- && params.outputs[0].Feature().v == 512;- bool split_exception_2 = params.outputs[0].X().v == 5 && params.outputs[0].Y().v == 5 && params.outputs[0].Z().v == 1- && params.outputs[0].Feature().v == 256;- bool split_exception_3 = params.outputs[0].X().v == 9 && params.outputs[0].Y().v == 9 && params.outputs[0].Z().v == 1- && params.outputs[0].Feature().v == 128;- bool split_exception_4 = params.outputs[0].X().v == 18 && params.outputs[0].Y().v == 18 && params.outputs[0].Z().v == 1- && params.outputs[0].Feature().v == 64;-- if (split_exception_1 || split_exception_2 || split_exception_3 || split_exception_4)+ bool split_exception_1 =+ params.outputs[0].X().v == 3 && params.outputs[0].Y().v == 3 && params.outputs[0].Z().v == 1 && params.outputs[0].Feature().v == 512;+ bool split_exception_2 =+ params.outputs[0].X().v == 5 && params.outputs[0].Y().v == 5 && params.outputs[0].Z().v == 1 && params.outputs[0].Feature().v == 256;+ bool split_exception_3 =+ params.outputs[0].X().v == 9 && params.outputs[0].Y().v == 9 && params.outputs[0].Z().v == 1 && params.outputs[0].Feature().v == 128;+ bool split_exception_4 =+ params.outputs[0].X().v == 18 && params.outputs[0].Y().v == 18 && params.outputs[0].Z().v == 1 && params.outputs[0].Feature().v == 64;++ if (split_exception_1 || split_exception_2 || split_exception_3 || split_exception_4) {max_slm_split = 2;+ }}// Check ratio in cycle for all available block params@@ -129,11 +133,13 @@ Convolution_kernel_b_fs_zyx_fsv16_imad::GetBlockParams(const convolution_params&for (size_t split = 1; split <= max_slm_split; split *= 2) {for (size_t temp_block_features = simd; temp_block_features <= simd * 2; temp_block_features += simd) {for (size_t d = 1; d < max_d; ++d) {- if (d != 1 && ((params.outputs[0].Z().v % d) != 0u))+ if (d != 1 && ((params.outputs[0].Z().v % d) != 0u)) {continue;+ }for (size_t h = 1; h < max_h; ++h) {- if (h != 1 && ((params.outputs[0].Y().v % h) != 0u))+ if (h != 1 && ((params.outputs[0].Y().v % h) != 0u)) {continue;+ }bool c_ifm_mul = CeilDiv(params.weights.IFM().v, fsv) % split == 0;bool c_mul_f = temp_block_features == simd ? true : params.weights.OFM().v % temp_block_features == 0;@@ -151,8 +157,14 @@ Convolution_kernel_b_fs_zyx_fsv16_imad::GetBlockParams(const convolution_params&}// Estimate current block params ratio- test_block_params = BlockParams{ temp_block_width, temp_block_height, temp_block_depth, temp_block_features,- temp_in_block_width, temp_in_block_height, temp_in_block_depth, split };+ test_block_params = BlockParams{temp_block_width,+ temp_block_height,+ temp_block_depth,+ temp_block_features,+ temp_in_block_width,+ temp_in_block_height,+ temp_in_block_depth,+ split};auto block_params_ratio = EstimateBlockParamsRatio(params, test_block_params);// Try to increase block_params_ratio@@ -173,12 +185,13 @@ Convolution_kernel_b_fs_zyx_fsv16_imad::GetBlockParams(const convolution_params&}}}- if (split * fsv >= params.weights.IFM().v)+ if (split * fsv >= params.weights.IFM().v) {break;+ }}}- return BlockParams{ block_width, block_height, block_depth, block_features, in_block_width, in_block_height, in_block_depth, feature_slm_split };+ return BlockParams{block_width, block_height, block_depth, block_features, in_block_width, in_block_height, in_block_depth, feature_slm_split};}float Convolution_kernel_b_fs_zyx_fsv16_imad::EstimateBlockParamsRatio(const convolution_params& params, const BlockParams& block) const {@@ -218,8 +231,9 @@ float Convolution_kernel_b_fs_zyx_fsv16_imad::EstimateBlockParamsRatio(const con// Exception for z != 1bool fb32_exception_z = output.X().v == output.Y().v && output.X().v % 28 == 0 && output.Z().v == 40 && output.Feature().v % 32 == 0;- if ((output.X().v == output.Y().v && output.Z().v == 1 && fb32_exceptions) || fb32_exception_z)+ if ((output.X().v == output.Y().v && output.Z().v == 1 && fb32_exceptions) || fb32_exception_z) {fb32_factor = 1.f;+ }} else if (occupancy_by_logic_size >= 2500.f) {fb32_factor = 0.5f;}@@ -248,11 +262,8 @@ float Convolution_kernel_b_fs_zyx_fsv16_imad::EstimateBlockParamsRatio(const con}// Estimate current block_params_ratio- float block_params_ratio = occupancy +- feature_block_32 * fb32_factor +- slm_usage * slm_usage_factor +- reg_pressure * reg_pressure_factor -- reduce_occupancy;+ float block_params_ratio =+ occupancy + feature_block_32 * fb32_factor + slm_usage * slm_usage_factor + reg_pressure * reg_pressure_factor - reduce_occupancy;// Check all restrictionsbool bad_block_params = reg_pressure > max_reg_pressure || slm_usage > max_slm_usage || (occupancy < 1.0f && can_increase_occupancy);@@ -305,26 +316,25 @@ float Convolution_kernel_b_fs_zyx_fsv16_imad::EstimateOccupancy(const convolutio}float Convolution_kernel_b_fs_zyx_fsv16_imad::EstimateSLMUsage(const convolution_params& params, const BlockParams& block) const {- if (block.feature_slm_split == 1)+ if (block.feature_slm_split == 1) {return 0.f;+ }- size_t slm_elements_per_work_group = block.output_block_width * block.output_block_height * block.output_block_depth *- block.output_block_features * (block.feature_slm_split - 1);+ size_t slm_elements_per_work_group =+ block.output_block_width * block.output_block_height * block.output_block_depth * block.output_block_features * (block.feature_slm_split - 1);size_t slm_bytes_per_work_group = slm_elements_per_work_group * BytesPerElement(GetAccumulatorType(params));// Check maxLocalMemSize limitationssize_t max_slm_bytes_per_sub_slice = params.engineInfo.maxLocalMemSize;- if (slm_bytes_per_work_group > max_slm_bytes_per_sub_slice)+ if (slm_bytes_per_work_group > max_slm_bytes_per_sub_slice) {return 0.f;+ }// Estimate work groups numberconst auto& output = params.outputs[0];- size_t work_groups_number = CeilDiv(output.X().v, block.output_block_width) *- CeilDiv(output.Y().v, block.output_block_height) *- CeilDiv(output.Z().v, block.output_block_depth) *- output.Batch().v *- CeilDiv(params.weights.OFM().v, block.output_block_features) *- params.groups;+ size_t work_groups_number = CeilDiv(output.X().v, block.output_block_width) * CeilDiv(output.Y().v, block.output_block_height) *+ CeilDiv(output.Z().v, block.output_block_depth) * output.Batch().v *+ CeilDiv(params.weights.OFM().v, block.output_block_features) * params.groups;// Check work groups per device limitationssize_t max_threads_per_compute_unit = static_cast<size_t>(params.engineInfo.maxThreadsPerExecutionUnit);@@ -332,26 +342,30 @@ float Convolution_kernel_b_fs_zyx_fsv16_imad::EstimateSLMUsage(const convolutionconstexpr size_t max_work_groups_per_sub_slice = 16;size_t max_sub_slices_per_device = params.engineInfo.computeUnitsCount / max_compute_units_per_sub_slice;size_t max_work_groups_per_device = max_sub_slices_per_device * max_work_groups_per_sub_slice;- if (work_groups_number > max_work_groups_per_device * 100)+ if (work_groups_number > max_work_groups_per_device * 100) {return 0.f;+ }// Estimate work groups number in sub slicesize_t threads_per_work_group = block.feature_slm_split;size_t threads_per_sub_slice = max_threads_per_compute_unit * max_compute_units_per_sub_slice;size_t current_max_work_groups_per_sub_slice = threads_per_sub_slice / threads_per_work_group;- while (current_max_work_groups_per_sub_slice * slm_bytes_per_work_group > max_slm_bytes_per_sub_slice)+ while (current_max_work_groups_per_sub_slice * slm_bytes_per_work_group > max_slm_bytes_per_sub_slice) {current_max_work_groups_per_sub_slice--;+ }// The best scenario for slm usage from the point of view of time spending is a case with 1 work group per sub slice// due to time isn't spent on waiting of synchronizations between work groups in sub slice- if (current_max_work_groups_per_sub_slice == 1)+ if (current_max_work_groups_per_sub_slice == 1) {return 1.0;+ }// Estimate the size of the SLM memory usedfloat max_slm_bytes_per_work_group = static_cast<float>(max_slm_bytes_per_sub_slice) / static_cast<float>(current_max_work_groups_per_sub_slice);max_slm_bytes_per_work_group = static_cast<float>(Align(static_cast<size_t>(max_slm_bytes_per_work_group), 1024));- if (max_slm_bytes_per_work_group * static_cast<float>(current_max_work_groups_per_sub_slice) > static_cast<float>(max_slm_bytes_per_sub_slice))+ if (max_slm_bytes_per_work_group * static_cast<float>(current_max_work_groups_per_sub_slice) > static_cast<float>(max_slm_bytes_per_sub_slice)) {max_slm_bytes_per_work_group -= 1024.0;+ }return static_cast<float>(slm_bytes_per_work_group) / static_cast<float>(max_slm_bytes_per_work_group);}@@ -400,8 +414,7 @@ KernelsData Convolution_kernel_b_fs_zyx_fsv16_imad::GetKernelsData(const Params&return GetCommonKernelsData(params);}-JitConstants Convolution_kernel_b_fs_zyx_fsv16_imad::GetJitConstants(const convolution_params& params,- const DispatchData& dispatchData) const {+JitConstants Convolution_kernel_b_fs_zyx_fsv16_imad::GetJitConstants(const convolution_params& params, const DispatchData& dispatchData) const {auto mem_consts = Parent::GetJitConstants(params, dispatchData);auto block_params = GetBlockParams(params);@@ -425,12 +438,12 @@ JitConstants Convolution_kernel_b_fs_zyx_fsv16_imad::GetJitConstants(const convoif (!params.fused_ops.empty()) {auto input_dt = GetActivationType(params);- std::vector<std::string> idx_order = { "out_b", "(out_f + ofb * 16)", "(out_y + oh)", "(out_x + ow)" };+ std::vector<std::string> idx_order = {"out_b", "(out_f + ofb * 16)", "(out_y + oh)", "(out_x + ow)"};if (DataTensor::ChannelsCount(params.outputs[0].GetLayout()) == 5) {- idx_order = { "out_b", "(out_f + ofb * 16)", "(out_z + od)", "(out_y + oh)", "(out_x + ow)" };+ idx_order = {"out_b", "(out_f + ofb * 16)", "(out_z + od)", "(out_y + oh)", "(out_x + ow)"};}- std::vector<Tensor::DataChannelName> loop_axes = { Tensor::DataChannelName::X };+ std::vector<Tensor::DataChannelName> loop_axes = {Tensor::DataChannelName::X};if (DataTensor::ChannelsCount(params.outputs[0].GetLayout()) == 5) {if (block_params.output_block_depth != 1) {@@ -446,13 +459,7 @@ JitConstants Convolution_kernel_b_fs_zyx_fsv16_imad::GetJitConstants(const convoidx_order[idx_order.size() - 2] = "out_y";}- FusedOpsConfiguration conf_scalar = { "_SCALAR",- idx_order,- "dequantized_val",- input_dt,- 1,- LoadType::LT_UNALIGNED,- BoundaryCheck::DISABLED };+ FusedOpsConfiguration conf_scalar = {"_SCALAR", idx_order, "dequantized_val", input_dt, 1, LoadType::LT_UNALIGNED, BoundaryCheck::DISABLED};conf_scalar.SetLoopAxes(loop_axes, true);mem_consts.Merge(MakeFusedOpsJitConstants(params, {conf_scalar}));@@ -461,8 +468,7 @@ JitConstants Convolution_kernel_b_fs_zyx_fsv16_imad::GetJitConstants(const convoreturn mem_consts;} // GetJitConstants-ConvolutionKernelBase::DispatchData Convolution_kernel_b_fs_zyx_fsv16_imad::SetDefault(const convolution_params& params,- int) const {+ConvolutionKernelBase::DispatchData Convolution_kernel_b_fs_zyx_fsv16_imad::SetDefault(const convolution_params& params, int) const {const BlockParams& block_params = GetBlockParams(params);return CalcDispatchDataWithBlockParams(params, block_params);} // SetDefault@@ -475,8 +481,8 @@ ConvolutionKernelBase::DispatchData Convolution_kernel_b_fs_zyx_fsv16_imad::CalcdispatchData.gws[0] = CeilDiv(output.X().v, block_params.output_block_width);dispatchData.gws[1] = CeilDiv(output.Y().v, block_params.output_block_height) * CeilDiv(output.Z().v, block_params.output_block_depth);- dispatchData.gws[2] = output.Batch().v * CeilDiv(weights.OFM().v, block_params.output_block_features) *- params.groups * simd * block_params.feature_slm_split;+ dispatchData.gws[2] =+ output.Batch().v * CeilDiv(weights.OFM().v, block_params.output_block_features) * params.groups * simd * block_params.feature_slm_split;dispatchData.lws[0] = 1;dispatchData.lws[1] = 1;@@ -484,10 +490,14 @@ ConvolutionKernelBase::DispatchData Convolution_kernel_b_fs_zyx_fsv16_imad::CalcdispatchData.cldnnStyle = {0, 0, 0, 0, 0};dispatchData.gemmStyle = {0, 0, 0, 0, 0, 0};- dispatchData.blockParams = { block_params.output_block_width, block_params.output_block_height,- block_params.output_block_depth, block_params.output_block_features,- block_params.input_block_width, block_params.input_block_height,- block_params.input_block_depth, block_params.feature_slm_split };+ dispatchData.blockParams = {block_params.output_block_width,+ block_params.output_block_height,+ block_params.output_block_depth,+ block_params.output_block_features,+ block_params.input_block_width,+ block_params.input_block_height,+ block_params.input_block_depth,+ block_params.feature_slm_split};return dispatchData;}@@ -495,8 +505,9 @@ KernelsPriority Convolution_kernel_b_fs_zyx_fsv16_imad::GetKernelsPriority(constconst auto& p = static_cast<const convolution_params&>(params);if (!p.is_shape_agnostic) {- if (static_cast<float>(p.weights.IFM().v) / static_cast<float>(Align(p.weights.IFM().v, fsv)) < 0.5f)+ if (static_cast<float>(p.weights.IFM().v) / static_cast<float>(Align(p.weights.IFM().v, fsv)) < 0.5f) {return FORCE_PRIORITY_4;+ }return FORCE_PRIORITY_2;}return FORCE_PRIORITY_4;@@ -511,21 +522,21 @@ bool Convolution_kernel_b_fs_zyx_fsv16_imad::Validate(const Params& params) consconvolution_params& conv_params = *static_cast<convolution_params*>(kd.params.get());if (conv_params.quantization == QuantizationType::ASYMMETRIC_DATA_AND_WEIGHTS) {- if ((conv_params.activations_zero_points.empty() || conv_params.weights_zero_points.empty()) &&- (conv_params.compensation.empty()))+ if ((conv_params.activations_zero_points.empty() || conv_params.weights_zero_points.empty()) && (conv_params.compensation.empty())) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }} else if (conv_params.quantization == QuantizationType::ASYMMETRIC_DATA) {- if ((conv_params.activations_zero_points.empty()) &&- (conv_params.compensation.empty()))+ if ((conv_params.activations_zero_points.empty()) && (conv_params.compensation.empty())) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }} else if (conv_params.quantization == QuantizationType::ASYMMETRIC_WEIGHTS) {- if (conv_params.weights_zero_points.empty())+ if (conv_params.weights_zero_points.empty()) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }} else {- if (!conv_params.activations_zero_points.empty() ||- !conv_params.weights_zero_points.empty() ||- !conv_params.compensation.empty())+ if (!conv_params.activations_zero_points.empty() || !conv_params.weights_zero_points.empty() || !conv_params.compensation.empty()) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}return true;diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_base.cppindex a4cf8fe6ebb..fb0f647935b 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_base.cpp@@ -3,11 +3,13 @@//#include "convolution_kernel_base.h"-#include "kernel_selector_utils.h"-#include "common_tools.h"++#include <algorithm>#include <string>#include <vector>-#include <algorithm>++#include "common_tools.h"+#include "kernel_selector_utils.h"namespace kernel_selector {bool ConvolutionKernelBase::Validate(const Params& p) const {@@ -18,8 +20,9 @@ bool ConvolutionKernelBase::Validate(const Params& p) const {const convolution_params& params = static_cast<const convolution_params&>(p);for (const auto& fused_op : params.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}return true;@@ -31,8 +34,7 @@ JitConstants ConvolutionKernelBase::GetJitConstants(const convolution_params& paconst auto& padding = params.padding_begin;const auto& input = params.inputs[0];- int64_t input_offset_with_padding =- (int64_t)input.GetFirstElementOffset() - padding.x * input.X().pitch - input.Y().pitch * padding.y;+ int64_t input_offset_with_padding = (int64_t)input.GetFirstElementOffset() - padding.x * input.X().pitch - input.Y().pitch * padding.y;input_offset_with_padding = std::max(input_offset_with_padding, (int64_t)0);mem_consts.AddConstants({@@ -71,10 +73,12 @@ JitConstants ConvolutionKernelBase::GetJitConstants(const convolution_params& paif (params.deformable_mode) {mem_consts.AddConstants({MakeJitConstant("DEFORMABLE_GROUPS", params.deformable_groups)});mem_consts.AddConstants({MakeJitConstant("DEFORMABLE_MODE", params.deformable_mode)});- if (params.deformable_mask_enabled)+ if (params.deformable_mask_enabled) {mem_consts.AddConstants({MakeJitConstant("DEFORMABLE_MASK_ENABLED", params.deformable_mask_enabled)});- if (params.bilinear_interpolation_pad)+ }+ if (params.bilinear_interpolation_pad) {mem_consts.AddConstants({MakeJitConstant("BILINEAR_INTERPOLATION_PAD", params.bilinear_interpolation_pad)});+ }}if (!params.is_shape_agnostic) {@@ -90,13 +94,13 @@ JitConstants ConvolutionKernelBase::GetJitConstantsWithLoopUnroll(const convolutJitConstants mem_consts = ConvolutionKernelBase::GetJitConstants(params, dispatchData);std::vector<uint32_t> unrollLoopParams{params.filterSize.x,- params.filterSize.y,- (uint32_t)dispatchData.gemmStyle.globalWorkSizeDX,- (uint32_t)dispatchData.gemmStyle.globalWorkSizeDY,- (uint32_t)dispatchData.gemmStyle.globalWorkSizeDZ,- (uint32_t)dispatchData.gemmStyle.subBlockDimM,- (uint32_t)dispatchData.gemmStyle.subBlockDimK,- (uint32_t)dispatchData.gemmStyle.subBlockDimN};+ params.filterSize.y,+ (uint32_t)dispatchData.gemmStyle.globalWorkSizeDX,+ (uint32_t)dispatchData.gemmStyle.globalWorkSizeDY,+ (uint32_t)dispatchData.gemmStyle.globalWorkSizeDZ,+ (uint32_t)dispatchData.gemmStyle.subBlockDimM,+ (uint32_t)dispatchData.gemmStyle.subBlockDimK,+ (uint32_t)dispatchData.gemmStyle.subBlockDimN};auto loopCount = *std::max_element(unrollLoopParams.begin(), unrollLoopParams.end());@@ -107,14 +111,17 @@ JitConstants ConvolutionKernelBase::GetJitConstantsWithLoopUnroll(const convolut}bool ConvolutionKernelBase::CheckWorkGroups(const ConvolutionKernelBase::DispatchData& dispatchData) {- if (dispatchData.gws.size() != 3 || dispatchData.lws.size() != 3)+ if (dispatchData.gws.size() != 3 || dispatchData.lws.size() != 3) {return false;+ }for (size_t i = 0; i < dispatchData.gws.size(); i++) {- if (dispatchData.gws[i] == 0 || dispatchData.lws[i] == 0)+ if (dispatchData.gws[i] == 0 || dispatchData.lws[i] == 0) {return false;- if ((dispatchData.gws[i] % dispatchData.lws[i]) != 0)+ }+ if ((dispatchData.gws[i] % dispatchData.lws[i]) != 0) {return false;+ }}return true;@@ -129,9 +136,7 @@ ConvolutionKernelBase::DispatchData ConvolutionKernelBase::SetDefault(const convconst auto& out = params.outputs[0];if (out_layout == DataLayout::bfyx || out_layout == DataLayout::byxf) {dispatchData.gws = {out.X().v, out.Y().v, out.Feature().v * out.Batch().v};- dims_by_gws = {{Tensor::DataChannelName::X},- {Tensor::DataChannelName::Y},- {Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH}};+ dims_by_gws = {{Tensor::DataChannelName::X}, {Tensor::DataChannelName::Y}, {Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH}};} else if (out_layout == DataLayout::bfzyx) {dispatchData.gws = {out.X().v, out.Y().v * out.Z().v, out.Feature().v * out.Batch().v};dims_by_gws = {{Tensor::DataChannelName::X},@@ -139,9 +144,7 @@ ConvolutionKernelBase::DispatchData ConvolutionKernelBase::SetDefault(const conv{Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH}};} else {dispatchData.gws = {out.Feature().v * out.Batch().v, out.X().v, out.Y().v};- dims_by_gws = {{Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH},- {Tensor::DataChannelName::X},- {Tensor::DataChannelName::Y}};+ dims_by_gws = {{Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH}, {Tensor::DataChannelName::X}, {Tensor::DataChannelName::Y}};}dispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo, in_layout, out_layout, dims_by_gws);@@ -176,9 +179,7 @@ void ConvolutionKernelBase::GetUpdateDispatchDataFunc(KernelData& kd) const {};}-KernelsData ConvolutionKernelBase::GetCommonKernelsData(const Params& params,- const std::string exeMode,- int autoTuneIndex) const {+KernelsData ConvolutionKernelBase::GetCommonKernelsData(const Params& params, const std::string exeMode, int autoTuneIndex) const {KernelData kd = KernelData::Default<convolution_params>(params);convolution_params& newParams = *static_cast<convolution_params*>(kd.params.get());@@ -187,12 +188,7 @@ KernelsData ConvolutionKernelBase::GetCommonKernelsData(const Params& params,}auto preferredWeightsLayout = GetPreferredWeightsLayout(newParams);- bool succeed = UpdateWeightsParams(newParams,- preferredWeightsLayout,- kd.weightsReorderParams,- GetSupportedKey(),- newParams.groups,- newParams.transposed);+ bool succeed = UpdateWeightsParams(newParams, preferredWeightsLayout, kd.weightsReorderParams, GetSupportedKey(), newParams.groups, newParams.transposed);bool bSupportedWeightsLayout = newParams.weights.GetLayout() == preferredWeightsLayout;const bool bWeightsOK = bSupportedWeightsLayout || newParams.allowStaticInputReordering;@@ -203,13 +199,15 @@ KernelsData ConvolutionKernelBase::GetCommonKernelsData(const Params& params,if (NeedPaddedInput()) {if (newParams.has_dynamic_inputs()) {- if (!CheckConvolutionExplicitPaddings(newParams))+ if (!CheckConvolutionExplicitPaddings(newParams)) {return {};+ }} else {kd.reorderInput = ConvolutionUpdateInputParams(newParams);- if (kd.reorderInput && !newParams.allowInputReordering)+ if (kd.reorderInput && !newParams.allowInputReordering) {return {};+ }}}@@ -237,26 +235,32 @@ KernelsData ConvolutionKernelBase::GetCommonKernelsData(const Params& params,exeMode,true,!newParams.bias.empty(),- 1, 0, 1,+ 1,+ 0,+ 1,newParams.is_shape_agnostic);if (newParams.deformable_mode) {kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 1});- if (newParams.deformable_mask_enabled)+ if (newParams.deformable_mask_enabled) {kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 2});+ }}- if (!newParams.weights_zero_points.empty())+ if (!newParams.weights_zero_points.empty()) {kernel.params.arguments.push_back({ArgumentDescriptor::Types::WEIGHTS_ZERO_POINTS, 1});- if (!newParams.activations_zero_points.empty())+ }+ if (!newParams.activations_zero_points.empty()) {kernel.params.arguments.push_back({ArgumentDescriptor::Types::ACTIVATIONS_ZERO_POINTS, 1});- if (!newParams.compensation.empty())+ }+ if (!newParams.compensation.empty()) {kernel.params.arguments.push_back({ArgumentDescriptor::Types::COMPENSATION, 1});+ }uint32_t fused_deps_total = 0;for (auto& fused_dep : newParams.fused_ops) {for (int i = 0; i < static_cast<int>(fused_dep.dep_size); i++) {- kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INPUT_OF_FUSED_PRIMITIVE, fused_deps_total });+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT_OF_FUSED_PRIMITIVE, fused_deps_total});fused_deps_total++;}}@@ -268,15 +272,12 @@ KernelsData ConvolutionKernelBase::GetCommonKernelsData(const Params& params,bool CheckConvolutionPaddedInputDesc(const convolution_params& params, const DataTensor& reqDesc) {assert(!params.inputs.empty());- bool properPadding = reqDesc.X().pad.before <= params.inputs[0].X().pad.before &&- reqDesc.Y().pad.before <= params.inputs[0].Y().pad.before &&+ bool properPadding = reqDesc.X().pad.before <= params.inputs[0].X().pad.before && reqDesc.Y().pad.before <= params.inputs[0].Y().pad.before &&reqDesc.Feature().pad.before <= params.inputs[0].Feature().pad.before &&reqDesc.Batch().pad.before <= params.inputs[0].Batch().pad.before;- properPadding &= reqDesc.X().pad.after <= params.inputs[0].X().pad.after &&- reqDesc.Y().pad.after <= params.inputs[0].Y().pad.after &&- reqDesc.Feature().pad.after <= params.inputs[0].Feature().pad.after &&- reqDesc.Batch().pad.after <= params.inputs[0].Batch().pad.after;+ properPadding &= reqDesc.X().pad.after <= params.inputs[0].X().pad.after && reqDesc.Y().pad.after <= params.inputs[0].Y().pad.after &&+ reqDesc.Feature().pad.after <= params.inputs[0].Feature().pad.after && reqDesc.Batch().pad.after <= params.inputs[0].Batch().pad.after;properPadding &= ((params.padding_begin.x == 0 && params.padding_begin.y == 0) || params.inputs[0].GetPaddedVal() == 0.f);@@ -288,7 +289,7 @@ static DataTensor GetConvolutionBFYXPaddedTensor(const convolution_params& cp) {auto ndims = cp.inputs[0].GetDims().size();DataTensor t = cp.inputs[0];- std::vector<Tensor::Pad> pad{{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} };+ std::vector<Tensor::Pad> pad{{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}};pad[0].before = cp.padding_begin.x;pad[1].before = cp.padding_begin.y;@@ -316,16 +317,16 @@ static DataTensor GetConvolutionBFYXPaddedTensor(const convolution_params& cp) {}bool CheckConvolutionExplicitPaddings(const convolution_params& conv_params) {- if (!conv_params.has_explicit_paddings)+ if (!conv_params.has_explicit_paddings) {return false;+ }bool proper_padding = true;proper_padding &= conv_params.padding_begin.x == conv_params.inputs[0].X().pad.before &&conv_params.padding_begin.y == conv_params.inputs[0].Y().pad.before &&conv_params.padding_begin.z == conv_params.inputs[0].Z().pad.before;- proper_padding &= conv_params.padding_end.x == conv_params.inputs[0].X().pad.after &&- conv_params.padding_end.y == conv_params.inputs[0].Y().pad.after &&+ proper_padding &= conv_params.padding_end.x == conv_params.inputs[0].X().pad.after && conv_params.padding_end.y == conv_params.inputs[0].Y().pad.after &&conv_params.padding_end.z == conv_params.inputs[0].Z().pad.after;return proper_padding;@@ -334,8 +335,9 @@ bool CheckConvolutionExplicitPaddings(const convolution_params& conv_params) {bool ConvolutionCheckInput(const Params& p) {const convolution_params& params = static_cast<const convolution_params&>(p);- if (params.has_dynamic_inputs())+ if (params.has_dynamic_inputs()) {return CheckConvolutionExplicitPaddings(params);+ }const auto req_input = GetConvolutionBFYXPaddedTensor(params);const bool bProperInputDesc = CheckConvolutionPaddedInputDesc(params, req_input);@@ -364,8 +366,7 @@ std::string ConvolutionKernelBase::GetAutoTuneOptions(int autoTuneIndex) const {return EXE_MODE_DEFAULT;}-KernelsData ConvolutionKernelBase::GetTunedKernelsDataByIndex(const Params& params,- const int autoTuneIndex) const {+KernelsData ConvolutionKernelBase::GetTunedKernelsDataByIndex(const Params& params, const int autoTuneIndex) const {return GetCommonKernelsData(params, GetAutoTuneOptions(autoTuneIndex), autoTuneIndex);}@@ -386,18 +387,16 @@ KernelsData ConvolutionKernelBase::GetKernelsDataForAutoTune(const Params& paramreturn res;}-JitConstants ConvolutionKernelBase::GetFusedPrimitivesJitConstants(const convolution_params& /*params*/,- const DispatchData& /*kd*/) const {+JitConstants ConvolutionKernelBase::GetFusedPrimitivesJitConstants(const convolution_params& /*params*/, const DispatchData& /*kd*/) const {return {};}-Datatype ConvolutionKernelBase::GetPackedType(Datatype dt, size_t pack_size) const {if (dt == Datatype::UINT8) {return pack_size == 4 ? Datatype::UINT32 : pack_size == 2 ? Datatype::UINT16 : dt;}if (dt == Datatype::INT8) {- return pack_size == 4 ? Datatype::INT32 : pack_size == 2 ? Datatype::INT16 : dt;+ return pack_size == 4 ? Datatype::INT32 : pack_size == 2 ? Datatype::INT16 : dt;}return dt;}@@ -414,19 +413,19 @@ Datatype ConvolutionKernelBase::GetActivationType(const convolution_params& parabool quantized_weights = false;bool quantized_inputs = false;- if (params.inputs[0].GetDType() == Datatype::UINT8 ||- params.inputs[0].GetDType() == Datatype::INT8)+ if (params.inputs[0].GetDType() == Datatype::UINT8 || params.inputs[0].GetDType() == Datatype::INT8) {quantized_inputs = true;+ }- if (params.weights.GetDType() == WeightsType::UINT8 ||- params.weights.GetDType() == WeightsType::INT8)+ if (params.weights.GetDType() == WeightsType::UINT8 || params.weights.GetDType() == WeightsType::INT8) {quantized_weights = true;+ }- if (params.quantization != QuantizationType::NONE || quantized_inputs || quantized_weights)+ if (params.quantization != QuantizationType::NONE || quantized_inputs || quantized_weights) {return Datatype::F32;+ }- if (params.outputs[0].GetDType() == Datatype::UINT8 ||- params.outputs[0].GetDType() == Datatype::INT8) {+ if (params.outputs[0].GetDType() == Datatype::UINT8 || params.outputs[0].GetDType() == Datatype::INT8) {if (params.inputs[0].GetDType() == Datatype::F32) {return Datatype::F32;}@@ -439,27 +438,30 @@ Datatype ConvolutionKernelBase::GetActivationType(const convolution_params& para}Datatype ConvolutionKernelBase::GetAccumulatorType(const convolution_params& params) const {- if (params.quantization != QuantizationType::NONE)+ if (params.quantization != QuantizationType::NONE) {return Datatype::INT32;+ }bool quantized_weights = false;bool quantized_inputs = false;- if (params.inputs[0].GetDType() == Datatype::UINT8 ||- params.inputs[0].GetDType() == Datatype::INT8)+ if (params.inputs[0].GetDType() == Datatype::UINT8 || params.inputs[0].GetDType() == Datatype::INT8) {quantized_inputs = true;+ }- if (params.weights.GetDType() == WeightsType::UINT8 ||- params.weights.GetDType() == WeightsType::INT8)+ if (params.weights.GetDType() == WeightsType::UINT8 || params.weights.GetDType() == WeightsType::INT8) {quantized_weights = true;+ }// This case should be always false, because quantization type is not NONE- if (quantized_inputs && quantized_weights)+ if (quantized_inputs && quantized_weights) {return Datatype::INT32;+ }// If we either weights or input is quantized, then we use fp32 accumulator to avoid fp16 overflow- if (quantized_inputs || quantized_weights)+ if (quantized_inputs || quantized_weights) {return Datatype::F32;+ }return params.inputs[0].GetDType();}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_1x1.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_1x1.cppindex 2695c9d11db..48b0196abb8 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_1x1.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_1x1.cpp@@ -85,8 +85,9 @@ bool ConvolutionKernel_bfyx_1x1::Validate(const Params& p) const {JitConstants ConvolutionKernel_bfyx_1x1::GetJitConstants(const convolution_params& params, const DispatchData& dispatchData) const {auto jit = Parent::GetJitConstants(params, dispatchData);- if ((params.outputs[0].Feature().v % 16) != 0u)+ if ((params.outputs[0].Feature().v % 16) != 0u) {jit.AddConstant(MakeJitConstant("LEFTOVERS", 1));+ }return jit;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_1x1_gemm_buf.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_1x1_gemm_buf.cppindex f91e940eeca..f7d7cda7671 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_1x1_gemm_buf.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_1x1_gemm_buf.cpp@@ -70,8 +70,9 @@ bool ConvolutionKernel_bfyx_1x1_gemm_buf::Validate(const Params& p) const {DO_NOT_USE_THIS_KERNEL(p.layerID);}- if (!params.engineInfo.supports_image)+ if (!params.engineInfo.supports_image) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_1x1_opt.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_1x1_opt.cppindex cd8ee6af95d..75064ef4acb 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_1x1_opt.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_1x1_opt.cpp@@ -3,12 +3,12 @@//#include "convolution_kernel_bfyx_1x1_opt.h"+#include <vector>namespace kernel_selector {-convolution_kernel_bfyx_1x1_opt::convolution_kernel_bfyx_1x1_opt()- : ConvolutionKernelBase("convolution_gpu_bfyx_1x1_opt") {}+convolution_kernel_bfyx_1x1_opt::convolution_kernel_bfyx_1x1_opt() : ConvolutionKernelBase("convolution_gpu_bfyx_1x1_opt") {}ParamsKey convolution_kernel_bfyx_1x1_opt::GetSupportedKey() const {ParamsKey k;@@ -72,8 +72,7 @@ static block_params get_out_block_size(const convolution_params& p) {return {1, 1, 1};}-ConvolutionKernelBase::DispatchData convolution_kernel_bfyx_1x1_opt::SetDefault(const convolution_params& cp,- int) const {+ConvolutionKernelBase::DispatchData convolution_kernel_bfyx_1x1_opt::SetDefault(const convolution_params& cp, int) const {DispatchData dispatchData = ConvolutionKernelBase::SetDefault(cp);constexpr size_t sub_group_size = 8;@@ -102,20 +101,25 @@ bool convolution_kernel_bfyx_1x1_opt::Validate(const Params& p) const {}const convolution_params& cp = static_cast<const convolution_params&>(p);- if (!IsSIMDSizeSupported(cp.engineInfo, 8))+ if (!IsSIMDSizeSupported(cp.engineInfo, 8)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (cp.stride.x != 1 || cp.stride.y != 1)+ if (cp.stride.x != 1 || cp.stride.y != 1) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (cp.filterSize.x != 1 || cp.filterSize.y != 1)+ if (cp.filterSize.x != 1 || cp.filterSize.y != 1) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (cp.outputs[0].Feature().v % 64 != 0)+ if (cp.outputs[0].Feature().v % 64 != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (cp.padding_begin.x != 0 || cp.padding_begin.y != 0)+ if (cp.padding_begin.x != 0 || cp.padding_begin.y != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }if (cp.inputs[0].Feature().v % 2 != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);@@ -123,19 +127,21 @@ bool convolution_kernel_bfyx_1x1_opt::Validate(const Params& p) const {// if block sizes are 1x1, then this algorithm is probably not the bestauto block = get_out_block_size(cp);- if (block.out_width == 1 && block.out_height == 1)+ if (block.out_width == 1 && block.out_height == 1) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (cp.outputs[0].X().v % block.out_width != 0)+ if (cp.outputs[0].X().v % block.out_width != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);- if (cp.outputs[0].Y().v % block.out_height != 0)+ }+ if (cp.outputs[0].Y().v % block.out_height != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}-JitConstants convolution_kernel_bfyx_1x1_opt::GetJitConstants(const convolution_params& params,- const DispatchData& dispatchData) const {+JitConstants convolution_kernel_bfyx_1x1_opt::GetJitConstants(const convolution_params& params, const DispatchData& dispatchData) const {auto jit = Parent::GetJitConstants(params, dispatchData);auto block = get_out_block_size(params);@@ -146,14 +152,17 @@ JitConstants convolution_kernel_bfyx_1x1_opt::GetJitConstants(const convolution_return jit;}-WeightsLayout convolution_kernel_bfyx_1x1_opt::GetPreferredWeightsLayout(const convolution_params &cp) const {+WeightsLayout convolution_kernel_bfyx_1x1_opt::GetPreferredWeightsLayout(const convolution_params& cp) const {auto block = get_out_block_size(cp);- if (block.out_depth == 8)+ if (block.out_depth == 8) {return WeightsLayout::os_iyx_osv64;- if (block.out_depth == 4)+ }+ if (block.out_depth == 4) {return WeightsLayout::os_iyx_osv32;- if (block.out_depth == 2)+ }+ if (block.out_depth == 2) {return WeightsLayout::os_iyx_osv16;+ }return WeightsLayout::yxio;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_depthwise_weights_lwg.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_depthwise_weights_lwg.cppindex 3e0701fecdb..f0b4a26b783 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_depthwise_weights_lwg.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_depthwise_weights_lwg.cpp@@ -67,8 +67,9 @@ JitConstants ConvolutionKernel_bfyx_depthwise_weights_lwg::GetJitConstants(constconst DispatchData& dispatchData) const {auto mem_consts = ConvolutionKernelBase::GetJitConstants(params, dispatchData);- if (params.padding_begin.x != 0 || params.padding_begin.y != 0)+ if (params.padding_begin.x != 0 || params.padding_begin.y != 0) {mem_consts.AddConstant(MakeJitConstant("BOUNDARY_CHECK", 1));+ }return mem_consts;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_gemm_like.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_gemm_like.cppindex 1e661782d35..698f31ddc7e 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_gemm_like.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_gemm_like.cpp@@ -57,8 +57,9 @@ JitConstants ConvolutionKernel_bfyx_GEMMLike::GetJitConstants(const convolution_if (CeilDiv(RoundUp(params.outputs[0].X().v * params.outputs[0].Y().v, dispatchData.gemmStyle.subBlockDimM),dispatchData.gemmStyle.globalWorkSizeDY) %dispatchData.lws[1] !=- 0)+ 0) {jit.AddConstant(MakeJitConstant("LEFTOVERS", 1));+ }return jit;}@@ -102,8 +103,9 @@ bool ConvolutionKernel_bfyx_GEMMLike::Validate(const Params& p) const {const auto& params = static_cast<const convolution_params&>(p);- if (!IsSIMDSizeSupported(p.engineInfo, 8) && params.inputs[0].GetDType() == Datatype::F32)+ if (!IsSIMDSizeSupported(p.engineInfo, 8) && params.inputs[0].GetDType() == Datatype::F32) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }if (!params.engineInfo.supports_intel_subgroups_short && params.inputs[0].GetDType() == Datatype::F16) {DO_NOT_USE_THIS_KERNEL(p.layerID);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_iyxo.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_iyxo.cppindex b5f96c2204c..194b5a40439 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_iyxo.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_iyxo.cpp@@ -57,8 +57,9 @@ bool ConvolutionKernel_bfyx_iyxo::Validate(const Params& p) const {}const auto& params = static_cast<const convolution_params&>(p);- if ((params.inputs[0].X().v % 64) != 0u)+ if ((params.inputs[0].X().v % 64) != 0u) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }bool bFilterSize = (params.filterSize.x == 5 && params.filterSize.y == 5) ||(params.filterSize.x == 3 && params.filterSize.y == 3 && (params.inputs[0].Feature().v % 4) == 0) ||diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_os_iyx_osv32.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_os_iyx_osv32.cppindex f8e9522e624..e20e63227ca 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_os_iyx_osv32.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_os_iyx_osv32.cpp@@ -184,10 +184,11 @@ ConvolutionKernel_bfyx_os_iyx_osv32::AutoTuneOption ConvolutionKernel_bfyx_os_iy// Shrink to the register budget and prefer wider blocks for contiguous memory access.while ((option.blockWidth > 1 || option.blockHeight > 1) &&needs_smaller_block(cp, option.blockWidth, option.blockHeight)) {- if (option.blockHeight >= option.blockWidth)+ if (option.blockHeight >= option.blockWidth) {option.blockHeight--;- else+ } else {option.blockWidth--;+ }}return option;diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_to_b_fs_yx_fsv16.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_to_b_fs_yx_fsv16.cppindex 3a34a4eb77b..ac994301cf4 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_to_b_fs_yx_fsv16.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_to_b_fs_yx_fsv16.cpp@@ -27,8 +27,9 @@ ConvolutionKernel_bfyx_to_bfyx_f16::ConvolutionKernel_bfyx_to_bfyx_f16(std::striConvolutionKernel_bfyx_to_bfyx_f16::AutoTuneOption ConvolutionKernel_bfyx_to_bfyx_f16::GetAutoTuneOptions(const Params& /* arg*/,int autoTuneIndex) const {- if (autoTuneIndex >= 0 && autoTuneIndex < static_cast<int>(autoTuneOptions.size()))+ if (autoTuneIndex >= 0 && autoTuneIndex < static_cast<int>(autoTuneOptions.size())) {return autoTuneOptions[autoTuneIndex];+ }return {8, EXE_MODE_AGE_BASED};}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_to_bs_fs_yx_bsv16_fsv16.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_to_bs_fs_yx_bsv16_fsv16.cppindex 0b60cedafc7..fba339c55bc 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_to_bs_fs_yx_bsv16_fsv16.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_to_bs_fs_yx_bsv16_fsv16.cpp@@ -62,8 +62,9 @@ bool ConvolutionKernel_bfyx_to_bfyx_bsv16_fsv16::Validate(const Params& p) constconst auto& input = params.inputs[0];const auto& output = params.outputs[0];- if (output.Feature().v % feature_block_size != 0 || output.Batch().v % batch_block_size != 0)+ if (output.Feature().v % feature_block_size != 0 || output.Batch().v % batch_block_size != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }if (input.Feature().v != 3) {DO_NOT_USE_THIS_KERNEL(p.layerID);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_to_fs_byx_fsv32.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_to_fs_byx_fsv32.cppindex 2f61c93ea17..d0387ebcea8 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_to_fs_byx_fsv32.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_bfyx_to_fs_byx_fsv32.cpp@@ -62,8 +62,9 @@ DeviceFeaturesKey ConvolutionKernel_bfyx_to_fs_byx_fsv32::get_required_device_feConvolutionKernel_bfyx_to_fs_byx_fsv32::AutoTuneOption ConvolutionKernel_bfyx_to_fs_byx_fsv32::GetAutoTuneOptions(const Params&,int autoTuneIndex) const {- if (autoTuneIndex >= 0 && autoTuneIndex < static_cast<int>(autoTuneOptions.size()))+ if (autoTuneIndex >= 0 && autoTuneIndex < static_cast<int>(autoTuneOptions.size())) {return autoTuneOptions[autoTuneIndex];+ }return {8, 2, EXE_MODE_AGE_BASED};}@@ -93,14 +94,16 @@ KernelsPriority ConvolutionKernel_bfyx_to_fs_byx_fsv32::GetKernelsPriority(const}bool ConvolutionKernel_bfyx_to_fs_byx_fsv32::Validate(const Params& p) const {- if (!ConvolutionKernelBase::Validate(p))+ if (!ConvolutionKernelBase::Validate(p)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }auto cp = static_cast<const convolution_params&>(p);// Output feature padding must be multiple of fsv to keep block alignment- if (cp.outputs[0].Feature().pad.before % fsv != 0)+ if (cp.outputs[0].Feature().pad.before % fsv != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_fs_byx_fsv32.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_fs_byx_fsv32.cppindex 79bb47515c3..9ed20f87d96 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_fs_byx_fsv32.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_fs_byx_fsv32.cpp@@ -67,8 +67,9 @@ DeviceFeaturesKey ConvolutionKernel_fs_byx_fsv32::get_required_device_features_kConvolutionKernel_fs_byx_fsv32::AutoTuneOption ConvolutionKernel_fs_byx_fsv32::GetAutoTuneOptions(const Params& arg,int autoTuneIndex) const {- if (autoTuneIndex >= 0 && autoTuneIndex < static_cast<int>(autoTuneOptions.size()))+ if (autoTuneIndex >= 0 && autoTuneIndex < static_cast<int>(autoTuneOptions.size())) {return autoTuneOptions[autoTuneIndex];+ }const convolution_params& cp = static_cast<const convolution_params&>(arg);@@ -79,8 +80,9 @@ ConvolutionKernel_fs_byx_fsv32::AutoTuneOption ConvolutionKernel_fs_byx_fsv32::G// Check if output can be evenly divided into large blocksfor (auto w : optBlockWidths) {- if (cp.outputs[0].X().v % w == 0 && getMinRegisterUsage(cp, w) < regThreshold)+ if (cp.outputs[0].X().v % w == 0 && getMinRegisterUsage(cp, w) < regThreshold) {return {w, EXE_MODE_AGE_BASED};+ }}// Try to find large blocks with smallest offset@@ -93,13 +95,15 @@ ConvolutionKernel_fs_byx_fsv32::AutoTuneOption ConvolutionKernel_fs_byx_fsv32::G}}- if (foundWidth != 0)+ if (foundWidth != 0) {return {foundWidth, EXE_MODE_AGE_BASED};+ }// Check small and memory bound block sizesfor (auto w : nonOptBlockWidths) {- if (cp.outputs[0].X().v % w == 0 && getMinRegisterUsage(cp, w) < regThreshold)+ if (cp.outputs[0].X().v % w == 0 && getMinRegisterUsage(cp, w) < regThreshold) {return {w, EXE_MODE_AGE_BASED};+ }}// This means all previous block sizes consumed too much registers, fallback to block width = 1@@ -132,18 +136,21 @@ KernelsPriority ConvolutionKernel_fs_byx_fsv32::GetKernelsPriority(const Params&}bool ConvolutionKernel_fs_byx_fsv32::Validate(const Params& p) const {- if (!ConvolutionKernelBase::Validate(p))+ if (!ConvolutionKernelBase::Validate(p)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }auto cp = static_cast<const convolution_params&>(p);// Output feature padding must be multiple of fsv to keep block alignment- if (cp.outputs[0].Feature().pad.before % fsv != 0)+ if (cp.outputs[0].Feature().pad.before % fsv != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }// Input feature padding must be multiple of fsv to keep block alignment- if (cp.inputs[0].Feature().pad.before % fsv != 0)+ if (cp.inputs[0].Feature().pad.before % fsv != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_fs_byx_fsv32_1x1.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_fs_byx_fsv32_1x1.cppindex f272c16522c..d987546e448 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_fs_byx_fsv32_1x1.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_fs_byx_fsv32_1x1.cpp@@ -57,8 +57,9 @@ DeviceFeaturesKey ConvolutionKernel_fs_byx_fsv32_1x1::get_required_device_featurConvolutionKernel_fs_byx_fsv32_1x1::AutoTuneOption ConvolutionKernel_fs_byx_fsv32_1x1::GetAutoTuneOptions(const Params& arg,int autoTuneIndex) const {- if (autoTuneIndex >= 0 && autoTuneIndex < static_cast<int>(autoTuneOptions.size()))+ if (autoTuneIndex >= 0 && autoTuneIndex < static_cast<int>(autoTuneOptions.size())) {return autoTuneOptions[autoTuneIndex];+ }const convolution_params& cp = static_cast<const convolution_params&>(arg);@@ -127,21 +128,25 @@ KernelsPriority ConvolutionKernel_fs_byx_fsv32_1x1::GetKernelsPriority(const Par}bool ConvolutionKernel_fs_byx_fsv32_1x1::Validate(const Params& p) const {- if (!ConvolutionKernelBase::Validate(p))+ if (!ConvolutionKernelBase::Validate(p)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const convolution_params& cp = static_cast<const convolution_params&>(p);- if (cp.filterSize.x != 1 || cp.filterSize.y != 1)+ if (cp.filterSize.x != 1 || cp.filterSize.y != 1) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }// Output feature padding must be multiple of fsv to keep block alignment- if (cp.outputs[0].Feature().pad.before % fsv != 0)+ if (cp.outputs[0].Feature().pad.before % fsv != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }// Input feature padding must be multiple of fsv to keep block alignment- if (cp.inputs[0].Feature().pad.before % fsv != 0)+ if (cp.inputs[0].Feature().pad.before % fsv != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_fs_byx_fsv32_depthwise.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_fs_byx_fsv32_depthwise.cppindex e8f6670d66a..20dae0beb67 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_fs_byx_fsv32_depthwise.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_fs_byx_fsv32_depthwise.cpp@@ -60,8 +60,9 @@ size_t ConvolutionKernel_fs_byx_fsv32_depthwise::getMinRegisterUsage(const convoConvolutionKernel_fs_byx_fsv32_depthwise::AutoTuneOption ConvolutionKernel_fs_byx_fsv32_depthwise::GetAutoTuneOptions(const Params& arg,int autoTuneIndex) const {- if (autoTuneIndex >= 0 && autoTuneIndex < static_cast<int>(autoTuneOptions.size()))+ if (autoTuneIndex >= 0 && autoTuneIndex < static_cast<int>(autoTuneOptions.size())) {return autoTuneOptions[autoTuneIndex];+ }const convolution_params& cp = static_cast<const convolution_params&>(arg);@@ -72,8 +73,9 @@ ConvolutionKernel_fs_byx_fsv32_depthwise::AutoTuneOption ConvolutionKernel_fs_by// Check if output can be evenly divided into large blocksfor (auto w : optBlockWidths) {- if (cp.outputs[0].X().v % w == 0 && getMinRegisterUsage(cp, w) < regThreshold)+ if (cp.outputs[0].X().v % w == 0 && getMinRegisterUsage(cp, w) < regThreshold) {return {w, EXE_MODE_AGE_BASED};+ }}// Try to find large blocks with smallest offset@@ -86,13 +88,15 @@ ConvolutionKernel_fs_byx_fsv32_depthwise::AutoTuneOption ConvolutionKernel_fs_by}}- if (foundWidth != 0)+ if (foundWidth != 0) {return {foundWidth, EXE_MODE_AGE_BASED};+ }// Check small and memory bound block sizesfor (auto w : nonOptBlockWidths) {- if (cp.outputs[0].X().v % w == 0 && getMinRegisterUsage(cp, w) < regThreshold)+ if (cp.outputs[0].X().v % w == 0 && getMinRegisterUsage(cp, w) < regThreshold) {return {w, EXE_MODE_AGE_BASED};+ }}// This means all previous block sizes consumed too much registers, fallback to block width = 1@@ -125,23 +129,28 @@ KernelsPriority ConvolutionKernel_fs_byx_fsv32_depthwise::GetKernelsPriority(con}bool ConvolutionKernel_fs_byx_fsv32_depthwise::Validate(const Params& p) const {- if (!ConvolutionKernelBase::Validate(p))+ if (!ConvolutionKernelBase::Validate(p)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }auto cp = static_cast<const convolution_params&>(p);- if (cp.groups < 16)+ if (cp.groups < 16) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (cp.inputs[0].Feature().v != cp.groups || cp.outputs[0].Feature().v != cp.groups)+ if (cp.inputs[0].Feature().v != cp.groups || cp.outputs[0].Feature().v != cp.groups) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }// Output feature padding must be multiple of fsv to keep block alignment- if (cp.outputs[0].Feature().pad.before % fsv != 0)+ if (cp.outputs[0].Feature().pad.before % fsv != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }// Input feature padding must be multiple of fsv to keep block alignment- if (cp.inputs[0].Feature().pad.before % fsv != 0)+ if (cp.inputs[0].Feature().pad.before % fsv != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_imad.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_imad.cppindex e23811106c0..0771ec048a4 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_imad.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_imad.cpp@@ -35,8 +35,9 @@ static void getOutBlock_WH(size_t output_size,size_t block_size = 0;for (size_t i = min_horisontal_block_size; i <= max_posible_tile_size; i++) {- if (output_size % i == 0)+ if (output_size % i == 0) {block_size = i;+ }}if (block_size != 0) {@@ -46,10 +47,11 @@ static void getOutBlock_WH(size_t output_size,}}- if (output_block_w <= 4)+ if (output_block_w <= 4) {output_block_h = output_block_w;- else+ } else {output_block_h = 1;+ }}namespace kernel_selector {@@ -112,10 +114,11 @@ JitConstants ConvolutionKernel_imad::GetJitConstants(const convolution_params& pconst auto& weights = params.weights;size_t in_fsv = 4;- if (params.inputs[0].GetLayout() == DataLayout::b_fs_yx_fsv4)+ if (params.inputs[0].GetLayout() == DataLayout::b_fs_yx_fsv4) {in_fsv = 4;- else if (params.inputs[0].GetLayout() == DataLayout::b_fs_yx_fsv16)+ } else if (params.inputs[0].GetLayout() == DataLayout::b_fs_yx_fsv16) {in_fsv = 16;+ }mem_consts.AddConstants({MakeJitConstant("_ID", RoundUp(input.Feature().v, in_fsv)),@@ -190,29 +193,35 @@ bool ConvolutionKernel_imad::Validate(const Params& params) const {const auto& conv_params = static_cast<const convolution_params&>(params);if (conv_params.groups > 1 && conv_params.weights.IFM().v % 4 != 0 &&- conv_params.inputs[0].GetLayout() != DataLayout::b_fs_yx_fsv16)+ conv_params.inputs[0].GetLayout() != DataLayout::b_fs_yx_fsv16) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }size_t min_block_size_x = (conv_params.weights.X().v - 1) * conv_params.dilation.x + 1;- if (min_block_size_x > SIMD_SIZE)+ if (min_block_size_x > SIMD_SIZE) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }if (conv_params.quantization == QuantizationType::ASYMMETRIC_DATA_AND_WEIGHTS) {if ((conv_params.activations_zero_points.empty() || conv_params.weights_zero_points.empty()) &&- (conv_params.compensation.empty()))+ (conv_params.compensation.empty())) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }} else if (conv_params.quantization == QuantizationType::ASYMMETRIC_DATA) {if ((conv_params.activations_zero_points.empty()) &&- (conv_params.compensation.empty()))+ (conv_params.compensation.empty())) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }} else if (conv_params.quantization == QuantizationType::ASYMMETRIC_WEIGHTS) {- if (conv_params.weights_zero_points.empty())+ if (conv_params.weights_zero_points.empty()) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }} else {if (!conv_params.activations_zero_points.empty() ||!conv_params.weights_zero_points.empty() ||- !conv_params.compensation.empty())+ !conv_params.compensation.empty()) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}return true;diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_imad_b_fs_yx_fsv4_1x1.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_imad_b_fs_yx_fsv4_1x1.cppindex a578b00a7fb..a301af823e1 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_imad_b_fs_yx_fsv4_1x1.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_imad_b_fs_yx_fsv4_1x1.cpp@@ -100,8 +100,9 @@ bool ConvolutionKernel_imad_b_fs_yx_fsv4_1x1::Validate(const Params& params) conKernelData kd = KernelData::Default<convolution_params>(params);convolution_params& newParams = *static_cast<convolution_params*>(kd.params.get());- if (newParams.filterSize.x != 1 || newParams.filterSize.y != 1)+ if (newParams.filterSize.x != 1 || newParams.filterSize.y != 1) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }return true;}@@ -213,8 +214,9 @@ KernelsData ConvolutionKernel_imad_b_fs_yx_fsv4_1x1::GetKernelsDataForAutoTune(cfor (size_t i = 0; i < all_tune_params.size(); i++) {auto tune_params = GetAutoTuneParams(conv_params, static_cast<int>(i));- if (!ValidateAutoTuneParams(conv_params, tune_params))+ if (!ValidateAutoTuneParams(conv_params, tune_params)) {continue;+ }KernelsData kd = GetTunedKernelsDataByIndex(params, static_cast<int>(i));if (!kd.empty()) {res.emplace_back(kd[0]);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_imad_b_fs_yx_fsv4_dw.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_imad_b_fs_yx_fsv4_dw.cppindex e4769d0a552..fbde0047048 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_imad_b_fs_yx_fsv4_dw.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_imad_b_fs_yx_fsv4_dw.cpp@@ -100,11 +100,13 @@ bool ConvolutionKernel_imad_b_fs_yx_fsv4_dw::Validate(const Params& params) consKernelData kd = KernelData::Default<convolution_params>(params);convolution_params& newParams = *static_cast<convolution_params*>(kd.params.get());- if (newParams.inputs[0].Feature().v != newParams.groups || newParams.outputs[0].Feature().v != newParams.groups)+ if (newParams.inputs[0].Feature().v != newParams.groups || newParams.outputs[0].Feature().v != newParams.groups) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }- if (newParams.outputs[0].Feature().pad.before % fsv != 0)+ if (newParams.outputs[0].Feature().pad.before % fsv != 0) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }return true;}@@ -115,36 +117,44 @@ bool ConvolutionKernel_imad_b_fs_yx_fsv4_dw::ValidateAutoTuneParams(const convolif (tune_params.tiled) {bool tiled_x_once = tune_params.tiled_simd >= (weights.X().v - 1) * params.dilation.x + 1;- if (!tiled_x_once)+ if (!tiled_x_once) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }auto max_tile_x = (tune_params.tiled_simd - 1 - (weights.X().v - 1) * params.dilation.x) / params.stride.x + 1;- if (tune_params.block_x > max_tile_x)+ if (tune_params.block_x > max_tile_x) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }- if (tune_params.block_y != 1 && params.stride.y != params.dilation.y)+ if (tune_params.block_y != 1 && params.stride.y != params.dilation.y) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }- if (tune_params.block_y > params.outputs[0].Y().v)+ if (tune_params.block_y > params.outputs[0].Y().v) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }} else if (tune_params.preload_input) {auto line_size = (tune_params.block_x - 1) * params.stride.x + (weights.X().v - 1) * params.dilation.x + 1;size_t reg_usage = tune_params.block_x * 4+ line_size * weights.Y().v+ Align(weights.X().v * weights.Y().v, 4) * static_cast<typename std::enable_if<std::is_integral<unsigned long>::value, unsigned long>::type>(tune_params.preload_weights);- if (reg_usage > max_reg_usage)+ if (reg_usage > max_reg_usage) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }- if (tune_params.block_y != 1 && params.stride.y != params.dilation.y)+ if (tune_params.block_y != 1 && params.stride.y != params.dilation.y) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }- if (tune_params.block_y > params.outputs[0].Y().v)+ if (tune_params.block_y > params.outputs[0].Y().v) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }} else {size_t block_size = tune_params.block_x * 4 + Align(weights.X().v * weights.Y().v, 4) * static_cast<typename std::enable_if<std::is_integral<unsigned long>::value, unsigned long>::type>(tune_params.preload_weights);- if (block_size > max_reg_usage)+ if (block_size > max_reg_usage) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}return true;@@ -188,10 +198,12 @@ ConvolutionKernel_imad_b_fs_yx_fsv4_dw::AutoTuneParams ConvolutionKernel_imad_b_size_t reg_usage = x * 4+ line_size * weights.Y().v+ Align(weights.X().v * weights.Y().v, 4);- if (x > output.X().v)+ if (x > output.X().v) {break;- if (reg_usage > max_reg_usage)+ }+ if (reg_usage > max_reg_usage) {break;+ }size_t blocks_x = CeilDiv(output.X().v, x);size_t overhang = blocks_x * x - output.X().v;@@ -231,8 +243,9 @@ ConvolutionKernel_imad_b_fs_yx_fsv4_dw::AutoTuneParams ConvolutionKernel_imad_b_size_t best_overhang_x_1 = 0;size_t best_overhang_x_8 = 0;for (size_t x = 1; x < 17; ++x) {- if (x > output.X().v)+ if (x > output.X().v) {break;+ }size_t blocks_x = CeilDiv(output.X().v, x);size_t overhang = blocks_x * x - output.X().v;@@ -399,8 +412,9 @@ KernelsData ConvolutionKernel_imad_b_fs_yx_fsv4_dw::GetKernelsDataForAutoTune(cofor (size_t i = 0; i < all_tune_params.size(); i++) {auto tune_params = GetAutoTuneParams(conv_params, static_cast<int>(i));- if (!ValidateAutoTuneParams(conv_params, tune_params))+ if (!ValidateAutoTuneParams(conv_params, tune_params)) {continue;+ }KernelsData kd = GetTunedKernelsDataByIndex(params, static_cast<int>(i));if (!kd.empty()) {res.emplace_back(kd[0]);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_imad_bs_fs_yx_bsv16_fsv16_1x1.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_imad_bs_fs_yx_bsv16_fsv16_1x1.cppindex 15ab8f69ad7..b3c93c35350 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_imad_bs_fs_yx_bsv16_fsv16_1x1.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_imad_bs_fs_yx_bsv16_fsv16_1x1.cpp@@ -123,11 +123,13 @@ bool Convolution_kernel_imad_bs_fs_yx_bsv16_fsv16_1x1::Validate(const Params& pa// check that all fused ops except eltwise have only feature or scalar inputsfor (auto& fo : newParams.fused_ops) {- if (fo.GetType() == FusedOpType::ELTWISE)+ if (fo.GetType() == FusedOpType::ELTWISE) {continue;+ }for (auto& input : fo.tensors) {- if (input.X().v != 1 || input.Y().v != 1 || input.Batch().v != 1)+ if (input.X().v != 1 || input.Y().v != 1 || input.Batch().v != 1) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_imad_bs_fs_yx_bsv16_fsv16_3x3.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_imad_bs_fs_yx_bsv16_fsv16_3x3.cppindex 2a73f556401..a8049a344e1 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_imad_bs_fs_yx_bsv16_fsv16_3x3.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_imad_bs_fs_yx_bsv16_fsv16_3x3.cpp@@ -124,11 +124,13 @@ bool Convolution_kernel_imad_bs_fs_yx_bsv16_fsv16_3x3::Validate(const Params& pa// check that all fused ops except eltwise have only feature or scalar inputsfor (auto& fo : newParams.fused_ops) {- if (fo.GetType() == FusedOpType::ELTWISE)+ if (fo.GetType() == FusedOpType::ELTWISE) {continue;+ }for (auto& input : fo.tensors) {- if (input.X().v != 1 || input.Y().v != 1 || input.Batch().v != 1)+ if (input.X().v != 1 || input.Y().v != 1 || input.Batch().v != 1) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_mmad_b_fs_yx_fsv32.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_mmad_b_fs_yx_fsv32.cppindex b8d87365574..304029600a9 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_mmad_b_fs_yx_fsv32.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_mmad_b_fs_yx_fsv32.cpp@@ -63,11 +63,13 @@ bool ConvolutionKernel_mmad_b_fs_yx_fsv32::Validate(const Params& p) const {DO_NOT_USE_THIS_KERNEL(p.layerID);}- if (!IsSIMDSizeSupported(params.engineInfo, 8) && !IsSIMDSizeSupported(params.engineInfo, 16))+ if (!IsSIMDSizeSupported(params.engineInfo, 8) && !IsSIMDSizeSupported(params.engineInfo, 16)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (params.groups > 1)+ if (params.groups > 1) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}@@ -86,10 +88,11 @@ ConvolutionKernel_mmad_b_fs_yx_fsv32::AutoTuneOption ConvolutionKernel_mmad_b_fs// TODO: Check if other block size can improve performanceoption.blockHeight = 1;option.prefetch = 1;- if (output.LogicalSize() < 49 * 1024)+ if (output.LogicalSize() < 49 * 1024) {option.blockWidth = 4;- else+ } else {option.blockWidth = 8;+ }return option;}@@ -105,8 +108,9 @@ ConvolutionKernelBase::DispatchData ConvolutionKernel_mmad_b_fs_yx_fsv32::SetDefsize_t ow_group = 8;while (ow_group > 1) {- if (CeilDiv(cp.outputs[0].X().v, dispatchData.cldnnStyle.blockWidth) % ow_group == 0)+ if (CeilDiv(cp.outputs[0].X().v, dispatchData.cldnnStyle.blockWidth) % ow_group == 0) {break;+ }ow_group--;}if (IsSIMDSizeSupported(cp.engineInfo, 8)) {diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_mmad_b_fs_yx_fsv32_dw.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_mmad_b_fs_yx_fsv32_dw.cppindex 597ef5df0f9..29c613da417 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_mmad_b_fs_yx_fsv32_dw.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_mmad_b_fs_yx_fsv32_dw.cpp@@ -50,8 +50,9 @@ bool ConvolutionKernel_mmad_b_fs_yx_fsv32_dw::Validate(const Params& p) const {auto params = dynamic_cast<const convolution_params&>(p);- if (params.inputs[0].Feature().v != params.groups || params.outputs[0].Feature().v != params.groups)+ if (params.inputs[0].Feature().v != params.groups || params.outputs[0].Feature().v != params.groups) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }if ((params.quantization == QuantizationType::ASYMMETRIC_DATA || params.quantization == QuantizationType::ASYMMETRIC_DATA_AND_WEIGHTS)&& !params.HasCompensation()) {diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_mmad_bfyx_to_b_fs_yx_fsv32.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_mmad_bfyx_to_b_fs_yx_fsv32.cppindex 7f7e06e45a5..ee16853be2f 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_mmad_bfyx_to_b_fs_yx_fsv32.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_mmad_bfyx_to_b_fs_yx_fsv32.cpp@@ -64,14 +64,17 @@ bool ConvolutionKernel_mmad_bfyx_to_b_fs_yx_fsv32::Validate(const Params &p) conauto params = dynamic_cast<const convolution_params&>(p);- if (params.inputs[0].Dimentions() != params.outputs[0].Dimentions())+ if (params.inputs[0].Dimentions() != params.outputs[0].Dimentions()) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (params.inputs[0].Feature().v != 3 && params.inputs[0].Feature().v != 4)+ if (params.inputs[0].Feature().v != 3 && params.inputs[0].Feature().v != 4) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (params.outputs[0].Feature().v % 2 != 0)+ if (params.outputs[0].Feature().v % 2 != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }if ((params.quantization == QuantizationType::ASYMMETRIC_DATA || params.quantization == QuantizationType::ASYMMETRIC_DATA_AND_WEIGHTS)&& !params.HasCompensation()) {@@ -142,8 +145,9 @@ static size_t get_slm_byte_size(const convolution_params &cp, size_t lws, size_tstatic size_t get_lws(const convolution_params &cp, size_t blocks_count, size_t block_size_x, size_t block_size_y, size_t max_lws) {while (max_lws > 1) {if (blocks_count % max_lws == 0) {- if (get_slm_byte_size(cp, max_lws, block_size_x, block_size_y) < cp.engineInfo.maxLocalMemSize)+ if (get_slm_byte_size(cp, max_lws, block_size_x, block_size_y) < cp.engineInfo.maxLocalMemSize) {return max_lws;+ }}max_lws--;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_mmad_bfyx_to_b_fs_yx_fsv4.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_mmad_bfyx_to_b_fs_yx_fsv4.cppindex c29f5129afe..785840ec48b 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_mmad_bfyx_to_b_fs_yx_fsv4.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_mmad_bfyx_to_b_fs_yx_fsv4.cpp@@ -55,8 +55,9 @@ bool ConvolutionKernel_mmad_bfyx_to_b_fs_yx_fsv4::Validate(const Params &p) consauto params = dynamic_cast<const convolution_params&>(p);- if (params.inputs[0].Feature().v != 3)+ if (params.inputs[0].Feature().v != 3) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_ref.cppindex 055e26cbb84..2a71757f0cb 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_ref.cpp@@ -114,8 +114,9 @@ KernelsPriority ConvolutionKernel_Ref::GetKernelsPriority(const Params& /*params}bool ConvolutionKernel_Ref::Validate(const Params& params) const {- if (!ConvolutionKernelBase::Validate(params))+ if (!ConvolutionKernelBase::Validate(params)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }const auto& conv_params = static_cast<const convolution_params&>(params);auto input_type = conv_params.inputs[0].GetDType();@@ -125,12 +126,14 @@ bool ConvolutionKernel_Ref::Validate(const Params& params) const {// int8/uint8 inputs (quantization case) require additional checks// require some additional checks.if (input_type != Datatype::UINT8 && input_type != Datatype::INT8 &&- output_type != Datatype::UINT8 && output_type != Datatype::INT8)+ output_type != Datatype::UINT8 && output_type != Datatype::INT8) {return true;+ }// (u)int8 input + fp weights- if (weights_type == WeightsType::F32 || weights_type == WeightsType::F16)+ if (weights_type == WeightsType::F32 || weights_type == WeightsType::F16) {return true;+ }bool is_quantization = (input_type == Datatype::INT8 || input_type == Datatype::UINT8) &&(output_type == Datatype::INT8 || output_type == Datatype::UINT8 ||@@ -141,21 +144,26 @@ bool ConvolutionKernel_Ref::Validate(const Params& params) const {!conv_params.fused_ops.empty() &&(output_type == Datatype::INT8 || output_type == Datatype::UINT8);- if (!is_quantization && !has_fused_op)+ if (!is_quantization && !has_fused_op) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }if (conv_params.quantization == QuantizationType::ASYMMETRIC_DATA_AND_WEIGHTS) {- if (conv_params.activations_zero_points.empty() || conv_params.weights_zero_points.empty())+ if (conv_params.activations_zero_points.empty() || conv_params.weights_zero_points.empty()) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }} else if (conv_params.quantization == QuantizationType::ASYMMETRIC_DATA) {- if (conv_params.activations_zero_points.empty())+ if (conv_params.activations_zero_points.empty()) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }} else if (conv_params.quantization == QuantizationType::ASYMMETRIC_WEIGHTS) {- if (conv_params.weights_zero_points.empty())+ if (conv_params.weights_zero_points.empty()) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }} else {- if (!conv_params.activations_zero_points.empty() || !conv_params.weights_zero_points.empty())+ if (!conv_params.activations_zero_points.empty() || !conv_params.weights_zero_points.empty()) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}return true;diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_ref.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_ref.hindex dd3b39961fa..79cdbb2dc58 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_ref.h+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_ref.h@@ -4,9 +4,10 @@#pragma once-#include "convolution_kernel_base.h"#include <vector>+#include "convolution_kernel_base.h"+namespace kernel_selector {class ConvolutionKernel_Ref : public ConvolutionKernelBase {@@ -19,9 +20,10 @@ public:ParamsKey GetSupportedKey() const override;protected:- WeightsLayout GetPreferredWeightsLayout(const convolution_params ¶ms) const override {- if (params.inputs[0].Dimentions() == 4)+ WeightsLayout GetPreferredWeightsLayout(const convolution_params& params) const override {+ if (params.inputs[0].Dimentions() == 4) {return (params.groups > 1) ? WeightsLayout::goiyx : WeightsLayout::oiyx;+ }return (params.groups > 1) ? WeightsLayout::goizyx : WeightsLayout::oizyx;}std::vector<FusedOpType> GetSupportedFusedOps() const override {@@ -29,10 +31,7 @@ protected:// only when fused_primitive_desc for reorder is added by optimization passes (e.g., remove_redundant_reorder) for corresponding primitive.// The typical usage for fused_primitive_desc for convolution is to get original output layout from jitter,// so that it can decide whether to fuse eltwise along with reorder.- return { FusedOpType::ELTWISE,- FusedOpType::QUANTIZE,- FusedOpType::ACTIVATION,- FusedOpType::REORDER };+ return {FusedOpType::ELTWISE, FusedOpType::QUANTIZE, FusedOpType::ACTIVATION, FusedOpType::REORDER};}JitConstants GetJitConstants(const convolution_params& params, const DispatchData& dispatchData) const override;diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_yxfb_yxio_b16.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_yxfb_yxio_b16.cppindex 28fe74ab9db..511ac308d72 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_yxfb_yxio_b16.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_yxfb_yxio_b16.cpp@@ -61,8 +61,9 @@ size_t GetBatchesPerWorkItem(size_t batch_size, Datatype dataType) {}size_t GetOfmPerWorkitem(Datatype dataType) {- if (dataType == Datatype::F16)+ if (dataType == Datatype::F16) {return 16;+ }return 8;}} // namespacediff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_yxfb_yxio_b1_block_multiple_x.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_yxfb_yxio_b1_block_multiple_x.cppindex 6eabd6ae184..fdad51e33d2 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_yxfb_yxio_b1_block_multiple_x.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_yxfb_yxio_b1_block_multiple_x.cpp@@ -31,10 +31,12 @@ DeviceFeaturesKey ConvolutionKernel_yxfb_yxio_b1_block_multiple_x::get_required_namespace {size_t GetOfmPerWorkitem(size_t filter_ofm_num, size_t localWorkSize) {- if (filter_ofm_num % (localWorkSize * 4) == 0)+ if (filter_ofm_num % (localWorkSize * 4) == 0) {return 4;- if (filter_ofm_num % (localWorkSize * 2) == 0)+ }+ if (filter_ofm_num % (localWorkSize * 2) == 0) {return 2;+ }return 1;}} // namespacediff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_yxfb_yxio_b8.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_yxfb_yxio_b8.cppindex d6761f41590..a8b08d6ebd4 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_yxfb_yxio_b8.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_kernel_yxfb_yxio_b8.cpp@@ -73,8 +73,9 @@ bool ConvolutionKernel_yxfb_yxio_b8::Validate(const Params& p) const {// Kernel uses TRANSPOSE_BLOCK_8 and subgroup block reads/writes designed for SIMD8.// With wider SIMD (e.g. SIMD16), lanes beyond 7 produce OOB filter accesses via// filter_idx2 = filter_idx + 8 (ofm_offset + sub_group_id + 8 exceeds FILTER_OFM_NUM).- if (!IsSIMDSizeSupported(params.engineInfo, 8))+ if (!IsSIMDSizeSupported(params.engineInfo, 8)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const bool bInputValidated = (filterOfmNum > 0) && (batchSize > 0) && (params.outputs[0].Feature().v == filterOfmNum);@@ -88,8 +89,9 @@ bool ConvolutionKernel_yxfb_yxio_b8::Validate(const Params& p) const {DO_NOT_USE_THIS_KERNEL(p.layerID);}- if (params.outputs[0].PitchesDifferFromLogicalDims())+ if (params.outputs[0].PitchesDifferFromLogicalDims()) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_params.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_params.cppindex 7408967c000..02fb748aca9 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_params.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/convolution_params.cpp@@ -53,10 +53,12 @@ ParamsKey convolution_params::GetParamsKey() const {if (deformable_mode) {k.EnableDeformableMode();- if (bilinear_interpolation_pad)+ if (bilinear_interpolation_pad) {k.EnableBilinearInterpolationPad();- if (deformable_mask_enabled)+ }+ if (deformable_mask_enabled) {k.EnableDeformableMask();+ }}k.EnableQuantization(quantization);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/deformable_convolution_kernel_bfyx_opt.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/deformable_convolution_kernel_bfyx_opt.cppindex 0d4a97f5362..ef093d1f2c1 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/deformable_convolution_kernel_bfyx_opt.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/deformable_convolution_kernel_bfyx_opt.cpp@@ -127,8 +127,9 @@ KernelsData DeformableConvolutionKernel_bfyx_opt::GetKernelsData(const Params& pconstexpr size_t kKernelsNum = 2;KernelData kd = KernelData::Default<convolution_params>(params, kKernelsNum);const auto& conv_params = static_cast<const convolution_params&>(params);- if (!conv_params.deformable_mode)+ if (!conv_params.deformable_mode) {return {};+ }auto preferredWeightsLayout = GetPreferredWeightsLayout(conv_params);bool succeed = UpdateWeightsParams(*static_cast<convolution_params*>(kd.params.get()),diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/deformable_convolution_kernel_bfyx_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/deformable_convolution_kernel_bfyx_ref.cppindex 5686f24f37e..212b21dc98c 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/deformable_convolution_kernel_bfyx_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/convolution/deformable_convolution_kernel_bfyx_ref.cpp@@ -43,13 +43,15 @@ KernelsPriority DeformableConvolutionKernel_bfyx_Ref::GetKernelsPriority(const P}bool DeformableConvolutionKernel_bfyx_Ref::Validate(const Params& params) const {- if (!ConvolutionKernelBase::Validate(params))+ if (!ConvolutionKernelBase::Validate(params)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }const auto& conv_params = static_cast<const convolution_params&>(params);- if (!conv_params.deformable_mode)+ if (!conv_params.deformable_mode) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/ctc_greedy_decoder/ctc_greedy_decoder_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/ctc_greedy_decoder/ctc_greedy_decoder_kernel_base.cppindex 925a94935fd..53c10f0b6b1 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/ctc_greedy_decoder/ctc_greedy_decoder_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/ctc_greedy_decoder/ctc_greedy_decoder_kernel_base.cpp@@ -44,8 +44,9 @@ CTCGreedyDecoderKernelBase::DispatchData CTCGreedyDecoderKernelBase::SetDefault(KernelsData CTCGreedyDecoderKernelBase::GetCommonKernelsData(const Params& params) const {assert(params.GetType() == KernelType::CTC_GREEDY_DECODER);- if (!Validate(params))+ if (!Validate(params)) {return {};+ }const ctc_greedy_decoder_params& orgParams = static_cast<const ctc_greedy_decoder_params&>(params);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/cum_sum/cum_sum_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/cum_sum/cum_sum_kernel_base.cppindex ba2cd893d74..ecee0efff05 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/cum_sum/cum_sum_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/cum_sum/cum_sum_kernel_base.cpp@@ -3,25 +3,26 @@//#include "cum_sum_kernel_base.h"+#include "kernel_selector_utils.h"namespace kernel_selector {Tensor::DataChannelName CumSumKernelBase::GetCumSumAxis(const cum_sum_params& params) const {switch (params.axis) {- case CumSumAxis::X:- return Tensor::DataChannelName::X;- case CumSumAxis::Y:- return Tensor::DataChannelName::Y;- case CumSumAxis::Z:- return Tensor::DataChannelName::Z;- case CumSumAxis::W:- return Tensor::DataChannelName::W;- case CumSumAxis::FEATURE:- return Tensor::DataChannelName::FEATURE;- case CumSumAxis::BATCH:- return Tensor::DataChannelName::BATCH;- default:- return Tensor::DataChannelName::BATCH;+ case CumSumAxis::X:+ return Tensor::DataChannelName::X;+ case CumSumAxis::Y:+ return Tensor::DataChannelName::Y;+ case CumSumAxis::Z:+ return Tensor::DataChannelName::Z;+ case CumSumAxis::W:+ return Tensor::DataChannelName::W;+ case CumSumAxis::FEATURE:+ return Tensor::DataChannelName::FEATURE;+ case CumSumAxis::BATCH:+ return Tensor::DataChannelName::BATCH;+ default:+ return Tensor::DataChannelName::BATCH;}}@@ -31,20 +32,24 @@ int32_t CumSumKernelBase::GetCumSumAxisIndex(const cum_sum_params& params) constsize_t CumSumKernelBase::GetRealAxisIndex(const cum_sum_params& params) const {size_t index = params.outputs[0].Dimentions() - GetCumSumAxisIndex(params) - 1;- if (params.outputs[0].Dimentions() == 6)+ if (params.outputs[0].Dimentions() == 6) {return index;- if (params.outputs[0].Dimentions() == 5)+ }+ if (params.outputs[0].Dimentions() == 5) {return (index > 1) ? index + 1 : index;+ }return (index > 1) ? index + 2 : index;}JitConstants CumSumKernelBase::GetJitConstants(const cum_sum_params& params, DispatchData) const {JitConstants jit = MakeBaseParamsJitConstants(params);- if (params.exclusive)+ if (params.exclusive) {jit.AddConstant(MakeJitConstant("EXCLUSIVE", 1));- if (params.reverse)+ }+ if (params.reverse) {jit.AddConstant(MakeJitConstant("REVERSE", 1));+ }jit.AddConstant(MakeJitConstant("AXIS", GetRealAxisIndex(params)));return jit;@@ -54,13 +59,13 @@ CumSumKernelBase::DispatchData CumSumKernelBase::SetDefault(const cum_sum_paramsDispatchData dispatchData;auto in_layout = params.inputs[0].GetLayout();auto out_layout = params.outputs[0].GetLayout();- std::vector<std::vector<Tensor::DataChannelName>> dims_by_gws = {{ Tensor::DataChannelName::BATCH },- { Tensor::DataChannelName::W, Tensor::DataChannelName::FEATURE },- { Tensor::DataChannelName::X, Tensor::DataChannelName::Y, Tensor::DataChannelName::Z }};+ std::vector<std::vector<Tensor::DataChannelName>> dims_by_gws = {{Tensor::DataChannelName::BATCH},+ {Tensor::DataChannelName::W, Tensor::DataChannelName::FEATURE},+ {Tensor::DataChannelName::X, Tensor::DataChannelName::Y, Tensor::DataChannelName::Z}};- dispatchData.gws = { params.outputs[0].Batch().v,- params.outputs[0].Feature().v * params.outputs[0].W().v,- params.outputs[0].Z().v * params.outputs[0].Y().v * params.outputs[0].X().v };+ dispatchData.gws = {params.outputs[0].Batch().v,+ params.outputs[0].Feature().v * params.outputs[0].W().v,+ params.outputs[0].Z().v * params.outputs[0].Y().v * params.outputs[0].X().v};dispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo, in_layout, out_layout, dims_by_gws);return dispatchData;@@ -94,8 +99,16 @@ KernelsData CumSumKernelBase::GetCommonKernelsData(const Params& params) const {auto& kernel = kd.kernels[0];- FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point,- "", false, false, 1,+ FillCLKernelData(kernel,+ dispatchData,+ params.engineInfo,+ kernelName,+ jit,+ entry_point,+ "",+ false,+ false,+ 1,GetFusedPrimitiveInputsCount(params),1,newParams.is_shape_agnostic);@@ -109,19 +122,21 @@ bool CumSumKernelBase::Validate(const Params& p) const {}const auto& params = static_cast<const cum_sum_params&>(p);- if (GetCumSumAxisIndex(params) == -1)+ if (GetCumSumAxisIndex(params) == -1) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (params.inputs.size() > 1 && params.inputs[1].GetDType() != Datatype::INT32 &&- params.inputs[1].GetDType() != Datatype::UINT32)+ if (params.inputs.size() > 1 && params.inputs[1].GetDType() != Datatype::INT32 && params.inputs[1].GetDType() != Datatype::UINT32) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}Datatype CumSumKernelBase::GetActivationType(const cum_sum_params& params) const {- if (params.outputs[0].GetDType() == Datatype::F16)+ if (params.outputs[0].GetDType() == Datatype::F16) {return Datatype::F16;+ }return Datatype::F32;}} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/cum_sum/cum_sum_kernel_partial_sum.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/cum_sum/cum_sum_kernel_partial_sum.cppindex 3223fbcb7c9..ceaaaf2799c 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/cum_sum/cum_sum_kernel_partial_sum.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/cum_sum/cum_sum_kernel_partial_sum.cpp@@ -54,8 +54,9 @@ JitConstants CumSumKernelPartialSum::GetJitConstants(const cum_sum_params& param}KernelsData CumSumKernelPartialSum::GetMultiStageKernelsData(const Params& params) const {- if (!Validate(params))+ if (!Validate(params)) {return {};+ }constexpr size_t kernels_num = 2;KernelData kd = KernelData::Default<cum_sum_params>(params, kernels_num);@@ -109,14 +110,16 @@ CumSumKernelPartialSum::MultiDispatchData CumSumKernelPartialSum::SetDefaultForMstd::vector<size_t> gws(3, 0);gws[0] = dims[index];for (size_t i = 0, gws_i = 1; i < dims.size(); ++i) {- if (i == index)+ if (i == index) {continue;+ }if (gws[gws_i] == 0) {gws[gws_i] = dims[i];} else {gws[gws_i] *= dims[i];- if (gws_i == 1)+ if (gws_i == 1) {++gws_i;+ }}}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_b_fs_zyx_fsv16.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_b_fs_zyx_fsv16.cppindex ad4f31d5a94..d9f46fc4cbb 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_b_fs_zyx_fsv16.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_b_fs_zyx_fsv16.cpp@@ -61,8 +61,9 @@ DeconvolutionKernelBase::DispatchData DeconvolutionKernel_b_fs_zyx_fsv16::SetDefif (ver_bsv16_fsv16) {dispatchData.gws[0] = 64;while (dispatchData.gws[0] > 16) {- if (f % dispatchData.gws[0] == 0)+ if (f % dispatchData.gws[0] == 0) {break;+ }dispatchData.gws[0] /= 2;}dispatchData.gws[1] = x * y * z;@@ -74,15 +75,17 @@ DeconvolutionKernelBase::DispatchData DeconvolutionKernel_b_fs_zyx_fsv16::SetDef} else {size_t x_block_size = 16;while (x_block_size > 1) {- if (x % x_block_size == 0)+ if (x % x_block_size == 0) {break;+ }x_block_size--;}x_block_size = std::max(x_block_size, (size_t)8);dispatchData.gws[0] = 64;while (dispatchData.gws[0] > 16) {- if (f % dispatchData.gws[0] == 0)+ if (f % dispatchData.gws[0] == 0) {break;+ }dispatchData.gws[0] /= 2;}dispatchData.gws[1] = CeilDiv(x, x_block_size) * y * z;@@ -106,15 +109,17 @@ bool DeconvolutionKernel_b_fs_zyx_fsv16::Validate(const Params& p) const {}const auto& deconv_params = static_cast<const deconvolution_params&>(p);- if (deconv_params.outputs[0].GetLayout() != deconv_params.inputs[0].GetLayout())+ if (deconv_params.outputs[0].GetLayout() != deconv_params.inputs[0].GetLayout()) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const auto& params = static_cast<const deconvolution_params&>(p);const auto feature_block_size = 16;// Check that padding features doesn't miss-align the blocks- if (params.inputs[0].Feature().pad.before % feature_block_size != 0 || params.outputs[0].Feature().pad.before % feature_block_size != 0)+ if (params.inputs[0].Feature().pad.before % feature_block_size != 0 || params.outputs[0].Feature().pad.before % feature_block_size != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}@@ -157,8 +162,9 @@ JitConstants DeconvolutionKernel_b_fs_zyx_fsv16::GetJitConstants(const deconvolu} else {iw_block = 16;while (iw_block > 1) {- if (output.X().v % iw_block == 0)+ if (output.X().v % iw_block == 0) {break;+ }iw_block--;}iw_block = std::max(iw_block, 8);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_b_fs_zyx_fsv16.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_b_fs_zyx_fsv16.hindex b01e577144a..222f5dadcea 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_b_fs_zyx_fsv16.h+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_b_fs_zyx_fsv16.h@@ -4,9 +4,10 @@#pragma once-#include "deconvolution_kernel_base.h"#include <vector>+#include "deconvolution_kernel_base.h"+namespace kernel_selector {class DeconvolutionKernel_b_fs_zyx_fsv16 : public DeconvolutionKernelBase {@@ -22,8 +23,9 @@ public:protected:WeightsLayout GetPreferredWeightsLayout(const deconvolution_params& p) const override {- if (p.outputs[0].Dimentions() == 4)+ if (p.outputs[0].Dimentions() == 4) {return WeightsLayout::is_os_yx_isv16_osv16;+ }return WeightsLayout::is_os_zyx_isv16_osv16;}bool Validate(const Params& p) const override;@@ -31,11 +33,7 @@ protected:JitConstants GetJitConstants(const deconvolution_params& params) const override;std::vector<FusedOpType> GetSupportedFusedOps() const override {- return {- FusedOpType::ACTIVATION,- FusedOpType::ELTWISE,- FusedOpType::QUANTIZE- };+ return {FusedOpType::ACTIVATION, FusedOpType::ELTWISE, FusedOpType::QUANTIZE};}};} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_b_fs_zyx_fsv16_dw.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_b_fs_zyx_fsv16_dw.cppindex a7fb05a7f86..353e68ea4c8 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_b_fs_zyx_fsv16_dw.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_b_fs_zyx_fsv16_dw.cpp@@ -160,15 +160,18 @@ bool DeconvolutionKernel_b_fs_zyx_fsv16_dw::Validate(const Params& p) const {const auto& params = static_cast<const deconvolution_params&>(p);- if (params.groups == 1)+ if (params.groups == 1) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (params.weights.IFM().v != 1 || params.weights.OFM().v != 1)+ if (params.weights.IFM().v != 1 || params.weights.OFM().v != 1) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }// Check that padding features doesn't miss-align the blocks- if (params.inputs[0].Feature().pad.before % feature_block_size != 0 || params.outputs[0].Feature().pad.before % feature_block_size != 0)+ if (params.inputs[0].Feature().pad.before % feature_block_size != 0 || params.outputs[0].Feature().pad.before % feature_block_size != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_b_fs_zyx_fsv16_dw.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_b_fs_zyx_fsv16_dw.hindex b59a3938450..6708bbeee72 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_b_fs_zyx_fsv16_dw.h+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_b_fs_zyx_fsv16_dw.h@@ -4,9 +4,10 @@#pragma once-#include "deconvolution_kernel_base.h"#include <vector>+#include "deconvolution_kernel_base.h"+namespace kernel_selector {class DeconvolutionKernel_b_fs_zyx_fsv16_dw : public DeconvolutionKernelBase {@@ -20,8 +21,9 @@ public:protected:WeightsLayout GetPreferredWeightsLayout(const deconvolution_params& p) const override {- if (p.outputs[0].GetLayout() == DataLayout::b_fs_yx_fsv16)+ if (p.outputs[0].GetLayout() == DataLayout::b_fs_yx_fsv16) {return WeightsLayout::gs_oiyx_gsv16;+ }return WeightsLayout::gs_oizyx_gsv16;}bool Validate(const Params& p) const override;@@ -29,15 +31,8 @@ protected:KernelsPriority GetKernelsPriority(const Params& params) const override;JitConstants GetJitConstants(const deconvolution_params& params) const override;- enum class weights_preload {- none,- line,- all- };- enum class input_preload {- none,- line- };+ enum class weights_preload { none, line, all };+ enum class input_preload { none, line };struct dispatch_params {size_t block_size_x;@@ -48,11 +43,7 @@ protected:float EstimateRegPressure(const deconvolution_params& params, const dispatch_params& disp_params) const;std::vector<FusedOpType> GetSupportedFusedOps() const override {- return {- FusedOpType::ACTIVATION,- FusedOpType::ELTWISE,- FusedOpType::QUANTIZE- };+ return {FusedOpType::ACTIVATION, FusedOpType::ELTWISE, FusedOpType::QUANTIZE};}};} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_base.cppindex d18955cea1d..87003f28066 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_base.cpp@@ -3,10 +3,12 @@//#include "deconvolution_kernel_base.h"-#include "kernel_selector_utils.h"++#include <algorithm>#include <string>#include <vector>-#include <algorithm>++#include "kernel_selector_utils.h"namespace kernel_selector {std::string deconvolution_params::to_string() const {@@ -14,8 +16,7 @@ std::string deconvolution_params::to_string() const {s << base_params::to_string() << "_";if (bias.empty()) {- s << "no_bias"- << "_";+ s << "no_bias" << "_";} else {s << "bias_size:" << bias[0].PhysicalSize() << "_";}@@ -44,8 +45,9 @@ bool DeconvolutionKernelBase::Validate(const Params& p) const {}for (const auto& fused_op : params.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}return true;@@ -56,17 +58,16 @@ JitConstants DeconvolutionKernelBase::GetJitConstants(const deconvolution_paramsconst auto& padding = dp.padding;const auto& input = dp.inputs[0];- int64_t input_offset_with_padding = (int64_t)input.GetFirstElementOffset() -- (dp.filterSize.x - 1 + padding.x) * input.X().pitch -- (dp.filterSize.y - 1 + padding.y) * input.Y().pitch;+ int64_t input_offset_with_padding =+ (int64_t)input.GetFirstElementOffset() - (dp.filterSize.x - 1 + padding.x) * input.X().pitch - (dp.filterSize.y - 1 + padding.y) * input.Y().pitch;input_offset_with_padding = std::max(input_offset_with_padding, (int64_t)0);- jit.AddConstants({ MakeJitConstant("STRIDE", dp.stride),- MakeJitConstant("PADDING", dp.padding),- MakeJitConstant("DILATION", dp.dilation),- MakeJitConstant("FILTER_ARRAY_NUM", 1),- MakeJitConstant("INPUT0_OFFSET_WITH_PADDING", input_offset_with_padding),- MakeJitConstant("GROUPED", (dp.groups > 1) ? 1 : 0) });+ jit.AddConstants({MakeJitConstant("STRIDE", dp.stride),+ MakeJitConstant("PADDING", dp.padding),+ MakeJitConstant("DILATION", dp.dilation),+ MakeJitConstant("FILTER_ARRAY_NUM", 1),+ MakeJitConstant("INPUT0_OFFSET_WITH_PADDING", input_offset_with_padding),+ MakeJitConstant("GROUPED", (dp.groups > 1) ? 1 : 0)});jit.Merge(MakeTypeJitConstants(GetAccumulatorType(dp), "ACCUMULATOR"));jit.Merge(MakeTypeJitConstants(GetActivationType(dp), "ACTIVATION"));@@ -100,7 +101,7 @@ KernelsData DeconvolutionKernelBase::GetKernelsData(const Params& params) constassert(params.GetType() == KernelType::DECONVOLUTION);if (!Validate(params)) {- return{};+ return {};}const deconvolution_params& orgParams = static_cast<const deconvolution_params&>(params);@@ -108,11 +109,7 @@ KernelsData DeconvolutionKernelBase::GetKernelsData(const Params& params) constKernelData kd = KernelData::Default<deconvolution_params>(params);deconvolution_params& newParams = *static_cast<deconvolution_params*>(kd.params.get());- bool succeed = UpdateWeightsParams(newParams,- GetPreferredWeightsLayout(newParams),- kd.weightsReorderParams,- GetSupportedKey(),- newParams.groups);+ bool succeed = UpdateWeightsParams(newParams, GetPreferredWeightsLayout(newParams), kd.weightsReorderParams, GetSupportedKey(), newParams.groups);if (!succeed) {return {};@@ -139,27 +136,30 @@ KernelsData DeconvolutionKernelBase::GetKernelsData(const Params& params) const}Datatype DeconvolutionKernelBase::GetAccumulatorType(const deconvolution_params& params) const {- if (params.inputs[0].GetDType() == Datatype::INT8 || params.inputs[0].GetDType() == Datatype::UINT8)+ if (params.inputs[0].GetDType() == Datatype::INT8 || params.inputs[0].GetDType() == Datatype::UINT8) {return Datatype::INT32;+ }// Use fp32 accumulator for dilated fp16 deconvolutions to avoid precision loss// during accumulation with large effective kernel sizes.- if (params.inputs[0].GetDType() == Datatype::F16 &&- (params.dilation.x > 1 || params.dilation.y > 1 || params.dilation.z > 1))+ if (params.inputs[0].GetDType() == Datatype::F16 && (params.dilation.x > 1 || params.dilation.y > 1 || params.dilation.z > 1)) {return Datatype::F32;+ }// input is either fp32 or fp16// for fp32->fp16 accumulate to fp16, otherwise accumulate to input type- if (params.outputs[0].GetDType() == Datatype::F16)+ if (params.outputs[0].GetDType() == Datatype::F16) {return Datatype::F16;+ }return params.inputs[0].GetDType();}Datatype DeconvolutionKernelBase::GetActivationType(const deconvolution_params& params) const {auto accumulator_dt = GetAccumulatorType(params);- if (accumulator_dt == Datatype::INT32)+ if (accumulator_dt == Datatype::INT32) {return Datatype::F32;+ }return accumulator_dt;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_base.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_base.hindex 5e09d353135..9db629174c9 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_base.h+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_base.h@@ -4,11 +4,12 @@#pragma once-#include "weight_bias_kernel_base.h"-#include "kernel_selector_params.h"#include <string>#include <vector>+#include "kernel_selector_params.h"+#include "weight_bias_kernel_base.h"+namespace kernel_selector {////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// deconvolution_params@@ -54,9 +55,10 @@ protected:using WeightBiasKernelBase::GetJitConstants;virtual JitConstants GetJitConstants(const deconvolution_params& params) const;virtual DispatchData SetDefault(const deconvolution_params& params) const;- virtual WeightsLayout GetPreferredWeightsLayout(const deconvolution_params ¶ms) const {- if (params.inputs[0].Dimentions() == 4)+ virtual WeightsLayout GetPreferredWeightsLayout(const deconvolution_params& params) const {+ if (params.inputs[0].Dimentions() == 4) {return (params.groups > 1) ? WeightsLayout::goiyx : WeightsLayout::oiyx;+ }return (params.groups > 1) ? WeightsLayout::goizyx : WeightsLayout::oizyx;}bool Validate(const Params& p) const override;diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_imad_along_f_tile_bfx.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_imad_along_f_tile_bfx.cppindex 8f49780df59..714b124ca5c 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_imad_along_f_tile_bfx.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_imad_along_f_tile_bfx.cpp@@ -4,17 +4,17 @@#include "deconvolution_kernel_imad_along_f_tile_bfx.hpp"-#include "kernel_selector_utils.h"-#include <algorithm>-#include <vector>#include <iostream>#include <string>+#include <vector>++#include "kernel_selector_utils.h"namespace kernel_selector {namespace {- constexpr size_t simd = 16;+constexpr size_t simd = 16;}ParamsKey DeconvolutionKernel_imad_along_f_tile_bfx::GetSupportedKey() const {@@ -65,16 +65,19 @@ DeviceFeaturesKey DeconvolutionKernel_imad_along_f_tile_bfx::get_required_device}bool DeconvolutionKernel_imad_along_f_tile_bfx::Validate(const Params& p) const {- if (!Parent::Validate(p))+ if (!Parent::Validate(p)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const auto& params = static_cast<const deconvolution_params&>(p);- if (params.groups > 1 && params.weights.IFM().v % 4 != 0)+ if (params.groups > 1 && params.weights.IFM().v % 4 != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }// Consider loosening at the cost of performance- if (params.groups > 1 && params.weights.OFM().v % simd != 0)+ if (params.groups > 1 && params.weights.OFM().v % simd != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}@@ -84,13 +87,12 @@ WeightsLayout DeconvolutionKernel_imad_along_f_tile_bfx::GetPreferredWeightsLayousing layout_map_key = std::tuple<size_t, size_t>;using layout_map = std::map<layout_map_key, WeightsLayout>;- layout_map lt_map = {- {layout_map_key((size_t)4, (size_t)16), WeightsLayout::g_os_zyx_is_osv16_isv4 },- {layout_map_key((size_t)16, (size_t)16), WeightsLayout::g_os_zyx_is_osv16_isv16 },- {layout_map_key((size_t)32, (size_t)16), WeightsLayout::g_os_zyx_is_osv16_isv32 },- {layout_map_key((size_t)4, (size_t)32), WeightsLayout::g_os_zyx_is_osv32_isv4 },- {layout_map_key((size_t)16, (size_t)32), WeightsLayout::g_os_zyx_is_osv32_isv16 },- {layout_map_key((size_t)32, (size_t)32), WeightsLayout::g_os_zyx_is_osv32_isv32 }};+ layout_map lt_map = {{layout_map_key((size_t)4, (size_t)16), WeightsLayout::g_os_zyx_is_osv16_isv4},+ {layout_map_key((size_t)16, (size_t)16), WeightsLayout::g_os_zyx_is_osv16_isv16},+ {layout_map_key((size_t)32, (size_t)16), WeightsLayout::g_os_zyx_is_osv16_isv32},+ {layout_map_key((size_t)4, (size_t)32), WeightsLayout::g_os_zyx_is_osv32_isv4},+ {layout_map_key((size_t)16, (size_t)32), WeightsLayout::g_os_zyx_is_osv32_isv16},+ {layout_map_key((size_t)32, (size_t)32), WeightsLayout::g_os_zyx_is_osv32_isv32}};auto tile_ifm = GetTileIFM(params);auto tile_ofm_simd = GetTileOFM(params) * simd;@@ -111,13 +113,11 @@ DeconvolutionKernelBase::DispatchData DeconvolutionKernel_imad_along_f_tile_bfx:auto tile_ofm = GetTileOFM(params);auto tile_b = GetTileB(params);- dispatchData.gws = {- CeilDiv(params.outputs[0].X().v, tile_x) * params.outputs[0].Y().v * params.outputs[0].Z().v,- Align(CeilDiv(params.outputs[0].Feature().v, tile_ofm), simd),- CeilDiv(params.outputs[0].Batch().v, tile_b)- };+ dispatchData.gws = {CeilDiv(params.outputs[0].X().v, tile_x) * params.outputs[0].Y().v * params.outputs[0].Z().v,+ Align(CeilDiv(params.outputs[0].Feature().v, tile_ofm), simd),+ CeilDiv(params.outputs[0].Batch().v, tile_b)};- dispatchData.lws = { 1, simd, 1 };+ dispatchData.lws = {1, simd, 1};return dispatchData;}@@ -126,8 +126,9 @@ KernelsPriority DeconvolutionKernel_imad_along_f_tile_bfx::GetKernelsPriority(coconst auto& p = static_cast<const deconvolution_params&>(params);// Currently most optimized for fsv16 formats- if (p.inputs[0].GetLayout() == DataLayout::b_fs_yx_fsv16 || p.inputs[0].GetLayout() == DataLayout::b_fs_zyx_fsv16)+ if (p.inputs[0].GetLayout() == DataLayout::b_fs_yx_fsv16 || p.inputs[0].GetLayout() == DataLayout::b_fs_zyx_fsv16) {return FORCE_PRIORITY_7;+ }return FORCE_PRIORITY_8;}@@ -183,36 +184,34 @@ JitConstants DeconvolutionKernel_imad_along_f_tile_bfx::GetJitConstants(const deauto fused_in_dt = GetActivationType(params);std::vector<std::string> idx_order;if (params.outputs[0].Dimentions() <= 4) {- idx_order = { "(out_b + ob)", "(out_f + of * SIMD)", "out_y", "(out_x + tx)" };+ idx_order = {"(out_b + ob)", "(out_f + of * SIMD)", "out_y", "(out_x + tx)"};} else {- idx_order = { "(out_b + ob)", "(out_f + of * SIMD)", "out_z", "out_y", "(out_x + tx)" };+ idx_order = {"(out_b + ob)", "(out_f + of * SIMD)", "out_z", "out_y", "(out_x + tx)"};}auto boundary_check = BoundaryCheck::DISABLED;- if (params.outputs[0].X().v % tile_x != 0- || params.outputs[0].Feature().v % (tile_ofm * simd) != 0- || params.outputs[0].Batch().v % tile_b != 0) {+ if (params.outputs[0].X().v % tile_x != 0 || params.outputs[0].Feature().v % (tile_ofm * simd) != 0 || params.outputs[0].Batch().v % tile_b != 0) {boundary_check = BoundaryCheck::ENABLED;}- std::vector<Tensor::DataChannelName> loop_axes = { Tensor::DataChannelName::X };+ std::vector<Tensor::DataChannelName> loop_axes = {Tensor::DataChannelName::X};if (tile_b != 1) {loop_axes.push_back(Tensor::DataChannelName::BATCH);} else {idx_order[0] = "out_b";}- auto conf = FusedOpsConfiguration{ "",- idx_order,- "dequantized[ob][of][tx]",- fused_in_dt,- 1,- LoadType::LT_UNALIGNED,- boundary_check,- IndexType::TENSOR_COORD,- Tensor::DataChannelName::X,- loop_axes,- true };-- jit.Merge(MakeFusedOpsJitConstants(params, { conf }));+ auto conf = FusedOpsConfiguration{"",+ idx_order,+ "dequantized[ob][of][tx]",+ fused_in_dt,+ 1,+ LoadType::LT_UNALIGNED,+ boundary_check,+ IndexType::TENSOR_COORD,+ Tensor::DataChannelName::X,+ loop_axes,+ true};++ jit.Merge(MakeFusedOpsJitConstants(params, {conf}));}return jit;@@ -220,14 +219,11 @@ JitConstants DeconvolutionKernel_imad_along_f_tile_bfx::GetJitConstants(const desize_t DeconvolutionKernel_imad_along_f_tile_bfx::GetTileIFM(const deconvolution_params& params) const {size_t fsv = 4;- if (params.inputs[0].GetLayout() == DataLayout::b_fs_yx_fsv16- || params.inputs[0].GetLayout() == DataLayout::b_fs_zyx_fsv16- || params.inputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv16_fsv16- || params.inputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv16_fsv16) {+ if (params.inputs[0].GetLayout() == DataLayout::b_fs_yx_fsv16 || params.inputs[0].GetLayout() == DataLayout::b_fs_zyx_fsv16 ||+ params.inputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv16_fsv16 || params.inputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv16_fsv16) {fsv = 16;}- if (params.inputs[0].GetLayout() == DataLayout::b_fs_yx_fsv32- || params.inputs[0].GetLayout() == DataLayout::b_fs_zyx_fsv32) {+ if (params.inputs[0].GetLayout() == DataLayout::b_fs_yx_fsv32 || params.inputs[0].GetLayout() == DataLayout::b_fs_zyx_fsv32) {fsv = 32;}@@ -235,35 +231,38 @@ size_t DeconvolutionKernel_imad_along_f_tile_bfx::GetTileIFM(const deconvolutionbool grouped = params.groups > 1;auto pref_tile_ifm = std::min(fsv, ifm);- std::vector<size_t> allowed_tile_ifm = { 4, 16, 32 };+ std::vector<size_t> allowed_tile_ifm = {4, 16, 32};size_t tile_ifm = 1;for (auto candidate : allowed_tile_ifm) {- if (candidate <= pref_tile_ifm- && (!grouped || ifm % candidate == 0))+ if (candidate <= pref_tile_ifm && (!grouped || ifm % candidate == 0)) {tile_ifm = candidate;+ }}return tile_ifm;}size_t DeconvolutionKernel_imad_along_f_tile_bfx::GetTileOFM(const deconvolution_params& params) const {// TODO Loosen divisibility requirement for tile ofm 2- if (params.weights.OFM().v % (simd * 2) == 0 && params.outputs[0].Batch().v % 2 != 0)+ if (params.weights.OFM().v % (simd * 2) == 0 && params.outputs[0].Batch().v % 2 != 0) {return 2;+ }return 1;}size_t DeconvolutionKernel_imad_along_f_tile_bfx::GetTileX(const deconvolution_params& params) const {constexpr size_t max_tile_x = simd;- if (params.outputs[0].X().v <= max_tile_x)+ if (params.outputs[0].X().v <= max_tile_x) {return params.outputs[0].X().v;+ }return max_tile_x;}size_t DeconvolutionKernel_imad_along_f_tile_bfx::GetTileB(const deconvolution_params& params) const {- if (params.outputs[0].Batch().v % 2 == 0)+ if (params.outputs[0].Batch().v % 2 == 0) {return 2;+ }return 1;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_ref.cppindex 29899b72b1d..be3338db448 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/deconvolution/deconvolution_kernel_ref.cpp@@ -90,8 +90,9 @@ KernelsPriority DeconvolutionKernelRef::GetKernelsPriority(const Params& /*paramJitConstants DeconvolutionKernelRef::GetJitConstants(const deconvolution_params& params) const {auto jit = DeconvolutionKernelBase::GetJitConstants(params);- if (params.outputs[0].Feature().v * params.outputs[0].Batch().v <= 16)+ if (params.outputs[0].Feature().v * params.outputs[0].Batch().v <= 16) {jit.AddConstant(MakeJitConstant("DIM_ORDER_XYBF", 1));+ }if (!params.fused_ops.empty()) {auto fused_dt = GetActivationType(params);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/depth_to_space/depth_to_space_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/depth_to_space/depth_to_space_kernel_base.cppindex 301e96cf08e..37c00c14fcc 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/depth_to_space/depth_to_space_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/depth_to_space/depth_to_space_kernel_base.cpp@@ -3,10 +3,12 @@//#include "depth_to_space_kernel_base.h"-#include "kernel_selector_utils.h"+#include <string>#include <vector>+#include "kernel_selector_utils.h"+namespace kernel_selector {bool DepthToSpaceKernelBase::Validate(const Params& p) const {@@ -16,12 +18,14 @@ bool DepthToSpaceKernelBase::Validate(const Params& p) const {const depth_to_space_params& params = static_cast<const depth_to_space_params&>(p);for (const auto& fused_op : params.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}- if (params.inputs[0].Dimentions() > 5)+ if (params.inputs[0].Dimentions() > 5) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}@@ -54,9 +58,18 @@ KernelsData DepthToSpaceKernelBase::GetCommonKernelsData(const Params& params) cauto& kernel = kd.kernels[0];- FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point,- EXE_MODE_DEFAULT, false, false, 1, GetFusedPrimitiveInputsCount(params));+ FillCLKernelData(kernel,+ dispatchData,+ params.engineInfo,+ kernelName,+ jit,+ entry_point,+ EXE_MODE_DEFAULT,+ false,+ false,+ 1,+ GetFusedPrimitiveInputsCount(params));- return { kd };+ return {kd};}} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/depth_to_space/depth_to_space_kernel_block2_opt.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/depth_to_space/depth_to_space_kernel_block2_opt.cppindex fd844d1d0f8..5056147f2b8 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/depth_to_space/depth_to_space_kernel_block2_opt.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/depth_to_space/depth_to_space_kernel_block2_opt.cpp@@ -18,16 +18,19 @@ ParamsKey DepthToSpaceKernelBlock2Opt::GetSupportedKey() const {}bool DepthToSpaceKernelBlock2Opt::Validate(const Params& p) const {- if (!DepthToSpaceKernelBase::Validate(p))+ if (!DepthToSpaceKernelBase::Validate(p)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const auto& params = static_cast<const depth_to_space_params&>(p);- if ((params.block_size != 2) || (params.inputs[0].X().v % 2 != 0))+ if ((params.block_size != 2) || (params.inputs[0].X().v % 2 != 0)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (params.mode != DepthToSpaceMode::BLOCKS_FIRST)+ if (params.mode != DepthToSpaceMode::BLOCKS_FIRST) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/detection_output/detection_output_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/detection_output/detection_output_kernel_ref.cppindex d771557da77..6c0d2b18f2c 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/detection_output/detection_output_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/detection_output/detection_output_kernel_ref.cpp@@ -200,8 +200,9 @@ void DetectionOutputKernelRef::SetKernelArguments(const detection_output_params&KernelsData DetectionOutputKernelRef::GetKernelsData(const Params& params) const {assert(params.GetType() == KernelType::DETECTION_OUTPUT);- if (!Validate(params))+ if (!Validate(params)) {return {};+ }constexpr size_t kKernelsNum = 4;KernelData kd = KernelData::Default<detection_output_params>(params, kKernelsNum);@@ -268,8 +269,9 @@ KernelsData DetectionOutputKernelRef::GetKernelsData(const Params& params) const// stack [LWS1 * LWS2 * 100 (stack_size) * 4 (int size) bytes]auto req_local_mem_size = dispatchData.lws[1] * dispatchData.lws[2] * 2 * 4 +dispatchData.lws[1] * dispatchData.lws[2] * stack_size * 4;- if (req_local_mem_size < detectOutParams.engineInfo.maxLocalMemSize)+ if (req_local_mem_size < detectOutParams.engineInfo.maxLocalMemSize) {cldnnJit.AddConstant(MakeJitConstant("USE_LOCAL_MEMORY_FOR_STACK", true));+ }cldnnJit.AddConstants({MakeJitConstant("DO_STAGE_" + std::to_string(i) + "_CAFFE", "true"),MakeJitConstant("LOCAL_CLASS_NUM", dispatchData.lws[1]),MakeJitConstant("LOCAL_WORK_NUM", dispatchData.lws[2]),@@ -306,8 +308,9 @@ KernelsData DetectionOutputKernelRef::GetKernelsData(const Params& params) constreturn static_cast<float>(bytes_used) / static_cast<float>(max_reg_bytes);};- if (estimateRegPressure() > 0.8)+ if (estimateRegPressure() > 0.8) {cldnnJit.AddConstant(MakeJitConstant("USE_LOCAL_MEMORY", "true"));+ }cldnnJit.AddConstant(MakeJitConstant("DO_STAGE_" + std::to_string(i) + "_CAFFE_OPT", "true"));} else {@@ -322,8 +325,9 @@ KernelsData DetectionOutputKernelRef::GetKernelsData(const Params& params) const} else {// Limit local memory usage for stack buffer [LWS0 * 100 (stack_size) * 4 (int size) bytes]auto req_local_mem_size = dispatchData.lws[0] * stack_size * 4;- if (req_local_mem_size < detectOutParams.engineInfo.maxLocalMemSize)+ if (req_local_mem_size < detectOutParams.engineInfo.maxLocalMemSize) {cldnnJit.AddConstant(MakeJitConstant("USE_LOCAL_MEMORY_FOR_STACK", true));+ }cldnnJit.AddConstants({MakeJitConstant("DO_STAGE_" + std::to_string(i) + "_CAFFE", "true"),MakeJitConstant("LOCAL_BATCHES_NUM", dispatchData.lws[0])});}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/dft/dft_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/dft/dft_kernel_ref.cppindex 1974d78553d..2bcaf7040b3 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/dft/dft_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/dft/dft_kernel_ref.cpp@@ -215,10 +215,11 @@ JitConstants DFTKernelRef::GetJitConstants(const dft_params& params) const {// when axis is negative value, convert to positive.if (axis < 0) {// RDFT has converted by r + a, others r -1 + a by op specification- if (params.mode == dft_params::Mode::real && params.direction == dft_params::Direction::forward)+ if (params.mode == dft_params::Mode::real && params.direction == dft_params::Direction::forward) {axis = out_rank -1 + axis; // (out_rank-1) is in_rank- else+ } else {axis = in_rank -1 + axis;+ }}auto inverted_axis = dims_size - axis;diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/dynamic_quantize/dynamic_quantize_kernel_opt.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/dynamic_quantize/dynamic_quantize_kernel_opt.cppindex a8dcd97ff16..944ba0cc76b 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/dynamic_quantize/dynamic_quantize_kernel_opt.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/dynamic_quantize/dynamic_quantize_kernel_opt.cpp@@ -23,12 +23,14 @@ enum class DynQuanMode {static size_t get_input_f_size(const dynamic_quantize_params& params) {size_t input_f = params.inputs[0].Feature().v;// 3D input- if (params.outputs[0].GetLayout() == DataLayout::bfyx)+ if (params.outputs[0].GetLayout() == DataLayout::bfyx) {input_f = params.inputs[0].Y().v * params.inputs[0].X().v;+ }// In Some model, input_f could be dynamic in input0. It refers to IFM value of weight.- if (params.inputs[0].is_dynamic() && input_f == 0)+ if (params.inputs[0].is_dynamic() && input_f == 0) {return params.fc_ifm_size;+ }return input_f;}@@ -36,8 +38,9 @@ static size_t get_input_f_size(const dynamic_quantize_params& params) {static std::pair<size_t, size_t> get_input_bf_size(const dynamic_quantize_params& params) {size_t input_batch = params.inputs[0].Batch().v;// 3D input- if (params.outputs[0].GetLayout() == DataLayout::bfyx)+ if (params.outputs[0].GetLayout() == DataLayout::bfyx) {input_batch = params.inputs[0].Batch().v * params.inputs[0].Feature().v;+ }// Validate() rejects this kernel when the size cannot be resolved, so it is known to be set hereconst auto input_f = get_input_f_size(params);@@ -183,8 +186,9 @@ void DynamicQuantizeKernelOpt::GetUpdateDispatchDataFunc(KernelData& kd) const {KernelsData DynamicQuantizeKernelOpt::GetKernelsData(const Params& params) const {assert(params.GetType() == KernelType::DYNAMIC_QUANTIZE);- if (!Validate(params))+ if (!Validate(params)) {return {};+ }const dynamic_quantize_params& prim_params = static_cast<const dynamic_quantize_params&>(params);auto dispatchData = SetDefault(prim_params);@@ -220,26 +224,30 @@ KernelsPriority DynamicQuantizeKernelOpt::GetKernelsPriority(const Params& /*par}bool DynamicQuantizeKernelOpt::Validate(const Params& params) const {- if (!KernelBaseOpenCL::Validate(params))+ if (!KernelBaseOpenCL::Validate(params)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }const auto& dq_params = static_cast<const dynamic_quantize_params&>(params);// The group count is baked into the kernel at compile time, so it cannot be built without knowing// the length of the dimension the groups are formed along- if (get_input_f_size(dq_params) == 0)+ if (get_input_f_size(dq_params) == 0) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }- if (get_dynamic_quantize_mode(dq_params) == DynQuanMode::PER_TOKEN && dq_params.generate_precomputed_reduction)+ if (get_dynamic_quantize_mode(dq_params) == DynQuanMode::PER_TOKEN && dq_params.generate_precomputed_reduction) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }if (dq_params.generate_precomputed_reduction && cldnn::one_of(dq_params.outputs[0].GetDType(), {Datatype::F8E4M3, Datatype::F8E5M2})) {DO_NOT_USE_THIS_KERNEL(params.layerID);}auto bf = get_input_bf_size(dq_params);- if (((bf.second) % (simd * 2)) != 0)+ if (((bf.second) % (simd * 2)) != 0) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }// For MODE_LARGE_GS, ensure the quantization group fits within a single work_group// There is no cross work_group synchronization.@@ -255,30 +263,37 @@ bool DynamicQuantizeKernelOpt::Validate(const Params& params) const {}}- if (dq_params.inputs[0].GetPaddedVal() != 0 || dq_params.outputs[0].GetPaddedVal() != 0)+ if (dq_params.inputs[0].GetPaddedVal() != 0 || dq_params.outputs[0].GetPaddedVal() != 0) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }- if (dq_params.append_axis != -1)+ if (dq_params.append_axis != -1) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }for (size_t i = 0; i < dq_params.group_sizes.size() - 1; i++) {- if (dq_params.group_sizes[i] != 1)+ if (dq_params.group_sizes[i] != 1) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}// Allow only default scales orderconst auto& scales_output_order = dq_params.scales_output_order;if (!scales_output_order.empty()) {- for (size_t i = 0; i < scales_output_order.size(); i++)- if (scales_output_order[i] != i)+ for (size_t i = 0; i < scales_output_order.size(); i++) {+ if (scales_output_order[i] != i) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }+ }}if (dq_params.use_asymmetric_quantization) {- if (dq_params.combine_scales_and_zp)+ if (dq_params.combine_scales_and_zp) {DO_NOT_USE_THIS_KERNEL(params.layerID);- if (dq_params.outputs[0].GetDType() != Datatype::UINT8)+ }+ if (dq_params.outputs[0].GetDType() != Datatype::UINT8) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}return true;diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/dynamic_quantize/dynamic_quantize_kernel_opt_kv_cache.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/dynamic_quantize/dynamic_quantize_kernel_opt_kv_cache.cppindex c0a47c23dc2..19f3c8e70da 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/dynamic_quantize/dynamic_quantize_kernel_opt_kv_cache.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/dynamic_quantize/dynamic_quantize_kernel_opt_kv_cache.cpp@@ -75,11 +75,13 @@ static size_t get_per_iter_elements_number(const dynamic_quantize_params& paramsconst auto maxWorkGroupSize = params.engineInfo.maxWorkGroupSize;const auto total_grouped_elements = get_elements_number_per_group(params);- if (total_grouped_elements % maxWorkGroupSize == 0)+ if (total_grouped_elements % maxWorkGroupSize == 0) {return maxWorkGroupSize;+ }- if (total_grouped_elements < maxWorkGroupSize)+ if (total_grouped_elements < maxWorkGroupSize) {return total_grouped_elements;+ }return 0;}@@ -166,8 +168,9 @@ JitConstants DynamicQuantizeKernelKVCache::GetJitConstants(const dynamic_quantizfor (size_t i = 0; i < scales_output_order.size(); i++) {ss << default_dim_order[scales_output_order[i]];- if (i + 1 != scales_output_order.size())+ if (i + 1 != scales_output_order.size()) {ss << ", ";+ }}jit.AddConstant(MakeJitConstant("SCALES_OUTPUT_ORDER", ss.str()));@@ -217,8 +220,9 @@ void DynamicQuantizeKernelKVCache::GetUpdateDispatchDataFunc(KernelData& kd) conKernelsData DynamicQuantizeKernelKVCache::GetKernelsData(const Params& params) const {assert(params.GetType() == KernelType::DYNAMIC_QUANTIZE);- if (!Validate(params))+ if (!Validate(params)) {return {};+ }const dynamic_quantize_params& prim_params = static_cast<const dynamic_quantize_params&>(params);auto dispatchData = SetDefault(prim_params);@@ -246,8 +250,9 @@ KernelsData DynamicQuantizeKernelKVCache::GetKernelsData(const Params& params) cstatic_cast<int>(prim_params.outputs.size()),prim_params.is_shape_agnostic);- if (prim_params.append_axis != -1)+ if (prim_params.append_axis != -1) {kernel.params.arguments.push_back({ArgumentDescriptor::Types::SCALAR, 0});+ }return {kd};}@@ -257,8 +262,9 @@ KernelsPriority DynamicQuantizeKernelKVCache::GetKernelsPriority(const Params& /}bool DynamicQuantizeKernelKVCache::Validate(const Params& params) const {- if (!KernelBaseOpenCL::Validate(params))+ if (!KernelBaseOpenCL::Validate(params)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }const auto& dq_params = static_cast<const dynamic_quantize_params&>(params);@@ -266,11 +272,13 @@ bool DynamicQuantizeKernelKVCache::Validate(const Params& params) const {const auto& input_dims = get_normalized_dims(dq_params.inputs[0]);const size_t non_compressed_dims_number = std::count(group_sizes.begin(), group_sizes.end(), 1);- if (dq_params.generate_precomputed_reduction)+ if (dq_params.generate_precomputed_reduction) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }- if (non_compressed_dims_number == group_sizes.size())+ if (non_compressed_dims_number == group_sizes.size()) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }for (size_t i = 0; i < group_sizes.size(); i++) {if (group_sizes[i] != 1 && input_dims[i].is_dynamic) {@@ -279,16 +287,19 @@ bool DynamicQuantizeKernelKVCache::Validate(const Params& params) const {}// Last dimension should be static, reduced by group_sizes configuration and divisible by 16- if (group_sizes.back() == 1 || input_dims.back().is_dynamic || input_dims.back().v % subgroup_size != 0)+ if (group_sizes.back() == 1 || input_dims.back().is_dynamic || input_dims.back().v % subgroup_size != 0) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }// Limit the size of the innermost dimension- if (input_dims.back().v > 256)+ if (input_dims.back().v > 256) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }// In case of HEADS_NUM * HEAD_SIZE group size, check that it fits into the supported workgroup size limit- if (get_elements_number_per_group(dq_params) / input_dims.back().v >= params.engineInfo.maxWorkGroupSize / subgroup_size)+ if (get_elements_number_per_group(dq_params) / input_dims.back().v >= params.engineInfo.maxWorkGroupSize / subgroup_size) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/dynamic_quantize/dynamic_quantize_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/dynamic_quantize/dynamic_quantize_kernel_ref.cppindex f59bb1c8385..1290c95e836 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/dynamic_quantize/dynamic_quantize_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/dynamic_quantize/dynamic_quantize_kernel_ref.cpp@@ -49,8 +49,9 @@ JitConstants DynamicQuantizeKernelRef::GetJitConstants(const dynamic_quantize_pafor (size_t i = 0; i < scales_output_order.size(); i++) {ss << default_dim_order[scales_output_order[i]];- if (i + 1 != scales_output_order.size())+ if (i + 1 != scales_output_order.size()) {ss << ", ";+ }}jit.AddConstant(MakeJitConstant("SCALES_OUTPUT_ORDER", ss.str()));@@ -101,8 +102,9 @@ CommonDispatchData DynamicQuantizeKernelRef::SetDefault(const dynamic_quantize_pparams.outputs[0].Batch().v, ",", params.outputs[0].Feature().v, ",", params.outputs[0].Y().v, ",", params.outputs[0].X().v, ")");// Grouped quantization is supported only over y axis- if (params.group_sizes[2] > 1 && params.group_sizes[2] != UINT64_MAX)+ if (params.group_sizes[2] > 1 && params.group_sizes[2] != UINT64_MAX) {y_size = params.outputs[0].Y().v / params.group_sizes[2];+ }dispatchData.gws = {batch_size * feature_size, y_size, x_size};dispatchData.lws = {1, 1, 1};@@ -124,8 +126,9 @@ void DynamicQuantizeKernelRef::GetUpdateDispatchDataFunc(KernelData& kd) const {KernelsData DynamicQuantizeKernelRef::GetKernelsData(const Params& params) const {assert(params.GetType() == KernelType::DYNAMIC_QUANTIZE);- if (!Validate(params))+ if (!Validate(params)) {return {};+ }const dynamic_quantize_params& prim_params = static_cast<const dynamic_quantize_params&>(params);auto dispatchData = SetDefault(prim_params);@@ -161,8 +164,9 @@ KernelsPriority DynamicQuantizeKernelRef::GetKernelsPriority(const Params& /*par}bool DynamicQuantizeKernelRef::Validate(const Params& params) const {- if (!KernelBaseOpenCL::Validate(params))+ if (!KernelBaseOpenCL::Validate(params)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }const auto& dq_params = static_cast<const dynamic_quantize_params&>(params);if (dq_params.generate_precomputed_reduction && cldnn::one_of(dq_params.outputs[0].GetDType(), {Datatype::F4E2M1, Datatype::F8E4M3, Datatype::F8E5M2})) {diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/ed_pgg/prior_grid_generator_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/ed_pgg/prior_grid_generator_kernel_ref.cppindex cf0efe4df4b..0d6886de1c5 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/ed_pgg/prior_grid_generator_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/ed_pgg/prior_grid_generator_kernel_ref.cpp@@ -10,10 +10,10 @@ namespace kernel_selector {namespace {-CommonDispatchData SetDefault(const experimental_detectron_prior_grid_generator_params ¶ms) {+CommonDispatchData SetDefault(const experimental_detectron_prior_grid_generator_params& params) {CommonDispatchData dispatchData;- dispatchData.gws = { params.layer_height, params.layer_width, params.inputs[0].Batch().v };+ dispatchData.gws = {params.layer_height, params.layer_width, params.inputs[0].Batch().v};dispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo);return dispatchData;@@ -21,18 +21,19 @@ CommonDispatchData SetDefault(const experimental_detectron_prior_grid_generator_} // namespace-KernelsData ExperimentalDetectronPriorGridGeneratorKernelRef::GetKernelsData(const Params ¶ms) const {+KernelsData ExperimentalDetectronPriorGridGeneratorKernelRef::GetKernelsData(const Params& params) const {KernelsData kernels_data;- if (!Validate(params))+ if (!Validate(params)) {return kernels_data;+ }kernels_data.push_back(KernelData::Default<experimental_detectron_prior_grid_generator_params>(params));- KernelData &kernel_data = kernels_data.front();- auto &derived_params = dynamic_cast<experimental_detectron_prior_grid_generator_params&>(*kernel_data.params.get());+ KernelData& kernel_data = kernels_data.front();+ auto& derived_params = dynamic_cast<experimental_detectron_prior_grid_generator_params&>(*kernel_data.params.get());auto dispatch_data = SetDefault(derived_params);auto entry_point = GetEntryPoint(kernelName, derived_params.layerID, params);auto jit_constants = GetJitConstants(derived_params);auto jit = CreateJit(kernelName, jit_constants, entry_point);- auto &clKernelData = kernel_data.kernels[0];+ auto& clKernelData = kernel_data.kernels[0];FillCLKernelData(clKernelData, dispatch_data, params.engineInfo, kernelName, jit, entry_point);return kernels_data;}@@ -53,13 +54,15 @@ ParamsKey ExperimentalDetectronPriorGridGeneratorKernelRef::GetSupportedKey() coreturn k;}-bool ExperimentalDetectronPriorGridGeneratorKernelRef::Validate(const Params &p) const {- if (p.GetType() != KernelType::EXPERIMENTAL_DETECTRON_PRIOR_GRID_GENERATOR)+bool ExperimentalDetectronPriorGridGeneratorKernelRef::Validate(const Params& p) const {+ if (p.GetType() != KernelType::EXPERIMENTAL_DETECTRON_PRIOR_GRID_GENERATOR) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const auto& params = dynamic_cast<const experimental_detectron_prior_grid_generator_params&>(p);- if (params.inputs.size() != 1)+ if (params.inputs.size() != 1) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_base.cppindex dfa65463118..bf66344c1ca 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_base.cpp@@ -3,10 +3,12 @@//#include "eltwise_kernel_base.h"-#include "kernel_selector_utils.h"+#include <string>#include <vector>+#include "kernel_selector_utils.h"+namespace kernel_selector {namespace {std::vector<size_t> GetLimitedOptimalLocalWorkGroupSizes(std::vector<size_t> gws, const EngineInfo& info, std::vector<size_t> limited_size_lws) {@@ -17,9 +19,11 @@ std::vector<size_t> GetLimitedOptimalLocalWorkGroupSizes(std::vector<size_t> gwsfor (size_t i = 0; i < gws.size(); ++i) {auto rest_lws = lws_max / total_lws;size_t lws_idx = 0;- while (rest_lws < optimal_lws_values[lws_idx] || optimal_lws_values[lws_idx] > limited_size_lws[i]) lws_idx++;+ while (rest_lws < optimal_lws_values[lws_idx] || optimal_lws_values[lws_idx] > limited_size_lws[i])+ lws_idx++;- while (gws[i] % optimal_lws_values[lws_idx]) lws_idx++;+ while (gws[i] % optimal_lws_values[lws_idx])+ lws_idx++;lws.push_back(optimal_lws_values[lws_idx]);total_lws *= optimal_lws_values[lws_idx];@@ -30,41 +34,41 @@ std::vector<size_t> GetLimitedOptimalLocalWorkGroupSizes(std::vector<size_t> gwsuint32_t GetNumberOfInputs(EltwiseMode m) {switch (m) {- case EltwiseMode::ADD:- case EltwiseMode::SUB:- case EltwiseMode::MUL:- case EltwiseMode::DIV:- case EltwiseMode::MIN:- case EltwiseMode::MAX:- case EltwiseMode::POW:- case EltwiseMode::MODULU:- case EltwiseMode::EQ:- case EltwiseMode::NE:- case EltwiseMode::LT:- case EltwiseMode::LE:- case EltwiseMode::GT:- case EltwiseMode::GE:- case EltwiseMode::LOGIC_AND:- case EltwiseMode::LOGIC_OR:- case EltwiseMode::LOGIC_XOR:- case EltwiseMode::SQUARED_DIFF:- case EltwiseMode::FLOOR_MOD:- case EltwiseMode::RIGHT_SHIFT:- case EltwiseMode::LEFT_SHIFT:- case EltwiseMode::BITWISE_AND:- case EltwiseMode::BITWISE_OR:- case EltwiseMode::BITWISE_XOR:- case EltwiseMode::ATAN2:- return 2;- case EltwiseMode::SQRT:- case EltwiseMode::RSQRT:- case EltwiseMode::ASSIGN:- case EltwiseMode::IS_FINITE:- case EltwiseMode::IS_INF:- case EltwiseMode::IS_NAN:- return 1;- default:- return 0;+ case EltwiseMode::ADD:+ case EltwiseMode::SUB:+ case EltwiseMode::MUL:+ case EltwiseMode::DIV:+ case EltwiseMode::MIN:+ case EltwiseMode::MAX:+ case EltwiseMode::POW:+ case EltwiseMode::MODULU:+ case EltwiseMode::EQ:+ case EltwiseMode::NE:+ case EltwiseMode::LT:+ case EltwiseMode::LE:+ case EltwiseMode::GT:+ case EltwiseMode::GE:+ case EltwiseMode::LOGIC_AND:+ case EltwiseMode::LOGIC_OR:+ case EltwiseMode::LOGIC_XOR:+ case EltwiseMode::SQUARED_DIFF:+ case EltwiseMode::FLOOR_MOD:+ case EltwiseMode::RIGHT_SHIFT:+ case EltwiseMode::LEFT_SHIFT:+ case EltwiseMode::BITWISE_AND:+ case EltwiseMode::BITWISE_OR:+ case EltwiseMode::BITWISE_XOR:+ case EltwiseMode::ATAN2:+ return 2;+ case EltwiseMode::SQRT:+ case EltwiseMode::RSQRT:+ case EltwiseMode::ASSIGN:+ case EltwiseMode::IS_FINITE:+ case EltwiseMode::IS_INF:+ case EltwiseMode::IS_NAN:+ return 1;+ default:+ return 0;}}@@ -117,11 +121,11 @@ ParamsKey eltwise_params::GetParamsKey() const {}static bool IsBitwiseMode(EltwiseMode mode) {- return mode == EltwiseMode::BITWISE_AND || mode == EltwiseMode::LEFT_SHIFT || mode == EltwiseMode::RIGHT_SHIFT ||- mode == EltwiseMode::BITWISE_OR || mode == EltwiseMode::BITWISE_XOR;+ return mode == EltwiseMode::BITWISE_AND || mode == EltwiseMode::LEFT_SHIFT || mode == EltwiseMode::RIGHT_SHIFT || mode == EltwiseMode::BITWISE_OR ||+ mode == EltwiseMode::BITWISE_XOR;}-Datatype EltwiseKernelBase::GetAccumulatorType(const eltwise_params ¶ms) const {+Datatype EltwiseKernelBase::GetAccumulatorType(const eltwise_params& params) const {// NOTE: Workaround for not promoting shift operations. Not sure what should happen// if shift op is just one operation of other elementwise operations. My guess is that is should be promoted as// well, but in reality more robust solution will be needed or (better) - assumption that types are not promoted. So@@ -130,15 +134,19 @@ Datatype EltwiseKernelBase::GetAccumulatorType(const eltwise_params ¶ms) conreturn params.inputs[0].GetDType();}- if (params.int8_quantization)+ if (params.int8_quantization) {return Datatype::INT32;+ }- Datatype types[] = { Datatype::F32, Datatype::BF16, Datatype::F16, Datatype::INT64, Datatype::INT32, Datatype::UINT32};+ Datatype types[] = {Datatype::F32, Datatype::BF16, Datatype::F16, Datatype::INT64, Datatype::INT32, Datatype::UINT32};- for (Datatype type : types)- for (const auto& in : params.inputs)- if (in.GetDType() == type)+ for (Datatype type : types) {+ for (const auto& in : params.inputs) {+ if (in.GetDType() == type) {return GetComputeDatatype(type);+ }+ }+ }return Datatype::F32;}@@ -177,8 +185,9 @@ bool EltwiseKernelBase::Validate(const Params& p) const {const eltwise_params& orgParams = static_cast<const eltwise_params&>(p);for (const auto& fused_op : orgParams.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}return true;@@ -206,10 +215,11 @@ bool EltwiseKernelBase::IsUnsupportedModeForVecCode(const eltwise_params& paramsEltwiseMode::IS_NAN,};- for (size_t op_num = 0; op_num < params.operations.size(); op_num++) {- const auto& ew = params.operations[op_num];- if (std::find(unsupported_modes.begin(), unsupported_modes.end(), ew.mode) != unsupported_modes.end())+ for (size_t op_num = 0; op_num < params.operations.size(); op_num++) {+ const auto& ew = params.operations[op_num];+ if (std::find(unsupported_modes.begin(), unsupported_modes.end(), ew.mode) != unsupported_modes.end()) {return true;+ }}return false;@@ -246,8 +256,9 @@ JitConstants EltwiseKernelBase::GetOperationsJitConstants(const eltwise_params&const auto& input = ew.inputs[input_idx];if (input.mode == EltwiseInputMode::INPUT_BUFFER && input.index < coefficients.size()) {const float c = coefficients[input.index];- if (c != 1.0f)+ if (c != 1.0f) {coeff_strings[input_idx] = cast_type + "(" + toCodeString(c) + ")*";+ }}}@@ -256,142 +267,142 @@ JitConstants EltwiseKernelBase::GetOperationsJitConstants(const eltwise_params&}switch (ew.mode) {- case EltwiseMode::ADD:- op += input0_str + " + " + input1_str;- break;- case EltwiseMode::SUB:- op += input0_str + " - " + input1_str;- break;- case EltwiseMode::MUL:- op += input0_str + " * " + input1_str;- break;- case EltwiseMode::DIV:- op += input0_str + " / " + input1_str;- break;- case EltwiseMode::MODULU:- case EltwiseMode::MIN:- case EltwiseMode::MAX: {- const auto* mode = (ew.mode == EltwiseMode::MODULU ? "mod" : (ew.mode == EltwiseMode::MIN ? "min" : "max"));- auto input_0_type = params.inputs[0].GetDType();- auto input_1_type = params.inputs[1].GetDType();-- auto is_integer_type = [](kernel_selector::Datatype type) {- return type == kernel_selector::Datatype::INT8 || type == kernel_selector::Datatype::UINT8 ||- type == kernel_selector::Datatype::INT16 || type == kernel_selector::Datatype::UINT16 ||- type == kernel_selector::Datatype::INT32 || type == kernel_selector::Datatype::UINT32 ||- type == kernel_selector::Datatype::INT64;- };-- // input_0 == int- if (is_integer_type(input_0_type)) {- // input_0 == int && input_1 == int- if (is_integer_type(input_1_type)) {- if (ew.mode == EltwiseMode::MODULU)- op += input0_str + " % " + input1_str;- else- op += cast_type + mode + "(" + input0_str + ", " + input1_str + ")";+ case EltwiseMode::ADD:+ op += input0_str + " + " + input1_str;+ break;+ case EltwiseMode::SUB:+ op += input0_str + " - " + input1_str;+ break;+ case EltwiseMode::MUL:+ op += input0_str + " * " + input1_str;+ break;+ case EltwiseMode::DIV:+ op += input0_str + " / " + input1_str;+ break;+ case EltwiseMode::MODULU:+ case EltwiseMode::MIN:+ case EltwiseMode::MAX: {+ const auto* mode = (ew.mode == EltwiseMode::MODULU ? "mod" : (ew.mode == EltwiseMode::MIN ? "min" : "max"));+ auto input_0_type = params.inputs[0].GetDType();+ auto input_1_type = params.inputs[1].GetDType();++ auto is_integer_type = [](kernel_selector::Datatype type) {+ return type == kernel_selector::Datatype::INT8 || type == kernel_selector::Datatype::UINT8 || type == kernel_selector::Datatype::INT16 ||+ type == kernel_selector::Datatype::UINT16 || type == kernel_selector::Datatype::INT32 || type == kernel_selector::Datatype::UINT32 ||+ type == kernel_selector::Datatype::INT64;+ };++ // input_0 == int+ if (is_integer_type(input_0_type)) {+ // input_0 == int && input_1 == int+ if (is_integer_type(input_1_type)) {+ if (ew.mode == EltwiseMode::MODULU) {+ op += input0_str + " % " + input1_str;} else {- // input_0 == int && input_1 != int- op += cast_type + "f" + mode + "(convert_float(" + input0_str + "), " + input1_str + ")";+ op += cast_type + mode + "(" + input0_str + ", " + input1_str + ")";}- } else if (is_integer_type(input_1_type)) {- // input_0 != int && input_1 == int- op += cast_type + "f" + mode + "(" + input0_str + ", convert_float(" + input1_str + "))";} else {- // input_0 != int && input_1 != int- op += cast_type + "f" + mode + "(" + input0_str + ", " + input1_str + ")";+ // input_0 == int && input_1 != int+ op += cast_type + "f" + mode + "(convert_float(" + input0_str + "), " + input1_str + ")";}- } break;- case EltwiseMode::POW:- op += cast_type + "pow(" + input0_str + ", " + input1_str + ")";- break;- case EltwiseMode::ATAN2:- // input0 = y (lhs of atan2), input1 = x (rhs).- op += cast_type + "atan2(" + input0_str + ", " + input1_str + ")";- break;- case EltwiseMode::SQRT:- op += cast_type + "sqrt(" + input0_str + ")";- break;- case EltwiseMode::RSQRT:- op += cast_type + "1/sqrt(" + input0_str + ")";- break;- case EltwiseMode::SQUARED_DIFF:- op += cast_type + "((" + input0_str + " - " + input1_str +- ")"- " * (" +- input0_str + " - " + input1_str + "))";- break;- case EltwiseMode::EQ:- op += "(" + input0_str + " == " + input1_str + ")";- break;- case EltwiseMode::NE:- op += "(" + input0_str + " != " + input1_str + ")";- break;- case EltwiseMode::LT:- op += "(" + input0_str + " < " + input1_str + ")";- break;- case EltwiseMode::LE:- op += "(" + input0_str + " <= " + input1_str + ")";- break;- case EltwiseMode::GT:- op += "(" + input0_str + " > " + input1_str + ")";- break;- case EltwiseMode::GE:- op += "(" + input0_str + " >= " + input1_str + ")";- break;- case EltwiseMode::LOGIC_AND:- op += "(" + input0_str + " && " + input1_str + ")";- break;- case EltwiseMode::LOGIC_OR:- op += "(" + input0_str + " || " + input1_str + ")";- break;- case EltwiseMode::LOGIC_XOR:- op += "(!" + input0_str + " != !" + input1_str + ")";- break;- case EltwiseMode::FLOOR_MOD: {- auto input_0_type = params.inputs[0].GetDType();- auto input_1_type = params.inputs[1].GetDType();- if (input_0_type == input_1_type && (input_0_type == kernel_selector::Datatype::F16 || input_0_type == kernel_selector::Datatype::BF16 ||- input_0_type == kernel_selector::Datatype::F32)) {- op += "fmod(" + input0_str + ", " + input1_str + ")";- } else if (input_1_type == kernel_selector::Datatype::F16 || input_1_type == kernel_selector::Datatype::BF16 ||- input_1_type == kernel_selector::Datatype::F32) {- op += "(" + input0_str + " - trunc(" + input0_str + " / " + input1_str + ") * " + input1_str + ")";- } else {- op += "(" + input0_str + " - trunc(" + input0_str + " / convert_float(" + input1_str + ")) * " + input1_str + ")";- }- break;+ } else if (is_integer_type(input_1_type)) {+ // input_0 != int && input_1 == int+ op += cast_type + "f" + mode + "(" + input0_str + ", convert_float(" + input1_str + "))";+ } else {+ // input_0 != int && input_1 != int+ op += cast_type + "f" + mode + "(" + input0_str + ", " + input1_str + ")";}- case EltwiseMode::ASSIGN:- op += input0_str;- break;- case EltwiseMode::IS_FINITE:- op += "(isfinite(" + input0_str + "))";- break;- case EltwiseMode::IS_INF:- op += "(isinf(" + input0_str + ") && (" + toCodeString(coefficients.at(0)) + " && signbit(" +- input0_str + ") || " + toCodeString(coefficients.at(1)) + " && !signbit(" + input0_str + ")))";- break;- case EltwiseMode::IS_NAN:- op += "(isnan(" + input0_str + "))";- break;- case EltwiseMode::RIGHT_SHIFT:- op += "(" + input0_str + " >> " + input1_str + ")";- break;- case EltwiseMode::LEFT_SHIFT:- op += "(" + input0_str + " << " + input1_str + ")";- break;- case EltwiseMode::BITWISE_AND:- op += "(" + input0_str + " & " + input1_str + ")";- break;- case EltwiseMode::BITWISE_OR:- op += "(" + input0_str + " | " + input1_str + ")";- break;- case EltwiseMode::BITWISE_XOR:- op += "(" + input0_str + " ^ " + input1_str + ")";- break;- default:- break;+ } break;+ case EltwiseMode::POW:+ op += cast_type + "pow(" + input0_str + ", " + input1_str + ")";+ break;+ case EltwiseMode::ATAN2:+ // input0 = y (lhs of atan2), input1 = x (rhs).+ op += cast_type + "atan2(" + input0_str + ", " + input1_str + ")";+ break;+ case EltwiseMode::SQRT:+ op += cast_type + "sqrt(" + input0_str + ")";+ break;+ case EltwiseMode::RSQRT:+ op += cast_type + "1/sqrt(" + input0_str + ")";+ break;+ case EltwiseMode::SQUARED_DIFF:+ op += cast_type + "((" + input0_str + " - " + input1_str ++ ")"+ " * (" ++ input0_str + " - " + input1_str + "))";+ break;+ case EltwiseMode::EQ:+ op += "(" + input0_str + " == " + input1_str + ")";+ break;+ case EltwiseMode::NE:+ op += "(" + input0_str + " != " + input1_str + ")";+ break;+ case EltwiseMode::LT:+ op += "(" + input0_str + " < " + input1_str + ")";+ break;+ case EltwiseMode::LE:+ op += "(" + input0_str + " <= " + input1_str + ")";+ break;+ case EltwiseMode::GT:+ op += "(" + input0_str + " > " + input1_str + ")";+ break;+ case EltwiseMode::GE:+ op += "(" + input0_str + " >= " + input1_str + ")";+ break;+ case EltwiseMode::LOGIC_AND:+ op += "(" + input0_str + " && " + input1_str + ")";+ break;+ case EltwiseMode::LOGIC_OR:+ op += "(" + input0_str + " || " + input1_str + ")";+ break;+ case EltwiseMode::LOGIC_XOR:+ op += "(!" + input0_str + " != !" + input1_str + ")";+ break;+ case EltwiseMode::FLOOR_MOD: {+ auto input_0_type = params.inputs[0].GetDType();+ auto input_1_type = params.inputs[1].GetDType();+ if (input_0_type == input_1_type && (input_0_type == kernel_selector::Datatype::F16 || input_0_type == kernel_selector::Datatype::BF16 ||+ input_0_type == kernel_selector::Datatype::F32)) {+ op += "fmod(" + input0_str + ", " + input1_str + ")";+ } else if (input_1_type == kernel_selector::Datatype::F16 || input_1_type == kernel_selector::Datatype::BF16 ||+ input_1_type == kernel_selector::Datatype::F32) {+ op += "(" + input0_str + " - trunc(" + input0_str + " / " + input1_str + ") * " + input1_str + ")";+ } else {+ op += "(" + input0_str + " - trunc(" + input0_str + " / convert_float(" + input1_str + ")) * " + input1_str + ")";+ }+ break;+ }+ case EltwiseMode::ASSIGN:+ op += input0_str;+ break;+ case EltwiseMode::IS_FINITE:+ op += "(isfinite(" + input0_str + "))";+ break;+ case EltwiseMode::IS_INF:+ op += "(isinf(" + input0_str + ") && (" + toCodeString(coefficients.at(0)) + " && signbit(" + input0_str + ") || " ++ toCodeString(coefficients.at(1)) + " && !signbit(" + input0_str + ")))";+ break;+ case EltwiseMode::IS_NAN:+ op += "(isnan(" + input0_str + "))";+ break;+ case EltwiseMode::RIGHT_SHIFT:+ op += "(" + input0_str + " >> " + input1_str + ")";+ break;+ case EltwiseMode::LEFT_SHIFT:+ op += "(" + input0_str + " << " + input1_str + ")";+ break;+ case EltwiseMode::BITWISE_AND:+ op += "(" + input0_str + " & " + input1_str + ")";+ break;+ case EltwiseMode::BITWISE_OR:+ op += "(" + input0_str + " | " + input1_str + ")";+ break;+ case EltwiseMode::BITWISE_XOR:+ op += "(" + input0_str + " ^ " + input1_str + ")";+ break;+ default:+ break;}jit.AddConstant(MakeJitConstant("OPERATION" + op_num_str, op));@@ -400,48 +411,49 @@ JitConstants EltwiseKernelBase::GetOperationsJitConstants(const eltwise_params&return jit;}-JitConstants EltwiseKernelBase::MakeLoadJitConstants(const eltwise_params& params,- bool useVload8) const {+JitConstants EltwiseKernelBase::MakeLoadJitConstants(const eltwise_params& params, bool useVload8) const {JitConstants jit = {};std::string vload_decls;for (size_t op_num = 0; op_num < params.operations.size(); op_num++) {const std::string op_num_str = toCodeString(op_num);- const auto &ew = params.operations[op_num];+ const auto& ew = params.operations[op_num];bool is_dynamic_crop_kernel = params.is_shape_agnostic && params.operations[op_num].mode == EltwiseMode::ASSIGN;- if (is_dynamic_crop_kernel)+ if (is_dynamic_crop_kernel) {jit.AddConstant(MakeJitConstant("IS_DYNAMIC_CROP", 1));+ }for (size_t input_idx = 0; input_idx < ew.inputs.size(); input_idx++) {- const auto &input = ew.inputs[input_idx];+ const auto& input = ew.inputs[input_idx];const std::string name = "INPUT_" + op_num_str + "_" + toCodeString(input_idx);std::string idx_order = "INPUT" + toCodeString(input.index) + "_IDX_ORDER";switch (input.mode) {- case EltwiseInputMode::SCALAR:- jit.AddConstant(MakeJitConstant(name, input.scalar));- break;- case EltwiseInputMode::INPUT_BUFFER:- if (useVload8)- jit.AddConstant(MakeJitConstant(name,- "DECODE_INPUT" + toCodeString(input.index) + "_COMPUTE_VECTOR_TYPE(in" + toCodeString(input.index) + ", 8)"));- else- jit.AddConstant(MakeJitConstant(name,- "DECODE_INPUT" + toCodeString(input.index) + "_COMPUTE_TYPE(input" + toCodeString(input.index) +- "[GET_INDEX(INPUT, " + toCodeString(input.index) + "," + idx_order + ") " +- (is_dynamic_crop_kernel ? "+ runtime_offset]" : "]") + ")"));- break;- case EltwiseInputMode::OUTPUT_BUFFER:- jit.AddConstant(MakeJitConstant(name, "DECODE_OUTPUT_COMPUTE_TYPE(output[GET_INDEX(OUTPUT,,OUTPUT_IDX_ORDER)])"));- break;- case EltwiseInputMode::UNORDERED_ACCESS_INPUT_BUFFER:+ case EltwiseInputMode::SCALAR:+ jit.AddConstant(MakeJitConstant(name, input.scalar));+ break;+ case EltwiseInputMode::INPUT_BUFFER:+ if (useVload8) {+ jit.AddConstant(+ MakeJitConstant(name, "DECODE_INPUT" + toCodeString(input.index) + "_COMPUTE_VECTOR_TYPE(in" + toCodeString(input.index) + ", 8)"));+ } else {jit.AddConstant(MakeJitConstant(name,- "DECODE_INPUT" + toCodeString(input.index) + "_COMPUTE_TYPE(input" + toCodeString(input.index) +- "[(size_t)tmp" + toCodeString(input.tmpIndex) + "])"));- break;- case EltwiseInputMode::INTERMEDIATE_RESULTS_INDEX:- jit.AddConstant(MakeJitConstant(name, "tmp" + toCodeString(input.tmpIndex)));- break;- default:- break;+ "DECODE_INPUT" + toCodeString(input.index) + "_COMPUTE_TYPE(input" + toCodeString(input.index) ++ "[GET_INDEX(INPUT, " + toCodeString(input.index) + "," + idx_order + ") " ++ (is_dynamic_crop_kernel ? "+ runtime_offset]" : "]") + ")"));+ }+ break;+ case EltwiseInputMode::OUTPUT_BUFFER:+ jit.AddConstant(MakeJitConstant(name, "DECODE_OUTPUT_COMPUTE_TYPE(output[GET_INDEX(OUTPUT,,OUTPUT_IDX_ORDER)])"));+ break;+ case EltwiseInputMode::UNORDERED_ACCESS_INPUT_BUFFER:+ jit.AddConstant(MakeJitConstant(name,+ "DECODE_INPUT" + toCodeString(input.index) + "_COMPUTE_TYPE(input" + toCodeString(input.index) ++ "[(size_t)tmp" + toCodeString(input.tmpIndex) + "])"));+ break;+ case EltwiseInputMode::INTERMEDIATE_RESULTS_INDEX:+ jit.AddConstant(MakeJitConstant(name, "tmp" + toCodeString(input.tmpIndex)));+ break;+ default:+ break;}}}@@ -449,10 +461,11 @@ JitConstants EltwiseKernelBase::MakeLoadJitConstants(const eltwise_params& paramif (useVload8) {for (size_t i = 0; i < params.inputs.size(); i++) {vload_decls += "\\\n\tconst " + toCLType(params.inputs[i].GetDType()) + "8 in" + toCodeString(i);- if (params.inputs[i].PhysicalSize() == 1) // Scalar case+ if (params.inputs[i].PhysicalSize() == 1) { // Scalar casevload_decls += " = (" + toCLType(params.inputs[i].GetDType()) + "8)(input" + toCodeString(i) + "[0]";- else // Buffer case+ } else { // Buffer casevload_decls += " = vload8(global_id, input" + toCodeString(i);+ }vload_decls += ");";}jit.AddConstant(MakeJitConstant("VLOAD_DECLS", vload_decls));@@ -460,8 +473,7 @@ JitConstants EltwiseKernelBase::MakeLoadJitConstants(const eltwise_params& paramreturn jit;}-JitConstants EltwiseKernelBase::MakeInputDeclsJitConstants(const eltwise_params& params,- bool /*useVload8*/) const {+JitConstants EltwiseKernelBase::MakeInputDeclsJitConstants(const eltwise_params& params, bool /*useVload8*/) const {JitConstants jit = {};std::string inputs_decls;const auto& updateInputs = params.updateInputIds;@@ -510,7 +522,7 @@ size_t EltwiseKernelBase::GetFeaturePadResetSize(const eltwise_params& params) c}JitConstants EltwiseKernelBase::MakeIndexJitConstants(const eltwise_params& params,- bool useVload8) const {+ bool useVload8) const {JitConstants jit = {};const auto& updateInputs = params.updateInputIds;@@ -518,18 +530,18 @@ JitConstants EltwiseKernelBase::MakeIndexJitConstants(const eltwise_params& para// TODO: Generalize this methodstd::vector<std::string> bfyx_idx_order = {};if (layoutBased) {- bfyx_idx_order = { "d4", "d3", "d2", "d1" };+ bfyx_idx_order = {"d4", "d3", "d2", "d1"};} else {if (l == DataLayout::yxfb) {- bfyx_idx_order = { "d1", "d2", "d4", "d3" };+ bfyx_idx_order = {"d1", "d2", "d4", "d3"};} else if (l == DataLayout::fyxb) {- bfyx_idx_order = { "d1", "d4", "d3", "d2" };+ bfyx_idx_order = {"d1", "d4", "d3", "d2"};} else if (l == DataLayout::byxf) {- bfyx_idx_order = { "d4", "d1", "d3", "d2" };+ bfyx_idx_order = {"d4", "d1", "d3", "d2"};} else if (l == DataLayout::fs_b_yx_fsv32) {- bfyx_idx_order = { "d3", "d4", "d2", "d1" };+ bfyx_idx_order = {"d3", "d4", "d2", "d1"};} else {- bfyx_idx_order = { "d4", "d3", "d2", "d1" };+ bfyx_idx_order = {"d4", "d3", "d2", "d1"};}}@@ -544,25 +556,20 @@ JitConstants EltwiseKernelBase::MakeIndexJitConstants(const eltwise_params& paraauto GetIdxOrderStringForLayout = [&](DataLayout l, bool layoutBased, uSize stride) -> std::string {std::vector<std::string> bfyx_idx_order = GetIdxOrderVecForLayout(l, layoutBased, stride);- return bfyx_idx_order[0] + "," +- bfyx_idx_order[1] + "," +- bfyx_idx_order[2] + "," +- bfyx_idx_order[3];+ return bfyx_idx_order[0] + "," + bfyx_idx_order[1] + "," + bfyx_idx_order[2] + "," + bfyx_idx_order[3];};std::string out_idx_order = "OUTPUT_IDX_ORDER";if (useVload8) {jit.AddConstant(MakeJitConstant(out_idx_order, "d1"));} else {- if (CheckInputsOutputNoPitchSameDims(params) &&- !params.layoutBased && !params.int8_quantization && !params.broadcast) {+ if (CheckInputsOutputNoPitchSameDims(params) && !params.layoutBased && !params.int8_quantization && !params.broadcast) {jit.AddConstant(MakeJitConstant(out_idx_order, "d1"));} else {size_t out_c = DataTensor::ChannelsCount(params.outputs[0].GetLayout());if (out_c <= 4) {- jit.AddConstant(MakeJitConstant(out_idx_order, GetIdxOrderStringForLayout(params.outputs[0].GetLayout(),- params.layoutBased || params.broadcast,- {1, 1, 1})));+ jit.AddConstant(MakeJitConstant(out_idx_order,+ GetIdxOrderStringForLayout(params.outputs[0].GetLayout(), params.layoutBased || params.broadcast, {1, 1, 1})));} else {std::string idx_order;for (size_t i = 0; i < out_c; i++) {@@ -615,17 +622,16 @@ JitConstants EltwiseKernelBase::MakeIndexJitConstants(const eltwise_params& paraif (useVload8) {jit.AddConstant(MakeJitConstant(idx_order, "d1"));} else {- if (CheckInputsOutputNoPitchSameDims(params) &&- !params.layoutBased && !params.int8_quantization && !params.broadcast) {+ if (CheckInputsOutputNoPitchSameDims(params) && !params.layoutBased && !params.int8_quantization && !params.broadcast) {jit.AddConstant(MakeJitConstant(idx_order, "d1"));} else {size_t in_c = DataTensor::ChannelsCount(params.inputs[i].GetLayout());size_t out_c = DataTensor::ChannelsCount(params.outputs[0].GetLayout());auto in_stride = params.stride.empty() ? uSize{1, 1, 1} : params.stride[i];if (out_c <= 4 && in_c <= 4) {- jit.AddConstant(MakeJitConstant(idx_order, GetIdxOrderStringForLayout(params.inputs[i].GetLayout(),- params.layoutBased || params.broadcast,- in_stride)));+ jit.AddConstant(+ MakeJitConstant(idx_order,+ GetIdxOrderStringForLayout(params.inputs[i].GetLayout(), params.layoutBased || params.broadcast, in_stride)));} else if (out_c == 5) {if (in_c < 5) {// Skip Z coord for 4d tensors@@ -706,11 +712,12 @@ JitConstants EltwiseKernelBase::GetJitConstantsCommon(const eltwise_params& para}const auto& updateInputs = params.updateInputIds;- for (size_t update_input_idx = 0; update_input_idx < updateInputs.size(); update_input_idx++)+ for (size_t update_input_idx = 0; update_input_idx < updateInputs.size(); update_input_idx++) {do_eltwise += "\\\n\tinput" + toCodeString(updateInputs[update_input_idx].inputId) + "[GET_INDEX(INPUT, " +toCodeString(updateInputs[update_input_idx].inputId) + ", " + "INPUT" + toCodeString(updateInputs[update_input_idx].inputId) +"_IDX_ORDER)] = TO_INPUT" + toCodeString(updateInputs[update_input_idx].inputId) + "_TYPE(tmp" +toCodeString(updateInputs[update_input_idx].tmpId) + ");";+ }do_eltwise += "\\\n\tres = tmp" + toCodeString(operations.size() - 1) + ";";@@ -789,20 +796,14 @@ EltwiseKernelBase::DispatchData EltwiseKernelBase::SetDefault(const eltwise_paraauto local = GetOptimalLocalWorkGroupSizes({dispatchData.gws[0], dispatchData.gws[1], dispatchData.gws[2]}, params.engineInfo);// TODO: can be potentially improved for GPUs with support of LWS > 256- const size_t optimal_lws_values[] = { 256, 224, 192, 160, 128, 96, 64, 32, 16 };-- if (dispatchData.gws[2] % 16 == 0 &&- params.outputs[0].Batch().v % 16 == 0 &&- params.outputs[0].Feature().v % 16 == 0 &&- dispatchData.gws[1] % 16 == 0 &&- (params.outputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv32_fsv16 ||- params.outputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv16_fsv16 ||- params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv32_fsv16 ||- params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv16_fsv16 ||- params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv16_fsv32 ||- params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv32_fsv32)) {+ const size_t optimal_lws_values[] = {256, 224, 192, 160, 128, 96, 64, 32, 16};++ if (dispatchData.gws[2] % 16 == 0 && params.outputs[0].Batch().v % 16 == 0 && params.outputs[0].Feature().v % 16 == 0 && dispatchData.gws[1] % 16 == 0 &&+ (params.outputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv32_fsv16 || params.outputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv16_fsv16 ||+ params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv32_fsv16 || params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv16_fsv16 ||+ params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv16_fsv32 || params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv32_fsv32)) {dispatchData.lws[0] = 1;- //dispatchData.gws[1] = ???; calc it below+ // dispatchData.gws[1] = ???; calc it belowdispatchData.lws[2] = 16;for (auto lws : optimal_lws_values) {if (dispatchData.gws[1] % lws == 0 && lws * dispatchData.lws[2] <= params.engineInfo.maxWorkGroupSize) {@@ -810,13 +811,10 @@ EltwiseKernelBase::DispatchData EltwiseKernelBase::SetDefault(const eltwise_parabreak;}}- } else if ((params.outputs[0].GetLayout() == DataLayout::b_fs_yx_fsv16 ||- params.outputs[0].GetLayout() == DataLayout::b_fs_zyx_fsv16 ||- params.outputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv32_fsv16 ||- params.outputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv16_fsv16 ||- params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv32_fsv16 ||- params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv16_fsv16) &&- params.outputs[0].Feature().v % 16 == 0 && dispatchData.gws[1] % 16 == 0) {+ } else if ((params.outputs[0].GetLayout() == DataLayout::b_fs_yx_fsv16 || params.outputs[0].GetLayout() == DataLayout::b_fs_zyx_fsv16 ||+ params.outputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv32_fsv16 || params.outputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv16_fsv16 ||+ params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv32_fsv16 || params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv16_fsv16) &&+ params.outputs[0].Feature().v % 16 == 0 && dispatchData.gws[1] % 16 == 0) {dispatchData.lws[0] = 1;for (auto lws : optimal_lws_values) {if (dispatchData.gws[1] % lws == 0) {@@ -830,15 +828,12 @@ EltwiseKernelBase::DispatchData EltwiseKernelBase::SetDefault(const eltwise_paradispatchData.lws[0] = 1;dispatchData.lws[1] = 1;dispatchData.lws[2] = 32;- } else if ((params.outputs[0].GetLayout() == DataLayout::b_fs_yx_fsv32 ||- params.outputs[0].GetLayout() == DataLayout::b_fs_zyx_fsv32 ||- params.outputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv16_fsv32 ||- params.outputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv32_fsv32 ||- params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv16_fsv32 ||- params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv32_fsv32)) {+ } else if ((params.outputs[0].GetLayout() == DataLayout::b_fs_yx_fsv32 || params.outputs[0].GetLayout() == DataLayout::b_fs_zyx_fsv32 ||+ params.outputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv16_fsv32 || params.outputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv32_fsv32 ||+ params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv16_fsv32 || params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv32_fsv32)) {if (params.layoutBased || params.int8_quantization || params.broadcast) {- auto bs_fsv32_local = GetLimitedOptimalLocalWorkGroupSizes({dispatchData.gws[1], dispatchData.gws[2], dispatchData.gws[0]},- params.engineInfo, {32, 32, 1024});+ auto bs_fsv32_local =+ GetLimitedOptimalLocalWorkGroupSizes({dispatchData.gws[1], dispatchData.gws[2], dispatchData.gws[0]}, params.engineInfo, {32, 32, 1024});dispatchData.lws[0] = bs_fsv32_local[2];dispatchData.lws[1] = bs_fsv32_local[0];dispatchData.lws[2] = bs_fsv32_local[1];@@ -850,16 +845,14 @@ EltwiseKernelBase::DispatchData EltwiseKernelBase::SetDefault(const eltwise_paradispatchData.lws[1] = bs_fsv32_local[2];dispatchData.lws[2] = bs_fsv32_local[0];}- } else if ((params.outputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv32_fsv16 ||- params.outputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv16_fsv16 ||- params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv16_fsv16 ||- params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv32_fsv16) &&- (params.outputs[0].Feature().v % 16 != 0 || dispatchData.gws[1] % 16 != 0)) {- auto bs_fsv16_local = GetLimitedOptimalLocalWorkGroupSizes({dispatchData.gws[2], dispatchData.gws[0], dispatchData.gws[1]},- params.engineInfo, {32 * 16, 1024, 1024});- dispatchData.lws[0] = bs_fsv16_local[1];- dispatchData.lws[1] = bs_fsv16_local[2];- dispatchData.lws[2] = bs_fsv16_local[0];+ } else if ((params.outputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv32_fsv16 || params.outputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv16_fsv16 ||+ params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv16_fsv16 || params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv32_fsv16) &&+ (params.outputs[0].Feature().v % 16 != 0 || dispatchData.gws[1] % 16 != 0)) {+ auto bs_fsv16_local =+ GetLimitedOptimalLocalWorkGroupSizes({dispatchData.gws[2], dispatchData.gws[0], dispatchData.gws[1]}, params.engineInfo, {32 * 16, 1024, 1024});+ dispatchData.lws[0] = bs_fsv16_local[1];+ dispatchData.lws[1] = bs_fsv16_local[2];+ dispatchData.lws[2] = bs_fsv16_local[0];} else {dispatchData.lws[0] = local[0];dispatchData.lws[1] = local[1];@@ -903,12 +896,7 @@ KernelsData EltwiseKernelBase::GetCommonKernelsData(const Params& params) constkernel.params.workGroups.global = dispatchData.gws;kernel.params.workGroups.local = dispatchData.lws;bool is_dynamic = newParams.is_shape_agnostic;- kernel.params.arguments = GetArgsDesc((uint32_t)newParams.inputs.size(),- false,- false,- GetFusedPrimitiveInputsCount(params),- 1,- is_dynamic);+ kernel.params.arguments = GetArgsDesc((uint32_t)newParams.inputs.size(), false, false, GetFusedPrimitiveInputsCount(params), 1, is_dynamic);if (params.is_shape_agnostic && newParams.operations[0].mode == EltwiseMode::ASSIGN) {kernel.params.arguments.push_back({ArgumentDescriptor::Types::SCALAR, 0});kernel_selector::ScalarDescriptor s;diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_blocked_opt.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_blocked_opt.cppindex c1d4e31d170..1abaf97e964 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_blocked_opt.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_blocked_opt.cpp@@ -103,8 +103,9 @@ bool EltwiseKernel_blocked_opt::Validate(const Params& params) const {}const auto& ewParams = static_cast<const eltwise_params&>(params);- if (IsUnsupportedModeForVecCode(ewParams))+ if (IsUnsupportedModeForVecCode(ewParams)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }for (size_t i = 0; i < ewParams.inputs.size(); i++) {if ((SelectVecSizeFromFormat(ewParams.inputs[i]) == 1) &&@@ -117,8 +118,9 @@ bool EltwiseKernel_blocked_opt::Validate(const Params& params) const {const auto& input0 = ewParams.inputs[0];const auto& output = ewParams.outputs[0];// Check that padding before features doesn't mis-align the blocks- if (input0.Feature().pad.before % vec_size != 0 || output.Feature().pad.before % vec_size != 0)+ if (input0.Feature().pad.before % vec_size != 0 || output.Feature().pad.before % vec_size != 0) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }auto compareTensors = [](const DataTensor& input0, const DataTensor& input1) -> bool {// Check all parameters except DataType@@ -140,8 +142,9 @@ bool EltwiseKernel_blocked_opt::Validate(const Params& params) const {for (size_t i = 1; i < ewParams.inputs.size(); i++) {const auto& input = ewParams.inputs[i];- if (input.LogicalSize() == input0.LogicalSize() && !(compareTensors(input, input0)))+ if (input.LogicalSize() == input0.LogicalSize() && !(compareTensors(input, input0))) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }if (input.Feature().pad.before % vec_size != 0) {DO_NOT_USE_THIS_KERNEL(params.layerID);}@@ -197,12 +200,13 @@ JitConstants EltwiseKernel_blocked_opt::MakeLoadJitConstants(const eltwise_param// Based on dimension, get a string of indexing for formmatted GET_INDEXstd::string default_indexing_str;- if (DataTensor::ChannelsCount(params.inputs[input_idx].GetLayout()) == 4)+ if (DataTensor::ChannelsCount(params.inputs[input_idx].GetLayout()) == 4) {default_indexing_str = "b, (f_block * " + toCodeString(vec_size) +"), y, x";- else if (DataTensor::ChannelsCount(params.inputs[input_idx].GetLayout()) == 5)+ } else if (DataTensor::ChannelsCount(params.inputs[input_idx].GetLayout()) == 5) {default_indexing_str = "b, (f_block * " + toCodeString(vec_size) +"), z, y, x";- else+ } else {OPENVINO_THROW("MakeLoadJit : Unexpected dimension for eltwise optimized kernel.");+ }// Generate Jitswitch (input.mode) {@@ -321,8 +325,9 @@ JitConstants EltwiseKernel_blocked_opt::GetJitConstants(const eltwise_params& paconst auto &ew = operations[op_num];for (size_t input_idx = 0; input_idx < ew.inputs.size(); input_idx++) {const auto &input = ew.inputs[input_idx];- if (input.mode != EltwiseInputMode::INPUT_BUFFER && input.mode != EltwiseInputMode::SCALAR)+ if (input.mode != EltwiseInputMode::INPUT_BUFFER && input.mode != EltwiseInputMode::SCALAR) {continue;+ }if (InputHasFeatureBroadcast(params, op_num, input_idx)) {do_eltwise += "\\\n\tDO_FEATURE_BROADCAST" + toCodeString(op_num) + "_" + toCodeString(input_idx) + ";";@@ -347,8 +352,9 @@ JitConstants EltwiseKernel_blocked_opt::GetJitConstants(const eltwise_params& pajit.Merge(MakeActivationJitConstants(params.activations, GetComputeDatatype(params.outputs[0].GetDType()), "_TYPED"));- if (params.outputs[0].Feature().v % vec_size != 0)+ if (params.outputs[0].Feature().v % vec_size != 0) {jit.AddConstant(MakeJitConstant("LEFTOVERS", params.outputs[0].Feature().v % vec_size));+ }// Fused post_opsif (!params.fused_ops.empty()) {@@ -379,8 +385,9 @@ JitConstants EltwiseKernel_blocked_opt::GetJitConstants(const eltwise_params& pa}}- if (need_idx_safe)+ if (need_idx_safe) {jit.AddConstant(MakeJitConstant("ELTWISE_BROADCAST", params.broadcast));+ }}return jit;@@ -404,10 +411,11 @@ static inline size_t CalculateTotalWorkItemCount(const eltwise_params& params) {auto feature = Align(params.outputs[0].Feature().v, GetInnerFeatureBlockSize(params.outputs[0]));auto batch = Align(params.outputs[0].Batch().v, GetInnerBatchBlockSize(params.outputs[0]));size_t spatial = 0;- if (DataTensor::ChannelsCount(params.outputs[0].GetLayout()) == 5)+ if (DataTensor::ChannelsCount(params.outputs[0].GetLayout()) == 5) {spatial = params.outputs[0].X().v * params.outputs[0].Y().v * params.outputs[0].Z().v;- else+ } else {spatial = params.outputs[0].X().v * params.outputs[0].Y().v;+ }return (feature * batch * spatial);}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_fs_b_yx_fsv32.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_fs_b_yx_fsv32.cppindex 2b9fb12de2d..084faf6af63 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_fs_b_yx_fsv32.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_fs_b_yx_fsv32.cpp@@ -40,14 +40,16 @@ bool EltwiseKernel_fs_b_yx_fsv32::Validate(const Params& params) const {bool bCheckSizes = true;for (size_t i = 0; i < ewParams.inputs.size(); i++) {// allow only the same input sizes or scalars, without pitches- if ((ewParams.inputs[0] != ewParams.inputs[i] || ewParams.inputs[i] != ewParams.outputs[0]) && ewParams.inputs[i].PhysicalSize() != 1)+ if ((ewParams.inputs[0] != ewParams.inputs[i] || ewParams.inputs[i] != ewParams.outputs[0]) && ewParams.inputs[i].PhysicalSize() != 1) {bCheckSizes = false;+ }}// TODO: add support to this implementation when user requests input values updatesbool bCheckUpdateInput = true;- if (!ewParams.updateInputIds.empty())+ if (!ewParams.updateInputIds.empty()) {bCheckUpdateInput = false;+ }// TODO: add support for reading from output buffer and using its values in computationbool bCheckUseOutput = true;@@ -60,8 +62,9 @@ bool EltwiseKernel_fs_b_yx_fsv32::Validate(const Params& params) const {}}- if (IsUnsupportedModeForVecCode(ewParams))+ if (IsUnsupportedModeForVecCode(ewParams)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }if (!bCheckSizes || !bSupportedCount || !bCheckUpdateInput || !bCheckUseOutput) {DO_NOT_USE_THIS_KERNEL(params.layerID);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_mixed_byxf_and_fs_b_yx_fsv32.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_mixed_byxf_and_fs_b_yx_fsv32.cppindex f8fcafc51ad..b9d3d163c73 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_mixed_byxf_and_fs_b_yx_fsv32.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_mixed_byxf_and_fs_b_yx_fsv32.cpp@@ -51,8 +51,9 @@ bool EltwiseKernel_mixed_byxf_and_fs_b_yx_fsv32::Validate(const Params& params)}for (auto in : inputs) {- if (in.GetLayout() != DataLayout::fs_b_yx_fsv32 && in.GetLayout() != DataLayout::byxf)+ if (in.GetLayout() != DataLayout::fs_b_yx_fsv32 && in.GetLayout() != DataLayout::byxf) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}const auto& input1 = inputs[0];diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_vload8.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_vload8.cppindex e18c7f696cd..9781f9ccdd6 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_vload8.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_vload8.cpp@@ -51,8 +51,9 @@ bool EltwiseKernel_vload8::Validate(const Params& params) const {(input_layout == DataLayout::b_fs_yx_fsv4 && feature_size % 8 != 0) ||input_layout == DataLayout::fs_b_yx_fsv32 ||(input_layout == DataLayout::bs_fs_yx_bsv32_fsv16 && (feature_size % 16 != 0 || batch_size % 32 != 0)) ||- (input_layout == DataLayout::bs_fs_yx_bsv32_fsv32 && (feature_size % 32 != 0 || batch_size % 32 != 0)))+ (input_layout == DataLayout::bs_fs_yx_bsv32_fsv32 && (feature_size % 32 != 0 || batch_size % 32 != 0))) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}if ((ewParams.outputs[0].GetLayout() == DataLayout::b_fs_yx_fsv16 && ewParams.outputs[0].Feature().v % 16 != 0) ||(ewParams.outputs[0].GetLayout() == DataLayout::b_fs_yx_fsv32 && ewParams.outputs[0].Feature().v % 32 != 0) ||@@ -62,8 +63,9 @@ bool EltwiseKernel_vload8::Validate(const Params& params) const {(ewParams.outputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv32_fsv16 &&(ewParams.outputs[0].Feature().v % 16 != 0 || ewParams.outputs[0].Batch().v % 32 != 0)) ||(ewParams.outputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv32_fsv32 &&- (ewParams.outputs[0].Feature().v % 32 != 0 || ewParams.outputs[0].Batch().v % 32 != 0)))+ (ewParams.outputs[0].Feature().v % 32 != 0 || ewParams.outputs[0].Batch().v % 32 != 0))) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }const auto& output = ewParams.outputs[0];const auto count = output.PhysicalSize();@@ -75,14 +77,16 @@ bool EltwiseKernel_vload8::Validate(const Params& params) const {// allow only the same input sizes or scalars, without pitchesif (ewParams.inputs[i].PitchesDifferFromLogicalDims() ||((ewParams.inputs[0] != ewParams.inputs[i] || ewParams.inputs[i] != ewParams.outputs[0]) &&- ewParams.inputs[i].PhysicalSize() != 1))+ ewParams.inputs[i].PhysicalSize() != 1)) {bCheckSizes = false;+ }}// TODO: add support to this implementation when user requests input values updatesbool bCheckUpdateInput = true;- if (!ewParams.updateInputIds.empty())+ if (!ewParams.updateInputIds.empty()) {bCheckUpdateInput = false;+ }// TODO: add support for reading from output buffer and using its values in computationbool bCheckUseOutput = true;@@ -95,8 +99,9 @@ bool EltwiseKernel_vload8::Validate(const Params& params) const {}}- if (IsUnsupportedModeForVecCode(ewParams))+ if (IsUnsupportedModeForVecCode(ewParams)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }if (!bCheckSizes || !bSupportedCount || !bCheckUpdateInput || !bCheckUseOutput) {DO_NOT_USE_THIS_KERNEL(params.layerID);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/embedding_bag/embedding_bag_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/embedding_bag/embedding_bag_kernel_ref.cppindex e93f8ac0b43..3af6c43a05e 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/embedding_bag/embedding_bag_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/embedding_bag/embedding_bag_kernel_ref.cpp@@ -24,8 +24,9 @@ JitConstants EmbeddingBagKernelRef::GetJitConstants(const embedding_bag_params&default:break;}- if (params.default_index > -1)+ if (params.default_index > -1) {jit.AddConstant(MakeJitConstant("DEFAULT_INDEX", params.default_index));+ }return jit;}@@ -110,12 +111,14 @@ bool EmbeddingBagKernelRef::Validate(const Params& p) const {return dt == Datatype::INT32 || dt == Datatype::UINT32;};- if (!checkIntType(params.inputs[1].GetDType()))+ if (!checkIntType(params.inputs[1].GetDType())) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }if (params.type == EmbeddingBagType::OFFSETS_SUM || params.type == EmbeddingBagType::SEGMENTS_SUM) {- if (!checkIntType(params.inputs[2].GetDType()))+ if (!checkIntType(params.inputs[2].GetDType())) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}return true;diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/extract_image_patches/extract_image_patches_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/extract_image_patches/extract_image_patches_kernel_base.cppindex 141da8e40fc..19660e2753b 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/extract_image_patches/extract_image_patches_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/extract_image_patches/extract_image_patches_kernel_base.cpp@@ -32,10 +32,11 @@ JitConstants ExtractImagePatchesKernelBase::GetJitConstants(const extract_image_MakeJitConstant("RATES_ROWS", params.rates[0]),MakeJitConstant("RATES_COLS", params.rates[1]),});- if (params.auto_pad == "same_upper")+ if (params.auto_pad == "same_upper") {jit.AddConstant(MakeJitConstant("AUTO_PAD", 1));- else if (params.auto_pad == "same_lower")+ } else if (params.auto_pad == "same_lower") {jit.AddConstant(MakeJitConstant("AUTO_PAD", 2));+ }return jit;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/eye/eye_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/eye/eye_kernel_ref.cppindex 6231d12b082..a9eaff5c6ee 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/eye/eye_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/eye/eye_kernel_ref.cpp@@ -58,8 +58,9 @@ bool EyeKernelRef::Validate(const Params& p) const {}const eye_params& params = dynamic_cast<const eye_params&>(p);- if (params.inputs.empty())+ if (params.inputs.empty()) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_block_kernel_base.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_block_kernel_base.hindex 9614271f589..b47e850eeb5 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_block_kernel_base.h+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_block_kernel_base.h@@ -6,7 +6,6 @@#include "fully_connected_kernel_base.h"-namespace kernel_selector {class FullyConnectedBlockKernelBase : public FullyConnectedKernelBase {public:@@ -25,8 +24,9 @@ protected:static size_t GetNeuronsPerWorkItem(const fully_connected_params& params) {auto batchSize = params.outputs[0].Batch().v;auto out_elements_count_per_batch = params.outputs[0].LogicalSize() / batchSize;- if (out_elements_count_per_batch % 16 == 0)+ if (out_elements_count_per_batch % 16 == 0) {return 2;+ }return 1;}};diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_base.cppindex 663a2f2b35f..dbe1bcac46f 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_base.cpp@@ -3,15 +3,16 @@//#include "fully_connected_kernel_base.h"-#include "kernel_selector_utils.h"-#include "common_tools.h"++#include <algorithm>#include <string>#include <vector>-#include <algorithm>++#include "common_tools.h"+#include "kernel_selector_utils.h"namespace kernel_selector {-JitConstants FullyConnectedKernelBase::GetJitConstants(const fully_connected_params& params,- const FullyConnectedKernelBase::DispatchData&) const {+JitConstants FullyConnectedKernelBase::GetJitConstants(const fully_connected_params& params, const FullyConnectedKernelBase::DispatchData&) const {JitConstants jit = WeightBiasKernelBase::GetJitConstants(params);const auto& input = params.inputs[0];if (input.is_dynamic()) {@@ -56,12 +57,11 @@ JitConstants FullyConnectedKernelBase::GetJitConstants(const fully_connected_parreturn jit;}-FullyConnectedKernelBase::DispatchData FullyConnectedKernelBase::SetDefault(const fully_connected_params& params,- int, int /*kernel_number*/) const {+FullyConnectedKernelBase::DispatchData FullyConnectedKernelBase::SetDefault(const fully_connected_params& params, int, int /*kernel_number*/) const {DispatchData dispatchData;// Determine global work sizes.- dispatchData.gws = { params.outputs[0].LogicalSize(), 1, 1 };+ dispatchData.gws = {params.outputs[0].LogicalSize(), 1, 1};// Find largest positive local work size that is divider for global work size.dispatchData.lws[0] = std::min(std::max(dispatchData.gws[0], static_cast<size_t>(1)), static_cast<size_t>(32));@@ -84,7 +84,7 @@ void FullyConnectedKernelBase::GetUpdateDispatchDataFunc(KernelData& kd) const {};}-KernelsData FullyConnectedKernelBase::GetCommonKernelsData(const Params ¶ms,+KernelsData FullyConnectedKernelBase::GetCommonKernelsData(const Params& params,DataLayout dl,WeightsLayout wl,const std::string exeMode,@@ -111,10 +111,7 @@ KernelsData FullyConnectedKernelBase::GetCommonKernelsData(const Params ¶ms,kd.reorderInput = true;}- bool succeed = UpdateWeightsParams(newParams,- wl,- kd.weightsReorderParams,- GetSupportedKey());+ bool succeed = UpdateWeightsParams(newParams, wl, kd.weightsReorderParams, GetSupportedKey());if (!succeed) {return {};@@ -131,8 +128,9 @@ KernelsData FullyConnectedKernelBase::GetCommonKernelsData(const Params ¶ms,int inputs_count = 1;if (newParams.compressed) {inputs_count++;- if (newParams.has_decompression_zp && !newParams.scalar_zp)+ if (newParams.has_decompression_zp && !newParams.scalar_zp) {inputs_count++;+ }}auto& kernel = kd.kernels[0];@@ -163,18 +161,10 @@ std::string FullyConnectedKernelBase::GetAutoTuneOptions(int autoTuneIndex) consreturn EXE_MODE_DEFAULT;}-KernelsData FullyConnectedKernelBase::GetTunedKernelsDataByIndex(const Params ¶ms,- DataLayout dl,- WeightsLayout wl,- const int autoTuneIndex) const {- return GetCommonKernelsData(params,- dl,- wl,- GetAutoTuneOptions(autoTuneIndex),- autoTuneIndex);+KernelsData FullyConnectedKernelBase::GetTunedKernelsDataByIndex(const Params& params, DataLayout dl, WeightsLayout wl, const int autoTuneIndex) const {+ return GetCommonKernelsData(params, dl, wl, GetAutoTuneOptions(autoTuneIndex), autoTuneIndex);}-JitConstants FullyConnectedKernelBase::GetFusedPrimitivesJitConstants(const fully_connected_params&, const DispatchData&) const {return {};}@@ -187,16 +177,18 @@ bool FullyConnectedKernelBase::Validate(const Params& p) const {}for (const auto& fused_op : params.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}return true;}Datatype FullyConnectedKernelBase::GetAccumulatorType(const fully_connected_params& params) const {- if (params.quantization != QuantizationType::NONE)+ if (params.quantization != QuantizationType::NONE) {return Datatype::INT32;+ }auto in_dt = params.inputs[0].GetDType();auto wei_dt = params.weights.GetDType();@@ -205,12 +197,14 @@ Datatype FullyConnectedKernelBase::GetAccumulatorType(const fully_connected_paraauto quantized_weights = wei_dt == WeightsType::UINT8 || wei_dt == WeightsType::INT8;// This case should be always false, because quantization type is not NONE- if (quantized_inputs && quantized_weights)+ if (quantized_inputs && quantized_weights) {return Datatype::INT32;+ }// If we either weights or input is quantized, then we use fp32 accumulator to avoid fp16 overflow- if ((quantized_inputs || quantized_weights) && !params.compressed)+ if ((quantized_inputs || quantized_weights) && !params.compressed) {return Datatype::F32;+ }return in_dt;}@@ -223,14 +217,16 @@ Datatype FullyConnectedKernelBase::GetActivationType(const fully_connected_paramauto quantized_inputs = in_dt == Datatype::UINT8 || in_dt == Datatype::INT8;auto quantized_weights = wei_dt == WeightsType::UINT8 || wei_dt == WeightsType::INT8;- if (params.quantization != QuantizationType::NONE || quantized_inputs || quantized_weights)+ if (params.quantization != QuantizationType::NONE || quantized_inputs || quantized_weights) {return Datatype::F32;+ }auto output_is_int8 = out_dt == Datatype::UINT8 || out_dt == Datatype::INT8;auto input_is_fp = in_dt == Datatype::F32 || in_dt == Datatype::F16;- if (output_is_int8 && input_is_fp)+ if (output_is_int8 && input_is_fp) {return in_dt;+ }return GetUnitType(params);}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_io_input_spatial.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_io_input_spatial.cppindex 12bbcfd2bf9..d5563101ae6 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_io_input_spatial.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_io_input_spatial.cpp@@ -52,9 +52,11 @@ KernelsPriority FullyConnected_bf_io_input_spatial::GetKernelsPriority(const Parconst auto& input = p.inputs[0];const auto& output = p.outputs[0];- if (input.Batch().v == 1 && output.Batch().v == 1)- if ((input.LogicalSize() / output.Batch().v >= 4096) && (output.Feature().v >= 4096))+ if (input.Batch().v == 1 && output.Batch().v == 1) {+ if ((input.LogicalSize() / output.Batch().v >= 4096) && (output.Feature().v >= 4096)) {return FORCE_PRIORITY_1;+ }+ }return DONT_USE_IF_HAVE_SOMETHING_ELSE;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_tiled.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_tiled.cppindex d10242ab401..f9c38c1ed7e 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_tiled.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_tiled.cpp@@ -3,41 +3,41 @@//#include "fully_connected_kernel_bf_tiled.h"++#include <functional>+#include <vector>++#include "common_types.h"#include "fully_connected_kernel_bf_tiled_dyn_b.h"#include "kernel_selector_utils.h"#include "swiglu/swiglu_kernel_base.h"-#include <vector>-#include <functional>-#include "common_types.h"static constexpr size_t lws_batches = 8;static constexpr size_t simd = 16;static constexpr size_t input_load_size = 4;-static constexpr size_t min_quantize_grp_size = (simd * 2); // SIMD * (min value of tile_ifm)+static constexpr size_t min_quantize_grp_size = (simd * 2); // SIMD * (min value of tile_ifm)static constexpr size_t min_slm_size = 256;static std::vector<size_t> available_quantize_grp_size = {128, 64, 32};// Per-direction bitmasks of batch sizes where dyn_b is beneficial (based on MTL profiling).// IFM << OFM (e.g. 3584→18944): exclude {20, 24}static constexpr uint64_t dyn_b_batches_ifm_lt_ofm =- (1ULL << 2) | (1ULL << 3) | (1ULL << 4) | (1ULL << 5) | (1ULL << 6) | (1ULL << 7) | (1ULL << 8) |- (1ULL << 9) | (1ULL << 10) | (1ULL << 11) | (1ULL << 12) | (1ULL << 13) |- (1ULL << 14) | (1ULL << 15) | (1ULL << 16) | (1ULL << 17) | (1ULL << 18) | (1ULL << 19) |- (1ULL << 21) | (1ULL << 22) | (1ULL << 23) |+ (1ULL << 2) | (1ULL << 3) | (1ULL << 4) | (1ULL << 5) | (1ULL << 6) | (1ULL << 7) | (1ULL << 8) | (1ULL << 9) | (1ULL << 10) | (1ULL << 11) | (1ULL << 12) |+ (1ULL << 13) | (1ULL << 14) | (1ULL << 15) | (1ULL << 16) | (1ULL << 17) | (1ULL << 18) | (1ULL << 19) | (1ULL << 21) | (1ULL << 22) | (1ULL << 23) |(1ULL << 25) | (1ULL << 26) | (1ULL << 27) | (1ULL << 28) | (1ULL << 29) | (1ULL << 30) | (1ULL << 31) | (1ULL << 32);// IFM >> OFM (e.g. 18944→3584): exclude {3, 6, 7, 8, 24, 25, 30, 31, 32}-static constexpr uint64_t dyn_b_batches_ifm_gt_ofm =- (1ULL << 2) | (1ULL << 4) | (1ULL << 5) |- (1ULL << 9) | (1ULL << 10) | (1ULL << 11) | (1ULL << 12) | (1ULL << 13) |- (1ULL << 14) | (1ULL << 15) | (1ULL << 16) | (1ULL << 17) | (1ULL << 18) | (1ULL << 19) |- (1ULL << 20) | (1ULL << 21) | (1ULL << 22) | (1ULL << 23) |- (1ULL << 26) | (1ULL << 27) | (1ULL << 28) | (1ULL << 29);+static constexpr uint64_t dyn_b_batches_ifm_gt_ofm = (1ULL << 2) | (1ULL << 4) | (1ULL << 5) | (1ULL << 9) | (1ULL << 10) | (1ULL << 11) | (1ULL << 12) |+ (1ULL << 13) | (1ULL << 14) | (1ULL << 15) | (1ULL << 16) | (1ULL << 17) | (1ULL << 18) | (1ULL << 19) |+ (1ULL << 20) | (1ULL << 21) | (1ULL << 22) | (1ULL << 23) | (1ULL << 26) | (1ULL << 27) | (1ULL << 28) |+ (1ULL << 29);static inline bool should_use_dyn_b_kernel(size_t batch, size_t ifm, size_t ofm, bool swiglu) {- if (swiglu || batch < 2 || batch > 32)+ if (swiglu || batch < 2 || batch > 32) {return false;- if (std::min(ifm, ofm) < simd)+ }+ if (std::min(ifm, ofm) < simd) {return false;+ }uint64_t mask = (ifm < ofm) ? dyn_b_batches_ifm_lt_ofm : dyn_b_batches_ifm_gt_ofm;return ((mask >> batch) & 1ULL) != 0u;}@@ -57,18 +57,15 @@ std::pair<size_t, size_t> get_input_bf_size(const fully_connected_params& params}// In Some model, input_f could be dynamic in input0. It refers to IFM value of weight.- if (input.is_dynamic() && input_f == 0 && params.weights.IFM().v != 0)+ if (input.is_dynamic() && input_f == 0 && params.weights.IFM().v != 0) {input_f = params.weights.IFM().v;+ }return {input_batch, input_f};}-std::pair<size_t, size_t> get_output_aligned_bf_size(const fully_connected_params& params,- bool needs_align,- uint32_t align_b,- int32_t align_f) {- size_t output_f =- (needs_align) ? CeilDiv(params.outputs[0].Feature().v, align_f) : params.outputs[0].Feature().v;+std::pair<size_t, size_t> get_output_aligned_bf_size(const fully_connected_params& params, bool needs_align, uint32_t align_b, int32_t align_f) {+ size_t output_f = (needs_align) ? CeilDiv(params.outputs[0].Feature().v, align_f) : params.outputs[0].Feature().v;size_t output_b = params.outputs[0].Batch().v;// 3D outputif (params.outputs[0].GetLayout() == DataLayout::bfyx) {@@ -93,8 +90,9 @@ bool is_8bit_asym_wei(const fully_connected_params& params) {bool is_weight_dyn_quantizable(const fully_connected_params& params) {auto weight_type = params.weights.GetDType();- if (weight_type == WeightsType::INT4 || weight_type == WeightsType::UINT4)+ if (weight_type == WeightsType::INT4 || weight_type == WeightsType::UINT4) {return true;+ }// No validated case of sym 8bit weightreturn is_8bit_asym_wei(params);}@@ -111,8 +109,9 @@ size_t get_dynamic_quantize_group_size(const fully_connected_params& params) {size_t scale_group_size = get_scale_group_size(params);size_t zp_group_num = params.decompression_zero_point.Feature().v;size_t zp_group_size = 0;- if (params.has_decompression_zp)+ if (params.has_decompression_zp) {zp_group_size = params.weights.IFM().v / params.decompression_zero_point.Feature().v;+ }// Per-token dyn-quanif (dynamic_quantization_group_size >= min_quantize_grp_size && is_per_token_dynamic_quantize(params)) {@@ -121,15 +120,14 @@ size_t get_dynamic_quantize_group_size(const fully_connected_params& params) {dynamic_quantization_group_size = scale_group_size;// For int8 ASYM model, activation_sum should fit to weight zp- if (is_8bit_asym_wei(params) && params.has_decompression_zp &&- dynamic_quantization_group_size > zp_group_size && (zp_group_size % input_load_size) == 0) {+ if (is_8bit_asym_wei(params) && params.has_decompression_zp && dynamic_quantization_group_size > zp_group_size &&+ (zp_group_size % input_load_size) == 0) {dynamic_quantization_group_size = zp_group_size;}- GPU_DEBUG_LOG << "FC dyn-quantize by per-token. Actual dyn_quan_group_size("- << dynamic_quantization_group_size << ") : From scale_group_size (" << scale_group_size- << ", zp_group_size(" << zp_group_size << "), zp_group_num(" << zp_group_num- << "), ifm_size (" << get_input_bf_size(params).second << ")" << std::endl;+ GPU_DEBUG_LOG << "FC dyn-quantize by per-token. Actual dyn_quan_group_size(" << dynamic_quantization_group_size << ") : From scale_group_size ("+ << scale_group_size << ", zp_group_size(" << zp_group_size << "), zp_group_num(" << zp_group_num << "), ifm_size ("+ << get_input_bf_size(params).second << ")" << std::endl;return (size_t)dynamic_quantization_group_size;}}@@ -140,9 +138,8 @@ size_t get_dynamic_quantize_group_size(const fully_connected_params& params) {dynamic_quantization_group_size = group_size;if (dynamic_quantization_group_size > scale_group_size) {- GPU_DEBUG_TRACE_DETAIL << " Scale group size " << scale_group_size- << " is smaller than FC dyn-quan group size " << dynamic_quantization_group_size- << ". Reduce FC dyn-quan group size to scale size." << std::endl;+ GPU_DEBUG_TRACE_DETAIL << " Scale group size " << scale_group_size << " is smaller than FC dyn-quan group size "+ << dynamic_quantization_group_size << ". Reduce FC dyn-quan group size to scale size." << std::endl;dynamic_quantization_group_size = scale_group_size;}@@ -156,38 +153,35 @@ size_t get_dynamic_quantize_group_size(const fully_connected_params& params) {bool should_dynamic_quantize(const fully_connected_params& params) {size_t dynamic_quantization_group_size = get_dynamic_quantize_group_size(params);- if (params.inputs[0].GetFirstElementOffset() != 0)+ if (params.inputs[0].GetFirstElementOffset() != 0) {return false;+ }if (dynamic_quantization_group_size < min_quantize_grp_size) {- GPU_DEBUG_TRACE_DETAIL << "Set dynamic_quantize_group_size " << dynamic_quantization_group_size- << " is smaller than minimum supported size 32" << std::endl;+ GPU_DEBUG_TRACE_DETAIL << "Set dynamic_quantize_group_size " << dynamic_quantization_group_size << " is smaller than minimum supported size 32"+ << std::endl;return false;}const size_t scale_group_size = get_scale_group_size(params);- if ((scale_group_size % min_quantize_grp_size) != 0)+ if ((scale_group_size % min_quantize_grp_size) != 0) {return false;+ }auto threads = get_input_bf_size(params);auto input_b = threads.first;auto input_f = threads.second;- if ((scale_group_size % simd == 0) && (input_f % dynamic_quantization_group_size == 0) &&- (params.is_shape_agnostic || input_b > min_slm_size) &&+ if ((scale_group_size % simd == 0) && (input_f % dynamic_quantization_group_size == 0) && (params.is_shape_agnostic || input_b > min_slm_size) &¶ms.inputs[0].GetDType() == Datatype::F16 && is_weight_dyn_quantizable(params)) {GPU_DEBUG_TRACE_DETAIL << " Dynamic quantizing for FC : scale_group_size: " << scale_group_size<< ", Dyn-quan group size: " << dynamic_quantization_group_size<< ", Type(I:" << kernel_selector::toString(params.inputs[0].GetDType())<< ", O:" << kernel_selector::toString(params.outputs[0].GetDType())<< ", W:" << kernel_selector::toString(params.weights.GetDType())- << "), Format(W:" << kernel_selector::toString(params.weights.GetLayout())- << ") B: " << params.inputs[0].Batch().v << ", F: " << params.inputs[0].Feature().v- << ", Y: " << params.inputs[0].Y().v- << ", X: " << params.inputs[0].X().v- << ", input_b: " << input_b- << ", input_f: " << input_f- << std ::endl;+ << "), Format(W:" << kernel_selector::toString(params.weights.GetLayout()) << ") B: " << params.inputs[0].Batch().v+ << ", F: " << params.inputs[0].Feature().v << ", Y: " << params.inputs[0].Y().v << ", X: " << params.inputs[0].X().v+ << ", input_b: " << input_b << ", input_f: " << input_f << std ::endl;return true;}@@ -196,23 +190,17 @@ bool should_dynamic_quantize(const fully_connected_params& params) {bool is_weight_vertical(const fully_connected_params& params, size_t output_f) {size_t min_num_threads = params.engineInfo.computeUnitsCount * simd;- GPU_DEBUG_TRACE_DETAIL << "out_ofm (== weight N dim) size " << output_f- << " is small compared to the available threads. "- << "(computeUnitsCount : " << params.engineInfo.computeUnitsCount- << " min_num_threads : " << min_num_threads << ")" << std::endl;+ GPU_DEBUG_TRACE_DETAIL << "out_ofm (== weight N dim) size " << output_f << " is small compared to the available threads. "+ << "(computeUnitsCount : " << params.engineInfo.computeUnitsCount << " min_num_threads : " << min_num_threads << ")" << std::endl;GPU_DEBUG_TRACE_DETAIL << "Use ofm_tile size 1 if the batch size is 1." << std::endl;- return (params.weights.IFM().v >= params.weights.OFM().v * 3 &&- output_f / 2 /*most frequently used tile_ofm*/ <= min_num_threads);+ return (params.weights.IFM().v >= params.weights.OFM().v * 3 && output_f / 2 /*most frequently used tile_ofm*/ <= min_num_threads);}bool is_weight_horizontal(const fully_connected_params& params, size_t output_f) {size_t min_num_threads = params.engineInfo.computeUnitsCount * simd;- GPU_DEBUG_TRACE_DETAIL << "out_ofm (== weight N dim) size " << output_f- << " is large compared to the available threads. "- << "(computeUnitsCount : " << params.engineInfo.computeUnitsCount- << " min_num_threads : " << min_num_threads << ")" << std::endl;- return (params.weights.OFM().v > params.weights.IFM().v * 3 &&- output_f / 4 /* tile_ofm=4 */ > min_num_threads * 1.5);+ GPU_DEBUG_TRACE_DETAIL << "out_ofm (== weight N dim) size " << output_f << " is large compared to the available threads. "+ << "(computeUnitsCount : " << params.engineInfo.computeUnitsCount << " min_num_threads : " << min_num_threads << ")" << std::endl;+ return (params.weights.OFM().v > params.weights.IFM().v * 3 && output_f / 4 /* tile_ofm=4 */ > min_num_threads * 1.5);}bool is_weight_small_kn(const fully_connected_params& params, size_t output_f) {@@ -224,41 +212,53 @@ bool is_swiglu_fused(const fully_connected_params& params) {bool swiglu_fused = false;if (!params.fused_ops.empty()) {for (auto p : params.fused_ops) {- if (p.GetType() == kernel_selector::KernelType::SWIGLU)+ if (p.GetType() == kernel_selector::KernelType::SWIGLU) {swiglu_fused = true;+ }}}- if (swiglu_fused)+ if (swiglu_fused) {OPENVINO_ASSERT(params.fused_ops.size() == 1);+ }return swiglu_fused;}bool is_suitable_outer_ofm(const fully_connected_params& params, size_t output_f) {- if (is_swiglu_fused(params))+ if (is_swiglu_fused(params)) {return true;+ }size_t min_num_threads = params.engineInfo.computeUnitsCount * simd;- return (params.weights.OFM().v > params.weights.IFM().v * 6 &&- output_f / 8 /* tile_ofm=4 and outer_ofm=2 */ > min_num_threads * 1.5);+ return (params.weights.OFM().v > params.weights.IFM().v * 6 && output_f / 8 /* tile_ofm=4 and outer_ofm=2 */ > min_num_threads * 1.5);}} // namespace fc_kernel_bf_tiled_utilsusing namespace fc_kernel_bf_tiled_utils;FullyConnected_bf_tiled::FullyConnected_bf_tiled() : FullyConnectedKernelBase("fully_connected_gpu_bf_tiled") {- for (unsigned tile_b = 1; tile_b <= 32; ++tile_b)- for (unsigned tile_ofm = 1; tile_ofm <= 4; tile_ofm *= 2)- for (unsigned tile_ifm = 1; tile_ifm <= 2; tile_ifm *= 2)- for (unsigned tile_k = 1; tile_k <= 8; tile_k *= 2)- for (unsigned outer_ofm = 1; outer_ofm <= 2; ++outer_ofm)- for (unsigned dispatch_bsv = 1; dispatch_bsv <= 16; ++dispatch_bsv)- for (unsigned dispatch_fsv = 1; dispatch_fsv <= 16; ++dispatch_fsv)- for (auto exec : Parent::autoTuneOptions) {- // Block reads support at most vector size of 8.- if (tile_k * tile_ofm > 8)- continue;- // For bsv == 1 dispatch order reduces to b_fsv, so anything other than fsv == 1 is redundant.- if (dispatch_bsv == 1 && dispatch_fsv != 1)- continue;-- auto_tune_params.emplace_back(tile_b, tile_ofm, tile_ifm, tile_k, outer_ofm, dispatch_bsv, dispatch_fsv, exec);+ for (unsigned tile_b = 1; tile_b <= 32; ++tile_b) {+ for (unsigned tile_ofm = 1; tile_ofm <= 4; tile_ofm *= 2) {+ for (unsigned tile_ifm = 1; tile_ifm <= 2; tile_ifm *= 2) {+ for (unsigned tile_k = 1; tile_k <= 8; tile_k *= 2) {+ for (unsigned outer_ofm = 1; outer_ofm <= 2; ++outer_ofm) {+ for (unsigned dispatch_bsv = 1; dispatch_bsv <= 16; ++dispatch_bsv) {+ for (unsigned dispatch_fsv = 1; dispatch_fsv <= 16; ++dispatch_fsv) {+ for (auto exec : Parent::autoTuneOptions) {+ // Block reads support at most vector size of 8.+ if (tile_k * tile_ofm > 8) {+ continue;+ }+ // For bsv == 1 dispatch order reduces to b_fsv, so anything+ // other than fsv == 1 is redundant.+ if (dispatch_bsv == 1 && dispatch_fsv != 1) {+ continue;+ }++ auto_tune_params.emplace_back(tile_b, tile_ofm, tile_ifm, tile_k, outer_ofm, dispatch_bsv, dispatch_fsv, exec);+ }+ }+ }+ }+ }+ }+ }}}@@ -312,32 +312,38 @@ bool FullyConnected_bf_tiled::Validate(const Params& params) const {// Block reads must be aligned to 4 bytes, for fp16 we can correct for offset misalignment,// but we need to ensure that batch pitch preserves alignment.if (input.GetDType() == Datatype::F16) {- if (input.Batch().pitch % 2 != 0 && (input.Batch().v > 1 || fc_params.is_shape_agnostic))+ if (input.Batch().pitch % 2 != 0 && (input.Batch().v > 1 || fc_params.is_shape_agnostic)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }// for 3d case we have to check feature alignment as well- if (output.GetLayout() == DataLayout::bfyx && input.Feature().pitch % 2 != 0 && (input.Feature().v > 1 || fc_params.is_shape_agnostic))+ if (output.GetLayout() == DataLayout::bfyx && input.Feature().pitch % 2 != 0 && (input.Feature().v > 1 || fc_params.is_shape_agnostic)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}// Dynamic kernel doesn't support dynamic weights yetif (fc_params.is_shape_agnostic && input.is_dynamic()) {- if (get_input_bf_size(fc_params).second == 0)+ if (get_input_bf_size(fc_params).second == 0) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}if (input.GetLayout() == DataLayout::bfyx) {// Padding on input is not supported.// TODO: Enable by mirroring the padding in weights.- if (input.X().pad.Total() != 0)+ if (input.X().pad.Total() != 0) {DO_NOT_USE_THIS_KERNEL(params.layerID);- if (input.Y().pad.Total() != 0)+ }+ if (input.Y().pad.Total() != 0) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}// We don't support 4d outputif (fc_params.outputs[0].GetLayout() == DataLayout::bfyx) {- if (input.X().v > 1)+ if (input.X().v > 1) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}auto wt = weights.GetDType();@@ -392,52 +398,64 @@ bool TuneParamsSelector::VerifyTuneParams(const fully_connected_params& params,auto batch_size = params.is_shape_agnostic ? Align(output_b, tparams.tile_b) : output_b;// If batch size is prime number, still can apply tile execution to avoid poor performance.if (batch_size % (tparams.tile_b * tparams.dispatch_bsv) != 0) {- if ((tparams.dispatch_bsv != 1) || batch_size == 1)+ if ((tparams.dispatch_bsv != 1) || batch_size == 1) {return false;+ }size_t tile = simd;- while (batch_size % tile != 0)+ while (batch_size % tile != 0) {tile--;- if (tile > 1)+ }+ if (tile > 1) {return false;+ }}- if (CeilDiv(output_f, tparams.tile_ofm * simd) % tparams.dispatch_fsv != 0)+ if (CeilDiv(output_f, tparams.tile_ofm * simd) % tparams.dispatch_fsv != 0) {return false;+ }// Same result can be achieved with smaller tile_ofm.- if (output_f <= (tparams.tile_ofm / 2) * simd)+ if (output_f <= (tparams.tile_ofm / 2) * simd) {return false;+ }// No weights layout for such huge tile ofm.- if (tparams.tile_ofm * simd > 64)+ if (tparams.tile_ofm * simd > 64) {return false;+ }bool is_dyn_quantable_type = is_weight_dyn_quantizable(params);if (tparams.kernel_type == FullyConnected_bf_tiled::KernelType::SLM) {const auto required_batch_alignment = 64;- if (!params.is_shape_agnostic && (!IsAligned(output_b, required_batch_alignment) || output_b < min_slm_size))+ if (!params.is_shape_agnostic && (!IsAligned(output_b, required_batch_alignment) || output_b < min_slm_size)) {return false;+ }const auto required_tile_b = 8;- if ((tparams.tile_b != required_tile_b) && !is_dyn_quantable_type)+ if ((tparams.tile_b != required_tile_b) && !is_dyn_quantable_type) {return false;+ }const auto required_tile_ofm = 2;- if (tparams.tile_ofm != required_tile_ofm)+ if (tparams.tile_ofm != required_tile_ofm) {return false;+ }- if (!is_dyn_quantable_type)+ if (!is_dyn_quantable_type) {return false;+ }- if (params.engineInfo.deviceType != dev_type::integrated_gpu)+ if (params.engineInfo.deviceType != dev_type::integrated_gpu) {return false;+ }- const auto required_slm_size = tparams.tile_ofm * simd * tparams.tile_ifm * simd * 2; // 2 bytes per value (FP16 data type)+ const auto required_slm_size = tparams.tile_ofm * simd * tparams.tile_ifm * simd * 2; // 2 bytes per value (FP16 data type)return params.engineInfo.maxLocalMemSize >= required_slm_size;}if (params.compressed && is_dyn_quantable_type) {- if (tparams.tile_ofm != 2 && tparams.tile_ofm != 4)+ if (tparams.tile_ofm != 2 && tparams.tile_ofm != 4) {return false;+ }return tparams.tile_ofm != 4 || tparams.outer_ofm != 2 || is_suitable_outer_ofm(params, output_f);}@@ -454,11 +472,12 @@ bool TuneParamsSelector::VerifyTuneParams(const fully_connected_params& params,} // namespace-FullyConnected_bf_tiled::tune_params-FullyConnected_bf_tiled::GetAutoTuneParams(const fully_connected_params& params, KernelType preferred_kernel_type, int idx) const {- if (idx >= 0 && idx < static_cast<int>(auto_tune_params.size())- && TuneParamsSelector::VerifyTuneParams(params, auto_tune_params[idx]))+FullyConnected_bf_tiled::tune_params FullyConnected_bf_tiled::GetAutoTuneParams(const fully_connected_params& params,+ KernelType preferred_kernel_type,+ int idx) const {+ if (idx >= 0 && idx < static_cast<int>(auto_tune_params.size()) && TuneParamsSelector::VerifyTuneParams(params, auto_tune_params[idx])) {return auto_tune_params[idx];+ }auto bf_size = get_output_aligned_bf_size(params, false);size_t batch = bf_size.first;@@ -469,8 +488,9 @@ FullyConnected_bf_tiled::GetAutoTuneParams(const fully_connected_params& params,auto selector = TuneParamsSelector(params);unsigned max_tile_ofm = 1;- while (max_tile_ofm * 2 * simd <= output_f && max_tile_ofm < 4)+ while (max_tile_ofm * 2 * simd <= output_f && max_tile_ofm < 4) {max_tile_ofm *= 2;+ }bool swiglu_fused = is_swiglu_fused(params);@@ -488,8 +508,9 @@ FullyConnected_bf_tiled::GetAutoTuneParams(const fully_connected_params& params,}} else if (is_weight_small_kn(params, output_f)) {if (params.weights.GetLayout() == WeightsLayout::os_is_yx_osv32_isv2) {- if (swiglu_fused)+ if (swiglu_fused) {return selector.Default(tune_params(1, 1, 4, 2, 2, 1, 1, EXE_MODE_DEFAULT));+ }return selector.Default(tune_params(1, 1, 4, 2, 1, 1, 1, EXE_MODE_DEFAULT));}return selector.Default(tune_params(1, 2, 4, 2, 1, 1, 1, EXE_MODE_DEFAULT));@@ -518,16 +539,18 @@ FullyConnected_bf_tiled::GetAutoTuneParams(const fully_connected_params& params,if (preferred_kernel_type != KernelType::DEFAULT) {if (params.is_shape_agnostic && !should_dynamic_quantize(params)) {selector.Case(tune_params(16, 2, 2, 4, forced_outer_ofm, 1, 1, EXE_MODE_DEFAULT, KernelType::SLM))- .Case(tune_params(16, 2, 1, 4, forced_outer_ofm, 1, 1, EXE_MODE_DEFAULT, KernelType::SLM));+ .Case(tune_params(16, 2, 1, 4, forced_outer_ofm, 1, 1, EXE_MODE_DEFAULT, KernelType::SLM));}selector.Case(tune_params(8, 2, 2, 4, forced_outer_ofm, 1, 1, EXE_MODE_DEFAULT, KernelType::SLM))- .Case(tune_params(8, 2, 1, 4, forced_outer_ofm, 1, 1, EXE_MODE_DEFAULT, KernelType::SLM));+ .Case(tune_params(8, 2, 1, 4, forced_outer_ofm, 1, 1, EXE_MODE_DEFAULT, KernelType::SLM));}- if (params.weights.GetLayout() == WeightsLayout::os_iyx_osv16)+ if (params.weights.GetLayout() == WeightsLayout::os_iyx_osv16) {return selector.Default(tune_params(8, 1, 1, 4, forced_outer_ofm, 1, 1, EXE_MODE_DEFAULT));- if (params.weights.GetLayout() == WeightsLayout::os_is_yx_osv64_isv2)+ }+ if (params.weights.GetLayout() == WeightsLayout::os_is_yx_osv64_isv2) {return selector.Default(tune_params(8, 4, 1, 2, forced_outer_ofm, 1, 1, EXE_MODE_DEFAULT));+ }return selector.Default(tune_params(8, 2, 1, 4, forced_outer_ofm, 1, 1, EXE_MODE_DEFAULT));}} else if (params.compressed && params.engineInfo.supports_immad) {@@ -538,53 +561,59 @@ FullyConnected_bf_tiled::GetAutoTuneParams(const fully_connected_params& params,// generation (extended TILE_K parameter) for both FP16 and FP32 data typesif (dtype == Datatype::F16) {// tune_params(tile_b, tile_ofm, tile_ifm, tile_k, outer_ofm, dispatch_bsv, dispatch_fsv, exec_options)- if (params.engineInfo.supports_immad)+ if (params.engineInfo.supports_immad) {selector.Case(tune_params(8, 1, 1, 4, 1, 1, 1, EXE_MODE_AGE_BASED));- else- selector.Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 2, 1, 1, 1, EXE_MODE_AGE_BASED));+ } else {+ selector.Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 2, 1, 1, 1, EXE_MODE_AGE_BASED));+ }} else if (dtype == Datatype::F32) {// tune_params(tile_b, tile_ofm, tile_ifm, tile_k, outer_ofm, dispatch_bsv, dispatch_fsv, exec_options)- if (params.engineInfo.supports_immad)+ if (params.engineInfo.supports_immad) {selector.Case(tune_params(8, 1, 1, 4, 1, 1, 1, EXE_MODE_AGE_BASED));- else- selector.Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 1, 1, 1, 1, EXE_MODE_AGE_BASED));+ } else {+ selector.Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 1, 1, 1, 1, EXE_MODE_AGE_BASED));+ }}} else {if (dtype == Datatype::F16) {// tune_params(tile_b, tile_ofm, tile_ifm, tile_k, outer_ofm, dispatch_bsv, dispatch_fsv, exec_options)- selector.Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 2, 1, 16, 2, EXE_MODE_AGE_BASED))- .Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 2, 1, 16, 1, EXE_MODE_AGE_BASED))- .Case(tune_params(16, std::min(max_tile_ofm, 2u), 1, 2, 1, 4, 2, EXE_MODE_AGE_BASED))- .Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 2, 1, 8, 1, EXE_MODE_AGE_BASED))- .Case(tune_params(16, std::min(max_tile_ofm, 2u), 1, 2, 1, 2, 2, EXE_MODE_AGE_BASED))- .Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 2, 1, 4, 1, EXE_MODE_AGE_BASED))- .Case(tune_params(16, std::min(max_tile_ofm, 2u), 1, 2, 1, 1, 1, EXE_MODE_AGE_BASED))- .Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 2, 1, 1, 1, EXE_MODE_AGE_BASED));+ selector.Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 2, 1, 16, 2, EXE_MODE_AGE_BASED))+ .Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 2, 1, 16, 1, EXE_MODE_AGE_BASED))+ .Case(tune_params(16, std::min(max_tile_ofm, 2u), 1, 2, 1, 4, 2, EXE_MODE_AGE_BASED))+ .Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 2, 1, 8, 1, EXE_MODE_AGE_BASED))+ .Case(tune_params(16, std::min(max_tile_ofm, 2u), 1, 2, 1, 2, 2, EXE_MODE_AGE_BASED))+ .Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 2, 1, 4, 1, EXE_MODE_AGE_BASED))+ .Case(tune_params(16, std::min(max_tile_ofm, 2u), 1, 2, 1, 1, 1, EXE_MODE_AGE_BASED))+ .Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 2, 1, 1, 1, EXE_MODE_AGE_BASED));} else if (dtype == Datatype::F32) {// tune_params(tile_b, tile_ofm, tile_ifm, tile_k, outer_ofm, dispatch_bsv, dispatch_fsv, exec_options)- selector.Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 1, 1, 16, 2, EXE_MODE_AGE_BASED))- .Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 1, 1, 16, 1, EXE_MODE_AGE_BASED))- .Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 1, 1, 8, 1, EXE_MODE_AGE_BASED))- .Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 1, 1, 4, 1, EXE_MODE_AGE_BASED))- .Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 1, 1, 2, 1, EXE_MODE_AGE_BASED))- .Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 1, 1, 1, 1, EXE_MODE_AGE_BASED));+ selector.Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 1, 1, 16, 2, EXE_MODE_AGE_BASED))+ .Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 1, 1, 16, 1, EXE_MODE_AGE_BASED))+ .Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 1, 1, 8, 1, EXE_MODE_AGE_BASED))+ .Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 1, 1, 4, 1, EXE_MODE_AGE_BASED))+ .Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 1, 1, 2, 1, EXE_MODE_AGE_BASED))+ .Case(tune_params(8, std::min(max_tile_ofm, 2u), 1, 1, 1, 1, 1, EXE_MODE_AGE_BASED));}- if (params.compressed && batch == 1)- selector.Case(tune_params(1, std::min(max_tile_ofm, 2u), 4, 2, 1, 1, 1, EXE_MODE_AGE_BASED));+ if (params.compressed && batch == 1) {+ selector.Case(tune_params(1, std::min(max_tile_ofm, 2u), 4, 2, 1, 1, 1, EXE_MODE_AGE_BASED));+ }selector.Case([&](const fully_connected_params&) -> tune_params {tune_params result(8, std::min(max_tile_ofm, 2u), 1, 2, 1, 1, 1, EXE_MODE_DEFAULT);- while (batch % result.tile_b != 0)+ while (batch % result.tile_b != 0) {result.tile_b--;+ }result.dispatch_bsv = 16;- while (batch % (result.tile_b * result.dispatch_bsv) != 0)+ while (batch % (result.tile_b * result.dispatch_bsv) != 0) {result.dispatch_bsv--;+ }- if (result.tile_b >= 8)+ if (result.tile_b >= 8) {result.exec_options = EXE_MODE_AGE_BASED;+ }return result;});@@ -593,32 +622,32 @@ FullyConnected_bf_tiled::GetAutoTuneParams(const fully_connected_params& params,return selector.Default(tune_params(1, 1, 1, 1, 1, 1, 1, EXE_MODE_DEFAULT));}-FullyConnected_bf_tiled::DispatchData-FullyConnected_bf_tiled::SetDefault(const fully_connected_params& params, int autoTuneIndex, int kernel_number) const {+FullyConnected_bf_tiled::DispatchData FullyConnected_bf_tiled::SetDefault(const fully_connected_params& params, int autoTuneIndex, int kernel_number) const {auto dispatchData = Parent::SetDefault(params);// Use KernelType::ANY by default, in case of shape-agnostic kernel, choose kernel type based// on `kernel_number` (this implementation allows to have 2 shape-agnostic kernels at the same time// for small batches and large batches and change them during inference on the fly)auto kernel_type = KernelType::ANY;- if (params.is_shape_agnostic)+ if (params.is_shape_agnostic) {kernel_type = kernel_number == 0 ? KernelType::DEFAULT : KernelType::SLM;+ }auto tparams = GetAutoTuneParams(params, kernel_type, autoTuneIndex);std::pair<size_t, size_t> threads;- if (is_swiglu_fused(params))+ if (is_swiglu_fused(params)) {threads = get_output_aligned_bf_size(params, true, tparams.tile_b, tparams.tile_ofm * simd);- else+ } else {threads = get_output_aligned_bf_size(params, true, tparams.tile_b, tparams.tile_ofm * tparams.outer_ofm * simd);+ }auto batch_threads = threads.first;auto feature_threads = threads.second;- const size_t aligned_batch = Align(batch_threads, lws_batches); // Each WG calculates 8x8 batches (TILE_B x LWS[2] size)+ const size_t aligned_batch = Align(batch_threads, lws_batches); // Each WG calculates 8x8 batches (TILE_B x LWS[2] size)const bool can_use_slm = tparams.kernel_type == KernelType::SLM;- dispatchData.gws[0] = can_use_slm ? feature_threads * simd- : feature_threads * batch_threads * simd;+ dispatchData.gws[0] = can_use_slm ? feature_threads * simd : feature_threads * batch_threads * simd;dispatchData.gws[1] = 1;dispatchData.gws[2] = can_use_slm ? aligned_batch : 1;@@ -644,10 +673,11 @@ KernelsPriority FullyConnected_bf_tiled::GetKernelsPriority(const Params& paramssize_t output_b = get_output_aligned_bf_size(fc_params, false).first;float estimated_time = FORCE_PRIORITY_5;- if (output_b > 1 && fc_params.inputs[0].GetDType() == Datatype::F32)+ if (output_b > 1 && fc_params.inputs[0].GetDType() == Datatype::F32) {estimated_time = FORCE_PRIORITY_3;- else if (output_b > 1 && fc_params.inputs[0].GetDType() == Datatype::F16)+ } else if (output_b > 1 && fc_params.inputs[0].GetDType() == Datatype::F16) {estimated_time = FORCE_PRIORITY_4;+ }return estimated_time;}@@ -672,8 +702,9 @@ JitConstants FullyConnected_bf_tiled::GetJitConstants(const fully_connected_parajit.Merge(make_sub_byte_packed_type_jit_constant("INT4_PACKED_TYPE", weights_dt, tile_k_ofm));const size_t scale_group_size = get_scale_group_size(params);// Do not use SCALE_POST_OP for SLM kernel, since it demonstrates worse performance- if (scale_group_size % simd == 0 && !dispatchData.use_slm)+ if (scale_group_size % simd == 0 && !dispatchData.use_slm) {add_decompress_scale_post_op = true;+ }}if (params.weights.GetLayout() == WeightsLayout::os_is_yx_osv32_isv2) {jit.AddConstant(MakeJitConstant("W_IDX", "fi * TILE_K + kii"));@@ -702,13 +733,13 @@ JitConstants FullyConnected_bf_tiled::GetJitConstants(const fully_connected_paraOPENVINO_ASSERT(is_weight_dyn_quantizable(params), "[GPU] Unsupported FC weights type for SLM kernel configuration");auto lws_batches = dispatchData.lws[2];- auto total_weights_elements = simd * dispatchData.tile_n * simd * dispatchData.tile_mk; // SIMD * TILE_OFM * SIMD * TILE_IFM+ auto total_weights_elements = simd * dispatchData.tile_n * simd * dispatchData.tile_mk; // SIMD * TILE_OFM * SIMD * TILE_IFMauto weights_elements_per_sg = total_weights_elements / lws_batches;auto weights_elements_per_wi = weights_elements_per_sg / simd;- auto weights_elements_per_wi_8bit = weights_elements_per_wi / 2; // number of pairs of int4 weights per WI+ auto weights_elements_per_wi_8bit = weights_elements_per_wi / 2; // number of pairs of int4 weights per WIauto block_read_size = 0;- auto preferred_block_sizes = { 8, 4, 2 };+ auto preferred_block_sizes = {8, 4, 2};for (auto block_size : preferred_block_sizes) {if (weights_elements_per_wi_8bit % block_size == 0) {@@ -753,11 +784,12 @@ JitConstants FullyConnected_bf_tiled::GetJitConstants(const fully_connected_parajit.AddConstant(MakeJitConstant("DQ_DECOMPRESSION_SCALE_POST_OP", 1));jit.AddConstant(MakeJitConstant("QUANTIZE_GROUP_SIZE", quantize_grp_size));- jit.AddConstant(MakeJitConstant("PER_TOKEN_SIZE_DYN_QUANTIZE",- is_per_token_dynamic_quantize(params) && quantize_grp_size == get_input_bf_size(params).second));+ jit.AddConstant(+ MakeJitConstant("PER_TOKEN_SIZE_DYN_QUANTIZE", is_per_token_dynamic_quantize(params) && quantize_grp_size == get_input_bf_size(params).second));} else {- if (add_decompress_scale_post_op)+ if (add_decompress_scale_post_op) {jit.AddConstant(MakeJitConstant("DECOMPRESSION_SCALE_POST_OP", 1));+ }jit.AddConstant(MakeJitConstant("DYNAMIC_QUANTIZE", 0));jit.AddConstant(MakeJitConstant("QUANTIZE_GROUP_SIZE", min_quantize_grp_size));}@@ -768,7 +800,7 @@ JitConstants FullyConnected_bf_tiled::GetJitConstants(const fully_connected_parajit.AddConstant(MakeJitConstant("SIMD", simd));jit.AddConstant(MakeJitConstant("TILE_B", dispatchData.tile_m));- jit.AddConstant(MakeJitConstant("HALF_TILE_B", dispatchData.tile_m/2));+ jit.AddConstant(MakeJitConstant("HALF_TILE_B", dispatchData.tile_m / 2));jit.AddConstant(MakeJitConstant("TILE_OFM", dispatchData.tile_n));jit.AddConstant(MakeJitConstant("TILE_IFM", dispatchData.tile_mk));jit.AddConstant(MakeJitConstant("TILE_K", dispatchData.tile_nk));@@ -786,8 +818,9 @@ JitConstants FullyConnected_bf_tiled::GetJitConstants(const fully_connected_para}auto max_tile_b_size = dispatchData.tile_m;- if (params.compressed && params.is_shape_agnostic && is_weight_dyn_quantizable(params))+ if (params.compressed && params.is_shape_agnostic && is_weight_dyn_quantizable(params)) {max_tile_b_size = std::max(max_tile_b_size, (uint32_t)8);+ }jit.Merge(MakeConstantLoopUnrollJitConstants(max_tile_b_size));@@ -825,26 +858,18 @@ JitConstants FullyConnected_bf_tiled::GetJitConstants(const fully_connected_para}if (!params.fused_ops.empty() && !is_swiglu_fused(params)) {- std::vector<std::string> idx_order_scalar = { "(out_b + bi)", "(out_f + sglid)", "0", "0" };- std::vector<std::string> idx_order_vec = { "(out_b + bi)", "(out_f + sglid + fi * SIMD)", "0", "0" };+ std::vector<std::string> idx_order_scalar = {"(out_b + bi)", "(out_f + sglid)", "0", "0"};+ std::vector<std::string> idx_order_vec = {"(out_b + bi)", "(out_f + sglid + fi * SIMD)", "0", "0"};if (params.outputs[0].GetLayout() == DataLayout::bfyx) {- idx_order_scalar = { "(out_b + bi) / OUTPUT_FEATURE_NUM", "(out_b + bi) % OUTPUT_FEATURE_NUM", "(out_f + sglid)", "0" };- idx_order_vec = { "(out_b + bi) / OUTPUT_FEATURE_NUM", "(out_b + bi) % OUTPUT_FEATURE_NUM", "(out_f + sglid + fi * SIMD)", "0" };+ idx_order_scalar = {"(out_b + bi) / OUTPUT_FEATURE_NUM", "(out_b + bi) % OUTPUT_FEATURE_NUM", "(out_f + sglid)", "0"};+ idx_order_vec = {"(out_b + bi) / OUTPUT_FEATURE_NUM", "(out_b + bi) % OUTPUT_FEATURE_NUM", "(out_f + sglid + fi * SIMD)", "0"};}// Simplify fused ops configuration to prevent mixed layout exception in jitter// for common cases with bfyx -> bf layouts and eltwise fusing (such scenarios currently don't work for vectors)- FusedOpsConfiguration conf_scalar = { "_SCALAR",- idx_order_scalar,- "activated[bi]",- activation_dt,- 1 };- FusedOpsConfiguration conf_vec = { "_VEC",- idx_order_vec,- "activated[bi][fi]",- activation_dt,- 1 };- jit.Merge(MakeFusedOpsJitConstants(params, { conf_scalar, conf_vec }));+ FusedOpsConfiguration conf_scalar = {"_SCALAR", idx_order_scalar, "activated[bi]", activation_dt, 1};+ FusedOpsConfiguration conf_vec = {"_VEC", idx_order_vec, "activated[bi][fi]", activation_dt, 1};+ jit.Merge(MakeFusedOpsJitConstants(params, {conf_scalar, conf_vec}));}return jit;@@ -865,21 +890,18 @@ void FullyConnected_bf_tiled::SetDispatchDataFunc(KernelData& kd, const Dispatch// We can use SLM version if `output_batch + default_alignment > min_slm_size(256)`// because memory and batch are aligned (whether 16 or 64 elements)bool use_slm = (idx.slm >= 0) && (output_batch + default_alignment > min_slm_size);- bool use_dyn_b = !use_slm && (idx.dyn_b >= 0) && (idx.quantize < 0)- && should_use_dyn_b_kernel(output_batch,- prim_params.weights.IFM().v,- prim_params.weights.OFM().v,- is_swiglu_fused(prim_params));+ bool use_dyn_b = !use_slm && (idx.dyn_b >= 0) && (idx.quantize < 0) &&+ should_use_dyn_b_kernel(output_batch, prim_params.weights.IFM().v, prim_params.weights.OFM().v, is_swiglu_fused(prim_params));int execute = use_slm ? idx.slm : (use_dyn_b ? idx.dyn_b : idx.default_fc);// Skip all FC kernels except the executing oneint32_t total_kernels = static_cast<int32_t>(kd.kernels.size());- for (int32_t i = idx.default_fc; i < total_kernels; i++)+ for (int32_t i = idx.default_fc; i < total_kernels; i++) {kd.kernels[i].skip_execution = (i != execute);+ }- GPU_DEBUG_TRACE_DETAIL << "FC bf tiled: " << (use_slm ? "SLM" : (use_dyn_b ? "DynB" : "Default"))- << " shape-agnostic kernel version "+ GPU_DEBUG_TRACE_DETAIL << "FC bf tiled: " << (use_slm ? "SLM" : (use_dyn_b ? "DynB" : "Default")) << " shape-agnostic kernel version "<< "will be used for batch size = " << output_batch << "\n";// Configure workgroups for the selected kernel@@ -888,14 +910,11 @@ void FullyConnected_bf_tiled::SetDispatchDataFunc(KernelData& kd, const Dispatchsize_t tile_b = FullyConnected_bf_tiled_dyn_b::SelectTileB(effective_batch);FullyConnected_bf_tiled_dyn_b dyn_b_impl;auto dyn_b_tparams = dyn_b_impl.GetTuneParams(prim_params);- auto threads = get_output_aligned_bf_size(prim_params, true,- static_cast<uint32_t>(tile_b),- static_cast<int32_t>(dyn_b_tparams.tile_ofm * simd));+ auto threads = get_output_aligned_bf_size(prim_params, true, static_cast<uint32_t>(tile_b), static_cast<int32_t>(dyn_b_tparams.tile_ofm * simd));kd.kernels[execute].params.workGroups.global = {threads.second * threads.first * simd, 1, 1};kd.kernels[execute].params.workGroups.local = {simd, 1, 1};} else {- auto dispatchData = SetDefault(prim_params, -1,- use_slm ? static_cast<int>(KernelType::SLM) : static_cast<int>(KernelType::DEFAULT));+ auto dispatchData = SetDefault(prim_params, -1, use_slm ? static_cast<int>(KernelType::SLM) : static_cast<int>(KernelType::DEFAULT));kd.kernels[execute].params.workGroups.global = dispatchData.gws;kd.kernels[execute].params.workGroups.local = dispatchData.lws;}@@ -903,12 +922,11 @@ void FullyConnected_bf_tiled::SetDispatchDataFunc(KernelData& kd, const Dispatchkd.kernels[execute].skip_execution = KernelData::SkipKernelExecution(prim_params);const auto& input = prim_params.inputs[0];- if (prim_params.outputs[0].GetLayout() == DataLayout::bfyx)- OPENVINO_ASSERT(input.X().pad.Total() == 0 && input.Y().pad.Total() == 0,- "[GPU] Invalid padding in spatial axes observed in FC bf tiled.");- else- OPENVINO_ASSERT(input.Feature().pad.Total(true) == 0,- "[GPU] Invalid padding in f axis observed in FC bf tiled.");+ if (prim_params.outputs[0].GetLayout() == DataLayout::bfyx) {+ OPENVINO_ASSERT(input.X().pad.Total() == 0 && input.Y().pad.Total() == 0, "[GPU] Invalid padding in spatial axes observed in FC bf tiled.");+ } else {+ OPENVINO_ASSERT(input.Feature().pad.Total(true) == 0, "[GPU] Invalid padding in f axis observed in FC bf tiled.");+ }// Pre-quantizing kernel was generated. Update the kernel and intermediate buffers or disable it.if (idx.quantize >= 0) {@@ -922,8 +940,7 @@ void FullyConnected_bf_tiled::SetDispatchDataFunc(KernelData& kd, const Dispatch// half type of de_quan_scale and activation sum for each quantized groupsize_t quan_var_size = (input_size / quantize_grp_size) * 2 * 2;- if (kd.internalBuffers[0].byte_count < input_size ||- kd.internalBuffers[1].byte_count < quan_var_size) {+ if (kd.internalBuffers[0].byte_count < input_size || kd.internalBuffers[1].byte_count < quan_var_size) {kd.internalBuffers.clear();// quantized input is char typekd.internalBuffers.push_back(input_size);@@ -955,7 +972,7 @@ void FullyConnected_bf_tiled::GetUpdateDispatchDataFunc(KernelData& kd) const {}DispatchIndices idx;- idx.quantize = kd.internalBuffers.empty() ? -1 : 0;+ idx.quantize = kd.internalBuffers.empty() ? -1 : 0;idx.default_fc = idx.quantize + 1;int32_t total = static_cast<int32_t>(kd.kernels.size());@@ -981,8 +998,9 @@ void FullyConnected_bf_tiled::GetUpdateDispatchDataFunc(KernelData& kd) const {}if (!last_has_internal_buffer) {idx.dyn_b = last;- if (last > idx.default_fc + 1)+ if (last > idx.default_fc + 1) {idx.slm = idx.default_fc + 1;+ }} else {idx.slm = idx.default_fc + 1;}@@ -991,21 +1009,22 @@ void FullyConnected_bf_tiled::GetUpdateDispatchDataFunc(KernelData& kd) const {// and neither do other kernels, so we cannot distinguish — but dyn_b is always last// and is only added when SLM is also present in this path)idx.slm = idx.default_fc + 1;- if (total > idx.default_fc + 2)+ if (total > idx.default_fc + 2) {idx.dyn_b = total - 1;+ }}}SetDispatchDataFunc(kd, idx);}-KernelsData FullyConnected_bf_tiled::GetTunedKernelsDataByIndex(const Params ¶ms,- const int autoTuneIndex) const {+KernelsData FullyConnected_bf_tiled::GetTunedKernelsDataByIndex(const Params& params, const int autoTuneIndex) const {const auto& fc_params = static_cast<const fully_connected_params&>(params);- if (autoTuneIndex >= 0 && autoTuneIndex < static_cast<int>(auto_tune_params.size())- && !TuneParamsSelector::VerifyTuneParams(fc_params, auto_tune_params[autoTuneIndex]))+ if (autoTuneIndex >= 0 && autoTuneIndex < static_cast<int>(auto_tune_params.size()) &&+ !TuneParamsSelector::VerifyTuneParams(fc_params, auto_tune_params[autoTuneIndex])) {return {};+ }tune_params tparams = GetAutoTuneParams(fc_params, KernelType::ANY, autoTuneIndex);auto output_f = get_output_aligned_bf_size(fc_params, false).second;@@ -1013,22 +1032,23 @@ KernelsData FullyConnected_bf_tiled::GetTunedKernelsDataByIndex(const Params &paWeightsLayout weights_layout = WeightsLayout::os_iyx_osv16;if (is_swiglu_fused(fc_params)) {weights_layout = WeightsLayout::os_is_yx_osv32_isv2;- } else if (fc_params.compressed && fc_params.inputs[0].GetDType() == Datatype::F16- && (fc_params.weights.GetLayout() == WeightsLayout::oiyx || fc_params.weights.GetLayout() == WeightsLayout::os_is_yx_osv64_isv2)- && (fc_params.weights.GetDType() == WeightsType::INT4 || fc_params.weights.GetDType() == WeightsType::UINT4)- && is_weight_horizontal(fc_params, output_f)) {+ } else if (fc_params.compressed && fc_params.inputs[0].GetDType() == Datatype::F16 &&+ (fc_params.weights.GetLayout() == WeightsLayout::oiyx || fc_params.weights.GetLayout() == WeightsLayout::os_is_yx_osv64_isv2) &&+ (fc_params.weights.GetDType() == WeightsType::INT4 || fc_params.weights.GetDType() == WeightsType::UINT4) &&+ is_weight_horizontal(fc_params, output_f)) {// Large N + small K case (horizontal weight) to use [osv64_isv2] + TILE_OFM 4 for batch 1weights_layout = WeightsLayout::os_is_yx_osv64_isv2;- } else if (fc_params.compressed && fc_params.inputs[0].GetDType() == Datatype::F16- && (fc_params.weights.GetDType() == WeightsType::INT4 || fc_params.weights.GetDType() == WeightsType::UINT4)- && (fc_params.weights.GetLayout() == WeightsLayout::oiyx || fc_params.weights.GetLayout() == WeightsLayout::os_iyx_osv16)- && is_weight_vertical(fc_params, output_f)) {+ } else if (fc_params.compressed && fc_params.inputs[0].GetDType() == Datatype::F16 &&+ (fc_params.weights.GetDType() == WeightsType::INT4 || fc_params.weights.GetDType() == WeightsType::UINT4) &&+ (fc_params.weights.GetLayout() == WeightsLayout::oiyx || fc_params.weights.GetLayout() == WeightsLayout::os_iyx_osv16) &&+ is_weight_vertical(fc_params, output_f)) {// Large K + Small N case (vertical weight) to use [osv16 + TILE_K 4] + TILE_OFM 1 for batch 1weights_layout = WeightsLayout::os_iyx_osv16;- } else if (fc_params.compressed && fc_params.inputs[0].GetDType() == Datatype::F16- // ioyx => os_is_yx_osv32_isv2 is not supported yet- && (fc_params.weights.GetLayout() == WeightsLayout::oiyx || fc_params.weights.GetLayout() == WeightsLayout::os_is_yx_osv32_isv2)- && (fc_params.weights.GetDType() == WeightsType::INT4 || fc_params.weights.GetDType() == WeightsType::UINT4)) {+ } else if (fc_params.compressed &&+ fc_params.inputs[0].GetDType() == Datatype::F16+ // ioyx => os_is_yx_osv32_isv2 is not supported yet+ && (fc_params.weights.GetLayout() == WeightsLayout::oiyx || fc_params.weights.GetLayout() == WeightsLayout::os_is_yx_osv32_isv2) &&+ (fc_params.weights.GetDType() == WeightsType::INT4 || fc_params.weights.GetDType() == WeightsType::UINT4)) {weights_layout = WeightsLayout::os_is_yx_osv32_isv2;} else if (tparams.tile_ofm * simd == 32) {weights_layout = WeightsLayout::os_iyx_osv32;@@ -1043,23 +1063,15 @@ KernelsData FullyConnected_bf_tiled::GetTunedKernelsDataByIndex(const Params &pa// 2nd kernel : fully connected kernel with KernelType::DEFAULT. Quantized inputs and scale values could be used.// 3rd kernel : (optional) fully connected shape_agnostic kernel with KernelType::SLM. Quantized inputs and scale values would be used.// 4th kernel : (optional) FC with dyn_b dispatch (original F16 input, no dynamic quantization)- auto [multi_kd, multi_idx] = GetMultiKernelsData(params,- fc_params.inputs[0].GetLayout(),- weights_layout,- tparams.exec_options,- autoTuneIndex);+ auto [multi_kd, multi_idx] = GetMultiKernelsData(params, fc_params.inputs[0].GetLayout(), weights_layout, tparams.exec_options, autoTuneIndex);kernels_data = std::move(multi_kd);OPENVINO_ASSERT(!kernels_data.empty() && !kernels_data[0].kernels.empty(), "[GPU] Error to create multi kernel for dynamic quantizing.");- if (params.is_shape_agnostic)+ if (params.is_shape_agnostic) {SetDispatchDataFunc(kernels_data[0], multi_idx);+ }} else {- kernels_data = GetCommonKernelsData(params,- fc_params.inputs[0].GetLayout(),- weights_layout,- tparams.exec_options,- autoTuneIndex,- 0);+ kernels_data = GetCommonKernelsData(params, fc_params.inputs[0].GetLayout(), weights_layout, tparams.exec_options, autoTuneIndex, 0);if (params.is_shape_agnostic) {DispatchIndices idx;@@ -1068,12 +1080,7 @@ KernelsData FullyConnected_bf_tiled::GetTunedKernelsDataByIndex(const Params &pa// Try to add SLM kernel for large batchesauto slm_tparams = GetAutoTuneParams(fc_params, KernelType::SLM, autoTuneIndex);if (slm_tparams.kernel_type == KernelType::SLM) {- auto slm_kernel = GetCommonKernelsData(params,- fc_params.inputs[0].GetLayout(),- weights_layout,- slm_tparams.exec_options,- autoTuneIndex,- 1);+ auto slm_kernel = GetCommonKernelsData(params, fc_params.inputs[0].GetLayout(), weights_layout, slm_tparams.exec_options, autoTuneIndex, 1);if (!slm_kernel.empty() && !slm_kernel[0].kernels.empty()) {kernels_data[0].kernels.push_back(slm_kernel[0].kernels.back());idx.slm = static_cast<int32_t>(kernels_data[0].kernels.size()) - 1;@@ -1095,8 +1102,9 @@ KernelsData FullyConnected_bf_tiled::GetTunedKernelsDataByIndex(const Params &pa}// Update default update_dispatch_data_func function- if (idx.slm >= 0 || idx.dyn_b >= 0)+ if (idx.slm >= 0 || idx.dyn_b >= 0) {SetDispatchDataFunc(kernels_data[0], idx);+ }}}@@ -1129,13 +1137,11 @@ KernelsData FullyConnected_bf_tiled::GetKernelsData(const Params& params) constreturn res;}--std::pair<KernelsData, FullyConnected_bf_tiled::DispatchIndices>-FullyConnected_bf_tiled::GetMultiKernelsData(const Params ¶ms,- DataLayout dl,- WeightsLayout wl,- const std::string exeMode,- int autoTuneIndex) const {+std::pair<KernelsData, FullyConnected_bf_tiled::DispatchIndices> FullyConnected_bf_tiled::GetMultiKernelsData(const Params& params,+ DataLayout dl,+ WeightsLayout wl,+ const std::string exeMode,+ int autoTuneIndex) const {if (!Validate(params)) {return {KernelsData(), {}};}@@ -1160,10 +1166,7 @@ FullyConnected_bf_tiled::GetMultiKernelsData(const Params ¶ms,kd.reorderInput = true;}- bool succeed = UpdateWeightsParams(new_params,- wl,- kd.weightsReorderParams,- GetSupportedKey());+ bool succeed = UpdateWeightsParams(new_params, wl, kd.weightsReorderParams, GetSupportedKey());if (!succeed) {return {{}, {}};}@@ -1171,8 +1174,9 @@ FullyConnected_bf_tiled::GetMultiKernelsData(const Params ¶ms,int inputs_count = 1;if (new_params.compressed) {inputs_count++;- if (new_params.has_decompression_zp && !new_params.scalar_zp)+ if (new_params.has_decompression_zp && !new_params.scalar_zp) {inputs_count++;+ }}// Generate dispatch data for KernelType::DEFAULT@@ -1185,8 +1189,9 @@ FullyConnected_bf_tiled::GetMultiKernelsData(const Params ¶ms,auto& quan_kernel = kd.kernels[0];DispatchData dyn_quan_dispatch = dispatchData;auto input_size = std::max(fc_params.inputs[0].PhysicalSize(), get_input_bf_size(fc_params).second);- if (!params.is_shape_agnostic)+ if (!params.is_shape_agnostic) {input_size = std::max(input_size, Align(get_input_bf_size(fc_params).first, lws_batches) * get_input_bf_size(fc_params).second);+ }dyn_quan_dispatch.gws = {(input_size / quantize_grp_size), 1, 1};dyn_quan_dispatch.lws = {1, 1, 1};@@ -1201,18 +1206,18 @@ FullyConnected_bf_tiled::GetMultiKernelsData(const Params ¶ms,auto quan_jit = CreateJit(kernelName, quan_cldnn_jit, quan_entry_point);FillCLKernelData(quan_kernel,- dyn_quan_dispatch,- params.engineInfo,- kernelName,- quan_jit,- quan_entry_point,- exeMode, // No exec mode- false,- false,- 1, // Only INPUT_0 is used for quantizing- 0, // No fused ops- 0, // No output- fc_params.is_shape_agnostic);+ dyn_quan_dispatch,+ params.engineInfo,+ kernelName,+ quan_jit,+ quan_entry_point,+ exeMode, // No exec mode+ false,+ false,+ 1, // Only INPUT_0 is used for quantizing+ 0, // No fused ops+ 0, // No output+ fc_params.is_shape_agnostic);quan_kernel.params.arguments.clear(); // Clear original output argumentquan_kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0});@@ -1239,18 +1244,18 @@ FullyConnected_bf_tiled::GetMultiKernelsData(const Params ¶ms,fc_kernel.skip_execution = false;FillCLKernelData(fc_kernel,- dispatchData,- params.engineInfo,- kernelName,- jit,- entry_point,- exeMode,- true,- !fc_params.bias.empty(),- inputs_count,- GetFusedPrimitiveInputsCount(params),- 1,- fc_params.is_shape_agnostic);+ dispatchData,+ params.engineInfo,+ kernelName,+ jit,+ entry_point,+ exeMode,+ true,+ !fc_params.bias.empty(),+ inputs_count,+ GetFusedPrimitiveInputsCount(params),+ 1,+ fc_params.is_shape_agnostic);fc_kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});fc_kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1});@@ -1275,18 +1280,18 @@ FullyConnected_bf_tiled::GetMultiKernelsData(const Params ¶ms,sa_kernel.skip_execution = false;FillCLKernelData(sa_kernel,- slm_Data,- params.engineInfo,- kernelName,- jit,- entry_point,- slm_params.exec_options,- true,- !fc_params.bias.empty(),- inputs_count,- GetFusedPrimitiveInputsCount(params),- 1,- fc_params.is_shape_agnostic);+ slm_Data,+ params.engineInfo,+ kernelName,+ jit,+ entry_point,+ slm_params.exec_options,+ true,+ !fc_params.bias.empty(),+ inputs_count,+ GetFusedPrimitiveInputsCount(params),+ 1,+ fc_params.is_shape_agnostic);sa_kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});sa_kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1});@@ -1311,18 +1316,18 @@ FullyConnected_bf_tiled::GetMultiKernelsData(const Params ¶ms,dyn_b_kernel.skip_execution = false;FillCLKernelData(dyn_b_kernel,- dyn_b_dispatch,- params.engineInfo,- "fully_connected_gpu_bf_tiled_dyn_b",- dyn_b_jit,- dyn_b_entry_point,- EXE_MODE_DEFAULT,- true,- !fc_params.bias.empty(),- inputs_count,- GetFusedPrimitiveInputsCount(params),- 1,- fc_params.is_shape_agnostic);+ dyn_b_dispatch,+ params.engineInfo,+ "fully_connected_gpu_bf_tiled_dyn_b",+ dyn_b_jit,+ dyn_b_entry_point,+ EXE_MODE_DEFAULT,+ true,+ !fc_params.bias.empty(),+ inputs_count,+ GetFusedPrimitiveInputsCount(params),+ 1,+ fc_params.is_shape_agnostic);// dyn_b reads original F16 input (no INTERNAL_BUFFER args)}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_tiled_dyn_b.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_tiled_dyn_b.cppindex 843d455484a..d3169da3461 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_tiled_dyn_b.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bf_tiled_dyn_b.cpp@@ -3,10 +3,12 @@//#include "fully_connected_kernel_bf_tiled_dyn_b.h"-#include "kernel_selector_utils.h"-#include <vector>+#include <functional>+#include <vector>+#include "common_types.h"+#include "kernel_selector_utils.h"static constexpr size_t simd = 16;@@ -14,8 +16,7 @@ namespace kernel_selector {using namespace fc_kernel_bf_tiled_utils;-FullyConnected_bf_tiled_dyn_b::FullyConnected_bf_tiled_dyn_b()- : FullyConnectedKernelBase("fully_connected_gpu_bf_tiled_dyn_b") {}+FullyConnected_bf_tiled_dyn_b::FullyConnected_bf_tiled_dyn_b() : FullyConnectedKernelBase("fully_connected_gpu_bf_tiled_dyn_b") {}ParamsKey FullyConnected_bf_tiled_dyn_b::GetSupportedKey() const {ParamsKey k;@@ -50,13 +51,15 @@ DeviceFeaturesKey FullyConnected_bf_tiled_dyn_b::get_required_device_features_kesize_t FullyConnected_bf_tiled_dyn_b::SelectTileB(size_t batch_size) {// For small batches, tile = batch (exact, no tail)- if (batch_size <= 8)+ if (batch_size <= 8) {return batch_size;+ }// Find largest exact divisor in [8..4] (no tail needed)for (size_t t = 8; t >= 4; --t) {- if (batch_size % t == 0)+ if (batch_size % t == 0) {return t;+ }}// No good exact divisor (primes, 2*prime, etc.):@@ -69,24 +72,30 @@ bool FullyConnected_bf_tiled_dyn_b::IsBeneficial(const fully_connected_params& pauto wt = weights.GetDType();// INT4 compressed, F16 input, shape_agnostic only- if (wt != WeightsType::UINT4 && wt != WeightsType::INT4)+ if (wt != WeightsType::UINT4 && wt != WeightsType::INT4) {return false;- if (!params.compressed)+ }+ if (!params.compressed) {return false;- if (params.inputs[0].GetDType() != Datatype::F16)+ }+ if (params.inputs[0].GetDType() != Datatype::F16) {return false;- if (!params.is_shape_agnostic)+ }+ if (!params.is_shape_agnostic) {return false;+ }// No SwiGLU support- if (is_swiglu_fused(params))+ if (is_swiglu_fused(params)) {return false;+ }// Only beneficial for imbalanced IFM/OFM with sufficient dimension sizeauto ifm = weights.IFM().v;auto ofm = weights.OFM().v;- if (std::min(ifm, ofm) < simd)+ if (std::min(ifm, ofm) < simd) {return false;+ }return 2 * ifm < ofm || ifm > 2 * ofm;}@@ -102,57 +111,68 @@ bool FullyConnected_bf_tiled_dyn_b::Validate(const Params& params) const {// Only INT4 compressed weightsauto wt = weights.GetDType();- if (wt != WeightsType::UINT4 && wt != WeightsType::INT4)+ if (wt != WeightsType::UINT4 && wt != WeightsType::INT4) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }- if (!fc_params.compressed)+ if (!fc_params.compressed) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }// F16 input only- if (input.GetDType() != Datatype::F16)+ if (input.GetDType() != Datatype::F16) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }// IFM must be known and even (for INT4 packing)if (input.is_dynamic()) {auto ifm_size = get_input_bf_size(fc_params).second;- if (ifm_size == 0)+ if (ifm_size == 0) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}- if (weights.IFM().v % 2 != 0)+ if (weights.IFM().v % 2 != 0) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }// Block reads: batch pitch must be even for F16- if (input.Batch().pitch % 2 != 0 && (input.Batch().v > 1 || fc_params.is_shape_agnostic))+ if (input.Batch().pitch % 2 != 0 && (input.Batch().v > 1 || fc_params.is_shape_agnostic)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }// For 3D: feature pitch must be even- if (output.GetLayout() == DataLayout::bfyx && input.Feature().pitch % 2 != 0- && (input.Feature().v > 1 || fc_params.is_shape_agnostic))+ if (output.GetLayout() == DataLayout::bfyx && input.Feature().pitch % 2 != 0 && (input.Feature().v > 1 || fc_params.is_shape_agnostic)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }// No padding on spatial dimensionsif (input.GetLayout() == DataLayout::bfyx) {- if (input.X().pad.Total() != 0 || input.Y().pad.Total() != 0)+ if (input.X().pad.Total() != 0 || input.Y().pad.Total() != 0) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}// No 4D outputif (output.GetLayout() == DataLayout::bfyx) {- if (input.X().v > 1)+ if (input.X().v > 1) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}// Reject dynamic quantization targets (let bf_tiled SLM handle those)- if (is_weight_dyn_quantizable(fc_params) && should_dynamic_quantize(fc_params))+ if (is_weight_dyn_quantizable(fc_params) && should_dynamic_quantize(fc_params)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }// This kernel is designed for dynamic batch dispatch only.// For static shapes, bf_tiled already selects optimal TILE_B at compile time.- if (!fc_params.is_shape_agnostic)+ if (!fc_params.is_shape_agnostic) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }// SwiGLU fused op is not supported (requires OUTER_OFM=2 / SWIGLU_LENGTH handling)- if (is_swiglu_fused(fc_params))+ if (is_swiglu_fused(fc_params)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }// Only beneficial when IFM and OFM are highly imbalanced with sufficient size.// For near-square shapes (IFM ≈ OFM), bf_tiled's dispatch is already efficient.@@ -160,29 +180,32 @@ bool FullyConnected_bf_tiled_dyn_b::Validate(const Params& params) const {{auto ifm = weights.IFM().v;auto ofm = weights.OFM().v;- if (std::min(ifm, ofm) < simd)+ if (std::min(ifm, ofm) < simd) {DO_NOT_USE_THIS_KERNEL(params.layerID);- if (2 * ifm >= ofm && ifm <= 2 * ofm)+ }+ if (2 * ifm >= ofm && ifm <= 2 * ofm) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}return true;}--FullyConnected_bf_tiled_dyn_b::tune_params-FullyConnected_bf_tiled_dyn_b::GetTuneParams(const fully_connected_params& params) const {+FullyConnected_bf_tiled_dyn_b::tune_params FullyConnected_bf_tiled_dyn_b::GetTuneParams(const fully_connected_params& params) const {// Same base config as static_b16 (optimized for INT4 on iGPU)- if (params.weights.GetLayout() == WeightsLayout::os_iyx_osv16)+ if (params.weights.GetLayout() == WeightsLayout::os_iyx_osv16) {return tune_params(1, 1, 4, 1, 1, EXE_MODE_DEFAULT);- if (params.weights.GetLayout() == WeightsLayout::os_is_yx_osv64_isv2)+ }+ if (params.weights.GetLayout() == WeightsLayout::os_is_yx_osv64_isv2) {return tune_params(2, 1, 2, 1, 1, EXE_MODE_DEFAULT);+ }// os_is_yx_osv32_isv2 (default)return tune_params(2, 1, 4, 1, 1, EXE_MODE_DEFAULT);}-FullyConnected_bf_tiled_dyn_b::DispatchData-FullyConnected_bf_tiled_dyn_b::SetDefault(const fully_connected_params& params, int autoTuneIndex, int kernel_number) const {+FullyConnected_bf_tiled_dyn_b::DispatchData FullyConnected_bf_tiled_dyn_b::SetDefault(const fully_connected_params& params,+ int autoTuneIndex,+ int kernel_number) const {auto dispatchData = Parent::SetDefault(params);auto tparams = GetTuneParams(params);@@ -192,9 +215,7 @@ FullyConnected_bf_tiled_dyn_b::SetDefault(const fully_connected_params& params,size_t batch = bf_size.first;size_t tile_b = (batch > 0) ? SelectTileB(batch) : default_tile_b;- auto threads = get_output_aligned_bf_size(params, true,- static_cast<uint32_t>(tile_b),- static_cast<int32_t>(tparams.tile_ofm * simd));+ auto threads = get_output_aligned_bf_size(params, true, static_cast<uint32_t>(tile_b), static_cast<int32_t>(tparams.tile_ofm * simd));auto batch_threads = threads.first;auto feature_threads = threads.second;@@ -235,8 +256,7 @@ KernelsPriority FullyConnected_bf_tiled_dyn_b::GetKernelsPriority(const Params&return FORCE_PRIORITY_9;}-JitConstants FullyConnected_bf_tiled_dyn_b::GetJitConstants(const fully_connected_params& params,- const DispatchData& dispatchData) const {+JitConstants FullyConnected_bf_tiled_dyn_b::GetJitConstants(const fully_connected_params& params, const DispatchData& dispatchData) const {JitConstants jit = Parent::GetJitConstants(params, dispatchData);size_t tile_k_ofm = dispatchData.tile_nk * dispatchData.tile_n;@@ -248,8 +268,9 @@ JitConstants FullyConnected_bf_tiled_dyn_b::GetJitConstants(const fully_connectetile_k_ofm_packed /= 2;jit.Merge(make_sub_byte_packed_type_jit_constant("INT4_PACKED_TYPE", weights_dt, tile_k_ofm));const size_t scale_group_size = get_scale_group_size(params);- if (scale_group_size % simd == 0)+ if (scale_group_size % simd == 0) {add_decompress_scale_post_op = true;+ }}// W_IDX and TILE_OFM_PER_OSV_SIZE based on weight layout@@ -273,8 +294,9 @@ JitConstants FullyConnected_bf_tiled_dyn_b::GetJitConstants(const fully_connectejit.AddConstant(MakeJitConstant("TILE_OFM_PER_OSV_SIZE", 1));}- if (add_decompress_scale_post_op)+ if (add_decompress_scale_post_op) {jit.AddConstant(MakeJitConstant("DECOMPRESSION_SCALE_POST_OP", 1));+ }jit.AddConstant(MakeJitConstant("DYNAMIC_QUANTIZE", 0));jit.AddConstant(MakeJitConstant("IFM_SIZE", get_input_bf_size(params).second));@@ -304,9 +326,7 @@ JitConstants FullyConnected_bf_tiled_dyn_b::GetJitConstants(const fully_connecte// Output layout constantsif (params.outputs[0].GetLayout() == DataLayout::bfyx) {- auto tile_in_b_pitch = (params.inputs[0].Feature().pitch == 0)- ? get_input_bf_size(params).second- : params.inputs[0].Feature().pitch;+ auto tile_in_b_pitch = (params.inputs[0].Feature().pitch == 0) ? get_input_bf_size(params).second : params.inputs[0].Feature().pitch;jit.AddConstant(MakeJitConstant("TILE_OUT_F_NUM", params.outputs[0].Y().v));jit.AddConstant(MakeJitConstant("TILE_OUT_F_PITCH", params.outputs[0].Y().pitch));jit.AddConstant(MakeJitConstant("TILE_IN_B_PITCH", tile_in_b_pitch));@@ -314,9 +334,7 @@ JitConstants FullyConnected_bf_tiled_dyn_b::GetJitConstants(const fully_connectejit.AddConstant(MakeJitConstant("OUTPUT_3D", true));jit.AddConstant(MakeJitConstant("BATCH_SIZE", "(OUTPUT_BATCH_NUM * OUTPUT_FEATURE_NUM)"));} else {- auto tile_in_b_pitch = (params.inputs[0].Batch().pitch == 0)- ? get_input_bf_size(params).second- : params.inputs[0].Batch().pitch;+ auto tile_in_b_pitch = (params.inputs[0].Batch().pitch == 0) ? get_input_bf_size(params).second : params.inputs[0].Batch().pitch;jit.AddConstant(MakeJitConstant("TILE_OUT_F_NUM", params.outputs[0].Feature().v));jit.AddConstant(MakeJitConstant("TILE_OUT_F_PITCH", params.outputs[0].Feature().pitch));jit.AddConstant(MakeJitConstant("TILE_IN_B_PITCH", tile_in_b_pitch));@@ -326,16 +344,16 @@ JitConstants FullyConnected_bf_tiled_dyn_b::GetJitConstants(const fully_connecte// Fused ops setupif (!params.fused_ops.empty()) {- std::vector<std::string> idx_order_scalar = { "(out_b + bi)", "(out_f + sglid)", "0", "0" };- std::vector<std::string> idx_order_vec = { "(out_b + bi)", "(out_f + sglid + fi * SIMD)", "0", "0" };+ std::vector<std::string> idx_order_scalar = {"(out_b + bi)", "(out_f + sglid)", "0", "0"};+ std::vector<std::string> idx_order_vec = {"(out_b + bi)", "(out_f + sglid + fi * SIMD)", "0", "0"};if (params.outputs[0].GetLayout() == DataLayout::bfyx) {- idx_order_scalar = { "(out_b + bi) / OUTPUT_FEATURE_NUM", "(out_b + bi) % OUTPUT_FEATURE_NUM", "(out_f + sglid)", "0" };- idx_order_vec = { "(out_b + bi) / OUTPUT_FEATURE_NUM", "(out_b + bi) % OUTPUT_FEATURE_NUM", "(out_f + sglid + fi * SIMD)", "0" };+ idx_order_scalar = {"(out_b + bi) / OUTPUT_FEATURE_NUM", "(out_b + bi) % OUTPUT_FEATURE_NUM", "(out_f + sglid)", "0"};+ idx_order_vec = {"(out_b + bi) / OUTPUT_FEATURE_NUM", "(out_b + bi) % OUTPUT_FEATURE_NUM", "(out_f + sglid + fi * SIMD)", "0"};}- FusedOpsConfiguration conf_scalar = { "_SCALAR", idx_order_scalar, "activated[bi]", activation_dt, 1 };- FusedOpsConfiguration conf_vec = { "_VEC", idx_order_vec, "activated[bi][fi]", activation_dt, 1 };- jit.Merge(MakeFusedOpsJitConstants(params, { conf_scalar, conf_vec }));+ FusedOpsConfiguration conf_scalar = {"_SCALAR", idx_order_scalar, "activated[bi]", activation_dt, 1};+ FusedOpsConfiguration conf_vec = {"_VEC", idx_order_vec, "activated[bi][fi]", activation_dt, 1};+ jit.Merge(MakeFusedOpsJitConstants(params, {conf_scalar, conf_vec}));}return jit;@@ -348,25 +366,20 @@ KernelsData FullyConnected_bf_tiled_dyn_b::GetKernelsData(const Params& params)// Determine optimal weight layoutWeightsLayout weights_layout = WeightsLayout::os_iyx_osv16;auto output_f = get_output_aligned_bf_size(fc_params, false).second;- if (fc_params.compressed && fc_params.inputs[0].GetDType() == Datatype::F16- && (fc_params.weights.GetDType() == WeightsType::INT4 || fc_params.weights.GetDType() == WeightsType::UINT4)) {- if ((fc_params.weights.GetLayout() == WeightsLayout::oiyx || fc_params.weights.GetLayout() == WeightsLayout::os_is_yx_osv64_isv2)- && is_weight_horizontal(fc_params, output_f)) {+ if (fc_params.compressed && fc_params.inputs[0].GetDType() == Datatype::F16 &&+ (fc_params.weights.GetDType() == WeightsType::INT4 || fc_params.weights.GetDType() == WeightsType::UINT4)) {+ if ((fc_params.weights.GetLayout() == WeightsLayout::oiyx || fc_params.weights.GetLayout() == WeightsLayout::os_is_yx_osv64_isv2) &&+ is_weight_horizontal(fc_params, output_f)) {weights_layout = WeightsLayout::os_is_yx_osv64_isv2;- } else if ((fc_params.weights.GetLayout() == WeightsLayout::oiyx || fc_params.weights.GetLayout() == WeightsLayout::os_iyx_osv16)- && is_weight_vertical(fc_params, output_f)) {+ } else if ((fc_params.weights.GetLayout() == WeightsLayout::oiyx || fc_params.weights.GetLayout() == WeightsLayout::os_iyx_osv16) &&+ is_weight_vertical(fc_params, output_f)) {weights_layout = WeightsLayout::os_iyx_osv16;} else if (fc_params.weights.GetLayout() == WeightsLayout::oiyx || fc_params.weights.GetLayout() == WeightsLayout::os_is_yx_osv32_isv2) {weights_layout = WeightsLayout::os_is_yx_osv32_isv2;}}- auto kernels_data = GetCommonKernelsData(params,- fc_params.inputs[0].GetLayout(),- weights_layout,- tparams.exec_options,- -1,- 0);+ auto kernels_data = GetCommonKernelsData(params, fc_params.inputs[0].GetLayout(), weights_layout, tparams.exec_options, -1, 0);if (!kernels_data.empty()) {GetUpdateDispatchDataFunc(kernels_data[0]);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bfyx_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bfyx_ref.cppindex f873d3b01f8..e782069a5e6 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bfyx_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bfyx_ref.cpp@@ -75,8 +75,9 @@ JitConstants FullyConnected_bfyx_Ref::GetJitConstants(const fully_connected_para? Datatype::F32: GetAccumulatorType(params);Datatype activation_dt = GetActivationType(params);- if (params.outputs[0].GetLayout() == DataLayout::bfyx)+ if (params.outputs[0].GetLayout() == DataLayout::bfyx) {jit.AddConstant(MakeJitConstant("OUTPUT_3D", true));+ }jit.Merge(MakeTypeJitConstants(activation_dt, "ACTIVATION"));jit.Merge(MakeTypeJitConstants(accumulator_dt, "ACCUMULATOR"));jit.Merge(MakeActivationJitConstants(params.activations, activation_dt, "_TYPED"));@@ -90,8 +91,9 @@ JitConstants FullyConnected_bfyx_Ref::GetJitConstants(const fully_connected_paraif (!params.fused_ops.empty()) {std::vector<std::string> idx_order = { "b", "ofm", "0", "0" };- if (params.outputs[0].GetLayout() == DataLayout::bfyx)+ if (params.outputs[0].GetLayout() == DataLayout::bfyx) {idx_order = { "b", "ofm", "oym", "0" };+ }FusedOpsConfiguration conf = { "", idx_order, "dequantized", activation_dt, 1 };jit.Merge(MakeFusedOpsJitConstants(params, { conf }));}@@ -116,15 +118,17 @@ KernelsData FullyConnected_bfyx_Ref::GetKernelsData(const Params& params) const}bool FullyConnected_bfyx_Ref::Validate(const Params& params) const {- if (!Parent::Validate(params))+ if (!Parent::Validate(params)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }// int8 validationconst auto& fc_params = static_cast<const fully_connected_params&>(params);// We don't support 4d output- if (fc_params.outputs[0].GetLayout() == DataLayout::bfyx && fc_params.outputs[0].X().v > 1)+ if (fc_params.outputs[0].GetLayout() == DataLayout::bfyx && fc_params.outputs[0].X().v > 1) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv8_af8.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv8_af8.cppindex 7a89dd5f12b..b2c6c7e9ce9 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv8_af8.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_bs_f_bsv8_af8.cpp@@ -56,8 +56,9 @@ bool FullyConnected_bs_f_bsv8_af8::Validate(const Params& p) const {DO_NOT_USE_THIS_KERNEL(p.layerID);}- if (!IsSIMDSizeSupported(p.engineInfo, 8))+ if (!IsSIMDSizeSupported(p.engineInfo, 8)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const auto& params = static_cast<const fully_connected_params&>(p);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_io_b8_f8.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_io_b8_f8.cppindex b33cc34b199..f6b7f54b2b1 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_io_b8_f8.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_fb_io_b8_f8.cpp@@ -33,11 +33,13 @@ DeviceFeaturesKey FullyConnected_fb_io_b8_f8::get_required_device_features_key(csize_t FullyConnected_fb_io_b8_f8::GetBatchesPerWorkItem(const fully_connected_params& params) const {auto batch_size = params.outputs[0].Batch().v;- if (batch_size % 32 == 0)+ if (batch_size % 32 == 0) {return std::min(batch_size, static_cast<size_t>(32U));+ }- if (batch_size % 16 == 0)+ if (batch_size % 16 == 0) {return std::min(batch_size, static_cast<size_t>(16U));+ }return std::min(batch_size, static_cast<size_t>(8U));}@@ -63,8 +65,9 @@ bool FullyConnected_fb_io_b8_f8::Validate(const Params& p) const {DO_NOT_USE_THIS_KERNEL(p.layerID);}- if (!IsSIMDSizeSupported(p.engineInfo, 8))+ if (!IsSIMDSizeSupported(p.engineInfo, 8)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const auto& params = static_cast<const fully_connected_params&>(p);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_gemv.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_gemv.cppindex bdc7b51c007..17626744529 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_gemv.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_gemv.cpp@@ -48,8 +48,9 @@ DeviceFeaturesKey FullyConnected_GEMV::get_required_device_features_key(const Pa}bool FullyConnected_GEMV::Validate(const Params& params) const {- if (!Parent::Validate(params))+ if (!Parent::Validate(params)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }const auto& fc_params = static_cast<const fully_connected_params&>(params);const auto& input = fc_params.inputs[0];@@ -97,15 +98,18 @@ bool FullyConnected_GEMV::Validate(const Params& params) const {if (input.GetLayout() == DataLayout::bfyx) {// Padding on input is not supported.- if (input.X().pad.Total() != 0)+ if (input.X().pad.Total() != 0) {DO_NOT_USE_THIS_KERNEL(params.layerID);- if (input.Y().pad.Total() != 0)+ }+ if (input.Y().pad.Total() != 0) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}// We don't support 4d output- if (fc_params.outputs[0].GetLayout() == DataLayout::bfyx && fc_params.outputs[0].X().v > 1)+ if (fc_params.outputs[0].GetLayout() == DataLayout::bfyx && fc_params.outputs[0].X().v > 1) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_imad.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_imad.cppindex ab87b2f2df5..a29ce6e3a93 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_imad.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_imad.cpp@@ -94,8 +94,9 @@ bool FullyConnectedKernelIMAD::Validate(const Params& params) const {// Dynamic kernel doesn't support dynamic weightsif (fc_params.is_shape_agnostic && in.is_dynamic()) {if ((out_l == DataLayout::bfyx && in.Y().v == 0) ||- (out_l == DataLayout::bf && in.Feature().v == 0))+ (out_l == DataLayout::bf && in.Feature().v == 0)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}if ((in.X().pad.before != 0) || (in.X().pad.after != 0) ||@@ -106,8 +107,9 @@ bool FullyConnectedKernelIMAD::Validate(const Params& params) const {if (out_l == DataLayout::bfyx) {// We don't support 4d output- if (in.X().v > 1)+ if (in.X().v > 1) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }} else {if (in.X().v * in.Y().v * wei.X().v * wei.Y().v != 1) {// Currently only Input = F x 1 x 1 with Filter = 1 x 1 is supported@@ -176,8 +178,9 @@ FullyConnectedKernelIMAD::FullyConnectedTuningData FullyConnectedKernelIMAD::Gettuning_data.tile_batch = tuning_data.sub_group_size == 8 ? 16 : 8;if (!params.has_dynamic_tensors()) {- while (tile_batch_max_size % tuning_data.tile_batch != 0)+ while (tile_batch_max_size % tuning_data.tile_batch != 0) {tuning_data.tile_batch--;+ }}size_t sub_group_pack_size = tuning_data.sub_group_size * tuning_data.pack_size;diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_mmad.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_mmad.cppindex 1b3a38337be..598f529db40 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_mmad.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/fully_connected/fully_connected_kernel_mmad.cpp@@ -48,8 +48,9 @@ DeviceFeaturesKey FullyConnectedKernelMMAD::get_required_device_features_key(con}bool FullyConnectedKernelMMAD::Validate(const Params& params) const {- if (!Parent::Validate(params))+ if (!Parent::Validate(params)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }auto fc_params = static_cast<const fully_connected_params&>(params);auto input = fc_params.inputs[0];@@ -88,8 +89,9 @@ FullyConnectedKernelMMAD::FullyConnectedTuningData FullyConnectedKernelMMAD::Get// Some specific HW doesn't support SIMD8, force SIMD16 to respect this HW// Also chose SIMD16 for the exception cases- if (!IsSIMDSizeSupported(params.engineInfo, 8) || simd16_is_faster)+ if (!IsSIMDSizeSupported(params.engineInfo, 8) || simd16_is_faster) {tuning_data.sub_group_size = 16;+ }size_t sub_group_pack_size = tuning_data.sub_group_size * tuning_data.pack_size;@@ -106,13 +108,16 @@ FullyConnectedKernelMMAD::FullyConnectedTuningData FullyConnectedKernelMMAD::Getinput_feature == 9216 && output_feature == 4096;size_t max_work_group_size = params.engineInfo.maxWorkGroupSize;- if (max_work_group_size > 256 && !big_wgs_exception)+ if (max_work_group_size > 256 && !big_wgs_exception) {max_work_group_size = 256;+ }- if (tuning_data.feature_blocks_count && tuning_data.sub_group_size == 8 && !slm_div_factor_exception)+ if (tuning_data.feature_blocks_count && tuning_data.sub_group_size == 8 && !slm_div_factor_exception) {while (tuning_data.feature_blocks_count % (tuning_data.slm_div_factor * 2) == 0 &&- (tuning_data.slm_div_factor * 2 <= max_work_group_size / tuning_data.sub_group_size))+ (tuning_data.slm_div_factor * 2 <= max_work_group_size / tuning_data.sub_group_size)) {tuning_data.slm_div_factor *= 2;+ }+ }tuning_data.work_group_size = tuning_data.slm_div_factor * tuning_data.sub_group_size;@@ -124,8 +129,9 @@ FullyConnectedKernelMMAD::FullyConnectedTuningData FullyConnectedKernelMMAD::Getsize_t temp_unroll_factor = 3;if (tuning_data.full_unroll_factor > 3) {- while (tuning_data.full_unroll_factor % temp_unroll_factor)+ while (tuning_data.full_unroll_factor % temp_unroll_factor) {temp_unroll_factor--;+ }tuning_data.unroll_factor = temp_unroll_factor;} else {tuning_data.unroll_factor = tuning_data.full_unroll_factor;@@ -142,8 +148,9 @@ FullyConnectedKernelMMAD::DispatchData FullyConnectedKernelMMAD::SetDefault(consconst auto& output = params.outputs[0];std::vector<size_t> global = { Align(output.Feature().v, tuning_data.sub_group_size) * tuning_data.slm_div_factor, output.Batch().v, 1 };- if (output.GetLayout() == DataLayout::bfyx)+ if (output.GetLayout() == DataLayout::bfyx) {global = { Align(output.Y().v, tuning_data.sub_group_size) * tuning_data.slm_div_factor, output.Batch().v, output.Feature().v };+ }dispatchData.gws = global;dispatchData.lws = { tuning_data.work_group_size, 1, 1 };@@ -207,8 +214,9 @@ JitConstants FullyConnectedKernelMMAD::GetJitConstants(const fully_connected_parbool has_feature_leftovers = (input.GetLayout() == DataLayout::bfyx && ((input.Feature().v % sub_group_pack_size) != 0u)) ||(input.GetLayout() != DataLayout::bfyx && tuning_data.sub_group_size == 16 && ((CeilDiv(input.Feature().v, 32) % 2) != 0u));- if (output.GetLayout() == DataLayout::bfyx)+ if (output.GetLayout() == DataLayout::bfyx) {has_feature_leftovers = ((input.Y().v % sub_group_pack_size) != 0u);+ }jit.AddConstant(MakeJitConstant("HAS_FEATURE_LEFTOVERS", has_feature_leftovers));jit.AddConstant(MakeJitConstant("FEATURE_BLOCKS_COUNT", tuning_data.feature_blocks_count));@@ -256,8 +264,9 @@ JitConstants FullyConnectedKernelMMAD::GetJitConstants(const fully_connected_parif (!params.fused_ops.empty()) {auto input_dt = GetActivationType(params);std::vector<std::string> idx_order = { "batch", "feature", "0", "0" };- if (output.GetLayout() == DataLayout::bfyx)+ if (output.GetLayout() == DataLayout::bfyx) {idx_order = { "batch", "skip_f", "feature", "0" };+ }FusedOpsConfiguration conf = { "", idx_order, "dequantized", input_dt, 1 };jit.Merge(MakeFusedOpsJitConstants(params, { conf }));diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/gather/gather_elements_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/gather/gather_elements_kernel_ref.cppindex 5c90635a92a..2e47a11febb 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/gather/gather_elements_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/gather/gather_elements_kernel_ref.cpp@@ -3,10 +3,12 @@//#include "gather_elements_kernel_ref.h"-#include "kernel_selector_utils.h"+#include <string>#include <vector>+#include "kernel_selector_utils.h"+namespace kernel_selector {static size_t GetGatherElementsChannelIndex(const gather_elements_params& params) {Tensor::DataChannelName name = Tensor::DataChannelName::X;@@ -14,20 +16,20 @@ static size_t GetGatherElementsChannelIndex(const gather_elements_params& paramssize_t inputSize = params.inputs[0].GetDims().size();switch (params.axis) {- case GatherAxis::X:- return inputSize - 1;- case GatherAxis::Y:- return inputSize - 2;- case GatherAxis::Z:- return inputSize - 3;- case GatherAxis::W:- return 2;- case GatherAxis::FEATURE:- return 1;- case GatherAxis::BATCH:- return 0;- default:- break;+ case GatherAxis::X:+ return inputSize - 1;+ case GatherAxis::Y:+ return inputSize - 2;+ case GatherAxis::Z:+ return inputSize - 3;+ case GatherAxis::W:+ return 2;+ case GatherAxis::FEATURE:+ return 1;+ case GatherAxis::BATCH:+ return 0;+ default:+ break;}return DataTensor::Channelndex(params.outputs[0].GetLayout(), name);@@ -88,11 +90,11 @@ ParamsKey GatherElementsKernelRef::GetSupportedKey() const {static inline std::vector<std::string> GetDefaultOrder(size_t size) {std::vector<std::string> default_order;if (size <= 4) {- default_order = { "b", "f", "y", "x" };+ default_order = {"b", "f", "y", "x"};} else if (size == 5) {- default_order = { "b", "f", "z", "y", "x" };+ default_order = {"b", "f", "z", "y", "x"};} else if (size == 6) {- default_order = { "b", "f", "w", "z", "y", "x" };+ default_order = {"b", "f", "w", "z", "y", "x"};}return default_order;@@ -100,8 +102,9 @@ static inline std::vector<std::string> GetDefaultOrder(size_t size) {static inline std::string GetOrderString(const std::vector<std::string>& order) {std::string order_str = order[0];- for (size_t i = 1; i < order.size(); i++)+ for (size_t i = 1; i < order.size(); i++) {order_str += ", " + order[i];+ }return order_str;}@@ -126,9 +129,7 @@ CommonDispatchData GatherElementsKernelRef::SetDefault(const gather_elements_parswitch (params.inputs[1].GetLayout()) {case DataLayout::bfyx:dispatchData.gws = {output.X().v, output.Y().v, output.Feature().v * output.Batch().v};- dims_by_gws = {{Tensor::DataChannelName::X},- {Tensor::DataChannelName::Y},- {Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH}};+ dims_by_gws = {{Tensor::DataChannelName::X}, {Tensor::DataChannelName::Y}, {Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH}};break;@@ -167,8 +168,8 @@ JitConstants GatherElementsKernelRef::GetJitConstants(const gather_elements_paraif (!params.fused_ops.empty()) {std::vector<std::string> idx_order = GetDefaultOrder(params.inputs[0].GetDims().size());- FusedOpsConfiguration conf = { "", idx_order, "val", params.inputs[0].GetDType() };- jit.Merge(MakeFusedOpsJitConstants(params, { conf }));+ FusedOpsConfiguration conf = {"", idx_order, "val", params.inputs[0].GetDType()};+ jit.Merge(MakeFusedOpsJitConstants(params, {conf}));}return jit;@@ -188,8 +189,9 @@ bool GatherElementsKernelRef::Validate(const Params& p) const {}for (const auto& fused_op : params.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}return true;@@ -222,9 +224,20 @@ KernelsData GatherElementsKernelRef::GetKernelsData(const Params& params) constGetUpdateDispatchDataFunc(kd);auto& kernel = kd.kernels[0];- FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point,- "", false, false, 2, GetFusedPrimitiveInputsCount(params), 1, newParams.is_shape_agnostic);- return { kd };+ FillCLKernelData(kernel,+ dispatchData,+ params.engineInfo,+ kernelName,+ jit,+ entry_point,+ "",+ false,+ false,+ 2,+ GetFusedPrimitiveInputsCount(params),+ 1,+ newParams.is_shape_agnostic);+ return {kd};}KernelsPriority GatherElementsKernelRef::GetKernelsPriority(const Params& /*params*/) const {diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/gather/gather_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/gather/gather_kernel_ref.cppindex 6b04cc72143..b387046b19d 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/gather/gather_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/gather/gather_kernel_ref.cpp@@ -3,10 +3,12 @@//#include "gather_kernel_ref.h"-#include "kernel_selector_utils.h"+#include <string>#include <vector>+#include "kernel_selector_utils.h"+namespace kernel_selector {static size_t GetGatherChannelIndex(const gather_params& params) {Tensor::DataChannelName name = Tensor::DataChannelName::X;@@ -14,20 +16,20 @@ static size_t GetGatherChannelIndex(const gather_params& params) {size_t inputSize = params.inputs[0].GetDims().size();switch (params.axis) {- case GatherAxis::X:- return inputSize - 1;- case GatherAxis::Y:- return inputSize - 2;- case GatherAxis::Z:- return inputSize - 3;- case GatherAxis::W:- return 2;- case GatherAxis::FEATURE:- return 1;- case GatherAxis::BATCH:- return 0;- default:- break;+ case GatherAxis::X:+ return inputSize - 1;+ case GatherAxis::Y:+ return inputSize - 2;+ case GatherAxis::Z:+ return inputSize - 3;+ case GatherAxis::W:+ return 2;+ case GatherAxis::FEATURE:+ return 1;+ case GatherAxis::BATCH:+ return 0;+ default:+ break;}return DataTensor::Channelndex(params.outputs[0].GetLayout(), name);@@ -72,16 +74,17 @@ static size_t GetNonEmptyDimsNumber(const DataTensor& data_tensor) {auto shape = shape_raw;int shape_idx = 0;for (size_t i = 0; i < DataTensor::max_rank(); i++) {- int shape_raw_idx =- data_tensor.Channelndex(data_tensor.GetLayout(), static_cast<Tensor::DataChannelName>(i));- if (shape_raw_idx >= 0)+ int shape_raw_idx = data_tensor.Channelndex(data_tensor.GetLayout(), static_cast<Tensor::DataChannelName>(i));+ if (shape_raw_idx >= 0) {shape[shape_idx++] = shape_raw[shape_raw_idx];+ }}for (auto& i : shape) {- if (i == 1)+ if (i == 1) {one_size_dims++;- else+ } else {break;+ }}return data_tensor.Dimentions() - one_size_dims;}@@ -89,8 +92,9 @@ static size_t GetNonEmptyDimsNumber(const DataTensor& data_tensor) {}static int64_t GetGatherBatchDim(const gather_params& params) {- if (params.batch_dim < 0)+ if (params.batch_dim < 0) {return (int64_t)GetNonEmptyDimsNumber(params.inputs[1]) + params.batch_dim;+ }return params.batch_dim;}@@ -139,8 +143,9 @@ static inline std::string GetGatherMaxIndexDim(const gather_params& params) {static inline std::string GetOrderString(const std::vector<std::string>& order) {std::string order_str = order[0];- for (size_t i = 1; i < order.size(); i++)+ for (size_t i = 1; i < order.size(); i++) {order_str += ", " + order[i];+ }return order_str;}@@ -166,16 +171,19 @@ static std::string GetDictionaryIndexOrder(const gather_params& params, size_t asize_t indices_dims_num = GetNonEmptyDimsNumber(params.outputs[0]) - dictionary_dims_num + 1;// Shift indices of Gather dictionary input related to output dims- for (size_t i = axis + 1; i < dictionary_dims_num; i++)+ for (size_t i = axis + 1; i < dictionary_dims_num; i++) {idx_order[i] = idx_order[i + indices_dims_num - 1];+ }- for (size_t i = dictionary_dims_num; i < idx_order.size(); i++)+ for (size_t i = dictionary_dims_num; i < idx_order.size(); i++) {idx_order[i] = zero_val;+ }// Fix size to inputs[0] dims sizeif (params.outputs[0].GetDims().size() > params.inputs[0].GetDims().size()) {- for (size_t i = 0; i < params.outputs[0].GetDims().size() - params.inputs[0].GetDims().size(); i++)+ for (size_t i = 0; i < params.outputs[0].GetDims().size() - params.inputs[0].GetDims().size(); i++) {idx_order.pop_back();+ }}idx_order[axis] = input_axis_index_macro;@@ -224,18 +232,14 @@ CommonDispatchData GatherKernelRef::SetDefault(const gather_params& params) consauto rank = params.outputs[0].Dimentions();if (rank == 4) {dispatchData.gws = {output.X().v, output.Y().v, output.Feature().v * output.Batch().v};- dims_by_gws = {{Tensor::DataChannelName::X},- {Tensor::DataChannelName::Y},- {Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH}};+ dims_by_gws = {{Tensor::DataChannelName::X}, {Tensor::DataChannelName::Y}, {Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH}};} else if (rank == 5) {dispatchData.gws = {output.X().v, output.Y().v * output.Z().v, output.Feature().v * output.Batch().v};dims_by_gws = {{Tensor::DataChannelName::X},{Tensor::DataChannelName::Y, Tensor::DataChannelName::Z},{Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH}};} else if (rank == 6) {- dispatchData.gws = {output.X().v * output.Y().v,- output.Z().v * output.W().v,- output.Feature().v * output.Batch().v};+ dispatchData.gws = {output.X().v * output.Y().v, output.Z().v * output.W().v, output.Feature().v * output.Batch().v};dims_by_gws = {{Tensor::DataChannelName::X, Tensor::DataChannelName::Y},{Tensor::DataChannelName::Z, Tensor::DataChannelName::W},{Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH}};@@ -243,8 +247,7 @@ CommonDispatchData GatherKernelRef::SetDefault(const gather_params& params) consOPENVINO_THROW("Unknown rank: rank=", rank);}- dispatchData.lws =- GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo, in_layout, out_layout, dims_by_gws);+ dispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo, in_layout, out_layout, dims_by_gws);return dispatchData;}@@ -268,16 +271,18 @@ JitConstants GatherKernelRef::GetJitConstants(const gather_params& params) const}}- if (!dyn_gather_idx_dim)+ if (!dyn_gather_idx_dim) {jit.AddConstant(MakeJitConstant("AXIS_DIM", GetGatherMaxIndexDim(params)));+ }- if (params.is_shape_agnostic && params.inputs[0].is_dynamic())+ if (params.is_shape_agnostic && params.inputs[0].is_dynamic()) {jit.AddConstant(MakeJitConstant("GATHER_AXIS_SHAPE_INFO_INDEX", GetGatherAxisIndexInShapeInfo(params)));+ }if (!params.fused_ops.empty()) {std::vector<std::string> idx_order;idx_order = GetOrder(params.outputs[0].GetDims().size());- FusedOpsConfiguration conf = { "", idx_order, "val", params.compressed ? params.outputs[0].GetDType() : params.inputs[0].GetDType() };+ FusedOpsConfiguration conf = {"", idx_order, "val", params.compressed ? params.outputs[0].GetDType() : params.inputs[0].GetDType()};jit.Merge(MakeFusedOpsJitConstants(params, {conf}));}@@ -328,24 +333,25 @@ bool GatherKernelRef::Validate(const Params& p) const {const gather_params& params = static_cast<const gather_params&>(p);for (const auto& fused_op : params.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}if (params.outputs[0].is_dynamic()) {auto supported_tensor_layout = [](const DataTensor& t) -> bool {- return t.GetLayout() == DataLayout::bfyx ||- t.GetLayout() == DataLayout::bfzyx ||- t.GetLayout() == DataLayout::bfwzyx;+ return t.GetLayout() == DataLayout::bfyx || t.GetLayout() == DataLayout::bfzyx || t.GetLayout() == DataLayout::bfwzyx;};for (const auto& in : params.inputs) {- if (!supported_tensor_layout(in))+ if (!supported_tensor_layout(in)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}for (const auto& out : params.outputs) {- if (!supported_tensor_layout(out))+ if (!supported_tensor_layout(out)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}}@@ -383,8 +389,9 @@ KernelsData GatherKernelRef::GetKernelsData(const Params& params) const {int inputs_count = 2;if (newParams.compressed) {inputs_count++;- if (newParams.has_decompression_zp && !newParams.scalar_zp)+ if (newParams.has_decompression_zp && !newParams.scalar_zp) {inputs_count++;+ }}FillCLKernelData(kernel,diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/gather/gather_nd_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/gather/gather_nd_kernel_ref.cppindex d1ca2fde927..ef27bf1c90c 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/gather/gather_nd_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/gather/gather_nd_kernel_ref.cpp@@ -3,10 +3,12 @@//#include "gather_nd_kernel_ref.h"-#include "kernel_selector_utils.h"+#include <string>#include <vector>+#include "kernel_selector_utils.h"+namespace kernel_selector {ParamsKey GatherNDKernelRef::GetSupportedKey() const {@@ -36,11 +38,11 @@ ParamsKey GatherNDKernelRef::GetSupportedKey() const {static inline std::vector<std::string> GetDefaultOrder(size_t size) {std::vector<std::string> default_order;if (size <= 4) {- default_order = { "b", "f", "y", "x" };+ default_order = {"b", "f", "y", "x"};} else if (size == 5) {- default_order = { "b", "f", "z", "y", "x" };+ default_order = {"b", "f", "z", "y", "x"};} else if (size == 6) {- default_order = { "b", "f", "w", "z", "y", "x" };+ default_order = {"b", "f", "w", "z", "y", "x"};}return default_order;@@ -55,19 +57,19 @@ CommonDispatchData GatherNDKernelRef::SetDefault(const gather_nd_params& params)std::reverse(indices_dims.begin(), indices_dims.end());}- indices_dims[params.indices_rank - 1] = 1; // set last dim of indices to 1+ indices_dims[params.indices_rank - 1] = 1; // set last dim of indices to 1switch (params.inputs[1].GetLayout()) {case DataLayout::bfyx:- dispatchData.gws = { indices_dims[3], indices_dims[2], indices_dims[1] * indices_dims[0] };+ dispatchData.gws = {indices_dims[3], indices_dims[2], indices_dims[1] * indices_dims[0]};break;case DataLayout::bfzyx:- dispatchData.gws = { indices_dims[4] * indices_dims[3], indices_dims[2], indices_dims[1] * indices_dims[0] };+ dispatchData.gws = {indices_dims[4] * indices_dims[3], indices_dims[2], indices_dims[1] * indices_dims[0]};break;case DataLayout::bfwzyx:- dispatchData.gws = { indices_dims[5] * indices_dims[4], indices_dims[3] * indices_dims[2], indices_dims[1] * indices_dims[0] };+ dispatchData.gws = {indices_dims[5] * indices_dims[4], indices_dims[3] * indices_dims[2], indices_dims[1] * indices_dims[0]};break;default:@@ -123,15 +125,15 @@ JitConstants GatherNDKernelRef::GetJitConstants(const gather_nd_params& params)jit.AddConstant(MakeJitConstant("INDICES_LAST_DIM", GetIndicesLastDim(params)));if (!params.fused_ops.empty()) {- FusedOpsConfiguration conf = { "", GetDefaultOrder(params.outputs[0].GetDims().size()), "val", params.inputs[0].GetDType() };- jit.Merge(MakeFusedOpsJitConstants(params, { conf }));+ FusedOpsConfiguration conf = {"", GetDefaultOrder(params.outputs[0].GetDims().size()), "val", params.inputs[0].GetDType()};+ jit.Merge(MakeFusedOpsJitConstants(params, {conf}));}return jit;}bool GatherNDKernelRef::Validate(const Params& p) const {- if (p.GetType() != KernelType:: GATHER_ND) {+ if (p.GetType() != KernelType::GATHER_ND) {DO_NOT_USE_THIS_KERNEL(p.layerID);}@@ -165,8 +167,9 @@ bool GatherNDKernelRef::Validate(const Params& p) const {}for (const auto& fused_op : params.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}return true;@@ -214,7 +217,7 @@ KernelsData GatherNDKernelRef::GetKernelsData(const Params& params) const {1,newParams.is_shape_agnostic);- return { kd };+ return {kd};}} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_base.cppindex 0f9c02b24c8..fcf862ed308 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_base.cpp@@ -3,32 +3,33 @@//#include "gemm_kernel_base.h"+#include <vector>+#include "kernel_selector_utils.h"namespace kernel_selector {-size_t GemmKernelBase::GetOuputSize(const std::vector<int64_t>& output_order, const kernel_selector::DataTensor &output,- char target_dim) const {+size_t GemmKernelBase::GetOuputSize(const std::vector<int64_t>& output_order, const kernel_selector::DataTensor& output, char target_dim) const {OPENVINO_ASSERT(target_dim == 'X' || target_dim == 'Y');auto output_dims_order = GetDimsOrder(output_order);int dim_idx = (target_dim == 'X') ? 10 : 8;switch (output_dims_order[dim_idx]) {- case 'b':- return output.Batch().v;- case 'f':- return output.Feature().v;- case 'w':- return output.W().v;- case 'z':- return output.Z().v;- case 'y':- return output.Y().v;- case 'x':- return output.X().v;- default:- OPENVINO_THROW("Unsupported dimension: ", output_dims_order[dim_idx]);+ case 'b':+ return output.Batch().v;+ case 'f':+ return output.Feature().v;+ case 'w':+ return output.W().v;+ case 'z':+ return output.Z().v;+ case 'y':+ return output.Y().v;+ case 'x':+ return output.X().v;+ default:+ OPENVINO_THROW("Unsupported dimension: ", output_dims_order[dim_idx]);}}@@ -137,8 +138,9 @@ std::string GemmKernelBase::GetDimsOrder(const std::vector<int64_t>& order_idx)auto get_order_idx = [](std::vector<int64_t> order_idx, int64_t dim_idx) {int loc = 0;for (auto idx : order_idx) {- if (idx == dim_idx)+ if (idx == dim_idx) {break;+ }loc += 1;}return loc;@@ -147,26 +149,22 @@ std::string GemmKernelBase::GetDimsOrder(const std::vector<int64_t>& order_idx)std::string dims_order;if (order_idx.size() == 2) {const std::vector<std::string> dims2 = {"y", "x"};- dims_order = "b,f,w,z,"- + dims2[get_order_idx(order_idx, 0)] + "," + dims2[get_order_idx(order_idx, 1)];+ dims_order = "b,f,w,z," + dims2[get_order_idx(order_idx, 0)] + "," + dims2[get_order_idx(order_idx, 1)];} else if (order_idx.size() == 3) {const std::vector<std::string> dims3 = {"f", "y", "x"};- dims_order = "b," + dims3[get_order_idx(order_idx, 0)] + ",w,z,"- + dims3[get_order_idx(order_idx, 1)] + "," + dims3[get_order_idx(order_idx, 2)];+ dims_order = "b," + dims3[get_order_idx(order_idx, 0)] + ",w,z," + dims3[get_order_idx(order_idx, 1)] + "," + dims3[get_order_idx(order_idx, 2)];} else if (order_idx.size() == 4) {const std::vector<std::string> dims4 = {"b", "f", "y", "x"};- dims_order = dims4[get_order_idx(order_idx, 0)] + "," + dims4[get_order_idx(order_idx, 1)] + ",w,z,"- + dims4[get_order_idx(order_idx, 2)] + "," + dims4[get_order_idx(order_idx, 3)];+ dims_order = dims4[get_order_idx(order_idx, 0)] + "," + dims4[get_order_idx(order_idx, 1)] + ",w,z," + dims4[get_order_idx(order_idx, 2)] + "," ++ dims4[get_order_idx(order_idx, 3)];} else if (order_idx.size() == 5) {const std::vector<std::string> dims5 = {"b", "f", "z", "y", "x"};- dims_order = dims5[get_order_idx(order_idx, 0)] + "," + dims5[get_order_idx(order_idx, 1)] + ",w,"- + dims5[get_order_idx(order_idx, 2)] + "," + dims5[get_order_idx(order_idx, 3)] + ","- + dims5[get_order_idx(order_idx, 4)];+ dims_order = dims5[get_order_idx(order_idx, 0)] + "," + dims5[get_order_idx(order_idx, 1)] + ",w," + dims5[get_order_idx(order_idx, 2)] + "," ++ dims5[get_order_idx(order_idx, 3)] + "," + dims5[get_order_idx(order_idx, 4)];} else if (order_idx.size() == 6) {const std::vector<std::string> dims6 = {"b", "f", "w", "z", "y", "x"};- dims_order = dims6[get_order_idx(order_idx, 0)] + "," + dims6[get_order_idx(order_idx, 1)] + ","- + dims6[get_order_idx(order_idx, 2)] + "," + dims6[get_order_idx(order_idx, 3)] + ","- + dims6[get_order_idx(order_idx, 4)] + "," + dims6[get_order_idx(order_idx, 5)];+ dims_order = dims6[get_order_idx(order_idx, 0)] + "," + dims6[get_order_idx(order_idx, 1)] + "," + dims6[get_order_idx(order_idx, 2)] + "," ++ dims6[get_order_idx(order_idx, 3)] + "," + dims6[get_order_idx(order_idx, 4)] + "," + dims6[get_order_idx(order_idx, 5)];} else {dims_order = "b,f,w,z,y,x";}@@ -192,20 +190,20 @@ JitConstants GemmKernelBase::GetJitConstants(const gemm_params& params) const {auto output_dims_order = GetDimsOrder(output_order_idx);switch (output_dims_order.at(target_idx)) {- case 'b':- return "OUTPUT_BATCH_NUM";- case 'f':- return "OUTPUT_FEATURE_NUM";- case 'w':- return "OUTPUT_SIZE_W";- case 'z':- return "OUTPUT_SIZE_Z";- case 'y':- return "OUTPUT_SIZE_Y";- case 'x':- return "OUTPUT_SIZE_X";- default:- return "";+ case 'b':+ return "OUTPUT_BATCH_NUM";+ case 'f':+ return "OUTPUT_FEATURE_NUM";+ case 'w':+ return "OUTPUT_SIZE_W";+ case 'z':+ return "OUTPUT_SIZE_Z";+ case 'y':+ return "OUTPUT_SIZE_Y";+ case 'x':+ return "OUTPUT_SIZE_X";+ default:+ return "";}};if (params.indirect_input0 || params.indirect_input1) {@@ -236,17 +234,15 @@ JitConstants GemmKernelBase::GetJitConstants(const gemm_params& params) const {if (params.input0_broadcast_val != 0) {jit.AddConstants({MakeJitConstant("BROADCAST_INPUT0", true),- MakeJitConstant("DO_BROADCAST_INPUT0", get_broadcast_input_str(params.inputs[0].GetDims().size(),- params.input0_reshape_axes,- params.input0_broadcast_val)),+ MakeJitConstant("DO_BROADCAST_INPUT0",+ get_broadcast_input_str(params.inputs[0].GetDims().size(), params.input0_reshape_axes, params.input0_broadcast_val)),});}if (params.input1_broadcast_val != 0) {jit.AddConstants({MakeJitConstant("BROADCAST_INPUT1", true),- MakeJitConstant("DO_BROADCAST_INPUT1", get_broadcast_input_str(params.inputs[1].GetDims().size(),- params.input1_reshape_axes,- params.input1_broadcast_val)),+ MakeJitConstant("DO_BROADCAST_INPUT1",+ get_broadcast_input_str(params.inputs[1].GetDims().size(), params.input1_reshape_axes, params.input1_broadcast_val)),});}@@ -272,7 +268,7 @@ GemmKernelBase::DispatchData GemmKernelBase::SetDefault(const gemm_params& paramif (!output.is_dynamic()) {auto total_batches = output.LogicalSize() / (output.X().v * output.Y().v);- dispatchData.gws = { output.X().v, output.Y().v, total_batches };+ dispatchData.gws = {output.X().v, output.Y().v, total_batches};dispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo);}@@ -282,11 +278,11 @@ GemmKernelBase::DispatchData GemmKernelBase::SetDefault(const gemm_params& paramvoid GemmKernelBase::GetUpdateDispatchDataFunc(KernelData& kd) const {kd.update_dispatch_data_func = [this](const Params& params, KernelData& kd) {const auto& prim_params = static_cast<const gemm_params&>(params);- auto dispatchData = SetDefault(prim_params);- OPENVINO_ASSERT(kd.kernels.size() == 1, "[GPU] Invalid kernels size for update dispatch data func");- kd.kernels[0].params.workGroups.global = dispatchData.gws;- kd.kernels[0].params.workGroups.local = dispatchData.lws;- kd.kernels[0].skip_execution = KernelData::SkipKernelExecution(prim_params);+ auto dispatchData = SetDefault(prim_params);+ OPENVINO_ASSERT(kd.kernels.size() == 1, "[GPU] Invalid kernels size for update dispatch data func");+ kd.kernels[0].params.workGroups.global = dispatchData.gws;+ kd.kernels[0].params.workGroups.local = dispatchData.lws;+ kd.kernels[0].skip_execution = KernelData::SkipKernelExecution(prim_params);};}@@ -334,16 +330,18 @@ bool GemmKernelBase::Validate(const Params& p) const {}for (const auto& fused_op : params.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}return true;}Datatype GemmKernelBase::GetActivationType(const gemm_params& params) const {- if (params.quantization != QuantizationType::NONE)+ if (params.quantization != QuantizationType::NONE) {return Datatype::F32;+ }return GetUnitType(params);}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_base.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_base.hindex 29f45c0ab93..2fd9a77410a 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_base.h+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_base.h@@ -36,8 +36,9 @@ struct gemm_params : public base_params {ParamsKey k = base_params::GetParamsKey();k.EnableQuantization(quantization);- if (indirect_input0 || indirect_input1)+ if (indirect_input0 || indirect_input1) {k.EnableIndirectGemm();+ }return k;}};diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_mmad_int8.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_mmad_int8.cppindex 3fbc61083cd..6bb5118178e 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_mmad_int8.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_mmad_int8.cpp@@ -173,20 +173,23 @@ KernelsPriority GemmKernelMMADint8::GetKernelsPriority(const Params& params) con}bool GemmKernelMMADint8::Validate(const Params& params) const {- if (!Parent::Validate(params))+ if (!Parent::Validate(params)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }const auto& gmm_params = static_cast<const gemm_params&>(params);auto input0_type = gmm_params.inputs[0].GetDType();auto input1_type = gmm_params.inputs[1].GetDType();if ((input0_type != Datatype::UINT8 && input0_type != Datatype::INT8) ||- (input1_type != Datatype::UINT8 && input1_type != Datatype::INT8))+ (input1_type != Datatype::UINT8 && input1_type != Datatype::INT8)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }GemmTuningData tuning_data = SetTuningParams(gmm_params);- if (!IsSIMDSizeSupported(params.engineInfo, tuning_data.simd_size))+ if (!IsSIMDSizeSupported(params.engineInfo, tuning_data.simd_size)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_mmad_int8_slm.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_mmad_int8_slm.cppindex 7e987728e65..28d883da526 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_mmad_int8_slm.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_mmad_int8_slm.cpp@@ -51,13 +51,14 @@ JitConstants GemmKernelMMADslmInt8::GetJitConstants(const gemm_params& params) cjit.Merge(MakeTypeJitConstants(params.inputs[1].GetDType() == Datatype::INT8 ? Datatype::INT32 : Datatype::UINT32, "PACKED_INPUT1"));jit.AddConstant(MakeJitConstant("SLM_TILE_SIZE", td.slm_tile_size));jit.AddConstant(MakeJitConstant("SLM_DECIMATION_FACTOR", td.slm_decimation_factor));- if (td.size_k <= td.max_slm_preloading_size) jit.AddConstant(MakeJitConstant("PRELOADING_SLM", 1));+ if (td.size_k <= td.max_slm_preloading_size)+ jit.AddConstant(MakeJitConstant("PRELOADING_SLM", 1));if (!params.fused_ops.empty()) {auto input_dt = GetActivationType(params);- FusedOpsConfiguration conf = { "", {"b", "f", "output_y", "output_x"}, "dequantized", input_dt, 1 };- conf.SetLoopAxes({ Tensor::DataChannelName::Y }, true);- jit.Merge(MakeFusedOpsJitConstants(params, { conf }));+ FusedOpsConfiguration conf = {"", {"b", "f", "output_y", "output_x"}, "dequantized", input_dt, 1};+ conf.SetLoopAxes({Tensor::DataChannelName::Y}, true);+ jit.Merge(MakeFusedOpsJitConstants(params, {conf}));}return jit;@@ -70,8 +71,8 @@ GemmKernelBase::DispatchData GemmKernelMMADslmInt8::SetDefault(const gemm_paramsDispatchData dispatchData;GemmTuningData td = SetTuningParams(params);- dispatchData.gws = { td.size_n / td.pack_size, output.Y().v / td.simd_size, total_batches };- dispatchData.lws = { td.slm_tile_size / td.pack_size, td.slm_tile_size / td.simd_size, 1 };+ dispatchData.gws = {td.size_n / td.pack_size, output.Y().v / td.simd_size, total_batches};+ dispatchData.lws = {td.slm_tile_size / td.pack_size, td.slm_tile_size / td.simd_size, 1};return dispatchData;}@@ -98,8 +99,7 @@ inline bool GemmKernelMMADslmInt8::HasLeftovers(const GemmTuningData& tuning_datGemmKernelMMADslmInt8::GemmTuningData GemmKernelMMADslmInt8::SetTuningParams(const gemm_params& params) const {GemmTuningData tuning_data = InitGemmTuningData(params);- tuning_data.slm_decimation_factor = tuning_data.size_k <= tuning_data.max_slm_preloading_size ?- tuning_data.size_k / tuning_data.slm_tile_size : 2;+ tuning_data.slm_decimation_factor = tuning_data.size_k <= tuning_data.max_slm_preloading_size ? tuning_data.size_k / tuning_data.slm_tile_size : 2;return tuning_data;}@@ -138,34 +138,40 @@ KernelsPriority GemmKernelMMADslmInt8::GetKernelsPriority(const Params& params)GemmTuningData tuning_data = InitGemmTuningData(prim_params);auto mmad_operations_number = GetMmadOperationsNumber(tuning_data);- if ((mmad_operations_number >= 1024 * 1024 * 1024) || (tuning_data.size_m == 384 && tuning_data.size_k == 384 && tuning_data.size_n == 64))+ if ((mmad_operations_number >= 1024 * 1024 * 1024) || (tuning_data.size_m == 384 && tuning_data.size_k == 384 && tuning_data.size_n == 64)) {return FORCE_PRIORITY_2;- if (mmad_operations_number <= 65536 || tuning_data.size_k <= 64)+ }+ if (mmad_operations_number <= 65536 || tuning_data.size_k <= 64) {return DONT_USE_IF_HAVE_SOMETHING_ELSE;+ }return FORCE_PRIORITY_5;}bool GemmKernelMMADslmInt8::Validate(const Params& params) const {- if (!Parent::Validate(params))+ if (!Parent::Validate(params)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }const auto& gmm_params = static_cast<const gemm_params&>(params);auto input0_type = gmm_params.inputs[0].GetDType();auto input1_type = gmm_params.inputs[1].GetDType();- if (gmm_params.transpose_input0 || gmm_params.transpose_input1)+ if (gmm_params.transpose_input0 || gmm_params.transpose_input1) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }GemmTuningData tuning_data = InitGemmTuningData(gmm_params);- if (HasLeftovers(tuning_data))+ if (HasLeftovers(tuning_data)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }- if (!IsSIMDSizeSupported(params.engineInfo, tuning_data.simd_size))+ if (!IsSIMDSizeSupported(params.engineInfo, tuning_data.simd_size)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }- if ((input0_type != Datatype::UINT8 && input0_type != Datatype::INT8) ||- (input1_type != Datatype::UINT8 && input1_type != Datatype::INT8))+ if ((input0_type != Datatype::UINT8 && input0_type != Datatype::INT8) || (input1_type != Datatype::UINT8 && input1_type != Datatype::INT8)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_ref.cppindex 85d597f37dc..8404f91d433 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_ref.cpp@@ -113,8 +113,9 @@ KernelsPriority GemmKernelRef::GetKernelsPriority(const Params& /*params*/) cons}bool GemmKernelRef::Validate(const Params& params) const {- if (!Parent::Validate(params))+ if (!Parent::Validate(params)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }// int8 validationconst auto& gmm_params = static_cast<const gemm_params&>(params);@@ -126,8 +127,9 @@ bool GemmKernelRef::Validate(const Params& params) const {// require some additional checks.if ((input_type != Datatype::UINT8 && input_type != Datatype::INT8) &&(input2_type != Datatype::UINT8 && input2_type != Datatype::INT8) &&- (output_type != Datatype::UINT8 && output_type != Datatype::INT8))+ (output_type != Datatype::UINT8 && output_type != Datatype::INT8)) {return true;+ }bool is_quantization = (input_type == Datatype::INT8 || input_type == Datatype::UINT8) &&(input2_type == Datatype::INT8 || input2_type == Datatype::UINT8) &&@@ -139,8 +141,9 @@ bool GemmKernelRef::Validate(const Params& params) const {!gmm_params.fused_ops.empty() &&(output_type == Datatype::INT8 || output_type == Datatype::UINT8);- if (!is_quantization && !has_fused_op)+ if (!is_quantization && !has_fused_op) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_tiled_opt.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_tiled_opt.cppindex b1a00cae9b1..f7259b338c8 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_tiled_opt.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/gemm/gemm_kernel_tiled_opt.cpp@@ -98,8 +98,9 @@ GemmKernelTiledOpt::GemmTuningData GemmKernelTiledOpt::SetTuningParams(const gem// Increasing tile_n_size has performance improvement when m_size and n_size are not shallow and n_size is aligned at 32.// TODO: Support TILE_K_LEFTOVER true case at static shapeif (m_size >= 128 && n_size >= 128 && (n_size % 32 == 0) && tuning_data.simd_size == 16 &&- (k_size % tuning_data.tile_k_size == 0) && params.fused_ops.empty())+ (k_size % tuning_data.tile_k_size == 0) && params.fused_ops.empty()) {tuning_data.tile_n_size = 32;+ }GPU_DEBUG_LOG << params.layerID << ": m_size: " << m_size << ", n_size: " << n_size << ", k_size: " << k_size << std::endl;} else {@@ -202,15 +203,18 @@ JitConstants GemmKernelTiledOpt::GetJitConstants(const gemm_params& params) cons});bool transpose_output = (!params.output_order.empty() && (params.output_order.back() != (static_cast<int>(params.output_order.size()) - 1)));- if (transpose_output)+ if (transpose_output) {jit.AddConstant(MakeJitConstant("TRANSPOSE_OUTPUT", 2 /* set as TRANSPOSE_OTHER */));- else+ } else {jit.AddConstant(MakeJitConstant("TRANSPOSE_OUTPUT", 0 /* set as TRANSPOSE_X_LAST */));+ }- if (dims0_padded.has_dynamic_pad)+ if (dims0_padded.has_dynamic_pad) {jit.AddConstant(MakeJitConstant("INPUT0_HAS_DYNAMIC_PADDING", 1));- if (dims1_padded.has_dynamic_pad)+ }+ if (dims1_padded.has_dynamic_pad) {jit.AddConstant(MakeJitConstant("INPUT1_HAS_DYNAMIC_PADDING", 1));+ }} else {auto get_transposed_dim_size = [](const kernel_selector::DataTensor &data_tensor,const std::vector<int64_t>& dims_order, const std::string dim) {@@ -292,10 +296,12 @@ JitConstants GemmKernelTiledOpt::GetJitConstants(const gemm_params& params) consMakeJitConstant("TR_X", GetTransposedDims(params.output_order, true).at(7)),});- if (params.inputs[0].LogicalSize() != params.inputs[0].PhysicalSize())+ if (params.inputs[0].LogicalSize() != params.inputs[0].PhysicalSize()) {jit.AddConstant(MakeJitConstant("INPUT0_HAS_PADDING", 1));- if (params.inputs[1].LogicalSize() != params.inputs[1].PhysicalSize())+ }+ if (params.inputs[1].LogicalSize() != params.inputs[1].PhysicalSize()) {jit.AddConstant(MakeJitConstant("INPUT1_HAS_PADDING", 1));+ }}if (tuning_data.tile_k_size > tuning_data.simd_size) {@@ -457,13 +463,15 @@ KernelsPriority GemmKernelTiledOpt::GetKernelsPriority(const Params& params) con}bool GemmKernelTiledOpt::Validate(const Params& params) const {- if (!Parent::Validate(params))+ if (!Parent::Validate(params)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }const auto& gmm_params = static_cast<const gemm_params&>(params);- if (gmm_params.outputs[0].PitchesDifferFromLogicalDims())+ if (gmm_params.outputs[0].PitchesDifferFromLogicalDims()) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }size_t num_inputs = (gmm_params.indirect_input0 || gmm_params.indirect_input1) ? gmm_params.inputs.size() - 1 : gmm_params.inputs.size();for (size_t input_idx = 0; input_idx < num_inputs; ++input_idx) {@@ -482,16 +490,20 @@ bool GemmKernelTiledOpt::Validate(const Params& params) const {proper_pad_y |= input.Y().pad.is_dynamic;}- if (!proper_pad_x || !proper_pad_y || input.Z().pad.Total() != 0 || !proper_pad_f)+ if (!proper_pad_x || !proper_pad_y || input.Z().pad.Total() != 0 || !proper_pad_f) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}- if (gmm_params.has_dynamic_inputs() && !gmm_params.is_shape_agnostic)+ if (gmm_params.has_dynamic_inputs() && !gmm_params.is_shape_agnostic) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }- for (size_t i = 1; i < num_inputs; i++)- if (gmm_params.inputs[0].GetDType() != gmm_params.inputs[i].GetDType())+ for (size_t i = 1; i < num_inputs; i++) {+ if (gmm_params.inputs[0].GetDType() != gmm_params.inputs[i].GetDType()) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/grid_sample/grid_sample_kernel_opt_bilinear_zeros.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/grid_sample/grid_sample_kernel_opt_bilinear_zeros.cppindex aba38a2963a..6c7e430f6d1 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/grid_sample/grid_sample_kernel_opt_bilinear_zeros.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/grid_sample/grid_sample_kernel_opt_bilinear_zeros.cpp@@ -28,8 +28,9 @@ KernelsPriority GridSampleKernelOpt_BilinearZeros::GetKernelsPriority(const Para}bool GridSampleKernelOpt_BilinearZeros::Validate(const Params& params) const {- if (!TBase::Validate(params))+ if (!TBase::Validate(params)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }auto PaddedSpatial = [](const MultiDataTensor& tensors) -> bool {bool is_padded = false;@@ -41,15 +42,18 @@ bool GridSampleKernelOpt_BilinearZeros::Validate(const Params& params) const {};const auto& kernel_params = static_cast<const grid_sample_params&>(params);- if (kernel_params.interpolation_mode != grid_sample_params::InterpolationMode::BILINEAR)+ if (kernel_params.interpolation_mode != grid_sample_params::InterpolationMode::BILINEAR) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }- if (kernel_params.padding_mode != grid_sample_params::PaddingMode::ZEROS)+ if (kernel_params.padding_mode != grid_sample_params::PaddingMode::ZEROS) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }if (kernel_params.inputs[0].GetDims().size() != 4 || kernel_params.outputs[0].GetDims().size() != 4 ||- PaddedSpatial(kernel_params.inputs) || PaddedSpatial(kernel_params.outputs))+ PaddedSpatial(kernel_params.inputs) || PaddedSpatial(kernel_params.outputs)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/grn/grn_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/grn/grn_kernel_base.cppindex 05138967f3c..e845697e9f6 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/grn/grn_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/grn/grn_kernel_base.cpp@@ -32,8 +32,9 @@ GRNKernelBase::DispatchData GRNKernelBase::SetDefault(const grn_params& params)KernelsData GRNKernelBase::GetCommonKernelsData(const Params& params) const {assert(params.GetType() == KernelType::GRN);- if (!Validate(params))+ if (!Validate(params)) {return {};+ }const grn_params& orgParams = static_cast<const grn_params&>(params);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/lrn/lrn_kernel_across_channel_opt_b8.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/lrn/lrn_kernel_across_channel_opt_b8.cppindex 03aeb777cfd..904d035ef6e 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/lrn/lrn_kernel_across_channel_opt_b8.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/lrn/lrn_kernel_across_channel_opt_b8.cpp@@ -41,8 +41,9 @@ bool LRNKernelAcrossChannel_b8::Validate(const Params& p) const {DO_NOT_USE_THIS_KERNEL(p.layerID);}- if (!IsSIMDSizeSupported(p.engineInfo, 8))+ if (!IsSIMDSizeSupported(p.engineInfo, 8)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const lrn_params& params = static_cast<const lrn_params&>(p);const auto& out = params.outputs[0];diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/lrn/lrn_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/lrn/lrn_kernel_base.cppindex 2452fd32e3b..3a5ce8846b0 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/lrn/lrn_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/lrn/lrn_kernel_base.cpp@@ -3,6 +3,7 @@//#include "lrn_kernel_base.h"+#include <algorithm>namespace kernel_selector {@@ -14,8 +15,9 @@ bool LRNKernelBase::Validate(const Params& p) const {const lrn_params& params = static_cast<const lrn_params&>(p);for (const auto& fused_op : params.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}return true;@@ -64,7 +66,7 @@ LRNKernelBase::DispatchData LRNKernelBase::SetDefault(const lrn_params& params)dispatchData.gws[0] = output.Batch().v * output.Feature().v; // B, FdispatchData.gws[1] = output.X().v; // XdispatchData.gws[2] = output.Y().v; // Y- // Find largest positive local work size that is divider for global work size.+ // Find largest positive local work size that is divider for global work size.dispatchData.lws[0] = std::min(std::max(dispatchData.gws[0], static_cast<size_t>(1)), static_cast<size_t>(32));while (dispatchData.gws[0] % dispatchData.lws[0] != 0) {--dispatchData.lws[0];@@ -91,17 +93,7 @@ KernelsData LRNKernelBase::GetCommonKernelsData(const Params& params) const {auto fused_deps_total = GetFusedPrimitiveInputsCount(params);auto& kernel = kd.kernels[0];- FillCLKernelData(kernel,- dispatchData,- params.engineInfo,- kernelName,- jit,- entryPoint,- "",- false,- false,- 1,- fused_deps_total);+ FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entryPoint, "", false, false, 1, fused_deps_total);return {kd};}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/matrix_nms/matrix_nms_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/matrix_nms/matrix_nms_kernel_ref.cppindex 4c678e5b13e..f4be038d3ce 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/matrix_nms/matrix_nms_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/matrix_nms/matrix_nms_kernel_ref.cpp@@ -53,16 +53,19 @@ std::tuple<int, int> GetMaxBoxes(const matrix_nms_params& params) {const int boxes_num = static_cast<int>(params.inputs[0].Feature().v);int max_boxes_per_class{boxes_num};- if (params.nms_top_k >= 0)+ if (params.nms_top_k >= 0) {max_boxes_per_class = std::min(max_boxes_per_class, params.nms_top_k);+ }auto classes_num_adj = classes_num;- if (params.background_class >= 0 && params.background_class < classes_num)+ if (params.background_class >= 0 && params.background_class < classes_num) {classes_num_adj = std::max(1, classes_num - 1);+ }auto max_boxes_per_batch = max_boxes_per_class * classes_num_adj;- if (params.keep_top_k >= 0)+ if (params.keep_top_k >= 0) {max_boxes_per_batch = std::min(max_boxes_per_batch, params.keep_top_k);+ }return {max_boxes_per_class, max_boxes_per_batch};}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/multiclass_nms/multiclass_nms_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/multiclass_nms/multiclass_nms_kernel_ref.cppindex b2c2490f07a..44cf4274ce8 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/multiclass_nms/multiclass_nms_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/multiclass_nms/multiclass_nms_kernel_ref.cpp@@ -95,8 +95,9 @@ JitConstants MulticlassNmsKernelRef::GetJitConstants(const multiclass_nms_params}auto max_output_boxes_per_batch = max_output_boxes_per_class * real_num_classes;- if (params.keep_top_k >= 0)+ if (params.keep_top_k >= 0) {max_output_boxes_per_batch = std::min<int64_t>(max_output_boxes_per_batch, params.keep_top_k);+ }jit.AddConstants({MakeJitConstant("SORT_RESULT_TYPE", static_cast<int>(params.sort_result_type)),diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/multinomial/multinomial_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/multinomial/multinomial_kernel_ref.cppindex dfde4b5a967..2aab4eea1ff 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/multinomial/multinomial_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/multinomial/multinomial_kernel_ref.cpp@@ -76,8 +76,9 @@ bool MultinomialKernelRef::Validate(const Params &p) const {DO_NOT_USE_THIS_KERNEL(p.layerID);}const multinomial_params ¶ms = dynamic_cast<const multinomial_params&>(p);- if (params.inputs.empty())+ if (params.inputs.empty()) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_b_fs_yx_fsv16.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_b_fs_yx_fsv16.cppindex aed01cbfc24..9b76cd7f26d 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_b_fs_yx_fsv16.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_b_fs_yx_fsv16.cpp@@ -3,11 +3,12 @@//#include "mvn_kernel_b_fs_yx_fsv16.hpp"-#include "common_tools.h"-#include <string>#include <algorithm>#include <iostream>+#include <string>++#include "common_tools.h"namespace kernel_selector {@@ -58,17 +59,18 @@ DeviceFeaturesKey MVNKernel_b_fs_yx_fsv16::get_required_device_features_key(cons}bool MVNKernel_b_fs_yx_fsv16::Validate(const Params& p) const {- if (!Parent::Validate(p))+ if (!Parent::Validate(p)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }auto params = static_cast<const mvn_params&>(p);// TODO Add support for input padding via iterating over y (parallel or in kernel).// Skip padding check for dynamic tensors (padding not known at compile time).if (!params.has_dynamic_tensors()) {- if (params.inputs[0].X().pad.Total() != 0 || params.inputs[0].Y().pad.Total() != 0 ||- params.inputs[0].Z().pad.Total() != 0)+ if (params.inputs[0].X().pad.Total() != 0 || params.inputs[0].Y().pad.Total() != 0 || params.inputs[0].Z().pad.Total() != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}return true;@@ -113,13 +115,14 @@ Datatype MVNKernel_b_fs_yx_fsv16::GetAccumulatorType(const mvn_params& params) cconst auto& input_dt = params.inputs[0].GetDType();switch (input_dt) {- case Datatype::F32:- case Datatype::F16:- return Datatype::F32;- case Datatype::INT8:- case Datatype::UINT8:- return Datatype::INT32;- default: return Datatype::F32;+ case Datatype::F32:+ case Datatype::F16:+ return Datatype::F32;+ case Datatype::INT8:+ case Datatype::UINT8:+ return Datatype::INT32;+ default:+ return Datatype::F32;}}@@ -135,12 +138,10 @@ JitConstants MVNKernel_b_fs_yx_fsv16::GetJitConstants(const mvn_params& params,jits.AddConstant(MakeJitConstant("GWS", dispatchData.gws[0]));jits.AddConstant(MakeJitConstant("ITEM_GROUPS", dispatchData.itemsNum));auto input_layout = params.inputs[0].GetLayout();- size_t input_slice_pitch = (input_layout == DataLayout::b_fs_yx_fsv32 ||- input_layout == DataLayout::b_fs_zyx_fsv32) ? 32 : 16;+ size_t input_slice_pitch = (input_layout == DataLayout::b_fs_yx_fsv32 || input_layout == DataLayout::b_fs_zyx_fsv32) ? 32 : 16;jits.AddConstant(MakeJitConstant("INPUT_SLICE_PITCH", input_slice_pitch));auto output_layout = params.outputs[0].GetLayout();- size_t output_slice_pitch = (output_layout == DataLayout::b_fs_yx_fsv32 ||- output_layout == DataLayout::b_fs_zyx_fsv32) ? 32 : 16;+ size_t output_slice_pitch = (output_layout == DataLayout::b_fs_yx_fsv32 || output_layout == DataLayout::b_fs_zyx_fsv32) ? 32 : 16;jits.AddConstant(MakeJitConstant("OUTPUT_SLICE_PITCH", output_slice_pitch));if (params.has_dynamic_tensors()) {// For dynamic shapes, ITEMS_NUM is passed as a scalar kernel argument@@ -149,17 +150,13 @@ JitConstants MVNKernel_b_fs_yx_fsv16::GetJitConstants(const mvn_params& params,} else {// Define ITEMS_NUM via JIT so the batch-compilation #undef system// cleans it up between kernels sharing the same CL source file.- jits.AddConstant(MakeJitConstant("ITEMS_NUM",- params.outputs[0].X().v * params.outputs[0].Y().v * params.outputs[0].Z().v));+ jits.AddConstant(MakeJitConstant("ITEMS_NUM", params.outputs[0].X().v * params.outputs[0].Y().v * params.outputs[0].Z().v));}if (!params.fused_ops.empty()) {std::vector<std::string> idx_order;if (params.inputs[0].GetDims().size() <= 4) {- idx_order = {"b",- "(f + set_idx)",- "(output_spatial / OUTPUT_SIZE_X)",- "(output_spatial % OUTPUT_SIZE_X)"};+ idx_order = {"b", "(f + set_idx)", "(output_spatial / OUTPUT_SIZE_X)", "(output_spatial % OUTPUT_SIZE_X)"};} else if (params.inputs[0].GetDims().size() == 5) {idx_order = {"b","(f + set_idx)",@@ -177,8 +174,7 @@ JitConstants MVNKernel_b_fs_yx_fsv16::GetJitConstants(const mvn_params& params,return jits;}-MVNKernel_b_fs_yx_fsv16::MultiDispatchData MVNKernel_b_fs_yx_fsv16::SetDefaultForMulti(- const mvn_params& params) const {+MVNKernel_b_fs_yx_fsv16::MultiDispatchData MVNKernel_b_fs_yx_fsv16::SetDefaultForMulti(const mvn_params& params) const {MultiDispatchData dispatchData;auto max_wg = params.engineInfo.maxWorkGroupSize;@@ -245,8 +241,9 @@ MVNKernel_b_fs_yx_fsv16::MultiDispatchData MVNKernel_b_fs_yx_fsv16::SetDefaultFo}KernelsData MVNKernel_b_fs_yx_fsv16::GetMultiStageKernelsData(const mvn_params& params) const {- if (!Validate(params))+ if (!Validate(params)) {return {};+ }constexpr size_t intermidiate_bytes = 4;const mvn_params& orgParams = static_cast<const mvn_params&>(params);@@ -265,22 +262,11 @@ KernelsData MVNKernel_b_fs_yx_fsv16::GetMultiStageKernelsData(const mvn_params&auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id++);auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);auto& kernel = kd.kernels[0];- FillCLKernelData(kernel,- dispatchData.stage_1,- params.engineInfo,- finalKernelName,- jit,- entry_point,- "",- false,- false,- 0,- 0);+ FillCLKernelData(kernel, dispatchData.stage_1, params.engineInfo, finalKernelName, jit, entry_point, "", false, false, 0, 0);kernel.params.arguments.clear(); // Clear original output argumentkernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0});kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});- kd.internalBuffers.push_back(params.outputs[0].Batch().v * Align(params.outputs[0].Feature().v, fsv) *- dispatchData.item_groups * intermidiate_bytes);+ kd.internalBuffers.push_back(params.outputs[0].Batch().v * Align(params.outputs[0].Feature().v, fsv) * dispatchData.item_groups * intermidiate_bytes);}{// Mean second stage@@ -289,22 +275,11 @@ KernelsData MVNKernel_b_fs_yx_fsv16::GetMultiStageKernelsData(const mvn_params&auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id++);auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);auto& kernel = kd.kernels[1];- FillCLKernelData(kernel,- dispatchData.stage_2,- params.engineInfo,- finalKernelName,- jit,- entry_point,- "",- false,- false,- 0,- 0);+ FillCLKernelData(kernel, dispatchData.stage_2, params.engineInfo, finalKernelName, jit, entry_point, "", false, false, 0, 0);kernel.params.arguments.clear(); // Clear original output argumentkernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1});- kd.internalBuffers.push_back(params.outputs[0].Batch().v * Align(params.outputs[0].Feature().v, fsv) *- intermidiate_bytes);+ kd.internalBuffers.push_back(params.outputs[0].Batch().v * Align(params.outputs[0].Feature().v, fsv) * intermidiate_bytes);}if (params.mvnNormalizeVariance) {// Variance first stage@@ -313,17 +288,7 @@ KernelsData MVNKernel_b_fs_yx_fsv16::GetMultiStageKernelsData(const mvn_params&auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id++);auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);auto& kernel = kd.kernels[2];- FillCLKernelData(kernel,- dispatchData.stage_1,- params.engineInfo,- finalKernelName,- jit,- entry_point,- "",- false,- false,- 0,- 0);+ FillCLKernelData(kernel, dispatchData.stage_1, params.engineInfo, finalKernelName, jit, entry_point, "", false, false, 0, 0);kernel.params.arguments.clear(); // Clear original output argumentkernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0});kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1});@@ -336,22 +301,11 @@ KernelsData MVNKernel_b_fs_yx_fsv16::GetMultiStageKernelsData(const mvn_params&auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id++);auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);auto& kernel = kd.kernels[3];- FillCLKernelData(kernel,- dispatchData.stage_2,- params.engineInfo,- finalKernelName,- jit,- entry_point,- "",- false,- false,- 0,- 0);+ FillCLKernelData(kernel, dispatchData.stage_2, params.engineInfo, finalKernelName, jit, entry_point, "", false, false, 0, 0);kernel.params.arguments.clear(); // Clear original output argumentkernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 2});- kd.internalBuffers.push_back(params.outputs[0].Batch().v * Align(params.outputs[0].Feature().v, fsv) *- intermidiate_bytes);+ kd.internalBuffers.push_back(params.outputs[0].Batch().v * Align(params.outputs[0].Feature().v, fsv) * intermidiate_bytes);}{ // Finalauto cldnn_jit = GetJitConstants(orgParams, dispatchData.stage_final);@@ -385,8 +339,9 @@ KernelsData MVNKernel_b_fs_yx_fsv16::GetMultiStageKernelsData(const mvn_params&}KernelsData MVNKernel_b_fs_yx_fsv16::GetDynamicMultiStageKernelsData(const mvn_params& params) const {- if (!Validate(params))+ if (!Validate(params)) {return {};+ }const mvn_params& orgParams = static_cast<const mvn_params&>(params);bool has_variance = params.mvnNormalizeVariance;@@ -439,17 +394,7 @@ KernelsData MVNKernel_b_fs_yx_fsv16::GetDynamicMultiStageKernelsData(const mvn_pauto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id++);auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);auto& kernel = kd.kernels[1];- FillCLKernelData(kernel,- dispatchData.stage_1,- params.engineInfo,- finalKernelName,- jit,- entry_point,- "",- false,- false,- 0,- 0);+ FillCLKernelData(kernel, dispatchData.stage_1, params.engineInfo, finalKernelName, jit, entry_point, "", false, false, 0, 0);kernel.params.arguments.clear();kernel.params.arguments.push_back({ArgumentDescriptor::Types::SHAPE_INFO, 0});kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0});@@ -464,17 +409,7 @@ KernelsData MVNKernel_b_fs_yx_fsv16::GetDynamicMultiStageKernelsData(const mvn_pauto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id++);auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);auto& kernel = kd.kernels[2];- FillCLKernelData(kernel,- dispatchData.stage_2,- params.engineInfo,- finalKernelName,- jit,- entry_point,- "",- false,- false,- 0,- 0);+ FillCLKernelData(kernel, dispatchData.stage_2, params.engineInfo, finalKernelName, jit, entry_point, "", false, false, 0, 0);kernel.params.arguments.clear();kernel.params.arguments.push_back({ArgumentDescriptor::Types::SHAPE_INFO, 0});kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});@@ -490,17 +425,7 @@ KernelsData MVNKernel_b_fs_yx_fsv16::GetDynamicMultiStageKernelsData(const mvn_pauto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id++);auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);auto& kernel = kd.kernels[3];- FillCLKernelData(kernel,- dispatchData.stage_1,- params.engineInfo,- finalKernelName,- jit,- entry_point,- "",- false,- false,- 0,- 0);+ FillCLKernelData(kernel, dispatchData.stage_1, params.engineInfo, finalKernelName, jit, entry_point, "", false, false, 0, 0);kernel.params.arguments.clear();kernel.params.arguments.push_back({ArgumentDescriptor::Types::SHAPE_INFO, 0});kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0});@@ -516,17 +441,7 @@ KernelsData MVNKernel_b_fs_yx_fsv16::GetDynamicMultiStageKernelsData(const mvn_pauto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id++);auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);auto& kernel = kd.kernels[4];- FillCLKernelData(kernel,- dispatchData.stage_2,- params.engineInfo,- finalKernelName,- jit,- entry_point,- "",- false,- false,- 0,- 0);+ FillCLKernelData(kernel, dispatchData.stage_2, params.engineInfo, finalKernelName, jit, entry_point, "", false, false, 0, 0);kernel.params.arguments.clear();kernel.params.arguments.push_back({ArgumentDescriptor::Types::SHAPE_INFO, 0});kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});@@ -585,9 +500,7 @@ void MVNKernel_b_fs_yx_fsv16::GetUpdateDispatchDataFunc(KernelData& kd) const {constexpr size_t local_pref_work_groups = 16;constexpr size_t intermediate_bytes = 4;- auto items_num = prim_params.outputs[0].X().v- * prim_params.outputs[0].Y().v- * prim_params.outputs[0].Z().v;+ auto items_num = prim_params.outputs[0].X().v * prim_params.outputs[0].Y().v * prim_params.outputs[0].Z().v;auto batch = prim_params.outputs[0].Batch().v;auto feature = prim_params.outputs[0].Feature().v;@@ -668,9 +581,7 @@ void MVNKernel_b_fs_yx_fsv16::GetUpdateDispatchDataFunc(KernelData& kd) const {size_t buf0_size = batch * Align(feature, local_fsv) * item_groups * intermediate_bytes;size_t buf1_size = batch * Align(feature, local_fsv) * intermediate_bytes;- if (kd.internalBuffers.size() >= 2 &&- (kd.internalBuffers[0].byte_count < buf0_size ||- kd.internalBuffers[1].byte_count < buf1_size)) {+ if (kd.internalBuffers.size() >= 2 && (kd.internalBuffers[0].byte_count < buf0_size || kd.internalBuffers[1].byte_count < buf1_size)) {kd.internalBuffers.clear();kd.internalBuffers.push_back(buf0_size);kd.internalBuffers.push_back(buf1_size);@@ -701,8 +612,9 @@ KernelsData MVNKernel_b_fs_yx_fsv16::GetKernelsData(const Params& params) constauto enough_lws = max_lws / simd >= 1;auto enough_items = items_num >= max_lws / simd * simd * pref_work_groups;- if (enough_slm && enough_lws && enough_items)+ if (enough_slm && enough_lws && enough_items) {return GetMultiStageKernelsData(orgParams);+ }return GetCommonKernelsData(params);}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_base.cppindex 6b48087e155..3e302524be9 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_base.cpp@@ -3,17 +3,20 @@//#include "mvn_kernel_base.h"-#include "kernel_selector_utils.h"+#include <vector>+#include "kernel_selector_utils.h"+namespace kernel_selector {bool MVNKernelBase::Validate(const Params& params) const {const mvn_params& orgParams = static_cast<const mvn_params&>(params);for (const auto& fused_op : orgParams.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}return true;@@ -61,8 +64,9 @@ void MVNKernelBase::GetUpdateDispatchDataFunc(KernelData& kd) const {KernelsData MVNKernelBase::GetCommonKernelsData(const Params& params) const {assert(params.GetType() == KernelType::MVN);- if (!Validate(params))+ if (!Validate(params)) {return {};+ }const mvn_params& orgParams = static_cast<const mvn_params&>(params);@@ -96,8 +100,9 @@ KernelsData MVNKernelBase::GetCommonKernelsData(const Params& params) const {}Datatype MVNKernelBase::GetActivationType(const mvn_params& params) const {- if (params.inputs[0].GetDType() == Datatype::F16)+ if (params.inputs[0].GetDType() == Datatype::F16) {return Datatype::F16;+ }return Datatype::F32;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_base.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_base.hindex f66a0ce9712..d8b04354609 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_base.h+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_base.h@@ -25,8 +25,9 @@ struct mvn_params : public base_params {k.EnableMVNMode(mvnMode);- if (mvnNormalizeVariance)+ if (mvnNormalizeVariance) {k.EnableMVNNormalizeVariance();+ }return k;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_bs_fs_yx_bsv32.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_bs_fs_yx_bsv32.cppindex 1a1b1240767..37ef1a4c1b8 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_bs_fs_yx_bsv32.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_bs_fs_yx_bsv32.cpp@@ -53,14 +53,16 @@ DeviceFeaturesKey MVNKernel_bs_fs_yx_bsv32::get_required_device_features_key(con}bool MVNKernel_bs_fs_yx_bsv32::Validate(const Params& p) const {- if (!Parent::Validate(p))+ if (!Parent::Validate(p)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }auto params = static_cast<const mvn_params&>(p);// TODO Add support for input padding via iterating over y (parallel or in kernel).- if (params.inputs[0].X().pad.Total() != 0 || params.inputs[0].Y().pad.Total() != 0)+ if (params.inputs[0].X().pad.Total() != 0 || params.inputs[0].Y().pad.Total() != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}@@ -191,8 +193,9 @@ MVNKernel_bs_fs_yx_bsv32::MultiDispatchData MVNKernel_bs_fs_yx_bsv32::SetDefaultKernelsData MVNKernel_bs_fs_yx_bsv32::GetMultiStageKernelsData(const mvn_params& params,bool has_enough_data) const {- if (!Validate(params))+ if (!Validate(params)) {return {};+ }constexpr size_t intermediate_bytes = 4;auto dispatchData = SetDefaultForMulti(params, has_enough_data);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_ref.cppindex 2e8345011e3..6bcdfc4d991 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_ref.cpp@@ -42,19 +42,20 @@ JitConstants MVNKernelRef::GetJitConstants(const mvn_params& params, DispatchDatif (!params.fused_ops.empty()) {std::vector<std::string> idx_order;if (params.inputs[0].GetDims().size() <= 4) {- idx_order = { "b", "f", "y", "x" };+ idx_order = {"b", "f", "y", "x"};} else if (params.inputs[0].GetDims().size() == 5) {- idx_order = { "b", "f", "z", "y", "x" };+ idx_order = {"b", "f", "z", "y", "x"};}auto conf = FusedOpsConfiguration("", idx_order, "result", activation_dt);- jits.Merge(MakeFusedOpsJitConstants(params, { conf }));+ jits.Merge(MakeFusedOpsJitConstants(params, {conf}));}return jits;}std::string MVNKernelRef::GetKernelName(const mvn_params& params) const {- if (params.mvnMode == MVNMode::ACROSS_CHANNELS)+ if (params.mvnMode == MVNMode::ACROSS_CHANNELS) {return kernelName + "_across_channels";+ }return kernelName + "_within_channels";}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/non_max_suppression/non_max_suppression_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/non_max_suppression/non_max_suppression_kernel_ref.cppindex 0459a772482..a64ecc0accf 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/non_max_suppression/non_max_suppression_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/non_max_suppression/non_max_suppression_kernel_ref.cpp@@ -3,9 +3,11 @@//#include "non_max_suppression_kernel_ref.h"-#include "kernel_selector_utils.h"+#include <vector>+#include "kernel_selector_utils.h"+namespace kernel_selector {namespace {static inline int GetPartitionStep(int localWorkItemNum) {@@ -22,10 +24,12 @@ static inline size_t GetOptimalLocalClassSize(std::vector<size_t> gws, const Engconst size_t globalClassNum = gws[1];const auto rest_lws = info.maxWorkGroupSize / splitNum;size_t lws_idx = 0;- while (rest_lws < optimal_values[lws_idx])+ while (rest_lws < optimal_values[lws_idx]) {lws_idx++;- while (globalClassNum % optimal_values[lws_idx])+ }+ while (globalClassNum % optimal_values[lws_idx]) {lws_idx++;+ }return optimal_values[lws_idx];}@@ -59,8 +63,9 @@ Datatype NonMaxSuppressionKernelRef::GetAccumulatorType(const non_max_suppressioauto out_dt = params.outputs[0].GetDType();auto smaller_fp_type = [](const Datatype& current, const Datatype& candidate) -> Datatype {- if (candidate != Datatype::F32 && candidate != Datatype::F16)+ if (candidate != Datatype::F32 && candidate != Datatype::F16) {return current;+ }return BytesPerElement(candidate) < BytesPerElement(current) ? candidate : current;};@@ -123,8 +128,8 @@ JitConstants NonMaxSuppressionKernelRef::GetJitConstants(const non_max_suppressithrow std::invalid_argument("NMS input0 type should be one of F32 or F16.");}- jit.AddConstants({MakeJitConstant("SORT_RESULT_DESCENDING", params.sort_result_descending),- MakeJitConstant("BOX_ENCODING", static_cast<int>(params.box_encoding))});+ jit.AddConstants(+ {MakeJitConstant("SORT_RESULT_DESCENDING", params.sort_result_descending), MakeJitConstant("BOX_ENCODING", static_cast<int>(params.box_encoding))});jit.AddConstant(MakeJitConstant("OUTPUT_NUM", params.outputs[0].Batch().v));@@ -173,8 +178,9 @@ bool NonMaxSuppressionKernelRef::Validate(const Params& p) const {const non_max_suppression_params& params = static_cast<const non_max_suppression_params&>(p);for (const auto& fused_op : params.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}return true;@@ -188,44 +194,48 @@ bool NonMaxSuppressionKernelRef::Validate(const Params& p) const {* INTERNAL_BUFFER[2]: intermidiate_sorted_box_num**/-void NonMaxSuppressionKernelRef::SetKernelArguments(const non_max_suppression_params& params,- clKernelData& kernel, size_t idx) const {+void NonMaxSuppressionKernelRef::SetKernelArguments(const non_max_suppression_params& params, clKernelData& kernel, size_t idx) const {switch (idx) {case 0:- kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INPUT, 1 });- kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INTERNAL_BUFFER, 0 });- kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INTERNAL_BUFFER, 2 });- if (params.score_threshold_type == base_params::ArgType::Input)- kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INPUT, params.GetIndexScoreThreshold() });+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 1});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 2});+ if (params.score_threshold_type == base_params::ArgType::Input) {+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, params.GetIndexScoreThreshold()});+ }break;case 1:- kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INTERNAL_BUFFER, 0 });- kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INTERNAL_BUFFER, 2 });+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 2});break;case 2:- kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INPUT, 0 });- kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INTERNAL_BUFFER, 0 });- kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INTERNAL_BUFFER, 1 });- kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INTERNAL_BUFFER, 2 });-- if (params.num_select_per_class_type == base_params::ArgType::Input)- kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INPUT, params.GetIndexNumSelectPerClass() });- if (params.iou_threshold_type == base_params::ArgType::Input)- kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INPUT, params.GetIndexIouThreshold() });- if (params.score_threshold_type == base_params::ArgType::Input)- kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INPUT, params.GetIndexScoreThreshold() });- if (params.soft_nms_sigma_type == base_params::ArgType::Input)- kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INPUT, params.GetIndexSoftNmsSigma() });+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 2});++ if (params.num_select_per_class_type == base_params::ArgType::Input) {+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, params.GetIndexNumSelectPerClass()});+ }+ if (params.iou_threshold_type == base_params::ArgType::Input) {+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, params.GetIndexIouThreshold()});+ }+ if (params.score_threshold_type == base_params::ArgType::Input) {+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, params.GetIndexScoreThreshold()});+ }+ if (params.soft_nms_sigma_type == base_params::ArgType::Input) {+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, params.GetIndexSoftNmsSigma()});+ }break;case 3:- kernel.params.arguments.push_back({ ArgumentDescriptor::Types::OUTPUT, 0 });- kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INTERNAL_BUFFER, 1 });- kernel.params.arguments.push_back({ ArgumentDescriptor::Types::INTERNAL_BUFFER, 0 });+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::OUTPUT, 0});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});for (size_t i = 1; i < params.outputs.size(); i++) {- kernel.params.arguments.push_back({ ArgumentDescriptor::Types::OUTPUT, static_cast<uint32_t>(i) });+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::OUTPUT, static_cast<uint32_t>(i)});}break;@@ -245,7 +255,7 @@ KernelsData NonMaxSuppressionKernelRef::GetKernelsData(const Params& params) conconst non_max_suppression_params& orgParams = static_cast<const non_max_suppression_params&>(params);// Assign internel buffer- constexpr size_t intermediate_bytes = 12; // struct size of SortedBoxInfo/BoxInfo in non_max_suppression_gpu_ref.cl+ constexpr size_t intermediate_bytes = 12; // struct size of SortedBoxInfo/BoxInfo in non_max_suppression_gpu_ref.clauto batch_num = orgParams.inputs[1].Batch().v;auto class_num = orgParams.inputs[1].Feature().v;auto boxes_num = orgParams.inputs[0].Feature().v;@@ -269,16 +279,16 @@ KernelsData NonMaxSuppressionKernelRef::GetKernelsData(const Params& params) consize_t num_bit_mask = CeilDiv(boxes_num, 8);size_t num_score_per_item = RoundUp(CeilDiv(boxes_num, params.engineInfo.maxWorkGroupSize), 8);size_t num_score_block = CeilDiv(boxes_num, num_score_per_item);- cldnn_jit.AddConstants({ MakeJitConstant("NUM_BIT_MASK", num_bit_mask)- , MakeJitConstant("NUM_SCORE_PER_ITEM", num_score_per_item)- , MakeJitConstant("NUM_SCORE_BLOCK", num_score_block)});+ cldnn_jit.AddConstants({MakeJitConstant("NUM_BIT_MASK", num_bit_mask),+ MakeJitConstant("NUM_SCORE_PER_ITEM", num_score_per_item),+ MakeJitConstant("NUM_SCORE_BLOCK", num_score_block)});} else if (i == 1) {- cldnn_jit.AddConstants({ MakeJitConstant("LOCAL_BATCH_NUM", dispatchData.lws[0])- , MakeJitConstant("LOCAL_CLASS_NUM", dispatchData.lws[1])- , MakeJitConstant("LOCAL_WORK_NUM", dispatchData.lws[2])- , MakeJitConstant("PARTITION_STEP", GetPartitionStep(static_cast<int>(dispatchData.lws[2])))});+ cldnn_jit.AddConstants({MakeJitConstant("LOCAL_BATCH_NUM", dispatchData.lws[0]),+ MakeJitConstant("LOCAL_CLASS_NUM", dispatchData.lws[1]),+ MakeJitConstant("LOCAL_WORK_NUM", dispatchData.lws[2]),+ MakeJitConstant("PARTITION_STEP", GetPartitionStep(static_cast<int>(dispatchData.lws[2])))});} else if (i == 2 && orgParams.reuse_internal_buffer) {- cldnn_jit.AddConstant({ MakeJitConstant("REUSE_INTERNAL_BUFFER", 1)});+ cldnn_jit.AddConstant({MakeJitConstant("REUSE_INTERNAL_BUFFER", 1)});}cldnn_jit.AddConstant(MakeJitConstant("NMS_STAGE_" + std::to_string(i), "true"));@@ -286,7 +296,7 @@ KernelsData NonMaxSuppressionKernelRef::GetKernelsData(const Params& params) conauto& kernel = kd.kernels[i];KernelBase::CheckDispatchData(kernelName, dispatchData, params.engineInfo);kernel.params.workGroups.global = dispatchData.gws;- kernel.params.workGroups.local = dispatchData.lws;+ kernel.params.workGroups.local = dispatchData.lws;kernel.code.kernelString = GetKernelString(kernelName, jit, entry_point, params.engineInfo);SetKernelArguments(orgParams, kernel, i);}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/non_zero/count_nonzero_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/non_zero/count_nonzero_kernel_ref.cppindex 9169f4534cb..d7af3a2199a 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/non_zero/count_nonzero_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/non_zero/count_nonzero_kernel_ref.cpp@@ -112,8 +112,9 @@ KernelsPriority CountNonzeroKernelRef::GetKernelsPriority(const Params& /*params}bool CountNonzeroKernelRef::Validate(const Params& p) const {- if (!KernelBaseOpenCL::Validate(p))+ if (!KernelBaseOpenCL::Validate(p)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const auto& rp = static_cast<const count_nonzero_params&>(p);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/non_zero/gather_nonzero_kernel_group.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/non_zero/gather_nonzero_kernel_group.cppindex deb1e4ddfad..c5c8d90467e 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/non_zero/gather_nonzero_kernel_group.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/non_zero/gather_nonzero_kernel_group.cpp@@ -118,8 +118,9 @@ KernelsPriority GatherNonzeroKernelGroup::GetKernelsPriority(const Params& /*par}bool GatherNonzeroKernelGroup::Validate(const Params& p) const {- if (!KernelBaseOpenCL::Validate(p))+ if (!KernelBaseOpenCL::Validate(p)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/non_zero/gather_nonzero_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/non_zero/gather_nonzero_kernel_ref.cppindex 49d86062186..d8078142683 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/non_zero/gather_nonzero_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/non_zero/gather_nonzero_kernel_ref.cpp@@ -115,8 +115,9 @@ KernelsPriority GatherNonzeroKernelRef::GetKernelsPriority(const Params& /*param}bool GatherNonzeroKernelRef::Validate(const Params& p) const {- if (!KernelBaseOpenCL::Validate(p))+ if (!KernelBaseOpenCL::Validate(p)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const auto& rp = static_cast<const gather_nonzero_params&>(p);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/normalize/normalize_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/normalize/normalize_kernel_base.cppindex d96a95c0a6e..22a3dfc4baa 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/normalize/normalize_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/normalize/normalize_kernel_base.cpp@@ -3,9 +3,11 @@//#include "normalize_kernel_base.h"-#include "kernel_selector_utils.h"+#include <vector>+#include "kernel_selector_utils.h"+namespace kernel_selector {JitConstants NormalizeKernelBase::GetJitConstants(const normalize_params& np) const {JitConstants jit = MakeBaseParamsJitConstants(np);@@ -20,9 +22,9 @@ JitConstants NormalizeKernelBase::GetJitConstants(const normalize_params& np) coauto activation_dt = GetActivationType(np);jit.Merge(MakeTypeJitConstants(activation_dt, "ACTIVATION"));if (!np.fused_ops.empty()) {- std::vector<std::string> idx_order = { "b", "f", "y", "x" };+ std::vector<std::string> idx_order = {"b", "f", "y", "x"};auto conf = FusedOpsConfiguration("", idx_order, "result", activation_dt);- jit.Merge(MakeFusedOpsJitConstants(np, { conf }));+ jit.Merge(MakeFusedOpsJitConstants(np, {conf}));}return jit;@@ -45,8 +47,9 @@ NormalizeKernelBase::DispatchData NormalizeKernelBase::SetDefault(const normalizKernelsData NormalizeKernelBase::GetCommonKernelsData(const Params& params) const {assert(params.GetType() == KernelType::NORMALIZE);- if (!Validate(params))+ if (!Validate(params)) {return {};+ }const normalize_params& orgParams = static_cast<const normalize_params&>(params);@@ -59,17 +62,7 @@ KernelsData NormalizeKernelBase::GetCommonKernelsData(const Params& params) consauto jit = CreateJit(kernelName, cldnn_jit, entry_point);auto& kernel = kd.kernels[0];- FillCLKernelData(kernel,- dispatchData,- params.engineInfo,- kernelName,- jit,- entry_point,- "",- false,- false,- 1,- GetFusedPrimitiveInputsCount(params));+ FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point, "", false, false, 1, GetFusedPrimitiveInputsCount(params));kernel.params.arguments.push_back({ArgumentDescriptor::Types::SCALE_TABLE, 0});@@ -80,16 +73,18 @@ bool NormalizeKernelBase::Validate(const Params& params) const {const normalize_params& orgParams = static_cast<const normalize_params&>(params);for (const auto& fused_op : orgParams.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }}return true;}Datatype NormalizeKernelBase::GetActivationType(const normalize_params& params) const {- if (params.outputs[0].GetDType() == Datatype::F16)+ if (params.outputs[0].GetDType() == Datatype::F16) {return Datatype::F16;+ }return Datatype::F32;}} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_base.cppindex a72a6bc4988..5e7c887614c 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_base.cpp@@ -19,8 +19,9 @@ bool PermuteKernelBase::Validate(const Params& p) const {}auto supported_dyn_layouts = {DataLayout::bfyx, DataLayout::bfzyx, DataLayout::bfwzyx, DataLayout::bfuwzyx, DataLayout::bfvuwzyx};- if (params.has_dynamic_tensors() && (!layout_is_one_of(params.inputs, supported_dyn_layouts) || !layout_is_one_of(params.outputs, supported_dyn_layouts)))+ if (params.has_dynamic_tensors() && (!layout_is_one_of(params.inputs, supported_dyn_layouts) || !layout_is_one_of(params.outputs, supported_dyn_layouts))) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_bfzyx_to_bfyxz.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_bfzyx_to_bfyxz.cppindex 25e56abd54f..a786a010153 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_bfzyx_to_bfyxz.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_bfzyx_to_bfyxz.cpp@@ -46,11 +46,13 @@ static inline bool IsMultipleDefaultTileSize(const size_t size) {static inline size_t GetTileSize(const permute_params& params) {// supports 4x4 or 8x8 tiling- if (!IsMultipleDefaultTileSize(params.inputs[0].X().v) || !IsMultipleDefaultTileSize(params.inputs[0].Z().v))+ if (!IsMultipleDefaultTileSize(params.inputs[0].X().v) || !IsMultipleDefaultTileSize(params.inputs[0].Z().v)) {return MIN_TILE_SIZE;+ }- if ((params.inputs[0].GetDType() == Datatype::INT64) || (params.outputs[0].GetDType() == Datatype::INT64))+ if ((params.inputs[0].GetDType() == Datatype::INT64) || (params.outputs[0].GetDType() == Datatype::INT64)) {return MIN_TILE_SIZE;+ }return DEFAULT_TILE_SIZE;}@@ -145,23 +147,27 @@ CommonDispatchData PermuteKernel_bfzyx_to_bfyxz::SetDefault(const permute_params}bool PermuteKernel_bfzyx_to_bfyxz::Validate(const Params& p) const {- if (!Parent::Validate(p)) DO_NOT_USE_THIS_KERNEL(p.layerID);+ if (!Parent::Validate(p)) { DO_NOT_USE_THIS_KERNEL(p.layerID);+ }std::function<bool(const std::vector<uint16_t>&)> is_rotating_coords = [](const std::vector<uint16_t>& order) {const std::vector<uint16_t> expected_order {0, 1, 4, 2, 3};if (order.size() != expected_order.size()) return false;- for (size_t i{}; i < order.size(); ++i)+ for (size_t i{}; i < order.size(); ++i) {if (order[i] != expected_order[i]) return false;+ }return true;};const permute_params& params = static_cast<const permute_params&>(p);- if (!is_rotating_coords(params.order))+ if (!is_rotating_coords(params.order)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (params.outputs[0].PitchesDifferFromLogicalDims() || params.inputs[0].PitchesDifferFromLogicalDims())+ if (params.outputs[0].PitchesDifferFromLogicalDims() || params.inputs[0].PitchesDifferFromLogicalDims()) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_f_y_axes.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_f_y_axes.cppindex 080a8cf3b79..9b3e93b303c 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_f_y_axes.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_f_y_axes.cpp@@ -20,8 +20,9 @@ constexpr size_t c3DTransposeBufHeight = 4UL;size_t GetDivisor(const size_t input_size) {for (size_t d : {16, 8, 4, 2}) {- if (input_size % d == 0)+ if (input_size % d == 0) {return d;+ }}return 1; // Fallback: Any integer divides evenly by 1@@ -68,8 +69,9 @@ size_t GetTileWidth(const permute_params& params) {if ((input_type == Datatype::INT64) || (output_type == Datatype::INT64)) {size_t halved = min_divisor >= 4 ? min_divisor / 2 : min_divisor;const auto& supported = params.engineInfo.supportedSimdSizes;- if (std::any_of(supported.begin(), supported.end(), [halved](size_t s) { return s == halved; }) || supported.empty())+ if (std::any_of(supported.begin(), supported.end(), [halved](size_t s) { return s == halved; }) || supported.empty()) {min_divisor = halved;+ }}if (input_type == Datatype::F16 || input_type == Datatype::BF16) {min_divisor = min_divisor * 2;diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_ref.cppindex 9572cf392d4..c8bcf5781c2 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_ref.cpp@@ -152,14 +152,16 @@ CommonDispatchData PermuteKernelRef::SetDefault(const permute_params& params) co}bool PermuteKernelRef::Validate(const Params& p) const {- if (!Parent::Validate(p)) DO_NOT_USE_THIS_KERNEL(p.layerID);+ if (!Parent::Validate(p)) { DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const permute_params& params = static_cast<const permute_params&>(p);auto in_rank = params.inputs[0].GetDims().size();auto out_rank = params.outputs[0].GetDims().size();- if (in_rank != out_rank && (in_rank > 6 || out_rank > 6))+ if (in_rank != out_rank && (in_rank > 6 || out_rank > 6)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_tile_8x8_4x4.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_tile_8x8_4x4.cppindex 4be24c45d82..6e530f80ee5 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_tile_8x8_4x4.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_tile_8x8_4x4.cpp@@ -48,12 +48,14 @@ ParamsKey PermuteKernel_tile_8x8_4x4::GetSupportedKey() const {static inline size_t GetTileSize(const permute_params& params) {// supports 4x4 or 8x8 tilingif (!params.is_shape_agnostic) {- if (params.inputs[0].X().v < DEFAULT_TILE_SIZE || params.inputs[0].Feature().v < DEFAULT_TILE_SIZE)+ if (params.inputs[0].X().v < DEFAULT_TILE_SIZE || params.inputs[0].Feature().v < DEFAULT_TILE_SIZE) {return MIN_TILE_SIZE;+ }}- if ((params.inputs[0].GetDType() == Datatype::INT64) || (params.outputs[0].GetDType() == Datatype::INT64))+ if ((params.inputs[0].GetDType() == Datatype::INT64) || (params.outputs[0].GetDType() == Datatype::INT64)) {return MIN_TILE_SIZE;+ }return DEFAULT_TILE_SIZE;}@@ -270,7 +272,8 @@ CommonDispatchData PermuteKernel_tile_8x8_4x4::SetDefault(const permute_params&}bool PermuteKernel_tile_8x8_4x4::Validate(const Params& p) const {- if (!Parent::Validate(p)) DO_NOT_USE_THIS_KERNEL(p.layerID);+ if (!Parent::Validate(p)) { DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const permute_params& params = static_cast<const permute_params&>(p);@@ -297,15 +300,17 @@ bool PermuteKernel_tile_8x8_4x4::Validate(const Params& p) const {std::function<bool(const permute_params&)> has_fused_op = [] (const permute_params& params) {if (!params.fused_ops.empty()) {for (auto f : params.fused_ops) {- if (f.GetType() != KernelType::REORDER)+ if (f.GetType() != KernelType::REORDER) {return true;+ }}}return false;};- if (has_fused_op(params) && params.inputs[0].GetDims().size() != params.outputs[0].GetDims().size())+ if (has_fused_op(params) && params.inputs[0].GetDims().size() != params.outputs[0].GetDims().size()) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_tile_8x8_4x4_fsv.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_tile_8x8_4x4_fsv.cppindex f08cdb53515..c32c87ab8f5 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_tile_8x8_4x4_fsv.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_tile_8x8_4x4_fsv.cpp@@ -294,7 +294,8 @@ CommonDispatchData PermuteKernel_tile_8x8_4x4_fsv::SetDefault(const permute_para// Validate is the same as permute_kernel_tile_8x8_4x4bool PermuteKernel_tile_8x8_4x4_fsv::Validate(const Params& p) const {- if (!Parent::Validate(p)) DO_NOT_USE_THIS_KERNEL(p.layerID);+ if (!Parent::Validate(p)) { DO_NOT_USE_THIS_KERNEL(p.layerID);+ }std::function<bool(const std::vector<uint16_t>&)> is_rotating_except_batch = [](const std::vector<uint16_t>& order) {// Target transform: Rotate feature dim to back to be taken as inner-most axis@@ -316,8 +317,9 @@ bool PermuteKernel_tile_8x8_4x4_fsv::Validate(const Params& p) const {(params.inputs[0].GetLayout() == DataLayout::b_fs_yx_fsv32)) {if (params.outputs[0].GetLayout() != DataLayout::bfyx&& params.outputs[0].GetLayout() != DataLayout::bfzyx- && params.outputs[0].GetLayout() != DataLayout::bfwzyx)+ && params.outputs[0].GetLayout() != DataLayout::bfwzyx) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }} else if ((params.inputs[0].GetLayout() == DataLayout::b_fs_zyx_fsv16) ||(params.inputs[0].GetLayout() == DataLayout::b_fs_zyx_fsv32)) {if (params.outputs[0].GetLayout() != DataLayout::bfyxdiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_xy_swap.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_xy_swap.cppindex 7f16a522e01..f5a8d716a1e 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_xy_swap.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/permute/permute_kernel_xy_swap.cpp@@ -30,8 +30,9 @@ size_t PickTileSize(const permute_params& params) {const auto pick_tile = [x, y](const auto& candidates) -> size_t {for (const auto t : candidates) {- if ((x % t) == 0 && (y % t) == 0)+ if ((x % t) == 0 && (y % t) == 0) {return t;+ }}return 0; // no tile size applies};@@ -62,8 +63,9 @@ TilePlan PlanTile(const permute_params& params) {bool IsXYSwapOrder(const std::vector<uint16_t>& order) {// 4D only, last two dims swapped, others identity.// cldnn order produced from IE {0,1,3,2} is also {0,1,3,2} for 4D inputs.- if (order.size() != 4)+ if (order.size() != 4) {return false;+ }return order[0] == 0 && order[1] == 1 && order[2] == 3 && order[3] == 2;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_base.cppindex d61b2c9216e..96ee235200e 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_base.cpp@@ -3,6 +3,7 @@//#include "pooling_kernel_base.h"+#include <algorithm>namespace kernel_selector {@@ -14,12 +15,14 @@ bool PoolingKernelBase::Validate(const Params& p) const {const auto& params = dynamic_cast<const pooling_params&>(p);for (const auto& fused_op : params.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}- if (params.inputs[0].Dimentions() > 5)+ if (params.inputs[0].Dimentions() > 5) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}@@ -46,12 +49,12 @@ Datatype PoolingKernelBase::GetAccumulatorType(const pooling_params& params) con}Datatype PoolingKernelBase::GetActivationType(const pooling_params& params) const {- if (params.outputs[0].GetDType() == Datatype::F16)+ if (params.outputs[0].GetDType() == Datatype::F16) {return Datatype::F16;+ }return Datatype::F32;}-JitConstants PoolingKernelBase::GetJitConstants(const pooling_params& pp, PoolingKernelBase::DispatchData dispatchData) const {JitConstants mem_consts = MakeBaseParamsJitConstants(pp);@@ -124,15 +127,13 @@ bool PoolingKernelBase::NeedsBoundaryCheck(const pooling_params& pp) const {bool PoolingKernelBase::EnableRound(const kernel_selector::pooling_params& params) const {bool has_fused_quantize_to_int8 = false;for (const auto& op : params.fused_ops) {- if (op.GetType() == FusedOpType::QUANTIZE &&- (op.output_tensor.GetDType() == Datatype::INT8 || op.output_tensor.GetDType() == Datatype::UINT8)) {+ if (op.GetType() == FusedOpType::QUANTIZE && (op.output_tensor.GetDType() == Datatype::INT8 || op.output_tensor.GetDType() == Datatype::UINT8)) {has_fused_quantize_to_int8 = true;}}- return !has_fused_quantize_to_int8 &&- (params.outputs[0].GetDType() == Datatype::INT8 || params.outputs[0].GetDType() == Datatype::UINT8) &&- params.poolType == PoolType::AVG;+ return !has_fused_quantize_to_int8 && (params.outputs[0].GetDType() == Datatype::INT8 || params.outputs[0].GetDType() == Datatype::UINT8) &&+ params.poolType == PoolType::AVG;}PoolingKernelBase::DispatchData PoolingKernelBase::SetDefault(const pooling_params& params) const {@@ -140,11 +141,9 @@ PoolingKernelBase::DispatchData PoolingKernelBase::SetDefault(const pooling_paraDispatchData dispatchData;- if (output.GetLayout() == DataLayout::bfyx || output.GetLayout() == DataLayout::b_fs_yx_fsv4 ||- output.GetLayout() == DataLayout::byxf ||+ if (output.GetLayout() == DataLayout::bfyx || output.GetLayout() == DataLayout::b_fs_yx_fsv4 || output.GetLayout() == DataLayout::byxf ||output.GetLayout() == DataLayout::bfzyx || output.GetLayout() == DataLayout::b_fs_zyx_fsv16 ||- output.GetLayout() == DataLayout::bs_fs_zyx_bsv16_fsv16 ||- output.GetLayout() == DataLayout::bs_fs_zyx_bsv16_fsv32 ||+ output.GetLayout() == DataLayout::bs_fs_zyx_bsv16_fsv16 || output.GetLayout() == DataLayout::bs_fs_zyx_bsv16_fsv32 ||output.GetLayout() == DataLayout::bs_fs_zyx_bsv32_fsv32) {// Determine global work sizes.dispatchData.gws[0] = Align(output.X().v, 32); // X@@ -198,7 +197,16 @@ KernelsData PoolingKernelBase::GetCommonKernelsData(const Params& params) constauto jit = CreateJit(kernelName, cldnn_jit, entry_point);auto& kernel = kd.kernels[0];- FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point, EXE_MODE_DEFAULT, false, false, 1,+ FillCLKernelData(kernel,+ dispatchData,+ params.engineInfo,+ kernelName,+ jit,+ entry_point,+ EXE_MODE_DEFAULT,+ false,+ false,+ 1,GetFusedPrimitiveInputsCount(params));if (orgParams.maxPoolOpset8Features) {diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_b_fs_yx_fsv16.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_b_fs_yx_fsv16.cppindex ee8cb046d9e..98e8ac5ef38 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_b_fs_yx_fsv16.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_b_fs_yx_fsv16.cpp@@ -37,18 +37,21 @@ DeviceFeaturesKey PoolingKernel_b_fs_yx_fsv16::get_required_device_features_key(}size_t PoolingKernel_b_fs_yx_fsv16::GetBlockSize(const pooling_params& params) const {- if (params.outputs[0].X().v > 4)+ if (params.outputs[0].X().v > 4) {return 8;- if (params.outputs[0].X().v > 1)+ }+ if (params.outputs[0].X().v > 1) {return 2;+ }return 1;}size_t PoolingKernel_b_fs_yx_fsv16::GetSimdSize(const pooling_params& params) const {const auto& out = params.outputs[0];// Use smaller simd size in case of global pooling and small channels count to have more threads- if (out.X().v == 1 && out.Y().v == 1 && out.Feature().v < 64 && IsSIMDSizeSupported(params.engineInfo, 8))+ if (out.X().v == 1 && out.Y().v == 1 && out.Feature().v < 64 && IsSIMDSizeSupported(params.engineInfo, 8)) {return 8;+ }return 16;}@@ -117,23 +120,23 @@ JitConstants PoolingKernel_b_fs_yx_fsv16::GetJitConstants(const pooling_params&if (!params.fused_ops.empty()) {auto input_dt = GetActivationType(params);FusedOpsConfiguration conf_vec = {"_VEC",- {"b", "(f_block*FEATURE_SLICE_SIZE + f_val*SUB_GROUP_SIZE)", "y", "x"},- "pool_result",- input_dt,- x_block_size,- LoadType::LT_ALIGNED_READ,- BoundaryCheck::ENABLED,- IndexType::TENSOR_COORD,- Tensor::DataChannelName::X};+ {"b", "(f_block*FEATURE_SLICE_SIZE + f_val*SUB_GROUP_SIZE)", "y", "x"},+ "pool_result",+ input_dt,+ x_block_size,+ LoadType::LT_ALIGNED_READ,+ BoundaryCheck::ENABLED,+ IndexType::TENSOR_COORD,+ Tensor::DataChannelName::X};FusedOpsConfiguration conf_scalar = {"_SCALAR",- {"b", "(f_block*FEATURE_SLICE_SIZE + f_val*SUB_GROUP_SIZE)", "y", "(x+i)"},- "pool_result[i]",- input_dt,- 1,- LoadType::LT_ALIGNED_READ,- BoundaryCheck::ENABLED,- IndexType::TENSOR_COORD,- Tensor::DataChannelName::X};+ {"b", "(f_block*FEATURE_SLICE_SIZE + f_val*SUB_GROUP_SIZE)", "y", "(x+i)"},+ "pool_result[i]",+ input_dt,+ 1,+ LoadType::LT_ALIGNED_READ,+ BoundaryCheck::ENABLED,+ IndexType::TENSOR_COORD,+ Tensor::DataChannelName::X};jit.Merge(MakeFusedOpsJitConstants(params, {conf_vec, conf_scalar}));}@@ -149,8 +152,9 @@ bool PoolingKernel_b_fs_yx_fsv16::Validate(const Params& p) const {const auto feature_block_size = 16;// Check that padding features doesn't miss-align the blocks- if (params.inputs[0].Feature().pad.before % feature_block_size != 0 || params.outputs[0].Feature().pad.before % feature_block_size != 0)+ if (params.inputs[0].Feature().pad.before % feature_block_size != 0 || params.outputs[0].Feature().pad.before % feature_block_size != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_b_fs_zyx_fsv16_imad.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_b_fs_zyx_fsv16_imad.cppindex d7c3f231c19..1d4513a7593 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_b_fs_zyx_fsv16_imad.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_b_fs_zyx_fsv16_imad.cpp@@ -100,20 +100,23 @@ JitConstants PoolingKernelGPU_b_fs_zyx_fsv16_imad::GetJitConstants(const poolingsize_t unrollX = 1;size_t unrollY = 1;size_t unrollZ = 1;- if (in_size_x < maxUnrollSize)+ if (in_size_x < maxUnrollSize) {unrollX = in_size_x;- else if (in_size_x % maxUnrollSize == 0)+ } else if (in_size_x % maxUnrollSize == 0) {unrollX = maxUnrollSize;+ }maxUnrollSize /= unrollX;- if (in_size_y < maxUnrollSize)+ if (in_size_y < maxUnrollSize) {unrollY = in_size_y;- else if (in_size_y % maxUnrollSize == 0)+ } else if (in_size_y % maxUnrollSize == 0) {unrollY = maxUnrollSize;+ }maxUnrollSize /= unrollY;- if (in_size_z < maxUnrollSize)+ if (in_size_z < maxUnrollSize) {unrollZ = in_size_z;- else if (in_size_z % maxUnrollSize == 0)+ } else if (in_size_z % maxUnrollSize == 0) {unrollZ = maxUnrollSize;+ }maxUnrollSize /= unrollZ;jit.AddConstant(MakeJitConstant("UNROLL_X", unrollX));jit.AddConstant(MakeJitConstant("UNROLL_Y", unrollY));@@ -123,8 +126,9 @@ JitConstants PoolingKernelGPU_b_fs_zyx_fsv16_imad::GetJitConstants(const poolingjit.AddConstant(MakeJitConstant("IN_Z_PITCH", in_z_pitch));jit.Merge(MakeTypeJitConstants(GetActivationType(params), "ACTIVATION"));jit.Merge(MakeTypeJitConstants(GetAccumulatorType(params), "ACCUMULATOR"));- if (IsGlobalPooling(params))+ if (IsGlobalPooling(params)) {jit.AddConstant(MakeJitConstant("GLOBAL_POOLING", 1));+ }if (!params.fused_ops.empty()) {auto input_dt = EnableRound(params) ? Datatype::INT32 : GetActivationType(params);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_bs_fs_yx_bsv16_fsv16.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_bs_fs_yx_bsv16_fsv16.cppindex f06c7f66d60..c3058854426 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_bs_fs_yx_bsv16_fsv16.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_bs_fs_yx_bsv16_fsv16.cpp@@ -87,11 +87,13 @@ bool Pooling_kernel_gpu_bs_fs_yx_bsv_16_fsv16::Validate(const Params& params) co}auto p = dynamic_cast<const pooling_params&>(params);- if (p.inputs[0].Feature().v % 16 != 0)+ if (p.inputs[0].Feature().v % 16 != 0) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }- if (p.inputs[0].Batch().v % 16 != 0)+ if (p.inputs[0].Batch().v % 16 != 0) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_bsv16_fsv16.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_bsv16_fsv16.cppindex b9c21ef875e..5671a707b45 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_bsv16_fsv16.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_bsv16_fsv16.cpp@@ -78,11 +78,13 @@ bool PoolingKernel_bsv16_fsv16::Validate(const Params& p) const {const auto& input = params.inputs[0];const auto& output = params.outputs[0];- if (output.Batch().v % batch_block_size != 0 || output.Feature().v % feature_block_size != 0)+ if (output.Batch().v % batch_block_size != 0 || output.Feature().v % feature_block_size != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (input.Batch().v % batch_block_size != 0 || input.Feature().v % feature_block_size != 0)+ if (input.Batch().v % batch_block_size != 0 || input.Feature().v % feature_block_size != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }// Check that padding before features doesn't miss-align the blocksif (input.Feature().pad.before % feature_block_size != 0 || output.Feature().pad.before % feature_block_size != 0 ||diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_byxf_padding_opt.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_byxf_padding_opt.cppindex a91b82ff434..f0103db90b2 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_byxf_padding_opt.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_byxf_padding_opt.cpp@@ -56,8 +56,9 @@ bool PoolingKernelGPUByxfPaddingOpt::Validate(const Params& p) const {}const pooling_params& params = static_cast<const pooling_params&>(p);- if (params.inputs[0].Feature().v % 8 != 0)+ if (params.inputs[0].Feature().v % 8 != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_fs_b_yx_fsv32.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_fs_b_yx_fsv32.cppindex 596b98492a0..cdb0acf8bbd 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_fs_b_yx_fsv32.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_fs_b_yx_fsv32.cpp@@ -50,17 +50,20 @@ PoolingKernelBase::DispatchData PoolingKerneGPU_fs_b_yx_fsv32::SetDefault(const}bool PoolingKerneGPU_fs_b_yx_fsv32::Validate(const Params& p) const {- if (!PoolingKernelBase::Validate(p))+ if (!PoolingKernelBase::Validate(p)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }auto pp = static_cast<const pooling_params&>(p);// Feature padding before must be aligned to 32 to keep slices aligned- if (pp.outputs[0].Feature().pad.before % 32 != 0)+ if (pp.outputs[0].Feature().pad.before % 32 != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (pp.inputs[0].Feature().pad.before % 32 != 0)+ if (pp.inputs[0].Feature().pad.before % 32 != 0) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_int8_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_int8_ref.cppindex 20531a97037..84c94230097 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_int8_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/pooling/pooling_kernel_gpu_int8_ref.cpp@@ -93,8 +93,9 @@ bool PoolingKernelGPUInt8Ref::Validate(const Params& params) const {if (p.inputs[0].GetDType() == Datatype::INT8 || p.inputs[0].GetDType() == Datatype::UINT8) {// Max pooling doesn't change quantization ranges, so output data type should be the same as inputif (p.poolType == PoolType::MAX && p.outputs[0].GetDType() != p.inputs[0].GetDType() &&- p.quantization == QuantizationType::NONE)+ p.quantization == QuantizationType::NONE) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }// Average pooling should produce FP by default. (u)int8 is possible when quantize op is fused.// if (p.poolType == PoolType::AVG &&// !((p.outputs[0].GetDType() == p.inputs[0].GetDType() && !p.fused_ops.empty()) ||diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/quantize/quantize_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/quantize/quantize_kernel_base.cppindex 7da69bdd350..26cd164cfba 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/quantize/quantize_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/quantize/quantize_kernel_base.cpp@@ -11,8 +11,9 @@ namespace kernel_selector {bool QuantizeKernelBase::Validate(const Params& p) const {const quantize_params& params = static_cast<const quantize_params&>(p);- if (params.inputs.size() != 5)+ if (params.inputs.size() != 5) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/quantize/quantize_kernel_params.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/quantize/quantize_kernel_params.hindex 3b5a130a5c6..2156f476758 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/quantize/quantize_kernel_params.h+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/quantize/quantize_kernel_params.h@@ -63,8 +63,9 @@ struct quantize_params : public base_params {ParamsKey GetParamsKey() const override {auto k = base_params::GetParamsKey();- if (scale_shift_opt)+ if (scale_shift_opt) {k.EnableQuantizeScaleShiftOpt();+ }return k;}};diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/quantize/quantize_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/quantize/quantize_kernel_ref.cppindex 21cca54ca32..2eb80a8fa17 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/quantize/quantize_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/quantize/quantize_kernel_ref.cpp@@ -65,8 +65,9 @@ JitConstants QuantizeKernelRef::GetJitConstants(const quantize_params& params, cbool QuantizeKernelRef::Validate(const Params& p) const {const quantize_params& params = static_cast<const quantize_params&>(p);- if (params.inputs.size() != 5)+ if (params.inputs.size() != 5) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/quantize/quantize_kernel_scale_shift_opt.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/quantize/quantize_kernel_scale_shift_opt.cppindex 7307a54bdd9..4722672d7fb 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/quantize/quantize_kernel_scale_shift_opt.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/quantize/quantize_kernel_scale_shift_opt.cpp@@ -118,8 +118,9 @@ JitConstants QuantizeKernelScaleShift::GetJitConstants(const quantize_params& pabool QuantizeKernelScaleShift::Validate(const Params& p) const {const quantize_params& params = static_cast<const quantize_params&>(p);- if (params.inputs.size() != 9)+ if (params.inputs.size() != 9) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/quantize/quantize_kernel_scale_shift_vload8_opt.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/quantize/quantize_kernel_scale_shift_vload8_opt.cppindex b9178a41cfe..9fc7a041bdd 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/quantize/quantize_kernel_scale_shift_vload8_opt.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/quantize/quantize_kernel_scale_shift_vload8_opt.cpp@@ -80,23 +80,25 @@ JitConstants QuantizeKernelScaleShift_vload8::GetJitConstants(const quantize_parbool QuantizeKernelScaleShift_vload8::Validate(const Params& p) const {const quantize_params& params = static_cast<const quantize_params&>(p);- if (params.inputs.size() != 9)+ if (params.inputs.size() != 9) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }// this kernel is opt for per tensor quantization params for nowif (!params.per_tensor_input_range || !params.per_tensor_output_range || !params.per_tensor_input_scale ||!params.per_tensor_output_scale || !params.per_tensor_output_shift ||(params.has_pre_shift && !params.per_tensor_input_shift) ||params.outputs[0].GetLayout() != params.inputs[0].GetLayout() ||- params.inputs[1].GetDType() != params.inputs[3].GetDType())+ params.inputs[1].GetDType() != params.inputs[3].GetDType()) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }// for blocked format, if extra padding exist in a block, will be opt in a seprate kernelif (!params.inputs[0].SimpleLayout()) {const auto input_layout = params.inputs[0].GetLayout();const auto batch_size = params.inputs[0].Batch().v;const auto feature_size = params.inputs[0].Feature().v;- if (!params.inputs[0].SimpleLayout())+ if (!params.inputs[0].SimpleLayout()) {if (((input_layout == DataLayout::b_fs_yx_fsv16 || input_layout == DataLayout::b_fs_zyx_fsv16) &&feature_size % 16 != 0) ||((input_layout == DataLayout::b_fs_yx_fsv32 || input_layout == DataLayout::b_fs_zyx_fsv32) &&@@ -114,11 +116,14 @@ bool QuantizeKernelScaleShift_vload8::Validate(const Params& p) const {(feature_size % 16 != 0 || batch_size % 16 != 0)) ||((input_layout == DataLayout::bs_fs_yx_bsv16_fsv32 ||input_layout == DataLayout::bs_fs_zyx_bsv16_fsv32) &&- (feature_size % 32 != 0 || batch_size % 16 != 0)))+ (feature_size % 32 != 0 || batch_size % 16 != 0))) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }+ }}- if (CalculateTotalWorkItemCount(params) < vec_size)+ if (CalculateTotalWorkItemCount(params) < vec_size) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}@@ -128,10 +133,11 @@ static inline size_t CalculateTotalWorkItemCount(const quantize_params& params)auto feature = Align(params.outputs[0].Feature().v, GetInnerFeatureBlockSize(params.outputs[0]));auto batch = Align(params.outputs[0].Batch().v, GetInnerBatchBlockSize(params.outputs[0]));size_t spatial = 0;- if (DataTensor::ChannelsCount(params.outputs[0].GetLayout()) == 5)+ if (DataTensor::ChannelsCount(params.outputs[0].GetLayout()) == 5) {spatial = params.outputs[0].X().v * params.outputs[0].Y().v * params.outputs[0].Z().v;- else+ } else {spatial = params.outputs[0].X().v * params.outputs[0].Y().v;+ }return (feature * batch * spatial);}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/range/range_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/range/range_kernel_ref.cppindex 476a4129305..ff0bc8515f2 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/range/range_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/range/range_kernel_ref.cpp@@ -10,11 +10,11 @@ namespace kernel_selector {namespace {-CommonDispatchData SetDefault(const range_params ¶ms) {+CommonDispatchData SetDefault(const range_params& params) {CommonDispatchData dispatchData;const auto& out = params.outputs[0];- dispatchData.gws = { 1, 1, out.Batch().v * out.Feature().v * out.X().v * out.Y().v * out.W().v * out.Z().v }; // TODO: these could be split better+ dispatchData.gws = {1, 1, out.Batch().v * out.Feature().v * out.X().v * out.Y().v * out.W().v * out.Z().v}; // TODO: these could be split betterdispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo);return dispatchData;@@ -33,9 +33,10 @@ void RangeKernelRef::GetUpdateDispatchDataFunc(KernelData& kd) const {};}-KernelsData RangeKernelRef::GetKernelsData(const Params ¶ms) const {- if (!Validate(params))+KernelsData RangeKernelRef::GetKernelsData(const Params& params) const {+ if (!Validate(params)) {return {};+ }KernelData kernel_data = KernelData::Default<range_params>(params);const auto& prim_params = static_cast<const range_params&>(params);@@ -47,13 +48,12 @@ KernelsData RangeKernelRef::GetKernelsData(const Params ¶ms) const {GetUpdateDispatchDataFunc(kernel_data);- auto &clKernelData = kernel_data.kernels[0];+ auto& clKernelData = kernel_data.kernels[0];bool is_dynamic = prim_params.has_dynamic_tensors();- FillCLKernelData(clKernelData, dispatch_data, params.engineInfo, kernelName, jit, entry_point,- EXE_MODE_DEFAULT, false, false, 3, 0, 1, is_dynamic);+ FillCLKernelData(clKernelData, dispatch_data, params.engineInfo, kernelName, jit, entry_point, EXE_MODE_DEFAULT, false, false, 3, 0, 1, is_dynamic);- auto &arguments = clKernelData.params.arguments;- arguments.erase(arguments.begin() + 1 + static_cast<int>(is_dynamic)); // stop is not used by kernel+ auto& arguments = clKernelData.params.arguments;+ arguments.erase(arguments.begin() + 1 + static_cast<int>(is_dynamic)); // stop is not used by kernelreturn {kernel_data};}@@ -89,17 +89,21 @@ ParamsKey RangeKernelRef::GetSupportedKey() const {return k;}-bool RangeKernelRef::Validate(const Params &p) const {- if (p.GetType() != KernelType::RANGE)+bool RangeKernelRef::Validate(const Params& p) const {+ if (p.GetType() != KernelType::RANGE) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const auto& params = dynamic_cast<const range_params&>(p);- if (params.inputs.size() != 3)+ if (params.inputs.size() != 3) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- for (const auto& input : params.inputs)- if (input.LogicalSize() != 1)+ for (const auto& input : params.inputs) {+ if (input.LogicalSize() != 1) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/reduce/reduce_kernel_b_fs_yx_fsv16.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/reduce/reduce_kernel_b_fs_yx_fsv16.cppindex 74757b66a60..fd0c90cdd82 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/reduce/reduce_kernel_b_fs_yx_fsv16.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/reduce/reduce_kernel_b_fs_yx_fsv16.cpp@@ -19,12 +19,13 @@ using NDims = std::vector<kernel_selector::Tensor::Dim>;static size_t calc_read_offset(const reduce_params& params) {auto read_offset = 1;- if (BytesPerElement(params.inputs[0].GetDType()) == 4)+ if (BytesPerElement(params.inputs[0].GetDType()) == 4) {read_offset = 4;- else if (BytesPerElement(params.inputs[0].GetDType()) == 2)+ } else if (BytesPerElement(params.inputs[0].GetDType()) == 2) {read_offset = 8;- else if (BytesPerElement(params.inputs[0].GetDType()) == 1)+ } else if (BytesPerElement(params.inputs[0].GetDType()) == 1) {read_offset = 16;+ }return read_offset;}@@ -81,8 +82,9 @@ static bool can_opt_reduce_xy(const reduce_params& params) {static bool reducing_unaligned_f_axis(const reduce_params& params) {if (count(params.reduceAxes.begin(), params.reduceAxes.end(), AXIS_F) > 0) {- if (params.inputs[0].Feature().v % 16 != 0)+ if (params.inputs[0].Feature().v % 16 != 0) {return true;+ }}return false;diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/reduce/reduce_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/reduce/reduce_kernel_base.cppindex cc41c7733aa..be9c347bbe9 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/reduce/reduce_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/reduce/reduce_kernel_base.cpp@@ -3,10 +3,12 @@//#include "reduce_kernel_base.h"-#include "kernel_selector_utils.h"-#include <vector>+#include <string>+#include <vector>+#include "common_tools.h"+#include "kernel_selector_utils.h"namespace kernel_selector {@@ -18,8 +20,9 @@ bool ReduceKernelBase::Validate(const Params& p) const {}for (const auto& fused_op : params.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}return true;@@ -51,48 +54,78 @@ JitConstants ReduceKernelBase::GetJitConstants(const reduce_params& params) consauto getDimSizeNameByNum = [&](size_t dim) -> std::string {if (params.inputs[0].Dimentions() == 8) {switch (dim) {- case 0: return "BATCH_NUM";- case 1: return "FEATURE_NUM";- case 2: return "SIZE_V";- case 3: return "SIZE_U";- case 4: return "SIZE_W";- case 5: return "SIZE_Z";- case 6: return "SIZE_Y";- case 7: return "SIZE_X";+ case 0:+ return "BATCH_NUM";+ case 1:+ return "FEATURE_NUM";+ case 2:+ return "SIZE_V";+ case 3:+ return "SIZE_U";+ case 4:+ return "SIZE_W";+ case 5:+ return "SIZE_Z";+ case 6:+ return "SIZE_Y";+ case 7:+ return "SIZE_X";}} else if (params.inputs[0].Dimentions() == 7) {switch (dim) {- case 0: return "BATCH_NUM";- case 1: return "FEATURE_NUM";- case 2: return "SIZE_U";- case 3: return "SIZE_W";- case 4: return "SIZE_Z";- case 5: return "SIZE_Y";- case 6: return "SIZE_X";+ case 0:+ return "BATCH_NUM";+ case 1:+ return "FEATURE_NUM";+ case 2:+ return "SIZE_U";+ case 3:+ return "SIZE_W";+ case 4:+ return "SIZE_Z";+ case 5:+ return "SIZE_Y";+ case 6:+ return "SIZE_X";}- } else if (params.inputs[0].Dimentions() == 6) {+ } else if (params.inputs[0].Dimentions() == 6) {switch (dim) {- case 0: return "BATCH_NUM";- case 1: return "FEATURE_NUM";- case 2: return "SIZE_W";- case 3: return "SIZE_Z";- case 4: return "SIZE_Y";- case 5: return "SIZE_X";+ case 0:+ return "BATCH_NUM";+ case 1:+ return "FEATURE_NUM";+ case 2:+ return "SIZE_W";+ case 3:+ return "SIZE_Z";+ case 4:+ return "SIZE_Y";+ case 5:+ return "SIZE_X";}} else if (params.inputs[0].Dimentions() == 5) {switch (dim) {- case 0: return "BATCH_NUM";- case 1: return "FEATURE_NUM";- case 2: return "SIZE_Z";- case 3: return "SIZE_Y";- case 4: return "SIZE_X";+ case 0:+ return "BATCH_NUM";+ case 1:+ return "FEATURE_NUM";+ case 2:+ return "SIZE_Z";+ case 3:+ return "SIZE_Y";+ case 4:+ return "SIZE_X";}} else if (params.inputs[0].Dimentions() == 4) {switch (dim) {- case 0: return "BATCH_NUM";- case 1: return "FEATURE_NUM";- case 2: return "SIZE_Y";- case 3: return "SIZE_X";+ case 0:+ return "BATCH_NUM";+ case 1:+ return "FEATURE_NUM";+ case 2:+ return "SIZE_Y";+ case 3:+ return "SIZE_X";}}return "";@@ -104,16 +137,19 @@ JitConstants ReduceKernelBase::GetJitConstants(const reduce_params& params) consfor (size_t i = 0; i < params.reduceAxes.size(); ++i) {divider += "INPUT0_" + getDimSizeNameByNum(convertedAxes[i]);size_t range_check = i;- if (++range_check < params.reduceAxes.size())+ if (++range_check < params.reduceAxes.size()) {divider += "*";+ }}jit.AddConstant(MakeJitConstant("DIVIDER", divider));const size_t kept_dims = inputDims.size() - params.reduceAxes.size();if (kept_dims == 1) {- for (size_t i = 0; i < inputDims.size(); ++i)- if (std::find(convertedAxes.begin(), convertedAxes.end(), i) == convertedAxes.end())+ for (size_t i = 0; i < inputDims.size(); ++i) {+ if (std::find(convertedAxes.begin(), convertedAxes.end(), i) == convertedAxes.end()) {jit.AddConstant(MakeJitConstant(getDimSizeNameByNum(i) + "_IDX_COMP(index)", "index"));+ }+ }} else {size_t kept_cnt = 0;for (size_t i = 0; i < inputDims.size(); ++i) {@@ -128,8 +164,7 @@ JitConstants ReduceKernelBase::GetJitConstants(const reduce_params& params) consstr += ")";jit.AddConstant(MakeJitConstant(getDimSizeNameByNum(i) + "_IDX_COMP(index)", str));} else if (kept_cnt == kept_dims - 1) {- jit.AddConstant(MakeJitConstant(getDimSizeNameByNum(i) + "_IDX_COMP(index)",- "(index % INPUT0_" + getDimSizeNameByNum(i) + ")"));+ jit.AddConstant(MakeJitConstant(getDimSizeNameByNum(i) + "_IDX_COMP(index)", "(index % INPUT0_" + getDimSizeNameByNum(i) + ")"));} else {std::string str = "(index ";for (size_t j = i + 1; j < inputDims.size(); ++j) {@@ -147,30 +182,30 @@ JitConstants ReduceKernelBase::GetJitConstants(const reduce_params& params) consfor (size_t a = 0; a < params.reduceAxes.size(); a++) {switch (params.reduceAxes[a]) {- case 0:- jit.AddConstant(MakeJitConstant("REDUCE_BATCH", 1));- break;- case 1:- jit.AddConstant(MakeJitConstant("REDUCE_FEATURE", 1));- break;- case 2:- jit.AddConstant(MakeJitConstant("REDUCE_X", 1));- break;- case 3:- jit.AddConstant(MakeJitConstant("REDUCE_Y", 1));- break;- case 4:- jit.AddConstant(MakeJitConstant("REDUCE_Z", 1));- break;- case 5:- jit.AddConstant(MakeJitConstant("REDUCE_W", 1));- break;- case 6:- jit.AddConstant(MakeJitConstant("REDUCE_U", 1));- break;- case 7:- jit.AddConstant(MakeJitConstant("REDUCE_V", 1));- break;+ case 0:+ jit.AddConstant(MakeJitConstant("REDUCE_BATCH", 1));+ break;+ case 1:+ jit.AddConstant(MakeJitConstant("REDUCE_FEATURE", 1));+ break;+ case 2:+ jit.AddConstant(MakeJitConstant("REDUCE_X", 1));+ break;+ case 3:+ jit.AddConstant(MakeJitConstant("REDUCE_Y", 1));+ break;+ case 4:+ jit.AddConstant(MakeJitConstant("REDUCE_Z", 1));+ break;+ case 5:+ jit.AddConstant(MakeJitConstant("REDUCE_W", 1));+ break;+ case 6:+ jit.AddConstant(MakeJitConstant("REDUCE_U", 1));+ break;+ case 7:+ jit.AddConstant(MakeJitConstant("REDUCE_V", 1));+ break;}}@@ -201,10 +236,7 @@ Datatype ReduceKernelBase::GetAccumulatorType(const reduce_params& params) constDatatype ReduceKernelBase::GetFinalAccumulatorType(const reduce_params& params) const {const auto& reduce_mode = params.reduceMode;- if (reduce_mode == ReduceMode::MEAN ||- reduce_mode == ReduceMode::LOG_SUM_EXP ||- reduce_mode == ReduceMode::LOG_SUM ||- reduce_mode == ReduceMode::L2 ||+ if (reduce_mode == ReduceMode::MEAN || reduce_mode == ReduceMode::LOG_SUM_EXP || reduce_mode == ReduceMode::LOG_SUM || reduce_mode == ReduceMode::L2 ||reduce_mode == ReduceMode::L1) {return Datatype::F32;}@@ -212,8 +244,9 @@ Datatype ReduceKernelBase::GetFinalAccumulatorType(const reduce_params& params)}Datatype ReduceKernelBase::GetActivationType(const reduce_params& params) const {- if (params.outputs[0].GetDType() == Datatype::F16)+ if (params.outputs[0].GetDType() == Datatype::F16) {return Datatype::F16;+ }return Datatype::F32;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/reduce/reduce_kernel_simple_to_scalar.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/reduce/reduce_kernel_simple_to_scalar.cppindex fed846c3df9..45703285877 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/reduce/reduce_kernel_simple_to_scalar.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/reduce/reduce_kernel_simple_to_scalar.cpp@@ -58,17 +58,21 @@ ParamsKey ReduceKernelSimpleToScalar::GetSupportedKey() const {bool ReduceKernelSimpleToScalar::Validate(const Params& p) const {const reduce_params& params = static_cast<const reduce_params&>(p);- if (params.inputs.size() != 1 || params.outputs.size() != 1)+ if (params.inputs.size() != 1 || params.outputs.size() != 1) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (!params.inputs[0].SimpleLayout() || !params.outputs[0].SimpleLayout())+ if (!params.inputs[0].SimpleLayout() || !params.outputs[0].SimpleLayout()) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (params.inputs[0].LogicalSize() < params.engineInfo.maxWorkGroupSize)+ if (params.inputs[0].LogicalSize() < params.engineInfo.maxWorkGroupSize) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (params.outputs[0].LogicalSize() != 1)+ if (params.outputs[0].LogicalSize() != 1) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }std::set<ReduceMode> supported_modes = {ReduceMode::SUM,@@ -78,8 +82,9 @@ bool ReduceKernelSimpleToScalar::Validate(const Params& p) const {ReduceMode::MEAN,};- if (supported_modes.find(params.reduceMode) == supported_modes.end())+ if (supported_modes.find(params.reduceMode) == supported_modes.end()) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const auto& in_dims = params.inputs[0].GetDims();const auto& out_dims = params.outputs[0].GetDims();@@ -90,8 +95,9 @@ bool ReduceKernelSimpleToScalar::Validate(const Params& p) const {return d.pad.before > 0 || d.pad.after > 0;}) > 0;- if (has_padding)+ if (has_padding) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_from_winograd_2x3_kernel.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_from_winograd_2x3_kernel.cppindex 2878784c5fb..3003b2818bb 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_from_winograd_2x3_kernel.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_from_winograd_2x3_kernel.cpp@@ -27,8 +27,9 @@ JitConstants ReorderFromWinograd2x3Kernel::GetJitConstants(const reorder_params&constexpr auto output_tile_width = 2; // by definition of F(2,3)- if (params.outputs[0].X().v % output_tile_width != 0)+ if (params.outputs[0].X().v % output_tile_width != 0) {jit.AddConstant(MakeJitConstant("LEFTOVERS", 1));+ }return jit;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel.cppindex 518cad99bc5..6a5a8aa9517 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel.cpp@@ -58,8 +58,9 @@ JitConstants ReorderKernelRef::GetJitConstants(const reorder_params& params) con}jit.Merge(GetTensorFriendlyWorkGroupsJit(params.inputs[0]));- if (params.surface_input)+ if (params.surface_input) {jit.AddConstant(MakeJitConstant("SURFACE_INPUT", true));+ }if (!params.fused_ops.empty()) {std::vector<std::string> idx_order;diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_base.cppindex 9fdfa9ff6df..3d6f573f17b 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_base.cpp@@ -213,8 +213,9 @@ ReorderKernelBase::DispatchData ReorderKernelBase::SetDefault(const reorder_paraKernelsData ReorderKernelBase::GetCommonKernelsData(const reorder_weights_params& params) const {assert(params.GetType() == KernelType::REORDER);- if (!Validate(params))+ if (!Validate(params)) {return {};+ }KernelData kd = KernelData::Default<reorder_weights_params>(params);reorder_weights_params& newParams = *static_cast<reorder_weights_params*>(kd.params.get());diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_fast_b1.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_fast_b1.cppindex d8a918cab82..7aa4aac04ac 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_fast_b1.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_fast_b1.cpp@@ -53,11 +53,13 @@ bool ReorderKernelFastBatch1::Validate(const Params& p) const {const reorder_params& params = static_cast<const reorder_params&>(p);- if (params.outputs[0].GetLayout() == DataLayout::fs_b_yx_fsv32)+ if (params.outputs[0].GetLayout() == DataLayout::fs_b_yx_fsv32) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (params.inputs[0].GetLayout() == DataLayout::fs_b_yx_fsv32)+ if (params.inputs[0].GetLayout() == DataLayout::fs_b_yx_fsv32) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_fs_b_yx_fsv32_to_bfyx.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_fs_b_yx_fsv32_to_bfyx.cppindex 88e831a3126..9776b9fd76b 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_fs_b_yx_fsv32_to_bfyx.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_fs_b_yx_fsv32_to_bfyx.cpp@@ -14,9 +14,11 @@ static const std::vector<size_t> optimal_x_sizes = { 16, 8, 4, 2, 1 };static const std::vector<size_t> optimal_feature_sizes = { 16, 8, 1 };static size_t GetOptimalSize(size_t val, std::vector<size_t> optimal_sizes) {- for (auto& s : optimal_sizes)- if (val % s == 0)+ for (auto& s : optimal_sizes) {+ if (val % s == 0) {return s;+ }+ }return 1;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_to_yxfb_batched.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_to_yxfb_batched.cppindex 81a3db9f721..580e9d4345c 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_to_yxfb_batched.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_to_yxfb_batched.cpp@@ -36,8 +36,9 @@ bool ReorderKernel_to_yxfb_batched::Validate(const Params& params) const {DO_NOT_USE_THIS_KERNEL(params.layerID);}- if (!IsSIMDSizeSupported(params.engineInfo, 8))+ if (!IsSIMDSizeSupported(params.engineInfo, 8)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }const reorder_params& r_params = static_cast<const reorder_params&>(params);@@ -49,8 +50,9 @@ bool ReorderKernel_to_yxfb_batched::Validate(const Params& params) const {}if ((r_params.inputs[0].GetLayout() == DataLayout::b_fs_zyx_fsv16 || r_params.inputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv16_fsv16) &&- r_params.inputs[0].Z().v != 1)+ r_params.inputs[0].Z().v != 1) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_weights_opt.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_weights_opt.cppindex 51cb1034373..4b82e20714a 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_weights_opt.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_weights_opt.cpp@@ -3,6 +3,7 @@//#include "reorder_weights_opt.h"+#include "kernel_selector_utils.h"namespace kernel_selector {@@ -78,7 +79,7 @@ DeviceFeaturesKey ReorderWeightsOpt::get_required_device_features_key(const Parabool requires_blocked_read_write = false;const auto& casted_params = static_cast<const reorder_weights_params&>(params);- std::vector<WeightsType> tensor_types = {casted_params.input.GetDType(), casted_params.output.GetDType() };+ std::vector<WeightsType> tensor_types = {casted_params.input.GetDType(), casted_params.output.GetDType()};for (auto& type : tensor_types) {if (type == WeightsType::F16) {requires_blocked_read_write_short = true;@@ -89,14 +90,17 @@ DeviceFeaturesKey ReorderWeightsOpt::get_required_device_features_key(const Para}}- if (requires_blocked_read_write)+ if (requires_blocked_read_write) {k.requires_blocked_read_write();+ }- if (requires_blocked_read_write_short)+ if (requires_blocked_read_write_short) {k.requires_blocked_read_write_short();+ }- if (requires_blocked_read_write_char)+ if (requires_blocked_read_write_char) {k.requires_blocked_read_write_char();+ }k.requires_subgroups();@@ -104,80 +108,76 @@ DeviceFeaturesKey ReorderWeightsOpt::get_required_device_features_key(const Para}static inline std::pair<size_t, size_t> GetSliceSizes(WeightsLayout l) {- if (l == WeightsLayout::os_is_yx_isv16_osv16 || l == WeightsLayout::os_is_zyx_isv16_osv16 ||- l == WeightsLayout::g_os_is_yx_isv16_osv16 || l == WeightsLayout::g_os_is_zyx_isv16_osv16 ||- l == WeightsLayout::is_os_zyx_isv16_osv16 || l == WeightsLayout::is_os_yx_isv16_osv16 ||- l == WeightsLayout::os_is_yx_osv16_isv16 || l == WeightsLayout::g_os_zyx_is_osv16_isv16 ||- l == WeightsLayout::g_is_os_yx_isv16_osv16 || l == WeightsLayout::g_is_os_zyx_isv16_osv16)+ if (l == WeightsLayout::os_is_yx_isv16_osv16 || l == WeightsLayout::os_is_zyx_isv16_osv16 || l == WeightsLayout::g_os_is_yx_isv16_osv16 ||+ l == WeightsLayout::g_os_is_zyx_isv16_osv16 || l == WeightsLayout::is_os_zyx_isv16_osv16 || l == WeightsLayout::is_os_yx_isv16_osv16 ||+ l == WeightsLayout::os_is_yx_osv16_isv16 || l == WeightsLayout::g_os_zyx_is_osv16_isv16 || l == WeightsLayout::g_is_os_yx_isv16_osv16 ||+ l == WeightsLayout::g_is_os_zyx_isv16_osv16) {return {16, 16};- if (l == WeightsLayout::os_iyx_osv16 || l == WeightsLayout::g_os_iyx_osv16)+ }+ if (l == WeightsLayout::os_iyx_osv16 || l == WeightsLayout::g_os_iyx_osv16) {return {1, 16};- if (l == WeightsLayout::os_iyx_osv32 || l == WeightsLayout::g_os_iyx_osv32 || l == WeightsLayout::os_iyx_osv32__ai32)+ }+ if (l == WeightsLayout::os_iyx_osv32 || l == WeightsLayout::g_os_iyx_osv32 || l == WeightsLayout::os_iyx_osv32__ai32) {return {1, 32};- if (l == WeightsLayout::os_is_zyx_osv32_isv16 || l == WeightsLayout::g_os_zyx_is_osv32_isv16)+ }+ if (l == WeightsLayout::os_is_zyx_osv32_isv16 || l == WeightsLayout::g_os_zyx_is_osv32_isv16) {return {16, 32};- if (l == WeightsLayout::os_is_zyx_osv64_isv16)+ }+ if (l == WeightsLayout::os_is_zyx_osv64_isv16) {return {16, 64};- if (l == WeightsLayout::g_os_zyx_is_osv16_isv32)+ }+ if (l == WeightsLayout::g_os_zyx_is_osv16_isv32) {return {32, 16};- if (l == WeightsLayout::g_os_zyx_is_osv32_isv32)+ }+ if (l == WeightsLayout::g_os_zyx_is_osv32_isv32) {return {32, 32};+ }return {1, 1};}static inline bool IsOsvFirst(WeightsLayout l) {- return l == WeightsLayout::os_is_yx_isv16_osv16 || l == WeightsLayout::os_is_zyx_isv16_osv16 ||- l == WeightsLayout::g_os_is_yx_isv16_osv16 || l == WeightsLayout::g_os_is_zyx_isv16_osv16 ||- l == WeightsLayout::os_iyx_osv16 || l == WeightsLayout::g_os_iyx_osv16||- l == WeightsLayout::os_iyx_osv32 || l == WeightsLayout::g_os_iyx_osv32 ||- l == WeightsLayout::os_iyx_osv32__ai32 || l == WeightsLayout::is_os_yx_isv16_osv16 ||- l == WeightsLayout::is_os_zyx_isv16_osv16 || l == WeightsLayout::g_is_os_yx_isv16_osv16 ||- l == WeightsLayout::g_is_os_zyx_isv16_osv16;+ return l == WeightsLayout::os_is_yx_isv16_osv16 || l == WeightsLayout::os_is_zyx_isv16_osv16 || l == WeightsLayout::g_os_is_yx_isv16_osv16 ||+ l == WeightsLayout::g_os_is_zyx_isv16_osv16 || l == WeightsLayout::os_iyx_osv16 || l == WeightsLayout::g_os_iyx_osv16 ||+ l == WeightsLayout::os_iyx_osv32 || l == WeightsLayout::g_os_iyx_osv32 || l == WeightsLayout::os_iyx_osv32__ai32 ||+ l == WeightsLayout::is_os_yx_isv16_osv16 || l == WeightsLayout::is_os_zyx_isv16_osv16 || l == WeightsLayout::g_is_os_yx_isv16_osv16 ||+ l == WeightsLayout::g_is_os_zyx_isv16_osv16;}static inline size_t GetOptimalSize(size_t val, std::vector<size_t> optimal_sizes) {- for (auto& s : optimal_sizes)- if (val % s == 0)+ for (auto& s : optimal_sizes) {+ if (val % s == 0) {return s;+ }+ }return 1;}-ReorderWeightsOpt::DispatchData ReorderWeightsOpt::SetDefault(- const reorder_weights_params& params) const {+ReorderWeightsOpt::DispatchData ReorderWeightsOpt::SetDefault(const reorder_weights_params& params) const {DispatchData dispatchData;const auto& output = params.output;const auto output_layout = output.GetLayout();const auto subgroup_size = 16;- const auto ifm_block_supported = (output_layout != WeightsLayout::os_iyx_osv16 &&- output_layout != WeightsLayout::os_iyx_osv32 &&- output_layout != WeightsLayout::g_os_iyx_osv16 &&- output_layout != WeightsLayout::g_os_iyx_osv32 &&- output_layout != WeightsLayout::os_iyx_osv32__ai32);+ const auto ifm_block_supported =+ (output_layout != WeightsLayout::os_iyx_osv16 && output_layout != WeightsLayout::os_iyx_osv32 && output_layout != WeightsLayout::g_os_iyx_osv16 &&+ output_layout != WeightsLayout::g_os_iyx_osv32 && output_layout != WeightsLayout::os_iyx_osv32__ai32);const auto osv_first = IsOsvFirst(output_layout);const auto ofm_block = (osv_first) ? subgroup_size : GetOptimalSize(output.OFM().v, preferred_sizes);- const auto ifm_block = (osv_first) ? ifm_block_supported ? GetOptimalSize(output.IFM().v, preferred_sizes) : 1- : subgroup_size;+ const auto ifm_block = (osv_first) ? ifm_block_supported ? GetOptimalSize(output.IFM().v, preferred_sizes) : 1 : subgroup_size;if (osv_first) {// When IFM is not aligned to the ISV block size, expand GWS to cover padding// positions so they can be zero-filled by the kernel.auto slice_sizes = GetSliceSizes(output_layout);size_t isv_size = slice_sizes.first;- size_t ifm_padded = (isv_size > 1 && (output.IFM().v % isv_size) != 0)- ? Align(output.IFM().v, isv_size)- : output.IFM().v;- dispatchData.gws = { output.G().v * (ifm_padded / ifm_block),- output.Z().v * output.Y().v * output.X().v,- Align(output.OFM().v, ofm_block) };+ size_t ifm_padded = (isv_size > 1 && (output.IFM().v % isv_size) != 0) ? Align(output.IFM().v, isv_size) : output.IFM().v;+ dispatchData.gws = {output.G().v * (ifm_padded / ifm_block), output.Z().v * output.Y().v * output.X().v, Align(output.OFM().v, ofm_block)};} else {- dispatchData.gws = { output.G().v * (output.OFM().v / ofm_block),- output.Z().v * output.Y().v * output.X().v,- Align(output.IFM().v, ifm_block) };+ dispatchData.gws = {output.G().v * (output.OFM().v / ofm_block), output.Z().v * output.Y().v * output.X().v, Align(output.IFM().v, ifm_block)};}- dispatchData.lws = { 1, 1, 16 };+ dispatchData.lws = {1, 1, 16};return dispatchData;}@@ -186,18 +186,15 @@ JitConstants ReorderWeightsOpt::GetJitConstants(const reorder_weights_params& paauto jit = ReorderKernelBase::GetJitConstants(params);const auto& output = params.output;const auto subgroup_size = 16;- const auto ifm_block_supported = (output.GetLayout() != WeightsLayout::os_iyx_osv16 &&- output.GetLayout() != WeightsLayout::os_iyx_osv32 &&- output.GetLayout() != WeightsLayout::g_os_iyx_osv16 &&- output.GetLayout() != WeightsLayout::g_os_iyx_osv32 &&+ const auto ifm_block_supported = (output.GetLayout() != WeightsLayout::os_iyx_osv16 && output.GetLayout() != WeightsLayout::os_iyx_osv32 &&+ output.GetLayout() != WeightsLayout::g_os_iyx_osv16 && output.GetLayout() != WeightsLayout::g_os_iyx_osv32 &&output.GetLayout() != WeightsLayout::os_iyx_osv32__ai32);const auto slice_sizes = GetSliceSizes(output.GetLayout());const auto osv_first = IsOsvFirst(output.GetLayout());const auto leftovers = (osv_first) ? output.OFM().v % subgroup_size : output.IFM().v % subgroup_size;const auto ofm_block = (osv_first) ? subgroup_size : GetOptimalSize(output.OFM().v, preferred_sizes);- const auto ifm_block = (osv_first) ? ifm_block_supported ? GetOptimalSize(output.IFM().v, preferred_sizes) : 1- : subgroup_size;+ const auto ifm_block = (osv_first) ? ifm_block_supported ? GetOptimalSize(output.IFM().v, preferred_sizes) : 1 : subgroup_size;jit.AddConstant(MakeJitConstant("IFM_SIZE", slice_sizes.first));jit.AddConstant(MakeJitConstant("OFM_SIZE", slice_sizes.second));@@ -205,8 +202,9 @@ JitConstants ReorderWeightsOpt::GetJitConstants(const reorder_weights_params& pajit.AddConstant(MakeJitConstant("IFM_BLOCK_SIZE", ifm_block));jit.AddConstant(MakeJitConstant("OFM_BLOCK_SIZE", ofm_block));- if (leftovers)+ if (leftovers) {jit.AddConstant(MakeJitConstant("OUTPUT_LEFTOVERS", leftovers));+ }// For blocked weight formats with OSV_FIRST (e.g., os_is_yx_isv16_osv16), when the// input feature count is not aligned to the ISV block size, we must zero-fill IFMdiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_base.cppindex 546d4af9566..a2e5ad7e72c 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_base.cpp@@ -3,12 +3,14 @@//#include "resample_kernel_base.h"-#include "kernel_selector_utils.h"-#include <string>+#include <algorithm>-#include <vector>-#include <unordered_map>#include <iostream>+#include <string>+#include <unordered_map>+#include <vector>++#include "kernel_selector_utils.h"namespace {int getAxisIndex(kernel_selector::InterpolateAxis axis) {@@ -35,19 +37,24 @@ size_t ResampleKernelBase::GetFeatureBlockSize(const resample_params& params) coconst size_t max_size = 32;const size_t min_size = 4;size_t feature_block_size = 1;- std::vector<size_t> preferred_sizes = { 32, 16, 8 };- for (auto& s : preferred_sizes)- if (params.outputs[0].Feature().v % s == 0)+ std::vector<size_t> preferred_sizes = {32, 16, 8};+ for (auto& s : preferred_sizes) {+ if (params.outputs[0].Feature().v % s == 0) {return s;- if (params.outputs[0].Feature().v < max_size)+ }+ }+ if (params.outputs[0].Feature().v < max_size) {return params.outputs[0].Feature().v;- for (size_t f = 1; f <= params.outputs[0].Feature().v && f <= max_size; f++)- if (params.outputs[0].Feature().v % f == 0)+ }+ for (size_t f = 1; f <= params.outputs[0].Feature().v && f <= max_size; f++) {+ if (params.outputs[0].Feature().v % f == 0) {feature_block_size = f;+ }+ }return std::max(feature_block_size, min_size);}-ResampleKernelBase::DispatchData ResampleKernelBase::SetDefault(const kernel_selector::resample_params &arg) const {+ResampleKernelBase::DispatchData ResampleKernelBase::SetDefault(const kernel_selector::resample_params& arg) const {DispatchData dispatchData;auto in_layout = arg.inputs[0].GetLayout();auto out_layout = arg.outputs[0].GetLayout();@@ -56,32 +63,28 @@ ResampleKernelBase::DispatchData ResampleKernelBase::SetDefault(const kernel_selconst auto& out = arg.outputs[0];if (arg.resampleType == ResampleType::NEAREST_NEIGHBOR) {- dispatchData.gws = { out.X().v, out.Y().v * out.Z().v, out.Feature().v * out.Batch().v };- dims_by_gws = {{ Tensor::DataChannelName::X },- { Tensor::DataChannelName::Y, Tensor::DataChannelName::Z },- { Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH }};- } else if ( (arg.resampleType == ResampleType::BILINEAR_INTERP || arg.resampleType == ResampleType::LINEAR_ONNX) &&- out.Dimentions() <= 4 ) {- dispatchData.gws = { Align(out.X().v, 32), out.Y().v, out.Batch().v };- dims_by_gws = {{ Tensor::DataChannelName::X },- { Tensor::DataChannelName::Y },- { Tensor::DataChannelName::BATCH }};+ dispatchData.gws = {out.X().v, out.Y().v * out.Z().v, out.Feature().v * out.Batch().v};+ dims_by_gws = {{Tensor::DataChannelName::X},+ {Tensor::DataChannelName::Y, Tensor::DataChannelName::Z},+ {Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH}};+ } else if ((arg.resampleType == ResampleType::BILINEAR_INTERP || arg.resampleType == ResampleType::LINEAR_ONNX) && out.Dimentions() <= 4) {+ dispatchData.gws = {Align(out.X().v, 32), out.Y().v, out.Batch().v};+ dims_by_gws = {{Tensor::DataChannelName::X}, {Tensor::DataChannelName::Y}, {Tensor::DataChannelName::BATCH}};} else if (arg.resampleType == ResampleType::CAFFE_BILINEAR_INTERP) {- dispatchData.gws = { out.X().v * out.Y().v, CeilDiv(out.Feature().v, GetFeatureBlockSize(arg)), out.Batch().v * out.Z().v };- dims_by_gws = {{ Tensor::DataChannelName::X, Tensor::DataChannelName::Y },- { Tensor::DataChannelName::FEATURE },- { Tensor::DataChannelName::Z, Tensor::DataChannelName::BATCH }};+ dispatchData.gws = {out.X().v * out.Y().v, CeilDiv(out.Feature().v, GetFeatureBlockSize(arg)), out.Batch().v * out.Z().v};+ dims_by_gws = {{Tensor::DataChannelName::X, Tensor::DataChannelName::Y},+ {Tensor::DataChannelName::FEATURE},+ {Tensor::DataChannelName::Z, Tensor::DataChannelName::BATCH}};} else {- dispatchData.gws = { out.X().v, out.Y().v * out.Z().v, out.Feature().v * out.Batch().v };- dims_by_gws = {{ Tensor::DataChannelName::X },- { Tensor::DataChannelName::Y, Tensor::DataChannelName::Z },- { Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH }};+ dispatchData.gws = {out.X().v, out.Y().v * out.Z().v, out.Feature().v * out.Batch().v};+ dims_by_gws = {{Tensor::DataChannelName::X},+ {Tensor::DataChannelName::Y, Tensor::DataChannelName::Z},+ {Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH}};}dispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, arg.engineInfo, in_layout, out_layout, dims_by_gws);- if ((arg.resampleType == ResampleType::BILINEAR_INTERP || arg.resampleType == ResampleType::LINEAR_ONNX) &&- out.Dimentions() <= 4) {+ if ((arg.resampleType == ResampleType::BILINEAR_INTERP || arg.resampleType == ResampleType::LINEAR_ONNX) && out.Dimentions() <= 4) {dispatchData.lws[0] = 32;dispatchData.lws[1] = 1;dispatchData.lws[2] = 1;@@ -98,8 +101,9 @@ bool ResampleKernelBase::Validate(const Params& p) const {const resample_params& params = static_cast<const resample_params&>(p);for (const auto& fused_op : params.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}if (params.inputs.empty()) {@@ -107,12 +111,11 @@ bool ResampleKernelBase::Validate(const Params& p) const {}const auto& input = params.inputs[0];- if ((input.GetDType() == Datatype::UINT8 || input.GetDType() == Datatype::INT8) &&- params.resampleType != ResampleType::NEAREST_NEIGHBOR &&- params.resampleType != ResampleType::CAFFE_BILINEAR_INTERP &&- params.resampleType != ResampleType::BILINEAR_INTERP &&- params.resampleType != ResampleType::LINEAR_ONNX)+ if ((input.GetDType() == Datatype::UINT8 || input.GetDType() == Datatype::INT8) && params.resampleType != ResampleType::NEAREST_NEIGHBOR &&+ params.resampleType != ResampleType::CAFFE_BILINEAR_INTERP && params.resampleType != ResampleType::BILINEAR_INTERP &&+ params.resampleType != ResampleType::LINEAR_ONNX) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}@@ -124,10 +127,12 @@ JitConstants ResampleKernelBase::GetJitConstants(const resample_params& params)const auto& output = params.outputs[0];auto pads_begin = params.pads_begin;auto pads_end = params.pads_end;- if (pads_begin.size() == 4)+ if (pads_begin.size() == 4) {pads_begin.insert(std::next(pads_begin.begin(), 2), 0);- if (pads_end.size() == 4)+ }+ if (pads_end.size() == 4) {pads_end.insert(std::next(pads_end.begin(), 2), 0);+ }const auto b_size_padded = pads_begin[0] + input.Batch().v + pads_end[0];const auto f_size_padded = pads_begin[1] + input.Feature().v + pads_end[1];@@ -155,12 +160,14 @@ JitConstants ResampleKernelBase::GetJitConstants(const resample_params& params)for (std::size_t i = 0; i < params.axes.size(); i++) {int idx = getAxisIndex(params.axes[i]);axesUsed[idx] = 1;- if (params.shapeCalculationMode == kernel_selector::ShapeCalculationMode::SCALES)+ if (params.shapeCalculationMode == kernel_selector::ShapeCalculationMode::SCALES) {scales[idx] = 1.f / params.scales[i];+ }}for (size_t i = 0; i < scales.size(); ++i) {- if (scales[i] != 1.f)+ if (scales[i] != 1.f) {axesUsed[i] = 1;+ }}jit.AddConstants({@@ -178,11 +185,16 @@ JitConstants ResampleKernelBase::GetJitConstants(const resample_params& params)});if (params.resampleType == ResampleType::CAFFE_BILINEAR_INTERP) {- if (axesUsed[0] == 1) jit.AddConstant(MakeJitConstant("AXES_USED_B", 1));- if (axesUsed[1] == 1) jit.AddConstant(MakeJitConstant("AXES_USED_F", 1));- if (axesUsed[2] == 1) jit.AddConstant(MakeJitConstant("AXES_USED_Z", 1));- if (axesUsed[3] == 1) jit.AddConstant(MakeJitConstant("AXES_USED_Y", 1));- if (axesUsed[4] == 1) jit.AddConstant(MakeJitConstant("AXES_USED_X", 1));+ if (axesUsed[0] == 1)+ jit.AddConstant(MakeJitConstant("AXES_USED_B", 1));+ if (axesUsed[1] == 1)+ jit.AddConstant(MakeJitConstant("AXES_USED_F", 1));+ if (axesUsed[2] == 1)+ jit.AddConstant(MakeJitConstant("AXES_USED_Z", 1));+ if (axesUsed[3] == 1)+ jit.AddConstant(MakeJitConstant("AXES_USED_Y", 1));+ if (axesUsed[4] == 1)+ jit.AddConstant(MakeJitConstant("AXES_USED_X", 1));jit.AddConstants({MakeJitConstant("PADDED_B", b_size_padded),@@ -232,8 +244,17 @@ KernelsData ResampleKernelBase::GetCommonKernelsData(const Params& params) constauto jit = CreateJit(kernelName, cldnn_jit, entry_point);auto& kernel = kd.kernels[0];- FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point,- EXE_MODE_DEFAULT, false, false, 1, GetFusedPrimitiveInputsCount(params));+ FillCLKernelData(kernel,+ dispatchData,+ params.engineInfo,+ kernelName,+ jit,+ entry_point,+ EXE_MODE_DEFAULT,+ false,+ false,+ 1,+ GetFusedPrimitiveInputsCount(params));return {kd};}@@ -241,8 +262,9 @@ KernelsData ResampleKernelBase::GetCommonKernelsData(const Params& params) constDatatype ResampleKernelBase::GetAccumulatorType(const resample_params& params) const {auto in_dt = params.inputs[0].GetDType();- if (params.resampleType == ResampleType::NEAREST_NEIGHBOR)+ if (params.resampleType == ResampleType::NEAREST_NEIGHBOR) {return in_dt;+ }return Datatype::F32;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_bfyx_cubic_opt.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_bfyx_cubic_opt.cppindex 3de3cc69a97..510ebce08f4 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_bfyx_cubic_opt.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_bfyx_cubic_opt.cpp@@ -63,26 +63,30 @@ KernelsPriority ResampleKernelBfyxCubicOpt::GetKernelsPriority(const Params& /*p}bool ResampleKernelBfyxCubicOpt::Validate(const Params& p) const {- if (!Parent::Validate(p))+ if (!Parent::Validate(p)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const resample_params& params = static_cast<const resample_params&>(p);// Only 4D tensors (no Z axis).- if (params.inputs[0].Dimentions() != 4)+ if (params.inputs[0].Dimentions() != 4) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }// Only spatial axes (Y, X) may be resized.for (const auto& axis : params.axes) {- if (axis != InterpolateAxis::Y && axis != InterpolateAxis::X)+ if (axis != InterpolateAxis::Y && axis != InterpolateAxis::X) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}// Non-spatial dimensions (batch and feature) must not be resized.const auto& in = params.inputs[0];const auto& out = params.outputs[0];- if (in.Batch().v != out.Batch().v || in.Feature().v != out.Feature().v)+ if (in.Batch().v != out.Batch().v || in.Feature().v != out.Feature().v) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_onnx.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_onnx.cppindex ab8637afe43..54e81eb26df 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_onnx.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_onnx.cpp@@ -127,13 +127,15 @@ KernelsPriority ResampleKernelOnnx::GetKernelsPriority(const Params& /*params*/)bool ResampleKernelOnnx::Validate(const Params& p) const {const resample_params& params = static_cast<const resample_params&>(p);- if (!Parent::Validate(p))+ if (!Parent::Validate(p)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const auto& input = params.inputs[0];const auto& output = params.outputs[0];- if (input.Batch().v != output.Batch().v || input.Feature().v != output.Feature().v)+ if (input.Batch().v != output.Batch().v || input.Feature().v != output.Feature().v) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}@@ -160,17 +162,19 @@ JitConstants ResampleKernelOnnx::GetJitConstants(const resample_params& params)size_t vec_size = get_vec_size(params);jit.AddConstant(MakeJitConstant("FEATURE_SLICE_SIZE", 16 * vec_size));- if (IsThreeSpatialResample(params))+ if (IsThreeSpatialResample(params)) {jit.AddConstant(MakeJitConstant("THREE_SPATIAL_RESAMPLE", ""));+ }jit.AddConstant(MakeJitConstant("VEC_SIZE", vec_size));if (!params.fused_ops.empty()) {std::vector<std::string> idx_order;- if (params.inputs[0].Dimentions() == 5)+ if (params.inputs[0].Dimentions() == 5) {idx_order = {"b", "feature_block", "z", "y", "(x + out_x)"};- else+ } else {idx_order = {"b", "feature_block", "y", "(x + out_x)"};+ }FusedOpsConfiguration conf ={"", idx_order, "res", GetAccumulatorType(params), vec_size, LoadType::LT_ALIGNED_READ};conf.SetVectorAxis(Tensor::DataChannelName::FEATURE);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_opt.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_opt.cppindex 47d65b04e69..834befa9e9b 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_opt.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_opt.cpp@@ -12,9 +12,11 @@ static constexpr size_t sub_group_size = 16;size_t ResampleKernelOpt::GetOptimalBlockSize(const resample_params& params) const {std::vector<size_t> block_width = { 16, 8, 4, 2, 1 };- for (auto& w : block_width)- if (params.outputs[0].X().v % w == 0)+ for (auto& w : block_width) {+ if (params.outputs[0].X().v % w == 0) {return w;+ }+ }return 1;}@@ -149,19 +151,22 @@ KernelsPriority ResampleKernelOpt::GetKernelsPriority(const Params& /*params*/)bool ResampleKernelOpt::Validate(const Params& p) const {const resample_params& params = static_cast<const resample_params&>(p);- if (!Parent::Validate(p))+ if (!Parent::Validate(p)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const auto& input = params.inputs[0];if ((input.GetDType() == Datatype::UINT8 || input.GetDType() == Datatype::INT8) &¶ms.resampleType != ResampleType::NEAREST_NEIGHBOR &&- params.resampleType != ResampleType::BILINEAR_INTERP)+ params.resampleType != ResampleType::BILINEAR_INTERP) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }// in the case of 5D support only NEAREST_NEIGHBOR- if (input.Dimentions() == 5 && params.resampleType != ResampleType::NEAREST_NEIGHBOR)+ if (input.Dimentions() == 5 && params.resampleType != ResampleType::NEAREST_NEIGHBOR) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}@@ -185,10 +190,11 @@ JitConstants ResampleKernelOpt::GetJitConstants(const resample_params ¶ms) cif (!params.fused_ops.empty()) {if (params.resampleType != ResampleType::CAFFE_BILINEAR_INTERP) {std::vector<std::string> idx_order;- if (params.inputs[0].Dimentions() == 5)+ if (params.inputs[0].Dimentions() == 5) {idx_order = {"b", "feature_block", "z", "y", "(x + out_x)"};- else+ } else {idx_order = {"b", "feature_block", "y", "(x + out_x)"};+ }FusedOpsConfiguration conf = {"", idx_order, "res", GetAccumulatorType(params), vec_size, LoadType::LT_ALIGNED_READ};conf.SetVectorAxis(Tensor::DataChannelName::FEATURE);jit.Merge(MakeFusedOpsJitConstants(params, {conf}));diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_pil_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_pil_ref.cppindex 8a0123cbbe0..1b7e3cc54bb 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_pil_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_pil_ref.cpp@@ -427,11 +427,13 @@ KernelsData ResampleKernelPilRef::GetKernelsData(const Params ¶ms) const {int i = 0;for (ResampleKernelPilRef::KernelId id = eCalcHorizontalCoefficients; id < eEnd; ++id) {if (!NeedHorizontalPass(resample_parameters) &&- (id == eCalcHorizontalCoefficients || id == eResampleHorizontal))+ (id == eCalcHorizontalCoefficients || id == eResampleHorizontal)) {continue;+ }if (!NeedVerticalPass(resample_parameters) &&- (id == eCalcVerticalCoefficients || id == eResampleVertical))+ (id == eCalcVerticalCoefficients || id == eResampleVertical)) {continue;+ }auto& kernel = kd.kernels[i++];const auto entryPoint = GetEntryPoint(kernelName, resample_parameters.layerID, params, i);auto jitConstants = GetJitConstantsForKernel(id, resample_parameters);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_ref.cppindex c5f705bf836..dd908bd14f5 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_ref.cpp@@ -46,8 +46,9 @@ static size_t packing_factor(const resample_params& params) {bool in_out_8bit = (params.inputs[0].GetDType() == Datatype::UINT8 || params.inputs[0].GetDType() == Datatype::INT8) &&(params.outputs[0].GetDType() == Datatype::UINT8 || params.outputs[0].GetDType() == Datatype::INT8);- if (!in_out_8bit)+ if (!in_out_8bit) {return 1;+ }auto get_layout_packing_factor = [](const DataLayout& layout) -> size_t {switch (layout) {@@ -65,21 +66,25 @@ static size_t packing_factor(const resample_params& params) {size_t input_factor = get_layout_packing_factor(params.inputs[0].GetLayout());size_t output_factor = get_layout_packing_factor(params.outputs[0].GetLayout());- if (input_factor % output_factor == 0 || output_factor % input_factor == 0)+ if (input_factor % output_factor == 0 || output_factor % input_factor == 0) {return std::min(input_factor, output_factor);+ }return 1;}static bool use_packing(const resample_params& params) {- if (params.resampleType != ResampleType::NEAREST_NEIGHBOR)+ if (params.resampleType != ResampleType::NEAREST_NEIGHBOR) {return false;+ }auto pack = packing_factor(params);- if (pack == 1)+ if (pack == 1) {return false;+ }- if (params.inputs[0].Feature().pad.before % pack != 0 || params.outputs[0].Feature().pad.before % pack != 0)+ if (params.inputs[0].Feature().pad.before % pack != 0 || params.outputs[0].Feature().pad.before % pack != 0) {return false;+ }auto packed_work_items = params.outputs[0].X().v * params.outputs[0].Y().v * params.outputs[0].Z().v* CeilDiv(params.outputs[0].Feature().v, pack) * params.outputs[0].Batch().v;diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/reshape/reshape_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/reshape/reshape_kernel_ref.cppindex 8c5637e90d9..ac4206046cf 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/reshape/reshape_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/reshape/reshape_kernel_ref.cpp@@ -50,10 +50,12 @@ KernelsData ReshapeKernelRef::GetKernelsData(const Params& params) const {size_t gws2 = 1;const auto& in_dims = in.GetDims();- if (!in_dims.empty())+ if (!in_dims.empty()) {gws0 = in_dims[0].v;- if (in_dims.size() >= 2)+ }+ if (in_dims.size() >= 2) {gws1 = in_dims[1].v;+ }for (size_t i = 2; i < in_dims.size(); ++i) {gws2 *= in_dims[i].v;}@@ -71,8 +73,9 @@ KernelsPriority ReshapeKernelRef::GetKernelsPriority(const Params& /*params*/) c}bool ReshapeKernelRef::Validate(const Params& p) const {- if (!KernelBaseOpenCL::Validate(p))+ if (!KernelBaseOpenCL::Validate(p)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const auto& rp = static_cast<const reshape_params&>(p);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/rms/rms_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/rms/rms_kernel_base.cppindex 23b17fa164e..abd55913aa6 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/rms/rms_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/rms/rms_kernel_base.cpp@@ -7,13 +7,15 @@namespace kernel_selector {bool RMSKernelBase::Validate(const Params& p) const {- if (!KernelBaseOpenCL::Validate(p))+ if (!KernelBaseOpenCL::Validate(p)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const rms_params& params = static_cast<const rms_params&>(p);auto supported_dyn_layouts = { DataLayout::bfyx, DataLayout::bfzyx };- if (params.has_dynamic_tensors() && (!layout_is_one_of(params.inputs, supported_dyn_layouts) || !layout_is_one_of(params.outputs, supported_dyn_layouts)))+ if (params.has_dynamic_tensors() && (!layout_is_one_of(params.inputs, supported_dyn_layouts) || !layout_is_one_of(params.outputs, supported_dyn_layouts))) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}@@ -96,8 +98,9 @@ void RMSKernelBase::GetUpdateDispatchDataFunc(KernelData& kd) const {KernelsData RMSKernelBase::GetCommonKernelsData(const Params& params) const {assert(params.GetType() == KernelType::RMS);- if (!Validate(params))+ if (!Validate(params)) {return {};+ }const rms_params& orgParams = static_cast<const rms_params&>(params);auto dispatchData = SetDefault(orgParams);diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/rms/rms_kernel_bfyx_opt.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/rms/rms_kernel_bfyx_opt.cppindex 5030f2861d5..204f5cac2e1 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/rms/rms_kernel_bfyx_opt.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/rms/rms_kernel_bfyx_opt.cpp@@ -74,8 +74,9 @@ JitConstants RMSKernelBfyxOpt::GetJitConstants(const rms_params& params, Dispatc}}- if (has_padding)+ if (has_padding) {jit.AddConstant(MakeJitConstant("HAS_PADDING", 1));+ }if (params.has_dynamic_tensors()) {const auto& input = params.inputs[0];@@ -193,14 +194,15 @@ RMSKernelBase::DispatchData RMSKernelBfyxOpt::SetDefault(const rms_params& paramdispatchData.gws[0] = dispatchData.lws[0];dispatchData.leftovers = dispatchData.dataSize % dispatchData.lws[0];- if (dispatchData.itemsNum >> 3)+ if (dispatchData.itemsNum >> 3) {dispatchData.subgroupBlockSize = 8;- else if (dispatchData.itemsNum >> 2)+ } else if (dispatchData.itemsNum >> 2) {dispatchData.subgroupBlockSize = 4;- else if (dispatchData.itemsNum >> 1)+ } else if (dispatchData.itemsNum >> 1) {dispatchData.subgroupBlockSize = 2;- else+ } else {dispatchData.subgroupBlockSize = 1;+ }} else {dispatchData.subgroupBlockSize = 8;}@@ -208,8 +210,9 @@ RMSKernelBase::DispatchData RMSKernelBfyxOpt::SetDefault(const rms_params& param}bool RMSKernelBfyxOpt::Validate(const Params& p) const {- if (!Parent::Validate(p))+ if (!Parent::Validate(p)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const rms_params& params = static_cast<const rms_params&>(p);if (params.elementwise_affine) {diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/roi_align/roi_align_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/roi_align/roi_align_kernel_ref.cppindex f3bb376e40e..f9cb9b90582 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/roi_align/roi_align_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/roi_align/roi_align_kernel_ref.cpp@@ -69,8 +69,9 @@ bool ROIAlignKernelRef::Validate(const Params& p) const {}const roi_align_params ¶ms = static_cast<const roi_align_params&>(p);- if (params.inputs.size() != 3)+ if (params.inputs.size() != 3) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/roi_pooling/roi_pooling_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/roi_pooling/roi_pooling_kernel_base.cppindex 72c43e949f5..a7a92d52ca6 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/roi_pooling/roi_pooling_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/roi_pooling/roi_pooling_kernel_base.cpp@@ -55,8 +55,9 @@ KernelsData ROIPoolingKernelBase::GetCommonKernelsData(const Params& params) conauto& kernel = kd.kernels[0];FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point);kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 1});- if (orgParams.mode == PoolType::DEFORMABLE_BILINEAR && !orgParams.no_trans)+ if (orgParams.mode == PoolType::DEFORMABLE_BILINEAR && !orgParams.no_trans) {kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 2});+ }return {kd};}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/roi_pooling/roi_pooling_kernel_ps_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/roi_pooling/roi_pooling_kernel_ps_ref.cppindex 640b4902180..f23b66b6c26 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/roi_pooling/roi_pooling_kernel_ps_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/roi_pooling/roi_pooling_kernel_ps_ref.cpp@@ -33,11 +33,12 @@ JitConstants PSROIPoolingKernelRef::GetJitConstants(const roi_pooling_params& rpMakeJitConstant("SPATIAL_BINS_Y", rp.spatial_bins_y),});- if (rp.mode == PoolType::DEFORMABLE_BILINEAR)+ if (rp.mode == PoolType::DEFORMABLE_BILINEAR) {jit.AddConstants({MakeJitConstant("TRANS_STD", rp.trans_std),MakeJitConstant("NO_TRANS", rp.no_trans),MakeJitConstant("PART_SIZE", rp.part_size),MakeJitConstant("GROUP_SIZE", rp.group_size)});+ }return jit;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/scatter_update/scatter_elements_update_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/scatter_update/scatter_elements_update_kernel_ref.cppindex 3efc9f4d92c..fb0449797bc 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/scatter_update/scatter_elements_update_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/scatter_update/scatter_elements_update_kernel_ref.cpp@@ -3,24 +3,26 @@//#include "scatter_elements_update_kernel_ref.h"-#include "kernel_selector_utils.h"+#include <string>#include <vector>+#include "kernel_selector_utils.h"+namespace kernel_selector {/*-* Dynamic Kernels Map With Reduction Mode-* The actual kernel executed for ITER 1 and ITER 2 is determined at runtime-* based on the calculated output size (use_local_memory flag).-*-* | Kernel Index (i) | OpenCL ITER | Execution Mode | Purpose |-* |------------------|-------------|------------------|---------------------|-* | 0 | 0 | N/A | Initialization |-* | 1 | 1 | Local Memory | Update |-* | 2 | 1 | Global Memory | Update |-* | 3 | 2 | Local Memory | Finalize |-* | 4 | 2 | Global Memory | Finalize |-*/+ * Dynamic Kernels Map With Reduction Mode+ * The actual kernel executed for ITER 1 and ITER 2 is determined at runtime+ * based on the calculated output size (use_local_memory flag).+ *+ * | Kernel Index (i) | OpenCL ITER | Execution Mode | Purpose |+ * |------------------|-------------|------------------|---------------------|+ * | 0 | 0 | N/A | Initialization |+ * | 1 | 1 | Local Memory | Update |+ * | 2 | 1 | Global Memory | Update |+ * | 3 | 2 | Local Memory | Finalize |+ * | 4 | 2 | Global Memory | Finalize |+ */enum class DynamicKernelStage : size_t {STAGE0 = 0, // Initialization@@ -32,20 +34,17 @@ enum class DynamicKernelStage : size_t {static bool is_second_stage(const scatter_elements_update_params& params, size_t index) {if (params.is_shape_agnostic && (params.mode != ScatterUpdateReduction::NONE)) {- return ((index == static_cast<size_t>(DynamicKernelStage::STAGE1_LOCAL)) ||- (index == static_cast<size_t>(DynamicKernelStage::STAGE1_GLOBAL)));+ return ((index == static_cast<size_t>(DynamicKernelStage::STAGE1_LOCAL)) || (index == static_cast<size_t>(DynamicKernelStage::STAGE1_GLOBAL)));}return (index == 1);}static bool is_dynamic_local_memory_kernel(size_t index) {- return ((index == static_cast<size_t>(DynamicKernelStage::STAGE1_LOCAL)) ||- (index == static_cast<size_t>(DynamicKernelStage::STAGE2_LOCAL)));+ return ((index == static_cast<size_t>(DynamicKernelStage::STAGE1_LOCAL)) || (index == static_cast<size_t>(DynamicKernelStage::STAGE2_LOCAL)));}static bool is_dynamic_global_memory_kernel(size_t index) {- return ((index == static_cast<size_t>(DynamicKernelStage::STAGE1_GLOBAL)) ||- (index == static_cast<size_t>(DynamicKernelStage::STAGE2_GLOBAL)));+ return ((index == static_cast<size_t>(DynamicKernelStage::STAGE1_GLOBAL)) || (index == static_cast<size_t>(DynamicKernelStage::STAGE2_GLOBAL)));}static bool is_global_memory(const scatter_elements_update_params& params) {@@ -57,20 +56,20 @@ static size_t GetScatterElementsUpdateChannelIndex(const scatter_elements_updateconst size_t input_size = params.inputs[0].GetDims().size();switch (params.axis) {- case ScatterUpdateAxis::X:- return (size_t)(input_size - 1);- case ScatterUpdateAxis::Y:- return (size_t)(input_size - 2);- case ScatterUpdateAxis::Z:- return (size_t)(input_size - 3);- case ScatterUpdateAxis::W:- return 2;- case ScatterUpdateAxis::FEATURE:- return 1;- case ScatterUpdateAxis::BATCH:- return 0;- default:- break;+ case ScatterUpdateAxis::X:+ return (size_t)(input_size - 1);+ case ScatterUpdateAxis::Y:+ return (size_t)(input_size - 2);+ case ScatterUpdateAxis::Z:+ return (size_t)(input_size - 3);+ case ScatterUpdateAxis::W:+ return 2;+ case ScatterUpdateAxis::FEATURE:+ return 1;+ case ScatterUpdateAxis::BATCH:+ return 0;+ default:+ break;}return DataTensor::Channelndex(params.outputs[0].GetLayout(), name);@@ -78,31 +77,27 @@ static size_t GetScatterElementsUpdateChannelIndex(const scatter_elements_updateParamsKey ScatterElementsUpdateKernelRef::GetSupportedKey() const {ParamsKey k;- const std::vector<Datatype> supportedTypes{- Datatype::F16, Datatype::F32, Datatype::INT32, Datatype::INT8, Datatype::UINT8- };+ const std::vector<Datatype> supportedTypes{Datatype::F16, Datatype::F32, Datatype::INT32, Datatype::INT8, Datatype::UINT8};for (const auto t : supportedTypes) {k.EnableInputDataType(t);k.EnableOutputDataType(t);}- const std::vector<DataLayout> supportedLayots{- DataLayout::bfyx,- DataLayout::b_fs_yx_fsv16,- DataLayout::b_fs_yx_fsv32,- DataLayout::bs_fs_yx_bsv16_fsv16,- DataLayout::bs_fs_yx_bsv32_fsv16,- DataLayout::bs_fs_yx_bsv16_fsv32,- DataLayout::bs_fs_yx_bsv32_fsv32,- DataLayout::bfzyx,- DataLayout::b_fs_zyx_fsv16,- DataLayout::b_fs_zyx_fsv32,- DataLayout::bs_fs_zyx_bsv16_fsv32,- DataLayout::bs_fs_zyx_bsv16_fsv16,- DataLayout::bs_fs_zyx_bsv32_fsv32,- DataLayout::bs_fs_zyx_bsv32_fsv16,- DataLayout::bfwzyx- };+ const std::vector<DataLayout> supportedLayots{DataLayout::bfyx,+ DataLayout::b_fs_yx_fsv16,+ DataLayout::b_fs_yx_fsv32,+ DataLayout::bs_fs_yx_bsv16_fsv16,+ DataLayout::bs_fs_yx_bsv32_fsv16,+ DataLayout::bs_fs_yx_bsv16_fsv32,+ DataLayout::bs_fs_yx_bsv32_fsv32,+ DataLayout::bfzyx,+ DataLayout::b_fs_zyx_fsv16,+ DataLayout::b_fs_zyx_fsv32,+ DataLayout::bs_fs_zyx_bsv16_fsv32,+ DataLayout::bs_fs_zyx_bsv16_fsv16,+ DataLayout::bs_fs_zyx_bsv32_fsv32,+ DataLayout::bs_fs_zyx_bsv32_fsv16,+ DataLayout::bfwzyx};for (const auto l : supportedLayots) {k.EnableInputLayout(l);k.EnableOutputLayout(l);@@ -143,56 +138,52 @@ CommonDispatchData ScatterElementsUpdateKernelRef::SetDefault(const scatter_elemif (!scope.is_dynamic()) {if (is_second && params.mode != ScatterUpdateReduction::NONE) {switch (rank) {- case 4:- dispatchData.gws = {indices.X().v * indices.Y().v, indices.Feature().v, indices.Batch().v};- dims_by_gws = {{Tensor::DataChannelName::X, Tensor::DataChannelName::Y},- {Tensor::DataChannelName::FEATURE},- {Tensor::DataChannelName::BATCH}};- break;- case 5:- dispatchData.gws = {indices.X().v * indices.Y().v, indices.Z().v * indices.Feature().v, indices.Batch().v};- dims_by_gws = {{Tensor::DataChannelName::X, Tensor::DataChannelName::Y},- {Tensor::DataChannelName::Z, Tensor::DataChannelName::FEATURE},- {Tensor::DataChannelName::BATCH}};- break;- case 6:- dispatchData.gws = {indices.X().v * indices.Y().v, indices.Z().v * indices.W().v, indices.Feature().v * indices.Batch().v};- dims_by_gws = {{Tensor::DataChannelName::X, Tensor::DataChannelName::Y},- {Tensor::DataChannelName::Z, Tensor::DataChannelName::W},- {Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH}};- break;- default:- throw std::invalid_argument("Unsupported data layout for scatter elements update primitive");- break;- }- dispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo, in_layout, out_layout, dims_by_gws);+ case 4:+ dispatchData.gws = {indices.X().v * indices.Y().v, indices.Feature().v, indices.Batch().v};+ dims_by_gws = {{Tensor::DataChannelName::X, Tensor::DataChannelName::Y}, {Tensor::DataChannelName::FEATURE}, {Tensor::DataChannelName::BATCH}};+ break;+ case 5:+ dispatchData.gws = {indices.X().v * indices.Y().v, indices.Z().v * indices.Feature().v, indices.Batch().v};+ dims_by_gws = {{Tensor::DataChannelName::X, Tensor::DataChannelName::Y},+ {Tensor::DataChannelName::Z, Tensor::DataChannelName::FEATURE},+ {Tensor::DataChannelName::BATCH}};+ break;+ case 6:+ dispatchData.gws = {indices.X().v * indices.Y().v, indices.Z().v * indices.W().v, indices.Feature().v * indices.Batch().v};+ dims_by_gws = {{Tensor::DataChannelName::X, Tensor::DataChannelName::Y},+ {Tensor::DataChannelName::Z, Tensor::DataChannelName::W},+ {Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH}};+ break;+ default:+ throw std::invalid_argument("Unsupported data layout for scatter elements update primitive");+ break;+ }+ dispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo, in_layout, out_layout, dims_by_gws);} else {switch (rank) {- case 4:- dispatchData.gws = {scope.X().v, scope.Y().v, scope.Feature().v * scope.Batch().v};- dims_by_gws = {{Tensor::DataChannelName::X},- {Tensor::DataChannelName::Y},- {Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH}};- break;-- case 5:- dispatchData.gws = {scope.X().v * scope.Y().v, scope.Z().v, scope.Feature().v * scope.Batch().v};- dims_by_gws = {{Tensor::DataChannelName::X, Tensor::DataChannelName::Y},- {Tensor::DataChannelName::Z},- {Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH}};- break;-- case 6:- dispatchData.gws = {scope.X().v * scope.Y().v, scope.Z().v * scope.W().v, scope.Feature().v * scope.Batch().v};- dims_by_gws = {{Tensor::DataChannelName::X, Tensor::DataChannelName::Y},- {Tensor::DataChannelName::Z, Tensor::DataChannelName::W},- {Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH}};- break;- default:- throw std::invalid_argument("Unsupported data layout for scatter elements update primitive");- break;- }- dispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo, in_layout, out_layout, dims_by_gws);+ case 4:+ dispatchData.gws = {scope.X().v, scope.Y().v, scope.Feature().v * scope.Batch().v};+ dims_by_gws = {{Tensor::DataChannelName::X}, {Tensor::DataChannelName::Y}, {Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH}};+ break;++ case 5:+ dispatchData.gws = {scope.X().v * scope.Y().v, scope.Z().v, scope.Feature().v * scope.Batch().v};+ dims_by_gws = {{Tensor::DataChannelName::X, Tensor::DataChannelName::Y},+ {Tensor::DataChannelName::Z},+ {Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH}};+ break;++ case 6:+ dispatchData.gws = {scope.X().v * scope.Y().v, scope.Z().v * scope.W().v, scope.Feature().v * scope.Batch().v};+ dims_by_gws = {{Tensor::DataChannelName::X, Tensor::DataChannelName::Y},+ {Tensor::DataChannelName::Z, Tensor::DataChannelName::W},+ {Tensor::DataChannelName::FEATURE, Tensor::DataChannelName::BATCH}};+ break;+ default:+ throw std::invalid_argument("Unsupported data layout for scatter elements update primitive");+ break;+ }+ dispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo, in_layout, out_layout, dims_by_gws);}}@@ -216,8 +207,8 @@ JitConstants ScatterElementsUpdateKernelRef::GetJitConstants(const scatter_eleme}if (!params.fused_ops.empty()) {- FusedOpsConfiguration conf1 = { "_FIRST_KERNEL", GetDefaultOrder(params.outputs[0].GetDims().size()), "val", params.inputs[0].GetDType() };- FusedOpsConfiguration conf2 = { "_SECOND_KERNEL", GetDefaultOrder(params.outputs[0].GetDims().size()), "val", params.inputs[0].GetDType() };+ FusedOpsConfiguration conf1 = {"_FIRST_KERNEL", GetDefaultOrder(params.outputs[0].GetDims().size()), "val", params.inputs[0].GetDType()};+ FusedOpsConfiguration conf2 = {"_SECOND_KERNEL", GetDefaultOrder(params.outputs[0].GetDims().size()), "val", params.inputs[0].GetDType()};jit.Merge(MakeFusedOpsJitConstants(params, {conf1, conf2}));}@@ -225,15 +216,16 @@ JitConstants ScatterElementsUpdateKernelRef::GetJitConstants(const scatter_eleme}bool ScatterElementsUpdateKernelRef::Validate(const Params& p) const {- if (p.GetType() != KernelType:: SCATTER_ELEMENTS_UPDATE) {+ if (p.GetType() != KernelType::SCATTER_ELEMENTS_UPDATE) {DO_NOT_USE_THIS_KERNEL(p.layerID);}const scatter_elements_update_params& params = static_cast<const scatter_elements_update_params&>(p);for (const auto& fused_op : params.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}return true;@@ -317,23 +309,23 @@ KernelsData ScatterElementsUpdateKernelRef::GetKernelsData(const Params& params)if (!params.is_shape_agnostic && newParams.mode != ScatterUpdateReduction::NONE) {kd.internalBuffers.clear();- kd.internalBuffers.push_back(output.PhysicalSizeInBytes() * 2); // fixed point output+ kd.internalBuffers.push_back(output.PhysicalSizeInBytes() * 2); // fixed point outputif (newParams.mode == ScatterUpdateReduction::MEAN) {- kd.internalBuffers.push_back(output.PhysicalSizeInBytes() * 2); // count for mean+ kd.internalBuffers.push_back(output.PhysicalSizeInBytes() * 2); // count for mean}if (!use_local_memory_for_static_shape) {- kd.internalBuffers.push_back(output.PhysicalSizeInBytes() * 2); // reduction value output- kd.internalBuffers.push_back(output.PhysicalSizeInBytes() * 2); // reduction_thread_count output+ kd.internalBuffers.push_back(output.PhysicalSizeInBytes() * 2); // reduction value output+ kd.internalBuffers.push_back(output.PhysicalSizeInBytes() * 2); // reduction_thread_count output}kd.internalBufferDataType = Datatype::INT32;}// Define adjustment map for ITER based on kernel indexconst std::unordered_map<size_t, int> iter_adjust_map = {- {2, -1}, // Kernel 2: decrement by 1- {3, -1}, // Kernel 3: decrement by 1- {4, -2} // Kernel 4: decrement by 2+ {2, -1}, // Kernel 2: decrement by 1+ {3, -1}, // Kernel 3: decrement by 1+ {4, -2} // Kernel 4: decrement by 2};auto adjust_iter = [&](size_t index) {@@ -368,8 +360,19 @@ KernelsData ScatterElementsUpdateKernelRef::GetKernelsData(const Params& params)auto jit = CreateJit(kernelName, cldnn_jit, entry_point);- FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point, "", false, false, 3, GetFusedPrimitiveInputsCount(params), 1,- params.is_shape_agnostic);+ FillCLKernelData(kernel,+ dispatchData,+ params.engineInfo,+ kernelName,+ jit,+ entry_point,+ "",+ false,+ false,+ 3,+ GetFusedPrimitiveInputsCount(params),+ 1,+ params.is_shape_agnostic);uint32_t buf_idx = 0;diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/scatter_update/scatter_update_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/scatter_update/scatter_update_kernel_ref.cppindex 8d49a396eb6..3054c739d89 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/scatter_update/scatter_update_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/scatter_update/scatter_update_kernel_ref.cpp@@ -3,30 +3,32 @@//#include "scatter_update_kernel_ref.h"-#include "kernel_selector_utils.h"+#include <string>#include <vector>+#include "kernel_selector_utils.h"+namespace kernel_selector {static size_t GetScatterUpdateChannelIndex(const scatter_update_params& params) {Tensor::DataChannelName name = Tensor::DataChannelName::X;const size_t dict_size = params.inputs[0].GetDims().size();switch (params.axis) {- case ScatterUpdateAxis::X:- return (size_t)(dict_size - 1);- case ScatterUpdateAxis::Y:- return (size_t)(dict_size - 2);- case ScatterUpdateAxis::Z:- return (size_t)(dict_size - 3);- case ScatterUpdateAxis::W:- return 2;- case ScatterUpdateAxis::FEATURE:- return 1;- case ScatterUpdateAxis::BATCH:- return 0;- default:- break;+ case ScatterUpdateAxis::X:+ return (size_t)(dict_size - 1);+ case ScatterUpdateAxis::Y:+ return (size_t)(dict_size - 2);+ case ScatterUpdateAxis::Z:+ return (size_t)(dict_size - 3);+ case ScatterUpdateAxis::W:+ return 2;+ case ScatterUpdateAxis::FEATURE:+ return 1;+ case ScatterUpdateAxis::BATCH:+ return 0;+ default:+ break;}return DataTensor::Channelndex(params.outputs[0].GetLayout(), name);@@ -58,8 +60,9 @@ ParamsKey ScatterUpdateKernelRef::GetSupportedKey() const {static inline std::string GetOrderString(std::vector<std::string>& order) {std::string order_str = order[0];- for (size_t i = 1; i < order.size(); i++)+ for (size_t i = 1; i < order.size(); i++) {order_str += ", " + order[i];+ }return order_str;}@@ -101,18 +104,18 @@ CommonDispatchData ScatterUpdateKernelRef::SetDefault(const scatter_update_paramif (!is_second) {switch (rank) {- case 4:- dispatchData.gws = {output.X().v, output.Y().v, output.Feature().v * output.Batch().v};- break;- case 5:- dispatchData.gws = {output.X().v * output.Y().v, output.Z().v, output.Feature().v * output.Batch().v};- break;- case 6:- dispatchData.gws = {output.X().v * output.Y().v, output.Z().v * output.W().v, output.Feature().v * output.Batch().v};- break;- default:- throw std::runtime_error("Unsupported combination\n");- break;+ case 4:+ dispatchData.gws = {output.X().v, output.Y().v, output.Feature().v * output.Batch().v};+ break;+ case 5:+ dispatchData.gws = {output.X().v * output.Y().v, output.Z().v, output.Feature().v * output.Batch().v};+ break;+ case 6:+ dispatchData.gws = {output.X().v * output.Y().v, output.Z().v * output.W().v, output.Feature().v * output.Batch().v};+ break;+ default:+ throw std::runtime_error("Unsupported combination\n");+ break;}} else {// second iteration@@ -122,45 +125,48 @@ CommonDispatchData ScatterUpdateKernelRef::SetDefault(const scatter_update_param// e.g., axis = b, input0(10, 9, 10, 9, 10) && input1(4, 2) => input2(8, 9, 10, 9, 10const size_t indices_size = params.inputs[1].LogicalSize();switch (rank) {- case 4:- if (params.axis == ScatterUpdateAxis::BATCH)- dispatchData.gws = {output.X().v, output.Y().v, output.Feature().v * indices_size};- else if (params.axis == ScatterUpdateAxis::FEATURE)- dispatchData.gws = {output.X().v, output.Y().v, indices_size * output.Batch().v};- else if (params.axis == ScatterUpdateAxis::Y)- dispatchData.gws = {output.X().v, indices_size, output.Feature().v * output.Batch().v};- else if (params.axis == ScatterUpdateAxis::X)- dispatchData.gws = {indices_size, output.Y().v, output.Feature().v * output.Batch().v};- break;- case 5:- if (params.axis == ScatterUpdateAxis::BATCH)- dispatchData.gws = {output.X().v * output.Y().v, output.Z().v, output.Feature().v * indices_size};- else if (params.axis == ScatterUpdateAxis::FEATURE)- dispatchData.gws = {output.X().v * output.Y().v, output.Z().v, indices_size * output.Batch().v};- else if (params.axis == ScatterUpdateAxis::Z)- dispatchData.gws = {output.X().v * output.Y().v, indices_size, output.Feature().v * output.Batch().v};- else if (params.axis == ScatterUpdateAxis::Y)- dispatchData.gws = {output.X().v * indices_size, output.Z().v, output.Feature().v * output.Batch().v};- else if (params.axis == ScatterUpdateAxis::X)- dispatchData.gws = {indices_size * output.Y().v, output.Z().v, output.Feature().v * output.Batch().v};- break;- case 6:- if (params.axis == ScatterUpdateAxis::BATCH)- dispatchData.gws = {output.X().v * output.Y().v, output.Z().v * output.W().v, output.Feature().v * indices_size};- else if (params.axis == ScatterUpdateAxis::FEATURE)- dispatchData.gws = {output.X().v * output.Y().v, output.Z().v * output.W().v, indices_size * output.Batch().v};- else if (params.axis == ScatterUpdateAxis::W)- dispatchData.gws = {output.X().v * output.Y().v, output.Z().v * indices_size, output.Feature().v * output.Batch().v};- else if (params.axis == ScatterUpdateAxis::Z)- dispatchData.gws = {output.X().v * output.Y().v, indices_size * output.W().v, output.Feature().v * output.Batch().v};- else if (params.axis == ScatterUpdateAxis::Y)- dispatchData.gws = {output.X().v * indices_size, output.Z().v * output.W().v, output.Feature().v * output.Batch().v};- else if (params.axis == ScatterUpdateAxis::X)- dispatchData.gws = {indices_size * output.Y().v, output.Z().v * output.W().v, output.Feature().v * output.Batch().v};- break;- default:- throw std::runtime_error("Unsupported combination\n");- break;+ case 4:+ if (params.axis == ScatterUpdateAxis::BATCH) {+ dispatchData.gws = {output.X().v, output.Y().v, output.Feature().v * indices_size};+ } else if (params.axis == ScatterUpdateAxis::FEATURE) {+ dispatchData.gws = {output.X().v, output.Y().v, indices_size * output.Batch().v};+ } else if (params.axis == ScatterUpdateAxis::Y) {+ dispatchData.gws = {output.X().v, indices_size, output.Feature().v * output.Batch().v};+ } else if (params.axis == ScatterUpdateAxis::X) {+ dispatchData.gws = {indices_size, output.Y().v, output.Feature().v * output.Batch().v};+ }+ break;+ case 5:+ if (params.axis == ScatterUpdateAxis::BATCH) {+ dispatchData.gws = {output.X().v * output.Y().v, output.Z().v, output.Feature().v * indices_size};+ } else if (params.axis == ScatterUpdateAxis::FEATURE) {+ dispatchData.gws = {output.X().v * output.Y().v, output.Z().v, indices_size * output.Batch().v};+ } else if (params.axis == ScatterUpdateAxis::Z) {+ dispatchData.gws = {output.X().v * output.Y().v, indices_size, output.Feature().v * output.Batch().v};+ } else if (params.axis == ScatterUpdateAxis::Y) {+ dispatchData.gws = {output.X().v * indices_size, output.Z().v, output.Feature().v * output.Batch().v};+ } else if (params.axis == ScatterUpdateAxis::X) {+ dispatchData.gws = {indices_size * output.Y().v, output.Z().v, output.Feature().v * output.Batch().v};+ }+ break;+ case 6:+ if (params.axis == ScatterUpdateAxis::BATCH) {+ dispatchData.gws = {output.X().v * output.Y().v, output.Z().v * output.W().v, output.Feature().v * indices_size};+ } else if (params.axis == ScatterUpdateAxis::FEATURE) {+ dispatchData.gws = {output.X().v * output.Y().v, output.Z().v * output.W().v, indices_size * output.Batch().v};+ } else if (params.axis == ScatterUpdateAxis::W) {+ dispatchData.gws = {output.X().v * output.Y().v, output.Z().v * indices_size, output.Feature().v * output.Batch().v};+ } else if (params.axis == ScatterUpdateAxis::Z) {+ dispatchData.gws = {output.X().v * output.Y().v, indices_size * output.W().v, output.Feature().v * output.Batch().v};+ } else if (params.axis == ScatterUpdateAxis::Y) {+ dispatchData.gws = {output.X().v * indices_size, output.Z().v * output.W().v, output.Feature().v * output.Batch().v};+ } else if (params.axis == ScatterUpdateAxis::X) {+ dispatchData.gws = {indices_size * output.Y().v, output.Z().v * output.W().v, output.Feature().v * output.Batch().v};+ }+ break;+ default:+ throw std::runtime_error("Unsupported combination\n");+ break;}}dispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo);@@ -196,17 +202,16 @@ JitConstants ScatterUpdateKernelRef::GetJitConstants(const scatter_update_paramsconst auto input2_has_padding = params.inputs[2].has_dynamic_pad() || params.inputs[2].PitchesDifferFromLogicalDims();// In case of padded input2 (updates), we also need non-planar indexing, because UPDATES_INDEX is calculated based on output sizes- const auto use_layout_aware_indexing = !SimpleLayout(params.inputs[0].GetLayout()) ||- !SimpleLayout(params.inputs[1].GetLayout()) ||- !SimpleLayout(params.inputs[2].GetLayout()) || input2_has_padding;+ const auto use_layout_aware_indexing = !SimpleLayout(params.inputs[0].GetLayout()) || !SimpleLayout(params.inputs[1].GetLayout()) ||+ !SimpleLayout(params.inputs[2].GetLayout()) || input2_has_padding;if (use_layout_aware_indexing) {jit.AddConstant(MakeJitConstant("USE_LAYOUT_AWARE_INDEXING", "1"));}jit.AddConstant(MakeJitConstant("UPDATES_INDEX_ORDER", GetUpdatesIndexOrder(params)));- jit.AddConstant(MakeJitConstant("SECOND_ITER_OUTPUT_INDEX_ORDER",- GetSecondIterOutputIndexOrder(params, static_cast<size_t>(GetScatterUpdateChannelIndex(params)))));+ jit.AddConstant(+ MakeJitConstant("SECOND_ITER_OUTPUT_INDEX_ORDER", GetSecondIterOutputIndexOrder(params, static_cast<size_t>(GetScatterUpdateChannelIndex(params)))));jit.AddConstant(MakeJitConstant("OUTPUT_INDEX_ON_AXIS", GetOutputIndexOnAxis(params, GetScatterUpdateChannelIndex(params))));jit.AddConstant(MakeJitConstant("AXIS_VALUE", axis_value));@@ -220,7 +225,7 @@ JitConstants ScatterUpdateKernelRef::GetJitConstants(const scatter_update_paramsstd::string get_update_idx = use_layout_aware_indexing ? "0" : "(INPUT2_OFFSET)";std::string get_update_idx_src = "UPDATES_GET_INDEX(";for (size_t i = 0; i < dims; ++i) {- if (i == dims-1) {+ if (i == dims - 1) {get_update_idx_src += default_order[i] + ")";std::string def_pitch = "UPDATES_" + GetAxisName(dims, i) + "_PITCH";std::string src_pitch = "1";@@ -234,10 +239,11 @@ JitConstants ScatterUpdateKernelRef::GetJitConstants(const scatter_update_paramsget_update_idx_src += default_order[i] + ", ";std::string def_pitch = "UPDATES_" + GetAxisName(dims, i) + "_PITCH" + "";std::string output_size_name;- if (i == 0)+ if (i == 0) {output_size_name = "OUTPUT_FEATURE_NUM";- else+ } else {output_size_name = "OUTPUT_SIZE_" + GetAxisName(dims, i + 1);+ }std::string src_pitch = "(UPDATES_" + GetAxisName(dims, i + 1) + "_PITCH * " + output_size_name + ")";jit.AddConstant(MakeJitConstant(def_pitch, src_pitch));}@@ -246,9 +252,11 @@ JitConstants ScatterUpdateKernelRef::GetJitConstants(const scatter_update_paramsjit.AddConstant(MakeJitConstant(get_update_idx_src, get_update_idx));if (!params.fused_ops.empty()) {- FusedOpsConfiguration conf1 = { "_FIRST_KERNEL", GetDefaultOrder(output.GetDims().size()), "val", params.inputs[0].GetDType() };- FusedOpsConfiguration conf2 = { "_SECOND_KERNEL", GetVectorSecondOutputIndexOrder(params, GetScatterUpdateChannelIndex(params)),- "val", params.inputs[0].GetDType() };+ FusedOpsConfiguration conf1 = {"_FIRST_KERNEL", GetDefaultOrder(output.GetDims().size()), "val", params.inputs[0].GetDType()};+ FusedOpsConfiguration conf2 = {"_SECOND_KERNEL",+ GetVectorSecondOutputIndexOrder(params, GetScatterUpdateChannelIndex(params)),+ "val",+ params.inputs[0].GetDType()};jit.Merge(MakeFusedOpsJitConstants(params, {conf1, conf2}));}@@ -256,15 +264,16 @@ JitConstants ScatterUpdateKernelRef::GetJitConstants(const scatter_update_params}bool ScatterUpdateKernelRef::Validate(const Params& p) const {- if (p.GetType() != KernelType:: SCATTER_UPDATE) {+ if (p.GetType() != KernelType::SCATTER_UPDATE) {DO_NOT_USE_THIS_KERNEL(p.layerID);}const scatter_update_params& params = static_cast<const scatter_update_params&>(p);for (const auto& fused_op : params.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}return true;@@ -319,8 +328,19 @@ KernelsData ScatterUpdateKernelRef::GetKernelsData(const Params& params) const {clKernelData& kernel = kd.kernels[i - start_with_iteration];- FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point,- "", false, false, 3, GetFusedPrimitiveInputsCount(params), 1, newParams.is_shape_agnostic);+ FillCLKernelData(kernel,+ dispatchData,+ params.engineInfo,+ kernelName,+ jit,+ entry_point,+ "",+ false,+ false,+ 3,+ GetFusedPrimitiveInputsCount(params),+ 1,+ newParams.is_shape_agnostic);}return {kd};diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/shuffle_channels/shuffle_channels_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/shuffle_channels/shuffle_channels_kernel_ref.cppindex 37d035d8dcf..830267008bb 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/shuffle_channels/shuffle_channels_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/shuffle_channels/shuffle_channels_kernel_ref.cpp@@ -34,8 +34,9 @@ bool ShuffleChannelsKernelRef::Validate(const Params& p) const {const shuffle_channels_params& params = static_cast<const shuffle_channels_params&>(p);- if (params.inputs[0].Dimentions() > 4)+ if (params.inputs[0].Dimentions() > 4) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/slice/slice_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/slice/slice_kernel_ref.cppindex 9dffb5b4af3..18d528407f0 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/slice/slice_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/slice/slice_kernel_ref.cpp@@ -114,11 +114,13 @@ bool SliceKernelRef::Validate(const Params &p) const {}const slice_params ¶ms = dynamic_cast<const slice_params&>(p);- if (params.inputs.empty())+ if (params.inputs.empty()) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (params.outputs[0].Dimentions() > MAX_SUPPORTED_DIM || params.inputs[0].Dimentions() > MAX_SUPPORTED_DIM)+ if (params.outputs[0].Dimentions() > MAX_SUPPORTED_DIM || params.inputs[0].Dimentions() > MAX_SUPPORTED_DIM) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/softmax/softmax_items_class_kernel_base.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/softmax/softmax_items_class_kernel_base.hindex 13241bd735c..72b6cfed573 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/softmax/softmax_items_class_kernel_base.h+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/softmax/softmax_items_class_kernel_base.h@@ -4,9 +4,10 @@#pragma once-#include "softmax_kernel_base.h"#include <vector>+#include "softmax_kernel_base.h"+namespace kernel_selector {class SoftmaxItemsClassKernelBase : public SoftmaxKernelBase {public:@@ -18,12 +19,13 @@ protected:static ParamsKey GetDefaultSupportedKey();static std::vector<size_t> GetSoftmaxDimGlobalSizes(SoftmaxDim dim, const DataTensor& output);Datatype GetAccumulatorType(const softmax_params& params) const {- if (params.inputs[0].GetDType() == Datatype::F16)+ if (params.inputs[0].GetDType() == Datatype::F16) {return Datatype::F16;+ }return Datatype::F32;}std::vector<KernelBase::FusedOpType> GetSupportedFusedOps() const override {- return { FusedOpType::QUANTIZE };+ return {FusedOpType::QUANTIZE};}};} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/softmax/softmax_kernel_base.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/softmax/softmax_kernel_base.hindex 1c6e2f35b37..0566deb7846 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/softmax/softmax_kernel_base.h+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/softmax/softmax_kernel_base.h@@ -47,8 +47,9 @@ protected:virtual DispatchData SetDefault(const softmax_params& params) const;KernelsData GetCommonKernelsData(const Params& params) const;Datatype GetActivationType(const softmax_params& params) const {- if (params.inputs[0].GetDType() == Datatype::F16)+ if (params.inputs[0].GetDType() == Datatype::F16) {return Datatype::F16;+ }return Datatype::F32;}};diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/softmax/softmax_kernel_bf.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/softmax/softmax_kernel_bf.cppindex 8d4d772e252..f314bd0efac 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/softmax/softmax_kernel_bf.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/softmax/softmax_kernel_bf.cpp@@ -68,14 +68,15 @@ SoftmaxKernel_bf::Parent::DispatchData SoftmaxKernel_bf::SetDefault(const softmaif ((dispatchData.dataSetsCount > 1) && ((dataSetSizeInByte - ((dataSetSizeInByte >> 4) << 4)))) {dispatchData.subgroupBlockSize = 1;} else {- if (dispatchData.itemsNum >> 3)+ if (dispatchData.itemsNum >> 3) {dispatchData.subgroupBlockSize = 8;- else if (dispatchData.itemsNum >> 2)+ } else if (dispatchData.itemsNum >> 2) {dispatchData.subgroupBlockSize = 4;- else if (dispatchData.itemsNum >> 1)+ } else if (dispatchData.itemsNum >> 1) {dispatchData.subgroupBlockSize = 2;- else+ } else {dispatchData.subgroupBlockSize = 1;+ }}assert((dispatchData.itemsNum + 1) * dispatchData.lws[0] >= dispatchData.dataSetSize && "More than 'lws[0]' items per batch remains! Lws too small?");diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/space_to_batch/space_to_batch_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/space_to_batch/space_to_batch_kernel_base.cppindex facc61cb8dd..9ee5e47999b 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/space_to_batch/space_to_batch_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/space_to_batch/space_to_batch_kernel_base.cpp@@ -3,9 +3,11 @@//#include "space_to_batch_kernel_base.h"-#include "kernel_selector_utils.h"+#include <string>+#include "kernel_selector_utils.h"+namespace kernel_selector {bool SpaceToBatchKernelBase::Validate(const Params& p) const {@@ -15,12 +17,14 @@ bool SpaceToBatchKernelBase::Validate(const Params& p) const {const space_to_batch_params& params = static_cast<const space_to_batch_params&>(p);for (const auto& fused_op : params.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}- if (params.inputs[0].Dimentions() > 6)+ if (params.inputs[0].Dimentions() > 6) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}@@ -33,14 +37,13 @@ CommonDispatchData SpaceToBatchKernelBase::SetDefault(const space_to_batch_paramCommonDispatchData dispatchData;if (out.GetLayout() == DataLayout::b_fs_yx_fsv16 && out.Feature().v % 16 == 0) {- dispatchData.gws = { out.Batch().v, out.Feature().v, out.Y().v * out.X().v };- dispatchData.lws = { 1, 16, 1 };+ dispatchData.gws = {out.Batch().v, out.Feature().v, out.Y().v * out.X().v};+ dispatchData.lws = {1, 16, 1};} else {- dispatchData.gws = { out.Batch().v, out.Feature().v, out.W().v * out.Z().v * out.Y().v * out.X().v };- dims_by_gws = {{ Tensor::DataChannelName::BATCH },- { Tensor::DataChannelName::FEATURE },- { Tensor::DataChannelName::X, Tensor::DataChannelName::Y,- Tensor::DataChannelName::Z, Tensor::DataChannelName::W }};+ dispatchData.gws = {out.Batch().v, out.Feature().v, out.W().v * out.Z().v * out.Y().v * out.X().v};+ dims_by_gws = {{Tensor::DataChannelName::BATCH},+ {Tensor::DataChannelName::FEATURE},+ {Tensor::DataChannelName::X, Tensor::DataChannelName::Y, Tensor::DataChannelName::Z, Tensor::DataChannelName::W}};dispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo, in_layout, out_layout, dims_by_gws);}@@ -112,10 +115,20 @@ KernelsData SpaceToBatchKernelBase::GetCommonKernelsData(const Params& params) cauto& kernel = kd.kernels[0];- FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point,- "", false, false, static_cast<int>(newParams.inputs.size()),- GetFusedPrimitiveInputsCount(params), 1, newParams.is_shape_agnostic);-- return { kd };+ FillCLKernelData(kernel,+ dispatchData,+ params.engineInfo,+ kernelName,+ jit,+ entry_point,+ "",+ false,+ false,+ static_cast<int>(newParams.inputs.size()),+ GetFusedPrimitiveInputsCount(params),+ 1,+ newParams.is_shape_agnostic);++ return {kd};}} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/space_to_depth/space_to_depth_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/space_to_depth/space_to_depth_kernel_ref.cppindex 3fe686a0bee..72317809ee4 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/space_to_depth/space_to_depth_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/space_to_depth/space_to_depth_kernel_ref.cpp@@ -3,10 +3,12 @@//#include "space_to_depth_kernel_ref.h"-#include "kernel_selector_utils.h"+#include <string>#include <vector>+#include "kernel_selector_utils.h"+namespace kernel_selector {ParamsKey SpaceToDepthKernelRef::GetSupportedKey() const {ParamsKey k;@@ -36,12 +38,14 @@ bool SpaceToDepthKernelRef::Validate(const Params& p) const {const space_to_depth_params& params = static_cast<const space_to_depth_params&>(p);for (const auto& fused_op : params.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}- if (params.inputs[0].Dimentions() > 5)+ if (params.inputs[0].Dimentions() > 5) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}@@ -50,13 +54,13 @@ CommonDispatchData SpaceToDepthKernelRef::SetDefault(const space_to_depth_paramsCommonDispatchData dispatchData;auto in_layout = params.inputs[0].GetLayout();auto out_layout = params.outputs[0].GetLayout();- std::vector<std::vector<Tensor::DataChannelName>> dims_by_gws = {{ Tensor::DataChannelName::BATCH },- { Tensor::DataChannelName::FEATURE },- { Tensor::DataChannelName::X, Tensor::DataChannelName::Y, Tensor::DataChannelName::Z }};+ std::vector<std::vector<Tensor::DataChannelName>> dims_by_gws = {{Tensor::DataChannelName::BATCH},+ {Tensor::DataChannelName::FEATURE},+ {Tensor::DataChannelName::X, Tensor::DataChannelName::Y, Tensor::DataChannelName::Z}};- dispatchData.gws = { params.outputs[0].Batch().v,- params.outputs[0].Feature().v,- params.outputs[0].Z().v * params.outputs[0].Y().v * params.outputs[0].X().v };+ dispatchData.gws = {params.outputs[0].Batch().v,+ params.outputs[0].Feature().v,+ params.outputs[0].Z().v * params.outputs[0].Y().v * params.outputs[0].X().v};dispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo, in_layout, out_layout, dims_by_gws);return dispatchData;@@ -66,10 +70,11 @@ JitConstants SpaceToDepthKernelRef::GetJitConstants(const space_to_depth_params&JitConstants jit = MakeBaseParamsJitConstants(params);jit.AddConstant(MakeJitConstant("BLOCK_SIZE", params.block_size));- if (params.depth_mode == SpaceToDepthMode::BLOCKS_FIRST)+ if (params.depth_mode == SpaceToDepthMode::BLOCKS_FIRST) {jit.AddConstant(MakeJitConstant("BLOCKS_FIRST_MODE", true));- else+ } else {jit.AddConstant(MakeJitConstant("DEPTH_FIRST_MODE", true));+ }auto input = params.inputs[0];auto input_dt = input.GetDType();@@ -102,8 +107,17 @@ KernelsData SpaceToDepthKernelRef::GetKernelsData(const Params& params) const {auto& kernel = kd.kernels[0];- FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point,- EXE_MODE_DEFAULT, false, false, 1, GetFusedPrimitiveInputsCount(params));+ FillCLKernelData(kernel,+ dispatchData,+ params.engineInfo,+ kernelName,+ jit,+ entry_point,+ EXE_MODE_DEFAULT,+ false,+ false,+ 1,+ GetFusedPrimitiveInputsCount(params));return {kd};}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/stft/stft_kernel_opt.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/stft/stft_kernel_opt.cppindex 34dc9fda62a..c1ef8a5fe67 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/stft/stft_kernel_opt.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/stft/stft_kernel_opt.cpp@@ -69,14 +69,16 @@ CommonDispatchData STFTKernelOpt::CalcLaunchConfig(const STFT_params& params) co}bool STFTKernelOpt::Validate(const Params& p) const {- if (!STFTKernelBase::Validate(p))+ if (!STFTKernelBase::Validate(p)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }const auto& params = static_cast<const STFT_params&>(p);const auto windowSize = params.inputs[1].LogicalSize();- if (params.is_shape_agnostic && windowSize > STATIC_MAX_X_I_BUFFER)+ if (params.is_shape_agnostic && windowSize > STATIC_MAX_X_I_BUFFER) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }return true;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/strided_slice/strided_slice_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/strided_slice/strided_slice_kernel_ref.cppindex 7cf8db93134..97c5471483d 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/strided_slice/strided_slice_kernel_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/strided_slice/strided_slice_kernel_ref.cpp@@ -3,13 +3,15 @@//#include "strided_slice_kernel_ref.h"-#include "kernel_selector_utils.h"+#include <string>#include <vector>+#include "kernel_selector_utils.h"+namespace kernel_selector {-template<typename T>+template <typename T>static void makeJitConstForParam(JitConstants& jit, const std::string name, const T& vec) {jit.AddConstant(MakeJitConstant(name + "_SIZES", vec));jit.AddConstant(MakeJitConstant(name + "_BATCH", vec[0]));@@ -34,7 +36,7 @@ static void makeJitConstForParam(JitConstants& jit, const std::string name, consstatic size_t GetUsedOutDimsCount(const strided_slice_params& params) {auto dims = params.outputs[0].GetDims();- size_t first_non_unit_dim = 0; // order is xy(zw)fb, so by default consider that we use all dims+ size_t first_non_unit_dim = 0; // order is xy(zw)fb, so by default consider that we use all dimsfor (size_t i = 0; i < dims.size(); i++) {if (dims[i].v != 1) {break;@@ -76,15 +78,18 @@ bool StridedSliceKernelRef::Validate(const Params& p) const {}const strided_slice_params& params = static_cast<const strided_slice_params&>(p);- if (params.inputs.empty())+ if (params.inputs.empty()) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }- if (params.outputs[0].Dimentions() > 6 || params.inputs[0].Dimentions() > 6)+ if (params.outputs[0].Dimentions() > 6 || params.inputs[0].Dimentions() > 6) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }for (const auto& fused_op : params.fused_ops) {- if (!IsFusedPrimitiveSupported(fused_op))+ if (!IsFusedPrimitiveSupported(fused_op)) {DO_NOT_USE_THIS_KERNEL(p.layerID);+ }}bool shrink_mode = std::find(params.shrink_axis_mask.begin(), params.shrink_axis_mask.end(), 1) != params.shrink_axis_mask.end();@@ -106,17 +111,17 @@ CommonDispatchData StridedSliceKernelRef::SetDefault(const strided_slice_params&CommonDispatchData dispatchData;auto in_layout = params.inputs[0].GetLayout();auto out_layout = params.outputs[0].GetLayout();- std::vector<std::vector<Tensor::DataChannelName>> dims_by_gws = {{ Tensor::DataChannelName::BATCH },- { Tensor::DataChannelName::FEATURE },- { Tensor::DataChannelName::X, Tensor::DataChannelName::Y,- Tensor::DataChannelName::Z, Tensor::DataChannelName::W }};+ std::vector<std::vector<Tensor::DataChannelName>> dims_by_gws = {+ {Tensor::DataChannelName::BATCH},+ {Tensor::DataChannelName::FEATURE},+ {Tensor::DataChannelName::X, Tensor::DataChannelName::Y, Tensor::DataChannelName::Z, Tensor::DataChannelName::W}};// If the new_axis_mask is set, then begin, end, and stride are ignored// and a new length 1 dimension is adding. Input data just copying to output// TODO: remove data copying in case where only shape size changing- dispatchData.gws = { params.outputs[0].Batch().v,- params.outputs[0].Feature().v,- params.outputs[0].W().v * params.outputs[0].Z().v * params.outputs[0].Y().v * params.outputs[0].X().v };+ dispatchData.gws = {params.outputs[0].Batch().v,+ params.outputs[0].Feature().v,+ params.outputs[0].W().v * params.outputs[0].Z().v * params.outputs[0].Y().v * params.outputs[0].X().v};dispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo, in_layout, out_layout, dims_by_gws);@@ -163,9 +168,7 @@ JitConstants StridedSliceKernelRef::GetJitConstants(const strided_slice_params&} else {makeJitConstForParam(jit, "SLICE_STEPS", params.striding_params[2]);}- jit.AddConstant(MakeJitConstant(- "NEW_AXIS_MODE",- std::find(params.new_axis_mask.begin(), params.new_axis_mask.end(), 1) != params.new_axis_mask.end()));+ jit.AddConstant(MakeJitConstant("NEW_AXIS_MODE", std::find(params.new_axis_mask.begin(), params.new_axis_mask.end(), 1) != params.new_axis_mask.end()));std::vector<int> dims_indexes;bool ellipsis_mode = std::find(params.ellipsis_mask.begin(), params.ellipsis_mask.end(), 1) != params.ellipsis_mask.end();@@ -182,15 +185,18 @@ JitConstants StridedSliceKernelRef::GetJitConstants(const strided_slice_params&const size_t skip_dims_num = output_rank - params.ellipsis_mask.size() + 1;int dim_counter = 0;- for (size_t i = 0; i < ellipsis_pos1; i++)+ for (size_t i = 0; i < ellipsis_pos1; i++) {dims_indexes.push_back(dim_counter++);+ }- for (size_t i = 0; i < skip_dims_num; i++)+ for (size_t i = 0; i < skip_dims_num; i++) {dims_indexes.push_back(-1);+ }dim_counter++;- for (size_t i = 0; i < params.ellipsis_mask.size() - ellipsis_pos1 - 1; i++)+ for (size_t i = 0; i < params.ellipsis_mask.size() - ellipsis_pos1 - 1; i++) {dims_indexes.push_back(dim_counter++);+ }OPENVINO_ASSERT(dims_indexes.size() == output_rank, "[GPU] Number of indexes is expected to match with output rank");} else {@@ -204,12 +210,13 @@ JitConstants StridedSliceKernelRef::GetJitConstants(const strided_slice_params&jit.AddConstant(MakeJitConstant("SHRINK_MODE", true));makeJitConstForParam(jit, "SHRINK", params.shrink_axis_mask);std::vector<std::string> bfwzyx_in_order;- if (params.outputs[0].Dimentions() == 6)+ if (params.outputs[0].Dimentions() == 6) {bfwzyx_in_order = {"batch", "feature", "w", "z", "y", "x"};- else if (params.outputs[0].Dimentions() == 5)+ } else if (params.outputs[0].Dimentions() == 5) {bfwzyx_in_order = {"batch", "feature", "z", "y", "x"};- else+ } else {bfwzyx_in_order = {"batch", "feature", "y", "x"};+ }// Insert zeroes to indices order for shinked axesfor (size_t i = 0; i < params.shrink_axis_mask.size(); i++) {@@ -219,12 +226,9 @@ JitConstants StridedSliceKernelRef::GetJitConstants(const strided_slice_params&}auto get_input_idx_order = [&](std::vector<std::string> bfwzyx_in_order) -> std::string {- std::string order = bfwzyx_in_order[0] + "," +- bfwzyx_in_order[1] + "," +- bfwzyx_in_order[2] + "," +- bfwzyx_in_order[3] + "," +- bfwzyx_in_order[4];- if (bfwzyx_in_order.size() == 6) order += "," + bfwzyx_in_order[5];+ std::string order = bfwzyx_in_order[0] + "," + bfwzyx_in_order[1] + "," + bfwzyx_in_order[2] + "," + bfwzyx_in_order[3] + "," + bfwzyx_in_order[4];+ if (bfwzyx_in_order.size() == 6)+ order += "," + bfwzyx_in_order[5];return order;};// Erase indices that exceeds 6d tensor. It should be safe, because we check in Validate method that@@ -284,9 +288,19 @@ KernelsData StridedSliceKernelRef::GetKernelsData(const Params& params) const {GetUpdateDispatchDataFunc(kd);- FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point,- "", false, false, static_cast<int>(newParams.inputs.size()),- 0, 1, newParams.is_shape_agnostic);+ FillCLKernelData(kernel,+ dispatchData,+ params.engineInfo,+ kernelName,+ jit,+ entry_point,+ "",+ false,+ false,+ static_cast<int>(newParams.inputs.size()),+ 0,+ 1,+ newParams.is_shape_agnostic);return {kd};}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/swiglu/swiglu_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/swiglu/swiglu_kernel_base.cppindex e642f6d87d3..0ae39e833c9 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/swiglu/swiglu_kernel_base.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/swiglu/swiglu_kernel_base.cpp@@ -3,6 +3,7 @@//#include "swiglu_kernel_base.h"+#include "kernel_selector_utils.h"namespace kernel_selector {@@ -54,8 +55,9 @@ JitConstants SwiGLUKernelBase::GetJitConstants(const swiglu_params& params, consKernelsData SwiGLUKernelBase::GetKernelsData(const Params& params) const {assert(params.GetType() == KernelType::SWIGLU);- if (!Validate(params))+ if (!Validate(params)) {return {};+ }const swiglu_params& orgParams = static_cast<const swiglu_params&>(params);auto dispatchData = SetDefault(orgParams);@@ -86,21 +88,24 @@ KernelsData SwiGLUKernelBase::GetKernelsData(const Params& params) const {return {kd};}-bool SwiGLUKernelBase::Validate(const Params& params) const {- if (!KernelBaseOpenCL::Validate(params))+ if (!KernelBaseOpenCL::Validate(params)) {DO_NOT_USE_THIS_KERNEL(params.layerID);+ }return true;}Datatype SwiGLUKernelBase::GetAccumulatorType(const swiglu_params& params) const {- Datatype types[] = { Datatype::F32, Datatype::F16, Datatype::INT64, Datatype::INT32, Datatype::UINT32};+ Datatype types[] = {Datatype::F32, Datatype::F16, Datatype::INT64, Datatype::INT32, Datatype::UINT32};- for (Datatype type : types)- for (const auto& in : params.inputs)- if (in.GetDType() == type)+ for (Datatype type : types) {+ for (const auto& in : params.inputs) {+ if (in.GetDType() == type) {return type;+ }+ }+ }return Datatype::F32;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/tensor_type.cpp b/src/plugins/intel_gpu/src/kernel_selector/tensor_type.cppindex 8129fe93b04..f253cbd1ad3 100644--- a/src/plugins/intel_gpu/src/kernel_selector/tensor_type.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/tensor_type.cpp@@ -512,10 +512,12 @@ void DataTensor::SwapXY() {auto x = X();auto y = Y();- if (GetLayout() != DataLayout::bfyx)+ if (GetLayout() != DataLayout::bfyx) {throw std::runtime_error("Unsupported - unsupported layout.");- if (x.pad.Total() != 0 || x.v != 1)+ }+ if (x.pad.Total() != 0 || x.v != 1) {throw std::runtime_error("Unsupported - unsupported shape.");+ }// Swap XY axes.y.pitch = 1;@@ -951,8 +953,9 @@ WeightsTensor WeightsTensor::TransformIgnorePadding(WeightsLayout l, WeightsTypevec[Channelndex(l, WeightsChannelName::OFM)] /= g;}- if (should_split && !DoesGroupDimExist(l))+ if (should_split && !DoesGroupDimExist(l)) {vec[Channelndex(l, WeightsChannelName::OFM)] /= g;+ }return {vec, t, l};}@@ -960,8 +963,9 @@ WeightsTensor WeightsTensor::TransformIgnorePadding(WeightsLayout l, WeightsTypevoid WeightsTensor::SwapXY() {auto x = X();- if (x.pad.Total() != 0 || x.v != 1)+ if (x.pad.Total() != 0 || x.v != 1) {throw std::runtime_error("Unsupported - unsupported weight shape.");+ }std::vector<size_t> vec;for (auto& d : dims) {diff --git a/src/plugins/intel_gpu/src/kernel_selector/tensor_type.h b/src/plugins/intel_gpu/src/kernel_selector/tensor_type.hindex f04db9bc342..b7470399922 100644--- a/src/plugins/intel_gpu/src/kernel_selector/tensor_type.h+++ b/src/plugins/intel_gpu/src/kernel_selector/tensor_type.h@@ -198,8 +198,9 @@ struct Pad {static size_t NumPadOffsetsPerDim() { return 2; /*pad_before/pad_after*/}size_t Total(bool is_runtime = false) const {- if (!is_runtime)+ if (!is_runtime) {OPENVINO_ASSERT(!is_dynamic, "Total() is called for dynamic pad!");+ }return before + after;}};@@ -490,8 +491,9 @@ protected:size_t channel = static_cast<size_t>(channelName);for (auto& entry : channelArr) {- if (entry.first == l)+ if (entry.first == l) {return entry.second[channel];+ }}return -1;@@ -510,9 +512,10 @@ protected:std::end(channelArr),[&](typename std::tuple_element<0, ArrayT>::type entry) { return entry.first == l; });- if (entry == channelArr.end())+ if (entry == channelArr.end()) {throw std::invalid_argument("Failed to get channels count for layout " +std::to_string(static_cast<uint32_t>(l)));+ }return std::accumulate(entry->second.begin(), entry->second.end(), 0U, [](uint32_t count, int v) {return count + ((v != -1) ? 1 : 0);diff --git a/src/plugins/intel_gpu/src/kernel_selector/weight_bias_params.cpp b/src/plugins/intel_gpu/src/kernel_selector/weight_bias_params.cppindex df1f9276ff4..22725761bf5 100644--- a/src/plugins/intel_gpu/src/kernel_selector/weight_bias_params.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/weight_bias_params.cpp@@ -35,12 +35,15 @@ std::string weight_bias_zero_point_params::to_cache_string_v2() const {std::stringstream s;s << weight_bias_params::to_cache_string_v2();- if (!activations_zero_points.empty())+ if (!activations_zero_points.empty()) {s << ";activation_zp";- if (!weights_zero_points.empty())+ }+ if (!weights_zero_points.empty()) {s << ";weights_zp";- if (HasCompensation())+ }+ if (HasCompensation()) {s << ";compensation";+ }return s.str();}diff --git a/src/plugins/intel_gpu/src/plugin/common_utils.cpp b/src/plugins/intel_gpu/src/plugin/common_utils.cppindex 5fa34249a98..506a2c758ae 100644--- a/src/plugins/intel_gpu/src/plugin/common_utils.cpp+++ b/src/plugins/intel_gpu/src/plugin/common_utils.cpp@@ -62,8 +62,9 @@ static inline void convert_and_copy_padded_source_fast(const src_t* src, dst_t*int64_t element_sizes[6] = {b, f, x, y, z, w};size_t offset = element_sizes[axes_map[0]];- for (size_t i = 1; i < map_len; i++)+ for (size_t i = 1; i < map_len; i++) {offset = offset * padded_sizes[i] + element_sizes[axes_map[i]];+ }*dst++ = static_cast<dst_t>(src[offset]);}@@ -99,8 +100,9 @@ void convert_and_copy_padded_source(const src_t* src, dst_t* dst, layout& layouttemplate <typename src_t, typename dst_t>void convert_and_copy_no_pad(const src_t* src, dst_t* dst, size_t size) {OPENVINO_ASSERT(src && dst, "[GPU] Src or Dst ptr is null");- for (size_t i = 0; i < size; i++)+ for (size_t i = 0; i < size; i++) {dst[i] = static_cast<dst_t>(src[i]);+ }}template <typename src_t, typename dst_t>@@ -123,8 +125,9 @@ void convert_and_copy_transposed(const src_t* src, dst_t* dst, ov::Shape shape)void convert_and_copy(const void* src_ptr, ov::element::Type src_et, void* dst_ptr, ov::element::Type dst_et,size_t size, cldnn::layout layout, bool transpose = false) {- if (size == 0)+ if (size == 0) {return;+ }if (src_et == dst_et && !layout.data_padding && !transpose) {std::memcpy(dst_ptr, src_ptr, size * src_et.size());@@ -216,13 +219,15 @@ bool is_supported(ov::element::Type_t et) {bool data_types_are_supported(const ov::Node* node) {for (size_t i = 0; i < node->get_input_size(); i++) {- if (!is_supported(node->get_input_element_type(i)))+ if (!is_supported(node->get_input_element_type(i))) {return false;+ }}for (size_t i = 0; i < node->get_output_size(); i++) {- if (!is_supported(node->get_output_element_type(i)))+ if (!is_supported(node->get_output_element_type(i))) {return false;+ }}return true;@@ -341,8 +346,9 @@ std::vector<cldnn::optional_data_type> get_output_data_types(const ov::Node* op,std::vector<cldnn::optional_data_type> output_data_types;for (size_t i = 0; i < op->get_output_size(); i++) {auto type = op->get_output_element_type(i);- if (precision_map.find(type) != precision_map.end())+ if (precision_map.find(type) != precision_map.end()) {type = precision_map.at(type);+ }output_data_types.push_back(cldnn::element_type_to_data_type(type));}return output_data_types;diff --git a/src/plugins/intel_gpu/src/plugin/compiled_model.cpp b/src/plugins/intel_gpu/src/plugin/compiled_model.cppindex 232df805e86..93b950f9c76 100644--- a/src/plugins/intel_gpu/src/plugin/compiled_model.cpp+++ b/src/plugins/intel_gpu/src/plugin/compiled_model.cpp@@ -352,8 +352,9 @@ ov::Any CompiledModel::get_property(const std::string& name) const {}if (name == ov::optimal_number_of_infer_requests) {unsigned int nr = m_config.get_num_streams();- if (m_config.get_performance_mode() != ov::hint::PerformanceMode::LATENCY)+ if (m_config.get_performance_mode() != ov::hint::PerformanceMode::LATENCY) {nr *= 2;+ }return decltype(ov::optimal_number_of_infer_requests)::value_type {nr};}if (name == ov::execution_devices) {diff --git a/src/plugins/intel_gpu/src/plugin/custom_layer.cpp b/src/plugins/intel_gpu/src/plugin/custom_layer.cppindex fee62cc9c5a..977d68465e8 100644--- a/src/plugins/intel_gpu/src/plugin/custom_layer.cpp+++ b/src/plugins/intel_gpu/src/plugin/custom_layer.cpp@@ -4,27 +4,32 @@#include "intel_gpu/plugin/custom_layer.hpp"-#include "intel_gpu/plugin/simple_math.hpp"-#include "intel_gpu/runtime/itt.hpp"-#include "openvino/core/except.hpp"-#include "openvino/util/xml_parse_utils.hpp"-#include <climits>#include <fstream>#include <map>#include <streambuf>+#include "intel_gpu/plugin/simple_math.hpp"+#include "intel_gpu/runtime/itt.hpp"+#include "openvino/core/except.hpp"+#include "openvino/util/xml_parse_utils.hpp"+#ifdef _WIN32-# ifndef NOMINMAX-# define NOMINMAX-# endif-# include <windows.h>+# ifndef NOMINMAX+# define NOMINMAX+# endif+# include <windows.h>#endifusing namespace ov::util::pugixml;#define CheckAndReturnError(cond, errorMsg) \- if (cond) { std::stringstream ss; ss << errorMsg; m_ErrorMessage = ss.str(); return; }+ if (cond) { \+ std::stringstream ss; \+ ss << errorMsg; \+ m_ErrorMessage = ss.str(); \+ return; \+ }#define CheckNodeTypeAndReturnError(node, type) \CheckAndReturnError((std::string(node.name()).compare(type)), "Wrong node! expected: " << #type << " found: " << node.name())#define CheckStrAttrAndReturnError(node, attr, value) \@@ -34,7 +39,7 @@ using namespace ov::util::pugixml;namespace ov::intel_gpu {-void CustomLayer::LoadSingleLayer(const pugi::xml_node & node) {+void CustomLayer::LoadSingleLayer(const pugi::xml_node& node) {// Root checksCheckNodeTypeAndReturnError(node, "CustomLayer");CheckStrAttrAndReturnError(node, "type", "SimpleGPU");@@ -49,14 +54,14 @@ void CustomLayer::LoadSingleLayer(const pugi::xml_node & node) {ProcessWorkSizesNode(node.child("WorkSizes"));}-void CustomLayer::ProcessKernelNode(const pugi::xml_node & node) {+void CustomLayer::ProcessKernelNode(const pugi::xml_node& node) {CheckNodeTypeAndReturnError(node, "Kernel");CheckAndReturnError(!m_kernelSource.empty(), "Multiple definition of Kernel");m_kernelEntry = get_str_attr(node, "entry", "");CheckAndReturnError(m_kernelEntry.empty(), "No Kernel entry in layer: " << get_str_attr(node.parent(), "name"));// Handle Source nodes- FOREACH_CHILD(sourceNode, node, "Source") {+ FOREACH_CHILD (sourceNode, node, "Source") {// open filestd::string filename = m_configDir + "/" + get_str_attr(sourceNode, "filename", "");std::ifstream inputFile(filename);@@ -68,8 +73,7 @@ void CustomLayer::ProcessKernelNode(const pugi::xml_node & node) {fileContent.reserve(inputFile.tellg());inputFile.seekg(0, std::ios::beg);- fileContent.assign((std::istreambuf_iterator<char>(inputFile)),- std::istreambuf_iterator<char>());+ fileContent.assign((std::istreambuf_iterator<char>(inputFile)), std::istreambuf_iterator<char>());// append to source stringm_kernelSource.append("\n// Custom Layer Kernel " + filename + "\n\n");@@ -77,7 +81,7 @@ void CustomLayer::ProcessKernelNode(const pugi::xml_node & node) {}// Handle Define nodes- FOREACH_CHILD(defineNode, node, "Define") {+ FOREACH_CHILD (defineNode, node, "Define") {KernelDefine kd;kd.name = get_str_attr(defineNode, "name", "");CheckAndReturnError((kd.name.empty()), "Missing name for define node");@@ -92,9 +96,9 @@ void CustomLayer::ProcessKernelNode(const pugi::xml_node & node) {}}-void CustomLayer::ProcessBuffersNode(const pugi::xml_node & node) {+void CustomLayer::ProcessBuffersNode(const pugi::xml_node& node) {CheckNodeTypeAndReturnError(node, "Buffers");- FOREACH_CHILD(tensorNode, node, "Tensor") {+ FOREACH_CHILD (tensorNode, node, "Tensor") {KerenlParam kp;kp.format = FormatFromString(get_str_attr(tensorNode, "format", "BFYX"));CheckAndReturnError(kp.format == cldnn::format::format_num, "Tensor node has an invalid format: " << get_str_attr(tensorNode, "format"));@@ -107,7 +111,7 @@ void CustomLayer::ProcessBuffersNode(const pugi::xml_node & node) {kp.type = ParamType::Input;} else if (typeStr.compare("output") == 0) {kp.type = ParamType::Output;- } else if (typeStr.compare("internal") == 0) {+ } else if (typeStr.compare("internal") == 0) {kp.type = ParamType::Internal;kp.size_expr = get_str_attr(tensorNode, "size", "");CheckAndReturnError(kp.size_expr.empty(), "Internal buffer requires a size attribute");@@ -116,7 +120,7 @@ void CustomLayer::ProcessBuffersNode(const pugi::xml_node & node) {}m_kernelParams.push_back(kp);}- FOREACH_CHILD(dataNode, node, "Data") {+ FOREACH_CHILD (dataNode, node, "Data") {KerenlParam kp;kp.type = ParamType::Data;kp.paramIndex = get_int_attr(dataNode, "arg-index", -1);@@ -127,7 +131,7 @@ void CustomLayer::ProcessBuffersNode(const pugi::xml_node & node) {}}-void CustomLayer::ProcessCompilerOptionsNode(const pugi::xml_node & node) {+void CustomLayer::ProcessCompilerOptionsNode(const pugi::xml_node& node) {if (node.empty()) {return; // Optional node doesn't exist}@@ -136,7 +140,7 @@ void CustomLayer::ProcessCompilerOptionsNode(const pugi::xml_node & node) {m_compilerOptions = get_str_attr(node, "options", "");}-void CustomLayer::ProcessWorkSizesNode(const pugi::xml_node & node) {+void CustomLayer::ProcessWorkSizesNode(const pugi::xml_node& node) {if (node.empty()) {return; // Optional node doesn't exist}@@ -187,13 +191,17 @@ void CustomLayer::ProcessWorkSizesNode(const pugi::xml_node & node) {}}-bool CustomLayer::IsLegalSizeRule(const std::string & rule) {+bool CustomLayer::IsLegalSizeRule(const std::string& rule) {SimpleMathExpression expr;expr.SetVariables({- { 'b', 1 }, { 'B', 1 },- { 'f', 1 }, { 'F', 1 },- { 'y', 1 }, { 'Y', 1 },- { 'x', 1 }, { 'X', 1 },+ {'b', 1},+ {'B', 1},+ {'f', 1},+ {'F', 1},+ {'y', 1},+ {'Y', 1},+ {'x', 1},+ {'X', 1},});if (!expr.SetExpression(rule)) {return false;@@ -207,26 +215,27 @@ bool CustomLayer::IsLegalSizeRule(const std::string & rule) {return true;}-cldnn::format CustomLayer::FormatFromString(const std::string & str) {+cldnn::format CustomLayer::FormatFromString(const std::string& str) {static const std::map<std::string, cldnn::format> FormatNameToType = {- { "BFYX" , cldnn::format::bfyx },- { "bfyx" , cldnn::format::bfyx },+ {"BFYX", cldnn::format::bfyx},+ {"bfyx", cldnn::format::bfyx},- { "BYXF" , cldnn::format::byxf },- { "byxf" , cldnn::format::byxf },+ {"BYXF", cldnn::format::byxf},+ {"byxf", cldnn::format::byxf},- { "FYXB" , cldnn::format::fyxb },- { "fyxb" , cldnn::format::fyxb },+ {"FYXB", cldnn::format::fyxb},+ {"fyxb", cldnn::format::fyxb},- { "YXFB" , cldnn::format::yxfb },- { "yxfb" , cldnn::format::yxfb },+ {"YXFB", cldnn::format::yxfb},+ {"yxfb", cldnn::format::yxfb},- { "ANY" , cldnn::format::any },- { "any" , cldnn::format::any },+ {"ANY", cldnn::format::any},+ {"any", cldnn::format::any},};auto it = FormatNameToType.find(str);- if (it != FormatNameToType.end())+ if (it != FormatNameToType.end()) {return it->second;+ }return cldnn::format::format_num;}@@ -249,7 +258,7 @@ void CustomLayer::LoadFromFile(const std::string configFile, CustomLayerMap& cuschar path[PATH_MAX];char* abs_path_ptr = realpath(configFile.c_str(), path);#else-#error "Intel GPU plugin: unknown target system"+# error "Intel GPU plugin: unknown target system"#endifif (abs_path_ptr == nullptr) {OPENVINO_THROW("Error loading custom layer configuration file: ", configFile, ", ", "Can't get canonicalized absolute pathname.");@@ -262,8 +271,7 @@ void CustomLayer::LoadFromFile(const std::string configFile, CustomLayerMap& cusstd::size_t colon_pos = abs_file_name.find_first_of(":");std::size_t first_slash_pos = abs_file_name.find_first_of("/");- if (dir_split_pos != std::string::npos &&- (colon_pos != std::string::npos || first_slash_pos == 0)) {+ if (dir_split_pos != std::string::npos && (colon_pos != std::string::npos || first_slash_pos == 0)) {// path is absolutedir_path = abs_file_name.substr(0, dir_split_pos);} else {diff --git a/src/plugins/intel_gpu/src/plugin/graph.cpp b/src/plugins/intel_gpu/src/plugin/graph.cppindex 06ff6818f46..594378a935d 100644--- a/src/plugins/intel_gpu/src/plugin/graph.cpp+++ b/src/plugins/intel_gpu/src/plugin/graph.cpp@@ -334,15 +334,17 @@ std::shared_ptr<ov::Model> Graph::get_runtime_model(std::vector<cldnn::primitive{ "space_to_depth", "SpaceToDepth" },};- if (type_n2l.find(cldnn_name) != type_n2l.end())+ if (type_n2l.find(cldnn_name) != type_n2l.end()) {return type_n2l.at(cldnn_name);+ }return cldnn_name;};auto concat_strings = [](std::vector<std::string> strs, char sep) -> std::string {- if (strs.empty())+ if (strs.empty()) {return "";+ }std::string res = strs[0];for (size_t i = 1; i < strs.size(); i++) {@@ -354,8 +356,9 @@ std::shared_ptr<ov::Model> Graph::get_runtime_model(std::vector<cldnn::primitiveauto remove_type_from_name = [](const std::string& name) -> std::string {auto it = std::find(name.begin(), name.end(), ':');- if (it == name.end() || (it + 1) == name.end())+ if (it == name.end() || (it + 1) == name.end()) {return name;+ }return std::string((it+1), name.end());};@@ -381,8 +384,9 @@ std::shared_ptr<ov::Model> Graph::get_runtime_model(std::vector<cldnn::primitive});if (filter_const_primitives) {- if (dep_it == primitives_info.end())+ if (dep_it == primitives_info.end()) {continue;+ }if (dep_it->type_id == "data") {continue;}@@ -426,8 +430,9 @@ std::shared_ptr<ov::Model> Graph::get_runtime_model(std::vector<cldnn::primitiveauto usr_it = std::find_if(primitives_info.begin(), primitives_info.end(), [&](cldnn::primitive_info& entry) {return entry.original_id == usr_id;});- if (usr_it == primitives_info.end())+ if (usr_it == primitives_info.end()) {continue;+ }return_node->set_output_type(port, out_et, out_pshape);port++;@@ -437,8 +442,9 @@ std::shared_ptr<ov::Model> Graph::get_runtime_model(std::vector<cldnn::primitiveauto layerName = remove_type_from_name(prim_info.original_id);return_node->set_friendly_name(layerName);- if (is_output)+ if (is_output) {results.back()->set_friendly_name(layerName + "_result");+ }std::map<std::string, std::string> info;info[ov::exec_model_info::OUTPUT_PRECISIONS] = ov::element::Type(prim_info.output_layout.data_type).get_type_name();@@ -451,8 +457,9 @@ std::shared_ptr<ov::Model> Graph::get_runtime_model(std::vector<cldnn::primitivestd::vector<std::string> originalNames{find_origin_layers(prim_info.original_id)};for (const auto& fused_id : prim_info.c_fused_ids) {for (auto& origin_id : find_origin_layers(fused_id)) {- if (std::find(originalNames.begin(), originalNames.end(), origin_id) == originalNames.end())+ if (std::find(originalNames.begin(), originalNames.end(), origin_id) == originalNames.end()) {originalNames.push_back(origin_id);+ }}}info[ov::exec_model_info::ORIGINAL_NAMES] = concat_strings(originalNames, ',');@@ -508,11 +515,13 @@ std::shared_ptr<ov::Model> Graph::get_runtime_model(std::vector<cldnn::primitivefor (auto&& kvp : info) {return_node->get_rt_info()[kvp.first] = kvp.second;- if (is_output)+ if (is_output) {results.back()->get_rt_info()[kvp.first] = kvp.second;+ }}- if (is_output)+ if (is_output) {results.back()->get_rt_info()[ov::exec_model_info::LAYER_TYPE] = "Result";+ }nodes.push_back(return_node);node2layer[prim_info.original_id] = return_node;@@ -528,8 +537,9 @@ std::shared_ptr<ov::Model> Graph::get_runtime_model(std::vector<cldnn::primitiveauto it = std::find_if(primitives_info.begin(), primitives_info.end(), [&](cldnn::primitive_info& entry) {return entry.original_id == dep;});- if (it == primitives_info.end())+ if (it == primitives_info.end()) {continue;+ }auto& dep_users = it->c_users;// Remove mutable data from users list@@ -544,12 +554,14 @@ std::shared_ptr<ov::Model> Graph::get_runtime_model(std::vector<cldnn::primitiveit = std::find_if(primitives_info.begin(), primitives_info.end(), [&](cldnn::primitive_info& entry) {return entry.original_id == user;});- if (it == primitives_info.end())+ if (it == primitives_info.end()) {continue;+ }for (auto& d : it->c_dependencies) {- if (d == pi.original_id)+ if (d == pi.original_id) {d = dep;+ }}}}@@ -637,8 +649,9 @@ void Graph::update_profiling_info() {} else if (interval.stage == cldnn::instrumentation::profiling_stage::duration) { // "duration" is used for CPU layerspc.cpu_uSec += count;- if (pc.num == 0)+ if (pc.num == 0) {pc.isCPU = true;+ }}}};@@ -733,8 +746,9 @@ std::vector<ov::ProfilingInfo> Graph::get_profiling_info() const {auto getFromProfiling = [&](std::string primId) -> bool {auto perfIter = perfMap.find(primId);- if (perfIter == perfMap.end())+ if (perfIter == perfMap.end()) {return false;+ }auto layerName = getClearName(perfIter->second.first);@@ -747,8 +761,9 @@ std::vector<ov::ProfilingInfo> Graph::get_profiling_info() const {start_time = extract_start_time_from_intervals(cldnnInfo.intervals);}- if (!perfCounter.parentPrimitive.empty() && combinePrimByIRLayers)+ if (!perfCounter.parentPrimitive.empty() && combinePrimByIRLayers) {return false;+ }auto& extPerfEntry = result[layerName];@@ -815,8 +830,9 @@ std::vector<ov::ProfilingInfo> Graph::get_profiling_info() const {if ((!existInProfiling || (existInProfiling && perfIter->second.first.empty())) &&executedPrimitives.find(primId) != executedPrimitives.end()) {auto event = executedPrimitives.at(primId);- if (!event)+ if (!event) {continue;+ }cldnn::instrumentation::profiling_info cldnnInfo{primId, event->get_profiling_info()};@@ -844,8 +860,9 @@ std::vector<ov::ProfilingInfo> Graph::get_profiling_info() const {for (auto& pi : primitivesInfo) {if (pi.original_id == primId) {- if (pi.type_id == "mutable_data")+ if (pi.type_id == "mutable_data") {continue;+ }auto& extPerfEntry = result[layerName];diff --git a/src/plugins/intel_gpu/src/plugin/multi_tensor_variable_state.cpp b/src/plugins/intel_gpu/src/plugin/multi_tensor_variable_state.cppindex 4b9d3cfc7c6..37f7f1dfe02 100644--- a/src/plugins/intel_gpu/src/plugin/multi_tensor_variable_state.cpp+++ b/src/plugins/intel_gpu/src/plugin/multi_tensor_variable_state.cpp@@ -104,10 +104,11 @@ static void rearrange_cache(cldnn::memory::ptr kv_in_mem, cldnn::memory::ptr bt_size_t out_offset = kv_out_mem->get_layout().get_linear_offset(out);size_t in_offset = kv_layout.get_linear_offset(in);- if (ov::element::Type(kv_layout.data_type).size() == 2)+ if (ov::element::Type(kv_layout.data_type).size() == 2) {copy_element<uint16_t>(kv_in_ptr.data(), kv_out_ptr.data(), in_offset, out_offset);- else if (ov::element::Type(kv_layout.data_type).size() == 4)+ } else if (ov::element::Type(kv_layout.data_type).size() == 4) {copy_element<uint32_t>(kv_in_ptr.data(), kv_out_ptr.data(), in_offset, out_offset);+ }}}}diff --git a/src/plugins/intel_gpu/src/plugin/ops/col2im.cpp b/src/plugins/intel_gpu/src/plugin/ops/col2im.cppindex 275662d4e08..91b0e6931e4 100644--- a/src/plugins/intel_gpu/src/plugin/ops/col2im.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/col2im.cpp@@ -28,10 +28,12 @@ static void CreateCol2ImOp(ProgramBuilder& p, const std::shared_ptr<ov::op::v15:ov::CoordinateDiff padding_begin;ov::CoordinateDiff padding_end;- for (auto p : op->get_pads_begin())+ for (auto p : op->get_pads_begin()) {padding_begin.push_back(p);- for (auto p : op->get_pads_end())+ }+ for (auto p : op->get_pads_end()) {padding_end.push_back(p);+ }auto output_shape_const = ov::as_type_ptr<ov::op::v0::Constant>(op->get_input_node_shared_ptr(1));auto vec_output_shape = output_shape_const->cast_vector<size_t>();diff --git a/src/plugins/intel_gpu/src/plugin/ops/concat.cpp b/src/plugins/intel_gpu/src/plugin/ops/concat.cppindex 5749aa2d89e..fb0dd9c2c89 100644--- a/src/plugins/intel_gpu/src/plugin/ops/concat.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/concat.cpp@@ -15,8 +15,9 @@ static void CreateConcatOp(ProgramBuilder& p, const std::shared_ptr<ov::op::v0::auto inputs = p.GetInputInfo(op);std::string layerName = layer_type_name_ID(op);int64_t axis = op->get_axis();- if (axis < 0)+ if (axis < 0) {axis = axis + static_cast<int64_t>(op->get_input_partial_shape(0).rank().get_length());+ }auto concatPrim = cldnn::concatenation(layerName,diff --git a/src/plugins/intel_gpu/src/plugin/ops/constant.cpp b/src/plugins/intel_gpu/src/plugin/ops/constant.cppindex 0141f4123bb..e5776516f42 100644--- a/src/plugins/intel_gpu/src/plugin/ops/constant.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/constant.cpp@@ -2,45 +2,43 @@// SPDX-License-Identifier: Apache-2.0//-#include "intel_gpu/plugin/program_builder.hpp"-#include "intel_gpu/plugin/common_utils.hpp"-#include "intel_gpu/op/convolution.hpp"+#include "openvino/op/constant.hpp"++#include <algorithm>+#include <cctype>+#include <cstdlib>+#include <cstring>+#include <string>+#include "intel_gpu/op/convolution.hpp"+#include "intel_gpu/plugin/common_utils.hpp"+#include "intel_gpu/plugin/program_builder.hpp"+#include "intel_gpu/primitives/data.hpp"+#include "intel_gpu/runtime/debug_configuration.hpp"+#include "moe_offload_constant.hpp"#include "openvino/core/weight_sharing_util.hpp"-#include "openvino/op/constant.hpp"-#include "openvino/op/convolution.hpp"+#include "openvino/op/bucketize.hpp"+#include "openvino/op/concat.hpp"#include "openvino/op/convert.hpp"+#include "openvino/op/convolution.hpp"#include "openvino/op/deformable_convolution.hpp"-#include "openvino/op/group_conv.hpp"-#include "openvino/op/concat.hpp"-#include "openvino/op/squared_difference.hpp"#include "openvino/op/gather.hpp"#include "openvino/op/gather_nd.hpp"-#include "openvino/op/split.hpp"+#include "openvino/op/group_conv.hpp"+#include "openvino/op/loop.hpp"+#include "openvino/op/matmul.hpp"+#include "openvino/op/moe.hpp"#include "openvino/op/prelu.hpp"#include "openvino/op/roi_align.hpp"#include "openvino/op/roi_align_rotated.hpp"-#include "openvino/op/variadic_split.hpp"-#include "openvino/op/util/op_types.hpp"-#include "openvino/op/loop.hpp"+#include "openvino/op/split.hpp"+#include "openvino/op/squared_difference.hpp"#include "openvino/op/tensor_iterator.hpp"-#include "openvino/op/bucketize.hpp"-#include "openvino/op/matmul.hpp"-#include "openvino/op/moe.hpp"#include "openvino/op/util/binary_elementwise_bitwise.hpp"-+#include "openvino/op/util/op_types.hpp"+#include "openvino/op/variadic_split.hpp"#include "ov_ops/moe_compressed.hpp"-#include "intel_gpu/primitives/data.hpp"-#include "intel_gpu/runtime/debug_configuration.hpp"-#include "moe_offload_constant.hpp"--#include <algorithm>-#include <cctype>-#include <cstdlib>-#include <cstring>-#include <string>-namespace ov::intel_gpu {static cldnn::tensor getConstTensor(const ov::Shape constDims) {@@ -56,26 +54,38 @@ static cldnn::tensor getConstTensor(const ov::Shape constDims) {case 7:constTensor = cldnn::tensor(shuffled_dims);break;- case 6: constTensor = cldnn::tensor(TensorValue(constDims[0]), TensorValue(constDims[1]),- TensorValue(constDims[5]), TensorValue(constDims[4]),- TensorValue(constDims[3]), TensorValue(constDims[2]));+ case 6:+ constTensor = cldnn::tensor(TensorValue(constDims[0]),+ TensorValue(constDims[1]),+ TensorValue(constDims[5]),+ TensorValue(constDims[4]),+ TensorValue(constDims[3]),+ TensorValue(constDims[2]));break;- case 5: constTensor = cldnn::tensor(TensorValue(constDims[0]), TensorValue(constDims[1]),- TensorValue(constDims[4]), TensorValue(constDims[3]), TensorValue(constDims[2]));+ case 5:+ constTensor = cldnn::tensor(TensorValue(constDims[0]),+ TensorValue(constDims[1]),+ TensorValue(constDims[4]),+ TensorValue(constDims[3]),+ TensorValue(constDims[2]));break;- case 4: constTensor = cldnn::tensor(TensorValue(constDims[0]), TensorValue(constDims[1]),- TensorValue(constDims[3]), TensorValue(constDims[2]));+ case 4:+ constTensor = cldnn::tensor(TensorValue(constDims[0]), TensorValue(constDims[1]), TensorValue(constDims[3]), TensorValue(constDims[2]));break;- case 3: constTensor = cldnn::tensor(TensorValue(constDims[0]), TensorValue(constDims[1]),- 1, TensorValue(constDims[2]));+ case 3:+ constTensor = cldnn::tensor(TensorValue(constDims[0]), TensorValue(constDims[1]), 1, TensorValue(constDims[2]));break;- case 2: constTensor = cldnn::tensor(TensorValue(constDims[0]), TensorValue(constDims[1]), 1, 1);+ case 2:+ constTensor = cldnn::tensor(TensorValue(constDims[0]), TensorValue(constDims[1]), 1, 1);break;- case 1: constTensor = cldnn::tensor(1, TensorValue(constDims[0]), 1, 1);+ case 1:+ constTensor = cldnn::tensor(1, TensorValue(constDims[0]), 1, 1);break;- case 0: constTensor = cldnn::tensor(1, 1, 1, 1);+ case 0:+ constTensor = cldnn::tensor(1, 1, 1, 1);break;- default: OPENVINO_THROW("Invalid constant blob dimensions");+ default:+ OPENVINO_THROW("Invalid constant blob dimensions");}return constTensor;}@@ -94,8 +104,8 @@ static void create_data(ProgramBuilder& p, const ov::Shape& const_shape, const s}cldnn::data_types out_dtype = cldnn::element_type_to_data_type(op->get_output_element_type(0));- cldnn::layout constLayout = p.use_new_shape_infer() ? cldnn::layout(const_shape, out_dtype, constFormat) :- cldnn::layout(out_dtype, constFormat, constTensor);+ cldnn::layout constLayout =+ p.use_new_shape_infer() ? cldnn::layout(const_shape, out_dtype, constFormat) : cldnn::layout(out_dtype, constFormat, constTensor);cldnn::primitive_id initialconstPrimID = layer_type_name_ID(op);cldnn::primitive_id constPrimID;@@ -126,8 +136,8 @@ static void create_data(ProgramBuilder& p, const ov::Shape& const_shape, const smem = p.get_engine().reinterpret_buffer(*one_dim_mem, constLayout);}- GPU_DEBUG_LOG << "[" << initialconstPrimID << ": constant] layout: "- << constLayout.to_short_string() << ", mem_ptr(" << mem << ", " << mem->size() << " bytes)"<< std::endl;+ GPU_DEBUG_LOG << "[" << initialconstPrimID << ": constant] layout: " << constLayout.to_short_string() << ", mem_ptr(" << mem << ", " << mem->size()+ << " bytes)" << std::endl;if (!partial_upload.enabled) {auto& stream = p.get_engine().get_service_stream();@@ -138,15 +148,12 @@ static void create_data(ProgramBuilder& p, const ov::Shape& const_shape, const s// If a constant has element type f64 but contains no elements (empty tensor),// convert it to f32 because the GPU plugin only supports the f32 data type internally.- if (upload_count == 1 &&- out_dtype == cldnn::data_types::f32 &&- op->get_output_element_type(0) == ov::element::f64) {+ if (upload_count == 1 && out_dtype == cldnn::data_types::f32 && op->get_output_element_type(0) == ov::element::f64) {const auto* f64data = op->get_data_ptr<double>();auto* f32buf = reinterpret_cast<float*>(buf);f32buf[0] = static_cast<float>(f64data[0]);} else if (out_dtype == cldnn::data_types::f32 &&- (op->get_output_element_type(0) == ov::element::u16 ||- op->get_output_element_type(0) == ov::element::i16)) {+ (op->get_output_element_type(0) == ov::element::u16 || op->get_output_element_type(0) == ov::element::i16)) {size_t count = upload_count;auto* f32buf = reinterpret_cast<float*>(buf);@@ -180,33 +187,29 @@ static bool is_btiwise(Node* node) {static void CreateConstantOp(ProgramBuilder& p, const std::shared_ptr<ov::op::v0::Constant>& op) {ov::Shape constDims = op->get_shape();auto constUsers = op->get_output_target_inputs(0);- std::unordered_map<std::shared_ptr<ov::op::v0::Constant>, ConstProperties> consts = {- {op, {false}}- };+ std::unordered_map<std::shared_ptr<ov::op::v0::Constant>, ConstProperties> consts = {{op, {false}}};- auto is_binary_eltwise = [&] (ov::Node* op) -> bool {- return ov::op::util::is_binary_elementwise_arithmetic(op) ||- ov::op::util::is_binary_elementwise_logical(op) ||- ov::op::util::is_binary_elementwise_comparison(op) ||- is_btiwise(op);+ auto is_binary_eltwise = [&](ov::Node* op) -> bool {+ return ov::op::util::is_binary_elementwise_arithmetic(op) || ov::op::util::is_binary_elementwise_logical(op) ||+ ov::op::util::is_binary_elementwise_comparison(op) || is_btiwise(op);};- auto is_all_inputs_1d = [&] (ov::Node* op) -> bool {+ auto is_all_inputs_1d = [&](ov::Node* op) -> bool {for (size_t i = 0; i < op->get_input_size(); i++) {const auto& in_shape = op->get_input_partial_shape(i);- if (in_shape.size() > 1)+ if (in_shape.size() > 1) {return false;+ }}return true;};- auto is_convert_into_binary_eltwise = [&] (ov::Node* op) -> bool {+ auto is_convert_into_binary_eltwise = [&](ov::Node* op) -> bool {if (ov::is_type<ov::op::v0::Convert>(op)) {for (size_t i = 0; i < op->get_output_size(); ++i) {auto convertUsers = op->get_output_target_inputs(i);for (auto user : convertUsers) {- if (is_binary_eltwise(user.get_node()) &&- is_all_inputs_1d(user.get_node())) {+ if (is_binary_eltwise(user.get_node()) && is_all_inputs_1d(user.get_node())) {return true;}}@@ -216,8 +219,9 @@ static void CreateConstantOp(ProgramBuilder& p, const std::shared_ptr<ov::op::v0};auto is_grouped_conv = [](ov::Node* op) -> bool {- if (ov::is_type<ov::op::v1::GroupConvolution>(op))+ if (ov::is_type<ov::op::v1::GroupConvolution>(op)) {return true;+ }if (ov::is_type<op::Convolution>(op)) {return ov::as_type<op::Convolution>(op)->get_groups() > 0;@@ -274,17 +278,18 @@ static void CreateConstantOp(ProgramBuilder& p, const std::shared_ptr<ov::op::v0auto input_shape = outOp->get_input_partial_shape(0);if ((constDims.size() != 1 && constDims.size() < input_shape.size()) ||(constDims.size() == 1 && input_shape.is_static() && input_shape.size() > 1 &&- static_cast<int64_t>(constDims[0]) != input_shape[1].get_length())) {+ static_cast<int64_t>(constDims[0]) != input_shape[1].get_length())) {// Reshape 'constDims' according to the numpy broadcasting rule.ov::Shape slope_shape(input_shape.size(), 1);- for (size_t j = 1; j <= constDims.size(); j++)+ for (size_t j = 1; j <= constDims.size(); j++) {slope_shape[slope_shape.size() - j] = constDims[constDims.size() - j];+ }constDims = slope_shape;}} else if (is_grouped_conv(outOp) && node.get_index() == 1 && !p.use_new_shape_infer()) {auto input_shape = outOp->get_input_partial_shape(0);- if (constDims.size() == 4 && input_shape.size() == 3) { // In case of weight dim 4 and input dim 3,- constDims.push_back(1); // The weight cldnn tensor adds 1d to the end as the input cldnn tensor does+ if (constDims.size() == 4 && input_shape.size() == 3) { // In case of weight dim 4 and input dim 3,+ constDims.push_back(1); // The weight cldnn tensor adds 1d to the end as the input cldnn tensor does}} else if (ov::is_type<ov::op::v3::ROIAlign>(outOp) || ov::is_type<ov::op::v9::ROIAlign>(outOp) ||ov::is_type<ov::op::v15::ROIAlignRotated>(outOp)) { //< Hacks...@@ -312,9 +317,7 @@ static void CreateConstantOp(ProgramBuilder& p, const std::shared_ptr<ov::op::v0// breaking the first-N-dims extraction in transform_input_layouts.if (constDims.size() == 1) {ov::Shape reshaped_const_dims(const_static_max_dims, 1);- const size_t const_idx = (user_index == 0)?- (const_static_max_dims - 1)- : (const_static_max_dims - 2);+ const size_t const_idx = (user_index == 0) ? (const_static_max_dims - 1) : (const_static_max_dims - 2);reshaped_const_dims[const_idx] = constDims[0];constDims = std::move(reshaped_const_dims);} else if (constDims.size() == 2 && user_index == 0 && apply_rank2_matmul_wa) {diff --git a/src/plugins/intel_gpu/src/plugin/ops/custom.cpp b/src/plugins/intel_gpu/src/plugin/ops/custom.cppindex 3759fade3a6..6449b392576 100644--- a/src/plugins/intel_gpu/src/plugin/ops/custom.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/custom.cpp@@ -15,8 +15,9 @@ namespace ov::intel_gpu {template<typename T>static inline std::string vecToString(std::vector<T> vec) {- if (vec.empty())+ if (vec.empty()) {return "";+ }std::string res = std::to_string(vec[0]);for (size_t i = 1; i < vec.size(); i++) {@@ -27,8 +28,9 @@ static inline std::string vecToString(std::vector<T> vec) {template<>inline std::string vecToString<std::string>(std::vector<std::string> vec) {- if (vec.empty())+ if (vec.empty()) {return "";+ }std::string res = vec[0];for (size_t i = 1; i < vec.size(); i++) {@@ -204,8 +206,9 @@ void CreateCustomOp(ProgramBuilder& p, const std::shared_ptr<ov::Node>& op, Cust// if input index is greater than -1, take dimension from inputif (iidx >= 0) {- if (static_cast<size_t>(iidx) >= op->get_input_size())+ if (static_cast<size_t>(iidx) >= op->get_input_size()) {OPENVINO_THROW("Invalid input tensor for index: ", iidx);+ }auto inputDims = op->get_input_shape(iidx);// Regardless of whether the model has one or more outputs, only the first output is used to update gws and lws.cldnn::custom_gpu_primitive::update_work_group_size(op->get_output_partial_shape(0),diff --git a/src/plugins/intel_gpu/src/plugin/ops/dynamic_quantize.cpp b/src/plugins/intel_gpu/src/plugin/ops/dynamic_quantize.cppindex 5cc2501957b..06b63b43ae2 100644--- a/src/plugins/intel_gpu/src/plugin/ops/dynamic_quantize.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/dynamic_quantize.cpp@@ -18,20 +18,23 @@ namespace ov::intel_gpu {static size_t get_innermost_size(const std::shared_ptr<ov::op::internal::DynamicQuantize>& op) {const auto& in_shape = op->get_input_partial_shape(0);const auto& innermost_dim = in_shape[in_shape.size() - 1];- if (innermost_dim.is_static())+ if (innermost_dim.is_static()) {return innermost_dim.get_length();+ }size_t innermost_size = 0;for (const auto& target_input : op->get_output_target_inputs(0)) {const auto* fc = ov::as_type<const op::FullyConnectedCompressed>(target_input.get_node());- if (fc == nullptr || target_input.get_index() != 0)+ if (fc == nullptr || target_input.get_index() != 0) {continue;+ }// Weights are [N, K] when transposed, [K, N] otherwiseconst auto& weights_shape = fc->get_input_partial_shape(1);const auto& ifm = weights_shape[weights_shape.size() - (fc->get_transpose_b() ? 1 : 2)];- if (!ifm.is_static())+ if (!ifm.is_static()) {continue;+ }// Every user consumes the same activations, so they have to agree on the lengthconst auto ifm_size = static_cast<size_t>(ifm.get_length());diff --git a/src/plugins/intel_gpu/src/plugin/ops/eltwise.cpp b/src/plugins/intel_gpu/src/plugin/ops/eltwise.cppindex 341812519d0..fb581058b5c 100644--- a/src/plugins/intel_gpu/src/plugin/ops/eltwise.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/eltwise.cpp@@ -170,8 +170,9 @@ static void CreatePowerOp(ProgramBuilder& p, const std::shared_ptr<ov::op::v1::Pif (ov::shape_size(power_node->get_output_shape(0)) == 1 &&op->get_input_partial_shape(0).same_scheme(op->get_output_partial_shape(0))) {float pow;- if (!ov::op::util::get_single_value(power_node, pow))+ if (!ov::op::util::get_single_value(power_node, pow)) {OPENVINO_THROW("Invalid parameter size in ", op->get_friendly_name(), " (", op->get_type_name(), ")");+ }CreateUnaryEltwiseOp(p, op, cldnn::activation_func::pow, {pow});return;}diff --git a/src/plugins/intel_gpu/src/plugin/ops/embedding_bag.cpp b/src/plugins/intel_gpu/src/plugin/ops/embedding_bag.cppindex 7226852cc4b..d26be4a156f 100644--- a/src/plugins/intel_gpu/src/plugin/ops/embedding_bag.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/embedding_bag.cpp@@ -27,8 +27,9 @@ static void CreateEmbeddingBagOffsetsSumOp(ProgramBuilder& p, const std::shared_OPENVINO_ASSERT(index_node != nullptr, "[GPU] Unsupported parameter nodes type in ", op->get_friendly_name(), " (", op->get_type_name(), ")");float val;- if (ov::shape_size(index_node->get_output_shape(0)) != 1 || !ov::op::util::get_single_value(index_node, val))+ if (ov::shape_size(index_node->get_output_shape(0)) != 1 || !ov::op::util::get_single_value(index_node, val)) {OPENVINO_THROW("Unsupported parameter size in ", op->get_friendly_name(), " (", op->get_type_name(), ")");+ }defaultIndex = static_cast<int32_t>(val);inputs.erase(inputs.begin() + 3); // Remove "default_index"@@ -111,8 +112,9 @@ static void CreateEmbeddingSegmentsSumOp(ProgramBuilder& p, const std::shared_ptOPENVINO_ASSERT(index_node != nullptr, "[GPU] Unsupported parameter nodes type in ", op->get_friendly_name(), " (", op->get_type_name(), ")");float val;- if (ov::shape_size(index_node->get_output_shape(0)) != 1 || !ov::op::util::get_single_value(index_node, val))+ if (ov::shape_size(index_node->get_output_shape(0)) != 1 || !ov::op::util::get_single_value(index_node, val)) {OPENVINO_THROW("Unsupported parameter size in ", op->get_friendly_name(), " (", op->get_type_name(), ")");+ }defaultIndex = static_cast<int32_t>(val);inputs.erase(inputs.begin() + 4); // Remove "default_index"diff --git a/src/plugins/intel_gpu/src/plugin/ops/gated_delta_net.cpp b/src/plugins/intel_gpu/src/plugin/ops/gated_delta_net.cppindex accf8591c8f..a907dbeb468 100644--- a/src/plugins/intel_gpu/src/plugin/ops/gated_delta_net.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/gated_delta_net.cpp@@ -42,14 +42,18 @@ static void CreateGatedDeltaNetOp(ProgramBuilder& p, const std::shared_ptr<ov::oconst auto k_heads_num_dim = query_ps[query_rank - 2];const auto v_heads_num_dim = value_ps[value_rank - 2];- if (k_head_size_dim.is_static())+ if (k_head_size_dim.is_static()) {gated_delta_net_prim.k_head_size = k_head_size_dim.get_length();- if (v_head_size_dim.is_static())+ }+ if (v_head_size_dim.is_static()) {gated_delta_net_prim.v_head_size = v_head_size_dim.get_length();- if (k_heads_num_dim.is_static())+ }+ if (k_heads_num_dim.is_static()) {gated_delta_net_prim.k_heads_num = k_heads_num_dim.get_length();- if (v_heads_num_dim.is_static())+ }+ if (v_heads_num_dim.is_static()) {gated_delta_net_prim.v_heads_num = v_heads_num_dim.get_length();+ }}}diff --git a/src/plugins/intel_gpu/src/plugin/ops/gated_mlp.cpp b/src/plugins/intel_gpu/src/plugin/ops/gated_mlp.cppindex dc84f2f4a2f..6aede6000f3 100644--- a/src/plugins/intel_gpu/src/plugin/ops/gated_mlp.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/gated_mlp.cpp@@ -70,8 +70,9 @@ static void CreateGatedMLPOp(ProgramBuilder& p, const std::shared_ptr<ov::intel_}();- if (p.use_new_shape_infer())+ if (p.use_new_shape_infer()) {prim.output_data_types = get_output_data_types(op);+ }p.add_primitive(*op, prim);}diff --git a/src/plugins/intel_gpu/src/plugin/ops/gather_elements.cpp b/src/plugins/intel_gpu/src/plugin/ops/gather_elements.cppindex 0f9bfb8cc57..31de5cea726 100644--- a/src/plugins/intel_gpu/src/plugin/ops/gather_elements.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/gather_elements.cpp@@ -19,8 +19,9 @@ static void CreateGatherElementsOp(ProgramBuilder& p, const std::shared_ptr<ov::size_t rank = op->get_input_partial_shape(0).size();int64_t axis = op->get_axis();- if (axis < 0)+ if (axis < 0) {axis += rank;+ }OPENVINO_ASSERT(axis >= 0 && axis < static_cast<int64_t>(rank),"GatherElements axis is not correspond to number of dimensions");diff --git a/src/plugins/intel_gpu/src/plugin/ops/grouped_matmul.cpp b/src/plugins/intel_gpu/src/plugin/ops/grouped_matmul.cppindex 6d9dc2128a8..b329351a917 100644--- a/src/plugins/intel_gpu/src/plugin/ops/grouped_matmul.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/grouped_matmul.cpp@@ -20,8 +20,9 @@ static void ensure_i32_offsets(ProgramBuilder& p,std::vector<cldnn::input_info>& inputs,size_t offsets_idx) {const auto offsets_dtype = cldnn::element_type_to_data_type(op->get_input_element_type(offsets_idx));- if (offsets_dtype == cldnn::data_types::i32)+ if (offsets_dtype == cldnn::data_types::i32) {return;+ }auto reorder_id = inputs[offsets_idx].pid + "_" + op->get_friendly_name() + ProgramBuilder::m_preProcessTag;auto fmt = cldnn::format::get_default_format(op->get_input_partial_shape(offsets_idx).size());auto reorder_prim = cldnn::reorder(reorder_id, inputs[offsets_idx], fmt, cldnn::data_types::i32);diff --git a/src/plugins/intel_gpu/src/plugin/ops/loop.cpp b/src/plugins/intel_gpu/src/plugin/ops/loop.cppindex fd5c0daa546..daaf1e1b38f 100644--- a/src/plugins/intel_gpu/src/plugin/ops/loop.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/loop.cpp@@ -244,8 +244,9 @@ static void CreateCommonLoopOp(ProgramBuilder& p, const std::shared_ptr<ov::op::trip_count_id = layer_type_name_ID(loop_op->get_input_node_shared_ptr(0));// Update trip_count_id for cached constant primitive- if (trip_count_id != p.primitive_ids[trip_count_id])+ if (trip_count_id != p.primitive_ids[trip_count_id]) {trip_count_id = p.primitive_ids[trip_count_id];+ }first_execution_condition_id = layer_type_name_ID(loop_op->get_input_node_shared_ptr(1));}diff --git a/src/plugins/intel_gpu/src/plugin/ops/matmul.cpp b/src/plugins/intel_gpu/src/plugin/ops/matmul.cppindex e8a267a8275..e87285f2a79 100644--- a/src/plugins/intel_gpu/src/plugin/ops/matmul.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/matmul.cpp@@ -52,8 +52,9 @@ static void CreateMatMulOp(ProgramBuilder& p, const std::shared_ptr<ov::op::v0::};auto canTransposeInputs = [&] (const std::array<ov::PartialShape, 2>& shapes, bool transA, bool transB, ov::element::Type type) -> bool {- if (!transA && !transB)+ if (!transA && !transB) {return false;+ }// dynamic shapes and 1D tensors are not transposedif (shapes[0].is_dynamic() || shapes[1].is_dynamic()) {@@ -64,8 +65,9 @@ static void CreateMatMulOp(ProgramBuilder& p, const std::shared_ptr<ov::op::v0::// until we have an essential solution, i.e., fixing the gemm_tiled_opt kernel to support unaligned shape.return p.get_engine().get_device_info().dev_type == cldnn::device_type::integrated_gpu;}- if (shapes[0].size() < 2 || shapes[1].size() < 2)+ if (shapes[0].size() < 2 || shapes[1].size() < 2) {return false;+ }// oneDNN matmul applies transpose_a/transpose_b by swapping the operand strides// (see get_gemm_primitive_descriptor in impls/onednn/gemm_onednn.cpp), so a materializeddiff --git a/src/plugins/intel_gpu/src/plugin/ops/moe_offload_constant.cpp b/src/plugins/intel_gpu/src/plugin/ops/moe_offload_constant.cppindex a538a6eed9b..3e8bc46bfb2 100644--- a/src/plugins/intel_gpu/src/plugin/ops/moe_offload_constant.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/moe_offload_constant.cpp@@ -20,10 +20,12 @@ MoEConstantRole get_moe_constant_role(const std::shared_ptr<ov::op::v0::Constantconst auto* node = input.get_node();if (ov::is_type<ov::op::internal::MOECompressed>(node)) {auto idx = input.get_index();- if (idx >= ROUTED_INPUT_START && idx <= ROUTED_INPUT_END)+ if (idx >= ROUTED_INPUT_START && idx <= ROUTED_INPUT_END) {return MoEConstantRole::RoutedExpert;- if (idx >= SHARED_INPUT_START && idx <= SHARED_INPUT_END)+ }+ if (idx >= SHARED_INPUT_START && idx <= SHARED_INPUT_END) {return MoEConstantRole::SharedExpert;+ }}}return MoEConstantRole::NotMoE;diff --git a/src/plugins/intel_gpu/src/plugin/ops/multinomial.cpp b/src/plugins/intel_gpu/src/plugin/ops/multinomial.cppindex f32b1d71bbd..bed14a89650 100644--- a/src/plugins/intel_gpu/src/plugin/ops/multinomial.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/multinomial.cpp@@ -125,10 +125,11 @@ static void CreateMultinomialOp(ProgramBuilder& p, const std::shared_ptr<ov::op:OPENVINO_ASSERT(const_num_samples != nullptr, "[GPU] Unsupported num_samples node type in ", op->get_friendly_name(), " (", op->get_type_name(), ")");std::int64_t num_samples{};- if (const_num_samples->get_output_element_type(0) == ov::element::Type_t::i32)+ if (const_num_samples->get_output_element_type(0) == ov::element::Type_t::i32) {num_samples = const_num_samples->cast_vector<std::int32_t>(1)[0];- else+ } else {num_samples = const_num_samples->cast_vector<std::int64_t>(1)[0];+ }cldnn::multinomial multinomial_prim {layer_type_name_ID(op),diff --git a/src/plugins/intel_gpu/src/plugin/ops/non_max_suppression.cpp b/src/plugins/intel_gpu/src/plugin/ops/non_max_suppression.cppindex fcad17642fe..ce07ac04d49 100644--- a/src/plugins/intel_gpu/src/plugin/ops/non_max_suppression.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/non_max_suppression.cpp@@ -53,8 +53,9 @@ static void apply_optional_inputs(const std::shared_ptr<ov::Node>& op, cldnn::no}static void add_nms_gather_if_needed(ProgramBuilder& p, const std::shared_ptr<ov::Node>& op, const std::string& nms_name, size_t num_outputs) {- if (!op->get_output_partial_shape(0).is_dynamic())+ if (!op->get_output_partial_shape(0).is_dynamic()) {return;+ }auto gather_name = nms_name + "_NMSGather";std::vector<cldnn::input_info> gather_inputs = {diff --git a/src/plugins/intel_gpu/src/plugin/ops/normalize_l2.cpp b/src/plugins/intel_gpu/src/plugin/ops/normalize_l2.cppindex 740dfe01c8f..9b00a033570 100644--- a/src/plugins/intel_gpu/src/plugin/ops/normalize_l2.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/normalize_l2.cpp@@ -39,8 +39,9 @@ static void CreateNormalizeL2Op(ProgramBuilder& p, const std::shared_ptr<ov::op:auto* buf = tmpPointer.data();auto bufSize = scale->get_output_tensor(0).size();- if (bufSize != constLayout.bytes_count())+ if (bufSize != constLayout.bytes_count()) {OPENVINO_THROW("Invalid scales buffer in NormalizeL2 op ", op->get_friendly_name());+ }std::memcpy(&buf[0], scale->get_data_ptr(), bufSize);auto scalesName = layerName + "_cldnn_input_scales";diff --git a/src/plugins/intel_gpu/src/plugin/ops/one_hot.cpp b/src/plugins/intel_gpu/src/plugin/ops/one_hot.cppindex 63ac092fe01..01976f2873b 100644--- a/src/plugins/intel_gpu/src/plugin/ops/one_hot.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/one_hot.cpp@@ -39,16 +39,18 @@ static void CreateOneHotOpGeneric(ProgramBuilder& p, const std::shared_ptr<ov::oauto dims = op->get_input_partial_shape(0);- if (axis < -1 || axis > static_cast<int16_t>(dims.size()))+ if (axis < -1 || axis > static_cast<int16_t>(dims.size())) {OPENVINO_THROW(op->get_friendly_name(), " Incorrect OneHot axis value: ", axis, ". Should be between -1 and ", dims.size());+ }if (axis == -1) {axis = dims.size();for (int i = static_cast<int>(dims.size() - 1); i >= 0; i--) {- if (dims[i] == 1)+ if (dims[i] == 1) {axis--;- else+ } else {break;+ }}}diff --git a/src/plugins/intel_gpu/src/plugin/ops/paged_gated_delta_net.cpp b/src/plugins/intel_gpu/src/plugin/ops/paged_gated_delta_net.cppindex 2bbfce0fa30..da7311fe4db 100644--- a/src/plugins/intel_gpu/src/plugin/ops/paged_gated_delta_net.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/paged_gated_delta_net.cpp@@ -41,14 +41,18 @@ static void CreatePagedGatedDeltaNetOp(ProgramBuilder& p, const std::shared_ptr<const auto k_heads_num_dim = query_ps[query_rank - 2];const auto v_heads_num_dim = value_ps[value_rank - 2];- if (k_head_size_dim.is_static())+ if (k_head_size_dim.is_static()) {prim.k_head_size = k_head_size_dim.get_length();- if (v_head_size_dim.is_static())+ }+ if (v_head_size_dim.is_static()) {prim.v_head_size = v_head_size_dim.get_length();- if (k_heads_num_dim.is_static())+ }+ if (k_heads_num_dim.is_static()) {prim.k_heads_num = k_heads_num_dim.get_length();- if (v_heads_num_dim.is_static())+ }+ if (v_heads_num_dim.is_static()) {prim.v_heads_num = v_heads_num_dim.get_length();+ }}OPENVINO_ASSERT(prim.k_head_size > 0, "PagedGatedDeltaNet must have k_head_size > 0");OPENVINO_ASSERT(prim.v_head_size > 0, "PagedGatedDeltaNet must have v_head_size > 0");diff --git a/src/plugins/intel_gpu/src/plugin/ops/parameter.cpp b/src/plugins/intel_gpu/src/plugin/ops/parameter.cppindex 00f4f92909f..c2812dbf480 100644--- a/src/plugins/intel_gpu/src/plugin/ops/parameter.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/parameter.cpp@@ -76,8 +76,9 @@ static void CreateParameterOp(ProgramBuilder& p, const std::shared_ptr<ov::op::vstd::function<bool(const std::shared_ptr<ov::Node>&)> connected_to_quantize =[&](const std::shared_ptr<ov::Node> &node) -> bool {for (auto& user : node->get_users()) {- if (ov::is_type<ov::op::v0::FakeQuantize>(user))+ if (ov::is_type<ov::op::v0::FakeQuantize>(user)) {return true;+ }}return false;};@@ -98,8 +99,9 @@ static void CreateParameterOp(ProgramBuilder& p, const std::shared_ptr<ov::op::vstd::string suffix;std::vector<cldnn::input_info> surfaces_inputs;for (size_t i = 0; i < batch; ++i) {- if (batch > 1)+ if (batch > 1) {suffix = "_" + std::to_string(i);+ }std::string batched_name = input_name + suffix;p.add_primitive(*op, cldnn::input_layout(batched_name, input_layout));@@ -119,10 +121,11 @@ static void CreateParameterOp(ProgramBuilder& p, const std::shared_ptr<ov::op::vsurfaces_inputs.emplace_back(reorder_name);}- if (batch > 1 && !is_convert_color_input)+ if (batch > 1 && !is_convert_color_input) {p.add_primitive(*op, cldnn::concatenation(input_name, surfaces_inputs, 0));- else+ } else {p.primitive_ids[input_name] = "reorder:" + input_name + ProgramBuilder::m_preProcessTag;+ }} else {auto reorder_name = "reorder:" + input_name + ProgramBuilder::m_preProcessTag;diff --git a/src/plugins/intel_gpu/src/plugin/ops/reduce.cpp b/src/plugins/intel_gpu/src/plugin/ops/reduce.cppindex ba5886f9ff7..761a954c9d3 100644--- a/src/plugins/intel_gpu/src/plugin/ops/reduce.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/reduce.cpp@@ -34,11 +34,13 @@ static void CreateReduceOp(ProgramBuilder& p, const std::shared_ptr<ov::Node>& ostd::vector<int64_t> axes = axes_constant->cast_vector<int64_t>();for (size_t i = 0; i < axes.size(); i++) {- if (axes[i] < 0)+ if (axes[i] < 0) {axes[i] += rank;+ }- if (axes[i] >= static_cast<int64_t>(rank) || axes[i] < 0)+ if (axes[i] >= static_cast<int64_t>(rank) || axes[i] < 0) {OPENVINO_THROW("[GPU] Unsupported axis value in ", op->get_friendly_name(), " (", axes[i], ")");+ }}auto reducePrim = cldnn::reduce(layerName,@@ -78,12 +80,13 @@ static void CreateReduceOp(ProgramBuilder& p, const std::shared_ptr<ov::Node>& ocldnn::format out_format = cldnn::format::any;auto out_dt = cldnn::element_type_to_data_type(op->get_output_element_type(0));if (!keep_dims && rank > 4) {- if (rank - axes.size() == 6)+ if (rank - axes.size() == 6) {out_format = cldnn::format::bfwzyx;- else if (rank - axes.size() == 5)+ } else if (rank - axes.size() == 5) {out_format = cldnn::format::bfzyx;- else if (rank - axes.size() <= 4)+ } else if (rank - axes.size() <= 4) {out_format = cldnn::format::bfyx;+ }auto reorder_prim = cldnn::reorder(reorderLayerName,cldnn::input_info(resultLayerName),diff --git a/src/plugins/intel_gpu/src/plugin/ops/roi_pooling.cpp b/src/plugins/intel_gpu/src/plugin/ops/roi_pooling.cppindex c7c0e7980f6..21681127f68 100644--- a/src/plugins/intel_gpu/src/plugin/ops/roi_pooling.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/roi_pooling.cpp@@ -2,24 +2,26 @@// SPDX-License-Identifier: Apache-2.0//-#include "intel_gpu/plugin/program_builder.hpp"-#include "intel_gpu/plugin/common_utils.hpp"-#include "openvino/op/roi_pooling.hpp"-#include "openvino/op/psroi_pooling.hpp"-#include "openvino/op/deformable_psroi_pooling.hpp"+#include "intel_gpu/plugin/common_utils.hpp"+#include "intel_gpu/plugin/program_builder.hpp"#include "intel_gpu/primitives/roi_pooling.hpp"+#include "openvino/op/deformable_psroi_pooling.hpp"+#include "openvino/op/psroi_pooling.hpp"namespace ov::intel_gpu {static cldnn::pooling_mode GetPoolingMode(std::string method) {- if (method == "bilinear")+ if (method == "bilinear") {return cldnn::pooling_mode::bilinear;- if (method == "max")+ }+ if (method == "max") {return cldnn::pooling_mode::max;- if (method == "average")+ }+ if (method == "average") {return cldnn::pooling_mode::average;+ }return cldnn::pooling_mode::deformable_bilinear;}diff --git a/src/plugins/intel_gpu/src/plugin/ops/split.cpp b/src/plugins/intel_gpu/src/plugin/ops/split.cppindex 8b9a544a806..a75a464d537 100644--- a/src/plugins/intel_gpu/src/plugin/ops/split.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/split.cpp@@ -74,8 +74,9 @@ static void CreateCommonSplitOp(ProgramBuilder& p, const std::shared_ptr<ov::Nodfor (size_t i = 0; i < op->get_output_size(); i++) {const auto& users = op->get_output_target_inputs(i);// don't add crop primitive if port is not used by anyone- if (users.empty())+ if (users.empty()) {continue;+ }auto cropPrim = cldnn::crop(get_layer_name(i),inputs,cldnn::tensor(1),diff --git a/src/plugins/intel_gpu/src/plugin/ops/strided_slice.cpp b/src/plugins/intel_gpu/src/plugin/ops/strided_slice.cppindex 0597eb01d95..2bb7e1fdd6c 100644--- a/src/plugins/intel_gpu/src/plugin/ops/strided_slice.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/strided_slice.cpp@@ -27,8 +27,9 @@ static void CreateStridedSliceOp(ProgramBuilder& p, const std::shared_ptr<ov::opauto convert_max_val = [](int64_t casted_val, ov::element::Type type) {// if the original const is int32_t and the value is max,// it should be kept to set the shape as unbounded dynamic shape.- if ((type == ov::element::i32 && casted_val == INT_MAX) || (type == ov::element::u32 && casted_val == UINT_MAX))+ if ((type == ov::element::i32 && casted_val == INT_MAX) || (type == ov::element::u32 && casted_val == UINT_MAX)) {return static_cast<int64_t>(0x7FFFFFFFFFFFFFFF);+ }return casted_val;};@@ -58,20 +59,23 @@ static void CreateStridedSliceOp(ProgramBuilder& p, const std::shared_ptr<ov::opauto input_pshape = op->get_input_partial_shape(0);- if (input_pshape.is_dynamic() || output_pshape.is_dynamic())+ if (input_pshape.is_dynamic() || output_pshape.is_dynamic()) {return;+ }auto input_shape = input_pshape.to_shape();auto output_shape = output_pshape.to_shape();bool ones_stride = true;for (auto & s : strides) {- if (s != 1)+ if (s != 1) {ones_stride = false;+ }}- if (!ones_stride)+ if (!ones_stride) {break;+ }auto convert_to_set = [](const std::vector<int64_t> mask) {ov::AxisSet axis_set{};@@ -103,12 +107,14 @@ static void CreateStridedSliceOp(ProgramBuilder& p, const std::shared_ptr<ov::opint num_new_axis_after_ellipses = 0;int num_input_axis_before_ellipses = 0;for (size_t i = 0; i < axis; ++i) {- if (!new_axis_mask.count(i))+ if (!new_axis_mask.count(i)) {num_input_axis_before_ellipses++;+ }}for (size_t i = axis + 1; i < begin.size(); ++i) {- if (new_axis_mask.count(i))+ if (new_axis_mask.count(i)) {num_new_axis_after_ellipses++;+ }}// -1 because it's a position of ellipses@@ -137,9 +143,10 @@ static void CreateStridedSliceOp(ProgramBuilder& p, const std::shared_ptr<ov::opreshape_pattern.emplace_back(1);dim.emplace_back(1);int64_t lb = begin[axis];- if (lb < 0)+ if (lb < 0) {lb = std::max(static_cast<int64_t>(input_shape[input_shape_idx]) + lb,static_cast<int64_t>(0));+ }offset.emplace_back(begin_mask.count(axis) ? 0 : lb);input_shape_idx++;} else {@@ -150,12 +157,14 @@ static void CreateStridedSliceOp(ProgramBuilder& p, const std::shared_ptr<ov::opint64_t ub = end[axis];// convert negative indexes to positive- if (lb < 0)+ if (lb < 0) {lb = std::max(static_cast<int64_t>(input_shape[input_shape_idx]) + lb,static_cast<int64_t>(0));- if (ub < 0)+ }+ if (ub < 0) {ub = std::max(static_cast<int64_t>(input_shape[input_shape_idx]) + ub,static_cast<int64_t>(0));+ }// apply restrictions when begin or end values more/less than max/min possible values.lb = std::min(static_cast<int64_t>(input_shape[input_shape_idx]), lb);@@ -165,31 +174,38 @@ static void CreateStridedSliceOp(ProgramBuilder& p, const std::shared_ptr<ov::op// set default value for stride or use given valueint64_t stride = 1;- if (strides.size() > axis)+ if (strides.size() > axis) {stride = strides[axis];+ }int64_t dimension = 0;if (stride < 0) {// apply masks- if (begin_mask.count(axis))+ if (begin_mask.count(axis)) {lb = static_cast<int64_t>(input_shape[input_shape_idx]) - 1;- if (end_mask.count(axis))+ }+ if (end_mask.count(axis)) {ub = -1;+ }lb = std::min(lb, static_cast<int64_t>(input_shape[input_shape_idx]) - 1);lb -= 1; // we always get 1st element, so we need decrease range- if (ub <= lb)+ if (ub <= lb) {dimension = (ub - lb) / stride + 1;+ }} else {// apply masks- if (begin_mask.count(axis))+ if (begin_mask.count(axis)) {lb = 0;- if (end_mask.count(axis))+ }+ if (end_mask.count(axis)) {ub = static_cast<int64_t>(input_shape[input_shape_idx]);+ }lb += 1; // we always get 1st element, so we need decrease range- if (ub >= lb)+ if (ub >= lb) {dimension = (ub - lb) / stride + 1;+ }}dim.emplace_back(dimension);diff --git a/src/plugins/intel_gpu/src/plugin/ops/transpose.cpp b/src/plugins/intel_gpu/src/plugin/ops/transpose.cppindex 1a93bca2028..720014d614f 100644--- a/src/plugins/intel_gpu/src/plugin/ops/transpose.cpp+++ b/src/plugins/intel_gpu/src/plugin/ops/transpose.cpp@@ -26,8 +26,9 @@ static void CreateTransposeOp(ProgramBuilder& p, const std::shared_ptr<ov::op::vint rank = std::max(4, static_cast<int>(op->get_input_partial_shape(0).size()));if (order.empty()) {// if order size is less than 4 - fill the rest with just copy- for (int o = rank - 1; o >= 0; o--)+ for (int o = rank - 1; o >= 0; o--) {order.push_back((uint16_t)o);+ }}auto permutePrim = cldnn::permute(layerName,diff --git a/src/plugins/intel_gpu/src/plugin/plugin.cpp b/src/plugins/intel_gpu/src/plugin/plugin.cppindex 7c45c3c5869..6cb9a83788b 100644--- a/src/plugins/intel_gpu/src/plugin/plugin.cpp+++ b/src/plugins/intel_gpu/src/plugin/plugin.cpp@@ -98,8 +98,9 @@ bool Plugin::is_weightless_cache_attributes_set(const std::shared_ptr<const ov::auto& rtInfo = node->get_rt_info();const auto& it = rtInfo.find(type_info);- if (it != rtInfo.end())+ if (it != rtInfo.end()) {return true;+ }}}@@ -187,8 +188,9 @@ std::shared_ptr<ov::Model> Plugin::clone_and_transform_model(const std::shared_pif (config_copy.get_enable_weightless()) {const auto weight_path = ov::util::make_path(config.get_weights_path());- if (weight_path.extension() != ".bin" && !is_weightless_cache_attributes_set(cloned_model))+ if (weight_path.extension() != ".bin" && !is_weightless_cache_attributes_set(cloned_model)) {set_weightless_cache_attributes(cloned_model);+ }}transform_model(cloned_model, config_copy, context);@@ -312,8 +314,9 @@ std::shared_ptr<RemoteContextImpl> Plugin::get_default_context(const std::stringOPENVINO_ASSERT(contexts.count(device_id), "[GPU] Context was not initialized for ", device_id, " device");auto context = contexts.at(device_id);- if (initialize)+ if (initialize) {context->initialize();+ }return context;}@@ -321,8 +324,9 @@ std::shared_ptr<RemoteContextImpl> Plugin::get_default_context(const std::stringov::SoPtr<ov::IRemoteContext> Plugin::get_default_context(const AnyMap& params) const {std::string device_id = m_default_device_id;- if (params.find(ov::device::id.name()) != params.end())+ if (params.find(ov::device::id.name()) != params.end()) {device_id = params.at(ov::device::id.name()).as<std::string>();+ }return get_default_context(device_id);}@@ -504,8 +508,9 @@ ov::Any Plugin::get_property(const std::string& name, const ov::AnyMap& options)}if (name == ov::available_devices) {std::vector<std::string> available_devices = { };- for (const auto& dev : m_device_map)+ for (const auto& dev : m_device_map) {available_devices.push_back(dev.first);+ }return decltype(ov::available_devices)::value_type {available_devices};}if (name == ov::internal::caching_properties) {@@ -607,10 +612,12 @@ ov::Any Plugin::get_metric(const std::string& name, const ov::AnyMap& options) cauto device_id = get_property(ov::device::id.name(), options).as<std::string>();auto iter = m_device_map.find(std::to_string(cldnn::device_query::device_id));- if (iter == m_device_map.end())+ if (iter == m_device_map.end()) {iter = m_device_map.find(device_id);- if (iter == m_device_map.end())+ }+ if (iter == m_device_map.end()) {iter = m_device_map.begin();+ }auto device = iter->second;auto device_info = device->get_info();@@ -834,14 +841,18 @@ std::vector<std::string> Plugin::get_device_capabilities(const cldnn::device_infcapabilities.emplace_back(ov::device::capability::FP32);capabilities.emplace_back(ov::device::capability::BIN);- if (info.supports_fp16)+ if (info.supports_fp16) {capabilities.emplace_back(ov::device::capability::FP16);- if (info.supports_imad || info.supports_immad)+ }+ if (info.supports_imad || info.supports_immad) {capabilities.emplace_back(ov::device::capability::INT8);- if (info.supports_immad)+ }+ if (info.supports_immad) {capabilities.emplace_back(ov::intel_gpu::capability::HW_MATMUL);- if (info.supports_usm)+ }+ if (info.supports_usm) {capabilities.emplace_back(ov::intel_gpu::capability::USM_MEMORY);+ }capabilities.emplace_back(ov::device::capability::EXPORT_IMPORT);return capabilities;@@ -963,8 +974,9 @@ uint32_t Plugin::get_max_batch_size(const ov::AnyMap& options) const {const auto& param = params[input_id];shapes[input_id] = param->get_output_partial_shape(0);}- for (const auto& input : batched_inputs)+ for (const auto& input : batched_inputs) {shapes[input.first][input.second] = base_batch_size;+ }cloned_model->reshape(shapes);} catch (...) {GPU_DEBUG_INFO << "[MAX_BATCH_SIZE] Error at reshape to " << base_batch_size << std::endl;@@ -1038,8 +1050,9 @@ uint32_t Plugin::get_optimal_batch_size(const ov::AnyMap& options) const {auto cloned_model = clone_and_transform_model(model, config, context);ov::MemBandwidthPressure memPressure = ov::mem_bandwidth_pressure_tolerance(cloned_model, L3_cache_size);uint32_t batch = 1;- if (memPressure.max_mem_tolerance != ov::MemBandwidthPressure::UNKNOWN)+ if (memPressure.max_mem_tolerance != ov::MemBandwidthPressure::UNKNOWN) {batch = static_cast<uint32_t>(std::max(1.0, 16 * closest_pow_of_2(memPressure.max_mem_tolerance)));+ }ov::AnyMap options_for_max_batch;options_for_max_batch[ov::hint::model.name()] = model;options_for_max_batch[ov::num_streams.name()] = ov::streams::AUTO;diff --git a/src/plugins/intel_gpu/src/plugin/program_builder.cpp b/src/plugins/intel_gpu/src/plugin/program_builder.cppindex ab9a147a98e..3578457029a 100644--- a/src/plugins/intel_gpu/src/plugin/program_builder.cpp+++ b/src/plugins/intel_gpu/src/plugin/program_builder.cpp@@ -73,8 +73,9 @@ ProgramBuilder::ProgramBuilder(std::shared_ptr<ov::Model> model, cldnn::engine&// Constant GPU uploads use the engine before cldnn::program ctor syncs config to the engine.m_engine.set_enable_large_allocations(m_config.get_enable_large_allocations());- if (m_task_executor == nullptr)+ if (m_task_executor == nullptr) {m_task_executor = cldnn::program::make_task_executor(m_config);+ }if (m_compilation_context == nullptr) {m_compilation_context = cldnn::program::make_compilation_context(m_config);@@ -186,8 +187,9 @@ bool ProgramBuilder::is_op_supported(const std::shared_ptr<ov::Node>& op) {// 2. We also check parameters of each operation, which means we have more// reliable results of QueryNetwork call.prepare_build();- if (!data_types_are_supported(op.get()))+ if (!data_types_are_supported(op.get())) {return false;+ }CreateSingleLayerPrimitive(op);cleanup_build();@@ -320,8 +322,9 @@ void ProgramBuilder::add_primitive(const ov::Node& op, std::shared_ptr<cldnn::prif (id != prim_id) {primitive_ids[prim_id] = prim_id;- if (!multi_output_case)+ if (!multi_output_case) {prim->origin_op_type_name = prim->type_string();+ }}if (this->m_config.get_enable_profiling() && should_profile) {diff --git a/src/plugins/intel_gpu/src/plugin/sync_infer_request.cpp b/src/plugins/intel_gpu/src/plugin/sync_infer_request.cppindex 9368b2750eb..929893d62da 100644--- a/src/plugins/intel_gpu/src/plugin/sync_infer_request.cpp+++ b/src/plugins/intel_gpu/src/plugin/sync_infer_request.cpp@@ -2,38 +2,38 @@// SPDX-License-Identifier: Apache-2.0//-#include "openvino/runtime/make_tensor.hpp"-#include "openvino/core/memory_util.hpp"-#include "openvino/core/preprocess/input_tensor_info.hpp"-#include "openvino/core/parallel.hpp"-#include "openvino/core/validation_util.hpp"--#include "intel_gpu/primitives/kv_cache.hpp"-#include "intel_gpu/primitives/read_value.hpp"-#include "intel_gpu/plugin/common_utils.hpp"-#include "intel_gpu/plugin/usm_host_tensor.hpp"#include "intel_gpu/plugin/sync_infer_request.hpp"-#include "intel_gpu/plugin/remote_context.hpp"-#include "intel_gpu/plugin/remote_tensor.hpp"-#include "intel_gpu/plugin/compiled_model.hpp"-#include "intel_gpu/plugin/variable_state.hpp"-#include "intel_gpu/plugin/multi_tensor_variable_state.hpp"-#include "intel_gpu/runtime/memory.hpp"-#include "intel_gpu/runtime/memory_caps.hpp"-#include "intel_gpu/runtime/internal_properties.hpp"-#include "intel_gpu/runtime/itt.hpp"-#include "intel_gpu/runtime/debug_configuration.hpp"#include <algorithm>+#include <functional>#include <iterator>+#include <map>#include <memory>+#include <mutex>+#include <shared_mutex>#include <string>-#include <map>#include <unordered_set>-#include <functional>#include <utility>-#include <mutex>-#include <shared_mutex>++#include "intel_gpu/plugin/common_utils.hpp"+#include "intel_gpu/plugin/compiled_model.hpp"+#include "intel_gpu/plugin/multi_tensor_variable_state.hpp"+#include "intel_gpu/plugin/remote_context.hpp"+#include "intel_gpu/plugin/remote_tensor.hpp"+#include "intel_gpu/plugin/usm_host_tensor.hpp"+#include "intel_gpu/plugin/variable_state.hpp"+#include "intel_gpu/primitives/kv_cache.hpp"+#include "intel_gpu/primitives/read_value.hpp"+#include "intel_gpu/runtime/debug_configuration.hpp"+#include "intel_gpu/runtime/internal_properties.hpp"+#include "intel_gpu/runtime/itt.hpp"+#include "intel_gpu/runtime/memory.hpp"+#include "intel_gpu/runtime/memory_caps.hpp"+#include "openvino/core/memory_util.hpp"+#include "openvino/core/parallel.hpp"+#include "openvino/core/preprocess/input_tensor_info.hpp"+#include "openvino/core/validation_util.hpp"+#include "openvino/runtime/make_tensor.hpp"namespace {@@ -42,8 +42,8 @@ bool is_convert_required(ov::element::Type src_et, ov::element::Type dst_et) {}bool same_host_mem(cldnn::memory::cptr memory, const uint8_t* host_ptr) {- const uint8_t* device_ptr = memory->get_allocation_type() == cldnn::allocation_type::usm_host ?- static_cast<uint8_t*>(memory->get_internal_params().mem) : nullptr;+ const uint8_t* device_ptr =+ memory->get_allocation_type() == cldnn::allocation_type::usm_host ? static_cast<uint8_t*>(memory->get_internal_params().mem) : nullptr;return device_ptr == host_ptr;}@@ -79,7 +79,8 @@ cldnn::data_types data_type_for_remote_tensor(ov::element::Type t) {return cldnn::data_types::i32;case ov::element::Type_t::boolean:return cldnn::data_types::u8;- default: return t;+ default:+ return t;}}@@ -91,12 +92,10 @@ namespace ov::intel_gpu {// -------------- ThreadSafeVariableStateWrapper (see issue #36458) ----------------------------- //// ----------------------------------------------------------------------------------------------- //-ThreadSafeVariableStateWrapper::ThreadSafeVariableStateWrapper(- std::shared_ptr<ov::IVariableState> state,- std::shared_ptr<Graph> graph)- : ov::IVariableState(state->get_name())- , m_state(std::move(state))- , m_graph(std::move(graph)) {}+ThreadSafeVariableStateWrapper::ThreadSafeVariableStateWrapper(std::shared_ptr<ov::IVariableState> state, std::shared_ptr<Graph> graph)+ : ov::IVariableState(state->get_name()),+ m_state(std::move(state)),+ m_graph(std::move(graph)) {}void ThreadSafeVariableStateWrapper::reset() {// Acquire the same mutex that infer() holds during shape inference@@ -120,13 +119,13 @@ ov::SoPtr<ov::ITensor> ThreadSafeVariableStateWrapper::get_state() const {// ----------------------------------------------------------------------------------------------- //SyncInferRequest::SyncInferRequest(const std::shared_ptr<const CompiledModel>& compiled_model)- : ov::ISyncInferRequest(compiled_model)- , m_graph(compiled_model->get_graph(0))- , m_context(std::static_pointer_cast<RemoteContextImpl>(compiled_model->get_context_impl()))- , m_shape_predictor(new cldnn::ShapePredictor(&m_graph->get_engine(), m_graph->get_config().get_shape_predictor_settings()))- , m_enable_profiling(m_graph->get_config().get_enable_profiling())- , m_use_external_queue(m_graph->use_external_queue())- , m_itt_infer_request_str("SyncInferenceGPU::infer::" + std::string(compiled_model->get_model_name())) {+ : ov::ISyncInferRequest(compiled_model),+ m_graph(compiled_model->get_graph(0)),+ m_context(std::static_pointer_cast<RemoteContextImpl>(compiled_model->get_context_impl())),+ m_shape_predictor(new cldnn::ShapePredictor(&m_graph->get_engine(), m_graph->get_config().get_shape_predictor_settings())),+ m_enable_profiling(m_graph->get_config().get_enable_profiling()),+ m_use_external_queue(m_graph->use_external_queue()),+ m_itt_infer_request_str("SyncInferenceGPU::infer::" + std::string(compiled_model->get_model_name())) {init_mappings();allocate_inputs();allocate_outputs();@@ -153,7 +152,7 @@ SyncInferRequest::~SyncInferRequest() {void SyncInferRequest::infer() {// String can be constructed once in the constructor- OV_ITT_SCOPED_TASK_BASE(itt::domains::intel_gpu_inference, m_itt_infer_request_str.c_str());+ OV_ITT_SCOPED_TASK_BASE(itt::domains::intel_gpu_inference, m_itt_infer_request_str.c_str());setup_stream_graph();std::lock_guard<std::mutex> lk(m_graph->get_mutex());enqueue();@@ -172,9 +171,7 @@ std::vector<ov::SoPtr<ov::IVariableState>> SyncInferRequest::query_state() const// graph mutex before reset()/set_state(), preventing concurrent// modification during shape inference on sibling InferRequests.// See: https://github.com/openvinotoolkit/openvino/issues/36458- ret.emplace_back(- std::make_shared<ThreadSafeVariableStateWrapper>(pair.second, m_graph),- nullptr);+ ret.emplace_back(std::make_shared<ThreadSafeVariableStateWrapper>(pair.second, m_graph), nullptr);}return ret;}@@ -187,8 +184,11 @@ void SyncInferRequest::set_tensor(const ov::Output<const ov::Node>& port, constOPENVINO_ASSERT(tensor != nullptr, "[GPU] Failed to set empty tensor to port with index: \'", port_index, "\'");OPENVINO_ASSERT(port.get_element_type() == tensor->get_element_type(),- "[GPU] Mismatch tensor and port type: ", port.get_element_type(), " vs ", tensor->get_element_type());- OPENVINO_ASSERT(shape.compatible(ov::PartialShape(tensor->get_shape())) || tensor->get_shape() == ov::Shape {0} || port.get_partial_shape().is_dynamic(),+ "[GPU] Mismatch tensor and port type: ",+ port.get_element_type(),+ " vs ",+ tensor->get_element_type());+ OPENVINO_ASSERT(shape.compatible(ov::PartialShape(tensor->get_shape())) || tensor->get_shape() == ov::Shape{0} || port.get_partial_shape().is_dynamic(),"[GPU] The tensor size is not equal to model, can't set input tensor with index: ",port_index,", because model input (shape=",@@ -205,16 +205,16 @@ void SyncInferRequest::set_tensor(const ov::Output<const ov::Node>& port, constauto is_same_tensor = user_tensors[port_index].ptr == tensor._ptr;// Keep PLUGIN as a tensor owner if current user's tensor owner is PLUGIN and underlying tensor pointer is not changed- auto new_tensor_owner = current_tensor_owner == TensorOwner::PLUGIN && is_same_tensor ? TensorOwner::PLUGIN- : TensorOwner::USER;+ auto new_tensor_owner = current_tensor_owner == TensorOwner::PLUGIN && is_same_tensor ? TensorOwner::PLUGIN : TensorOwner::USER;- user_tensors[port_index] = { tensor._ptr, new_tensor_owner };+ user_tensors[port_index] = {tensor._ptr, new_tensor_owner};// We need to properly handle PLUGIN -> USER ownership change to prevent invalid PLUGIN's ush_host buffer sharing,// so remove plugin's tensor to reallocate it in prepare_input() methodif (current_tensor_owner == TensorOwner::PLUGIN && new_tensor_owner == TensorOwner::USER) {- if ((plugin_tensors.count(port_index) != 0u) && std::dynamic_pointer_cast<RemoteTensorImpl>(plugin_tensors[port_index].ptr)->is_shared())+ if ((plugin_tensors.count(port_index) != 0u) && std::dynamic_pointer_cast<RemoteTensorImpl>(plugin_tensors[port_index].ptr)->is_shared()) {plugin_tensors.erase(plugin_tensors.find(port_index));+ }}};@@ -264,13 +264,11 @@ ov::SoPtr<ov::ITensor> SyncInferRequest::get_tensor(const ov::Output<const ov::N// Materialize the reserved slot on first access.if (!tensor_ptr) {ensure_input_allocated(port_index);- GPU_DEBUG_LOG << "[lazy alloc] input " << port_index- << " shape: " << port.get_partial_shape()- << " allocated at get_tensor" << std::endl;+ GPU_DEBUG_LOG << "[lazy alloc] input " << port_index << " shape: " << port.get_partial_shape() << " allocated at get_tensor" << std::endl;auto inputs = m_user_inputs.read();tensor_ptr = inputs->at(port_index).ptr;}- return { tensor_ptr, nullptr };+ return {tensor_ptr, nullptr};}{auto outputs = m_user_outputs.read();@@ -293,8 +291,9 @@ void SyncInferRequest::check_tensors() const {auto it = inputs->find(i);return it != inputs->end() && !it->second.ptr;}();- if (not_allocated)+ if (not_allocated) {continue;+ }check_tensor(inputs[i], get_tensor_ptr(inputs[i]));}}@@ -358,9 +357,7 @@ void SyncInferRequest::enqueue() {}if (needs_alloc) {ensure_input_allocated(port_idx);- GPU_DEBUG_LOG << "[lazy alloc] input " << port_idx- << " shape: " << port.get_partial_shape()- << " allocated at enqueue" << std::endl;+ GPU_DEBUG_LOG << "[lazy alloc] input " << port_idx << " shape: " << port.get_partial_shape() << " allocated at enqueue" << std::endl;}}@@ -486,7 +483,7 @@ void SyncInferRequest::wait() {auto sync_end = std::chrono::high_resolution_clock::now();GPU_DEBUG_IF(true)- sync_total_time = std::chrono::duration_cast<std::chrono::microseconds>(sync_end - sync_start).count();+ sync_total_time = std::chrono::duration_cast<std::chrono::microseconds>(sync_end - sync_start).count();}std::vector<cldnn::event::ptr> copy_events;@@ -530,13 +527,16 @@ void SyncInferRequest::wait() {GPU_DEBUG_TRACE_DETAIL << internal_name << " handle output tensor (remote) with index: " << port_idx << ": "<< remote_tensor_impl_ptr->get_original_memory_buf_ptr() << std::endl;} else {- GPU_DEBUG_TRACE_DETAIL << internal_name << " handle output tensor (host) with index: " << port_idx << ": "- << output_tensor->data() << std::endl;+ GPU_DEBUG_TRACE_DETAIL << internal_name << " handle output tensor (host) with index: " << port_idx << ": " << output_tensor->data() << std::endl;}OPENVINO_ASSERT(output_tensor_wrapper.owner == TensorOwner::PLUGIN || is_dynamic || output_tensor_wrapper.actual_size >= output_memory->size(),- "[GPU] Output port is static and output tensor set by user has smaller size (", output_tensor->get_byte_size(), ") ",- "than required (", output_memory->size(), ")");+ "[GPU] Output port is static and output tensor set by user has smaller size (",+ output_tensor->get_byte_size(),+ ") ",+ "than required (",+ output_memory->size(),+ ")");bool need_output_update = output_layout.bytes_count() == 0 || (output_memory && output_tensor->get_byte_size() != output_memory->size());@@ -569,8 +569,8 @@ void SyncInferRequest::wait() {// the block already owns the memory that the GPU wrote into.// Update the USMHostTensor's backing memory to point to the block's buffer.auto block_it = m_output_memory_blocks.find(port_idx);- if (block_it != m_output_memory_blocks.end() && block_it->second->memory() && usm_host_tensor- && output_tensor_wrapper.owner == TensorOwner::PLUGIN) {+ if (block_it != m_output_memory_blocks.end() && block_it->second->memory() && usm_host_tensor &&+ output_tensor_wrapper.owner == TensorOwner::PLUGIN) {auto block_mem = block_it->second->memory();auto* impl = usm_host_tensor->get_impl().get();// Update the backing memory to match the block's current buffer and actual data size@@ -586,10 +586,10 @@ void SyncInferRequest::wait() {if (need_reallocate) {std::string internal_name = m_output_names_map.at(port_idx);- auto actual_memory_shape = predict_shape(internal_name, cldnn::layout(mem_shape,- output_tensor->get_element_type(),- cldnn::format::get_default_format(mem_shape.size())),- *m_shape_predictor);+ auto actual_memory_shape =+ predict_shape(internal_name,+ cldnn::layout(mem_shape, output_tensor->get_element_type(), cldnn::format::get_default_format(mem_shape.size())),+ *m_shape_predictor);output_tensor->set_shape(actual_memory_shape);}}@@ -605,7 +605,8 @@ void SyncInferRequest::wait() {bool same_mem = same_host_mem(output_memory, dst_ptr);if (!same_mem && output_memory->size()) {GPU_DEBUG_TRACE_DETAIL << internal_name << " with index " << port_idx << " copy from: " << output_memory->buffer_ptr() << " to "- << (!is_remote_tensor_impl ? output_tensor->data() : remote_tensor_impl_ptr->get_original_memory_buf_ptr()) << std::endl;+ << (!is_remote_tensor_impl ? output_tensor->data() : remote_tensor_impl_ptr->get_original_memory_buf_ptr())+ << std::endl;if (auto ev = copy_output_data(output_memory, *output_tensor)) {copy_events.push_back(ev);}@@ -689,7 +690,8 @@ std::shared_ptr<ov::ITensor> SyncInferRequest::create_host_tensor(const ov::Partreturn m_context->create_host_tensor(port_element_type, get_tensor_shape(port_shape))._ptr;}-std::shared_ptr<ov::ITensor> SyncInferRequest::create_device_tensor(const ov::PartialShape& port_shape, ov::element::Type element_type,+std::shared_ptr<ov::ITensor> SyncInferRequest::create_device_tensor(const ov::PartialShape& port_shape,+ ov::element::Type element_type,bool need_lockable_memory) const {TensorType tensor_type = TensorType::BT_EMPTY;if (m_graph->get_engine().use_unified_shared_memory()) {@@ -699,13 +701,11 @@ std::shared_ptr<ov::ITensor> SyncInferRequest::create_device_tensor(const ov::Pa}// Create OpenCL buffer for PVC if lockable memory is needed due to performance issue with usm host- if (!can_use_usm_host(m_graph->get_engine(), total_output_bytes) && need_lockable_memory)+ if (!can_use_usm_host(m_graph->get_engine(), total_output_bytes) && need_lockable_memory) {tensor_type = TensorType::BT_BUF_INTERNAL;+ }- return std::make_shared<RemoteTensorImpl>(m_context,- get_tensor_shape(port_shape),- ::data_type_for_remote_tensor(element_type),- tensor_type);+ return std::make_shared<RemoteTensorImpl>(m_context, get_tensor_shape(port_shape), ::data_type_for_remote_tensor(element_type), tensor_type);}TensorWrapper SyncInferRequest::create_or_share_device_tensor(const TensorWrapper& user_tensor_wrapper,@@ -724,41 +724,42 @@ TensorWrapper SyncInferRequest::create_or_share_device_tensor(const TensorWrappe// Note: currently, using USM Host memory for dGPUs in some scenarios (LLMs) leads to performance degradation,// so apply wider USM Host memory type detection only for iGPUsauto user_tensor_mem_type = !generic_remote_tensor ? engine.detect_usm_allocation_type(user_tensor->data()) : cldnn::allocation_type::unknown;- auto usm_host_raw_ptr = engine.get_device_info().dev_type == cldnn::device_type::integrated_gpu &&- user_tensor_mem_type == cldnn::allocation_type::usm_host;+ auto usm_host_raw_ptr = engine.get_device_info().dev_type == cldnn::device_type::integrated_gpu && user_tensor_mem_type == cldnn::allocation_type::usm_host;- bool can_share = !is_convert_required(user_tensor->get_element_type(), element_type)- && can_use_usm_host(engine, total_output_bytes)- && !generic_remote_tensor;+ bool can_share =+ !is_convert_required(user_tensor->get_element_type(), element_type) && can_use_usm_host(engine, total_output_bytes) && !generic_remote_tensor;if (usm_host_tensor && can_share && m_context == usm_host_tensor->get_impl()->get_context()) {- return { usm_host_tensor->get_impl(), user_tensor_wrapper.owner };+ return {usm_host_tensor->get_impl(), user_tensor_wrapper.owner};}if (usm_host_raw_ptr && can_share) {- return { std::make_shared<RemoteTensorImpl>(m_context,- user_tensor->get_shape(),- ::data_type_for_remote_tensor(element_type),- TensorType::BT_USM_SHARED,- user_tensor->data()), TensorOwner::USER };+ return {std::make_shared<RemoteTensorImpl>(m_context,+ user_tensor->get_shape(),+ ::data_type_for_remote_tensor(element_type),+ TensorType::BT_USM_SHARED,+ user_tensor->data()),+ TensorOwner::USER};}auto actual_memory_shape = tensor_shape;if (is_dynamic) {- actual_memory_shape = predict_shape(name, cldnn::layout(tensor_shape,- element_type,- cldnn::format::get_default_format(tensor_shape.size())),- *m_shape_predictor);+ actual_memory_shape =+ predict_shape(name, cldnn::layout(tensor_shape, element_type, cldnn::format::get_default_format(tensor_shape.size())), *m_shape_predictor);}- return { create_device_tensor(actual_memory_shape, element_type, need_lockable_mem), TensorOwner::PLUGIN };+ return {create_device_tensor(actual_memory_shape, element_type, need_lockable_mem), TensorOwner::PLUGIN};}cldnn::event::ptr SyncInferRequest::copy_output_data(cldnn::memory::ptr src, ov::ITensor& dst) const {OV_ITT_SCOPED_TASK(itt::domains::intel_gpu_plugin, "SyncInferRequest::copy_output_data");OPENVINO_ASSERT(src->count() <= dst.get_size(),"[GPU] Unexpected elements count of dst tensor: ",- "expected at least ", src->count(), ", but ",- "only ", dst.get_size(), " got");+ "expected at least ",+ src->count(),+ ", but ",+ "only ",+ dst.get_size(),+ " got");const auto& layout = src->get_layout();auto& stream = m_graph->get_network()->get_stream();@@ -803,7 +804,7 @@ void SyncInferRequest::allocate_input(size_t input_idx, GuardedMap::map_t& user_const auto& shape = internal_port.get_partial_shape();auto element_type = internal_port.get_element_type();- user_inputs[input_idx] = { create_host_tensor(shape, element_type), TensorOwner::PLUGIN };+ user_inputs[input_idx] = {create_host_tensor(shape, element_type), TensorOwner::PLUGIN};if (element_type == ov::element::string) {// In case the element type is string and input data is an empty string,// it produces the segmentation fault unless the each element of tensor.data is initialized.@@ -838,10 +839,8 @@ void SyncInferRequest::allocate_output(const ov::Output<const ov::Node>& port,const auto& device_info = engine.get_device_info();// In the case of dynamic shapes, the total_output_bytes is useless as the actual output size is determined only at runtime.// For dGPUs, using USM Host memory for outputs may lead to performance degradation in some scenarios (see can_use_usm_host impl).- // We have to be conservative and enable USM Host memory for dynamic outputs only on iGPUs.- if (cldnn::device_type::integrated_gpu == device_info.dev_type &&- shape.is_dynamic() &&- can_use_usm_host(engine, total_output_bytes)) {+ // We have to be conservative and enable USM Host memory for dynamic outputs only on iGPUs.+ if (cldnn::device_type::integrated_gpu == device_info.dev_type && shape.is_dynamic() && can_use_usm_host(engine, total_output_bytes)) {auto device_et = convert_to_supported_device_type(element_type);if (!is_convert_required(device_et, element_type)) {m_output_memory_blocks[output_idx] = std::make_unique<OutputMemoryBlock>(engine);@@ -859,12 +858,13 @@ void SyncInferRequest::allocate_inputs() {for (const auto& it : m_input_ports_map) {size_t input_idx = it.first;const auto& port = it.second;- GPU_DEBUG_LOG << "[init input blob with index: " << input_idx << "]" << " shape: " << port.get_partial_shape() << " type: " << port.get_element_type() << std::endl;+ GPU_DEBUG_LOG << "[init input blob with index: " << input_idx << "]" << " shape: " << port.get_partial_shape() << " type: " << port.get_element_type()+ << std::endl;bool is_nv12_input = false;if (port.get_rt_info().count(ov::preprocess::TensorInfoMemoryType::get_type_info_static()) != 0u) {- std::string mem_type = port.get_rt_info().at(ov::preprocess::TensorInfoMemoryType::get_type_info_static())- .as<ov::preprocess::TensorInfoMemoryType>().value;+ std::string mem_type =+ port.get_rt_info().at(ov::preprocess::TensorInfoMemoryType::get_type_info_static()).as<ov::preprocess::TensorInfoMemoryType>().value;if (mem_type.find(ov::intel_gpu::memory_type::surface) != std::string::npos) {is_nv12_input = true;}@@ -875,9 +875,8 @@ void SyncInferRequest::allocate_inputs() {const bool can_defer = pshape.is_static() && port.get_element_type() != ov::element::string;if (can_defer) {// Reserve a null slot; materialized lazily or replaced by set_tensor().- (*inputs)[input_idx] = { nullptr, TensorOwner::PLUGIN };- GPU_DEBUG_LOG << "[lazy alloc] reserved input slot " << input_idx- << " shape: " << pshape << std::endl;+ (*inputs)[input_idx] = {nullptr, TensorOwner::PLUGIN};+ GPU_DEBUG_LOG << "[lazy alloc] reserved input slot " << input_idx << " shape: " << pshape << std::endl;} else {// Dynamic/string inputs stay eager.allocate_input(input_idx, *inputs);@@ -896,16 +895,18 @@ void SyncInferRequest::allocate_outputs() {for (const auto& it : m_output_ports_map) {size_t output_idx = it.first;const auto& port = it.second;- GPU_DEBUG_LOG << "[init output blob with index: " << output_idx << "]" << " shape: " << port.get_partial_shape() << " type: " << port.get_element_type() << std::endl;+ GPU_DEBUG_LOG << "[init output blob with index: " << output_idx << "]" << " shape: " << port.get_partial_shape() << " type: " << port.get_element_type()+ << std::endl;allocate_output(port, output_idx, *outputs);const auto& pshape = port.get_partial_shape();// Deferred static outputs have no tensor yet; size them from the static shape.- if (pshape.is_static())+ if (pshape.is_static()) {total_output_bytes += ov::util::get_memory_size(port.get_element_type(),ov::shape_size(pshape.to_shape()));- else+ } else {total_output_bytes += ov::ISyncInferRequest::get_tensor(port)->get_byte_size();+ }}}@@ -934,23 +935,18 @@ void SyncInferRequest::allocate_states() {}if (compressed) {- m_variables.emplace(vi.first, std::make_shared<VariableStateIndirectKVCacheCompressed>(vi.second,- m_context,- m_shape_predictor,- states_layouts,- beam_axis,- concat_axis,- has_zp_state));- } else if (indirect_kv_cache) {- m_variables.emplace(vi.first, std::make_shared<VariableStateIndirectKVCache>(vi.second,+ m_variables.emplace(vi.first,+ std::make_shared<VariableStateIndirectKVCacheCompressed>(vi.second,m_context,m_shape_predictor,+ states_layouts,beam_axis,- concat_axis));+ concat_axis,+ has_zp_state));+ } else if (indirect_kv_cache) {+ m_variables.emplace(vi.first, std::make_shared<VariableStateIndirectKVCache>(vi.second, m_context, m_shape_predictor, beam_axis, concat_axis));} else {- m_variables.emplace(vi.first, std::make_shared<VariableState>(vi.second,- m_context,- m_shape_predictor));+ m_variables.emplace(vi.first, std::make_shared<VariableState>(vi.second, m_context, m_shape_predictor));}}}@@ -1021,10 +1017,8 @@ std::vector<cldnn::event::ptr> SyncInferRequest::prepare_input(const std::stringbool is_remote_tensor_impl = remote_tensor_impl_ptr != nullptr;bool is_usm_host_tensor = usm_host_ptr != nullptr && usm_host_ptr->get_impl()->get_context() == m_context;- GPU_DEBUG_TRACE_DETAIL << "Prepare input for " << internal_name- << " (is_remote_tensor_impl ? " << is_remote_tensor_impl- << ", is_usm_host_tensor ? " << is_usm_host_tensor- << ", is_generic_remote ? " << is_generic_remote << ")" << std::endl;+ GPU_DEBUG_TRACE_DETAIL << "Prepare input for " << internal_name << " (is_remote_tensor_impl ? " << is_remote_tensor_impl << ", is_usm_host_tensor ? "+ << is_usm_host_tensor << ", is_generic_remote ? " << is_generic_remote << ")" << std::endl;GPU_DEBUG_TRACE_DETAIL << " port shape : " << pshape.to_string() << std::endl;GPU_DEBUG_TRACE_DETAIL << " user_tensor shape: " << user_tensor->get_shape().to_string() << std::endl;@@ -1048,9 +1042,7 @@ std::vector<cldnn::event::ptr> SyncInferRequest::prepare_input(const std::stringif (is_remote_tensor_impl) {if (convert_needed) {- m_plugin_inputs[input_idx] = { create_device_tensor(pshape,- ::data_type_for_remote_tensor(element_type),- false), TensorOwner::PLUGIN };+ m_plugin_inputs[input_idx] = {create_device_tensor(pshape, ::data_type_for_remote_tensor(element_type), false), TensorOwner::PLUGIN};} else {m_plugin_inputs[input_idx] = user_tensor_wrapper;}@@ -1063,7 +1055,7 @@ std::vector<cldnn::event::ptr> SyncInferRequest::prepare_input(const std::stringuser_tensor->data()),TensorOwner::USER};} else {- m_plugin_inputs[input_idx] = { usm_host_ptr->get_impl(), user_tensor_wrapper.owner };+ m_plugin_inputs[input_idx] = {usm_host_ptr->get_impl(), user_tensor_wrapper.owner};}is_remote_tensor_impl = true;}@@ -1080,11 +1072,9 @@ std::vector<cldnn::event::ptr> SyncInferRequest::prepare_input(const std::string// Note: currently, using USM Host memory for dGPUs in some scenarios (LLMs) leads to performance degradation,// so apply wider USM Host memory type detection only for iGPUs- auto usm_host_raw_ptr = engine.get_device_info().dev_type == cldnn::device_type::integrated_gpu &&- user_tensor_mem_type == cldnn::allocation_type::usm_host;+ auto usm_host_raw_ptr = engine.get_device_info().dev_type == cldnn::device_type::integrated_gpu && user_tensor_mem_type == cldnn::allocation_type::usm_host;- bool update_device_tensor = ((m_plugin_inputs.count(input_idx) == 0) ||- (m_plugin_inputs[input_idx].owner == TensorOwner::USER && !is_remote_tensor_impl) ||+ bool update_device_tensor = ((m_plugin_inputs.count(input_idx) == 0) || (m_plugin_inputs[input_idx].owner == TensorOwner::USER && !is_remote_tensor_impl) ||(plugin_tensor_mem_type != cldnn::allocation_type::usm_host && usm_host_raw_ptr));if (update_device_tensor) {// If device input hasn't been created, then try to use user memory if it's usm_host, or allocate new device buffer@@ -1096,14 +1086,14 @@ std::vector<cldnn::event::ptr> SyncInferRequest::prepare_input(const std::stringauto device_tensor = std::dynamic_pointer_cast<RemoteTensorImpl>(device_tensor_wrapper.ptr);if (is_dynamic) {if (device_tensor->get_original_memory()->size() < user_tensor->get_byte_size()) {- auto actual_shape = predict_shape(internal_name, cldnn::layout(user_tensor->get_shape(),- element_type,- cldnn::format::get_default_format(user_tensor->get_shape().size())),- *m_shape_predictor);+ auto actual_shape =+ predict_shape(internal_name,+ cldnn::layout(user_tensor->get_shape(), element_type, cldnn::format::get_default_format(user_tensor->get_shape().size())),+ *m_shape_predictor);GPU_DEBUG_TRACE_DETAIL << " actual memory shape: " << actual_shape.to_string() << std::endl;auto new_tensor = create_device_tensor(actual_shape, device_tensor_et, need_lockable_mem);new_tensor->set_shape(user_tensor->get_shape());- m_plugin_inputs[input_idx] = { new_tensor, TensorOwner::PLUGIN };+ m_plugin_inputs[input_idx] = {new_tensor, TensorOwner::PLUGIN};}}}@@ -1115,7 +1105,8 @@ std::vector<cldnn::event::ptr> SyncInferRequest::prepare_input(const std::stringdevice_tensor->get_original_memory()->size(),") is expected to be greater or equal to user tensor (=",user_tensor->get_size(),- ") in dynamic case for ", internal_name);+ ") in dynamic case for ",+ internal_name);// tensor reshape below is expected to work w/o reallocationdevice_tensor->set_shape(user_tensor->get_shape());} else {@@ -1124,7 +1115,8 @@ std::vector<cldnn::event::ptr> SyncInferRequest::prepare_input(const std::stringuser_tensor->get_size(),") and device tensor (=",device_tensor->get_size(),- ") don't match for ", internal_name,+ ") don't match for ",+ internal_name,". Those are expected to be equal in case of static shape of the port");}@@ -1162,8 +1154,9 @@ std::vector<cldnn::event::ptr> SyncInferRequest::prepare_input(const std::string<< " alloc_type: " << memory->get_allocation_type() << std::endl;network->set_input_data(internal_name, memory);- if (ret_event && !ret_event->is_set())- return { ret_event };+ if (ret_event && !ret_event->is_set()) {+ return {ret_event};+ }return {};}@@ -1208,15 +1201,14 @@ std::vector<cldnn::event::ptr> SyncInferRequest::prepare_output(size_t output_idif (!is_dynamic) {bool need_lockable_mem = network->does_node_need_lockable_output(internal_name);bool has_device_buffer = m_plugin_outputs.count(output_idx) > 0;- bool update_device_tensor = !has_device_buffer ||- is_generic_remote ||- (m_plugin_outputs[output_idx].owner == TensorOwner::USER && !is_remote_tensor_impl);+ bool update_device_tensor =+ !has_device_buffer || is_generic_remote || (m_plugin_outputs[output_idx].owner == TensorOwner::USER && !is_remote_tensor_impl);if (update_device_tensor) {if (!is_remote_tensor_impl) {m_plugin_outputs[output_idx] =create_or_share_device_tensor(user_tensor_wrapper, internal_name, pshape, device_tensor_et, need_lockable_mem || convert_needed);} else {- m_plugin_outputs[output_idx] = { create_device_tensor(pshape, device_tensor_et, need_lockable_mem || convert_needed), TensorOwner::PLUGIN };+ m_plugin_outputs[output_idx] = {create_device_tensor(pshape, device_tensor_et, need_lockable_mem || convert_needed), TensorOwner::PLUGIN};}}}diff --git a/src/plugins/intel_gpu/src/plugin/transformations/binary_conv_to_conv.cpp b/src/plugins/intel_gpu/src/plugin/transformations/binary_conv_to_conv.cppindex 9d0c9244f1d..db1a339a307 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/binary_conv_to_conv.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/binary_conv_to_conv.cpp@@ -37,8 +37,9 @@ ConvertBinaryConvolutionToConvolution::ConvertBinaryConvolutionToConvolution() {auto binary_fq = [](const Output<Node>& node) {auto fq = ov::as_type_ptr<ov::op::v0::FakeQuantize>(node.get_node_shared_ptr());- if (!fq)+ if (!fq) {return false;+ }return fq->get_levels() == 2;};diff --git a/src/plugins/intel_gpu/src/plugin/transformations/convert_convolution.cpp b/src/plugins/intel_gpu/src/plugin/transformations/convert_convolution.cppindex b7ceccea1a2..7e7e165454d 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/convert_convolution.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/convert_convolution.cpp@@ -4,8 +4,11 @@#include "convert_convolution.hpp"+#include <memory>+#include "intel_gpu/op/convolution.hpp"#include "intel_gpu/op/placeholder.hpp"+#include "openvino/core/graph_util.hpp"#include "openvino/core/rt_info.hpp"#include "openvino/op/group_conv.hpp"#include "openvino/op/subtract.hpp"@@ -17,16 +20,13 @@#include "openvino/pass/pattern/op/wrap_type.hpp"#include "transformations/utils/utils.hpp"-#include <memory>-#include "openvino/core/graph_util.hpp"-using namespace ov::pass::pattern;using ov::pass::pattern::op::Or;namespace ov::intel_gpu {namespace {-template<typename W_T, typename AZP_T>+template <typename W_T, typename AZP_T>ov::Tensor get_compensation(ov::Tensor* w_tensor, ov::Tensor* azp_tensor, ov::Tensor* wzp_tensor, int64_t groups) {const auto weights_shape = w_tensor->get_shape();const auto output_channels = groups > 0 ? weights_shape[1] : weights_shape[0];@@ -52,10 +52,8 @@ ov::Tensor get_compensation(ov::Tensor* w_tensor, ov::Tensor* azp_tensor, ov::Tefor (size_t k = 0; k < total_spatial_size; k++) {size_t azp_offset = (g * input_channels + ic) % azp_total;size_t wzp_offset = (g * output_channels + oc) % wzp_total;- const auto w_offset = g * output_channels * input_channels * total_spatial_size- + oc * input_channels * total_spatial_size- + ic * total_spatial_size- + k;+ const auto w_offset =+ g * output_channels * input_channels * total_spatial_size + oc * input_channels * total_spatial_size + ic * total_spatial_size + k;if (azp) {c += w[w_offset] * azp[azp_offset];@@ -86,14 +84,18 @@ ov::Tensor get_compensation(std::shared_ptr<ov::Node> w, std::shared_ptr<ov::Nodwzp_tensor = ov::Tensor(wzp_const->get_element_type(), wzp_const->get_shape(), const_cast<void*>(wzp_const->get_data_ptr()));}- if (w_const->get_element_type() == ov::element::u8 && azp_const->get_element_type() == ov::element::u8)+ if (w_const->get_element_type() == ov::element::u8 && azp_const->get_element_type() == ov::element::u8) {return get_compensation<uint8_t, uint8_t>(&w_tensor, &azp_tensor, wzp_const ? &wzp_tensor : nullptr, groups);- if (w_const->get_element_type() == ov::element::u8 && azp_const->get_element_type() == ov::element::i8)+ }+ if (w_const->get_element_type() == ov::element::u8 && azp_const->get_element_type() == ov::element::i8) {return get_compensation<uint8_t, int8_t>(&w_tensor, &azp_tensor, wzp_const ? &wzp_tensor : nullptr, groups);- if (w_const->get_element_type() == ov::element::i8 && azp_const->get_element_type() == ov::element::u8)+ }+ if (w_const->get_element_type() == ov::element::i8 && azp_const->get_element_type() == ov::element::u8) {return get_compensation<int8_t, uint8_t>(&w_tensor, &azp_tensor, wzp_const ? &wzp_tensor : nullptr, groups);- if (w_const->get_element_type() == ov::element::i8 && azp_const->get_element_type() == ov::element::i8)+ }+ if (w_const->get_element_type() == ov::element::i8 && azp_const->get_element_type() == ov::element::i8) {return get_compensation<int8_t, int8_t>(&w_tensor, &azp_tensor, wzp_const ? &wzp_tensor : nullptr, groups);+ }OPENVINO_THROW("[GPU] Unsupported element types combination for quantized weights and zero-points");}@@ -124,7 +126,7 @@ AsymmetricConvolutionMatcher::AsymmetricConvolutionMatcher() {auto conv_activations_m = std::make_shared<Or>(OutputVector{input_m, azp_subtract_m});auto conv_weights_m = std::make_shared<Or>(OutputVector{weights_m, wzp_subtract_m});- auto convolution_m = wrap_type<ov::op::v1::Convolution, ov::op::v1::GroupConvolution>({ conv_activations_m, conv_weights_m });+ auto convolution_m = wrap_type<ov::op::v1::Convolution, ov::op::v1::GroupConvolution>({conv_activations_m, conv_weights_m});ov::matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](Matcher& m) {const auto& pattern_map = m.get_pattern_value_map();@@ -137,8 +139,9 @@ AsymmetricConvolutionMatcher::AsymmetricConvolutionMatcher() {int64_t groups = -1;if (auto grouped_conv = ov::as_type_ptr<ov::op::v1::GroupConvolution>(conv_node)) {auto weights_shape = grouped_conv->get_input_partial_shape(1);- if (weights_shape[0].is_dynamic())+ if (weights_shape[0].is_dynamic()) {return false;+ }groups = weights_shape[0].get_length();}@@ -188,7 +191,7 @@ ConvolutionMatcher::ConvolutionMatcher() {auto input_m = any_input();auto weights_m = any_input(has_static_dim(0));auto bias_val_m = wrap_type<ov::op::v0::Constant>();- auto convolution_m = wrap_type<ov::op::v1::Convolution, ov::op::v1::GroupConvolution>({ input_m, weights_m });+ auto convolution_m = wrap_type<ov::op::v1::Convolution, ov::op::v1::GroupConvolution>({input_m, weights_m});ov::matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](Matcher& m) {const auto& pattern_map = m.get_pattern_value_map();@@ -201,8 +204,9 @@ ConvolutionMatcher::ConvolutionMatcher() {int64_t groups = -1;if (auto grouped_conv = ov::as_type_ptr<ov::op::v1::GroupConvolution>(conv_node)) {auto weights_shape = grouped_conv->get_input_partial_shape(1);- if (weights_shape[0].is_dynamic())+ if (weights_shape[0].is_dynamic()) {return false;+ }groups = weights_shape[0].get_length();}diff --git a/src/plugins/intel_gpu/src/plugin/transformations/convert_fc_to_compressed.cpp b/src/plugins/intel_gpu/src/plugin/transformations/convert_fc_to_compressed.cppindex 736b98ae5ab..8d01b03d82d 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/convert_fc_to_compressed.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/convert_fc_to_compressed.cpp@@ -6,8 +6,10 @@#include <memory>+#include "compressed_weights_pattern.hpp"#include "intel_gpu/op/fully_connected.hpp"#include "intel_gpu/op/fully_connected_compressed.hpp"+#include "openvino/core/graph_util.hpp"#include "openvino/core/rt_info.hpp"#include "openvino/core/rt_info/weightless_caching_attributes.hpp"#include "openvino/op/constant.hpp"@@ -21,9 +23,6 @@#include "openvino/pass/pattern/op/pattern.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"#include "transformations/utils/utils.hpp"-#include "openvino/core/graph_util.hpp"--#include "compressed_weights_pattern.hpp"namespace ov::intel_gpu {using namespace ov::pass::pattern;@@ -51,26 +50,31 @@ ConvertFullyConnectedToFullyConnectedCompressed::ConvertFullyConnectedToFullyConbool sub_with_convert = pattern_map.count(sub_with_convert_m) > 0;auto weight_shape = fc->get_input_shape(1);- bool is_weight_3d = (std::count_if(weight_shape.begin(), weight_shape.end(), [](size_t d) { return d > 1; }) == 3);+ bool is_weight_3d = (std::count_if(weight_shape.begin(), weight_shape.end(), [](size_t d) {+ return d > 1;+ }) == 3);bool grouped = scale_shape.size() == weight_shape.size() + 1;bool weight_u8 = false;std::shared_ptr<ov::Node> weight_ptr =pattern_map.count(weights_const_m) ? pattern_map.at(weights_const_m).get_node_shared_ptr() : pattern_map.at(weights_param_m).get_node_shared_ptr();- if (weight_ptr->get_element_type() == ov::element::u8 || weight_ptr->get_element_type() == ov::element::i8)+ if (weight_ptr->get_element_type() == ov::element::u8 || weight_ptr->get_element_type() == ov::element::i8) {weight_u8 = true;+ }auto reshape_const = [has_transpose, grouped, is_weight_3d](std::shared_ptr<ov::Node> node) {auto constant = ov::as_type_ptr<ov::op::v0::Constant>(node);OPENVINO_ASSERT(constant != nullptr);ov::Shape current_shape = constant->get_shape();- if (current_shape.size() <= 2)+ if (current_shape.size() <= 2) {return constant;+ }ov::Shape new_shape;if (current_shape.size() == 3) {- if (is_weight_3d)+ if (is_weight_3d) {return constant;+ }new_shape = (has_transpose || !grouped) ? ov::Shape{current_shape[0] * current_shape[1], current_shape[2]}: ov::Shape{current_shape[0], current_shape[1] * current_shape[2]};} else if (current_shape.size() == 4 && is_weight_3d) {@@ -80,8 +84,7 @@ ConvertFullyConnectedToFullyConnectedCompressed::ConvertFullyConnectedToFullyConnew_shape = (has_transpose || !grouped) ? ov::Shape{current_shape[0] * current_shape[1] * current_shape[2], current_shape[3]}: ov::Shape{current_shape[0] * current_shape[1], current_shape[2] * current_shape[3]};} else {- OPENVINO_THROW("Unexpected constant shape rank ", current_shape.size(),- " with is_weight_3d=", is_weight_3d);+ OPENVINO_THROW("Unexpected constant shape rank ", current_shape.size(), " with is_weight_3d=", is_weight_3d);}auto new_constant = std::make_shared<ov::op::v0::Constant>(*constant, new_shape);@@ -93,21 +96,21 @@ ConvertFullyConnectedToFullyConnectedCompressed::ConvertFullyConnectedToFullyConauto constant = ov::as_type_ptr<ov::op::v0::Constant>(node);std::shared_ptr<ov::Node> result = nullptr;// Convert ZP to u8- if (constant->get_element_type() == ov::element::u8)+ if (constant->get_element_type() == ov::element::u8) {result = constant;- else if (constant->get_element_type() == ov::element::u4 || constant->get_element_type() == ov::element::u2)+ } else if (constant->get_element_type() == ov::element::u4 || constant->get_element_type() == ov::element::u2) {result = std::make_shared<ov::op::v0::Convert>(node, ov::element::u8);- // Only unsigned ZP types can be converted to u8.- else if (weight_u8 && sub_with_convert && !constant->get_element_type().is_signed())+ // Only unsigned ZP types can be converted to u8.+ } else if (weight_u8 && sub_with_convert && !constant->get_element_type().is_signed()) {result = std::make_shared<ov::op::v0::Convert>(node, ov::element::u8);- else+ } else {result = constant;+ }ov::copy_weightless_cache_attr(node, result);return result;};-const ov::Output<Node>& fc_input_a = fc->input(0).get_source_output();const auto& scale = reshape_const(pattern_map.at(mul_const_m).get_node_shared_ptr());std::shared_ptr<ov::Node> optional_zero_point = nullptr;@@ -117,10 +120,10 @@ ConvertFullyConnectedToFullyConnectedCompressed::ConvertFullyConnectedToFullyConoptional_zero_point = convert_const_to_u8(reshape_const(pattern_map.at(sub_const_m).get_node_shared_ptr()));}- std::shared_ptr<ov::Node> fc_input_b =- pattern_map.count(weights_const_m) ? reshape_const(pattern_map.at(weights_const_m).get_node_shared_ptr())- : (pattern_map.count(weights_reshape_m) ? pattern_map.at(weights_reshape_m).get_node_shared_ptr()- : pattern_map.at(weights_param_m).get_node_shared_ptr());+ std::shared_ptr<ov::Node> fc_input_b = pattern_map.count(weights_const_m)+ ? reshape_const(pattern_map.at(weights_const_m).get_node_shared_ptr())+ : (pattern_map.count(weights_reshape_m) ? pattern_map.at(weights_reshape_m).get_node_shared_ptr()+ : pattern_map.at(weights_param_m).get_node_shared_ptr());std::shared_ptr<ov::Node> fc_input_scale = scale;std::shared_ptr<ov::Node> fc_input_zp = optional_zero_point;std::shared_ptr<ov::Node> fc_input_bias = pattern_map.at(bias_m).get_node_shared_ptr();@@ -129,7 +132,7 @@ ConvertFullyConnectedToFullyConnectedCompressed::ConvertFullyConnectedToFullyConif (fc_input_b->get_output_partial_shape(0).size() != fc_input_scale->get_shape().size()) {OPENVINO_ASSERT(!pattern_map.count(weights_const_m));ov::Shape weight_shape_final(fc_input_scale->get_shape().size(), 1);- for (size_t i = weight_shape.size() - 1, idx = fc_input_scale->get_shape().size() - 1; ; --i) {+ for (size_t i = weight_shape.size() - 1, idx = fc_input_scale->get_shape().size() - 1;; --i) {if (weight_shape[i] > 1) {weight_shape_final[idx--] = weight_shape[i];}@@ -178,10 +181,20 @@ ConvertFullyConnectedToFullyConnectedCompressed::ConvertFullyConnectedToFullyConstd::shared_ptr<ov::Node> new_fc = nullptr;if (with_zero_point) {- new_fc =- std::make_shared<op::FullyConnectedCompressed>(fc_input_a, fc_input_b, fc_input_bias, fc_input_scale, fc_input_zp, fc->get_output_type(), fc->get_transpose_b());+ new_fc = std::make_shared<op::FullyConnectedCompressed>(fc_input_a,+ fc_input_b,+ fc_input_bias,+ fc_input_scale,+ fc_input_zp,+ fc->get_output_type(),+ fc->get_transpose_b());} else {- new_fc = std::make_shared<op::FullyConnectedCompressed>(fc_input_a, fc_input_b, fc_input_bias, fc_input_scale, fc->get_output_type(), fc->get_transpose_b());+ new_fc = std::make_shared<op::FullyConnectedCompressed>(fc_input_a,+ fc_input_b,+ fc_input_bias,+ fc_input_scale,+ fc->get_output_type(),+ fc->get_transpose_b());}result_nodes.push_back(new_fc);diff --git a/src/plugins/intel_gpu/src/plugin/transformations/convert_matmul_to_fc.cpp b/src/plugins/intel_gpu/src/plugin/transformations/convert_matmul_to_fc.cppindex eb8f7bb83a5..50e7625391c 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/convert_matmul_to_fc.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/convert_matmul_to_fc.cpp@@ -240,10 +240,11 @@ ConvertMatMulToFullyConnected::ConvertMatMulToFullyConnected(bool supports_immad} else if (supports_immad && shape_a.is_static() && shape_b.is_static()) {auto output_shape = matmul->get_output_shape(0);size_t k = 0;- if (matmul->get_transpose_a())+ if (matmul->get_transpose_a()) {k = shape_a[shape_a.rank().get_length() - 2].get_length();- else+ } else {k = shape_a[shape_a.rank().get_length() - 1].get_length();+ }// M is the row/token dimension and N the output dimension of the matmul.size_t m = output_shape.size() >= 2 ? output_shape[output_shape.size() - 2] : 1;size_t n = !output_shape.empty() ? output_shape[output_shape.size() - 1] : 1;diff --git a/src/plugins/intel_gpu/src/plugin/transformations/convert_stridedslices_to_variadicsplit.cpp b/src/plugins/intel_gpu/src/plugin/transformations/convert_stridedslices_to_variadicsplit.cppindex 1487e0d12e4..e4847e9528e 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/convert_stridedslices_to_variadicsplit.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/convert_stridedslices_to_variadicsplit.cpp@@ -5,7 +5,6 @@#include "convert_stridedslices_to_variadicsplit.hpp"#include "intel_gpu/op/fully_connected_compressed.hpp"-#include "openvino/core/rt_info.hpp"#include "openvino/core/validation_util.hpp"#include "openvino/op/constant.hpp"@@ -24,10 +23,11 @@ ConvertStridedSlicesToVariadicSplit::ConvertStridedSlicesToVariadicSplit() {const size_t num_users_to_fuse = 3;const auto fc = ov::as_type_ptr<op::FullyConnectedCompressed>(output.get_node_shared_ptr());size_t user_count = 0;- for (const auto& user : fc ->get_users()) {+ for (const auto& user : fc->get_users()) {const auto strided_slice = ov::as_type_ptr<ov::op::v1::StridedSlice>(user);- if (!strided_slice)+ if (!strided_slice) {return false;+ }user_count++;}return (user_count == num_users_to_fuse) && consumers_count(num_users_to_fuse)(output);@@ -55,34 +55,36 @@ ConvertStridedSlicesToVariadicSplit::ConvertStridedSlicesToVariadicSplit() {};const auto& input_ps = strided_slice_node->get_input_partial_shape(0);const auto& output_ps = strided_slice_node->get_output_partial_shape(0);- if (!valid_ps(input_ps) || !valid_ps(output_ps) || input_ps.rank().get_length() != output_ps.rank().get_length())+ if (!valid_ps(input_ps) || !valid_ps(output_ps) || input_ps.rank().get_length() != output_ps.rank().get_length()) {return false;+ }const auto& total_length = input_ps[input_ps.rank().get_length() - 1];const auto& split_length = output_ps[output_ps.rank().get_length() - 1];- if (total_length.get_length() / 3 != split_length.get_length())+ if (total_length.get_length() / 3 != split_length.get_length()) {return false;+ }split_lengths.push_back(split_length.get_length());- if (!strided_slice_node->get_shrink_axis_mask().empty() ||- !strided_slice_node->get_new_axis_mask().empty() ||+ if (!strided_slice_node->get_shrink_axis_mask().empty() || !strided_slice_node->get_new_axis_mask().empty() ||!strided_slice_node->get_ellipsis_mask().empty()) {return false;}- if (strided_slice_node->get_input_size() == 4 &&- !ov::op::util::is_constant_and_all_values_equal_int(strided_slice_node->input_value(3), 1)) {+ if (strided_slice_node->get_input_size() == 4 && !ov::op::util::is_constant_and_all_values_equal_int(strided_slice_node->input_value(3), 1)) {return false;}end_offset += split_length.get_length();auto check_mask = [](const std::vector<int64_t>& mask_to_check) -> bool {- if (mask_to_check.back() != 0)+ if (mask_to_check.back() != 0) {return false;+ }for (size_t i = 0; i < mask_to_check.size() - 1; ++i) {- if (!mask_to_check[i])+ if (!mask_to_check[i]) {return false;+ }}return true;};@@ -90,28 +92,34 @@ ConvertStridedSlicesToVariadicSplit::ConvertStridedSlicesToVariadicSplit() {if (const auto& begin_constant_node = ov::util::get_constant_from_source(begin_node)) {auto values = begin_constant_node->cast_vector<int64_t>();auto begin_mask = strided_slice_node->get_begin_mask();- if (values.size() != begin_mask.size())+ if (values.size() != begin_mask.size()) {return false;- if (!check_mask(begin_mask))+ }+ if (!check_mask(begin_mask)) {return false;- if (values.back() != begin_offset)+ }+ if (values.back() != begin_offset) {return false;+ }} else {return false;}auto end_node = strided_slice_node->input_value(2);if (const auto& end_constant_node = ov::util::get_constant_from_source(end_node)) {- int64_t max_value = end_node.get_node()->get_element_type() == ov::element::i32 ? std::numeric_limits<int32_t>::max()- : std::numeric_limits<int64_t>::max();+ int64_t max_value =+ end_node.get_node()->get_element_type() == ov::element::i32 ? std::numeric_limits<int32_t>::max() : std::numeric_limits<int64_t>::max();auto values = end_constant_node->cast_vector<int64_t>();auto end_mask = strided_slice_node->get_end_mask();- if (values.size() != end_mask.size())+ if (values.size() != end_mask.size()) {return false;- if (!check_mask(end_mask))+ }+ if (!check_mask(end_mask)) {return false;- if ((values.back() != end_offset) && (values.back() != max_value))+ }+ if ((values.back() != end_offset) && (values.back() != max_value)) {return false;+ }} else {return false;}@@ -120,7 +128,7 @@ ConvertStridedSlicesToVariadicSplit::ConvertStridedSlicesToVariadicSplit() {}}auto name = fc->get_friendly_name() + "_split";- auto axis_const = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{1}, {fc->get_output_partial_shape(0).rank().get_length()- 1});+ auto axis_const = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{1}, {fc->get_output_partial_shape(0).rank().get_length() - 1});auto split_lenghts_const = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{3}, split_lengths);auto variadic_split = std::make_shared<ov::op::v1::VariadicSplit>(fc, axis_const, split_lenghts_const);variadic_split->set_friendly_name(name);diff --git a/src/plugins/intel_gpu/src/plugin/transformations/decompose_reduce_for_false_keepdims.cpp b/src/plugins/intel_gpu/src/plugin/transformations/decompose_reduce_for_false_keepdims.cppindex 909aca7be6c..939bedc752d 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/decompose_reduce_for_false_keepdims.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/decompose_reduce_for_false_keepdims.cpp@@ -1,4 +1,4 @@-// Copyright (C) 2018-2026 Intel Corporationc+// Copyright (C) 2018-2026 Intel Corporation// SPDX-License-Identifier: Apache-2.0//@@ -38,8 +38,9 @@ DecomposeReduceForFalseKeepDims::DecomposeReduceForFalseKeepDims() {const auto& pattern_map = m.get_pattern_value_map();auto reduce =as_type_ptr<op::util::ArithmeticReductionKeepDims>(pattern_map.at(reduce_pattern).get_node_shared_ptr());- if (!reduce)+ if (!reduce) {return false;+ }auto input = reduce->input_value(0);const auto input_shape = input.get_shape();@@ -59,18 +60,19 @@ DecomposeReduceForFalseKeepDims::DecomposeReduceForFalseKeepDims() {ov::op::v0::Constant::create(ov::element::i64, ov::Shape{axes_vector.size()}, axes_vector);// Add each reduce mode supported by oneDNN- if (ov::is_type<ov::op::v1::ReduceSum>(reduce))+ if (ov::is_type<ov::op::v1::ReduceSum>(reduce)) {input = std::make_shared<ov::op::v1::ReduceSum>(input, reduce_const, true);- else if (ov::is_type<ov::op::v1::ReduceMean>(reduce))+ } else if (ov::is_type<ov::op::v1::ReduceMean>(reduce)) {input = std::make_shared<ov::op::v1::ReduceMean>(input, reduce_const, true);- else if (ov::is_type<ov::op::v1::ReduceMin>(reduce))+ } else if (ov::is_type<ov::op::v1::ReduceMin>(reduce)) {input = std::make_shared<ov::op::v1::ReduceMin>(input, reduce_const, true);- else if (ov::is_type<ov::op::v1::ReduceMax>(reduce))+ } else if (ov::is_type<ov::op::v1::ReduceMax>(reduce)) {input = std::make_shared<ov::op::v1::ReduceMax>(input, reduce_const, true);- else if (ov::is_type<ov::op::v1::ReduceProd>(reduce))+ } else if (ov::is_type<ov::op::v1::ReduceProd>(reduce)) {input = std::make_shared<ov::op::v1::ReduceProd>(input, reduce_const, true);- else+ } else {return false;+ }input.get_node_shared_ptr()->set_friendly_name(reduce->get_friendly_name());new_ops.push_back(input.get_node_shared_ptr());diff --git a/src/plugins/intel_gpu/src/plugin/transformations/decompose_reduce_scalar_output.cpp b/src/plugins/intel_gpu/src/plugin/transformations/decompose_reduce_scalar_output.cppindex abd0c30de8a..7a49355126d 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/decompose_reduce_scalar_output.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/decompose_reduce_scalar_output.cpp@@ -69,8 +69,9 @@ ov::intel_gpu::DecomposeReduceForScalarOutput::DecomposeReduceForScalarOutput()const auto& pattern_map = m.get_pattern_value_map();auto reduce_orig =as_type_ptr<op::util::ArithmeticReductionKeepDims>(pattern_map.at(reduce_pattern).get_node_shared_ptr());- if (!reduce_orig || transformation_callback(reduce_orig))+ if (!reduce_orig || transformation_callback(reduce_orig)) {return false;+ }const auto& input_shape = reduce_orig->input_value(0).get_partial_shape();const auto& output_shape = reduce_orig->get_output_partial_shape(0);@@ -99,8 +100,9 @@ ov::intel_gpu::DecomposeReduceForScalarOutput::DecomposeReduceForScalarOutput()}}}- if (!reduce_new)+ if (!reduce_new) {return false;+ }CREATE_REDUCE(reduce_new->get_default_output(), reduce_orig->input_value(1), reduce_orig->get_keep_dims());reduce_new->set_friendly_name(reduce_orig->get_friendly_name());diff --git a/src/plugins/intel_gpu/src/plugin/transformations/disable_fp16_comp_cumsum_sin_gen.cpp b/src/plugins/intel_gpu/src/plugin/transformations/disable_fp16_comp_cumsum_sin_gen.cppindex ed33227f6bb..ee5fc5e2342 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/disable_fp16_comp_cumsum_sin_gen.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/disable_fp16_comp_cumsum_sin_gen.cpp@@ -32,15 +32,17 @@ DisableFP16CompCumSumSinGen::DisableFP16CompCumSumSinGen() {const auto& pattern_map = m.get_pattern_value_map();auto sin_node = pattern_map.at(sin_m).get_node_shared_ptr();- if (transformation_callback(sin_node))+ if (transformation_callback(sin_node)) {return false;+ }auto cumsum_node = pattern_map.at(cumsum_m).get_node_shared_ptr();// Also tag the producer feeding CumSum's first input.auto cumsum_input = cumsum_node->input_value(0).get_node_shared_ptr();- if (cumsum_input)+ if (cumsum_input) {ov::disable_conversion(cumsum_input, element::f16);+ }for (const auto& key : {cumsum_m, mul1_m, transpose2_m, mul2_m, interpolate_m, transpose3_m, sin_m}) {ov::disable_conversion(pattern_map.at(key).get_node_shared_ptr(), element::f16);diff --git a/src/plugins/intel_gpu/src/plugin/transformations/dynamic_quantize_fully_connected.cpp b/src/plugins/intel_gpu/src/plugin/transformations/dynamic_quantize_fully_connected.cppindex 09c5a185570..1df5a4ca803 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/dynamic_quantize_fully_connected.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/dynamic_quantize_fully_connected.cpp@@ -125,8 +125,9 @@ DynamicQuantizeFullyConnected::DynamicQuantizeFullyConnected(uint64_t group_sizedyn_quan->output(dyn_quan_output_idx++) : std::make_shared<ov::intel_gpu::op::Placeholder>();auto output_type = m_fc->get_output_type();- if (output_type.is_dynamic())+ if (output_type.is_dynamic()) {output_type = m_fc->get_input_element_type(0);+ }auto new_fc = std::make_shared<op::FullyConnectedCompressed>(dyn_quan->output(0),m_fc->input_value(1),diff --git a/src/plugins/intel_gpu/src/plugin/transformations/expand_broadcast_reshape_sdpa_fusion.cpp b/src/plugins/intel_gpu/src/plugin/transformations/expand_broadcast_reshape_sdpa_fusion.cppindex fa8941b4097..179c2fb841a 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/expand_broadcast_reshape_sdpa_fusion.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/expand_broadcast_reshape_sdpa_fusion.cpp@@ -4,24 +4,24 @@#include "expand_broadcast_reshape_sdpa_fusion.hpp"-#include "intel_gpu/op/sdpa.hpp"-#include "intel_gpu/op/kv_cache.hpp"+#include <optional>+#include "intel_gpu/op/kv_cache.hpp"+#include "intel_gpu/op/sdpa.hpp"+#include "openvino/core/graph_util.hpp"#include "openvino/core/rt_info.hpp"#include "openvino/op/broadcast.hpp"+#include "openvino/op/concat.hpp"#include "openvino/op/constant.hpp"#include "openvino/op/reshape.hpp"#include "openvino/op/transpose.hpp"#include "openvino/op/unsqueeze.hpp"-#include "openvino/op/concat.hpp"#include "openvino/pass/pattern/op/label.hpp"-#include "openvino/pass/pattern/op/wrap_type.hpp"-#include "openvino/pass/pattern/op/or.hpp"#include "openvino/pass/pattern/op/optional.hpp"+#include "openvino/pass/pattern/op/or.hpp"+#include "openvino/pass/pattern/op/wrap_type.hpp"#include "ov_ops/rotary_positional_embeddings.hpp"#include "transformations/utils/utils.hpp"-#include "openvino/core/graph_util.hpp"-#include <optional>namespace ov::intel_gpu {using ov::pass::pattern::op::Or;@@ -77,12 +77,12 @@ ExpandBroadcastReshapeSDPAFusion::ExpandBroadcastReshapeSDPAFusion() {auto concat_expand_pred = [](const ov::Output<ov::Node>& out) {auto concat = ov::as_type_ptr<ov::op::v0::Concat>(out.get_node_shared_ptr());- if (!concat)+ if (!concat) {return false;+ }auto reshape_input = ov::as_type_ptr<ov::op::v1::Reshape>(concat->get_input_node_shared_ptr(0));- bool reshape_check = reshape_input &&- reshape_input->get_output_partial_shape(0).rank().is_static() &&- reshape_input->get_output_partial_shape(0).size() == 5;+ bool reshape_check =+ reshape_input && reshape_input->get_output_partial_shape(0).rank().is_static() && reshape_input->get_output_partial_shape(0).size() == 5;return concat && concat->get_axis() == 2 && concat->get_input_size() > 2 && reshape_check;};@@ -90,21 +90,19 @@ ExpandBroadcastReshapeSDPAFusion::ExpandBroadcastReshapeSDPAFusion() {auto reshape_k_m = wrap_type<ov::op::v1::Reshape>({any_input(), any_input()});auto concat_k_expand_m = wrap_type<ov::op::v0::Concat>(concat_expand_pred);auto broadcast_k_expand_m = wrap_type<ov::op::v3::Broadcast>({reshape_k_m, any_input()});- auto expand_key_m = std::make_shared<ov::pass::pattern::op::Label>(- ov::element::dynamic,- ov::PartialShape::dynamic(),- rank_equals(5),- OutputVector{concat_k_expand_m, broadcast_k_expand_m});+ auto expand_key_m = std::make_shared<ov::pass::pattern::op::Label>(ov::element::dynamic,+ ov::PartialShape::dynamic(),+ rank_equals(5),+ OutputVector{concat_k_expand_m, broadcast_k_expand_m});auto reshape_b_b_m = wrap_type<ov::op::v1::Reshape>({expand_key_m, any_input()}, rank_equals(4));auto reshape_v_m = wrap_type<ov::op::v1::Reshape>({any_input(), any_input()});auto concat_v_expand_m = wrap_type<ov::op::v0::Concat>(concat_expand_pred);auto broadcast_v_expand_m = wrap_type<ov::op::v3::Broadcast>({reshape_v_m, any_input()});- auto expand_value_m = std::make_shared<ov::pass::pattern::op::Label>(- ov::element::dynamic,- ov::PartialShape::dynamic(),- rank_equals(5),- OutputVector{concat_v_expand_m, broadcast_v_expand_m});+ auto expand_value_m = std::make_shared<ov::pass::pattern::op::Label>(ov::element::dynamic,+ ov::PartialShape::dynamic(),+ rank_equals(5),+ OutputVector{concat_v_expand_m, broadcast_v_expand_m});auto reshape_c_b_m = wrap_type<ov::op::v1::Reshape>({expand_value_m, any_input()}, rank_equals(4));// ── Combined K/V inputs: Pattern A (with optional Convert) OR Pattern B ──@@ -126,29 +124,33 @@ ExpandBroadcastReshapeSDPAFusion::ExpandBroadcastReshapeSDPAFusion() {auto sdpa = ov::as_type_ptr<op::SDPA>(m.get_match_root());- auto valid_broadcast_target_shape = [](const std::vector<int32_t>& input_shape,- const std::vector<int32_t>& target_shape,- bool is_static_output) {+ auto valid_broadcast_target_shape = [](const std::vector<int32_t>& input_shape, const std::vector<int32_t>& target_shape, bool is_static_output) {if (is_static_output) {// For static output shapes, check that input_shape and target_shape differ in exactly one dimension- if (input_shape.empty() || (input_shape.size() != target_shape.size())) return false;+ if (input_shape.empty() || (input_shape.size() != target_shape.size()))+ return false;int diff_cnt = 0;for (size_t i = 0; i < input_shape.size(); ++i) {- if (input_shape[i] != target_shape[i]) ++diff_cnt;+ if (input_shape[i] != target_shape[i])+ ++diff_cnt;}return diff_cnt == 1;}- // For dynamic output shapes, check the target_shape pattern- return std::count_if(target_shape.begin(), target_shape.end(), [](int32_t s) { return s != 1; }) == 1;+ // For dynamic output shapes, check the target_shape pattern+ return std::count_if(target_shape.begin(), target_shape.end(), [](int32_t s) {+ return s != 1;+ }) == 1;};auto get_input_shape = [](const std::shared_ptr<ov::op::v3::Broadcast>& broadcast) -> std::vector<int32_t> {- if (!broadcast) return {};+ if (!broadcast)+ return {};auto input_node = broadcast->get_input_node_shared_ptr(0);if (input_node && input_node->get_output_partial_shape(0).is_static()) {auto pshape = input_node->get_output_shape(0);std::vector<int32_t> result(pshape.size());- std::transform(pshape.begin(), pshape.end(), result.begin(),- [](size_t v) { return static_cast<int32_t>(v); });+ std::transform(pshape.begin(), pshape.end(), result.begin(), [](size_t v) {+ return static_cast<int32_t>(v);+ });return result;}return {};@@ -156,8 +158,9 @@ ExpandBroadcastReshapeSDPAFusion::ExpandBroadcastReshapeSDPAFusion() {// ── Pattern B path: bypass reshape→expand→reshape by rewiring SDPA inputs directly ──if (pattern_map.count(expand_key_m) > 0) {- if (pattern_map.count(expand_value_m) == 0)+ if (pattern_map.count(expand_value_m) == 0) {return false;+ }// --- Validate broadcast for expand_key_m ---auto expand_key_node = pattern_map.at(expand_key_m).get_node_shared_ptr();@@ -206,15 +209,15 @@ ExpandBroadcastReshapeSDPAFusion::ExpandBroadcastReshapeSDPAFusion() {if (pattern_map.count(concat_k_expand_m) > 0 && pattern_map.count(concat_v_expand_m) > 0) {auto concat_k_node = pattern_map.at(concat_k_expand_m).get_node_shared_ptr();- auto *reshape_k = concat_k_node->input_value(0).get_node();+ auto* reshape_k = concat_k_node->input_value(0).get_node();auto concat_v_node = pattern_map.at(concat_v_expand_m).get_node_shared_ptr();- auto *reshape_v = concat_v_node->input_value(0).get_node();+ auto* reshape_v = concat_v_node->input_value(0).get_node();return replace_sdpa_inputs(reshape_k, reshape_v);}if (pattern_map.count(broadcast_k_expand_m) > 0 && pattern_map.count(broadcast_v_expand_m) > 0) {- auto *reshape_k = pattern_map.at(reshape_k_m).get_node_shared_ptr().get();- auto *reshape_v = pattern_map.at(reshape_v_m).get_node_shared_ptr().get();+ auto* reshape_k = pattern_map.at(reshape_k_m).get_node_shared_ptr().get();+ auto* reshape_v = pattern_map.at(reshape_v_m).get_node_shared_ptr().get();return replace_sdpa_inputs(reshape_k, reshape_v);}}@@ -274,7 +277,8 @@ ExpandBroadcastReshapeSDPAFusion::ExpandBroadcastReshapeSDPAFusion() {}}- if (broadcast_axis == -1) return std::nullopt;+ if (broadcast_axis == -1)+ return std::nullopt;// handle if the 5D expansion was a reshapeif (auto reshape_node = ov::as_type_ptr<ov::op::v1::Reshape>(orig_5d_expansion)) {@@ -285,7 +289,7 @@ ExpandBroadcastReshapeSDPAFusion::ExpandBroadcastReshapeSDPAFusion() {if (dim.is_static()) {shape_vec.push_back(dim.get_length());} else {- shape_vec.push_back(orig_special_zero ? 0 : -1);+ shape_vec.push_back(orig_special_zero ? 0 : -1);}}// Remove the broadcast axis@@ -323,22 +327,29 @@ ExpandBroadcastReshapeSDPAFusion::ExpandBroadcastReshapeSDPAFusion() {};std::shared_ptr<ov::Node> k_5d;- if (pattern_map.count(pre_reshape_b_m)) k_5d = pattern_map.at(pre_reshape_b_m).get_node_shared_ptr();- else if (pattern_map.count(unsqueeze_b_m)) k_5d = pattern_map.at(unsqueeze_b_m).get_node_shared_ptr();+ if (pattern_map.count(pre_reshape_b_m)) {+ k_5d = pattern_map.at(pre_reshape_b_m).get_node_shared_ptr();+ } else if (pattern_map.count(unsqueeze_b_m)) {+ k_5d = pattern_map.at(unsqueeze_b_m).get_node_shared_ptr();+ }std::shared_ptr<ov::Node> v_5d;- if (pattern_map.count(pre_reshape_c_m)) v_5d = pattern_map.at(pre_reshape_c_m).get_node_shared_ptr();- else if (pattern_map.count(unsqueeze_c_m)) v_5d = pattern_map.at(unsqueeze_c_m).get_node_shared_ptr();+ if (pattern_map.count(pre_reshape_c_m)) {+ v_5d = pattern_map.at(pre_reshape_c_m).get_node_shared_ptr();+ } else if (pattern_map.count(unsqueeze_c_m)) {+ v_5d = pattern_map.at(unsqueeze_c_m).get_node_shared_ptr();+ }auto k_bc = pattern_map.at(broadcast_b_m).get_node_shared_ptr();auto v_bc = pattern_map.at(broadcast_c_m).get_node_shared_ptr();OutputVector data_inputs;- data_inputs.push_back(pattern_map.at(input_a_m).get_node_shared_ptr()); // Q input+ data_inputs.push_back(pattern_map.at(input_a_m).get_node_shared_ptr()); // Q inputif (pattern_map.count(unsqueeze_b_m) || pattern_map.count(pre_reshape_b_m)) {ov::Output<ov::Node> key_input = k_5d->input_value(0);auto opt_key_input = ensure_4d(key_input, k_5d, k_bc);- if (!opt_key_input) return false;+ if (!opt_key_input)+ return false;data_inputs.push_back(opt_key_input.value());} else {return false;@@ -347,17 +358,18 @@ ExpandBroadcastReshapeSDPAFusion::ExpandBroadcastReshapeSDPAFusion() {if (pattern_map.count(unsqueeze_c_m) || pattern_map.count(pre_reshape_c_m)) {ov::Output<ov::Node> value_input = v_5d->input_value(0);auto opt_value_input = ensure_4d(value_input, v_5d, v_bc);- if (!opt_value_input) return false;+ if (!opt_value_input)+ return false;data_inputs.push_back(opt_value_input.value());} else {return false;}if (pattern_map.find(sdpa_with_attn_mask_m) != pattern_map.end()) {- data_inputs.push_back(sdpa->get_input_source_output(3)); // attn_mask+ data_inputs.push_back(sdpa->get_input_source_output(3)); // attn_mask} else if (pattern_map.find(sdpa_with_attn_mask_and_scale_m) != pattern_map.end()) {- data_inputs.push_back(sdpa->get_input_source_output(3)); // attn_mask- data_inputs.push_back(sdpa->get_input_source_output(4)); // scale+ data_inputs.push_back(sdpa->get_input_source_output(3)); // attn_mask+ data_inputs.push_back(sdpa->get_input_source_output(4)); // scale}auto order_a = sdpa->get_input0_transpose_order();diff --git a/src/plugins/intel_gpu/src/plugin/transformations/fc_convert_fusion.cpp b/src/plugins/intel_gpu/src/plugin/transformations/fc_convert_fusion.cppindex ccb652e3b88..e1fc9a3adf7 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/fc_convert_fusion.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/fc_convert_fusion.cpp@@ -55,14 +55,14 @@ FullyConnectedConvertFusion::FullyConnectedConvertFusion() {OPENVINO_ASSERT(m_fc_typed);- if (m_fc->input_values().size() == 4)+ if (m_fc->input_values().size() == 4) {new_fc = std::make_shared<op::FullyConnectedCompressed>(m_fc->input_value(0),m_weights,m_bias,m_fc->input_value(3),output_type,m_fc_typed->get_transpose_b());- else+ } else {new_fc = std::make_shared<op::FullyConnectedCompressed>(m_fc->input_value(0),m_weights,m_bias,@@ -70,6 +70,7 @@ FullyConnectedConvertFusion::FullyConnectedConvertFusion() {m_fc->input_value(4),output_type,m_fc_typed->get_transpose_b());+ }}new_fc->set_friendly_name(m_convert->get_friendly_name());copy_runtime_info(m.get_matched_nodes(), new_fc);diff --git a/src/plugins/intel_gpu/src/plugin/transformations/fc_horizontal_fusion.cpp b/src/plugins/intel_gpu/src/plugin/transformations/fc_horizontal_fusion.cppindex bf69824bf9d..4fb95ad592a 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/fc_horizontal_fusion.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/fc_horizontal_fusion.cpp@@ -6,25 +6,19 @@#include "intel_gpu/op/fully_connected.hpp"#include "intel_gpu/op/fully_connected_compressed.hpp"--#include "openvino/core/rt_info.hpp"-#include "openvino/opsets/opset1_decl.hpp"-#include "openvino/pass/pattern/op/or.hpp"-#include "openvino/pass/pattern/op/wrap_type.hpp"-#include "transformations/utils/utils.hpp"#include "intel_gpu/op/placeholder.hpp"#include "intel_gpu/runtime/debug_configuration.hpp"#include "openvino/core/graph_util.hpp"+#include "openvino/core/rt_info.hpp"#include "openvino/op/add.hpp"#include "openvino/op/concat.hpp"#include "openvino/op/multiply.hpp"#include "openvino/op/transpose.hpp"#include "openvino/op/variadic_split.hpp"-#include "openvino/op/add.hpp"-#include "openvino/op/concat.hpp"-#include "openvino/op/multiply.hpp"-#include "openvino/op/transpose.hpp"-#include "openvino/op/variadic_split.hpp"+#include "openvino/opsets/opset1_decl.hpp"+#include "openvino/pass/pattern/op/or.hpp"+#include "openvino/pass/pattern/op/wrap_type.hpp"+#include "transformations/utils/utils.hpp"namespace ov::intel_gpu {@@ -37,8 +31,9 @@ FullyConnectedHorizontalFusion::FullyConnectedHorizontalFusion(bool fuse_mlp_swi// For cldnn, two fcs in mlp will be fused at horizontal fc fusion, and then swiglu will be fused at prepare_primitive_fusion// i.e., eltwise((fc + swish), fc) => fused_fc + swiglu => fused_fc_swilgu// Onednn gemms are to be handled in a different way (TBD)- if (fuse_mlp_swiglu)+ if (fuse_mlp_swiglu) {min_num_fcs_to_fuse = 2;+ }auto is_target_pattern = [min_num_fcs_to_fuse](const Output<Node>& output) {const int max_num_fcs_to_fuse = 3;// Currently this pass targets only compressed FCs (QKV) on dynamic generative models@@ -47,10 +42,12 @@ FullyConnectedHorizontalFusion::FullyConnectedHorizontalFusion(bool fuse_mlp_swi// if it is not constant, the only allowed cases are Constant => convert// All FCs have same # of valid inputs (e.g., if one of the fc has zp, all fcs have zp)auto is_constant = [](const std::shared_ptr<ov::Node> node) {- if (ov::as_type_ptr<ov::op::v0::Constant>(node))+ if (ov::as_type_ptr<ov::op::v0::Constant>(node)) {return true;- if (ov::as_type_ptr<ov::op::v0::Convert>(node) && ov::as_type_ptr<ov::op::v0::Constant>(node->get_input_node_shared_ptr(0)))+ }+ if (ov::as_type_ptr<ov::op::v0::Convert>(node) && ov::as_type_ptr<ov::op::v0::Constant>(node->get_input_node_shared_ptr(0))) {return true;+ }return ov::as_type_ptr<ov::op::v1::Transpose>(node) && ov::as_type_ptr<ov::op::v0::Constant>(node->get_input_node_shared_ptr(0));};auto is_placeholder = [](const std::shared_ptr<ov::Node> node) {@@ -59,31 +56,36 @@ FullyConnectedHorizontalFusion::FullyConnectedHorizontalFusion(bool fuse_mlp_swiconst auto& fc = ov::as_type_ptr<op::FullyConnectedCompressed>(output.get_node_shared_ptr());const auto& input = fc->get_input_node_shared_ptr(0);- if (!fc->get_input_partial_shape(0).is_dynamic())+ if (!fc->get_input_partial_shape(0).is_dynamic()) {return false;+ }size_t user_fc_count = 0;int32_t nodes_with_bias = 0;int32_t nodes_with_zp = 0;for (const auto& u : input->get_users()) {const auto& fc_user = ov::as_type_ptr<op::FullyConnectedCompressed>(u);- if (!fc_user)+ if (!fc_user) {continue;+ }// Skip horizontal fusion when the weight is not a constant. The fused-weight Concat// created during fusion relies on constant-folding at compile time; with a non-constant// weight (e.g. weights provided as runtime inputs) it cannot fold, survives to program// build, and may hit formats/types without a Concat implementation. Even when a Concat// impl exists, concatenating weights on every inference is pure overhead with no benefit.- if (!is_constant(fc_user->get_input_node_shared_ptr(1)))+ if (!is_constant(fc_user->get_input_node_shared_ptr(1))) {return false;+ }auto num_inputs = fc_user->inputs().size();- if (num_inputs >= 5)+ if (num_inputs >= 5) {nodes_with_zp++;+ }for (size_t i = 2; i < num_inputs; ++i) {const auto& fc_input = fc_user->get_input_node_shared_ptr(i);- if (!is_constant(fc_input) && !is_placeholder(fc_input))+ if (!is_constant(fc_input) && !is_placeholder(fc_input)) {return false;+ }if (i == 2 && !is_placeholder(fc_input)) {nodes_with_bias++;}@@ -116,22 +118,26 @@ FullyConnectedHorizontalFusion::FullyConnectedHorizontalFusion(bool fuse_mlp_swifc_nodes_vec.push_back(fc_user);weight_nodes.push_back(fc_user->get_input_node_shared_ptr(1));if (!ov::as_type_ptr<op::Placeholder>(fc_user->get_input_node_shared_ptr(2))) {- if (bias_rank == -1)+ if (bias_rank == -1) {bias_rank = static_cast<int32_t>(fc_user->get_input_partial_shape(2).size());- if (bias_rank != static_cast<int32_t>(fc_user->get_input_partial_shape(2).size()))+ }+ if (bias_rank != static_cast<int32_t>(fc_user->get_input_partial_shape(2).size())) {return false;+ }bias_nodes.push_back(fc_user->get_input_node_shared_ptr(2));}scale_nodes.push_back(fc_user->get_input_node_shared_ptr(3));- if (fc_user->inputs().size() > 4)+ if (fc_user->inputs().size() > 4) {zp_nodes.push_back(fc_user->get_input_node_shared_ptr(4));+ }}}// Weight layout depends on transpose_b: [N, K] when transpose_b=true (default),// [K, N] when transpose_b=false.const size_t weight_idx = 1;- if (fc_nodes[0]->get_input_shape(weight_idx).size() != 2)+ if (fc_nodes[0]->get_input_shape(weight_idx).size() != 2) {return false;+ }const bool transpose_b = fc_nodes[0]->get_transpose_b();// n_axis is the output (N) dimension, k_axis the contraction (K) dimension.const size_t n_axis = transpose_b ? 0 : 1;@@ -141,12 +147,15 @@ FullyConnectedHorizontalFusion::FullyConnectedHorizontalFusion(bool fuse_mlp_swistd::vector<int64_t> orig_n_sizes;// merge weights, scale, zpfor (auto fc : fc_nodes) {- if (k_size != fc->get_input_shape(weight_idx)[k_axis])+ if (k_size != fc->get_input_shape(weight_idx)[k_axis]) {return false;- if (weight_dtype != fc->get_input_element_type(weight_idx))+ }+ if (weight_dtype != fc->get_input_element_type(weight_idx)) {return false;- if (transpose_b != fc->get_transpose_b())+ }+ if (transpose_b != fc->get_transpose_b()) {return false;+ }orig_n_sizes.push_back(fc->get_input_shape(weight_idx)[n_axis]);}ov::OutputVector weight_nodes_as_output_vector;@@ -174,21 +183,20 @@ FullyConnectedHorizontalFusion::FullyConnectedHorizontalFusion(bool fuse_mlp_swisize_t n_bias_users = 0;if (bias_nodes.empty()) {for (auto fc : fc_nodes) {- if (fc->get_users().size() == 1 &&- fc->get_users()[0]->get_type_info() == ov::opset1::Add::get_type_info_static() &&+ if (fc->get_users().size() == 1 && fc->get_users()[0]->get_type_info() == ov::opset1::Add::get_type_info_static() &&ov::is_type<ov::op::v0::Constant>(fc->get_users()[0]->inputs()[1].get_source_output().get_node())) {auto bias_input1_shape = fc->get_users()[0]->get_input_partial_shape(1).get_shape();- if (bias_rank == -1)+ if (bias_rank == -1) {bias_rank = static_cast<int32_t>(bias_input1_shape.size());- if (bias_rank != static_cast<int32_t>(bias_input1_shape.size()))+ }+ if (bias_rank != static_cast<int32_t>(bias_input1_shape.size())) {break;+ }size_t ndim_size = bias_input1_shape.back();// allow only [1, 1, N] shape bias- if (std::accumulate(bias_input1_shape.begin(),- bias_input1_shape.end(),- static_cast<size_t>(1),- std::multiplies<size_t>()) != ndim_size)+ if (std::accumulate(bias_input1_shape.begin(), bias_input1_shape.end(), static_cast<size_t>(1), std::multiplies<size_t>()) != ndim_size) {break;+ }n_bias_users++;}}@@ -203,8 +211,8 @@ FullyConnectedHorizontalFusion::FullyConnectedHorizontalFusion(bool fuse_mlp_swifor (size_t i = 0; i < fc_nodes.size(); ++i) {auto orig_fc = fc_nodes[i];auto bias_node = orig_fc->get_users()[0];- GPU_DEBUG_TRACE_DETAIL << "Set Add op user " << bias_node->get_friendly_name() << " as the FC "- << orig_fc->get_friendly_name() << "'s bias input" << std::endl;+ GPU_DEBUG_TRACE_DETAIL << "Set Add op user " << bias_node->get_friendly_name() << " as the FC " << orig_fc->get_friendly_name()+ << "'s bias input" << std::endl;auto bias_const = orig_fc->get_users()[0]->input_value(1);auto orig_users_of_bias_user = bias_node->get_users();ov::OutputVector fc_inputs = orig_fc->input_values();@@ -257,21 +265,22 @@ FullyConnectedHorizontalFusion::FullyConnectedHorizontalFusion(bool fuse_mlp_swiif (is_scalar) {for (size_t i = 1; i < zp_nodes.size(); ++i) {bool current_is_scalar = (ov::shape_size(zp_nodes[i]->get_output_shape(0)) == 1);- if (!current_is_scalar)+ if (!current_is_scalar) {return false;+ }// validate all zp values are sameint32_t cur_zp_val = 0;if (auto zp_const = ov::as_type_ptr<ov::op::v0::Constant>(zp_nodes[i])) {cur_zp_val = zp_const->cast_vector<int32_t>()[0];} else if (auto zp_convert = ov::as_type_ptr<ov::op::v0::Convert>(zp_nodes[i])) {- auto zp_const =- ov::as_type_ptr<ov::op::v0::Constant>(zp_convert->get_input_node_shared_ptr(0));+ auto zp_const = ov::as_type_ptr<ov::op::v0::Constant>(zp_convert->get_input_node_shared_ptr(0));cur_zp_val = zp_const->cast_vector<int32_t>()[0];} else {OPENVINO_THROW("Unsupported zp input node for FC horizontal fusion");}- if (cur_zp_val != scalar_zp_val)+ if (cur_zp_val != scalar_zp_val) {return false;+ }}} else {ov::OutputVector zp_nodes_as_output_vector;@@ -284,7 +293,7 @@ FullyConnectedHorizontalFusion::FullyConnectedHorizontalFusion(bool fuse_mlp_swi}// Create new fc with merged weights, bias, scale, zpstd::shared_ptr<ov::Node> new_fc;- if (fused_zps)+ if (fused_zps) {new_fc = std::make_shared<op::FullyConnectedCompressed>(input_node,fused_weight,fused_bias,@@ -292,13 +301,10 @@ FullyConnectedHorizontalFusion::FullyConnectedHorizontalFusion(bool fuse_mlp_swifused_zps,fc_nodes[0]->get_output_type(),transpose_b);- else- new_fc = std::make_shared<op::FullyConnectedCompressed>(input_node,- fused_weight,- fused_bias,- fused_scale,- fc_nodes[0]->get_output_type(),- transpose_b);+ } else {+ new_fc =+ std::make_shared<op::FullyConnectedCompressed>(input_node, fused_weight, fused_bias, fused_scale, fc_nodes[0]->get_output_type(), transpose_b);+ }auto new_fc_name = fc_nodes[0]->get_friendly_name() + "_fused_" + std::to_string(fc_nodes.size()) + "FCs";new_fc->set_friendly_name(new_fc_name);@@ -333,11 +339,13 @@ FullyConnectedHorizontalFusion::FullyConnectedHorizontalFusion(bool fuse_mlp_swi// Mul Mul Mul VariadicSplit// | | | | | |const auto is_scalar_const = [](const ov::Output<ov::Node>& output) -> bool {- if (!ov::is_type<ov::op::v0::Constant>(output.get_node()))+ if (!ov::is_type<ov::op::v0::Constant>(output.get_node())) {return false;+ }const auto shape = output.get_partial_shape();- if (shape.is_dynamic())+ if (shape.is_dynamic()) {return false;+ }return ov::shape_size(shape.to_shape()) == 1;};@@ -358,8 +366,7 @@ FullyConnectedHorizontalFusion::FullyConnectedHorizontalFusion(bool fuse_mlp_swifor (auto& input : target_node->inputs()) {if (input.get_source_output() != output) {if (is_scalar_const(input.get_source_output())) {- const_node = ov::as_type_ptr<ov::op::v0::Constant>(- input.get_source_output().get_node_shared_ptr());+ const_node = ov::as_type_ptr<ov::op::v0::Constant>(input.get_source_output().get_node_shared_ptr());const_values.emplace_back(const_node->cast_vector<float>()[0]);} else {can_be_merged = false;@@ -369,8 +376,7 @@ FullyConnectedHorizontalFusion::FullyConnectedHorizontalFusion(bool fuse_mlp_swi}}- if (const_values.size() != split_size ||- !std::equal(const_values.begin() + 1, const_values.end(), const_values.begin())) {+ if (const_values.size() != split_size || !std::equal(const_values.begin() + 1, const_values.end(), const_values.begin())) {can_be_merged = false;}diff --git a/src/plugins/intel_gpu/src/plugin/transformations/fc_per_layer_scaling.cpp b/src/plugins/intel_gpu/src/plugin/transformations/fc_per_layer_scaling.cppindex a5a0279afa8..43e524c0468 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/fc_per_layer_scaling.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/fc_per_layer_scaling.cpp@@ -27,11 +27,13 @@ FullyConnectedPerLayerScaling::FullyConnectedPerLayerScaling(float scale_factor)auto fc_compressed_m = std::make_shared<ov::pass::pattern::op::Or>(OutputVector{fc_compressed_wo_zp_m, fc_compressed_w_zp_m});ov::matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](Matcher& m) {- if (scale_factor == 0.f || scale_factor == 1.f)+ if (scale_factor == 0.f || scale_factor == 1.f) {return false;+ }auto fc = ov::as_type_ptr<op::FullyConnectedCompressed>(m.get_match_root());- if (!fc || transformation_callback(fc))+ if (!fc || transformation_callback(fc)) {return false;+ }const auto& pattern_map = m.get_pattern_value_map();const auto& data = pattern_map.at(data_m).get_node_shared_ptr();diff --git a/src/plugins/intel_gpu/src/plugin/transformations/fuse_atan2_decomposed.cpp b/src/plugins/intel_gpu/src/plugin/transformations/fuse_atan2_decomposed.cppindex 728f4855d86..1e013b88704 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/fuse_atan2_decomposed.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/fuse_atan2_decomposed.cpp@@ -51,21 +51,24 @@ FuseAtan2Decomposed::FuseAtan2Decomposed() {auto sel1 = pattern_map.at(sel1_m).get_node_shared_ptr();auto atan = pattern_map.at(atan_m).get_node_shared_ptr();- if (transformation_callback(sel3))+ if (transformation_callback(sel3)) {return false;+ }// Both branches of Sel1 must consume the Atan (the only structural// fingerprint robust to constant folding of the special-case chain).auto branch_uses_atan = [&](const std::shared_ptr<ov::Node>& branch) {for (size_t i = 0; i < branch->get_input_size(); ++i) {- if (branch->get_input_node_shared_ptr(i) == atan)+ if (branch->get_input_node_shared_ptr(i) == atan) {return true;+ }}return false;};if (!branch_uses_atan(sel1->get_input_node_shared_ptr(1)) ||- !branch_uses_atan(sel1->get_input_node_shared_ptr(2)))+ !branch_uses_atan(sel1->get_input_node_shared_ptr(2))) {return false;+ }// Pattern guarantees atan->input(0) is either Divide or Multiply(_, Power(_, -1)).ov::Output<ov::Node> lhs, rhs;@@ -82,8 +85,9 @@ FuseAtan2Decomposed::FuseAtan2Decomposed() {}const auto& y_et = lhs.get_element_type();- if (!y_et.is_real() || rhs.get_element_type() != y_et)+ if (!y_et.is_real() || rhs.get_element_type() != y_et) {return false;+ }auto atan2 = std::make_shared<ov::intel_gpu::op::Atan2>(lhs, rhs);atan2->set_friendly_name(sel3->get_friendly_name());diff --git a/src/plugins/intel_gpu/src/plugin/transformations/fuse_gated_mlp.cpp b/src/plugins/intel_gpu/src/plugin/transformations/fuse_gated_mlp.cppindex 78395d625d8..075360e7ccd 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/fuse_gated_mlp.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/fuse_gated_mlp.cpp@@ -48,26 +48,32 @@ FuseGatedMLP::FuseGatedMLP() {auto sw = ov::as_type_ptr<ov::op::v4::Swish>(pm.at(swish).get_node_shared_ptr());ov::NodeVector new_ops;- if (!down || !up || !gate || !sw || transformation_callback(down))+ if (!down || !up || !gate || !sw || transformation_callback(down)) {return false;+ }- if (down->get_transpose_a() || up->get_transpose_a() || gate->get_transpose_a())+ if (down->get_transpose_a() || up->get_transpose_a() || gate->get_transpose_a()) {return false;+ }- if (up->input_value(0) != gate->input_value(0))+ if (up->input_value(0) != gate->input_value(0)) {return false;+ }// Swish can be represented as 1-input(default beta=1.0) or 2-input(beta tensor).- if (sw->get_input_size() != 1 && sw->get_input_size() != 2)+ if (sw->get_input_size() != 1 && sw->get_input_size() != 2) {return false;+ }if (sw->get_input_size() == 2) {auto beta_const = ov::as_type_ptr<ov::op::v0::Constant>(sw->get_input_node_shared_ptr(1));- if (!beta_const)+ if (!beta_const) {return false;+ }auto beta = beta_const->cast_vector<float>();- if (beta.empty() || std::fabs(beta[0] - 1.0f) > 1e-6f)+ if (beta.empty() || std::fabs(beta[0] - 1.0f) > 1e-6f) {return false;+ }}auto create_transpose = [&](const ov::Output<ov::Node>& node, const std::string& transpose_name) -> ov::Output<ov::Node> {diff --git a/src/plugins/intel_gpu/src/plugin/transformations/increase_position_ids_precision.cpp b/src/plugins/intel_gpu/src/plugin/transformations/increase_position_ids_precision.cppindex 77c7f68afa4..0bab7542cef 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/increase_position_ids_precision.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/increase_position_ids_precision.cpp@@ -7,40 +7,38 @@#include <set>#include "intel_gpu/op/gemm.hpp"-#include "ov_ops/rotary_positional_embeddings.hpp"-+#include "openvino/core/graph_util.hpp"#include "openvino/core/rt_info.hpp"-#include "openvino/op/constant.hpp"-#include "openvino/op/matmul.hpp"-#include "openvino/op/parameter.hpp"+#include "openvino/op/add.hpp"+#include "openvino/op/broadcast.hpp"#include "openvino/op/concat.hpp"+#include "openvino/op/constant.hpp"#include "openvino/op/cos.hpp"-#include "openvino/op/sin.hpp"-#include "openvino/op/multiply.hpp"-#include "openvino/op/swish.hpp"+#include "openvino/op/gather.hpp"+#include "openvino/op/gather_nd.hpp"#include "openvino/op/gelu.hpp"+#include "openvino/op/matmul.hpp"+#include "openvino/op/multiply.hpp"+#include "openvino/op/parameter.hpp"#include "openvino/op/reshape.hpp"+#include "openvino/op/scaled_dot_product_attention.hpp"+#include "openvino/op/shape_of.hpp"+#include "openvino/op/sin.hpp"#include "openvino/op/squeeze.hpp"+#include "openvino/op/strided_slice.hpp"#include "openvino/op/subtract.hpp"+#include "openvino/op/swish.hpp"#include "openvino/op/transpose.hpp"#include "openvino/op/unsqueeze.hpp"-#include "openvino/op/add.hpp"-#include "openvino/op/gather.hpp"-#include "openvino/op/gather_nd.hpp"-#include "openvino/op/strided_slice.hpp"-#include "openvino/op/shape_of.hpp"-#include "openvino/op/broadcast.hpp"-#include "openvino/op/scaled_dot_product_attention.hpp"#include "openvino/op/variadic_split.hpp"-#include "ov_ops/rms.hpp"-#include "ov_ops/rotary_positional_embeddings.hpp"#include "openvino/pass/pattern/op/optional.hpp"#include "openvino/pass/pattern/op/or.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"-#include "transformations/utils/utils.hpp"-#include "openvino/core/graph_util.hpp"-#include "transformations/symbolic_transformations/symbolic_optimizations.hpp"+#include "ov_ops/rms.hpp"+#include "ov_ops/rotary_positional_embeddings.hpp"#include "transformations/rt_info/disable_precision_conversion.hpp"+#include "transformations/symbolic_transformations/symbolic_optimizations.hpp"+#include "transformations/utils/utils.hpp"#include "utils.hpp"namespace ov::intel_gpu {@@ -92,18 +90,20 @@ IncreasePositionIdsPrecisionForRoPE::IncreasePositionIdsPrecisionForRoPE() {auto sin_node = ov::as_type_ptr<ov::op::v0::Sin>(pattern_map.at(sin).get_node_shared_ptr());auto rope_node = pattern_map.at(rope).get_node_shared_ptr();- if (!matmul_node || transformation_callback(matmul_node))+ if (!matmul_node || transformation_callback(matmul_node)) {return false;+ }const auto desired_et = ov::element::f32;const auto original_et = matmul_node->get_output_element_type(0);- if (original_et == desired_et)+ if (original_et == desired_et) {return false;+ }// Step 1: Ensure MatMul inputs are f32size_t input_idx = 0;bool is_changed = insert_converts_before_if_needed(matmul_node, desired_et, input_idx);-+// Step 2: Insert restore converts only if RoPE expects non-f32 precision.if (is_changed) {size_t output_idx = 0;@@ -160,18 +160,21 @@ IncreasePositionIdsPrecisionForQwen25VL::IncreasePositionIdsPrecisionForQwen25VLauto sin_node = ov::as_type_ptr<ov::op::v0::Sin>(pattern_map.at(sin).get_node_shared_ptr());auto cos_node = ov::as_type_ptr<ov::op::v0::Cos>(pattern_map.at(cos).get_node_shared_ptr());- if (!convert_node || !matmul_node || transformation_callback(convert_node))+ if (!convert_node || !matmul_node || transformation_callback(convert_node)) {return false;+ }const auto desired_et = ov::element::f32;const auto original_et = convert_node->get_output_element_type(0);- if (original_et == desired_et)+ if (original_et == desired_et) {return false;+ }// Check if input is integer type (position_ids should be i32 or i64)auto input_et = convert_node->input_value(0).get_element_type();- if (!input_et.is_integral())+ if (!input_et.is_integral()) {return false;+ }// 1. Change Convert output from f16 to f32 (position_ids path)auto new_convert = std::make_shared<ov::op::v0::Convert>(convert_node->input_value(0), desired_et);@@ -236,18 +239,21 @@ IncreasePositionIdsPrecisionForQwen3VL::IncreasePositionIdsPrecisionForQwen3VL()auto broadcast_node = pattern_map.at(broadcast_freq).get_node_shared_ptr();auto matmul_node = ov::as_type_ptr<ov::op::v0::MatMul>(pattern_map.at(matmul).get_node_shared_ptr());- if (!convert_node || !matmul_node || transformation_callback(convert_node))+ if (!convert_node || !matmul_node || transformation_callback(convert_node)) {return false;+ }const auto desired_et = ov::element::f32;const auto original_et = convert_node->get_output_element_type(0);- if (original_et == desired_et)+ if (original_et == desired_et) {return false;+ }// Verify input is integer type (position_ids should be i32 or i64)auto input_et = convert_node->input_value(0).get_element_type();- if (!input_et.is_integral())+ if (!input_et.is_integral()) {return false;+ }// Walk forward from MatMul to find Sin and Cos nodes through the// Reshape -> Gather -> ScatterNDUpdate -> Reshape -> Concat chain.@@ -266,12 +272,14 @@ IncreasePositionIdsPrecisionForQwen3VL::IncreasePositionIdsPrecisionForQwen3VL()stack.pop_back();for (auto& output : current->outputs()) {- if (!output.get_element_type().is_real())+ if (!output.get_element_type().is_real()) {continue;+ }for (const auto& target_input : output.get_target_inputs()) {auto consumer = target_input.get_node()->shared_from_this();- if (!visited.insert(consumer.get()).second)+ if (!visited.insert(consumer.get()).second) {continue;+ }nodes_visited++;if (auto sin_ptr = ov::as_type_ptr<ov::op::v0::Sin>(consumer)) {@@ -285,8 +293,9 @@ IncreasePositionIdsPrecisionForQwen3VL::IncreasePositionIdsPrecisionForQwen3VL()}}- if (!sin_node || !cos_node)+ if (!sin_node || !cos_node) {return false;+ }// 1. Change Convert output from f16 to f32 (position_ids path)auto new_convert = std::make_shared<ov::op::v0::Convert>(convert_node->input_value(0), desired_et);@@ -373,11 +382,10 @@ IncreasePositionIdsPrecisionForLtxVideo::IncreasePositionIdsPrecisionForLtxVideoauto cos_concat = std::make_shared<Or>(OutputVector{cos_concat_m1, cos_concat_m2});// RoPE: input 0 = x, input 1 = cos_concat, input 2 = sin_concat- auto rope = wrap_type<ov::op::internal::RoPE>({any_input(), cos_concat, sin_concat},- [](const ov::Output<ov::Node>& output) {- auto node = ov::as_type_ptr<ov::op::internal::RoPE>(output.get_node_shared_ptr());- return node && node->get_config().is_ltx_video;- });+ auto rope = wrap_type<ov::op::internal::RoPE>({any_input(), cos_concat, sin_concat}, [](const ov::Output<ov::Node>& output) {+ auto node = ov::as_type_ptr<ov::op::internal::RoPE>(output.get_node_shared_ptr());+ return node && node->get_config().is_ltx_video;+ });ov::matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](ov::pass::pattern::Matcher& m) {const auto& pattern_map = m.get_pattern_value_map();@@ -389,8 +397,9 @@ IncreasePositionIdsPrecisionForLtxVideo::IncreasePositionIdsPrecisionForLtxVideoconst auto desired_et = ov::element::f32;const auto original_et = mul_node->get_output_element_type(0);- if (original_et == desired_et)+ if (original_et == desired_et) {return false;+ }size_t input_idx = 0;bool is_changed = insert_converts_before_if_needed(mul_node, desired_et, input_idx);@@ -458,21 +467,24 @@ IncreasePositionIdsPrecisionForGPTOSS::IncreasePositionIdsPrecisionForGPTOSS() {ov::matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](ov::pass::pattern::Matcher& m) {const auto& pattern_map = m.get_pattern_value_map();- if (transformation_callback(rope_qk))+ if (transformation_callback(rope_qk)) {return false;+ }auto rope_node = ov::as_type_ptr<ov::op::internal::RoPE>(pattern_map.at(rope_qk).get_node_shared_ptr());auto matmul_node = ov::as_type_ptr<ov::op::v0::MatMul>(pattern_map.at(matmul_freq_pos_id).get_node_shared_ptr());auto mul_node1 = ov::as_type_ptr<ov::op::v1::Multiply>(pattern_map.at(mul_sin_scale).get_node_shared_ptr());auto mul_node2 = ov::as_type_ptr<ov::op::v1::Multiply>(pattern_map.at(mul_cos_scale).get_node_shared_ptr());- if (!rope_node || !matmul_node || !mul_node1 || !mul_node2)+ if (!rope_node || !matmul_node || !mul_node1 || !mul_node2) {return false;+ }const auto desired_et = ov::element::f32;const auto original_et = rope_node->get_output_element_type(0);- if (original_et == desired_et)+ if (original_et == desired_et) {return false;+ }size_t idx = 0;insert_converts_before_if_needed(matmul_node, desired_et, idx);@@ -498,21 +510,20 @@ IncreasePositionIdsPrecisionForDirectMatMulSinCos::IncreasePositionIdsPrecisionFauto sin_node = ov::as_type_ptr<ov::op::v0::Sin>(pattern_map.at(sin).get_node_shared_ptr());std::vector<std::shared_ptr<ov::op::v0::Cos>> cos_nodes;- if (!matmul_node || !sin_node || transformation_callback(matmul_node))+ if (!matmul_node || !sin_node || transformation_callback(matmul_node)) {return false;+ }auto reaches_position_ids = [](ov::Output<ov::Node> output) {std::set<ov::Node*> visited;while (visited.insert(output.get_node()).second) {const auto node = output.get_node_shared_ptr();if (const auto parameter = ov::as_type_ptr<ov::op::v0::Parameter>(node)) {- return parameter->get_friendly_name() == "position_ids" ||- parameter->output(0).get_names().count("position_ids") != 0;+ return parameter->get_friendly_name() == "position_ids" || parameter->output(0).get_names().count("position_ids") != 0;}- if (ov::is_type<ov::op::v0::Convert>(node) || ov::is_type<ov::op::v1::Reshape>(node) ||- ov::is_type<ov::op::v0::Squeeze>(node) || ov::is_type<ov::op::v0::Unsqueeze>(node) ||- ov::is_type<ov::op::v8::Gather>(node)) {+ if (ov::is_type<ov::op::v0::Convert>(node) || ov::is_type<ov::op::v1::Reshape>(node) || ov::is_type<ov::op::v0::Squeeze>(node) ||+ ov::is_type<ov::op::v0::Unsqueeze>(node) || ov::is_type<ov::op::v8::Gather>(node)) {output = node->input_value(0);continue;}@@ -527,28 +538,28 @@ IncreasePositionIdsPrecisionForDirectMatMulSinCos::IncreasePositionIdsPrecisionFwhile (visited.insert(position_ids_path.get_node()).second) {const auto node = position_ids_path.get_node_shared_ptr();if (const auto convert = ov::as_type_ptr<ov::op::v0::Convert>(node)) {- if (convert->input_value(0).get_element_type().is_integral() &&- reaches_position_ids(convert->input_value(0))) {+ if (convert->input_value(0).get_element_type().is_integral() && reaches_position_ids(convert->input_value(0))) {position_ids_convert_node = convert;break;}}- if (ov::is_type<ov::op::v0::Convert>(node) || ov::is_type<ov::op::v1::Reshape>(node) ||- ov::is_type<ov::op::v0::Squeeze>(node) || ov::is_type<ov::op::v0::Unsqueeze>(node) ||- ov::is_type<ov::op::v8::Gather>(node)) {+ if (ov::is_type<ov::op::v0::Convert>(node) || ov::is_type<ov::op::v1::Reshape>(node) || ov::is_type<ov::op::v0::Squeeze>(node) ||+ ov::is_type<ov::op::v0::Unsqueeze>(node) || ov::is_type<ov::op::v8::Gather>(node)) {position_ids_path = node->input_value(0);continue;}break;}- if (position_ids_convert_node)+ if (position_ids_convert_node) {break;+ }}- if (!position_ids_convert_node)+ if (!position_ids_convert_node) {return false;+ }for (const auto& user : matmul_node->get_users()) {if (auto cos_node = ov::as_type_ptr<ov::op::v0::Cos>(user)) {@@ -560,32 +571,36 @@ IncreasePositionIdsPrecisionForDirectMatMulSinCos::IncreasePositionIdsPrecisionFconst auto desired_et = ov::element::f32;const auto original_et = matmul_node->get_output_element_type(0);- if (cos_nodes.empty() || original_et == desired_et)+ if (cos_nodes.empty() || original_et == desired_et) {return false;+ }size_t input_idx = 0;- if (!insert_converts_before_if_needed(matmul_node, desired_et, input_idx))+ if (!insert_converts_before_if_needed(matmul_node, desired_et, input_idx)) {return false;+ }auto promote_output = [&](const std::shared_ptr<ov::Node>& node) {- if (auto type_relaxed = std::dynamic_pointer_cast<ov::op::TypeRelaxedBase>(node))+ if (auto type_relaxed = std::dynamic_pointer_cast<ov::op::TypeRelaxedBase>(node)) {type_relaxed->set_overridden_output_type(desired_et);+ }node->validate_and_infer_types();};promote_output(matmul_node);promote_output(sin_node);- for (const auto& cos_node : cos_nodes)+ for (const auto& cos_node : cos_nodes) {promote_output(cos_node);+ }size_t output_idx = 0;- for (const auto& cos_node : cos_nodes)+ for (const auto& cos_node : cos_nodes) {insert_converts_after_if_needed(cos_node, original_et, output_idx);+ }insert_converts_after_if_needed(sin_node, original_et, output_idx);return true;};- auto m =- std::make_shared<ov::pass::pattern::Matcher>(sin, "IncreasePositionIdsPrecisionForDirectMatMulSinCos");+ auto m = std::make_shared<ov::pass::pattern::Matcher>(sin, "IncreasePositionIdsPrecisionForDirectMatMulSinCos");this->register_matcher(m, callback);}@@ -623,8 +638,9 @@ DisableFP16ComForGPTOSSROPEPattern::DisableFP16ComForGPTOSSROPEPattern() {const auto& pattern_map = m.get_pattern_value_map();auto sin_node = ov::as_type_ptr<ov::op::v0::Sin>(pattern_map.at(sin).get_node_shared_ptr());- if (!sin_node || transformation_callback(sin_node))+ if (!sin_node || transformation_callback(sin_node)) {return false;+ }auto freq_const_node = ov::as_type_ptr<ov::op::v0::Constant>(pattern_map.at(freq_const).get_node_shared_ptr());ov::disable_conversion(freq_const_node, element::f16);return true;diff --git a/src/plugins/intel_gpu/src/plugin/transformations/increase_rms_input_precision.cpp b/src/plugins/intel_gpu/src/plugin/transformations/increase_rms_input_precision.cppindex 165fba1aa08..5cb8f73ae73 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/increase_rms_input_precision.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/increase_rms_input_precision.cpp@@ -83,17 +83,21 @@ IncreasePrecisionForQwenVLMerger::IncreasePrecisionForQwenVLMerger() {size_t input_idx = 0;bool is_changed = insert_converts_before_if_needed(matmul, desired_et, input_idx);- if (!is_changed)+ if (!is_changed) {return false;+ }is_changed = insert_converts_before_if_needed(add_1, desired_et, input_idx);- if (!is_changed)+ if (!is_changed) {return false;+ }is_changed = insert_converts_before_if_needed(add_2, desired_et, input_idx, {1});- if (!is_changed)+ if (!is_changed) {return false;+ }is_changed = insert_converts_before_if_needed(rms, desired_et, input_idx, {0});- if (!is_changed)+ if (!is_changed) {return false;+ }size_t output_idx = 0;insert_converts_after_if_needed(rms, original_et, output_idx);diff --git a/src/plugins/intel_gpu/src/plugin/transformations/keep_gqa_kv_scale_precision.cpp b/src/plugins/intel_gpu/src/plugin/transformations/keep_gqa_kv_scale_precision.cppindex ba72534e3c4..b8b497cf9a2 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/keep_gqa_kv_scale_precision.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/keep_gqa_kv_scale_precision.cpp@@ -15,15 +15,18 @@ KeepGQAKVScalePrecision::KeepGQAKVScalePrecision() {ov::matcher_pass_callback callback = [=](ov::pass::pattern::Matcher& m) {auto gqa = ov::as_type_ptr<ov::op::internal::GroupQueryAttention>(m.get_match_root());- if (!gqa)+ if (!gqa) {return false;+ }- if (transformation_callback(gqa))+ if (transformation_callback(gqa)) {return false;+ }// Only a quantized KV cache has scales at inputs 12 (k_scale) / 13 (v_scale).- if (!gqa->is_kv_quantized())+ if (!gqa->is_kv_quantized()) {return false;+ }constexpr size_t k_scale_idx = 12;constexpr size_t v_scale_idx = 13;diff --git a/src/plugins/intel_gpu/src/plugin/transformations/keep_xattention_threshold_precision.cpp b/src/plugins/intel_gpu/src/plugin/transformations/keep_xattention_threshold_precision.cppindex 4516f04a8b7..2a7dcb2b041 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/keep_xattention_threshold_precision.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/keep_xattention_threshold_precision.cpp@@ -16,11 +16,13 @@ KeepXAttentionThresholdPrecision::KeepXAttentionThresholdPrecision() {ov::matcher_pass_callback callback = [=](ov::pass::pattern::Matcher& m) {auto pa = ov::as_type_ptr<ov::op::PagedAttentionExtension>(m.get_match_root());- if (!pa)+ if (!pa) {return false;+ }- if (transformation_callback(pa))+ if (transformation_callback(pa)) {return false;+ }constexpr size_t thr_idx = cldnn::paged_attention::PagedAttentionInputIdx::XATTENTION_THRESHOLD;ov::mark_as_precision_sensitive(pa->input(thr_idx));diff --git a/src/plugins/intel_gpu/src/plugin/transformations/kv_cache_compression.cpp b/src/plugins/intel_gpu/src/plugin/transformations/kv_cache_compression.cppindex ea0a733fb18..dcaa3f96877 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/kv_cache_compression.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/kv_cache_compression.cpp@@ -88,8 +88,9 @@ std::shared_ptr<ov::intel_gpu::op::ReadValues>OutputVector initializer_outputs = { initializer_dq->output(0), initializer_dq->output(1) };if (quantization_attrs.quantization_type == ov::op::internal::DynamicQuantize::QuantizationType::Asymmetric &&- quantization_attrs.output_storage_type == ov::op::internal::DynamicQuantize::OutputStorageType::Planar)+ quantization_attrs.output_storage_type == ov::op::internal::DynamicQuantize::OutputStorageType::Planar) {initializer_outputs.push_back(initializer_dq->output(2));+ }new_past_rv_node = std::make_shared<ov::intel_gpu::op::ReadValues>(initializer_outputs, past_rv_node->get_variable(), variable_infos);}@@ -113,8 +114,9 @@ std::shared_ptr<ov::intel_gpu::op::KVCacheCompressed>kv_cache_inputs.push_back(past_rv_node->output(1));if (quantization_attrs.quantization_type == ov::op::internal::DynamicQuantize::QuantizationType::Asymmetric &&- quantization_attrs.output_storage_type == ov::op::internal::DynamicQuantize::OutputStorageType::Planar)+ quantization_attrs.output_storage_type == ov::op::internal::DynamicQuantize::OutputStorageType::Planar) {kv_cache_inputs.push_back(past_rv_node->output(2));+ }auto new_kv_cache = std::make_shared<op::KVCacheCompressed>(kv_cache_inputs,kv_cache_node->get_variable(),@@ -139,8 +141,9 @@ public:KVCacheCompressionMatcher::KVCacheCompressionMatcher(ov::element::Type compression_dt, bool supports_immad) {using namespace ov::pass::pattern;- if (!cldnn::one_of(compression_dt, {element::i8, element::u8, element::i4, element::u4}))+ if (!cldnn::one_of(compression_dt, {element::i8, element::u8, element::i4, element::u4})) {return;+ }const auto quantization_type = ov::op::internal::DynamicQuantize::QuantizationType::Asymmetric;const auto output_storage_type = supports_immad ? ov::op::internal::DynamicQuantize::OutputStorageType::Planar@@ -249,8 +252,9 @@ KVCacheCompressionMatcher::KVCacheCompressionMatcher(ov::element::Type compressiOutputVector sdpa_inputs;// Add Query, Key, Value, attention_mask, scale inputs- for (size_t i = 0; i < sdpa_node->get_input_size() - 1; i++)+ for (size_t i = 0; i < sdpa_node->get_input_size() - 1; i++) {sdpa_inputs.push_back(sdpa_node->input_value(i));+ }// Replace Key and Value inputs with compressed onessdpa_inputs[1] = new_key_cache->output(0);diff --git a/src/plugins/intel_gpu/src/plugin/transformations/kv_cache_fusion.cpp b/src/plugins/intel_gpu/src/plugin/transformations/kv_cache_fusion.cppindex cf650ac7ea6..c1da90b2dd2 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/kv_cache_fusion.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/kv_cache_fusion.cpp@@ -69,13 +69,15 @@ KVCacheFusionMatcher::KVCacheFusionMatcher() {auto past_node = ov::as_type_ptr<ov::op::v6::ReadValue>(pattern_map.at(past).get_node_shared_ptr());auto present_node = ov::as_type_ptr<ov::op::v6::Assign>(pattern_map.at(present).get_node_shared_ptr());- if (past_node->get_variable_id() != present_node->get_variable_id())+ if (past_node->get_variable_id() != present_node->get_variable_id()) {return false;+ }// TODO: Support conversion internallyif (ov::is_type<ov::opset8::Gather>(concat_past_input)) {- if (!concat_node || concat_node->get_output_element_type(0) != past_node->get_output_element_type(0))+ if (!concat_node || concat_node->get_output_element_type(0) != past_node->get_output_element_type(0)) {return false;+ }}auto variable = past_node->get_variable();@@ -122,8 +124,9 @@ KVCacheFusionMatcher::KVCacheFusionMatcher() {// StridedSlice uses multi-dim for end tensor, extract only the slice dimif (has_strided_slice) {const auto strided_slice = ov::as_type_ptr<ov::op::v1::StridedSlice>(concat_node->input_value(0).get_node_shared_ptr());- if (!strided_slice)+ if (!strided_slice) {return false;+ }const auto begin_mask = strided_slice->get_begin_mask();const auto end_mask = strided_slice->get_end_mask();// begin/end mask should be the same and only last element is 0 (being sliced)diff --git a/src/plugins/intel_gpu/src/plugin/transformations/op/fully_connected_compressed.cpp b/src/plugins/intel_gpu/src/plugin/transformations/op/fully_connected_compressed.cppindex 733255b82e1..fa3215989cd 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/op/fully_connected_compressed.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/op/fully_connected_compressed.cpp@@ -52,14 +52,10 @@ FullyConnectedCompressed::FullyConnectedCompressed(const ov::Output<Node>& A,std::shared_ptr<ov::Node> FullyConnectedCompressed::clone_with_new_inputs(const ov::OutputVector& new_args) const {check_new_args_count(this, new_args);- if (new_args.size() == 4)- return std::make_shared<FullyConnectedCompressed>(new_args.at(0),- new_args.at(1),- new_args.at(2),- new_args.at(3),- m_output_type,- m_transpose_b);- if (new_args.size() == 5)+ if (new_args.size() == 4) {+ return std::make_shared<FullyConnectedCompressed>(new_args.at(0), new_args.at(1), new_args.at(2), new_args.at(3), m_output_type, m_transpose_b);+ }+ if (new_args.size() == 5) {return std::make_shared<FullyConnectedCompressed>(new_args.at(0),new_args.at(1),new_args.at(2),@@ -67,7 +63,8 @@ std::shared_ptr<ov::Node> FullyConnectedCompressed::clone_with_new_inputs(constnew_args.at(4),m_output_type,m_transpose_b);- if (new_args.size() == 8)+ }+ if (new_args.size() == 8) {return std::make_shared<FullyConnectedCompressed>(new_args.at(0),new_args.at(1),new_args.at(2),@@ -78,6 +75,7 @@ std::shared_ptr<ov::Node> FullyConnectedCompressed::clone_with_new_inputs(constnew_args.at(7),m_output_type,m_transpose_b);+ }OPENVINO_THROW("Unexpected inputs count for FullyConnectedCompressed op: ", new_args.size());}} // namespace ov::intel_gpu::opdiff --git a/src/plugins/intel_gpu/src/plugin/transformations/op/kv_cache.cpp b/src/plugins/intel_gpu/src/plugin/transformations/op/kv_cache.cppindex 801af4c2d6f..3843a03e680 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/op/kv_cache.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/op/kv_cache.cpp@@ -37,8 +37,9 @@ KVCache::KVCache(const Output<Node>& past,int64_t gather_axis,const ov::element::Type output_type): KVCache({past, new_token_data, beam_idx}, past_variable, true, false, concat_axis, gather_axis, output_type) {- if (m_indirect)+ if (m_indirect) {set_output_size(2);+ }validate_and_infer_types();}@@ -70,8 +71,9 @@ KVCache::KVCache(const Output<Node>& past,int64_t gather_axis,const ov::element::Type output_type): KVCache({past, new_token_data, beam_idx, past_seq_len}, past_variable, true, true, concat_axis, gather_axis, output_type) {- if (m_indirect)+ if (m_indirect) {set_output_size(2);+ }validate_and_infer_types();}@@ -208,8 +210,9 @@ KVCacheCompressed::KVCacheCompressed(const OutputVector& inputs,m_variable = past_variable;size_t output_size = 3;if (quantization_attrs.quantization_type == ov::op::internal::DynamicQuantize::QuantizationType::Asymmetric &&- quantization_attrs.output_storage_type == ov::op::internal::DynamicQuantize::OutputStorageType::Planar)+ quantization_attrs.output_storage_type == ov::op::internal::DynamicQuantize::OutputStorageType::Planar) {output_size++; // add zp output+ }set_output_size(output_size);validate_and_infer_types();@@ -222,8 +225,9 @@ void KVCacheCompressed::validate_and_infer_types() {input_shapes.push_back(get_input_partial_shape(compress_input_offset + 0));if (m_quantization_attrs.quantization_type == ov::op::internal::DynamicQuantize::QuantizationType::Asymmetric &&- m_quantization_attrs.output_storage_type == ov::op::internal::DynamicQuantize::OutputStorageType::Planar)+ m_quantization_attrs.output_storage_type == ov::op::internal::DynamicQuantize::OutputStorageType::Planar) {input_shapes.push_back(get_input_partial_shape(compress_input_offset + 1));+ }auto shapes = shape_infer(this, input_shapes);diff --git a/src/plugins/intel_gpu/src/plugin/transformations/op/sdpa.cpp b/src/plugins/intel_gpu/src/plugin/transformations/op/sdpa.cppindex 00fa3ed415b..99deb96520e 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/op/sdpa.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/op/sdpa.cpp@@ -126,8 +126,9 @@ size_t SDPA::get_compression_inputs_num() const {compression_inputs += 2; // 2 * scalesif (m_quantization_attrs.quantization_type == ov::op::internal::DynamicQuantize::QuantizationType::Asymmetric &&- m_quantization_attrs.output_storage_type == ov::op::internal::DynamicQuantize::OutputStorageType::Planar)+ m_quantization_attrs.output_storage_type == ov::op::internal::DynamicQuantize::OutputStorageType::Planar) {compression_inputs += 2; // 2 * zp+ }}return compression_inputs;diff --git a/src/plugins/intel_gpu/src/plugin/transformations/optimize_subsequent_reshapes.cpp b/src/plugins/intel_gpu/src/plugin/transformations/optimize_subsequent_reshapes.cppindex fa5497ae851..1b4de45e916 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/optimize_subsequent_reshapes.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/optimize_subsequent_reshapes.cpp@@ -22,15 +22,18 @@ OptimizeSubsequentReshapes::OptimizeSubsequentReshapes() {auto single_dynamic_dim = [](Output<Node> output) {const auto& shape = output.get_partial_shape();- if (shape.rank().is_dynamic())+ if (shape.rank().is_dynamic()) {return false;+ }- if (shape.size() <= 1)+ if (shape.size() <= 1) {return false;+ }auto dynamic_dims = 0;- for (size_t i = 0; i < shape.size(); i++)+ for (size_t i = 0; i < shape.size(); i++) {dynamic_dims += shape[i].is_dynamic() ? 1 : 0;+ }return dynamic_dims == 1;};@@ -58,16 +61,18 @@ OptimizeSubsequentReshapes::OptimizeSubsequentReshapes() {int64_t total_dims = 1;for (auto& dim : ps) {- if (dim.is_static())+ if (dim.is_static()) {total_dims *= dim.get_length();+ }}return total_dims;};if (static_dims_product(input_ps) != static_dims_product(first_reshape_ps) ||- static_dims_product(first_reshape_ps) != static_dims_product(second_reshape_ps))+ static_dims_product(first_reshape_ps) != static_dims_product(second_reshape_ps)) {return false;+ }std::vector<int32_t> new_pattern;for (auto& dim : second_reshape_ps) {diff --git a/src/plugins/intel_gpu/src/plugin/transformations/sink_reshape.cpp b/src/plugins/intel_gpu/src/plugin/transformations/sink_reshape.cppindex 054035e2490..0eaf778f9bf 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/sink_reshape.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/sink_reshape.cpp@@ -5,11 +5,8 @@#include "sink_reshape.hpp"#include "intel_gpu/op/convolution.hpp"-#include "openvino/core/rt_info.hpp"-#include "openvino/pass/pattern/op/or.hpp"-#include "openvino/pass/pattern/op/wrap_type.hpp"-#include "transformations/utils/utils.hpp"#include "openvino/core/graph_util.hpp"+#include "openvino/core/rt_info.hpp"#include "openvino/op/add.hpp"#include "openvino/op/clamp.hpp"#include "openvino/op/divide.hpp"@@ -26,6 +23,9 @@#include "openvino/op/subtract.hpp"#include "openvino/op/swish.hpp"#include "openvino/op/transpose.hpp"+#include "openvino/pass/pattern/op/or.hpp"+#include "openvino/pass/pattern/op/wrap_type.hpp"+#include "transformations/utils/utils.hpp"namespace ov {namespace intel_gpu {@@ -37,27 +37,29 @@ SinkReshape::SinkReshape() {auto reshape_predicate = [](const ov::Output<ov::Node>& output) -> bool {auto supported_conv_act_post_ops_for_fuse = [](const std::shared_ptr<const Node>& node) -> bool {- return ov::is_type<v0::Relu>(node) || ov::is_type<v0::Elu>(node) || ov::is_type<v0::Sigmoid>(node) ||- ov::is_type<v5::HSigmoid>(node) || ov::is_type<v0::Clamp>(node) || ov::is_type<v4::Swish>(node) ||- ov::is_type<v4::HSwish>(node) || ov::is_type<v4::Mish>(node) || ov::is_type<v5::Round>(node) ||- ov::is_type<v4::Mish>(node) || ov::is_type<v5::Round>(node);+ return ov::is_type<v0::Relu>(node) || ov::is_type<v0::Elu>(node) || ov::is_type<v0::Sigmoid>(node) || ov::is_type<v5::HSigmoid>(node) ||+ ov::is_type<v0::Clamp>(node) || ov::is_type<v4::Swish>(node) || ov::is_type<v4::HSwish>(node) || ov::is_type<v4::Mish>(node) ||+ ov::is_type<v5::Round>(node) || ov::is_type<v4::Mish>(node) || ov::is_type<v5::Round>(node);};auto supported_conv_eltwise_post_ops_for_fuse = [](const std::shared_ptr<const Node>& node) -> bool {- if (ov::is_type<v1::Add>(node) || ov::is_type<v1::Subtract>(node) || ov::is_type<v1::Multiply>(node) ||- ov::is_type<v1::Divide>(node))+ if (ov::is_type<v1::Add>(node) || ov::is_type<v1::Subtract>(node) || ov::is_type<v1::Multiply>(node) || ov::is_type<v1::Divide>(node)) {return std::dynamic_pointer_cast<v0::Constant>(node->get_input_node_shared_ptr(1)) != nullptr;+ }return ov::is_type<v0::Exp>(node);};std::function<bool(const std::shared_ptr<ov::Node>&)> is_suitable_parent;is_suitable_parent = [&](const std::shared_ptr<ov::Node>& node) -> bool {- if (node->get_users().size() != 1 || node->is_dynamic())+ if (node->get_users().size() != 1 || node->is_dynamic()) {return false;- if (ov::as_type_ptr<op::Convolution>(node))+ }+ if (ov::as_type_ptr<op::Convolution>(node)) {return true;+ }for (size_t idx = 0; idx < node->get_input_size(); idx++) {auto input = node->get_input_node_shared_ptr(idx);- if (ov::as_type_ptr<v0::Constant>(node))+ if (ov::as_type_ptr<v0::Constant>(node)) {continue;+ }if (supported_conv_eltwise_post_ops_for_fuse(node)) {return is_suitable_parent(input);}@@ -70,16 +72,19 @@ SinkReshape::SinkReshape() {};// reshape supported only in one case, if two consecutive input dims are merged into 1auto is_suitable_reshape = [](const std::shared_ptr<ov::Node>& node) -> bool {- if (node->is_dynamic())+ if (node->is_dynamic()) {return false;+ }const auto& in_ps = node->get_input_partial_shape(0);const auto& out_ps = node->get_output_partial_shape(0);- if (in_ps.size() - out_ps.size() != 1)+ if (in_ps.size() - out_ps.size() != 1) {return false;+ }size_t mismatch_count = 0;for (size_t i = 0; i < out_ps.size(); ++i) {- if (i + mismatch_count >= in_ps.size())+ if (i + mismatch_count >= in_ps.size()) {return false;+ }if (out_ps[i] != in_ps[i + mismatch_count]) {mismatch_count++;}@@ -113,8 +118,9 @@ SinkReshape::SinkReshape() {ov::Shape new_shape(transformed_order.size());const uint16_t merge_dim_idx = [&]() {for (uint16_t i = 0; i < reshape_out_shape.size(); ++i) {- if (reshape_in_shape[i] != reshape_out_shape[i])+ if (reshape_in_shape[i] != reshape_out_shape[i]) {return i;+ }}OPENVINO_THROW("same input/output for reshape node");}();@@ -133,15 +139,19 @@ SinkReshape::SinkReshape() {// allow tranposes which rotate feature dim to back to be taken as inner-most axisauto check_transpose_order = [](std::vector<uint16_t>& order) -> bool {- if (order.size() <= 2)+ if (order.size() <= 2) {return false;- if ((int32_t)order[order.size() - 2] != order.size() - 1)+ }+ if ((int32_t)order[order.size() - 2] != order.size() - 1) {return false;- if ((int32_t)order[0] != 0)+ }+ if ((int32_t)order[0] != 0) {return false;+ }for (int32_t i = 2; i < (int32_t)order.size(); ++i) {- if ((int32_t)order[i - 1] != i)+ if ((int32_t)order[i - 1] != i) {return false;+ }}return true;};@@ -153,21 +163,15 @@ SinkReshape::SinkReshape() {auto tranpose_order = std::dynamic_pointer_cast<v0::Constant>(org_transpose_m);auto updated_order = update_order(tranpose_order->cast_vector<uint16_t>(), reshape);if (check_transpose_order(updated_order)) {- auto updated_transpose_order = std::make_shared<v0::Constant>(tranpose_order->get_element_type(),- ov::Shape(1, updated_order.size()),- updated_order);+ auto updated_transpose_order =+ std::make_shared<v0::Constant>(tranpose_order->get_element_type(), ov::Shape(1, updated_order.size()), updated_order);updated_transpose_order->set_friendly_name(tranpose_order->get_friendly_name() + "_updated");- auto new_transpose =- std::make_shared<v1::Transpose>(reshape->input(0).get_source_output(), updated_transpose_order);+ auto new_transpose = std::make_shared<v1::Transpose>(reshape->input(0).get_source_output(), updated_transpose_order);new_transpose->set_friendly_name(transpose->get_friendly_name() + "_with_updated_order");copy_runtime_info(transpose, new_transpose);ov::replace_node(reshape, new_transpose);- auto new_pattern_const = std::make_shared<ov::op::v0::Constant>(ov::element::i32,- ov::Shape{org_transpose_os.size()},- org_transpose_os);- auto new_reshape = std::make_shared<ov::op::v1::Reshape>(new_transpose,- new_pattern_const,- reshape->get_special_zero());+ auto new_pattern_const = std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{org_transpose_os.size()}, org_transpose_os);+ auto new_reshape = std::make_shared<ov::op::v1::Reshape>(new_transpose, new_pattern_const, reshape->get_special_zero());new_reshape->set_friendly_name(reshape->get_friendly_name() + "_sinked_after_transpose");copy_runtime_info(reshape, new_reshape);ov::replace_node(transpose, new_reshape);diff --git a/src/plugins/intel_gpu/src/plugin/transformations/swiglu_fusion_with_clamp.cpp b/src/plugins/intel_gpu/src/plugin/transformations/swiglu_fusion_with_clamp.cppindex 8130574b8e3..e318f3ad86a 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/swiglu_fusion_with_clamp.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/swiglu_fusion_with_clamp.cpp@@ -57,16 +57,18 @@ namespace intel_gpu {const auto& pattern_map = m.get_pattern_value_map();auto swish_node_ptr = ov::as_type_ptr<ov::op::v4::Swish>(pattern_map.at(swish_m).get_node_shared_ptr());auto mul_node_ptr = ov::as_type_ptr<ov::op::v1::Multiply>(pattern_map.at(multiply1_m).get_node_shared_ptr());- if (!mul_node_ptr || transformation_callback(mul_node_ptr))+ if (!mul_node_ptr || transformation_callback(mul_node_ptr)) {return false;+ }auto clamp_node = ov::as_type_ptr<ov::op::v0::Clamp>(pattern_map.at(clamp_m).get_node_shared_ptr());auto clamp_min_value = static_cast<float>(clamp_node->get_min());auto clamp_max_value = static_cast<float>(clamp_node->get_max());size_t gate_idx = 0;- if (ov::is_type<ov::op::v4::Swish>(mul_node_ptr->get_input_node_shared_ptr(1)))+ if (ov::is_type<ov::op::v4::Swish>(mul_node_ptr->get_input_node_shared_ptr(1))) {gate_idx = 1;+ }auto slice1_node_ptr = ov::as_type_ptr<ov::op::v8::Slice>(pattern_map.at(slice1_m).get_node_shared_ptr());auto slice1_in_ps = slice1_node_ptr->get_input_partial_shape(0);@@ -76,8 +78,9 @@ namespace intel_gpu {bool valid_axis_const_values = ov::op::util::has_constant_value<int64_t>(axis_node_ptr, -1)|| ov::op::util::has_constant_value<int64_t>(axis_node_ptr, last_dim);// only innermost axis supported- if (!valid_axis_const_values)+ if (!valid_axis_const_values) {return false;+ }auto axis_dim = axis_node_ptr->cast_vector<int64_t>()[0];auto slice1_start_node_ptr = ov::as_type_ptr<ov::op::v0::Constant>(pattern_map.at(slice1_start_const_m).get_node_shared_ptr());@@ -98,8 +101,9 @@ namespace intel_gpu {} else {return false;}- if (pattern_map.find(swish_beta_m) == pattern_map.end())+ if (pattern_map.find(swish_beta_m) == pattern_map.end()) {return false;+ }auto swish_beta_node_ptr = ov::as_type_ptr<ov::op::v0::Constant>(pattern_map.at(swish_beta_m).get_node_shared_ptr());auto swish_beta_val = static_cast<float>(swish_beta_node_ptr->cast_vector<double>()[0]);auto add_const_node_ptr = ov::as_type_ptr<ov::op::v0::Constant>(pattern_map.at(added_const_m).get_node_shared_ptr());diff --git a/src/plugins/intel_gpu/src/plugin/transformations/transpose_fusion.cpp b/src/plugins/intel_gpu/src/plugin/transformations/transpose_fusion.cppindex 5838d4756da..212fe0d2e94 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/transpose_fusion.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/transpose_fusion.cpp@@ -2,35 +2,35 @@// SPDX-License-Identifier: Apache-2.0//+#include "transpose_fusion.hpp"++#include <iostream>+#include <ostream>+#include <vector>++#include "graph/include/gemm_inst.h"#include "intel_gpu/op/gemm.hpp"#include "intel_gpu/op/sdpa.hpp"#include "intel_gpu/runtime/utils.hpp"+#include "openvino/core/graph_util.hpp"#include "openvino/core/node_vector.hpp"#include "openvino/core/partial_shape.hpp"+#include "openvino/core/rt_info.hpp"#include "openvino/core/type/element_type.hpp"#include "openvino/op/constant.hpp"-#include "openvino/pass/pattern/op/label.hpp"-#include "openvino/pass/pattern/op/pattern.hpp"-#include "transpose_fusion.hpp"+#include "openvino/op/convert.hpp"#include "openvino/op/matmul.hpp"+#include "openvino/op/reshape.hpp"#include "openvino/op/scaled_dot_product_attention.hpp"-#include "openvino/op/convert.hpp"-#include "openvino/op/transpose.hpp"#include "openvino/op/split.hpp"-#include "openvino/op/reshape.hpp"-#include "openvino/core/rt_info.hpp"-#include "openvino/pass/pattern/op/wrap_type.hpp"-#include "openvino/pass/pattern/op/or.hpp"+#include "openvino/op/transpose.hpp"#include "openvino/pass/pattern/op/any.hpp"-#include "transformations/utils/utils.hpp"-#include "openvino/core/graph_util.hpp"-#include "graph/include/gemm_inst.h"-+#include "openvino/pass/pattern/op/label.hpp"+#include "openvino/pass/pattern/op/or.hpp"+#include "openvino/pass/pattern/op/pattern.hpp"+#include "openvino/pass/pattern/op/wrap_type.hpp"#include "ov_ops/vl_sdpa.hpp"--#include <iostream>-#include <vector>-#include <ostream>+#include "transformations/utils/utils.hpp"using namespace ov::pass::pattern;using ov::pass::pattern::op::Or;@@ -49,15 +49,18 @@ bool is_valid_order(const std::vector<size_t>& target_order, bool is_output_tran}bool has_optimized_version(const ov::Output<ov::Node>& output, bool supports_immad, bool is_output_transpose = false) {- if (!output.get_element_type().is_real())+ if (!output.get_element_type().is_real()) {return false;+ }- if (output.get_partial_shape().is_static() && !supports_immad)+ if (output.get_partial_shape().is_static() && !supports_immad) {return false;+ }auto order_node = output.get_node()->get_input_node_shared_ptr(1);- if (!ov::is_type<ov::op::v0::Constant>(order_node))+ if (!ov::is_type<ov::op::v0::Constant>(order_node)) {return false;+ }auto transpose_order = ov::as_type_ptr<ov::op::v0::Constant>(order_node)->cast_vector<int64_t>();const auto expected_dims_num = 4;@@ -65,10 +68,12 @@ bool has_optimized_version(const ov::Output<ov::Node>& output, bool supports_immstd::vector<size_t> order(std::begin(transpose_order), std::end(transpose_order));if (expected_dims_num > order.size()) {size_t orders_to_add = expected_dims_num - order.size();- for (size_t i = 0; i < orders_to_add; ++i)+ for (size_t i = 0; i < orders_to_add; ++i) {order.insert(order.begin(), i);- for (size_t i = orders_to_add; i < order.size(); ++i)+ }+ for (size_t i = orders_to_add; i < order.size(); ++i) {order[i] = order[i] + orders_to_add;+ }}return is_valid_order(order, is_output_transpose);@@ -86,9 +91,11 @@ TransposeFusion::TransposeFusion(bool supports_immad) {TransposeVLSDPAMatcher::TransposeVLSDPAMatcher() {auto is_fp_type = [](const ov::Output<ov::Node>& output) -> bool {switch (output.get_element_type()) {- case ov::element::f16:- case ov::element::f32: return true;- default: return false;+ case ov::element::f16:+ case ov::element::f32:+ return true;+ default:+ return false;}};auto not_transpose = [](const ov::Output<ov::Node>& output) -> bool {@@ -107,7 +114,7 @@ TransposeVLSDPAMatcher::TransposeVLSDPAMatcher() {auto transpose_k_m = wrap_type<ov::op::v1::Transpose>({input_k_m, transpose_k_order_m}, is_fp_type);auto transpose_v_m = wrap_type<ov::op::v1::Transpose>({input_v_m, transpose_v_order_m}, is_fp_type);- auto sdpa_m = wrap_type<ov::op::internal::VLSDPA>({ transpose_q_m, transpose_k_m, transpose_v_m, input_cu_seqlens });+ auto sdpa_m = wrap_type<ov::op::internal::VLSDPA>({transpose_q_m, transpose_k_m, transpose_v_m, input_cu_seqlens});// fuse output transpose into VLSDPA tooauto transpose_o_order_m = wrap_type<ov::op::v0::Constant>(consumers_count(1));@@ -135,11 +142,12 @@ TransposeVLSDPAMatcher::TransposeVLSDPAMatcher() {std::vector<int64_t>& order,size_t& output_idx) {auto transpose_order_const = ov::as_type_ptr<ov::op::v0::Constant>(transpose_order_const_node);- std::vector<int64_t>_order = transpose_order_const->cast_vector<int64_t>();+ std::vector<int64_t> _order = transpose_order_const->cast_vector<int64_t>();// Allow any transposes without head_size dim position change- if (_order.back() != static_cast<int64_t>(_order.size() - 1))+ if (_order.back() != static_cast<int64_t>(_order.size() - 1)) {return false;+ }auto transpose = ov::as_type_ptr<ov::op::v1::Transpose>(transpose_node);output_idx = transpose->get_input_source_output(0).get_index();@@ -150,27 +158,36 @@ TransposeVLSDPAMatcher::TransposeVLSDPAMatcher() {};bool can_fuse_transposes = true;- if (pattern_map.count(transpose_q_m) > 0)+ if (pattern_map.count(transpose_q_m) > 0) {can_fuse_transposes &= process_transpose(pattern_map.at(transpose_q_m).get_node_shared_ptr(),pattern_map.at(transpose_q_order_m).get_node_shared_ptr(),- order_q, input_q_output_idx);+ order_q,+ input_q_output_idx);+ }- if (pattern_map.count(transpose_k_m) > 0)+ if (pattern_map.count(transpose_k_m) > 0) {can_fuse_transposes &= process_transpose(pattern_map.at(transpose_k_m).get_node_shared_ptr(),pattern_map.at(transpose_k_order_m).get_node_shared_ptr(),- order_k, input_k_output_idx);+ order_k,+ input_k_output_idx);+ }- if (pattern_map.count(transpose_v_m) > 0)+ if (pattern_map.count(transpose_v_m) > 0) {can_fuse_transposes &= process_transpose(pattern_map.at(transpose_v_m).get_node_shared_ptr(),pattern_map.at(transpose_v_order_m).get_node_shared_ptr(),- order_v, input_v_output_idx);+ order_v,+ input_v_output_idx);+ }- if (pattern_map.count(transpose_o_m) > 0)+ if (pattern_map.count(transpose_o_m) > 0) {can_fuse_transposes &= process_transpose(pattern_map.at(transpose_o_m).get_node_shared_ptr(),- pattern_map.at(transpose_o_order_m).get_node_shared_ptr(),- order_output, output_o_input_idx);- if (!can_fuse_transposes)+ pattern_map.at(transpose_o_order_m).get_node_shared_ptr(),+ order_output,+ output_o_input_idx);+ }+ if (!can_fuse_transposes) {return false;+ }auto input_q = ov::Output<Node>(pattern_map.at(input_q_m).get_node_shared_ptr(), input_q_output_idx);auto input_k = ov::Output<Node>(pattern_map.at(input_k_m).get_node_shared_ptr(), input_k_output_idx);@@ -198,14 +215,15 @@ TransposeVLSDPAMatcher::TransposeVLSDPAMatcher() {TransposeSDPAMatcher::TransposeSDPAMatcher() {auto is_fp_type = [](const ov::Output<ov::Node>& output) -> bool {switch (output.get_element_type()) {- case ov::element::f16:- case ov::element::f32: return true;- default: return false;+ case ov::element::f16:+ case ov::element::f32:+ return true;+ default:+ return false;}};auto not_transpose = [is_fp_type](const ov::Output<ov::Node>& output) -> bool {- return ov::as_type_ptr<ov::op::v1::Transpose>(output.get_node_shared_ptr()) == nullptr- && is_fp_type(output);+ return ov::as_type_ptr<ov::op::v1::Transpose>(output.get_node_shared_ptr()) == nullptr && is_fp_type(output);};auto input_q_m = any_input(not_transpose);@@ -224,10 +242,9 @@ TransposeSDPAMatcher::TransposeSDPAMatcher() {auto sdpa_in_k = std::make_shared<Or>(OutputVector{input_k_m, transpose_k_m});auto sdpa_in_v = std::make_shared<Or>(OutputVector{input_v_m, transpose_v_m});- auto sdpa_without_attn_mask_m = wrap_type<ov::op::v13::ScaledDotProductAttention>({ sdpa_in_q, sdpa_in_k, sdpa_in_v });- auto sdpa_with_attn_mask_m = wrap_type<ov::op::v13::ScaledDotProductAttention>({ sdpa_in_q, sdpa_in_k, sdpa_in_v, input_attn_mask });- auto sdpa_with_attn_mask_and_scale_m =- wrap_type<ov::op::v13::ScaledDotProductAttention>({ sdpa_in_q, sdpa_in_k, sdpa_in_v, input_attn_mask, input_scale });+ auto sdpa_without_attn_mask_m = wrap_type<ov::op::v13::ScaledDotProductAttention>({sdpa_in_q, sdpa_in_k, sdpa_in_v});+ auto sdpa_with_attn_mask_m = wrap_type<ov::op::v13::ScaledDotProductAttention>({sdpa_in_q, sdpa_in_k, sdpa_in_v, input_attn_mask});+ auto sdpa_with_attn_mask_and_scale_m = wrap_type<ov::op::v13::ScaledDotProductAttention>({sdpa_in_q, sdpa_in_k, sdpa_in_v, input_attn_mask, input_scale});auto sdpa_m = std::make_shared<Or>(OutputVector{sdpa_without_attn_mask_m, sdpa_with_attn_mask_m, sdpa_with_attn_mask_and_scale_m});@@ -261,8 +278,9 @@ TransposeSDPAMatcher::TransposeSDPAMatcher() {order = transpose_order_const->cast_vector<int64_t>();// Allow any transposes without head_size dim position change- if (order.back() != static_cast<int64_t>(order.size() - 1))+ if (order.back() != static_cast<int64_t>(order.size() - 1)) {return false;+ }auto transpose = ov::as_type_ptr<ov::op::v1::Transpose>(transpose_node);output_idx = transpose->get_input_source_output(0).get_index();@@ -271,23 +289,30 @@ TransposeSDPAMatcher::TransposeSDPAMatcher() {};bool can_fuse_transposes = true;- if (pattern_map.count(transpose_q_m) > 0)+ if (pattern_map.count(transpose_q_m) > 0) {can_fuse_transposes &= process_transpose(pattern_map.at(transpose_q_m).get_node_shared_ptr(),pattern_map.at(transpose_q_order_m).get_node_shared_ptr(),- order_q, input_q_output_idx);+ order_q,+ input_q_output_idx);+ }- if (pattern_map.count(transpose_k_m) > 0)+ if (pattern_map.count(transpose_k_m) > 0) {can_fuse_transposes &= process_transpose(pattern_map.at(transpose_k_m).get_node_shared_ptr(),pattern_map.at(transpose_k_order_m).get_node_shared_ptr(),- order_k, input_k_output_idx);+ order_k,+ input_k_output_idx);+ }- if (pattern_map.count(transpose_v_m) > 0)+ if (pattern_map.count(transpose_v_m) > 0) {can_fuse_transposes &= process_transpose(pattern_map.at(transpose_v_m).get_node_shared_ptr(),pattern_map.at(transpose_v_order_m).get_node_shared_ptr(),- order_v, input_v_output_idx);+ order_v,+ input_v_output_idx);+ }- if (!can_fuse_transposes)+ if (!can_fuse_transposes) {return false;+ }auto input_q = ov::Output<Node>(pattern_map.at(input_q_m).get_node_shared_ptr(), input_q_output_idx);auto input_k = ov::Output<Node>(pattern_map.at(input_k_m).get_node_shared_ptr(), input_k_output_idx);@@ -327,8 +352,7 @@ TransposeSDPAMatcher::TransposeSDPAMatcher() {TransposeMatMulMatcher::TransposeMatMulMatcher(bool supports_immad) {auto not_transpose = [](const ov::Output<ov::Node>& output) -> bool {- return ov::as_type_ptr<ov::op::v1::Transpose>(output.get_node_shared_ptr()) == nullptr- && output.get_element_type().is_real();+ return ov::as_type_ptr<ov::op::v1::Transpose>(output.get_node_shared_ptr()) == nullptr && output.get_element_type().is_real();};auto transpose_predicate = [supports_immad](const ov::Output<ov::Node>& output) -> bool {@@ -339,12 +363,14 @@ TransposeMatMulMatcher::TransposeMatMulMatcher(bool supports_immad) {// CreateMatMulOp factory can now insert extra transpose which improves the performanceauto matmul_predicate = [](const ov::Output<ov::Node>& output) -> bool {auto* node = output.get_node();- if (node->is_dynamic())+ if (node->is_dynamic()) {return true;+ }for (size_t i = 0; i < node->get_input_size(); i++) {- if (ov::is_type<ov::op::v1::Transpose>(node->get_input_node_ptr(i)))+ if (ov::is_type<ov::op::v1::Transpose>(node->get_input_node_ptr(i))) {return true;+ }}return false;@@ -360,7 +386,7 @@ TransposeMatMulMatcher::TransposeMatMulMatcher(bool supports_immad) {auto matmul_in_a = std::make_shared<Or>(OutputVector{input_a_m, transpose_a_m});auto matmul_in_b = std::make_shared<Or>(OutputVector{input_b_m, transpose_b_m});- auto matmul_m = wrap_type<ov::op::v0::MatMul>({ matmul_in_a, matmul_in_b }, matmul_predicate);+ auto matmul_m = wrap_type<ov::op::v0::MatMul>({matmul_in_a, matmul_in_b}, matmul_predicate);ov::matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](Matcher& m) {const auto& pattern_map = m.get_pattern_value_map();@@ -416,8 +442,7 @@ TransposeMatMulMatcher::TransposeMatMulMatcher(bool supports_immad) {TransposeMatMulTransposeMatcher::TransposeMatMulTransposeMatcher(bool supports_immad) {auto not_transpose = [](const ov::Output<ov::Node>& output) -> bool {- return ov::as_type_ptr<ov::op::v1::Transpose>(output.get_node_shared_ptr()) == nullptr- && output.get_element_type().is_real();+ return ov::as_type_ptr<ov::op::v1::Transpose>(output.get_node_shared_ptr()) == nullptr && output.get_element_type().is_real();};auto input_transpose_predicate = [supports_immad](const ov::Output<ov::Node>& output) -> bool {return has_optimized_version(output, supports_immad, false);@@ -435,7 +460,7 @@ TransposeMatMulTransposeMatcher::TransposeMatMulTransposeMatcher(bool supports_iauto matmul_in_a = std::make_shared<Or>(OutputVector{input_a_m, transpose_a_m});auto matmul_in_b = std::make_shared<Or>(OutputVector{input_b_m, transpose_b_m});- auto matmul_m = wrap_type<ov::op::v0::MatMul>({ matmul_in_a, matmul_in_b }, consumers_count(1));+ auto matmul_m = wrap_type<ov::op::v0::MatMul>({matmul_in_a, matmul_in_b}, consumers_count(1));auto transpose_c_order_m = wrap_type<ov::op::v0::Constant>(consumers_count(1));auto transpose_c_m = wrap_type<ov::op::v1::Transpose>({matmul_m, transpose_c_order_m}, output_transpose_predicate);@@ -543,16 +568,14 @@ TransposeSplitMatcher::TransposeSplitMatcher() {}// Get transpose order- auto transpose_order_const = ov::as_type_ptr<ov::op::v0::Constant>(- pattern_map.at(transpose_order_m).get_node_shared_ptr());+ auto transpose_order_const = ov::as_type_ptr<ov::op::v0::Constant>(pattern_map.at(transpose_order_m).get_node_shared_ptr());if (!transpose_order_const) {return false;}auto transpose_order = transpose_order_const->cast_vector<int64_t>();// Get split axis- auto split_axis_const = ov::as_type_ptr<ov::op::v0::Constant>(- pattern_map.at(split_axis_m).get_node_shared_ptr());+ auto split_axis_const = ov::as_type_ptr<ov::op::v0::Constant>(pattern_map.at(split_axis_m).get_node_shared_ptr());if (!split_axis_const) {return false;}diff --git a/src/plugins/intel_gpu/src/plugin/transformations/unsqueeze_broadcast_reshape_matmul_fusion.cpp b/src/plugins/intel_gpu/src/plugin/transformations/unsqueeze_broadcast_reshape_matmul_fusion.cppindex 90b0f67da91..87cd0c2ed9d 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/unsqueeze_broadcast_reshape_matmul_fusion.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/unsqueeze_broadcast_reshape_matmul_fusion.cpp@@ -56,8 +56,9 @@ UnsqueezeBroadcastReshapeMatmulFusion::UnsqueezeBroadcastReshapeMatmulFusion() {auto target_shape_constant = ov::as_type_ptr<ov::op::v0::Constant>(broadcast->get_input_node_shared_ptr(1));if (target_shape_constant) {auto target_shape_val = target_shape_constant->cast_vector<int32_t>();- if (!valid_broadcast_target_shape(target_shape_val))+ if (!valid_broadcast_target_shape(target_shape_val)) {return false;+ }}auto input_a = pattern_map.at(input_a_m).get_node_shared_ptr();diff --git a/src/plugins/intel_gpu/src/plugin/transformations/utils.hpp b/src/plugins/intel_gpu/src/plugin/transformations/utils.hppindex c0ff3b8056d..986be650a5d 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/utils.hpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/utils.hpp@@ -27,8 +27,9 @@ inline bool insert_converts_before_if_needed(const std::shared_ptr<ov::Node>& noconst auto& incoming_node = incoming_output.get_node_shared_ptr();const auto input_et = incoming_output.get_element_type();- if (input_et == desired_et)+ if (input_et == desired_et) {continue;+ }if (std::find(skip_inputs.begin(), skip_inputs.end(), input.get_index()) != skip_inputs.end()) {continue;diff --git a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cppindex c6df0f8e492..678b406b0ef 100644--- a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp@@ -891,10 +891,11 @@ void TransformationsPipeline::apply(std::shared_ptr<ov::Model> func) {if (use_xattention) {// Throw exception if xattn is not supported by either GPU archieture or compiler.- if (!check_xattn_gpu_compatibility())+ if (!check_xattn_gpu_compatibility()) {OPENVINO_THROW("[GPU] XAttention is not supported by your current GPU architecture or IGC version. "- "Please either disable XAttention by following the GenAI guide, or switch to a GPU with Xe2/Xe3 "- "architecture and ensure the latest IGC is installed.");+ "Please either disable XAttention by following the GenAI guide, or switch to a GPU with Xe2/Xe3 "+ "architecture and ensure the latest IGC is installed.");+ }}// KVCache layout with default attention -diff --git a/src/plugins/intel_gpu/src/plugin/variable_state.cpp b/src/plugins/intel_gpu/src/plugin/variable_state.cppindex 8be9c5dc2f2..f08cd33f421 100644--- a/src/plugins/intel_gpu/src/plugin/variable_state.cpp+++ b/src/plugins/intel_gpu/src/plugin/variable_state.cpp@@ -54,8 +54,9 @@ void VariableState::set_memory(const cldnn::memory::ptr& new_mem, const cldnn::l}void VariableState::set_layout(const cldnn::layout& new_layout) {- if (m_layout == new_layout)+ if (m_layout == new_layout) {return;+ }m_layout = new_layout;GPU_DEBUG_TRACE_DETAIL << m_name << " : " << "Update state layout to " << new_layout.to_short_string() << std::endl;update_device_buffer();@@ -88,8 +89,9 @@ void VariableState::set_state(const ov::SoPtr<ov::ITensor>& state) {std::vector<ov::Dimension::value_type> upper_pad(src_rank, 0);std::vector<ov::Dimension::value_type> lower_pad(src_rank, 0);for (int32_t i = static_cast<int32_t>(src_stride.size()) - 1; i >= 0; --i) {- if (i <= static_cast<int32_t>(src_stride.size()) - 2)+ if (i <= static_cast<int32_t>(src_stride.size()) - 2) {src_stride_no_pad[i] = src_stride_no_pad[i + 1] * src_shape[i + 1];+ }if (src_stride[i] != src_stride_no_pad[i]) {OPENVINO_ASSERT(src_stride[i] > src_stride_no_pad[i]);size_t padded_size = src_stride[i] / src_stride[i + 1];diff --git a/src/plugins/intel_gpu/src/runtime/debug_configuration.cpp b/src/plugins/intel_gpu/src/runtime/debug_configuration.cppindex 9e4ac47d453..bcace1c31d4 100644--- a/src/plugins/intel_gpu/src/runtime/debug_configuration.cpp+++ b/src/plugins/intel_gpu/src/runtime/debug_configuration.cpp@@ -12,8 +12,9 @@ std::ostream& get_verbose_stream() {#ifdef GPU_DEBUG_CONFIGif (!ExecutionConfig::get_log_to_file().empty()) {static std::ofstream fout;- if (!fout.is_open())+ if (!fout.is_open()) {fout.open(ExecutionConfig::get_log_to_file());+ }return fout;}return std::cout;diff --git a/src/plugins/intel_gpu/src/runtime/engine.cpp b/src/plugins/intel_gpu/src/runtime/engine.cppindex 03140afcef6..daa4ffb850d 100644--- a/src/plugins/intel_gpu/src/runtime/engine.cpp+++ b/src/plugins/intel_gpu/src/runtime/engine.cpp@@ -95,10 +95,12 @@ uint64_t engine::get_host_memory_size() const {}bool engine::supports_allocation(allocation_type type) const {- if (memory_capabilities::is_usm_type(type) && !use_unified_shared_memory())+ if (memory_capabilities::is_usm_type(type) && !use_unified_shared_memory()) {return false;- if (allocation_type::usm_shared == type)+ }+ if (allocation_type::usm_shared == type) {return false;+ }return _device->get_mem_caps().support_allocation_type(type);}@@ -108,8 +110,9 @@ bool engine::can_use_host_usm_zero_copy() const {}allocation_type engine::get_lockable_preferred_memory_allocation_type(bool is_image_layout) const {- if (!use_unified_shared_memory() || is_image_layout)+ if (!use_unified_shared_memory() || is_image_layout) {return get_default_allocation_type();+ }/*We do not check device allocation here.@@ -120,24 +123,29 @@ allocation_type engine::get_lockable_preferred_memory_allocation_type(bool is_imbool support_usm_host = supports_allocation(allocation_type::usm_host);bool support_usm_shared = supports_allocation(allocation_type::usm_shared);- if (support_usm_shared)+ if (support_usm_shared) {return allocation_type::usm_shared;- if (support_usm_host)+ }+ if (support_usm_host) {return allocation_type::usm_host;+ }OPENVINO_ASSERT(false, "[GPU] Couldn't find proper allocation type in get_lockable_preferred_memory_allocation_type method");}allocation_type engine::get_preferred_memory_allocation_type(bool is_image_layout) const {- if (!use_unified_shared_memory() || is_image_layout)+ if (!use_unified_shared_memory() || is_image_layout) {return get_default_allocation_type();+ }- if (supports_allocation(allocation_type::usm_device))+ if (supports_allocation(allocation_type::usm_device)) {return allocation_type::usm_device;+ }// Fallback to host allocations in case if device ones are not supported for some reason- if (supports_allocation(allocation_type::usm_host))+ if (supports_allocation(allocation_type::usm_host)) {return allocation_type::usm_host;+ }OPENVINO_ASSERT(false, "[GPU] Couldn't find proper allocation type in get_preferred_memory_allocation_type method");}diff --git a/src/plugins/intel_gpu/src/runtime/event.cpp b/src/plugins/intel_gpu/src/runtime/event.cppindex 8699e7a131f..5a76007714b 100644--- a/src/plugins/intel_gpu/src/runtime/event.cpp+++ b/src/plugins/intel_gpu/src/runtime/event.cpp@@ -12,8 +12,9 @@namespace cldnn {void event::wait() {- if (_set)+ if (_set) {return;+ }// TODO: refactor in context of multiple simultaneous calls (for generic engine)wait_impl();@@ -21,16 +22,18 @@ void event::wait() {}void event::set() {- if (_set)+ if (_set) {return;+ }_set = true;set_impl();call_handlers();}bool event::is_set() {- if (_set)+ if (_set) {return true;+ }// TODO: refactor in context of multiple simultaneous calls (for generic engine)_set = is_set_impl();@@ -46,8 +49,9 @@ bool event::add_event_handler(event_handler handler, void* data) {std::lock_guard<std::mutex> lock(_handlers_mutex);auto itr = _handlers.insert(_handlers.end(), {handler, data});auto ret = add_event_handler_impl(handler, data);- if (!ret)+ if (!ret) {_handlers.erase(itr);+ }return ret;}diff --git a/src/plugins/intel_gpu/src/runtime/execution_config.cpp b/src/plugins/intel_gpu/src/runtime/execution_config.cppindex 39efa623660..44b4c06e982 100644--- a/src/plugins/intel_gpu/src/runtime/execution_config.cpp+++ b/src/plugins/intel_gpu/src/runtime/execution_config.cpp@@ -42,8 +42,9 @@ namespace {ov::RTMap get_rt_info(const ov::Model& model) {ov::RTMap rt_info;- if (model.has_rt_info("runtime_options"))+ if (model.has_rt_info("runtime_options")) {rt_info = model.get_rt_info<ov::AnyMap>("runtime_options");+ }if (model.has_rt_info("__weights_path")) {rt_info[ov::weights_path.name()] = model.get_rt_info<ov::Any>("__weights_path");@@ -64,20 +65,24 @@ bool requires_new_shape_infer(const std::shared_ptr<ov::Node>& op) {if (ov::is_type<ov::op::v15::SearchSorted>(op)||ov::is_type<ov::op::v15::STFT>(op) ||ov::is_type<ov::op::v16::ISTFT>(op) ||- ov::is_type<ov::op::v16::SparseFillEmptyRows>(op))+ ov::is_type<ov::op::v16::SparseFillEmptyRows>(op)) {return true;+ }- if (ov::is_type<ov::op::internal::DynamicQuantize>(op) || ov::is_type<ov::op::internal::RMS>(op))+ if (ov::is_type<ov::op::internal::DynamicQuantize>(op) || ov::is_type<ov::op::internal::RMS>(op)) {return true;+ }if (ov::is_type<ov::op::internal::GatedDeltaNet>(op) || ov::is_type<ov::op::internal::SelectiveSSM>(op) ||- ov::is_type<ov::op::internal::PagedSelectiveSSM>(op))+ ov::is_type<ov::op::internal::PagedSelectiveSSM>(op)) {return true;+ }if (ov::is_type<ov::op::v5::Loop>(op)) {const auto body_function = std::static_pointer_cast<ov::op::v5::Loop>(op)->get_function();- if (body_function->is_dynamic())+ if (body_function->is_dynamic()) {return true;+ }}if (ov::is_type<ov::op::v5::GRUSequence>(op) || ov::is_type<ov::op::v5::LSTMSequence>(op) || ov::is_type<ov::op::v4::LSTMCell>(op)) {@@ -112,18 +117,21 @@ bool requires_new_shape_infer(const std::shared_ptr<ov::Node>& op) {// because op.is_dynamic() which only checks input shapes return false.// So, in the case of input data, we need to check output shape.for (size_t i = 0; i < op->get_output_size(); i++) {- if (op->get_output_partial_shape(i).is_dynamic())+ if (op->get_output_partial_shape(i).is_dynamic()) {return true;+ }}for (size_t i = 0; i < op->get_output_size(); i++) {- if (op->get_output_partial_shape(i).size() > 6)+ if (op->get_output_partial_shape(i).size() > 6) {return true;+ }}for (size_t i = 0; i < op->get_input_size(); i++) {- if (op->get_input_partial_shape(i).size() > 6)+ if (op->get_input_partial_shape(i).size() > 6) {return true;+ }}return false;@@ -250,12 +258,14 @@ void ExecutionConfig::apply_model_specific_options(const IRemoteContext* context// Trace MatMul weight input through the decompression subgraph// (Convert→Subtract→Multiply→Reshape→Convert→Constant) to check for 4-bit weights.auto has_4bit_matmul_weights = [](const std::shared_ptr<Node>& op) -> bool {- if (!ov::is_type<ov::op::v0::MatMul>(op))+ if (!ov::is_type<ov::op::v0::MatMul>(op)) {return false;+ }auto weight = op->get_input_node_shared_ptr(1);for (int depth = 0; depth < 8 && weight->get_input_size() > 0; ++depth) {- if (ov::is_type<ov::op::v0::Constant>(weight))+ if (ov::is_type<ov::op::v0::Constant>(weight)) {break;+ }weight = weight->get_input_node_shared_ptr(0);}if (auto constant = ov::as_type_ptr<ov::op::v0::Constant>(weight)) {@@ -347,10 +357,11 @@ void ExecutionConfig::finalize_impl(const IRemoteContext* context) {// Enable dynamic quantization by default for non-systolic platformsif (!is_set_by_user(ov::hint::dynamic_quantization_group_size) && get_dynamic_quantization_group_size() == 0) {- if (info.supports_immad)+ if (info.supports_immad) {m_dynamic_quantization_group_size = std::numeric_limits<uint64_t>::max();- else+ } else {m_dynamic_quantization_group_size = 32;+ }}if (!get_force_implementations().empty()) {@@ -394,10 +405,11 @@ void ExecutionConfig::apply_execution_hints(const cldnn::device_info& info) {if (mode == ov::hint::ExecutionMode::ACCURACY) {m_inference_precision = ov::element::dynamic;} else if (mode == ov::hint::ExecutionMode::PERFORMANCE) {- if (info.supports_fp16)+ if (info.supports_fp16) {m_inference_precision = ov::element::f16;- else+ } else {m_inference_precision = ov::element::f32;+ }}}}diff --git a/src/plugins/intel_gpu/src/runtime/format.cpp b/src/plugins/intel_gpu/src/runtime/format.cppindex c835344c502..af6ea474f21 100644--- a/src/plugins/intel_gpu/src/runtime/format.cpp+++ b/src/plugins/intel_gpu/src/runtime/format.cpp@@ -3,172 +3,205 @@//#include "intel_gpu/runtime/format.hpp"-#include "openvino/core/except.hpp"+#include <algorithm>#include <list>#include <vector>-#include <algorithm>-#define FMT_TRAITS(fmt, ...) {format::fmt, {#fmt, __VA_ARGS__}}+#include "openvino/core/except.hpp"++#define FMT_TRAITS(fmt, ...) \+ { \+ format::fmt, { \+ #fmt, __VA_ARGS__ \+ } \+ }namespace cldnn {-static const std::map<format::type, format_traits> format_traits_map {- // B - number of Batch dimensions- // F - number of Feature dimensions- // S - number of Spatial dimensions- // G - number of Group dimensions- // Order - dims changing order from rare to often- // Inner order - dims order for internal storage in _sizes array- // Block sizes - vector of pairs of dimension number (by inner order) and block size ordered from rare to often- // Format B F S G Dims order Order Inner order Block sizes Block Sizes (in logical order)- FMT_TRAITS(yxfb, 1, 1, 2, 0, {2, 3, 1, 0}, "yxfb", "bfxy", {}, {}), // NOLINT- FMT_TRAITS(byxf, 1, 1, 2, 0, {0, 2, 3, 1}, "byxf", "bfxy", {}, {}), // NOLINT- FMT_TRAITS(bfyx, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {}, {}), // NOLINT- FMT_TRAITS(bfxy, 1, 1, 2, 0, {0, 1, 3, 2}, "bfxy", "bfxy", {}, {}), // NOLINT- FMT_TRAITS(fbyx, 1, 1, 2, 0, {1, 0, 2, 3}, "fbyx", "bfxy", {}, {}), // NOLINT- FMT_TRAITS(fyxb, 1, 1, 2, 0, {1, 2, 3, 0}, "fyxb", "bfxy", {}, {}), // NOLINT- FMT_TRAITS(fybx, 1, 1, 2, 0, {1, 2, 0, 3}, "fybx", "bfxy", {}, {}), // NOLINT- FMT_TRAITS(xbfy, 1, 1, 2, 0, {3, 0, 1, 2}, "xbfy", "bfxy", {}, {}), // NOLINT- FMT_TRAITS(ybfx, 1, 1, 2, 0, {2, 0, 1, 3}, "ybfx", "bfxy", {}, {}), // NOLINT- FMT_TRAITS(byfx, 1, 1, 2, 0, {0, 2, 1, 3}, "byfx", "bfxy", {}, {}), // NOLINT- FMT_TRAITS(bxfy, 1, 1, 2, 0, {0, 3, 1, 2}, "bxfy", "bfxy", {}, {}), // NOLINT- FMT_TRAITS(b_fs_yx_fsv2, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{1, 2}}, {{1, 2}}), // NOLINT- FMT_TRAITS(b_fs_yx_fsv4, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{1, 4}}, {{1, 4}}), // NOLINT- FMT_TRAITS(b_fs_yx_fsv8, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{1, 8}}, {{1, 8}}), // NOLINT- FMT_TRAITS(b_fs_yx_fsv16, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{1, 16}}, {{1, 16}}), // NOLINT- FMT_TRAITS(b_fs_yx_fsv32, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{1, 32}}, {{1, 32}}), // NOLINT- FMT_TRAITS(b_fs_zyx_fsv2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{1, 2}}, {{1, 2}}), // NOLINT- FMT_TRAITS(b_fs_zyx_fsv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{1, 4}}, {{1, 4}}), // NOLINT- FMT_TRAITS(b_fs_zyx_fsv8, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{1, 8}}, {{1, 8}}), // NOLINT- FMT_TRAITS(b_fs_zyx_fsv32, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{1, 32}}, {{1, 32}}), // NOLINT- FMT_TRAITS(bs_fs_fsv8_bsv8, 1, 1, 0, 0, {0, 1}, "bf", "bf", {{0, 8}, {1, 8}}, {{0, 8}, {1, 8}}), // NOLINT- FMT_TRAITS(bs_fs_fsv8_bsv16, 1, 1, 0, 0, {0, 1}, "bf", "bf", {{0, 16}, {1, 8}}, {{0, 16}, {1, 8}}), // NOLINT- FMT_TRAITS(bs_f_bsv16, 1, 1, 0, 0, {0, 1}, "bf", "bf", {{0, 16}}, {{0, 16}}), // NOLINT- FMT_TRAITS(winograd_2x3_s1_data, 1, 1, 2, 0, {0, 2, 3, 1}, "bxyf", "bfxy", {}, {}), // NOLINT- FMT_TRAITS(bzyxf, 1, 1, 3, 0, {0, 2, 3, 4, 1}, "bzyxf", "bfxyz", {}, {}), // NOLINT- FMT_TRAITS(bfzyx, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {}, {}), // NOLINT- FMT_TRAITS(bfwzyx, 1, 1, 4, 0, {0, 1, 2, 3, 4, 5}, "bfwzyx", "bfxyzw", {}, {}), // NOLINT- FMT_TRAITS(bfuwzyx, 1, 1, 5, 0, {0, 1, 2, 3, 4, 5, 6}, "bfuwzyx", "bfxyzwu", {}, {}), // NOLINT- FMT_TRAITS(bfvuwzyx, 1, 1, 6, 0, {0, 1, 2, 3, 4, 5, 6, 7}, "bfvuwzyx", "bfxyzwuv", {}, {}), // NOLINT- FMT_TRAITS(fs_b_yx_fsv32, 1, 1, 2, 0, {1, 0, 2, 3}, "fbyx", "bfxy", {{1, 32}}, {{1, 32}}), // NOLINT- FMT_TRAITS(b_fs_zyx_fsv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{1, 16}}, {{1, 16}}), // NOLINT- FMT_TRAITS(bs_fs_zyx_bsv16_fsv32, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 16 }, {1, 32}}, {{0, 16 }, {1, 32}}), // NOLINT- FMT_TRAITS(bs_fs_zyx_bsv16_fsv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 16 }, {1, 16}}, {{0, 16 }, {1, 16}}), // NOLINT- FMT_TRAITS(bs_fs_yx_bsv16_fsv16, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 16 }, {1, 16}}, {{0, 16 }, {1, 16}}), // NOLINT- FMT_TRAITS(bs_fs_yx_bsv16_fsv32, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 16 }, {1, 32}}, {{0, 16 }, {1, 32}}), // NOLINT- FMT_TRAITS(bs_fs_yx_bsv4_fsv4, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 4 }, {1, 4}}, {{0, 4 }, {1, 4}}), // NOLINT- FMT_TRAITS(bs_fs_yx_bsv8_fsv4, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 8 }, {1, 4}}, {{0, 8 }, {1, 4}}), // NOLINT- FMT_TRAITS(bs_fs_zyx_bsv8_fsv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 8 }, {1, 4}}, {{0, 8 }, {1, 4}}), // NOLINT- FMT_TRAITS(bs_fs_yx_bsv16_fsv8, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 16 }, {1, 8}}, {{0, 16 }, {1, 8}}), // NOLINT- FMT_TRAITS(bs_fs_zyx_bsv16_fsv8, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 16 }, {1, 8}}, {{0, 16 }, {1, 8}}), // NOLINT- FMT_TRAITS(bs_fs_yx_bsv16_fsv4, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 16 }, {1, 4}}, {{0, 16 }, {1, 4}}), // NOLINT- FMT_TRAITS(bs_fs_zyx_bsv16_fsv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 16 }, {1, 4}}, {{0, 16 }, {1, 4}}), // NOLINT- FMT_TRAITS(bs_fs_yx_bsv16_fsv2, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 16 }, {1, 2}}, {{0, 16 }, {1, 2}}), // NOLINT- FMT_TRAITS(bs_fs_zyx_bsv16_fsv2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 16 }, {1, 2}}, {{0, 16 }, {1, 2}}), // NOLINT- FMT_TRAITS(bs_fs_yx_bsv8_fsv2, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 8 }, {1, 2}}, {{0, 8 }, {1, 2}}), // NOLINT- FMT_TRAITS(bs_fs_zyx_bsv8_fsv2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 8 }, {1, 2}}, {{0, 8 }, {1, 2}}), // NOLINT- FMT_TRAITS(bs_fs_yx_bsv4_fsv2, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 4 }, {1, 2}}, {{0, 4 }, {1, 2}}), // NOLINT- FMT_TRAITS(bs_fs_zyx_bsv4_fsv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 4 }, {1, 4}}, {{0, 4 }, {1, 4}}), // NOLINT- FMT_TRAITS(bs_fs_zyx_bsv4_fsv2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 4 }, {1, 2}}, {{0, 4 }, {1, 2}}), // NOLINT- FMT_TRAITS(bs_fs_zyx_bsv32_fsv32, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 32 }, {1, 32}}, {{0, 32 }, {1, 32}}), // NOLINT- FMT_TRAITS(bs_fs_zyx_bsv32_fsv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 32 }, {1, 16}}, {{0, 32 }, {1, 16}}), // NOLINT- FMT_TRAITS(bs_fs_yx_bsv32_fsv32, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 32 }, {1, 32}}, {{0, 32 }, {1, 32}}), // NOLINT- FMT_TRAITS(bs_fs_yx_bsv32_fsv16, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 32 }, {1, 16}}, {{0, 32 }, {1, 16}}), // NOLINT- FMT_TRAITS(nv12, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {}, {}), // NOLINT- FMT_TRAITS(image_2d_rgba, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {}, {}), // NOLINT-- FMT_TRAITS(oiyx, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {}, {}), // NOLINT- FMT_TRAITS(ioyx, 1, 1, 2, 0, {1, 0, 2, 3}, "ioyx", "oixy", {}, {}), // NOLINT- FMT_TRAITS(iyxo, 1, 1, 2, 0, {1, 2, 3, 0}, "iyxo", "oixy", {}, {}), // NOLINT- FMT_TRAITS(oyxi, 1, 1, 2, 0, {0, 2, 3, 1}, "oyxi", "oixy", {}, {}), // NOLINT- FMT_TRAITS(oyix, 1, 1, 2, 0, {0, 2, 1, 3}, "oyix", "oixy", {}, {}), // NOLINT- FMT_TRAITS(oxiy, 1, 1, 2, 0, {0, 3, 1, 2}, "oxiy", "oixy", {}, {}), // NOLINT- FMT_TRAITS(yxio, 1, 1, 2, 0, {2, 3, 1, 0}, "yxio", "oixy", {}, {}), // NOLINT- FMT_TRAITS(oizyx, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {}, {}), // NOLINT- FMT_TRAITS(iozyx, 1, 1, 3, 0, {1, 0, 2, 3, 4}, "iozyx", "oixyz", {}, {}), // NOLINT- FMT_TRAITS(os_is_yx_isv16_osv16, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 16}, {0, 16}}, {{1, 16}, {0, 16}}), // NOLINT- FMT_TRAITS(o_is_yx_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 4}}, {{1, 4}}), // NOLINT- FMT_TRAITS(o_is_yx_isv16, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 16}}, {{1, 16}}), // NOLINT- FMT_TRAITS(os_iyx_osv16, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 16}}, {{0, 16}}), // NOLINT- FMT_TRAITS(os_iyx_osv32, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}}, {{0, 32}}), // NOLINT- FMT_TRAITS(os_iyx_osv64, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 64}}, {{0, 64}}), // NOLINT- FMT_TRAITS(winograd_2x3_s1_weights, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {}, {}), // NOLINT- FMT_TRAITS(winograd_2x3_s1_fused_weights, 1, 1, 2, 0, {3, 2, 1, 0}, "xyio", "oixy", {}, {}), // NOLINT- FMT_TRAITS(winograd_6x3_s1_fused_weights, 1, 1, 2, 0, {3, 2, 1, 0}, "xyio", "oixy", {}, {}), // NOLINT- FMT_TRAITS(image_2d_weights_winograd_6x3_s1_fbxyb, 1, 1, 2, 0, {1, 0, 3, 2}, "ioxy", "oixy", {}, {}), // NOLINT- FMT_TRAITS(image_2d_weights_winograd_6x3_s1_xfbyb, 1, 1, 2, 0, {3, 1, 0, 2}, "xioy", "oixy", {}, {}), // NOLINT- FMT_TRAITS(image_2d_weights_c4_fyx_b, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {}, {}), // NOLINT- FMT_TRAITS(image_2d_weights_c1_b_fyx, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {}, {}), // NOLINT- FMT_TRAITS(os_is_yx_isa8_osv16_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 8}, {0, 16}, {1, 4}}, {{1, 8}, {0, 16}, {1, 4}}), // NOLINT- FMT_TRAITS(os_is_yx_osa4_isa8_osv8_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 4}, {1, 8}, {0, 8}, {1, 4}}, {{0, 4}, {1, 8}, {0, 8}, {1, 4}}), // NOLINT- FMT_TRAITS(os_is_zyx_osa4_isa8_osv8_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 4}, {1, 8}, {0, 8}, {1, 4}}, {{0, 4}, {1, 8}, {0, 8}, {1, 4}}), // NOLINT- FMT_TRAITS(os_is_zyx_isa8_osv8_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 8}, {0, 8}, {1, 4}}, {{1, 8}, {0, 8}, {1, 4}}), // NOLINT- FMT_TRAITS(os_is_zyx_isa8_osv16_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 8}, {0, 16}, {1, 4}}, {{1, 8}, {0, 16}, {1, 4}}), // NOLINT- FMT_TRAITS(os_is_yx_osa4_isa8_osv8_isv4_swizzled_by_4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}, {1, 32}}, {{0, 32}, {1, 32}}), // NOLINT- FMT_TRAITS(os_is_zyx_osa4_isa8_osv8_isv4_swizzled_by_4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 32}, {1, 32}}, {{0, 32}, {1, 32}}), // NOLINT- FMT_TRAITS(os_is_yx_osa2_isa8_osv16_isv4_swizzled_by_2, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}, {1, 32}}, {{0, 32}, {1, 32}}), // NOLINT- FMT_TRAITS(os_is_zyx_osa2_isa8_osv16_isv4_swizzled_by_2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 32}, {1, 32}}, {{0, 32}, {1, 32}}), // NOLINT- FMT_TRAITS(os_is_yx_osv16_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 16}, {1, 4}}, {{0, 16}, {1, 4}}), // NOLINT- FMT_TRAITS(os_is_yx_osv8_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 8}, {1, 4}}, {{0, 8}, {1, 4}}), // NOLINT- FMT_TRAITS(os_is_zyx_osv16_isv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 16}, {1, 16}}, {{0, 16}, {1, 16}}), // NOLINT- FMT_TRAITS(os_is_yx_osv32_isv4_swizzled_by_2, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}, {1, 4}}, {{0, 32}, {1, 4}}), // NOLINT- FMT_TRAITS(os_is_yx_osv32_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}, {1, 4}}, {{0, 32}, {1, 4}}), // NOLINT- FMT_TRAITS(os_is_zyx_osv32_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 32}, {1, 4}}, {{0, 32}, {1, 4}}), // NOLINT- FMT_TRAITS(os_is_zyx_isv16_osv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 16}, {0, 16}}, {{1, 16}, {0, 16}}), // NOLINT- FMT_TRAITS(is_os_zyx_isv16_osv16, 1, 1, 3, 0, {1, 0, 2, 3, 4}, "iozyx", "oixyz", {{1, 16}, {0, 16}}, {{1, 16}, {0, 16}}), // NOLINT- FMT_TRAITS(is_os_yx_isv16_osv16, 1, 1, 2, 0, {1, 0, 2, 3}, "ioyx", "oixy", {{1, 16}, {0, 16}}, {{1, 16}, {0, 16}}), // NOLINT- FMT_TRAITS(os_is_zyx_isa8_osv8_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 8}, {0, 8}, {1, 4}}, {{1, 8}, {0, 8}, {1, 4}}), // NOLINT- FMT_TRAITS(os_is_zyx_isa8_osv16_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 8}, {0, 16}, {1, 4}}, {{1, 8}, {0, 16}, {1, 4}}), // NOLINT- FMT_TRAITS(os_is_yx_isa8_osv8_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 8}, {0, 8}, {1, 4}}, {{1, 8}, {0, 8}, {1, 4}}), // NOLINT- FMT_TRAITS(os_is_zyx_isv8_osv16_isv2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 8}, {0, 16}, {1, 2}}, {{1, 8}, {0, 16}, {1, 2}}), // NOLINT- FMT_TRAITS(os_zyxi_osv16, 1, 1, 3, 0, {0, 2, 3, 4, 1}, "ozyxi", "oixyz", {{0, 16}}, {{0, 16}}), // NOLINT- FMT_TRAITS(os_is_yx_isv8_osv16_isv2, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 8}, {0, 16}, {1, 2}}, {{1, 8}, {0, 16}, {1, 2}}), // NOLINT- FMT_TRAITS(os_is_yx_osv16_isv16, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 16}, {1, 16}}, {{0, 16}, {1, 16}}), // NOLINT- FMT_TRAITS(os_is_yx_osv32_isv2, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}}, {{0, 32}}), // NOLINT- FMT_TRAITS(os_is_yx_osv64_isv2, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 64}}, {{0, 64}}), // NOLINT- FMT_TRAITS(os_is_zyx_osv32_isv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 32}, {1, 16}}, {{0, 32}, {1, 16}}), // NOLINT- FMT_TRAITS(os_is_zyx_osv64_isv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 64}, {1, 16}}, {{0, 64}, {1, 16}}), // NOLINT- FMT_TRAITS(os_iyx_osv8, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 8}}, {{0, 8}}), // NOLINT- FMT_TRAITS(os_iyx_osv32__ai32, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}}, {{0, 32}}), // NOLINT- FMT_TRAITS(i_yxs_os_yxsv2_osv16, 1, 1, 2, 0, {1, 2, 3, 0}, "iyxo", "oixy", {{0, 16}}, {{0, 16}}), // NOLINT- FMT_TRAITS(iy_xs_os_xsv2_osv8__ao32, 1, 1, 2, 0, {1, 2, 3, 0}, "iyxo", "oixy", {{2, 2}, {0, 8}}, {{3, 2}, {0, 8}}), // NOLINT- FMT_TRAITS(iy_xs_os_xsv2_osv16__ao32, 1, 1, 2, 0, {1, 2, 3, 0}, "iyxo", "oixy", {{2, 2}, {0, 16}}, {{3, 2}, {0, 16}}), // NOLINT- FMT_TRAITS(os_i_osv16, 1, 1, 0, 0, {0, 1}, "oi", "oi", {{0, 16}}, {{0, 16}}), // NOLINT- FMT_TRAITS(os_i_osv16__ai8, 1, 1, 0, 0, {0, 1}, "oi", "oi", {{1, 8}, {0, 16}}, {{1, 8}, {0, 16}}), // NOLINT- FMT_TRAITS(os_i_osv8__ai8, 1, 1, 0, 0, {0, 1}, "oi", "oi", {{1, 8}, {0, 8}}, {{1, 8}, {0, 8}}), // NOLINT-- FMT_TRAITS(goiyx, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {}, {}), // NOLINT- FMT_TRAITS(gioyx, 1, 1, 2, 1, {0, 2, 1, 3, 4}, "gioyx", "oixy????g", {}, {}), // NOLINT- FMT_TRAITS(goizyx, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "goizyx", "oixyz???g", {}, {}), // NOLINT- FMT_TRAITS(giozyx, 1, 1, 3, 1, {0, 2, 1, 3, 4, 5}, "giozyx", "oixyz???g", {}, {}), // NOLINT- FMT_TRAITS(g_os_iyx_osv8, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{0, 8}}, {{1, 8}}), // NOLINT- FMT_TRAITS(g_os_iyx_osv16, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{0, 16}}, {{1, 16}}), // NOLINT- FMT_TRAITS(g_os_iyx_osv32, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{0, 32}}, {{1, 32}}), // NOLINT- FMT_TRAITS(gs_oiyx_gsv16, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{8, 16}}, {{0, 16}}), // NOLINT- FMT_TRAITS(gs_oizyx_gsv16, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "goizyx", "oixyz???g", {{8, 16}}, {{0, 16}}), // NOLINT- FMT_TRAITS(gs_oiyx_gsv32, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{8, 32}}, {{0, 32}}), // NOLINT- FMT_TRAITS(gyxio, 1, 1, 2, 1, {0, 3, 4, 2, 1}, "gyxio", "oixy????g", {}, {}), // NOLINT- FMT_TRAITS(g_is_os_zyx_isv16_osv16, 1, 1, 3, 1, {0, 2, 1, 3, 4, 5}, "giozyx", "oixyz???g", {{1, 16}, {0, 16}}, {{2, 16}, {1, 16}}), // NOLINT- FMT_TRAITS(g_is_os_yx_isv16_osv16, 1, 1, 2, 1, {0, 2, 1, 3, 4}, "gioyx", "oixy????g", {{1, 16}, {0, 16}}, {{2, 16}, {1, 16}}), // NOLINT- FMT_TRAITS(g_os_is_zyx_isv8_osv16_isv2, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "goizyx", "oixyz???g", {{1, 8}, {0, 16}, {1, 2}}, {{2, 8}, {1, 16}, {2, 2}}), // NOLINT- FMT_TRAITS(g_os_is_yx_isv8_osv16_isv2, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{1, 8}, {0, 16}, {1, 2}}, {{2, 8}, {1, 16}, {2, 2}}), // NOLINT- FMT_TRAITS(g_os_is_zyx_isv16_osv16, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "goizyx", "oixyz???g", {{0, 16}, {1, 16}}, {{1, 16}, {2, 16}}), // NOLINT- FMT_TRAITS(g_os_is_yx_osv16_isv4, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{0, 16}, {1, 4}}, {{1, 16}, {2, 4}}), // NOLINT- FMT_TRAITS(g_os_is_zyx_osv16_isv16, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "goizyx", "oixyz???g", {{0, 16}, {1, 16}}, {{1, 16}, {2, 16}}), // NOLINT- FMT_TRAITS(g_os_zyx_is_osv16_isv4, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 16}, {1, 4}}, {{1, 16}, {5, 4}}), // NOLINT- FMT_TRAITS(g_os_zyx_is_osv16_isv16, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 16}, {1, 16}}, {{1, 16}, {5, 16}}), // NOLINT- FMT_TRAITS(g_os_zyx_is_osv16_isv32, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 16}, {1, 32}}, {{1, 16}, {5, 32}}), // NOLINT- FMT_TRAITS(g_os_zyx_is_osv32_isv4, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 32}, {1, 4}}, {{1, 32}, {5, 4}}), // NOLINT- FMT_TRAITS(g_os_zyx_is_osv32_isv16, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 32}, {1, 16}}, {{1, 32}, {5, 16}}), // NOLINT- FMT_TRAITS(g_os_zyx_is_osv32_isv32, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 32}, {1, 32}}, {{1, 32}, {5, 32}}), // NOLINT- FMT_TRAITS(gs_oi_yxs_gsv4_yxsv4, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{8, 4}}, {{0, 4}}), // NOLINT- FMT_TRAITS(gs_oi_yxs_gsv16_yxsv4, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{8, 16}}, {{0, 16}}), // NOLINT- FMT_TRAITS(gs_oi_yxs_gsv32_yxsv4, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{8, 32}}, {{0, 32}}), // NOLINT- FMT_TRAITS(g_os_is_yx_isv16_osv16, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{1, 16}, {0, 16}}, {{2, 16}, {1, 16}}), // NOLINT- FMT_TRAITS(gi_yxs_os_yxsv2_osv16, 1, 1, 2, 1, {0, 2, 3, 4, 1}, "giyxo", "oixy????g", {{0, 16}}, {{1, 16}}), // NOLINT- FMT_TRAITS(giy_xs_os_xsv2_osv8__ao32, 1, 1, 2, 1, {0, 2, 3, 4, 1}, "giyxo", "oixy????g", {{2, 2}, {0, 8}}, {{4, 2}, {1, 8}}), // NOLINT- FMT_TRAITS(giy_xs_os_xsv2_osv16__ao32, 1, 1, 2, 1, {0, 2, 3, 4, 1}, "giyxo", "oixy????g", {{2, 2}, {0, 16}}, {{4, 2}, {1, 16}}), // NOLINT+static const std::map<format::type, format_traits> format_traits_map{+ // B - number of Batch dimensions+ // F - number of Feature dimensions+ // S - number of Spatial dimensions+ // G - number of Group dimensions+ // Order - dims changing order from rare to often+ // Inner order - dims order for internal storage in _sizes array+ // Block sizes - vector of pairs of dimension number (by inner order) and block size ordered from rare to often+ // Format B F S G Dims order Order Inner order Block sizes Block Sizes (in logical order)+ FMT_TRAITS(yxfb, 1, 1, 2, 0, {2, 3, 1, 0}, "yxfb", "bfxy", {}, {}), // NOLINT+ FMT_TRAITS(byxf, 1, 1, 2, 0, {0, 2, 3, 1}, "byxf", "bfxy", {}, {}), // NOLINT+ FMT_TRAITS(bfyx, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {}, {}), // NOLINT+ FMT_TRAITS(bfxy, 1, 1, 2, 0, {0, 1, 3, 2}, "bfxy", "bfxy", {}, {}), // NOLINT+ FMT_TRAITS(fbyx, 1, 1, 2, 0, {1, 0, 2, 3}, "fbyx", "bfxy", {}, {}), // NOLINT+ FMT_TRAITS(fyxb, 1, 1, 2, 0, {1, 2, 3, 0}, "fyxb", "bfxy", {}, {}), // NOLINT+ FMT_TRAITS(fybx, 1, 1, 2, 0, {1, 2, 0, 3}, "fybx", "bfxy", {}, {}), // NOLINT+ FMT_TRAITS(xbfy, 1, 1, 2, 0, {3, 0, 1, 2}, "xbfy", "bfxy", {}, {}), // NOLINT+ FMT_TRAITS(ybfx, 1, 1, 2, 0, {2, 0, 1, 3}, "ybfx", "bfxy", {}, {}), // NOLINT+ FMT_TRAITS(byfx, 1, 1, 2, 0, {0, 2, 1, 3}, "byfx", "bfxy", {}, {}), // NOLINT+ FMT_TRAITS(bxfy, 1, 1, 2, 0, {0, 3, 1, 2}, "bxfy", "bfxy", {}, {}), // NOLINT+ FMT_TRAITS(b_fs_yx_fsv2, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{1, 2}}, {{1, 2}}), // NOLINT+ FMT_TRAITS(b_fs_yx_fsv4, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{1, 4}}, {{1, 4}}), // NOLINT+ FMT_TRAITS(b_fs_yx_fsv8, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{1, 8}}, {{1, 8}}), // NOLINT+ FMT_TRAITS(b_fs_yx_fsv16, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{1, 16}}, {{1, 16}}), // NOLINT+ FMT_TRAITS(b_fs_yx_fsv32, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{1, 32}}, {{1, 32}}), // NOLINT+ FMT_TRAITS(b_fs_zyx_fsv2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{1, 2}}, {{1, 2}}), // NOLINT+ FMT_TRAITS(b_fs_zyx_fsv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{1, 4}}, {{1, 4}}), // NOLINT+ FMT_TRAITS(b_fs_zyx_fsv8, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{1, 8}}, {{1, 8}}), // NOLINT+ FMT_TRAITS(b_fs_zyx_fsv32, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{1, 32}}, {{1, 32}}), // NOLINT+ FMT_TRAITS(bs_fs_fsv8_bsv8, 1, 1, 0, 0, {0, 1}, "bf", "bf", {{0, 8}, {1, 8}}, {{0, 8}, {1, 8}}), // NOLINT+ FMT_TRAITS(bs_fs_fsv8_bsv16, 1, 1, 0, 0, {0, 1}, "bf", "bf", {{0, 16}, {1, 8}}, {{0, 16}, {1, 8}}), // NOLINT+ FMT_TRAITS(bs_f_bsv16, 1, 1, 0, 0, {0, 1}, "bf", "bf", {{0, 16}}, {{0, 16}}), // NOLINT+ FMT_TRAITS(winograd_2x3_s1_data, 1, 1, 2, 0, {0, 2, 3, 1}, "bxyf", "bfxy", {}, {}), // NOLINT+ FMT_TRAITS(bzyxf, 1, 1, 3, 0, {0, 2, 3, 4, 1}, "bzyxf", "bfxyz", {}, {}), // NOLINT+ FMT_TRAITS(bfzyx, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {}, {}), // NOLINT+ FMT_TRAITS(bfwzyx, 1, 1, 4, 0, {0, 1, 2, 3, 4, 5}, "bfwzyx", "bfxyzw", {}, {}), // NOLINT+ FMT_TRAITS(bfuwzyx, 1, 1, 5, 0, {0, 1, 2, 3, 4, 5, 6}, "bfuwzyx", "bfxyzwu", {}, {}), // NOLINT+ FMT_TRAITS(bfvuwzyx, 1, 1, 6, 0, {0, 1, 2, 3, 4, 5, 6, 7}, "bfvuwzyx", "bfxyzwuv", {}, {}), // NOLINT+ FMT_TRAITS(fs_b_yx_fsv32, 1, 1, 2, 0, {1, 0, 2, 3}, "fbyx", "bfxy", {{1, 32}}, {{1, 32}}), // NOLINT+ FMT_TRAITS(b_fs_zyx_fsv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{1, 16}}, {{1, 16}}), // NOLINT+ FMT_TRAITS(bs_fs_zyx_bsv16_fsv32, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 16}, {1, 32}}, {{0, 16}, {1, 32}}), // NOLINT+ FMT_TRAITS(bs_fs_zyx_bsv16_fsv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 16}, {1, 16}}, {{0, 16}, {1, 16}}), // NOLINT+ FMT_TRAITS(bs_fs_yx_bsv16_fsv16, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 16}, {1, 16}}, {{0, 16}, {1, 16}}), // NOLINT+ FMT_TRAITS(bs_fs_yx_bsv16_fsv32, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 16}, {1, 32}}, {{0, 16}, {1, 32}}), // NOLINT+ FMT_TRAITS(bs_fs_yx_bsv4_fsv4, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 4}, {1, 4}}, {{0, 4}, {1, 4}}), // NOLINT+ FMT_TRAITS(bs_fs_yx_bsv8_fsv4, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 8}, {1, 4}}, {{0, 8}, {1, 4}}), // NOLINT+ FMT_TRAITS(bs_fs_zyx_bsv8_fsv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 8}, {1, 4}}, {{0, 8}, {1, 4}}), // NOLINT+ FMT_TRAITS(bs_fs_yx_bsv16_fsv8, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 16}, {1, 8}}, {{0, 16}, {1, 8}}), // NOLINT+ FMT_TRAITS(bs_fs_zyx_bsv16_fsv8, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 16}, {1, 8}}, {{0, 16}, {1, 8}}), // NOLINT+ FMT_TRAITS(bs_fs_yx_bsv16_fsv4, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 16}, {1, 4}}, {{0, 16}, {1, 4}}), // NOLINT+ FMT_TRAITS(bs_fs_zyx_bsv16_fsv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 16}, {1, 4}}, {{0, 16}, {1, 4}}), // NOLINT+ FMT_TRAITS(bs_fs_yx_bsv16_fsv2, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 16}, {1, 2}}, {{0, 16}, {1, 2}}), // NOLINT+ FMT_TRAITS(bs_fs_zyx_bsv16_fsv2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 16}, {1, 2}}, {{0, 16}, {1, 2}}), // NOLINT+ FMT_TRAITS(bs_fs_yx_bsv8_fsv2, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 8}, {1, 2}}, {{0, 8}, {1, 2}}), // NOLINT+ FMT_TRAITS(bs_fs_zyx_bsv8_fsv2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 8}, {1, 2}}, {{0, 8}, {1, 2}}), // NOLINT+ FMT_TRAITS(bs_fs_yx_bsv4_fsv2, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 4}, {1, 2}}, {{0, 4}, {1, 2}}), // NOLINT+ FMT_TRAITS(bs_fs_zyx_bsv4_fsv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 4}, {1, 4}}, {{0, 4}, {1, 4}}), // NOLINT+ FMT_TRAITS(bs_fs_zyx_bsv4_fsv2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 4}, {1, 2}}, {{0, 4}, {1, 2}}), // NOLINT+ FMT_TRAITS(bs_fs_zyx_bsv32_fsv32, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 32}, {1, 32}}, {{0, 32}, {1, 32}}), // NOLINT+ FMT_TRAITS(bs_fs_zyx_bsv32_fsv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 32}, {1, 16}}, {{0, 32}, {1, 16}}), // NOLINT+ FMT_TRAITS(bs_fs_yx_bsv32_fsv32, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 32}, {1, 32}}, {{0, 32}, {1, 32}}), // NOLINT+ FMT_TRAITS(bs_fs_yx_bsv32_fsv16, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 32}, {1, 16}}, {{0, 32}, {1, 16}}), // NOLINT+ FMT_TRAITS(nv12, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {}, {}), // NOLINT+ FMT_TRAITS(image_2d_rgba, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {}, {}), // NOLINT++ FMT_TRAITS(oiyx, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {}, {}), // NOLINT+ FMT_TRAITS(ioyx, 1, 1, 2, 0, {1, 0, 2, 3}, "ioyx", "oixy", {}, {}), // NOLINT+ FMT_TRAITS(iyxo, 1, 1, 2, 0, {1, 2, 3, 0}, "iyxo", "oixy", {}, {}), // NOLINT+ FMT_TRAITS(oyxi, 1, 1, 2, 0, {0, 2, 3, 1}, "oyxi", "oixy", {}, {}), // NOLINT+ FMT_TRAITS(oyix, 1, 1, 2, 0, {0, 2, 1, 3}, "oyix", "oixy", {}, {}), // NOLINT+ FMT_TRAITS(oxiy, 1, 1, 2, 0, {0, 3, 1, 2}, "oxiy", "oixy", {}, {}), // NOLINT+ FMT_TRAITS(yxio, 1, 1, 2, 0, {2, 3, 1, 0}, "yxio", "oixy", {}, {}), // NOLINT+ FMT_TRAITS(oizyx, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {}, {}), // NOLINT+ FMT_TRAITS(iozyx, 1, 1, 3, 0, {1, 0, 2, 3, 4}, "iozyx", "oixyz", {}, {}), // NOLINT+ FMT_TRAITS(os_is_yx_isv16_osv16, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 16}, {0, 16}}, {{1, 16}, {0, 16}}), // NOLINT+ FMT_TRAITS(o_is_yx_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 4}}, {{1, 4}}), // NOLINT+ FMT_TRAITS(o_is_yx_isv16, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 16}}, {{1, 16}}), // NOLINT+ FMT_TRAITS(os_iyx_osv16, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 16}}, {{0, 16}}), // NOLINT+ FMT_TRAITS(os_iyx_osv32, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}}, {{0, 32}}), // NOLINT+ FMT_TRAITS(os_iyx_osv64, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 64}}, {{0, 64}}), // NOLINT+ FMT_TRAITS(winograd_2x3_s1_weights, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {}, {}), // NOLINT+ FMT_TRAITS(winograd_2x3_s1_fused_weights, 1, 1, 2, 0, {3, 2, 1, 0}, "xyio", "oixy", {}, {}), // NOLINT+ FMT_TRAITS(winograd_6x3_s1_fused_weights, 1, 1, 2, 0, {3, 2, 1, 0}, "xyio", "oixy", {}, {}), // NOLINT+ FMT_TRAITS(image_2d_weights_winograd_6x3_s1_fbxyb, 1, 1, 2, 0, {1, 0, 3, 2}, "ioxy", "oixy", {}, {}), // NOLINT+ FMT_TRAITS(image_2d_weights_winograd_6x3_s1_xfbyb, 1, 1, 2, 0, {3, 1, 0, 2}, "xioy", "oixy", {}, {}), // NOLINT+ FMT_TRAITS(image_2d_weights_c4_fyx_b, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {}, {}), // NOLINT+ FMT_TRAITS(image_2d_weights_c1_b_fyx, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {}, {}), // NOLINT+ FMT_TRAITS(os_is_yx_isa8_osv16_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 8}, {0, 16}, {1, 4}}, {{1, 8}, {0, 16}, {1, 4}}), // NOLINT+ FMT_TRAITS(os_is_yx_osa4_isa8_osv8_isv4,+ 1,+ 1,+ 2,+ 0,+ {0, 1, 2, 3},+ "oiyx",+ "oixy",+ {{0, 4}, {1, 8}, {0, 8}, {1, 4}},+ {{0, 4}, {1, 8}, {0, 8}, {1, 4}}), // NOLINT+ FMT_TRAITS(os_is_zyx_osa4_isa8_osv8_isv4,+ 1,+ 1,+ 3,+ 0,+ {0, 1, 2, 3, 4},+ "oizyx",+ "oixyz",+ {{0, 4}, {1, 8}, {0, 8}, {1, 4}},+ {{0, 4}, {1, 8}, {0, 8}, {1, 4}}), // NOLINT+ FMT_TRAITS(os_is_zyx_isa8_osv8_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 8}, {0, 8}, {1, 4}}, {{1, 8}, {0, 8}, {1, 4}}), // NOLINT+ FMT_TRAITS(os_is_zyx_isa8_osv16_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 8}, {0, 16}, {1, 4}}, {{1, 8}, {0, 16}, {1, 4}}), // NOLINT+ FMT_TRAITS(os_is_yx_osa4_isa8_osv8_isv4_swizzled_by_4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}, {1, 32}}, {{0, 32}, {1, 32}}), // NOLINT+ FMT_TRAITS(os_is_zyx_osa4_isa8_osv8_isv4_swizzled_by_4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 32}, {1, 32}}, {{0, 32}, {1, 32}}), // NOLINT+ FMT_TRAITS(os_is_yx_osa2_isa8_osv16_isv4_swizzled_by_2, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}, {1, 32}}, {{0, 32}, {1, 32}}), // NOLINT+ FMT_TRAITS(os_is_zyx_osa2_isa8_osv16_isv4_swizzled_by_2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 32}, {1, 32}}, {{0, 32}, {1, 32}}), // NOLINT+ FMT_TRAITS(os_is_yx_osv16_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 16}, {1, 4}}, {{0, 16}, {1, 4}}), // NOLINT+ FMT_TRAITS(os_is_yx_osv8_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 8}, {1, 4}}, {{0, 8}, {1, 4}}), // NOLINT+ FMT_TRAITS(os_is_zyx_osv16_isv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 16}, {1, 16}}, {{0, 16}, {1, 16}}), // NOLINT+ FMT_TRAITS(os_is_yx_osv32_isv4_swizzled_by_2, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}, {1, 4}}, {{0, 32}, {1, 4}}), // NOLINT+ FMT_TRAITS(os_is_yx_osv32_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}, {1, 4}}, {{0, 32}, {1, 4}}), // NOLINT+ FMT_TRAITS(os_is_zyx_osv32_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 32}, {1, 4}}, {{0, 32}, {1, 4}}), // NOLINT+ FMT_TRAITS(os_is_zyx_isv16_osv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 16}, {0, 16}}, {{1, 16}, {0, 16}}), // NOLINT+ FMT_TRAITS(is_os_zyx_isv16_osv16, 1, 1, 3, 0, {1, 0, 2, 3, 4}, "iozyx", "oixyz", {{1, 16}, {0, 16}}, {{1, 16}, {0, 16}}), // NOLINT+ FMT_TRAITS(is_os_yx_isv16_osv16, 1, 1, 2, 0, {1, 0, 2, 3}, "ioyx", "oixy", {{1, 16}, {0, 16}}, {{1, 16}, {0, 16}}), // NOLINT+ FMT_TRAITS(os_is_zyx_isa8_osv8_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 8}, {0, 8}, {1, 4}}, {{1, 8}, {0, 8}, {1, 4}}), // NOLINT+ FMT_TRAITS(os_is_zyx_isa8_osv16_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 8}, {0, 16}, {1, 4}}, {{1, 8}, {0, 16}, {1, 4}}), // NOLINT+ FMT_TRAITS(os_is_yx_isa8_osv8_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 8}, {0, 8}, {1, 4}}, {{1, 8}, {0, 8}, {1, 4}}), // NOLINT+ FMT_TRAITS(os_is_zyx_isv8_osv16_isv2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 8}, {0, 16}, {1, 2}}, {{1, 8}, {0, 16}, {1, 2}}), // NOLINT+ FMT_TRAITS(os_zyxi_osv16, 1, 1, 3, 0, {0, 2, 3, 4, 1}, "ozyxi", "oixyz", {{0, 16}}, {{0, 16}}), // NOLINT+ FMT_TRAITS(os_is_yx_isv8_osv16_isv2, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 8}, {0, 16}, {1, 2}}, {{1, 8}, {0, 16}, {1, 2}}), // NOLINT+ FMT_TRAITS(os_is_yx_osv16_isv16, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 16}, {1, 16}}, {{0, 16}, {1, 16}}), // NOLINT+ FMT_TRAITS(os_is_yx_osv32_isv2, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}}, {{0, 32}}), // NOLINT+ FMT_TRAITS(os_is_yx_osv64_isv2, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 64}}, {{0, 64}}), // NOLINT+ FMT_TRAITS(os_is_zyx_osv32_isv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 32}, {1, 16}}, {{0, 32}, {1, 16}}), // NOLINT+ FMT_TRAITS(os_is_zyx_osv64_isv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 64}, {1, 16}}, {{0, 64}, {1, 16}}), // NOLINT+ FMT_TRAITS(os_iyx_osv8, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 8}}, {{0, 8}}), // NOLINT+ FMT_TRAITS(os_iyx_osv32__ai32, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}}, {{0, 32}}), // NOLINT+ FMT_TRAITS(i_yxs_os_yxsv2_osv16, 1, 1, 2, 0, {1, 2, 3, 0}, "iyxo", "oixy", {{0, 16}}, {{0, 16}}), // NOLINT+ FMT_TRAITS(iy_xs_os_xsv2_osv8__ao32, 1, 1, 2, 0, {1, 2, 3, 0}, "iyxo", "oixy", {{2, 2}, {0, 8}}, {{3, 2}, {0, 8}}), // NOLINT+ FMT_TRAITS(iy_xs_os_xsv2_osv16__ao32, 1, 1, 2, 0, {1, 2, 3, 0}, "iyxo", "oixy", {{2, 2}, {0, 16}}, {{3, 2}, {0, 16}}), // NOLINT+ FMT_TRAITS(os_i_osv16, 1, 1, 0, 0, {0, 1}, "oi", "oi", {{0, 16}}, {{0, 16}}), // NOLINT+ FMT_TRAITS(os_i_osv16__ai8, 1, 1, 0, 0, {0, 1}, "oi", "oi", {{1, 8}, {0, 16}}, {{1, 8}, {0, 16}}), // NOLINT+ FMT_TRAITS(os_i_osv8__ai8, 1, 1, 0, 0, {0, 1}, "oi", "oi", {{1, 8}, {0, 8}}, {{1, 8}, {0, 8}}), // NOLINT++ FMT_TRAITS(goiyx, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {}, {}), // NOLINT+ FMT_TRAITS(gioyx, 1, 1, 2, 1, {0, 2, 1, 3, 4}, "gioyx", "oixy????g", {}, {}), // NOLINT+ FMT_TRAITS(goizyx, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "goizyx", "oixyz???g", {}, {}), // NOLINT+ FMT_TRAITS(giozyx, 1, 1, 3, 1, {0, 2, 1, 3, 4, 5}, "giozyx", "oixyz???g", {}, {}), // NOLINT+ FMT_TRAITS(g_os_iyx_osv8, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{0, 8}}, {{1, 8}}), // NOLINT+ FMT_TRAITS(g_os_iyx_osv16, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{0, 16}}, {{1, 16}}), // NOLINT+ FMT_TRAITS(g_os_iyx_osv32, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{0, 32}}, {{1, 32}}), // NOLINT+ FMT_TRAITS(gs_oiyx_gsv16, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{8, 16}}, {{0, 16}}), // NOLINT+ FMT_TRAITS(gs_oizyx_gsv16, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "goizyx", "oixyz???g", {{8, 16}}, {{0, 16}}), // NOLINT+ FMT_TRAITS(gs_oiyx_gsv32, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{8, 32}}, {{0, 32}}), // NOLINT+ FMT_TRAITS(gyxio, 1, 1, 2, 1, {0, 3, 4, 2, 1}, "gyxio", "oixy????g", {}, {}), // NOLINT+ FMT_TRAITS(g_is_os_zyx_isv16_osv16, 1, 1, 3, 1, {0, 2, 1, 3, 4, 5}, "giozyx", "oixyz???g", {{1, 16}, {0, 16}}, {{2, 16}, {1, 16}}), // NOLINT+ FMT_TRAITS(g_is_os_yx_isv16_osv16, 1, 1, 2, 1, {0, 2, 1, 3, 4}, "gioyx", "oixy????g", {{1, 16}, {0, 16}}, {{2, 16}, {1, 16}}), // NOLINT+ FMT_TRAITS(g_os_is_zyx_isv8_osv16_isv2,+ 1,+ 1,+ 3,+ 1,+ {0, 1, 2, 3, 4, 5},+ "goizyx",+ "oixyz???g",+ {{1, 8}, {0, 16}, {1, 2}},+ {{2, 8}, {1, 16}, {2, 2}}), // NOLINT+ FMT_TRAITS(g_os_is_yx_isv8_osv16_isv2, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{1, 8}, {0, 16}, {1, 2}}, {{2, 8}, {1, 16}, {2, 2}}), // NOLINT+ FMT_TRAITS(g_os_is_zyx_isv16_osv16, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "goizyx", "oixyz???g", {{0, 16}, {1, 16}}, {{1, 16}, {2, 16}}), // NOLINT+ FMT_TRAITS(g_os_is_yx_osv16_isv4, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{0, 16}, {1, 4}}, {{1, 16}, {2, 4}}), // NOLINT+ FMT_TRAITS(g_os_is_zyx_osv16_isv16, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "goizyx", "oixyz???g", {{0, 16}, {1, 16}}, {{1, 16}, {2, 16}}), // NOLINT+ FMT_TRAITS(g_os_zyx_is_osv16_isv4, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 16}, {1, 4}}, {{1, 16}, {5, 4}}), // NOLINT+ FMT_TRAITS(g_os_zyx_is_osv16_isv16, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 16}, {1, 16}}, {{1, 16}, {5, 16}}), // NOLINT+ FMT_TRAITS(g_os_zyx_is_osv16_isv32, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 16}, {1, 32}}, {{1, 16}, {5, 32}}), // NOLINT+ FMT_TRAITS(g_os_zyx_is_osv32_isv4, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 32}, {1, 4}}, {{1, 32}, {5, 4}}), // NOLINT+ FMT_TRAITS(g_os_zyx_is_osv32_isv16, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 32}, {1, 16}}, {{1, 32}, {5, 16}}), // NOLINT+ FMT_TRAITS(g_os_zyx_is_osv32_isv32, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 32}, {1, 32}}, {{1, 32}, {5, 32}}), // NOLINT+ FMT_TRAITS(gs_oi_yxs_gsv4_yxsv4, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{8, 4}}, {{0, 4}}), // NOLINT+ FMT_TRAITS(gs_oi_yxs_gsv16_yxsv4, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{8, 16}}, {{0, 16}}), // NOLINT+ FMT_TRAITS(gs_oi_yxs_gsv32_yxsv4, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{8, 32}}, {{0, 32}}), // NOLINT+ FMT_TRAITS(g_os_is_yx_isv16_osv16, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{1, 16}, {0, 16}}, {{2, 16}, {1, 16}}), // NOLINT+ FMT_TRAITS(gi_yxs_os_yxsv2_osv16, 1, 1, 2, 1, {0, 2, 3, 4, 1}, "giyxo", "oixy????g", {{0, 16}}, {{1, 16}}), // NOLINT+ FMT_TRAITS(giy_xs_os_xsv2_osv8__ao32, 1, 1, 2, 1, {0, 2, 3, 4, 1}, "giyxo", "oixy????g", {{2, 2}, {0, 8}}, {{4, 2}, {1, 8}}), // NOLINT+ FMT_TRAITS(giy_xs_os_xsv2_osv16__ao32, 1, 1, 2, 1, {0, 2, 3, 4, 1}, "giyxo", "oixy????g", {{2, 2}, {0, 16}}, {{4, 2}, {1, 16}}), // NOLINT};const format_traits& format::traits(type fmt) {@@ -243,13 +276,12 @@ format format::adjust_to_rank(format fmt, size_t new_rank) {auto current_order = current_traits._order;auto current_blocking = current_traits.block_sizes;auto current_rank = current_order.size();- if (new_rank == current_rank)+ if (new_rank == current_rank) {return fmt;+ }auto is_adjustable = [](const format& fmt) -> bool {- return !format::is_weights_format(fmt) &&- !format::is_image_2d(fmt) &&- !format::is_winograd(fmt);+ return !format::is_weights_format(fmt) && !format::is_image_2d(fmt) && !format::is_winograd(fmt);};// Skip special formats as order + blocking desc may be not enough to properly match them@@ -274,23 +306,25 @@ format format::adjust_to_rank(format fmt, size_t new_rank) {auto candidate_blocking = candidate_traits.block_sizes;auto candidate_rank = candidate_traits.order.size();- if (candidate_rank != new_rank || !is_adjustable(candidate_tag))+ if (candidate_rank != new_rank || !is_adjustable(candidate_tag)) {continue;+ }bool same_blocking_scheme = candidate_blocking == current_blocking;- bool same_dims_scheme = current_traits.batch_num == candidate_traits.batch_num &&- current_traits.group_num == candidate_traits.group_num &&+ bool same_dims_scheme = current_traits.batch_num == candidate_traits.batch_num && current_traits.group_num == candidate_traits.group_num &¤t_traits.feature_num == candidate_traits.feature_num;- if (!same_blocking_scheme || !same_dims_scheme)+ if (!same_blocking_scheme || !same_dims_scheme) {continue;+ }if (current_rank > candidate_rank) {align_order(candidate_order, candidate_rank, current_rank);}- if (candidate_order == current_order)+ if (candidate_order == current_order) {return candidate_tag;+ }}OPENVINO_ASSERT(false, "Can't adjust format ", fmt.to_string(), " to the new rank (", new_rank, ")");@@ -300,12 +334,14 @@ format format::adjust_to_rank(format fmt, size_t new_rank) {const std::vector<std::pair<size_t, int>> format::per_axis_block_size(format fmt) {std::vector<std::pair<size_t, int>> sizes_for_dims;for (const auto& block : fmt.block_sizes()) {- auto it = std::find_if(sizes_for_dims.begin(), sizes_for_dims.end(),- [&block](const std::pair<size_t, int>& ele) { return ele.first == block.first; });- if (it != sizes_for_dims.end())+ auto it = std::find_if(sizes_for_dims.begin(), sizes_for_dims.end(), [&block](const std::pair<size_t, int>& ele) {+ return ele.first == block.first;+ });+ if (it != sizes_for_dims.end()) {it->second *= block.second; // the axis is double blocked- else+ } else {sizes_for_dims.push_back({block.first, block.second});+ }}return sizes_for_dims;@@ -319,19 +355,16 @@ format format::find_format(const std::vector<uint64_t>& order,bool is_winograd,bool is_nv12) {auto is_suitable_traits = [&](const std::pair<format::type, format_traits>& traits) -> bool {- return traits.second._order == order &&- traits.second.block_sizes == block_sizes &&- format::is_weights_format(traits.first) == is_weights &&- format::is_grouped(traits.first) == is_grouped &&- format::is_image_2d(traits.first) == is_image_2d &&- format::is_winograd(traits.first) == is_winograd &&- format::is_nv12(traits.first) == is_nv12;+ return traits.second._order == order && traits.second.block_sizes == block_sizes && format::is_weights_format(traits.first) == is_weights &&+ format::is_grouped(traits.first) == is_grouped && format::is_image_2d(traits.first) == is_image_2d &&+ format::is_winograd(traits.first) == is_winograd && format::is_nv12(traits.first) == is_nv12;};std::vector<format> finded_formats;for (const auto& traits : format_traits_map) {- if (is_suitable_traits(traits))+ if (is_suitable_traits(traits)) {finded_formats.emplace_back(traits.first);+ }}OPENVINO_ASSERT(!finded_formats.empty(), "[GPU] Cannot find a format with the specified parameters");diff --git a/src/plugins/intel_gpu/src/runtime/layout.cpp b/src/plugins/intel_gpu/src/runtime/layout.cppindex 74956fb52ef..e7c2a3bfab3 100644--- a/src/plugins/intel_gpu/src/runtime/layout.cpp+++ b/src/plugins/intel_gpu/src/runtime/layout.cpp@@ -24,13 +24,15 @@ std::vector<int32_t> convert_dimensions(const std::vector<int32_t>& sizes, conststd::vector<int32_t> new_sizes(out_order.size(), {-1});for (size_t out_idx = 0; out_idx < out_order.size(); ++out_idx) {auto channel = out_order[out_idx];- if (channel == '?')+ if (channel == '?') {continue;+ }auto in_idx = in_order.find(channel);if (in_idx != in_order.npos) {- if (in_idx < sizes.size())+ if (in_idx < sizes.size()) {new_sizes[out_idx] = sizes[in_idx];+ }}}return new_sizes;@@ -72,8 +74,9 @@ tensor::value_type layout::feature() const {}tensor::value_type layout::spatial(size_t spatial_idx) const {- if (spatial_idx >= format.spatial_num() )+ if (spatial_idx >= format.spatial_num() ) {return 1;+ }const auto& dims = get_dims();const size_t dim_idx = (format::is_grouped(format) ? 3 : 2) + (format.spatial_num() - 1 - spatial_idx);return dims[dim_idx];@@ -85,8 +88,9 @@ tensor::value_type layout::group() const {throw std::logic_error("[GPU] can't get group dimension for data layout");}- if (!format::is_grouped(format))+ if (!format::is_grouped(format)) {return 1;+ }return dims[0];}@@ -111,16 +115,18 @@ tensor::value_type layout::ifm() const {}std::vector<tensor::value_type> layout::get_dims() const {- if (is_dynamic())+ if (is_dynamic()) {throw std::runtime_error("[GPU] get_dims() is called for dynamic shape");+ }std::vector<tensor::value_type> res;for (const auto& dim : size) {res.push_back(static_cast<tensor::value_type>(dim.get_length()));}- if (res.size() < format.dimension())+ if (res.size() < format.dimension()) {res.insert(res.end(), format.dimension() - res.size(), 1);+ }return res;}@@ -153,8 +159,9 @@ std::vector<tensor::value_type> layout::get_padded_dims() const {}static format to_weights_format(format f, bool is_grouped) {- if (format::is_weights_format(f))+ if (format::is_weights_format(f)) {return f;+ }switch (f) {case format::bfyx:@@ -174,8 +181,9 @@ static format to_weights_format(format f, bool is_grouped) {case format::bfzyx:return is_grouped ? format::goiyx : format::oizyx;case format::bfwzyx: {- if (!is_grouped)+ if (!is_grouped) {throw std::runtime_error("Invalid conversion of data format to weights format. bfwzyx can't be non-grouped as 4D spatials are not supported");+ }return format::goizyx;}case format::b_fs_yx_fsv4:@@ -196,8 +204,9 @@ layout layout::convert_to_weights_layout(bool is_grouped) const {}std::vector<tensor::value_type> layout::get_ordered_dims() const {- if (is_dynamic())+ if (is_dynamic()) {throw std::runtime_error("[GPU] get_ordered_dims() is called for dynamic shape");+ }const auto& t = get_tensor();return t.sizes(format);@@ -232,8 +241,9 @@ std::string layout::to_short_string() const {} else {for (size_t i = 0; i < shape.size(); i++) {stream << shape[i];- if (i != shape.size() - 1)+ if (i != shape.size() - 1) {stream << "x";+ }}}};@@ -242,8 +252,9 @@ std::string layout::to_short_string() const {size_t rank) {stream << "[";for (size_t i = 0; i < rank; ++i) {- if (i)+ if (i) {stream << ",";+ }stream << values[i];}stream << "]";@@ -269,8 +280,9 @@ std::string layout::to_short_string() const {}size_t layout::count() const {- if (is_dynamic())+ if (is_dynamic()) {throw std::runtime_error("[GPU] Count is called for dynamic shape");+ }return ov::shape_size(size.to_shape());}@@ -370,8 +382,9 @@ size_t layout::get_linear_offset(tensor element) const {auto t = get_tensor();for (auto& d : t.raw) {- if (d == 0)+ if (d == 0) {d = 1;+ }}if ((element.batch[0] < 0 && -element.batch[0] > l_padd.batch[0]) ||@@ -385,8 +398,9 @@ size_t layout::get_linear_offset(tensor element) const {(element.spatial[0] >= t.spatial[0] + u_padd.spatial[0]) ||(element.spatial[1] >= t.spatial[1] + u_padd.spatial[1]) ||(element.spatial[2] >= t.spatial[2] + u_padd.spatial[2]) ||- (element.spatial[3] >= t.spatial[3] + u_padd.spatial[3]))+ (element.spatial[3] >= t.spatial[3] + u_padd.spatial[3])) {throw std::invalid_argument("Requested to calculate linear offset for an element which lies outside of the buffer range.");+ }auto padded_size = t + l_padd + u_padd;auto padded_element = element + l_padd;@@ -401,15 +415,17 @@ size_t layout::get_linear_size() const {const auto& blocks = format.logic_block_sizes();for (size_t i = 0; i < blocks.size(); i++) {- if (processed_dims.count(blocks[i].first))+ if (processed_dims.count(blocks[i].first)) {continue;+ }auto block_axis = blocks[i].first;auto block_size = blocks[i].second;for (size_t j = i + 1; j < blocks.size(); j++) {- if (blocks[j].first != block_axis)+ if (blocks[j].first != block_axis) {continue;+ }block_size *= blocks[j].second;}@@ -470,24 +486,31 @@ bool layout::compatible(const layout& other) const {const auto& l1 = *this;const auto& l2 = other;- if (l1.is_dynamic() || l2.is_dynamic())+ if (l1.is_dynamic() || l2.is_dynamic()) {return false;+ }- if (l1 == l2)+ if (l1 == l2) {return true;- if (check_redundant_1d_along_feature(l1, l2))+ }+ if (check_redundant_1d_along_feature(l1, l2)) {return true;- if (l1.data_type != l2.data_type)+ }+ if (l1.data_type != l2.data_type) {return false;+ }// Reorders between bfyx, bfzyx, bfwzyx can be reinterpeted as reshape when// there is no padding and both hold same number of elements.if (format::is_default_format(l1.format) && format::is_default_format(l2.format) &&- !l1.data_padding && !l2.data_padding && l1.get_linear_size() == l2.get_linear_size())+ !l1.data_padding && !l2.data_padding && l1.get_linear_size() == l2.get_linear_size()) {return true;- if (l1.get_shape() != l2.get_shape())+ }+ if (l1.get_shape() != l2.get_shape()) {return false;- if (l1.get_linear_size() != l2.get_linear_size())+ }+ if (l1.get_linear_size() != l2.get_linear_size()) {return false;+ }auto check_format = [&l1, &l2](cldnn::format format) {return (l1.format == format && l2.format != format) ||@@ -499,8 +522,9 @@ bool layout::compatible(const layout& other) const {// TODO: Relax restrictions belowif (blocks1 != blocks2 ||- (!blocks1.empty() && l1.format.dims_order() != l2.format.dims_order()))+ (!blocks1.empty() && l1.format.dims_order() != l2.format.dims_order())) {return false;+ }// Since it is not possible to properly check compatibility for custom formats, return falseif (l1.format == cldnn::format::custom || l2.format == cldnn::format::custom) {@@ -529,8 +553,9 @@ bool layout::compatible(const layout& other) const {check_format(format::bs_fs_zyx_bsv16_fsv32) ||check_format(format::bs_fs_zyx_bsv16_fsv16) ||check_format(format::bs_fs_zyx_bsv32_fsv16) ||- check_format(format::bs_fs_zyx_bsv32_fsv32))+ check_format(format::bs_fs_zyx_bsv32_fsv32)) {return false;+ }auto l1_pitch = l1.get_pitches();auto l2_pitch = l2.get_pitches();@@ -554,8 +579,9 @@ bool layout::compatible(const layout& other) const {}bool layout::identical(const layout& other) const {- if (is_dynamic() || other.is_dynamic())+ if (is_dynamic() || other.is_dynamic()) {return false;+ }bool ret = (*this == other);if (ret && this->format == cldnn::format::custom) {ret &= (this->format.traits().block_sizes == other.format.traits().block_sizes);@@ -572,8 +598,9 @@ ov::PartialShape layout::transform(const ov::PartialShape& pshape, const cldnn::if (format::is_default_format(old_fmt) && new_fmt == format::bfvuwzyx) {ov::PartialShape res = pshape;// This part is necessary because we treat 3D layouts as "bfy", not as "bfx".- if (res.size() == 3)+ if (res.size() == 3) {res.push_back(1);+ }size_t num_to_insert = layout::max_rank() - res.size();size_t pos_to_insert = std::min<size_t>(res.size(), 2);res.insert(res.begin() + pos_to_insert, num_to_insert, 1);@@ -626,8 +653,9 @@ ov::PartialShape layout::transform(const ov::PartialShape& pshape, const cldnn::for (size_t i = 0; i < new_order.size(); i++) {auto c = new_order[i]; //bfxywz- if (c == '?')+ if (c == '?') {continue;+ }if (new_sizes[i] == -1) {new_sizes[i] = 1;}@@ -635,10 +663,11 @@ ov::PartialShape layout::transform(const ov::PartialShape& pshape, const cldnn::auto new_dims = convert_dimensions(new_sizes, default_fmt.internal_order(), new_fmt.order());for (int idx = static_cast<int>(new_dims.size() - 1); idx >= 0; idx--) {- if (new_dims[idx] == -1)+ if (new_dims[idx] == -1) {new_dims.erase((new_dims.begin() + idx));- else if (new_dims[idx] < 0)+ } else if (new_dims[idx] < 0) {new_dims[idx] *= -1;+ }}ov::PartialShape res;@@ -663,8 +692,9 @@ static inline bool check_redundant_1d_along_feature(layout const& l1, layout conauto is_1x1_spatial = [](layout const& l) {for (size_t i = 0; i < l.get_spatial_rank(); ++i) {- if (l.spatial(i) > 1)+ if (l.spatial(i) > 1) {return false;+ }}return true;};@@ -683,8 +713,9 @@ static inline bool check_redundant_1d_along_feature(layout const& l1, layout conl1.feature() == l2_inner_blk)) {// each spatial axis should be samefor (size_t i = 0 ; i < l2.get_spatial_rank() ; i++) {- if (l2.spatial(i) != l1.spatial(i))+ if (l2.spatial(i) != l1.spatial(i)) {return false;+ }}return true;diff --git a/src/plugins/intel_gpu/src/runtime/memory_pool.cpp b/src/plugins/intel_gpu/src/runtime/memory_pool.cppindex cb07c874fe6..656bce776ea 100644--- a/src/plugins/intel_gpu/src/runtime/memory_pool.cpp+++ b/src/plugins/intel_gpu/src/runtime/memory_pool.cpp@@ -39,8 +39,9 @@ memory_pool::~memory_pool() = default;bool memory_pool::has_conflict(const memory_set& mem_cand,const memory_restricter<uint32_t>& restrictions) {for (const auto& mem_usr : mem_cand) {- if (restrictions.contains(static_cast<uint32_t>(mem_usr._unique_id)))+ if (restrictions.contains(static_cast<uint32_t>(mem_usr._unique_id))) {return true;+ }}return false;}@@ -72,8 +73,9 @@ void memory_pool::release_memory(memory* mem, const size_t& unique_id, primitiveGPU_DEBUG_IF(_config.get_dump_memory_pool()) {auto released_mem_size = it->first;total_mem_size_non_padded_pool -= released_mem_size;- if (type == allocation_type::usm_host)+ if (type == allocation_type::usm_host) {mem_size_non_padded_pool_host -= released_mem_size;+ }}#endif// if this was the only user of the memory, then free it up@@ -108,8 +110,9 @@ void memory_pool::release_memory(memory* mem, const size_t& unique_id, primitiveGPU_DEBUG_IF(_config.get_dump_memory_pool()) {auto released_mem_size = mem->size();total_mem_size_padded_pool -= released_mem_size;- if (type == allocation_type::usm_host)+ if (type == allocation_type::usm_host) {mem_size_padded_pool_host -= released_mem_size;+ }}#endif// if this was the only user of the memory, then free it up@@ -138,8 +141,9 @@ void memory_pool::release_memory(memory* mem, const size_t& unique_id, primitiveGPU_DEBUG_IF(_config.get_dump_memory_pool()) {auto released_mem_size = iter->_users.begin()->_mem_size;total_mem_size_no_reusable -= released_mem_size;- if (type == allocation_type::usm_host)+ if (type == allocation_type::usm_host) {mem_size_no_reusable_host -= released_mem_size;+ }}iter->_users.clear();_no_reusable_mems.erase(iter);@@ -207,8 +211,9 @@ memory::ptr memory_pool::get_from_non_padded_pool(const layout& layout,{GPU_DEBUG_IF(_config.get_dump_memory_pool()) {total_mem_size_non_padded_pool += layout_bytes_count;- if (type == allocation_type::usm_host)+ if (type == allocation_type::usm_host) {mem_size_non_padded_pool_host += layout_bytes_count;+ }}}#endif@@ -257,8 +262,9 @@ memory::ptr memory_pool::get_from_padded_pool(const layout& layout,GPU_DEBUG_IF(_config.get_dump_memory_pool()) {const auto allocated_mem_size = mem->size();total_mem_size_padded_pool += allocated_mem_size;- if (type == allocation_type::usm_host)+ if (type == allocation_type::usm_host) {mem_size_padded_pool_host += allocated_mem_size;+ }}}#endif@@ -273,8 +279,9 @@ memory::ptr memory_pool::get_from_padded_pool(const layout& layout,GPU_DEBUG_IF(_config.get_dump_memory_pool()) {const auto allocated_mem_size = mem->size();total_mem_size_padded_pool += allocated_mem_size;- if (type == allocation_type::usm_host)+ if (type == allocation_type::usm_host) {mem_size_padded_pool_host += allocated_mem_size;+ }}}#endif@@ -308,8 +315,9 @@ memory::ptr memory_pool::get_memory(const layout& layout,_no_reusable_mems.push_back(memory_record({{MEM_USER(unique_id, network_id, prim_id, allocated_mem_size)}}, mem, network_id, type));total_mem_size_no_reusable += allocated_mem_size;- if (type == allocation_type::usm_host)+ if (type == allocation_type::usm_host) {mem_size_no_reusable_host += allocated_mem_size;+ }}#endifreturn mem;@@ -334,8 +342,9 @@ void memory_pool::clear_pool_for_network(uint32_t network_id) {GPU_DEBUG_IF(_config.get_dump_memory_pool()) {auto released_mem_size = itr->first;total_mem_size_non_padded_pool -= released_mem_size;- if (record._type == allocation_type::usm_host)+ if (record._type == allocation_type::usm_host) {mem_size_non_padded_pool_host -= released_mem_size;+ }}#endifitr = _non_padded_pool.erase(itr);@@ -368,8 +377,9 @@ void memory_pool::clear_pool_for_network(uint32_t network_id) {GPU_DEBUG_IF(_config.get_dump_memory_pool()) {auto released_mem_size = itr->first.bytes_count();total_mem_size_padded_pool -= released_mem_size;- if (type == allocation_type::usm_host)+ if (type == allocation_type::usm_host) {mem_size_padded_pool_host -= released_mem_size;+ }}#endifitr = _padded_pool.erase(itr);@@ -389,8 +399,9 @@ void memory_pool::clear_pool_for_network(uint32_t network_id) {GPU_DEBUG_IF(_config.get_dump_memory_pool()) {auto released_mem_size = itr->_users.begin()->_mem_size;total_mem_size_no_reusable -= released_mem_size;- if (record._type == allocation_type::usm_host)+ if (record._type == allocation_type::usm_host) {mem_size_no_reusable_host -= released_mem_size;+ }}itr = _no_reusable_mems.erase(itr);} else {@@ -413,8 +424,9 @@ memory_pool::memory_pool(engine& engine, const ExecutionConfig& config) : _engin#ifdef GPU_DEBUG_CONFIGinline std::string get_mb_size(size_t size) {- if (size == 0)+ if (size == 0) {return "0 MB";+ }return std::to_string(static_cast<float>(size) / (1024.f * 1024.f)) + " MB";}@@ -439,8 +451,9 @@ size_t memory_pool::get_total_mem_pool_size(allocation_type type) {void memory_pool::dump(uint32_t net_id, int64_t iter, std::string dump_dir_path) {dump_to_screen(net_id, iter);- if (!dump_dir_path.empty())+ if (!dump_dir_path.empty()) {dump_to_file(net_id, iter, dump_dir_path);+ }}void memory_pool::dump_to_file(uint32_t net_id, int64_t iter, std::string dump_dir_path) {diff --git a/src/plugins/intel_gpu/src/runtime/ocl/ocl_command_queues_builder.cpp b/src/plugins/intel_gpu/src/runtime/ocl/ocl_command_queues_builder.cppindex 0ea7a814252..dda652281e4 100644--- a/src/plugins/intel_gpu/src/runtime/ocl/ocl_command_queues_builder.cpp+++ b/src/plugins/intel_gpu/src/runtime/ocl/ocl_command_queues_builder.cpp@@ -62,9 +62,10 @@ std::vector<cl_queue_properties> command_queues_builder::get_properties(const cl}}- if (num_queues)+ if (num_queues) {properties.insert(properties.end(), {CL_QUEUE_FAMILY_INTEL, family,CL_QUEUE_INDEX_INTEL, stream_id % num_queues});+ }}bool out_of_order = _out_of_order;diff --git a/src/plugins/intel_gpu/src/runtime/ocl/ocl_device.cpp b/src/plugins/intel_gpu/src/runtime/ocl/ocl_device.cppindex b1875cce0ac..795a7c6dbe7 100644--- a/src/plugins/intel_gpu/src/runtime/ocl/ocl_device.cpp+++ b/src/plugins/intel_gpu/src/runtime/ocl/ocl_device.cpp@@ -5,47 +5,47 @@#include "ocl_device.hpp"#ifdef ENABLE_ONEDNN_FOR_GPU-#ifndef NOMINMAX-# define NOMINMAX-#endif-#include "gpu/intel/jit/generator.hpp"+# ifndef NOMINMAX+# define NOMINMAX+# endif+# include "gpu/intel/jit/generator.hpp"#endif-#include "ocl_common.hpp"-#include "intel_gpu/runtime/debug_configuration.hpp"--#include <map>-#include <string>-#include <vector>#include <algorithm>-#include <unordered_map>-#include <string>#include <cassert>-#include <ctime>-#include <limits>#include <chrono>+#include <ctime>#include <fstream>#include <iostream>+#include <limits>+#include <map>+#include <string>+#include <unordered_map>#include <utility>+#include <vector>++#include "intel_gpu/runtime/debug_configuration.hpp"+#include "ocl_common.hpp"#ifdef _WIN32-#ifndef WIN32_LEAN_AND_MEAN-#define WIN32_LEAN_AND_MEAN-#endif-#ifndef NOMINMAX-#define NOMINMAX-#endif-#include <windows.h>-#include <setupapi.h>-#include <devguid.h>-#include <cstring>+# ifndef WIN32_LEAN_AND_MEAN+# define WIN32_LEAN_AND_MEAN+# endif+# ifndef NOMINMAX+# define NOMINMAX+# endif+# include <devguid.h>+# include <setupapi.h>+# include <windows.h>++# include <cstring>#else-#include <unistd.h>-#include <climits>-#include <link.h>-#include <dlfcn.h>-#endif+# include <dlfcn.h>+# include <link.h>+# include <unistd.h>+# include <climits>+#endifnamespace cldnn {namespace ocl {@@ -55,26 +55,34 @@ namespace {#if defined(ENABLE_ONEDNN_FOR_GPU) && defined(OV_GPU_WITH_OCL_RT)gpu_arch convert_ngen_arch(ngen::HW gpu_arch) {switch (gpu_arch) {- case ngen::HW::Gen9: return gpu_arch::gen9;- case ngen::HW::Gen11: return gpu_arch::gen11;- case ngen::HW::XeLP: return gpu_arch::xe_lp;- case ngen::HW::XeHP: return gpu_arch::xe_hp;- case ngen::HW::XeHPG: return gpu_arch::xe_hpg;- case ngen::HW::XeHPC: OPENVINO_THROW("[GPU] XeHPC is not supported");- case ngen::HW::Xe2: return gpu_arch::xe2;- case ngen::HW::Xe3: return gpu_arch::xe3;- case ngen::HW::Xe3p: return gpu_arch::xe3p;- case ngen::HW::Gen10:- case ngen::HW::Unknown: return gpu_arch::unknown;+ case ngen::HW::Gen9:+ return gpu_arch::gen9;+ case ngen::HW::Gen11:+ return gpu_arch::gen11;+ case ngen::HW::XeLP:+ return gpu_arch::xe_lp;+ case ngen::HW::XeHP:+ return gpu_arch::xe_hp;+ case ngen::HW::XeHPG:+ return gpu_arch::xe_hpg;+ case ngen::HW::XeHPC:+ OPENVINO_THROW("[GPU] XeHPC is not supported");+ case ngen::HW::Xe2:+ return gpu_arch::xe2;+ case ngen::HW::Xe3:+ return gpu_arch::xe3;+ case ngen::HW::Xe3p:+ return gpu_arch::xe3p;+ case ngen::HW::Gen10:+ case ngen::HW::Unknown:+ return gpu_arch::unknown;}return gpu_arch::unknown;}#endifint driver_dev_id() {- const std::vector<int> unused_ids = {- 0x4905, 0x4906, 0x4907, 0x4908- };+ const std::vector<int> unused_ids = {0x4905, 0x4906, 0x4907, 0x4908};std::vector<int> result;#ifdef _WIN32@@ -109,7 +117,7 @@ int driver_dev_id() {}#elif defined(__linux__){- std::string dev_base{ "/sys/devices/pci0000:00/0000:00:02.0/" };+ std::string dev_base{"/sys/devices/pci0000:00/0000:00:02.0/"};std::ifstream ifs(dev_base + "vendor");if (ifs.good()) {int ven_id;@@ -129,14 +137,16 @@ int driver_dev_id() {auto id_itr = result.begin();while (id_itr != result.end()) {- if (std::find(unused_ids.begin(), unused_ids.end(), *id_itr) != unused_ids.end())+ if (std::find(unused_ids.begin(), unused_ids.end(), *id_itr) != unused_ids.end()) {id_itr = result.erase(id_itr);- else+ } else {id_itr++;+ }}- if (result.empty())+ if (result.empty()) {return 0;+ }return result.back();}@@ -146,7 +156,6 @@ device_type get_device_type(const cl::Device& device) {return unified_mem ? device_type::integrated_gpu : device_type::discrete_gpu;}-gfx_version parse_version(cl_uint gmdid) {union GMDID {uint32_t value;@@ -161,35 +170,33 @@ gfx_version parse_version(cl_uint gmdid) {GMDID gmd_id = {gmdid};if (gmd_id.architecture > 0 && gmd_id.architecture < 100) {// New format- return { static_cast<uint16_t>(gmd_id.architecture), static_cast<uint8_t>(gmd_id.release), static_cast<uint8_t>(gmd_id.revision)};+ return {static_cast<uint16_t>(gmd_id.architecture), static_cast<uint8_t>(gmd_id.release), static_cast<uint8_t>(gmd_id.revision)};} // Old format- cl_uint ver = gmdid;- uint16_t major = ver >> 16;- uint8_t minor = (ver >> 8) & 0xFF;- uint8_t revision = ver & 0xFF;+ cl_uint ver = gmdid;+ uint16_t major = ver >> 16;+ uint8_t minor = (ver >> 8) & 0xFF;+ uint8_t revision = ver & 0xFF;- return {major, minor, revision};+ return {major, minor, revision};}bool get_imad_support(const cl::Device& device) {std::string dev_name = device.getInfo<CL_DEVICE_NAME>();- if (dev_name.find("Gen12") != std::string::npos ||- dev_name.find("Xe") != std::string::npos)+ if (dev_name.find("Gen12") != std::string::npos || dev_name.find("Xe") != std::string::npos) {return true;+ }if (get_device_type(device) == device_type::integrated_gpu) {- const std::vector<int> imad_ids = {- 0x9A40, 0x9A49, 0x9A59, 0x9AD9,- 0x9A60, 0x9A68, 0x9A70, 0x9A78,- 0x9A7F, 0x9AF8, 0x9AC0, 0x9AC9- };+ const std::vector<int> imad_ids = {0x9A40, 0x9A49, 0x9A59, 0x9AD9, 0x9A60, 0x9A68, 0x9A70, 0x9A78, 0x9A7F, 0x9AF8, 0x9AC0, 0x9AC9};int dev_id = driver_dev_id();- if (dev_id == 0)+ if (dev_id == 0) {return false;+ }- if (std::find(imad_ids.begin(), imad_ids.end(), dev_id) != imad_ids.end())+ if (std::find(imad_ids.begin(), imad_ids.end(), dev_id) != imad_ids.end()) {return true;+ }} else {return true;}@@ -207,7 +214,7 @@ device_info init_device_info(const cl::Device& device, const cl::Context& contexinfo.cacheline_size = device.getInfo<CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE>();// Alignment requirement (in bits) for sub-buffer offsets, converting to bytes and ensuring at least 1 byte alignment.- auto bits = device.getInfo<CL_DEVICE_MEM_BASE_ADDR_ALIGN>();+ auto bits = device.getInfo<CL_DEVICE_MEM_BASE_ADDR_ALIGN>();info.sub_buffer_base_alignment = std::max<uint32_t>(1, bits / 8);info.execution_units_count = device.getInfo<CL_DEVICE_MAX_COMPUTE_UNITS>();@@ -260,8 +267,9 @@ device_info init_device_info(const cl::Device& device, const cl::Context& contexauto query_device_bool = [&](cl_device_info param) -> bool {cl_bool value = CL_FALSE;try {- if (device.getInfo(param, &value) != CL_SUCCESS)+ if (device.getInfo(param, &value) != CL_SUCCESS) {return false;+ }} catch (const cl::Error&) {return false;}@@ -304,8 +312,7 @@ device_info init_device_info(const cl::Device& device, const cl::Context& contexinfo.supports_imad = info.supports_imad || ((features & CL_DEVICE_FEATURE_FLAG_DP4A_INTEL) != 0u);info.supports_immad = info.supports_immad || ((features & CL_DEVICE_FEATURE_FLAG_DPAS_INTEL) != 0u);- if (info.dev_type == device_type::discrete_gpu ||- info.gfx_ver.major > 12 || (info.gfx_ver.major == 12 && info.gfx_ver.minor >= 70)) {+ if (info.dev_type == device_type::discrete_gpu || info.gfx_ver.major > 12 || (info.gfx_ver.major == 12 && info.gfx_ver.minor >= 70)) {info.has_separate_cache = true;}} else if (nv_device_attr_supported) {@@ -368,28 +375,38 @@ device_info init_device_info(const cl::Device& device, const cl::Context& contexinfo.supports_immad = false;}}-#else // ENABLE_ONEDNN_FOR_GPU+#else // ENABLE_ONEDNN_FOR_GPUinfo.arch = gpu_arch::unknown;#endif // ENABLE_ONEDNN_FOR_GPUauto arch_to_string = [](gpu_arch arch) -> const char* {switch (arch) {- case gpu_arch::unknown: return "unknown";- case gpu_arch::gen9: return "gen9";- case gpu_arch::gen11: return "gen11";- case gpu_arch::xe_lp: return "xe_lp";- case gpu_arch::xe_hp: return "xe_hp";- case gpu_arch::xe_hpg: return "xe_hpg";- case gpu_arch::xe_hpc: return "xe_hpc";- case gpu_arch::xe2: return "xe2";- case gpu_arch::xe3: return "xe3";- case gpu_arch::xe3p: return "xe3p";+ case gpu_arch::unknown:+ return "unknown";+ case gpu_arch::gen9:+ return "gen9";+ case gpu_arch::gen11:+ return "gen11";+ case gpu_arch::xe_lp:+ return "xe_lp";+ case gpu_arch::xe_hp:+ return "xe_hp";+ case gpu_arch::xe_hpg:+ return "xe_hpg";+ case gpu_arch::xe_hpc:+ return "xe_hpc";+ case gpu_arch::xe2:+ return "xe2";+ case gpu_arch::xe3:+ return "xe3";+ case gpu_arch::xe3p:+ return "xe3p";}return "unknown";};- GPU_DEBUG_INFO << "GPU architecture: " << arch_to_string(info.arch) << ", version: "- << static_cast<int>(info.gfx_ver.major) << "." << static_cast<int>(info.gfx_ver.minor) << "." << static_cast<int>(info.gfx_ver.revision)- << (info.has_separate_cache ? " with separate cache" : "") << std::endl;+ GPU_DEBUG_INFO << "GPU architecture: " << arch_to_string(info.arch) << ", version: " << static_cast<int>(info.gfx_ver.major) << "."+ << static_cast<int>(info.gfx_ver.minor) << "." << static_cast<int>(info.gfx_ver.revision)+ << (info.has_separate_cache ? " with separate cache" : "") << std::endl;return info;}@@ -397,7 +414,8 @@ device_info init_device_info(const cl::Device& device, const cl::Context& contexbool does_device_support(int32_t param, const cl::Device& device) {cl_device_unified_shared_memory_capabilities_intel capabilities;auto err = clGetDeviceInfo(device.get(), param, sizeof(cl_device_unified_shared_memory_capabilities_intel), &capabilities, nullptr);- if (err) throw std::runtime_error("[CLDNN ERROR]. clGetDeviceInfo error " + std::to_string(err));+ if (err)+ throw std::runtime_error("[CLDNN ERROR]. clGetDeviceInfo error " + std::to_string(err));return !((capabilities & CL_UNIFIED_SHARED_MEMORY_ACCESS_INTEL) == 0u);}@@ -429,20 +447,20 @@ void ocl_device::initialize_context(const cl::Context& ctx) {}ocl_device::ocl_device(const cl::Device dev, const cl::Context& ctx, const cl::Platform& platform, bool initialize_ctx)-: _device(dev)-, _platform(platform)-, _info(init_device_info(dev, ctx))-, _mem_caps(init_memory_caps(dev, _info)) {+ : _device(dev),+ _platform(platform),+ _info(init_device_info(dev, ctx)),+ _mem_caps(init_memory_caps(dev, _info)) {if (initialize_ctx) {initialize_context(ctx);}}ocl_device::ocl_device(const ocl_device::ptr other, bool initialize_ctx)-: _device(other->_device)-, _platform(other->_platform)-, _info(other->_info)-, _mem_caps(other->_mem_caps) {+ : _device(other->_device),+ _platform(other->_platform),+ _info(other->_info),+ _mem_caps(other->_mem_caps) {if (initialize_ctx) {initialize_context(other->_context);}@@ -450,12 +468,14 @@ ocl_device::ocl_device(const ocl_device::ptr other, bool initialize_ctx)bool ocl_device::is_same(const device::ptr other) {auto* casted = downcast<ocl_device>(other.get());- if (!casted)+ if (!casted) {return false;+ }// Short path if cl_device is the same- if (_platform == casted->_platform && _device.get() && casted->_device.get() && _device == casted->_device)+ if (_platform == casted->_platform && _device.get() && casted->_device.get() && _device == casted->_device) {return true;+ }return _info.is_same_device(casted->_info);}@@ -468,8 +488,9 @@ void ocl_device::set_sub_device_idx(uint32_t idx) {}void ocl_device::initialize() {- if (_is_initialized)+ if (_is_initialized) {return;+ }ocl::ocl_device_detector detector;auto device_map = detector.get_available_devices(nullptr, nullptr, 0, -1, false);diff --git a/src/plugins/intel_gpu/src/runtime/ocl/ocl_device_detector.cpp b/src/plugins/intel_gpu/src/runtime/ocl/ocl_device_detector.cppindex aee784eef6b..9abdb923bcc 100644--- a/src/plugins/intel_gpu/src/runtime/ocl/ocl_device_detector.cpp+++ b/src/plugins/intel_gpu/src/runtime/ocl/ocl_device_detector.cpp@@ -64,8 +64,9 @@ bool does_device_match_config(const cl::Device& device) {#elseint32_t min_ocl_version = 120;#endif- if (ocl_version < min_ocl_version)+ if (ocl_version < min_ocl_version) {return false;+ }}return true;@@ -206,8 +207,9 @@ std::vector<device::ptr> ocl_device_detector::create_device_list() const {std::vector<cl::Device> devices;platform.getDevices(CL_DEVICE_TYPE_ALL, &devices);for (auto& device : devices) {- if (!does_device_match_config(device))+ if (!does_device_match_config(device)) {continue;+ }if (device.getInfo<CL_DEVICE_VENDOR_ID>() == cldnn::INTEL_VENDOR_ID) {supported_devices.emplace_back(std::make_shared<ocl_device>(device, cl::Context(device), platform));@@ -231,8 +233,9 @@ std::vector<device::ptr> ocl_device_detector::create_device_list_from_user_contestd::vector<device::ptr> supported_devices;for (size_t i = 0; i < all_devices.size(); i++) {auto& device = all_devices[i];- if (!does_device_match_config(device) || static_cast<int>(i) != ctx_device_id)+ if (!does_device_match_config(device) || static_cast<int>(i) != ctx_device_id) {continue;+ }supported_devices.emplace_back(std::make_shared<ocl_device>(device, ctx, cl::Platform(device.getInfo<CL_DEVICE_PLATFORM>())));}@@ -255,8 +258,9 @@ std::vector<device::ptr> ocl_device_detector::create_device_list_from_user_devicfor (auto& id : platform_ids) {cl::PlatformVA platform = cl::PlatformVA(id);- if (platform.getInfo<CL_PLATFORM_VENDOR>() != INTEL_PLATFORM_VENDOR)+ if (platform.getInfo<CL_PLATFORM_VENDOR>() != INTEL_PLATFORM_VENDOR) {continue;+ }std::vector<cl::Device> devices;#ifdef _WIN32@@ -283,8 +287,9 @@ std::vector<device::ptr> ocl_device_detector::create_device_list_from_user_devic&devices);for (auto& device : devices) {- if (!does_device_match_config(device))+ if (!does_device_match_config(device)) {continue;+ }cl_context_properties props[] = {#ifdef _WIN32diff --git a/src/plugins/intel_gpu/src/runtime/ocl/ocl_engine.cpp b/src/plugins/intel_gpu/src/runtime/ocl/ocl_engine.cppindex e8f50c05d86..432f6dc874f 100644--- a/src/plugins/intel_gpu/src/runtime/ocl/ocl_engine.cpp+++ b/src/plugins/intel_gpu/src/runtime/ocl/ocl_engine.cpp@@ -3,20 +3,21 @@//#include "ocl_engine.hpp"-#include "intel_gpu/runtime/utils.hpp"-#include "openvino/runtime/intel_gpu/remote_properties.hpp"+#include <cstdint>+#include <memory>+#include <stdexcept>+#include <string>+#include <vector>++#include "intel_gpu/runtime/utils.hpp"+#include "ocl_common.hpp"+#include "ocl_engine_factory.hpp"#include "ocl_kernel.hpp"#include "ocl_kernel_builder.hpp"-#include "ocl_common.hpp"#include "ocl_memory.hpp"#include "ocl_stream.hpp"-#include "ocl_engine_factory.hpp"-#include <string>-#include <vector>-#include <memory>-#include <stdexcept>-#include <cstdint>+#include "openvino/runtime/intel_gpu/remote_properties.hpp"// NOTE: Due to buggy scope transition of warnings we need to disable warning in place of use/instantation// of some types (even though we already disabled them in scope of definition of these types).@@ -24,7 +25,7 @@// of proper support for mangling of custom GCC attributes into type name (usually when used// with templates, even from standard library).#if defined __GNUC__ && __GNUC__ >= 6-#pragma GCC diagnostic ignored "-Wignored-attributes"+# pragma GCC diagnostic ignored "-Wignored-attributes"#endif// static class memebers - pointers to dynamically obtained OpenCL extension functions@@ -36,30 +37,28 @@ cl::PFN_clCreateFromD3D11Buffer cl::BufferDX::pfn_clCreateFromD3D11Buffer = NULL#endif#ifdef ENABLE_ONEDNN_FOR_GPU-#include <oneapi/dnnl/dnnl_ocl.hpp>-#include "intel_gpu/runtime/file_util.hpp"+# include <oneapi/dnnl/dnnl_ocl.hpp>++# include "intel_gpu/runtime/file_util.hpp"#endifnamespace cldnn {namespace ocl {OPENVINO_SUPPRESS_DEPRECATED_START-ocl_error::ocl_error(cl::Error const& err)- : ov::Exception("[GPU] " + std::string(err.what()) + std::string(", error code: ") + std::to_string(err.err())) {}+ocl_error::ocl_error(const cl::Error& err) : ov::Exception("[GPU] " + std::string(err.what()) + std::string(", error code: ") + std::to_string(err.err())) {}OPENVINO_SUPPRESS_DEPRECATED_ENDnamespace {cl_platform_id get_platform_id_for_device(const cl::Device& device) {cl_platform_id platform = nullptr;cl_int err = clGetDeviceInfo(device.get(), CL_DEVICE_PLATFORM, sizeof(platform), &platform, nullptr);- OPENVINO_ASSERT(err == CL_SUCCESS && platform != nullptr,- "[GPU] Failed to retrieve CL_DEVICE_PLATFORM, error: ", err);+ OPENVINO_ASSERT(err == CL_SUCCESS && platform != nullptr, "[GPU] Failed to retrieve CL_DEVICE_PLATFORM, error: ", err);return platform;}} // namespace-ocl_engine::ocl_engine(const device::ptr dev, runtime_types runtime_type)- : engine(dev) {+ocl_engine::ocl_engine(const device::ptr dev, runtime_types runtime_type) : engine(dev) {OPENVINO_ASSERT(runtime_type == runtime_types::ocl, "[GPU] Invalid runtime type specified for OCL engine. Only OCL runtime is supported");auto* casted = dynamic_cast<ocl_device*>(dev.get());@@ -76,11 +75,11 @@ void ocl_engine::create_onednn_engine(const ExecutionConfig& config) {if (!_onednn_engine) {auto casted = std::dynamic_pointer_cast<ocl_device>(_device);OPENVINO_ASSERT(casted, "[GPU] Invalid device type stored in ocl_engine");-#ifdef OV_GPU_WITH_ZE_RT+# ifdef OV_GPU_WITH_ZE_RTOPENVINO_THROW("[GPU] Using OCL OneDNN API with Level Zero runtime");-#else+# else_onednn_engine = std::make_shared<dnnl::engine>(dnnl::ocl_interop::make_engine(casted->get_device().get(), casted->get_context().get()));-#endif+# endif}}#endif@@ -104,8 +103,7 @@ const cl::UsmHelper& ocl_engine::get_usm_helper() const {}allocation_type ocl_engine::detect_usm_allocation_type(const void* memory) const {- return use_unified_shared_memory() ? ocl::gpu_usm::detect_allocation_type(this, memory)- : allocation_type::unknown;+ return use_unified_shared_memory() ? ocl::gpu_usm::detect_allocation_type(this, memory) : allocation_type::unknown;}memory::ptr ocl_engine::import_buffer(const layout& layout, ov::intel_gpu::os_handle_param external_handle) {@@ -121,21 +119,21 @@ memory::ptr ocl_engine::import_buffer(const layout& layout, ov::intel_gpu::os_ha#ifndef CL_VERSION_3_0OPENVINO_THROW("[GPU] External memory import is not supported on this platform");#else-#ifdef _WIN32+# ifdef _WIN32constexpr auto handle_type_token = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR;-#elif defined(__linux__)+# elif defined(__linux__)constexpr auto handle_type_token = CL_EXTERNAL_MEMORY_HANDLE_DMA_BUF_KHR;-#else+# elseOPENVINO_THROW("[GPU] External memory import is not supported on this platform");-#endif+# endifcl_mem_properties props[] = {static_cast<cl_mem_properties>(handle_type_token),-#ifdef __linux__+# ifdef __linux__static_cast<cl_mem_properties>(external_handle),-#else+# elsestatic_cast<cl_mem_properties>(reinterpret_cast<intptr_t>(external_handle)),-#endif+# endif0,};@@ -199,13 +197,13 @@ memory::ptr ocl_engine::allocate_memory(const layout& layout, allocation_type tyreturn res;} catch (const cl::Error& clErr) {switch (clErr.err()) {- case CL_MEM_OBJECT_ALLOCATION_FAILURE:- case CL_OUT_OF_RESOURCES:- case CL_OUT_OF_HOST_MEMORY:- case CL_INVALID_BUFFER_SIZE:- OPENVINO_THROW("[GPU] out of GPU resources");- default:- OPENVINO_THROW("[GPU] buffer allocation failed");+ case CL_MEM_OBJECT_ALLOCATION_FAILURE:+ case CL_OUT_OF_RESOURCES:+ case CL_OUT_OF_HOST_MEMORY:+ case CL_INVALID_BUFFER_SIZE:+ OPENVINO_THROW("[GPU] out of GPU resources");+ default:+ OPENVINO_THROW("[GPU] buffer allocation failed");}}}@@ -220,30 +218,20 @@ memory::ptr ocl_engine::create_subbuffer(const memory& memory, const layout& newauto* ptr = new_buf.get_buffer().get();auto sub_buffer = cl::UsmMemory(get_usm_helper(), ptr, byte_offset);- return std::make_shared<ocl::gpu_usm>(this,- new_layout,- sub_buffer,- memory.get_allocation_type(),- memory.get_mem_tracker());+ return std::make_shared<ocl::gpu_usm>(this, new_layout, sub_buffer, memory.get_allocation_type(), memory.get_mem_tracker());} else {auto buffer = reinterpret_cast<const ocl::gpu_buffer&>(memory).get_buffer();cl_buffer_region sub_buffer_region = {byte_offset, new_layout.bytes_count()};auto sub_buffer = buffer.createSubBuffer({}, CL_BUFFER_CREATE_TYPE_REGION, &sub_buffer_region);- return std::make_shared<ocl::gpu_buffer>(this,- new_layout,- sub_buffer,- memory.get_mem_tracker());+ return std::make_shared<ocl::gpu_buffer>(this, new_layout, sub_buffer, memory.get_mem_tracker());}- } catch (cl::Error const& err) {+ } catch (const cl::Error& err) {OPENVINO_THROW(OCL_ERR_MSG_FMT(err));}}-memory_ptr ocl_engine::create_hostbuffer(void* cpu_address,- size_t data_size,- allocation_type _allocation_type,- const layout output_layout) {+memory_ptr ocl_engine::create_hostbuffer(void* cpu_address, size_t data_size, allocation_type _allocation_type, const layout output_layout) {return create_hostbuffer_impl(cpu_address, data_size, _allocation_type, output_layout, CL_MEM_READ_WRITE);}@@ -260,37 +248,35 @@ memory::ptr ocl_engine::reinterpret_buffer(const memory& memory, const layout& nOPENVINO_ASSERT(memory.get_engine() == this, "[GPU] trying to reinterpret buffer allocated by a different engine");OPENVINO_ASSERT(new_layout.format.is_image() == memory.get_layout().format.is_image(),"[GPU] trying to reinterpret between image and non-image layouts. Current: ",- memory.get_layout().format.to_string(), " Target: ", new_layout.format.to_string());+ memory.get_layout().format.to_string(),+ " Target: ",+ new_layout.format.to_string());try {bool from_memory_pool = memory.from_memory_pool;memory::ptr reinterpret_memory = nullptr;if (new_layout.format.is_image_2d()) {- reinterpret_memory = std::make_shared<ocl::gpu_image2d>(this,- new_layout,- reinterpret_cast<const ocl::gpu_image2d&>(memory).get_buffer(),- memory.get_mem_tracker());+ reinterpret_memory =+ std::make_shared<ocl::gpu_image2d>(this, new_layout, reinterpret_cast<const ocl::gpu_image2d&>(memory).get_buffer(), memory.get_mem_tracker());} else if (memory_capabilities::is_usm_type(memory.get_allocation_type())) {- reinterpret_memory = std::make_shared<ocl::gpu_usm>(this,- new_layout,- reinterpret_cast<const ocl::gpu_usm&>(memory).get_buffer(),- memory.get_allocation_type(),- memory.get_mem_tracker());+ reinterpret_memory = std::make_shared<ocl::gpu_usm>(this,+ new_layout,+ reinterpret_cast<const ocl::gpu_usm&>(memory).get_buffer(),+ memory.get_allocation_type(),+ memory.get_mem_tracker());} else {- reinterpret_memory = std::make_shared<ocl::gpu_buffer>(this,- new_layout,- reinterpret_cast<const ocl::gpu_buffer&>(memory).get_buffer(),- memory.get_mem_tracker());+ reinterpret_memory =+ std::make_shared<ocl::gpu_buffer>(this, new_layout, reinterpret_cast<const ocl::gpu_buffer&>(memory).get_buffer(), memory.get_mem_tracker());}reinterpret_memory->from_memory_pool = from_memory_pool;return reinterpret_memory;- } catch (cl::Error const& err) {+ } catch (const cl::Error& err) {OPENVINO_THROW(OCL_ERR_MSG_FMT(err));}}memory::ptr ocl_engine::reinterpret_handle(const layout& new_layout, shared_mem_params params) {- try {+ try {if (new_layout.format.is_image_2d() && params.mem_type == shared_mem_type::shared_mem_image) {cl::Image2D img(static_cast<cl_mem>(params.mem), true);return std::make_shared<ocl::gpu_image2d>(this, new_layout, img, nullptr);@@ -307,8 +293,11 @@ memory::ptr ocl_engine::reinterpret_handle(const layout& new_layout, shared_mem_auto actual_mem_size = buf.getInfo<CL_MEM_SIZE>();auto requested_mem_size = new_layout.bytes_count();OPENVINO_ASSERT(actual_mem_size >= requested_mem_size,- "[GPU] shared buffer has smaller size (", actual_mem_size,- ") than specified layout (", requested_mem_size, ")");+ "[GPU] shared buffer has smaller size (",+ actual_mem_size,+ ") than specified layout (",+ requested_mem_size,+ ")");return std::make_shared<ocl::gpu_buffer>(this, new_layout, buf, nullptr);}if (params.mem_type == shared_mem_type::shared_mem_usm) {@@ -316,14 +305,16 @@ memory::ptr ocl_engine::reinterpret_handle(const layout& new_layout, shared_mem_auto actual_mem_size = get_usm_helper().get_usm_allocation_size(usm_buffer.get());auto requested_mem_size = new_layout.bytes_count();OPENVINO_ASSERT(actual_mem_size >= requested_mem_size,- "[GPU] shared USM buffer has smaller size (", actual_mem_size,- ") than specified layout (", requested_mem_size, ")");+ "[GPU] shared USM buffer has smaller size (",+ actual_mem_size,+ ") than specified layout (",+ requested_mem_size,+ ")");return std::make_shared<ocl::gpu_usm>(this, new_layout, usm_buffer, nullptr);}OPENVINO_THROW("[GPU] unknown shared object fromat or type");- }- catch (const cl::Error& clErr) {+ } catch (const cl::Error& clErr) {switch (clErr.err()) {case CL_MEM_OBJECT_ALLOCATION_FAILURE:case CL_OUT_OF_RESOURCES:@@ -337,22 +328,24 @@ memory::ptr ocl_engine::reinterpret_handle(const layout& new_layout, shared_mem_}bool ocl_engine::is_the_same_buffer(const memory& mem1, const memory& mem2) {- if (mem1.get_engine() != this || mem2.get_engine() != this)+ if (mem1.get_engine() != this || mem2.get_engine() != this) {return false;- if (mem1.get_allocation_type() != mem2.get_allocation_type())+ }+ if (mem1.get_allocation_type() != mem2.get_allocation_type()) {return false;- if (&mem1 == &mem2)+ }+ if (&mem1 == &mem2) {return true;+ }- if (!memory_capabilities::is_usm_type(mem1.get_allocation_type()))- return (reinterpret_cast<const ocl::gpu_buffer&>(mem1).get_buffer() ==- reinterpret_cast<const ocl::gpu_buffer&>(mem2).get_buffer());+ if (!memory_capabilities::is_usm_type(mem1.get_allocation_type())) {+ return (reinterpret_cast<const ocl::gpu_buffer&>(mem1).get_buffer() == reinterpret_cast<const ocl::gpu_buffer&>(mem2).get_buffer());+ }return (reinterpret_cast<const ocl::gpu_usm&>(mem1).get_buffer() == reinterpret_cast<const ocl::gpu_usm&>(mem2).get_buffer());}void* ocl_engine::get_user_context(runtime_types rt_type) const {- OPENVINO_ASSERT(rt_type == runtime_types::ocl,- "[GPU] OCL engine can only provide OCL context but requested context for ", rt_type);+ OPENVINO_ASSERT(rt_type == runtime_types::ocl, "[GPU] OCL engine can only provide OCL context but requested context for ", rt_type);auto& cl_device = downcast<ocl_device>(*_device);return static_cast<void*>(cl_device.get_context().get());}@@ -379,7 +372,11 @@ std::shared_ptr<cldnn::engine> ocl_engine::create(const device::ptr device, runtreturn std::make_shared<ocl::ocl_engine>(device, runtime_type);}-memory_ptr ocl_engine::create_hostbuffer_impl(void* cpu_address, size_t data_size, allocation_type allocation, const layout& output_layout, cl_mem_flags access_flags) {+memory_ptr ocl_engine::create_hostbuffer_impl(void* cpu_address,+ size_t data_size,+ allocation_type allocation,+ const layout& output_layout,+ cl_mem_flags access_flags) {cl_int err = CL_SUCCESS;cl_mem_flags flags = access_flags | CL_MEM_USE_HOST_PTR;@@ -388,9 +385,10 @@ memory_ptr ocl_engine::create_hostbuffer_impl(void* cpu_address, size_t data_sizOPENVINO_ASSERT(minimal_alignment > 0, "[GPU] cacheline_size must be > 0 for host pointer import");OPENVINO_ASSERT(cpu_address != nullptr, "[GPU] shared buffer pointer is invalid");OPENVINO_ASSERT((reinterpret_cast<std::uintptr_t>(cpu_address) % minimal_alignment) == 0,- "[GPU] shared buffer pointer must be ", minimal_alignment, "-byte aligned");- OPENVINO_ASSERT((data_size % minimal_alignment) == 0,- "[GPU] shared buffer size must be a multiple of ", minimal_alignment, " bytes");+ "[GPU] shared buffer pointer must be ",+ minimal_alignment,+ "-byte aligned");+ OPENVINO_ASSERT((data_size % minimal_alignment) == 0, "[GPU] shared buffer size must be a multiple of ", minimal_alignment, " bytes");flags |= CL_MEM_FORCE_HOST_MEMORY_INTEL;#endifcl::Buffer buffer(get_cl_context(), flags, data_size, cpu_address, &err);@@ -402,21 +400,14 @@ memory_ptr ocl_engine::create_hostbuffer_impl(void* cpu_address, size_t data_sizstd::shared_ptr<MemoryTracker> tracker = nullptr;#ifdef CL_MEM_FORCE_HOST_MEMORY_INTEL- tracker = std::make_shared<MemoryTracker>(nullptr,- cpu_address,- data_size,- allocation);+ tracker = std::make_shared<MemoryTracker>(nullptr, cpu_address, data_size, allocation);#else- tracker = std::make_shared<MemoryTracker>(this,- cpu_address,- data_size,- allocation);+ tracker = std::make_shared<MemoryTracker>(this, cpu_address, data_size, allocation);#endifreturn std::make_shared<ocl::gpu_buffer>(this, output_layout, buffer, tracker);}-std::shared_ptr<cldnn::engine> create_ocl_engine(const device::ptr device, runtime_types runtime_type) {return ocl_engine::create(device, runtime_type);}diff --git a/src/plugins/intel_gpu/src/runtime/ocl/ocl_event.cpp b/src/plugins/intel_gpu/src/runtime/ocl/ocl_event.cppindex 99426c60f95..186f3738f31 100644--- a/src/plugins/intel_gpu/src/runtime/ocl/ocl_event.cpp+++ b/src/plugins/intel_gpu/src/runtime/ocl/ocl_event.cpp@@ -54,8 +54,9 @@ void CL_CALLBACK ocl_event::ocl_event_completion_callback(cl_event, cl_int, void}void ocl_event::set_ocl_callback() {- if (_callback_set)+ if (_callback_set) {return;+ }if (_event.get() != nullptr) {_event.setCallback(CL_COMPLETE, ocl_event_completion_callback, this);@@ -100,8 +101,9 @@ static const std::vector<profiling_period_ocl_start_stop> profiling_periods{};bool ocl_event::get_profiling_info_impl(std::list<instrumentation::profiling_interval>& info) {- if (!is_event_profiled(_event))+ if (!is_event_profiled(_event)) {return true;+ }for (const auto& period : profiling_periods) {cl_ulong start;@@ -161,8 +163,9 @@ bool ocl_events::get_profiling_info_impl(std::list<instrumentation::profiling_incontinue;}- if (!is_event_profiled(be->_event))+ if (!is_event_profiled(be->_event)) {continue;+ }for (const auto& period : profiling_periods) {cl_ulong ev_start;@@ -231,8 +234,9 @@ bool ocl_events::get_profiling_info_impl(std::list<instrumentation::profiling_inunsigned long long min_start = durations.front().first;unsigned long long sum = 0;for (auto& duration : durations) {- if (duration.first < min_start)+ if (duration.first < min_start) {min_start = duration.first;+ }sum += (duration.second - duration.first);}diff --git a/src/plugins/intel_gpu/src/runtime/ocl/ocl_ext.hpp b/src/plugins/intel_gpu/src/runtime/ocl/ocl_ext.hppindex 096e85c03a6..5ca25c20784 100644--- a/src/plugins/intel_gpu/src/runtime/ocl/ocl_ext.hpp+++ b/src/plugins/intel_gpu/src/runtime/ocl/ocl_ext.hpp@@ -11,26 +11,26 @@#include <array>#ifdef OV_GPU_USE_OPENCL_HPP-#include <CL/opencl.hpp>+# include <CL/opencl.hpp>#else-#include <CL/cl2.hpp>+# include <CL/cl2.hpp>#endif#ifndef CL_HPP_PARAM_NAME_CL_INTEL_UNIFIED_SHARED_MEMORY_-#define OPENVINO_CLHPP_HEADERS_ARE_OLDER_THAN_V2024_10_24+# define OPENVINO_CLHPP_HEADERS_ARE_OLDER_THAN_V2024_10_24#endif#include <CL/cl_ext.h>#ifdef _WIN32-# ifndef NOMINMAX-# define NOMINMAX-# endif-# include <CL/cl_d3d11.h>+# ifndef NOMINMAX+# define NOMINMAX+# endif+# include <CL/cl_d3d11.h>typedef cl_d3d11_device_source_khr cl_device_source_intel;-typedef cl_d3d11_device_set_khr cl_device_set_intel;+typedef cl_d3d11_device_set_khr cl_device_set_intel;#else-# include <CL/cl_va_api_media_sharing_intel.h>+# include <CL/cl_va_api_media_sharing_intel.h>using cl_device_source_intel = cl_va_api_device_source_intel;using cl_device_set_intel = cl_va_api_device_set_intel;#endif@@ -38,16 +38,16 @@ using cl_device_set_intel = cl_va_api_device_set_intel;#include <sstream>/********************************************-* cl_intel_required_subgroup_size extension *-*********************************************/+ * cl_intel_required_subgroup_size extension *+ *********************************************/#if !defined(cl_intel_required_subgroup_size)-#define cl_intel_required_subgroup_size 1+# define cl_intel_required_subgroup_size 1// cl_intel_required_subgroup_size-#define CL_DEVICE_SUB_GROUP_SIZES_INTEL 0x4108+# define CL_DEVICE_SUB_GROUP_SIZES_INTEL 0x4108-#endif // cl_intel_required_subgroup_size+#endif // cl_intel_required_subgroup_size#ifdef OPENVINO_CLHPP_HEADERS_ARE_OLDER_THAN_V2024_10_24@@ -57,26 +57,26 @@ CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_SUB_GROUP_SIZES_INTEL, cl} // namespace detail} // namespace cl-#endif // OPENVINO_CLHPP_HEADERS_ARE_OLDER_THAN_V2024_10_24+#endif // OPENVINO_CLHPP_HEADERS_ARE_OLDER_THAN_V2024_10_24#if !defined(CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT)-#define CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT 0x1065+# define CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT 0x1065#endif#if !defined(CL_DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT)-#define CL_DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT 0x1068+# define CL_DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT 0x1068#endif/***************************************************************-* cl_intel_command_queue_families-***************************************************************/+ * cl_intel_command_queue_families+ ***************************************************************/#if !defined(cl_intel_command_queue_families)-#define cl_intel_command_queue_families 1+# define cl_intel_command_queue_families 1-typedef cl_bitfield cl_command_queue_capabilities_intel;+typedef cl_bitfield cl_command_queue_capabilities_intel;-#define CL_QUEUE_FAMILY_MAX_NAME_SIZE_INTEL 64+# define CL_QUEUE_FAMILY_MAX_NAME_SIZE_INTEL 64typedef struct _cl_queue_family_properties_intel {cl_command_queue_properties properties;@@ -86,154 +86,131 @@ typedef struct _cl_queue_family_properties_intel {} cl_queue_family_properties_intel;/* cl_device_info */-#define CL_DEVICE_QUEUE_FAMILY_PROPERTIES_INTEL 0x418B+# define CL_DEVICE_QUEUE_FAMILY_PROPERTIES_INTEL 0x418B/* cl_queue_properties */-#define CL_QUEUE_FAMILY_INTEL 0x418C-#define CL_QUEUE_INDEX_INTEL 0x418D+# define CL_QUEUE_FAMILY_INTEL 0x418C+# define CL_QUEUE_INDEX_INTEL 0x418D/* cl_command_queue_capabilities_intel */-#define CL_QUEUE_DEFAULT_CAPABILITIES_INTEL 0+# define CL_QUEUE_DEFAULT_CAPABILITIES_INTEL 0#endif // cl_intel_command_queue_families/*******************************************-* cl_intel_unified_shared_memory extension *-********************************************/+ * cl_intel_unified_shared_memory extension *+ ********************************************/#if !defined(cl_intel_unified_shared_memory)-#define cl_intel_unified_shared_memory 1+# define cl_intel_unified_shared_memory 1/* cl_mem_alloc_info_intel */-#define CL_MEM_ALLOC_TYPE_INTEL 0x419A-#define CL_MEM_ALLOC_SIZE_INTEL 0x419C+# define CL_MEM_ALLOC_TYPE_INTEL 0x419A+# define CL_MEM_ALLOC_SIZE_INTEL 0x419C/* cl_unified_shared_memory_type_intel */-#define CL_MEM_TYPE_UNKNOWN_INTEL 0x4196-#define CL_MEM_TYPE_HOST_INTEL 0x4197-#define CL_MEM_TYPE_DEVICE_INTEL 0x4198-#define CL_MEM_TYPE_SHARED_INTEL 0x4199+# define CL_MEM_TYPE_UNKNOWN_INTEL 0x4196+# define CL_MEM_TYPE_HOST_INTEL 0x4197+# define CL_MEM_TYPE_DEVICE_INTEL 0x4198+# define CL_MEM_TYPE_SHARED_INTEL 0x4199/* cl_device_info */-#define CL_DEVICE_HOST_MEM_CAPABILITIES_INTEL 0x4190-#define CL_DEVICE_DEVICE_MEM_CAPABILITIES_INTEL 0x4191-#define CL_DEVICE_SINGLE_DEVICE_SHARED_MEM_CAPABILITIES_INTEL 0x4192+# define CL_DEVICE_HOST_MEM_CAPABILITIES_INTEL 0x4190+# define CL_DEVICE_DEVICE_MEM_CAPABILITIES_INTEL 0x4191+# define CL_DEVICE_SINGLE_DEVICE_SHARED_MEM_CAPABILITIES_INTEL 0x4192/* cl_device_unified_shared_memory_capabilities_intel - bitfield */-#define CL_UNIFIED_SHARED_MEMORY_ACCESS_INTEL (1 << 0)+# define CL_UNIFIED_SHARED_MEMORY_ACCESS_INTEL (1 << 0)-typedef cl_ulong cl_properties;+typedef cl_ulong cl_properties;typedef cl_properties cl_mem_properties_intel;typedef cl_uint cl_mem_info_intel;typedef cl_uint cl_unified_shared_memory_type_intel;typedef cl_bitfield cl_device_unified_shared_memory_capabilities_intel;-typedef cl_int (CL_API_CALL *-clMemFreeINTEL_fn)(- cl_context context,- void* ptr);--typedef cl_int (CL_API_CALL *-clSetKernelArgMemPointerINTEL_fn)(- cl_kernel kernel,- cl_uint arg_index,- const void* arg_value);--typedef cl_int (CL_API_CALL *-clEnqueueMemcpyINTEL_fn)(- cl_command_queue command_queue,- cl_bool blocking,- void* dst_ptr,- const void* src_ptr,- size_t size,- cl_uint num_events_in_wait_list,- const cl_event* event_wait_list,- cl_event* event);--typedef void* (CL_API_CALL *-clHostMemAllocINTEL_fn)(- cl_context context,- const cl_mem_properties_intel* properties,- size_t size,- cl_uint alignment,- cl_int* errcode_ret);--typedef void* (CL_API_CALL *-clSharedMemAllocINTEL_fn)(- cl_context context,- cl_device_id device,- const cl_mem_properties_intel* properties,- size_t size,- cl_uint alignment,- cl_int* errcode_ret);--typedef void* (CL_API_CALL *-clDeviceMemAllocINTEL_fn)(- cl_context context,- cl_device_id device,- const cl_mem_properties_intel* properties,- size_t size,- cl_uint alignment,- cl_int* errcode_ret);--typedef cl_int (CL_API_CALL *-clGetMemAllocInfoINTEL_fn)(- cl_context context,- const void* ptr,- cl_mem_info_intel param_name,- size_t param_value_size,- void* param_value,- size_t* param_value_size_ret);--typedef cl_int (CL_API_CALL *-clEnqueueMemsetINTEL_fn)( /* Deprecated */- cl_command_queue command_queue,- void* dst_ptr,- cl_int value,- size_t size,- cl_uint num_events_in_wait_list,- const cl_event* event_wait_list,- cl_event* event);--typedef cl_int (CL_API_CALL *-clEnqueueMemFillINTEL_fn)(- cl_command_queue command_queue,- void* dst_ptr,- const void* pattern,- size_t pattern_size,- size_t size,- cl_uint num_events_in_wait_list,- const cl_event* event_wait_list,- cl_event* event);--#endif // cl_intel_unified_shared_memory+typedef cl_int(CL_API_CALL* clMemFreeINTEL_fn)(cl_context context, void* ptr);++typedef cl_int(CL_API_CALL* clSetKernelArgMemPointerINTEL_fn)(cl_kernel kernel, cl_uint arg_index, const void* arg_value);++typedef cl_int(CL_API_CALL* clEnqueueMemcpyINTEL_fn)(cl_command_queue command_queue,+ cl_bool blocking,+ void* dst_ptr,+ const void* src_ptr,+ size_t size,+ cl_uint num_events_in_wait_list,+ const cl_event* event_wait_list,+ cl_event* event);++typedef void*(+ CL_API_CALL* clHostMemAllocINTEL_fn)(cl_context context, const cl_mem_properties_intel* properties, size_t size, cl_uint alignment, cl_int* errcode_ret);++typedef void*(CL_API_CALL* clSharedMemAllocINTEL_fn)(cl_context context,+ cl_device_id device,+ const cl_mem_properties_intel* properties,+ size_t size,+ cl_uint alignment,+ cl_int* errcode_ret);++typedef void*(CL_API_CALL* clDeviceMemAllocINTEL_fn)(cl_context context,+ cl_device_id device,+ const cl_mem_properties_intel* properties,+ size_t size,+ cl_uint alignment,+ cl_int* errcode_ret);++typedef cl_int(CL_API_CALL* clGetMemAllocInfoINTEL_fn)(cl_context context,+ const void* ptr,+ cl_mem_info_intel param_name,+ size_t param_value_size,+ void* param_value,+ size_t* param_value_size_ret);++typedef cl_int(CL_API_CALL* clEnqueueMemsetINTEL_fn)(/* Deprecated */+ cl_command_queue command_queue,+ void* dst_ptr,+ cl_int value,+ size_t size,+ cl_uint num_events_in_wait_list,+ const cl_event* event_wait_list,+ cl_event* event);++typedef cl_int(CL_API_CALL* clEnqueueMemFillINTEL_fn)(cl_command_queue command_queue,+ void* dst_ptr,+ const void* pattern,+ size_t pattern_size,+ size_t size,+ cl_uint num_events_in_wait_list,+ const cl_event* event_wait_list,+ cl_event* event);++#endif // cl_intel_unified_shared_memory/********************************-* cl_intel_planar_yuv extension *-*********************************/+ * cl_intel_planar_yuv extension *+ *********************************/#if !defined(CL_NV12_INTEL)-#define CL_NV12_INTEL 0x410E-#endif // CL_NV12_INTEL+# define CL_NV12_INTEL 0x410E+#endif // CL_NV12_INTEL#if !defined(CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)-#define CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL (1 << 25)-#endif // CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL+# define CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL (1 << 25)+#endif // CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL/*********************************-* cl_khr_device_uuid extension-*********************************/+ * cl_khr_device_uuid extension+ *********************************/#if !defined(cl_khr_device_uuid)-#define cl_khr_device_uuid 1+# define cl_khr_device_uuid 1-#define CL_UUID_SIZE_KHR 16-#define CL_LUID_SIZE_KHR 8+# define CL_UUID_SIZE_KHR 16+# define CL_LUID_SIZE_KHR 8-#define CL_DEVICE_UUID_KHR 0x106A-#define CL_DEVICE_LUID_KHR 0x106D+# define CL_DEVICE_UUID_KHR 0x106A+# define CL_DEVICE_LUID_KHR 0x106D-#endif // cl_khr_device_uuid+#endif // cl_khr_device_uuid// some versions of CL/opencl.hpp don't define C++ wrapper for CL_DEVICE_UUID_KHR// we are checking it in cmake and defined macro OV_GPU_OPENCL_HPP_HAS_UUID if it is defined@@ -250,40 +227,40 @@ CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_LUID_KHR, luid_array)} // namespace detail} // namespace cl-#endif // OV_GPU_OPENCL_HPP_HAS_UUID+#endif // OV_GPU_OPENCL_HPP_HAS_UUID/***************************************************************-* cl_intel_device_attribute_query-***************************************************************/+ * cl_intel_device_attribute_query+ ***************************************************************/#if !defined(cl_intel_device_attribute_query)-#define cl_intel_device_attribute_query 1+# define cl_intel_device_attribute_query 1-typedef cl_bitfield cl_device_feature_capabilities_intel;+typedef cl_bitfield cl_device_feature_capabilities_intel;/* cl_device_feature_capabilities_intel */-#define CL_DEVICE_FEATURE_FLAG_DP4A_INTEL (1 << 0)-#define CL_DEVICE_FEATURE_FLAG_DPAS_INTEL (1 << 1)+# define CL_DEVICE_FEATURE_FLAG_DP4A_INTEL (1 << 0)+# define CL_DEVICE_FEATURE_FLAG_DPAS_INTEL (1 << 1)/* cl_device_info */-#define CL_DEVICE_IP_VERSION_INTEL 0x4250-#define CL_DEVICE_ID_INTEL 0x4251-#define CL_DEVICE_NUM_SLICES_INTEL 0x4252-#define CL_DEVICE_NUM_SUB_SLICES_PER_SLICE_INTEL 0x4253-#define CL_DEVICE_NUM_EUS_PER_SUB_SLICE_INTEL 0x4254-#define CL_DEVICE_NUM_THREADS_PER_EU_INTEL 0x4255-#define CL_DEVICE_FEATURE_CAPABILITIES_INTEL 0x4256+# define CL_DEVICE_IP_VERSION_INTEL 0x4250+# define CL_DEVICE_ID_INTEL 0x4251+# define CL_DEVICE_NUM_SLICES_INTEL 0x4252+# define CL_DEVICE_NUM_SUB_SLICES_PER_SLICE_INTEL 0x4253+# define CL_DEVICE_NUM_EUS_PER_SUB_SLICE_INTEL 0x4254+# define CL_DEVICE_NUM_THREADS_PER_EU_INTEL 0x4255+# define CL_DEVICE_FEATURE_CAPABILITIES_INTEL 0x4256-#endif // cl_intel_device_attribute_query+#endif // cl_intel_device_attribute_query/***************************************************************-* cl_khr_pci_bus_info-***************************************************************/+ * cl_khr_pci_bus_info+ ***************************************************************/#if !defined(cl_khr_pci_bus_info)-#define cl_khr_pci_bus_info 1+# define cl_khr_pci_bus_info 1-#define CL_KHR_PCI_BUS_INFO_EXTENSION_VERSION CL_MAKE_VERSION(1, 0, 0)+# define CL_KHR_PCI_BUS_INFO_EXTENSION_VERSION CL_MAKE_VERSION(1, 0, 0)typedef struct _cl_device_pci_bus_info_khr {cl_uint pci_domain;@@ -293,9 +270,9 @@ typedef struct _cl_device_pci_bus_info_khr {} cl_device_pci_bus_info_khr;/* cl_device_info */-#define CL_DEVICE_PCI_BUS_INFO_KHR 0x410F+# define CL_DEVICE_PCI_BUS_INFO_KHR 0x410F-#endif // cl_khr_pci_bus_info+#endif // cl_khr_pci_bus_info// some versions of CL/opencl.hpp don't define C++ wrapper for CL_DEVICE_BUS_INFO_KHR// we are checking it in cmake and defined macro OV_GPU_OPENCL_HPP_HAS_BUS_INFO if it is defined@@ -307,15 +284,15 @@ CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_PCI_BUS_INFO_KHR, cl_devi} // namespace detail} // namespace cl-#endif // OV_GPU_OPENCL_HPP_HAS_BUS_INFO+#endif // OV_GPU_OPENCL_HPP_HAS_BUS_INFO#ifndef CL_HPP_PARAM_NAME_CL_INTEL_COMMAND_QUEUE_FAMILIES_-#define CL_HPP_PARAM_NAME_CL_INTEL_COMMAND_QUEUE_FAMILIES_(F) \- F(cl_device_info, CL_DEVICE_QUEUE_FAMILY_PROPERTIES_INTEL, cl::vector<cl_queue_family_properties_intel>) \- \- F(cl_command_queue_info, CL_QUEUE_FAMILY_INTEL, cl_uint) \- F(cl_command_queue_info, CL_QUEUE_INDEX_INTEL, cl_uint)-#endif // CL_HPP_PARAM_NAME_CL_INTEL_COMMAND_QUEUE_FAMILIES_+# define CL_HPP_PARAM_NAME_CL_INTEL_COMMAND_QUEUE_FAMILIES_(F) \+ F(cl_device_info, CL_DEVICE_QUEUE_FAMILY_PROPERTIES_INTEL, cl::vector<cl_queue_family_properties_intel>) \+ \+ F(cl_command_queue_info, CL_QUEUE_FAMILY_INTEL, cl_uint) \+ F(cl_command_queue_info, CL_QUEUE_INDEX_INTEL, cl_uint)+#endif // CL_HPP_PARAM_NAME_CL_INTEL_COMMAND_QUEUE_FAMILIES_#ifdef OPENVINO_CLHPP_HEADERS_ARE_OLDER_THAN_V2024_10_24@@ -332,7 +309,7 @@ CL_HPP_PARAM_NAME_CL_INTEL_COMMAND_QUEUE_FAMILIES_(CL_HPP_DECLARE_PARAM_TRAITS_)} // namespace detail} // namespace cl-#endif // OPENVINO_CLHPP_HEADERS_ARE_OLDER_THAN_V2024_10_24+#endif // OPENVINO_CLHPP_HEADERS_ARE_OLDER_THAN_V2024_10_24#if CL_HPP_TARGET_OPENCL_VERSION >= 300 && !defined(CL_HPP_PARAM_NAME_INFO_3_0_)namespace cl {@@ -344,7 +321,7 @@ CL_HPP_DECLARE_PARAM_TRAITS_(cl_device_info, CL_DEVICE_WORK_GROUP_COLLECTIVE_FUN#endif#ifndef CL_EXTERNAL_MEMORY_HANDLE_DMA_BUF_KHR-#define CL_EXTERNAL_MEMORY_HANDLE_DMA_BUF_KHR 0x2067+# define CL_EXTERNAL_MEMORY_HANDLE_DMA_BUF_KHR 0x2067#endif#define CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL (1 << 23)@@ -360,12 +337,12 @@ T load_entrypoint(const cl_platform_id platform, const std::string name) {// The pointer returned should be cast to a function pointer type matching the extension function's definition defined in the appropriate extension// specification and header file."// So the pointer-to-object to pointer-to-function cast below is supposed to be valid, thus we suppress warning from old GCC versions.-#pragma GCC diagnostic push-#pragma GCC diagnostic ignored "-Wpedantic"+# pragma GCC diagnostic push+# pragma GCC diagnostic ignored "-Wpedantic"#endifT p = reinterpret_cast<T>(clGetExtensionFunctionAddressForPlatform(platform, name.c_str()));#if defined(__GNUC__) && __GNUC__ < 5-#pragma GCC diagnostic pop+# pragma GCC diagnostic pop#endifif (!p) {throw std::runtime_error("clGetExtensionFunctionAddressForPlatform(" + name + ") returned NULL.");@@ -424,11 +401,9 @@ T try_load_entrypoint(const cl_platform_id platform, const std::string name) {template <typename T>T load_entrypoint(const cl_kernel kernel, const std::string name) {cl_context context;- cl_int error = clGetKernelInfo(kernel, CL_KERNEL_CONTEXT, sizeof(context),- &context, nullptr);+ cl_int error = clGetKernelInfo(kernel, CL_KERNEL_CONTEXT, sizeof(context), &context, nullptr);if (error) {- throw std::runtime_error("Failed to retrieve CL_KERNEL_CONTEXT: " +- std::to_string(error));+ throw std::runtime_error("Failed to retrieve CL_KERNEL_CONTEXT: " + std::to_string(error));}return load_entrypoint<T>(context, name);}@@ -436,48 +411,35 @@ T load_entrypoint(const cl_kernel kernel, const std::string name) {template <typename T>T load_entrypoint(const cl_command_queue queue, const std::string name) {cl_context context;- cl_int error = clGetCommandQueueInfo(queue, CL_QUEUE_CONTEXT, sizeof(context),- &context, nullptr);+ cl_int error = clGetCommandQueueInfo(queue, CL_QUEUE_CONTEXT, sizeof(context), &context, nullptr);if (error) {- throw std::runtime_error("Failed to retrieve CL_QUEUE_CONTEXT: " +- std::to_string(error));+ throw std::runtime_error("Failed to retrieve CL_QUEUE_CONTEXT: " + std::to_string(error));}return load_entrypoint<T>(context, name);}} // namespace-namespace cl {-using PFN_clEnqueueAcquireMediaSurfacesINTEL = CL_API_ENTRY cl_int(CL_API_CALL *)(- cl_command_queue /* command_queue */,- cl_uint /* num_objects */,- const cl_mem* /* mem_objects */,- cl_uint /* num_events_in_wait_list */,- const cl_event* /* event_wait_list */,- cl_event* /* event */);--using PFN_clEnqueueReleaseMediaSurfacesINTEL = CL_API_ENTRY cl_int(CL_API_CALL *)(- cl_command_queue /* command_queue */,- cl_uint /* num_objects */,- const cl_mem* /* mem_objects */,- cl_uint /* num_events_in_wait_list */,- const cl_event* /* event_wait_list */,- cl_event* /* event */);--using PFN_clCreateFromMediaSurfaceINTEL = CL_API_ENTRY cl_mem(CL_API_CALL *)(- cl_context /* context */,- cl_mem_flags /* flags */,- void* /* surface */,- cl_uint /* plane */,- cl_int* /* errcode_ret */);+using PFN_clEnqueueAcquireMediaSurfacesINTEL = CL_API_ENTRY cl_int(CL_API_CALL*)(cl_command_queue /* command_queue */,+ cl_uint /* num_objects */,+ const cl_mem* /* mem_objects */,+ cl_uint /* num_events_in_wait_list */,+ const cl_event* /* event_wait_list */,+ cl_event* /* event */);++using PFN_clEnqueueReleaseMediaSurfacesINTEL = CL_API_ENTRY cl_int(CL_API_CALL*)(cl_command_queue /* command_queue */,+ cl_uint /* num_objects */,+ const cl_mem* /* mem_objects */,+ cl_uint /* num_events_in_wait_list */,+ const cl_event* /* event_wait_list */,+ cl_event* /* event */);+using PFN_clCreateFromMediaSurfaceINTEL =+ CL_API_ENTRY cl_mem(CL_API_CALL*)(cl_context /* context */, cl_mem_flags /* flags */, void* /* surface */, cl_uint /* plane */, cl_int* /* errcode_ret */);#ifdef WIN32- using PFN_clCreateFromD3D11Buffer = CL_API_ENTRY cl_mem(CL_API_CALL *)(- cl_context context,- cl_mem_flags flags,- void* resource, cl_int* errcode_ret);+using PFN_clCreateFromD3D11Buffer = CL_API_ENTRY cl_mem(CL_API_CALL*)(cl_context context, cl_mem_flags flags, void* resource, cl_int* errcode_ret);#endifclass SharedSurfLock {@@ -505,15 +467,9 @@ public:}}- SharedSurfLock(cl_command_queue queue,- std::vector<cl_mem>& surfaces,- cl_int * err = nullptr)- : m_queue(queue), m_surfaces(surfaces), m_errPtr(err) {+ SharedSurfLock(cl_command_queue queue, std::vector<cl_mem>& surfaces, cl_int* err = nullptr) : m_queue(queue), m_surfaces(surfaces), m_errPtr(err) {if (pfn_acquire != nullptr && !m_surfaces.empty()) {- cl_int error = pfn_acquire(m_queue,- static_cast<cl_uint>(m_surfaces.size()),- m_surfaces.data(),- 0, nullptr, nullptr);+ cl_int error = pfn_acquire(m_queue, static_cast<cl_uint>(m_surfaces.size()), m_surfaces.data(), 0, nullptr, nullptr);if (error != CL_SUCCESS && m_errPtr != nullptr) {*m_errPtr = error;@@ -523,10 +479,7 @@ public:~SharedSurfLock() {if (pfn_release != nullptr && !m_surfaces.empty()) {- cl_int error = pfn_release(m_queue,- static_cast<cl_uint>(m_surfaces.size()),- m_surfaces.data(),- 0, nullptr, nullptr);+ cl_int error = pfn_release(m_queue, static_cast<cl_uint>(m_surfaces.size()), m_surfaces.data(), 0, nullptr, nullptr);if (error != CL_SUCCESS && m_errPtr != nullptr) {*m_errPtr = error;}@@ -550,31 +503,29 @@ public:}/*! \brief Constructs a ImageVA, in a specified context, from a- * given vaSurfaceID.- *- * Wraps clCreateFromMediaSurfaceINTEL().- */- ImageVA(- const Context& context,- cl_mem_flags flags,+ * given vaSurfaceID.+ *+ * Wraps clCreateFromMediaSurfaceINTEL().+ */+ ImageVA(const Context& context,+ cl_mem_flags flags,#ifdef WIN32- void* surface,+ void* surface,#else- uint32_t surface,+ uint32_t surface,#endif- uint32_t plane,- cl_int * err = nullptr) {+ uint32_t plane,+ cl_int* err = nullptr) {cl_int error;- object_ = pfn_clCreateFromMediaSurfaceINTEL(- context(),- flags,+ object_ = pfn_clCreateFromMediaSurfaceINTEL(context(),+ flags,#ifdef WIN32- surface,+ surface,#else- reinterpret_cast<void*>(&surface),+ reinterpret_cast<void*>(&surface),#endif- plane,- &error);+ plane,+ &error);detail::errHandler(error);if (err != nullptr) {@@ -586,43 +537,42 @@ public:ImageVA() = default;/*! \brief Constructor from cl_mem - takes ownership.- *- * \param retainObject will cause the constructor to retain its cl object.- * Defaults to false to maintain compatibility with- * earlier versions.- * See Memory for further details.- */- explicit ImageVA(const cl_mem& image, bool retainObject = false) :- Image2D(image, retainObject) { }+ *+ * \param retainObject will cause the constructor to retain its cl object.+ * Defaults to false to maintain compatibility with+ * earlier versions.+ * See Memory for further details.+ */+ explicit ImageVA(const cl_mem& image, bool retainObject = false) : Image2D(image, retainObject) {}/*! \brief Assignment from cl_mem - performs shallow copy.- *- * See Memory for further details.- */- ImageVA& operator = (const cl_mem& rhs) {+ *+ * See Memory for further details.+ */+ ImageVA& operator=(const cl_mem& rhs) {Image2D::operator=(rhs);return *this;}/*! \brief Copy constructor to forward copy to the superclass correctly.- * Required for MSVC.- */+ * Required for MSVC.+ */ImageVA(const ImageVA& img) = default;/*! \brief Copy assignment to forward copy to the superclass correctly.- * Required for MSVC.- */- ImageVA& operator = (const ImageVA &img) = default;+ * Required for MSVC.+ */+ ImageVA& operator=(const ImageVA& img) = default;/*! \brief Move constructor to forward move to the superclass correctly.- * Required for MSVC.- */+ * Required for MSVC.+ */ImageVA(ImageVA&& buf) noexcept : Image2D(std::move(buf)) {}/*! \brief Move assignment to forward move to the superclass correctly.- * Required for MSVC.- */- ImageVA& operator = (ImageVA &&buf) {+ * Required for MSVC.+ */+ ImageVA& operator=(ImageVA&& buf) {Image2D::operator=(std::move(buf));return *this;}@@ -640,18 +590,10 @@ public:}}- BufferDX(- const Context& context,- cl_mem_flags flags,- void* resource,- cl_int * err = NULL) {+ BufferDX(const Context& context, cl_mem_flags flags, void* resource, cl_int* err = NULL) {cl_int error;ID3D11Buffer* buffer = static_cast<ID3D11Buffer*>(resource);- object_ = pfn_clCreateFromD3D11Buffer(- context(),- flags,- buffer,- &error);+ object_ = pfn_clCreateFromD3D11Buffer(context(), flags, buffer, &error);detail::errHandler(error);if (err != NULL) {@@ -660,50 +602,48 @@ public:}//! \brief Default constructor - initializes to NULL.- BufferDX() : Buffer() { }+ BufferDX() : Buffer() {}/*! \brief Constructor from cl_mem - takes ownership.- *- * \param retainObject will cause the constructor to retain its cl object.- * Defaults to false to maintain compatibility with- * earlier versions.- * See Memory for further details.- */- explicit BufferDX(const cl_mem& buf, bool retainObject = false) :- Buffer(buf, retainObject) { }+ *+ * \param retainObject will cause the constructor to retain its cl object.+ * Defaults to false to maintain compatibility with+ * earlier versions.+ * See Memory for further details.+ */+ explicit BufferDX(const cl_mem& buf, bool retainObject = false) : Buffer(buf, retainObject) {}/*! \brief Assignment from cl_mem - performs shallow copy.- *- * See Memory for further details.- */- BufferDX& operator = (const cl_mem& rhs) {+ *+ * See Memory for further details.+ */+ BufferDX& operator=(const cl_mem& rhs) {Buffer::operator=(rhs);return *this;}/*! \brief Copy constructor to forward copy to the superclass correctly.- * Required for MSVC.- */- BufferDX(const BufferDX& buf) :- Buffer(buf) {}+ * Required for MSVC.+ */+ BufferDX(const BufferDX& buf) : Buffer(buf) {}/*! \brief Copy assignment to forward copy to the superclass correctly.- * Required for MSVC.- */- BufferDX& operator = (const BufferDX &buf) {+ * Required for MSVC.+ */+ BufferDX& operator=(const BufferDX& buf) {Buffer::operator=(buf);return *this;}/*! \brief Move constructor to forward move to the superclass correctly.- * Required for MSVC.- */+ * Required for MSVC.+ */BufferDX(BufferDX&& buf) noexcept : Buffer(std::move(buf)) {}/*! \brief Move assignment to forward move to the superclass correctly.- * Required for MSVC.- */- BufferDX& operator = (BufferDX &&buf) {+ * Required for MSVC.+ */+ BufferDX& operator=(BufferDX&& buf) {Buffer::operator=(std::move(buf));return *this;}@@ -711,36 +651,37 @@ public:#endifclass ExternalMemoryHelper {- using PFN_clEnqueueAcquireExternalMemObjectsKHR = CL_API_ENTRY cl_int(CL_API_CALL *)(- cl_command_queue /* command_queue */,- cl_uint /* num_mem_objects */,- const cl_mem* /* mem_objects */,- cl_uint /* num_events_in_wait_list */,- const cl_event* /* event_wait_list */,- cl_event* /* event */);-- using PFN_clEnqueueReleaseExternalMemObjectsKHR = CL_API_ENTRY cl_int(CL_API_CALL *)(- cl_command_queue /* command_queue */,- cl_uint /* num_mem_objects */,- const cl_mem* /* mem_objects */,- cl_uint /* num_events_in_wait_list */,- const cl_event* /* event_wait_list */,- cl_event* /* event */);-public:+ using PFN_clEnqueueAcquireExternalMemObjectsKHR = CL_API_ENTRY cl_int(CL_API_CALL*)(cl_command_queue /* command_queue */,+ cl_uint /* num_mem_objects */,+ const cl_mem* /* mem_objects */,+ cl_uint /* num_events_in_wait_list */,+ const cl_event* /* event_wait_list */,+ cl_event* /* event */);++ using PFN_clEnqueueReleaseExternalMemObjectsKHR = CL_API_ENTRY cl_int(CL_API_CALL*)(cl_command_queue /* command_queue */,+ cl_uint /* num_mem_objects */,+ const cl_mem* /* mem_objects */,+ cl_uint /* num_events_in_wait_list */,+ const cl_event* /* event_wait_list */,+ cl_event* /* event */);+public:static cl_int acquire(cl_platform_id platform, cl_command_queue queue, const cl_mem& mem) {auto pfn = get_acquire(platform);- if (pfn == nullptr)+ if (pfn == nullptr) {return CL_INVALID_OPERATION;+ }return pfn(queue, 1, &mem, 0, nullptr, nullptr);}static cl_int release(cl_platform_id platform, cl_command_queue queue, const cl_mem& mem) {auto pfn = get_release(platform);- if (pfn == nullptr)+ if (pfn == nullptr) {return CL_INVALID_OPERATION;+ }return pfn(queue, 1, &mem, 0, nullptr, nullptr);}+private:static PFN_clEnqueueAcquireExternalMemObjectsKHR get_acquire(cl_platform_id platform) {static PFN_clEnqueueAcquireExternalMemObjectsKHR fn = nullptr;@@ -757,7 +698,6 @@ private:}return fn;}-};class PlatformVA : public Platform {@@ -765,22 +705,16 @@ public://! \brief Default constructor - initializes to NULL.PlatformVA() = default;- explicit PlatformVA(const cl_platform_id &platform, bool retainObject = false) :- Platform(platform, retainObject) { }-- cl_int getDevices(- cl_device_source_intel media_adapter_type,- void * media_adapter,- cl_device_set_intel media_adapter_set,- vector<Device>* devices) const {- using PFN_clGetDeviceIDsFromMediaAdapterINTEL = CL_API_ENTRY cl_int(CL_API_CALL *)(- cl_platform_id /* platform */,- cl_device_source_intel /* media_adapter_type */,- void * /* media_adapter */,- cl_device_set_intel /* media_adapter_set */,- cl_uint /* num_entries */,- cl_device_id * /* devices */,- cl_uint * /* num_devices */);+ explicit PlatformVA(const cl_platform_id& platform, bool retainObject = false) : Platform(platform, retainObject) {}++ cl_int getDevices(cl_device_source_intel media_adapter_type, void* media_adapter, cl_device_set_intel media_adapter_set, vector<Device>* devices) const {+ using PFN_clGetDeviceIDsFromMediaAdapterINTEL = CL_API_ENTRY cl_int(CL_API_CALL*)(cl_platform_id /* platform */,+ cl_device_source_intel /* media_adapter_type */,+ void* /* media_adapter */,+ cl_device_set_intel /* media_adapter_set */,+ cl_uint /* num_entries */,+ cl_device_id* /* devices */,+ cl_uint* /* num_devices */);#ifdef WIN32const char* fname = "clGetDeviceIDsFromD3D11KHR";#else@@ -798,28 +732,14 @@ public:}cl_uint n = 0;- cl_int err = pfn_clGetDeviceIDsFromMediaAdapterINTEL(- object_,- media_adapter_type,- media_adapter,- media_adapter_set,- 0,- nullptr,- &n);+ cl_int err = pfn_clGetDeviceIDsFromMediaAdapterINTEL(object_, media_adapter_type, media_adapter, media_adapter_set, 0, nullptr, &n);if (err != CL_SUCCESS && err != CL_DEVICE_NOT_FOUND) {return detail::errHandler(err, fname);}if (err != CL_DEVICE_NOT_FOUND) {vector<cl_device_id> ids(n);- err = pfn_clGetDeviceIDsFromMediaAdapterINTEL(- object_,- media_adapter_type,- media_adapter,- media_adapter_set,- n,- ids.data(),- nullptr);+ err = pfn_clGetDeviceIDsFromMediaAdapterINTEL(object_, media_adapter_type, media_adapter, media_adapter_set, n, ids.data(), nullptr);if (err != CL_SUCCESS) {return detail::errHandler(err, fname);}@@ -853,108 +773,128 @@ class UsmHelper {public:explicit UsmHelper(const cl::Context& ctx, const cl::Device device, bool use_usm) : _ctx(ctx), _device(device) {if (use_usm) {- _host_mem_alloc_fn = try_load_entrypoint<clHostMemAllocINTEL_fn>(_ctx.get(), "clHostMemAllocINTEL");- _shared_mem_alloc_fn = try_load_entrypoint<clSharedMemAllocINTEL_fn>(_ctx.get(), "clSharedMemAllocINTEL");- _device_mem_alloc_fn = try_load_entrypoint<clDeviceMemAllocINTEL_fn>(_ctx.get(), "clDeviceMemAllocINTEL");- _mem_free_fn = try_load_entrypoint<clMemFreeINTEL_fn>(_ctx.get(), "clMemFreeINTEL");+ _host_mem_alloc_fn = try_load_entrypoint<clHostMemAllocINTEL_fn>(_ctx.get(), "clHostMemAllocINTEL");+ _shared_mem_alloc_fn = try_load_entrypoint<clSharedMemAllocINTEL_fn>(_ctx.get(), "clSharedMemAllocINTEL");+ _device_mem_alloc_fn = try_load_entrypoint<clDeviceMemAllocINTEL_fn>(_ctx.get(), "clDeviceMemAllocINTEL");+ _mem_free_fn = try_load_entrypoint<clMemFreeINTEL_fn>(_ctx.get(), "clMemFreeINTEL");_set_kernel_arg_mem_pointer_fn = try_load_entrypoint<clSetKernelArgMemPointerINTEL_fn>(_ctx.get(), "clSetKernelArgMemPointerINTEL");- _enqueue_memcpy_fn = try_load_entrypoint<clEnqueueMemcpyINTEL_fn>(_ctx.get(), "clEnqueueMemcpyINTEL");- _enqueue_mem_fill_fn = try_load_entrypoint<clEnqueueMemFillINTEL_fn>(_ctx.get(), "clEnqueueMemFillINTEL");- _enqueue_memset_fn = try_load_entrypoint<clEnqueueMemsetINTEL_fn>(_ctx.get(), "clEnqueueMemsetINTEL");- _get_mem_alloc_info_fn = try_load_entrypoint<clGetMemAllocInfoINTEL_fn>(_ctx.get(), "clGetMemAllocInfoINTEL");+ _enqueue_memcpy_fn = try_load_entrypoint<clEnqueueMemcpyINTEL_fn>(_ctx.get(), "clEnqueueMemcpyINTEL");+ _enqueue_mem_fill_fn = try_load_entrypoint<clEnqueueMemFillINTEL_fn>(_ctx.get(), "clEnqueueMemFillINTEL");+ _enqueue_memset_fn = try_load_entrypoint<clEnqueueMemsetINTEL_fn>(_ctx.get(), "clEnqueueMemsetINTEL");+ _get_mem_alloc_info_fn = try_load_entrypoint<clGetMemAllocInfoINTEL_fn>(_ctx.get(), "clGetMemAllocInfoINTEL");}}- void* allocate_host(const cl_mem_properties_intel *properties, size_t size, cl_uint alignment, cl_int* err_code_ret) const {\- if (!_host_mem_alloc_fn)+ void* allocate_host(const cl_mem_properties_intel* properties, size_t size, cl_uint alignment, cl_int* err_code_ret) const {+ if (!_host_mem_alloc_fn) {throw std::runtime_error("[CLDNN] clHostMemAllocINTEL is nullptr");+ }return _host_mem_alloc_fn(_ctx.get(), properties, size, alignment, err_code_ret);}- void* allocate_shared(const cl_mem_properties_intel *properties, size_t size, cl_uint alignment, cl_int* err_code_ret) const {- if (!_shared_mem_alloc_fn)+ void* allocate_shared(const cl_mem_properties_intel* properties, size_t size, cl_uint alignment, cl_int* err_code_ret) const {+ if (!_shared_mem_alloc_fn) {throw std::runtime_error("[CLDNN] clSharedMemAllocINTEL is nullptr");+ }return _shared_mem_alloc_fn(_ctx.get(), _device.get(), properties, size, alignment, err_code_ret);}- void* allocate_device(const cl_mem_properties_intel *properties, size_t size, cl_uint alignment, cl_int* err_code_ret) const {- if (!_device_mem_alloc_fn)+ void* allocate_device(const cl_mem_properties_intel* properties, size_t size, cl_uint alignment, cl_int* err_code_ret) const {+ if (!_device_mem_alloc_fn) {throw std::runtime_error("[CLDNN] clDeviceMemAllocINTEL is nullptr");+ }return _device_mem_alloc_fn(_ctx.get(), _device.get(), properties, size, alignment, err_code_ret);}void free_mem(void* ptr) const {- if (!_mem_free_fn)+ if (!_mem_free_fn) {throw std::runtime_error("[CLDNN] clMemFreeINTEL is nullptr");+ }_mem_free_fn(_ctx.get(), ptr);}cl_int set_kernel_arg_mem_pointer(const cl::Kernel& kernel, uint32_t index, const void* ptr) const {- if (!_set_kernel_arg_mem_pointer_fn)+ if (!_set_kernel_arg_mem_pointer_fn) {throw std::runtime_error("[CLDNN] clSetKernelArgMemPointerINTEL is nullptr");+ }return _set_kernel_arg_mem_pointer_fn(kernel.get(), index, ptr);}- cl_int enqueue_memcpy(const cl::CommandQueue& cpp_queue, void *dst_ptr, const void *src_ptr,- size_t bytes_count, bool blocking = true, const std::vector<cl::Event>* wait_list = nullptr, cl::Event* ret_event = nullptr) const {- if (!_enqueue_memcpy_fn)+ cl_int enqueue_memcpy(const cl::CommandQueue& cpp_queue,+ void* dst_ptr,+ const void* src_ptr,+ size_t bytes_count,+ bool blocking = true,+ const std::vector<cl::Event>* wait_list = nullptr,+ cl::Event* ret_event = nullptr) const {+ if (!_enqueue_memcpy_fn) {throw std::runtime_error("[CLDNN] clEnqueueMemcpyINTEL is nullptr");+ }cl_event tmp;- cl_int err = _enqueue_memcpy_fn(- cpp_queue.get(),- static_cast<cl_bool>(blocking),- dst_ptr,- src_ptr,- bytes_count,- wait_list == nullptr ? 0 : static_cast<cl_uint>(wait_list->size()),- wait_list == nullptr ? nullptr : reinterpret_cast<const cl_event*>(&wait_list->front()),- ret_event == nullptr ? nullptr : &tmp);-- if (ret_event != nullptr && err == CL_SUCCESS)+ cl_int err = _enqueue_memcpy_fn(cpp_queue.get(),+ static_cast<cl_bool>(blocking),+ dst_ptr,+ src_ptr,+ bytes_count,+ wait_list == nullptr ? 0 : static_cast<cl_uint>(wait_list->size()),+ wait_list == nullptr ? nullptr : reinterpret_cast<const cl_event*>(&wait_list->front()),+ ret_event == nullptr ? nullptr : &tmp);++ if (ret_event != nullptr && err == CL_SUCCESS) {*ret_event = tmp;+ }return err;}- cl_int enqueue_fill_mem(const cl::CommandQueue& cpp_queue, void *dst_ptr, const void* pattern,- size_t pattern_size, size_t bytes_count, const std::vector<cl::Event>* wait_list = nullptr,+ cl_int enqueue_fill_mem(const cl::CommandQueue& cpp_queue,+ void* dst_ptr,+ const void* pattern,+ size_t pattern_size,+ size_t bytes_count,+ const std::vector<cl::Event>* wait_list = nullptr,cl::Event* ret_event = nullptr) const {- if (!_enqueue_mem_fill_fn)+ if (!_enqueue_mem_fill_fn) {throw std::runtime_error("[CLDNN] clEnqueueMemFillINTEL is nullptr");+ }cl_event tmp;- cl_int err = _enqueue_mem_fill_fn(- cpp_queue.get(),- dst_ptr,- pattern,- pattern_size,- bytes_count,- wait_list == nullptr ? 0 : static_cast<cl_uint>(wait_list->size()),- wait_list == nullptr ? nullptr : reinterpret_cast<const cl_event*>(&wait_list->front()),- ret_event == nullptr ? nullptr : &tmp);-- if (ret_event != nullptr && err == CL_SUCCESS)+ cl_int err = _enqueue_mem_fill_fn(cpp_queue.get(),+ dst_ptr,+ pattern,+ pattern_size,+ bytes_count,+ wait_list == nullptr ? 0 : static_cast<cl_uint>(wait_list->size()),+ wait_list == nullptr ? nullptr : reinterpret_cast<const cl_event*>(&wait_list->front()),+ ret_event == nullptr ? nullptr : &tmp);++ if (ret_event != nullptr && err == CL_SUCCESS) {*ret_event = tmp;+ }return err;}- cl_int enqueue_set_mem(const cl::CommandQueue& cpp_queue, void* dst_ptr, cl_int value,- size_t bytes_count, const std::vector<cl::Event>* wait_list = nullptr,+ cl_int enqueue_set_mem(const cl::CommandQueue& cpp_queue,+ void* dst_ptr,+ cl_int value,+ size_t bytes_count,+ const std::vector<cl::Event>* wait_list = nullptr,cl::Event* ret_event = nullptr) const {- if (!_enqueue_memset_fn)+ if (!_enqueue_memset_fn) {throw std::runtime_error("[CLDNN] clEnqueueMemsetINTEL is nullptr");+ }cl_event tmp;- cl_int err = _enqueue_memset_fn(- cpp_queue.get(),- dst_ptr,- value,- bytes_count,- wait_list == nullptr ? 0 : static_cast<cl_uint>(wait_list->size()),- wait_list == nullptr ? nullptr : reinterpret_cast<const cl_event*>(&wait_list->front()),- ret_event == nullptr ? nullptr : &tmp);-- if (ret_event != nullptr && err == CL_SUCCESS)+ cl_int err = _enqueue_memset_fn(cpp_queue.get(),+ dst_ptr,+ value,+ bytes_count,+ wait_list == nullptr ? 0 : static_cast<cl_uint>(wait_list->size()),+ wait_list == nullptr ? nullptr : reinterpret_cast<const cl_event*>(&wait_list->front()),+ ret_event == nullptr ? nullptr : &tmp);++ if (ret_event != nullptr && err == CL_SUCCESS) {*ret_event = tmp;+ }return err;}@@ -1001,16 +941,16 @@ private:*/class UsmHolder {public:- UsmHolder(const cl::UsmHelper& usmHelper, void* ptr, bool shared_memory = false)- : _usmHelper(usmHelper)- , _ptr(ptr)- , _shared_memory(shared_memory) { }+ UsmHolder(const cl::UsmHelper& usmHelper, void* ptr, bool shared_memory = false) : _usmHelper(usmHelper), _ptr(ptr), _shared_memory(shared_memory) {}- void* ptr() { return _ptr; }+ void* ptr() {+ return _ptr;+ }void memFree() {try {- if (!_shared_memory)+ if (!_shared_memory) {_usmHelper.free_mem(_ptr);+ }} catch (...) {// Exception may happen only when clMemFreeINTEL function is unavailable, thus can't free memory properly}@@ -1019,6 +959,7 @@ public:~UsmHolder() {memFree();}+private:const cl::UsmHelper& _usmHelper;void* _ptr;@@ -1029,17 +970,19 @@ private:*/class UsmMemory {public:- explicit UsmMemory(const cl::UsmHelper& usmHelper) : _usmHelper(usmHelper) { }+ explicit UsmMemory(const cl::UsmHelper& usmHelper) : _usmHelper(usmHelper) {}UsmMemory(const cl::UsmHelper& usmHelper, void* usm_ptr, size_t offset = 0)- : _usmHelper(usmHelper)- , _usm_pointer(std::make_shared<UsmHolder>(_usmHelper, reinterpret_cast<uint8_t*>(usm_ptr) + offset, true)) {+ : _usmHelper(usmHelper),+ _usm_pointer(std::make_shared<UsmHolder>(_usmHelper, reinterpret_cast<uint8_t*>(usm_ptr) + offset, true)) {if (!usm_ptr) {throw std::runtime_error("[GPU] Can't share null usm pointer");}}// Get methods returns original pointer allocated by openCL.- void* get() const { return _usm_pointer->ptr(); }+ void* get() const {+ return _usm_pointer->ptr();+ }void allocateHost(size_t size, const cl_mem_properties_intel* properties = nullptr) {cl_int error = CL_SUCCESS;@@ -1063,8 +1006,9 @@ public:}void freeMem() {- if (!_usm_pointer)+ if (!_usm_pointer) {throw std::runtime_error("[CL ext] Can not free memory of empty UsmHolder");+ }_usm_pointer->memFree();}@@ -1083,8 +1027,9 @@ private:if (ptr == nullptr || error != CL_SUCCESS) {std::stringstream sout;sout << "[CL ext] Can not allocate " << size << " bytes for USM " << usm_type << ". ptr: " << ptr << ", error: " << error << std::endl;- if (ptr == nullptr)+ if (ptr == nullptr) {throw std::runtime_error(sout.str());+ }detail::errHandler(error, sout.str().c_str());}}@@ -1096,9 +1041,10 @@ private:*/class KernelIntel : public Kernel {using Kernel::Kernel;+public:explicit KernelIntel(const UsmHelper& usmHelper) : _usmHelper(usmHelper) {}- KernelIntel(const Kernel &other, const UsmHelper& usmHelper) : Kernel(other), _usmHelper(usmHelper) { }+ KernelIntel(const Kernel& other, const UsmHelper& usmHelper) : Kernel(other), _usmHelper(usmHelper) {}KernelIntel clone() const {Kernel cloned_kernel(this->getInfo<CL_KERNEL_PROGRAM>(), this->getInfo<CL_KERNEL_FUNCTION_NAME>().c_str());@@ -1108,16 +1054,17 @@ public:cl_int setArgUsm(cl_uint index, const UsmMemory& mem) {return detail::errHandler(_usmHelper.set_kernel_arg_mem_pointer(*this, index, mem.get()), "[CL_EXT] setArgUsm in KernelIntel failed");}+private:const UsmHelper& _usmHelper;};-inline bool operator==(const UsmMemory &lhs, const UsmMemory &rhs) {+inline bool operator==(const UsmMemory& lhs, const UsmMemory& rhs) {return lhs.get() == rhs.get();}-inline bool operator!=(const UsmMemory &lhs, const UsmMemory &rhs) {+inline bool operator!=(const UsmMemory& lhs, const UsmMemory& rhs) {return !operator==(lhs, rhs);}-} //namespace cl+} // namespace cldiff --git a/src/plugins/intel_gpu/src/runtime/ocl/ocl_kernel.cpp b/src/plugins/intel_gpu/src/runtime/ocl/ocl_kernel.cppindex 1209e4f0d77..1bc30e40cf9 100644--- a/src/plugins/intel_gpu/src/runtime/ocl/ocl_kernel.cpp+++ b/src/plugins/intel_gpu/src/runtime/ocl/ocl_kernel.cpp@@ -24,8 +24,9 @@ std::vector<uint8_t> ocl_kernel::get_binary() const {}// Binary is not available for the device.- if (binary_size == 0)+ if (binary_size == 0) {throw std::runtime_error("get_binary: Binary size is zero");+ }// Get program binary.std::vector<uint8_t> binary(binary_size);diff --git a/src/plugins/intel_gpu/src/runtime/ocl/ocl_kernel.hpp b/src/plugins/intel_gpu/src/runtime/ocl/ocl_kernel.hppindex 67b175a8dfb..28d670649c6 100644--- a/src/plugins/intel_gpu/src/runtime/ocl/ocl_kernel.hpp+++ b/src/plugins/intel_gpu/src/runtime/ocl/ocl_kernel.hpp@@ -28,8 +28,9 @@ public:const ocl_kernel_type& get_handle() const { return _compiled_kernel; }ocl_kernel_type& get_handle() { return _compiled_kernel; }std::shared_ptr<kernel> clone(bool reuse_kernel_handle = false) const override {- if (reuse_kernel_handle)+ if (reuse_kernel_handle) {return std::make_shared<ocl_kernel>(get_handle(), _kernel_id);+ }return std::make_shared<ocl_kernel>(get_handle().clone(), _kernel_id);}diff --git a/src/plugins/intel_gpu/src/runtime/ocl/ocl_memory.cpp b/src/plugins/intel_gpu/src/runtime/ocl/ocl_memory.cppindex a1bdfedbdd6..6832a5eb9c3 100644--- a/src/plugins/intel_gpu/src/runtime/ocl/ocl_memory.cpp+++ b/src/plugins/intel_gpu/src/runtime/ocl/ocl_memory.cpp@@ -137,8 +137,9 @@ shared_mem_params gpu_buffer::get_internal_params(runtime_types rt_type) const {event::ptr gpu_buffer::copy_from(stream& stream, const void* data_ptr, size_t src_offset, size_t dst_offset, size_t size, bool blocking) {auto result_event = create_event(stream, size, blocking);- if (size == 0)+ if (size == 0) {return result_event;+ }check_boundaries(SIZE_MAX, src_offset, _bytes_count, dst_offset, size, "gpu_buffer::copy_from(void*)");@@ -153,8 +154,9 @@ event::ptr gpu_buffer::copy_from(stream& stream, const void* data_ptr, size_t srevent::ptr gpu_buffer::copy_from(stream& stream, const memory& src_mem, size_t src_offset, size_t dst_offset, size_t size, bool blocking) {auto result_event = create_event(stream, size, false);- if (size == 0)+ if (size == 0) {return result_event;+ }check_boundaries(src_mem.size(), src_offset, _bytes_count, dst_offset, size, "gpu_buffer::copy_from(memory&)");@@ -177,8 +179,9 @@ event::ptr gpu_buffer::copy_from(stream& stream, const memory& src_mem, size_t sTRY_CATCH_CL_ERROR(cl_stream->get_cl_queue().enqueueCopyBuffer(cl_mem_buffer->get_buffer(), get_buffer(), src_offset, dst_offset, size, nullptr, ev_ocl));- if (blocking)+ if (blocking) {result_event->wait();+ }return result_event;}@@ -189,8 +192,9 @@ event::ptr gpu_buffer::copy_from(stream& stream, const memory& src_mem, size_t sevent::ptr gpu_buffer::copy_to(stream& stream, void* data_ptr, size_t src_offset, size_t dst_offset, size_t size, bool blocking) const {auto result_event = create_event(stream, size, blocking);- if (size == 0)+ if (size == 0) {return result_event;+ }check_boundaries(_bytes_count, src_offset, SIZE_MAX, dst_offset, size, "gpu_buffer::copy_to(void*)");@@ -387,8 +391,9 @@ shared_mem_params gpu_image2d::get_internal_params(runtime_types rt_type) constevent::ptr gpu_image2d::copy_from(stream& stream, const void* data_ptr, size_t src_offset, size_t dst_offset, size_t size, bool blocking) {auto result_event = create_event(stream, size, blocking);- if (size == 0)+ if (size == 0) {return result_event;+ }OPENVINO_ASSERT(dst_offset == 0, "[GPU] Unsupported dst_offset value for gpu_image2d::copy_from() function");OPENVINO_ASSERT(size == _bytes_count, "[GPU] Unsupported data_size value for gpu_image2d::copy_from() function");@@ -405,8 +410,9 @@ event::ptr gpu_image2d::copy_from(stream& stream, const void* data_ptr, size_t sevent::ptr gpu_image2d::copy_from(stream& stream, const memory& src_mem, size_t src_offset, size_t dst_offset, size_t size, bool blocking) {auto result_event = create_event(stream, size, false);- if (size == 0)+ if (size == 0) {return result_event;+ }OPENVINO_ASSERT(src_mem.get_layout().format.is_image_2d(), "Unsupported buffer type for gpu_image2d::copy_from() function");OPENVINO_ASSERT(src_offset == 0, "[GPU] Unsupported dst_offset value for gpu_image2d::copy_from() function");@@ -420,16 +426,18 @@ event::ptr gpu_image2d::copy_from(stream& stream, const memory& src_mem, size_tTRY_CATCH_CL_ERROR(cl_stream->get_cl_queue().enqueueCopyImage(cl_image_mem->get_buffer(), get_buffer(), {0, 0, 0}, {0, 0, 0}, {_width, _height, 1}, nullptr, cl_event));- if (blocking)+ if (blocking) {cl_event->wait();+ }return result_event;}event::ptr gpu_image2d::copy_to(stream& stream, void* data_ptr, size_t src_offset, size_t dst_offset, size_t size, bool blocking) const {auto result_event = create_event(stream, size, blocking);- if (size == 0)+ if (size == 0) {return result_event;+ }OPENVINO_ASSERT(src_offset == 0, "[GPU] Unsupported src_offset value for gpu_image2d::copy_from() function");OPENVINO_ASSERT(size == _bytes_count, "[GPU] Unsupported data_size value for gpu_image2d::copy_from() function");@@ -493,8 +501,9 @@ gpu_usm::gpu_usm(ocl_engine* engine, const layout& layout, allocation_type type), _buffer(engine->get_usm_helper()), _host_buffer(engine->get_usm_helper()) {auto actual_bytes_count = _bytes_count;- if (actual_bytes_count == 0)+ if (actual_bytes_count == 0) {actual_bytes_count = 1;+ }std::vector<cl_mem_properties_intel> properties = {0};if (engine->get_enable_large_allocations()) {@@ -602,8 +611,9 @@ event::ptr gpu_usm::fill(stream& stream, const std::vector<event::ptr>& dep_evenevent::ptr gpu_usm::copy_from(stream& stream, const void* data_ptr, size_t src_offset, size_t dst_offset, size_t size, bool blocking) {auto result_event = create_event(stream, size, blocking);- if (size == 0)+ if (size == 0) {return result_event;+ }check_boundaries(SIZE_MAX, src_offset, _bytes_count, dst_offset, size, "gpu_usm::copy_from(void*)");@@ -619,8 +629,9 @@ event::ptr gpu_usm::copy_from(stream& stream, const void* data_ptr, size_t src_oevent::ptr gpu_usm::copy_from(stream& stream, const memory& src_mem, size_t src_offset, size_t dst_offset, size_t size, bool blocking) {auto result_event = create_event(stream, size, blocking);- if (size == 0)+ if (size == 0) {return result_event;+ }check_boundaries(src_mem.size(), src_offset, _bytes_count, dst_offset, size, "gpu_usm::copy_from(memory&)");@@ -653,8 +664,9 @@ event::ptr gpu_usm::copy_from(stream& stream, const memory& src_mem, size_t src_event::ptr gpu_usm::copy_to(stream& stream, void* data_ptr, size_t src_offset, size_t dst_offset, size_t size, bool blocking) const {auto result_event = create_event(stream, size, blocking);- if (size == 0)+ if (size == 0) {return result_event;+ }check_boundaries(_bytes_count, src_offset, SIZE_MAX, dst_offset, size, "gpu_usm::copy_to(void*)");diff --git a/src/plugins/intel_gpu/src/runtime/ocl/ocl_stream.cpp b/src/plugins/intel_gpu/src/runtime/ocl/ocl_stream.cppindex 67ee086c809..9c9e65adc7d 100644--- a/src/plugins/intel_gpu/src/runtime/ocl/ocl_stream.cpp+++ b/src/plugins/intel_gpu/src/runtime/ocl/ocl_stream.cpp@@ -3,20 +3,21 @@//#include "ocl_stream.hpp"++#include <cassert>+#include <memory>+#include <string>+#include <vector>+#include "CL/cl.h"+#include "intel_gpu/runtime/debug_configuration.hpp"#include "intel_gpu/runtime/stream.hpp"-#include "ocl_event.hpp"-#include "ocl_user_event.hpp"#include "ocl_command_queues_builder.hpp"-#include "intel_gpu/runtime/debug_configuration.hpp"-#include "ocl_kernel.hpp"#include "ocl_common.hpp"+#include "ocl_event.hpp"+#include "ocl_kernel.hpp"#include "ocl_memory.hpp"--#include <cassert>-#include <string>-#include <vector>-#include <memory>+#include "ocl_user_event.hpp"// NOTE: Due to buggy scope transition of warnings we need to disable warning in place of use/instantation// of some types (even though we already disabled them in scope of definition of these types).@@ -24,11 +25,11 @@// of proper support for mangling of custom GCC attributes into type name (usually when used// with templates, even from standard library).#if defined __GNUC__ && __GNUC__ >= 6-#pragma GCC diagnostic ignored "-Wignored-attributes"+# pragma GCC diagnostic ignored "-Wignored-attributes"#endif#ifdef ENABLE_ONEDNN_FOR_GPU-#include <oneapi/dnnl/dnnl_ocl.hpp>+# include <oneapi/dnnl/dnnl_ocl.hpp>#endifnamespace cldnn {@@ -37,29 +38,30 @@ namespace ocl {namespace {inline cl::NDRange toNDRange(const std::vector<size_t>& v) {switch (v.size()) {- case 1:- return cl::NDRange(v[0]);- case 2:- return cl::NDRange(v[0], v[1]);- case 3:- return cl::NDRange(v[0], v[1], v[2]);- default:- return cl::NullRange;+ case 1:+ return cl::NDRange(v[0]);+ case 2:+ return cl::NDRange(v[0], v[1]);+ case 3:+ return cl::NDRange(v[0], v[1], v[2]);+ default:+ return cl::NullRange;}}-cl_int set_kernel_arg(ocl_kernel_type& kernel, uint32_t idx, uint32_t size) {- if (size == 0)+ if (size == 0) {return CL_INVALID_ARG_VALUE;+ }GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set arg " << idx << " local memory size : " << size << std::endl;return kernel.setArg(idx, size, nullptr);}cl_int set_kernel_arg(ocl_kernel_type& kernel, uint32_t idx, cldnn::memory::cptr mem) {- if (!mem)+ if (!mem) {return CL_INVALID_ARG_VALUE;+ }if (mem->get_layout().format.is_image_2d()) {auto buf = std::dynamic_pointer_cast<const ocl::gpu_image2d>(mem)->get_buffer();@@ -69,8 +71,8 @@ cl_int set_kernel_arg(ocl_kernel_type& kernel, uint32_t idx, cldnn::memory::cptrif (memory_capabilities::is_usm_type(mem->get_allocation_type())) {auto buf = std::dynamic_pointer_cast<const ocl::gpu_usm>(mem)->get_buffer();auto mem_type = std::dynamic_pointer_cast<const ocl::gpu_usm>(mem)->get_allocation_type();- GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set arg (" << mem_type << ") " << idx- << " mem: " << buf.get() << " size: " << mem->size() << std::endl;+ GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set arg (" << mem_type << ") " << idx << " mem: " << buf.get() << " size: " << mem->size()+ << std::endl;return kernel.setArgUsm(idx, buf);}auto buf = std::dynamic_pointer_cast<const ocl::gpu_buffer>(mem)->get_buffer();@@ -80,124 +82,121 @@ cl_int set_kernel_arg(ocl_kernel_type& kernel, uint32_t idx, cldnn::memory::cptrreturn CL_INVALID_ARG_VALUE;}-void set_arguments_impl(ocl_kernel_type& kernel,- const arguments_desc& args,- const kernel_arguments_data& data) {+void set_arguments_impl(ocl_kernel_type& kernel, const arguments_desc& args, const kernel_arguments_data& data) {using args_t = argument_desc::Types;using scalar_t = scalar_desc::Types;for (uint32_t i = 0; i < static_cast<uint32_t>(args.size()); i++) {cl_int status = CL_INVALID_ARG_VALUE;switch (args[i].t) {- case args_t::INPUT:- OPENVINO_ASSERT(args[i].index < data.inputs.size() && data.inputs[args[i].index],- "The allocated input memory is necessary to set kernel arguments.");- status = set_kernel_arg(kernel, i, data.inputs[args[i].index]);- break;- case args_t::INPUT_OF_FUSED_PRIMITIVE:- OPENVINO_ASSERT(args[i].index < data.fused_op_inputs.size() && data.fused_op_inputs[args[i].index],- "The allocated fused_op_input memory is necessary to set kernel arguments.");- status = set_kernel_arg(kernel, i, data.fused_op_inputs[args[i].index]);- break;- case args_t::INTERNAL_BUFFER:- OPENVINO_ASSERT(args[i].index < data.intermediates.size() && data.intermediates[args[i].index],- "The allocated intermediate memory is necessary to set kernel arguments.");- status = set_kernel_arg(kernel, i, data.intermediates[args[i].index]);- break;- case args_t::OUTPUT:- OPENVINO_ASSERT(args[i].index < data.outputs.size() && data.outputs[args[i].index],- "The allocated output memory is necessary to set kernel arguments.");- status = set_kernel_arg(kernel, i, data.outputs[args[i].index]);- break;- case args_t::WEIGHTS:- status = set_kernel_arg(kernel, i, data.weights);- break;- case args_t::BIAS:- status = set_kernel_arg(kernel, i, data.bias);- break;- case args_t::WEIGHTS_ZERO_POINTS:- status = set_kernel_arg(kernel, i, data.weights_zero_points);- break;- case args_t::ACTIVATIONS_ZERO_POINTS:- status = set_kernel_arg(kernel, i, data.activations_zero_points);- break;- case args_t::COMPENSATION:- status = set_kernel_arg(kernel, i, data.compensation);- break;- case args_t::SCALE_TABLE:- status = set_kernel_arg(kernel, i, data.scale_table);- break;- case args_t::SLOPE:- status = set_kernel_arg(kernel, i, data.slope);- break;- case args_t::SCALAR:- if (data.scalars && args[i].index < data.scalars->size()) {- const auto& scalar = (*data.scalars)[args[i].index];- switch (scalar.t) {- case scalar_t::UINT8:- status = kernel.setArg(i, scalar.v.u8);- GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set scalar " << i << " (u8): " << static_cast<int>(scalar.v.u8) << "\n";- break;- case scalar_t::UINT16:- status = kernel.setArg(i, scalar.v.u16);- GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set scalar " << i << " (u16): " << scalar.v.u16 << "\n";- break;- case scalar_t::UINT32:- status = kernel.setArg(i, scalar.v.u32);- GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set scalar " << i << " (u32): " << scalar.v.u32 << "\n";- break;- case scalar_t::UINT64:- status = kernel.setArg(i, scalar.v.u64);- GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set scalar " << i << " (u64): " << scalar.v.u64 << "\n";- break;- case scalar_t::INT8:- status = kernel.setArg(i, scalar.v.s8);- GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set scalar " << i << " (s8): " << static_cast<int>(scalar.v.s8) << "\n";- break;- case scalar_t::INT16:- status = kernel.setArg(i, scalar.v.s16);- GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set scalar " << i << " (s16): " << scalar.v.s16 << "\n";- break;- case scalar_t::INT32:- status = kernel.setArg(i, scalar.v.s32);- GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set scalar " << i << " (s32): " << scalar.v.s32 << "\n";- break;- case scalar_t::INT64:- status = kernel.setArg(i, scalar.v.s64);- GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set scalar " << i << " (s64): " << scalar.v.s64 << "\n";- break;- case scalar_t::FLOAT32:- status = kernel.setArg(i, scalar.v.f32);- GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set scalar " << i << " (f32): " << scalar.v.f32 << "\n";- break;- case scalar_t::FLOAT64:- status = kernel.setArg(i, scalar.v.f64);- GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set scalar " << i << " (f64): " << scalar.v.f64 << "\n";- break;- default:- break;- }+ case args_t::INPUT:+ OPENVINO_ASSERT(args[i].index < data.inputs.size() && data.inputs[args[i].index],+ "The allocated input memory is necessary to set kernel arguments.");+ status = set_kernel_arg(kernel, i, data.inputs[args[i].index]);+ break;+ case args_t::INPUT_OF_FUSED_PRIMITIVE:+ OPENVINO_ASSERT(args[i].index < data.fused_op_inputs.size() && data.fused_op_inputs[args[i].index],+ "The allocated fused_op_input memory is necessary to set kernel arguments.");+ status = set_kernel_arg(kernel, i, data.fused_op_inputs[args[i].index]);+ break;+ case args_t::INTERNAL_BUFFER:+ OPENVINO_ASSERT(args[i].index < data.intermediates.size() && data.intermediates[args[i].index],+ "The allocated intermediate memory is necessary to set kernel arguments.");+ status = set_kernel_arg(kernel, i, data.intermediates[args[i].index]);+ break;+ case args_t::OUTPUT:+ OPENVINO_ASSERT(args[i].index < data.outputs.size() && data.outputs[args[i].index],+ "The allocated output memory is necessary to set kernel arguments.");+ status = set_kernel_arg(kernel, i, data.outputs[args[i].index]);+ break;+ case args_t::WEIGHTS:+ status = set_kernel_arg(kernel, i, data.weights);+ break;+ case args_t::BIAS:+ status = set_kernel_arg(kernel, i, data.bias);+ break;+ case args_t::WEIGHTS_ZERO_POINTS:+ status = set_kernel_arg(kernel, i, data.weights_zero_points);+ break;+ case args_t::ACTIVATIONS_ZERO_POINTS:+ status = set_kernel_arg(kernel, i, data.activations_zero_points);+ break;+ case args_t::COMPENSATION:+ status = set_kernel_arg(kernel, i, data.compensation);+ break;+ case args_t::SCALE_TABLE:+ status = set_kernel_arg(kernel, i, data.scale_table);+ break;+ case args_t::SLOPE:+ status = set_kernel_arg(kernel, i, data.slope);+ break;+ case args_t::SCALAR:+ if (data.scalars && args[i].index < data.scalars->size()) {+ const auto& scalar = (*data.scalars)[args[i].index];+ switch (scalar.t) {+ case scalar_t::UINT8:+ status = kernel.setArg(i, scalar.v.u8);+ GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set scalar " << i << " (u8): " << static_cast<int>(scalar.v.u8) << "\n";+ break;+ case scalar_t::UINT16:+ status = kernel.setArg(i, scalar.v.u16);+ GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set scalar " << i << " (u16): " << scalar.v.u16 << "\n";+ break;+ case scalar_t::UINT32:+ status = kernel.setArg(i, scalar.v.u32);+ GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set scalar " << i << " (u32): " << scalar.v.u32 << "\n";+ break;+ case scalar_t::UINT64:+ status = kernel.setArg(i, scalar.v.u64);+ GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set scalar " << i << " (u64): " << scalar.v.u64 << "\n";+ break;+ case scalar_t::INT8:+ status = kernel.setArg(i, scalar.v.s8);+ GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set scalar " << i << " (s8): " << static_cast<int>(scalar.v.s8) << "\n";+ break;+ case scalar_t::INT16:+ status = kernel.setArg(i, scalar.v.s16);+ GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set scalar " << i << " (s16): " << scalar.v.s16 << "\n";+ break;+ case scalar_t::INT32:+ status = kernel.setArg(i, scalar.v.s32);+ GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set scalar " << i << " (s32): " << scalar.v.s32 << "\n";+ break;+ case scalar_t::INT64:+ status = kernel.setArg(i, scalar.v.s64);+ GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set scalar " << i << " (s64): " << scalar.v.s64 << "\n";+ break;+ case scalar_t::FLOAT32:+ status = kernel.setArg(i, scalar.v.f32);+ GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set scalar " << i << " (f32): " << scalar.v.f32 << "\n";+ break;+ case scalar_t::FLOAT64:+ status = kernel.setArg(i, scalar.v.f64);+ GPU_DEBUG_TRACE_DETAIL << "kernel: " << kernel.get() << " set scalar " << i << " (f64): " << scalar.v.f64 << "\n";+ break;+ default:+ break;}- break;- case args_t::CELL:- status = set_kernel_arg(kernel, i, data.cell);- break;- case args_t::SHAPE_INFO:- status = set_kernel_arg(kernel, i, data.shape_info);- break;- case args_t::LOCAL_MEMORY_SIZE:- OPENVINO_ASSERT(args[i].index < data.local_memory_args->size() && data.local_memory_args->at(args[i].index),- "The allocated local memory is necessary to set kernel arguments.");- status = set_kernel_arg(kernel, i, static_cast<uint32_t>(data.local_memory_args->at(args[i].index)));- break;- break;- default:- break;+ }+ break;+ case args_t::CELL:+ status = set_kernel_arg(kernel, i, data.cell);+ break;+ case args_t::SHAPE_INFO:+ status = set_kernel_arg(kernel, i, data.shape_info);+ break;+ case args_t::LOCAL_MEMORY_SIZE:+ OPENVINO_ASSERT(args[i].index < data.local_memory_args->size() && data.local_memory_args->at(args[i].index),+ "The allocated local memory is necessary to set kernel arguments.");+ status = set_kernel_arg(kernel, i, static_cast<uint32_t>(data.local_memory_args->at(args[i].index)));+ break;+ break;+ default:+ break;}if (status != CL_SUCCESS) {- throw std::runtime_error("Error set arg " + std::to_string(i)- + ", kernel: " + kernel.getInfo<CL_KERNEL_FUNCTION_NAME>()- + ", error code: " + std::to_string(status) + "\n");+ throw std::runtime_error("Error set arg " + std::to_string(i) + ", kernel: " + kernel.getInfo<CL_KERNEL_FUNCTION_NAME>() ++ ", error code: " + std::to_string(status) + "\n");}}}@@ -212,9 +211,9 @@ std::shared_ptr<device_clock_sync> make_device_clock(const ocl_engine& engine, c} // namespace-ocl_stream::ocl_stream(const ocl_engine &engine, const ExecutionConfig& config)- : stream(config.get_queue_type(), stream::get_expected_sync_method(config))- , _engine(engine) {+ocl_stream::ocl_stream(const ocl_engine& engine, const ExecutionConfig& config)+ : stream(config.get_queue_type(), stream::get_expected_sync_method(config)),+ _engine(engine) {auto context = engine.get_cl_context();auto device = engine.get_cl_device();ocl::command_queues_builder queue_builder;@@ -237,9 +236,9 @@ ocl_stream::ocl_stream(const ocl_engine &engine, const ExecutionConfig& config)_device_clock = make_device_clock(_engine, config);}-ocl_stream::ocl_stream(const ocl_engine &engine, const ExecutionConfig& config, void *handle)- : stream(ocl_stream::detect_queue_type(handle), stream::get_expected_sync_method(config))- , _engine(engine) {+ocl_stream::ocl_stream(const ocl_engine& engine, const ExecutionConfig& config, void* handle)+ : stream(ocl_stream::detect_queue_type(handle), stream::get_expected_sync_method(config)),+ _engine(engine) {auto* casted_handle = static_cast<cl_command_queue>(handle);_command_queue = ocl_queue_type(casted_handle, true);_device_clock = make_device_clock(_engine, config);@@ -250,18 +249,18 @@ dnnl::stream& ocl_stream::get_onednn_stream() {OPENVINO_ASSERT(m_queue_type == QueueTypes::in_order, "[GPU] Can't create onednn stream handle as onednn doesn't support out-of-order queue");OPENVINO_ASSERT(_engine.get_device_info().vendor_id == INTEL_VENDOR_ID, "[GPU] Can't create onednn stream handle as for non-Intel devices");if (!_onednn_stream) {-#ifdef OV_GPU_WITH_ZE_RT+# ifdef OV_GPU_WITH_ZE_RTOPENVINO_THROW("[GPU] Using OCL OneDNN API with Level Zero runtime");-#else+# else_onednn_stream = std::make_shared<dnnl::stream>(dnnl::ocl_interop::make_stream(_engine.get_onednn_engine(), _command_queue.get()));-#endif+# endif}return *_onednn_stream;}#endif-QueueTypes ocl_stream::detect_queue_type(void *queue_handle) {+QueueTypes ocl_stream::detect_queue_type(void* queue_handle) {cl_command_queue queue = static_cast<cl_command_queue>(queue_handle);cl_command_queue_properties properties;auto status = clGetCommandQueueInfo(queue, CL_QUEUE_PROPERTIES, sizeof(cl_command_queue_properties), &properties, nullptr);@@ -283,7 +282,7 @@ void ocl_stream::set_arguments(kernel& kernel, const kernel_arguments_desc& argstry {GPU_DEBUG_TRACE_DETAIL << "Set arguments for primitive: " << args_desc.layerID << " (" << kernel.get_id() << " = " << kern.get() << ")\n";set_arguments_impl(kern, args_desc.arguments, args);- } catch (cl::Error const& err) {+ } catch (const cl::Error& err) {OPENVINO_THROW(OCL_ERR_MSG_FMT(err));}}@@ -291,7 +290,7 @@ void ocl_stream::set_arguments(kernel& kernel, const kernel_arguments_desc& argsevent::ptr ocl_stream::enqueue_kernel(kernel& kernel,const kernel_arguments_desc& args_desc,const kernel_arguments_data& /* args */,- std::vector<event::ptr> const& deps,+ const std::vector<event::ptr>& deps,bool is_output) {auto& ocl_kernel = downcast<ocl::ocl_kernel>(kernel);@@ -313,7 +312,7 @@ event::ptr ocl_stream::enqueue_kernel(kernel& kernel,try {_command_queue.enqueueNDRangeKernel(kern, cl::NullRange, global, local, dep_events_ptr, set_output_event ? &ret_ev : nullptr);- } catch (cl::Error const& err) {+ } catch (const cl::Error& err) {ocl::rethrow(err, _engine.get_device_info());}@@ -323,18 +322,18 @@ event::ptr ocl_stream::enqueue_kernel(kernel& kernel,void ocl_stream::enqueue_barrier() {try {_command_queue.enqueueBarrierWithWaitList(nullptr, nullptr);- } catch (cl::Error const& err) {+ } catch (const cl::Error& err) {OPENVINO_THROW(OCL_ERR_MSG_FMT(err));}}-event::ptr ocl_stream::enqueue_marker(std::vector<event::ptr> const& deps, bool is_output) {+event::ptr ocl_stream::enqueue_marker(const std::vector<event::ptr>& deps, bool is_output) {// Wait for all previously enqueued tasks if deps list is emptyif (deps.empty()) {cl::Event ret_ev;try {_command_queue.enqueueMarkerWithWaitList(nullptr, &ret_ev);- } catch (cl::Error const& err) {+ } catch (const cl::Error& err) {OPENVINO_THROW(OCL_ERR_MSG_FMT(err));}@@ -349,7 +348,7 @@ event::ptr ocl_stream::enqueue_marker(std::vector<event::ptr> const& deps, boolreturn create_user_event(true);}_command_queue.enqueueMarkerWithWaitList(&dep_events, &ret_ev);- } catch (cl::Error const& err) {+ } catch (const cl::Error& err) {OPENVINO_THROW(OCL_ERR_MSG_FMT(err));}@@ -362,9 +361,10 @@ event::ptr ocl_stream::enqueue_marker(std::vector<event::ptr> const& deps, boolreturn std::make_shared<ocl_user_event>(_engine.get_cl_context(), true, _device_clock);}-event::ptr ocl_stream::group_events(std::vector<event::ptr> const& deps) {- if (deps.size() == 1)+event::ptr ocl_stream::group_events(const std::vector<event::ptr>& deps) {+ if (deps.size() == 1) {return deps[0];+ }return std::make_shared<ocl_events>(deps);}@@ -377,21 +377,21 @@ event::ptr ocl_stream::create_base_event() {return std::make_shared<ocl_event>(ret_ev, ++_queue_counter);}-std::unique_ptr<surfaces_lock> ocl_stream::create_surfaces_lock(const std::vector<memory::ptr> &mem) const {+std::unique_ptr<surfaces_lock> ocl_stream::create_surfaces_lock(const std::vector<memory::ptr>& mem) const {return std::unique_ptr<ocl::ocl_surfaces_lock>(new ocl::ocl_surfaces_lock(mem, *this));}void ocl_stream::flush() const {try {get_cl_queue().flush();- } catch (cl::Error const& err) {+ } catch (const cl::Error& err) {OPENVINO_THROW(OCL_ERR_MSG_FMT(err));}}void ocl_stream::finish() const {try {get_cl_queue().finish();- } catch (cl::Error const& err) {+ } catch (const cl::Error& err) {OPENVINO_THROW(OCL_ERR_MSG_FMT(err));}}@@ -402,21 +402,23 @@ void ocl_stream::wait() {// Enqueue barrier with empty wait list to wait for all previously enqueued taskstry {_command_queue.enqueueBarrierWithWaitList(nullptr, &ev);- } catch (cl::Error const& err) {+ } catch (const cl::Error& err) {OPENVINO_THROW(OCL_ERR_MSG_FMT(err));}ev.wait();}void ocl_stream::wait_for_events(const std::vector<event::ptr>& events) {- if (events.empty())+ if (events.empty()) {return;+ }bool needs_barrier = false;std::vector<cl_event> clevents;for (const auto& ev : events) {- if (!ev)+ if (!ev) {continue;+ }if (auto* ocl_base_ev = downcast<ocl_base_event>(ev.get())) {if (ocl_base_ev->get().get() != nullptr) {@@ -432,7 +434,7 @@ void ocl_stream::wait_for_events(const std::vector<event::ptr>& events) {try {_command_queue.enqueueBarrierWithWaitList(nullptr, &barrier_ev);clevents.push_back(barrier_ev.get());- } catch (cl::Error const& err) {+ } catch (const cl::Error& err) {OPENVINO_THROW(OCL_ERR_MSG_FMT(err));}}@@ -445,7 +447,7 @@ void ocl_stream::wait_for_events(const std::vector<event::ptr>& events) {}}-void ocl_stream::sync_events(std::vector<event::ptr> const& deps, bool is_output) {+void ocl_stream::sync_events(const std::vector<event::ptr>& deps, bool is_output) {bool needs_barrier = false;for (const auto& dep : deps) {auto* ocl_base_ev = downcast<ocl_base_event>(dep.get());@@ -456,11 +458,12 @@ void ocl_stream::sync_events(std::vector<event::ptr> const& deps, bool is_outputif (needs_barrier) {try {- if (is_output)+ if (is_output) {_command_queue.enqueueBarrierWithWaitList(nullptr, &_last_barrier_ev);- else+ } else {_command_queue.enqueueBarrierWithWaitList(nullptr, nullptr);- } catch (cl::Error const& err) {+ }+ } catch (const cl::Error& err) {OPENVINO_THROW(OCL_ERR_MSG_FMT(err));}diff --git a/src/plugins/intel_gpu/src/runtime/shape_predictor.cpp b/src/plugins/intel_gpu/src/runtime/shape_predictor.cppindex f55868b7340..b0d93da3751 100644--- a/src/plugins/intel_gpu/src/runtime/shape_predictor.cpp+++ b/src/plugins/intel_gpu/src/runtime/shape_predictor.cpp@@ -3,6 +3,7 @@//#include "intel_gpu/runtime/shape_predictor.hpp"+#include "intel_gpu/runtime/engine.hpp"namespace cldnn {@@ -21,8 +22,9 @@ static ov::Shape operator+(const ov::Shape& s1, const ov::Shape& s2) {OPENVINO_ASSERT(s1.size() == s2.size(), "[GPU] Rank mismatch: ", s1, " and ", s2);std::vector<size_t> result;- for (size_t i = 0; i < s1.size(); i++)+ for (size_t i = 0; i < s1.size(); i++) {result.push_back(s1[i] + s2[i]);+ }return result;}@@ -32,8 +34,9 @@ static ov::Shape operator-(const ov::Shape& s1, const ov::Shape& s2) {std::vector<size_t> result;for (size_t i = 0; i < s1.size(); i++) {- if (s1[i] < s2[i])+ if (s1[i] < s2[i]) {return std::vector<size_t>();+ }result.push_back(s1[i] - s2[i]);}@@ -43,8 +46,9 @@ static ov::Shape operator-(const ov::Shape& s1, const ov::Shape& s2) {void ShapePredictor::add_shape(const std::string& id, const ov::Shape& shape) {auto& shapes = _shapes_info[id];- if (shapes.size() >= _max_deque_size)+ if (shapes.size() >= _max_deque_size) {shapes.pop_front();+ }shapes.push_back(shape);}@@ -53,8 +57,9 @@ bool ShapePredictor::can_preallocate(size_t desired_buffer_size) {const auto memory_threshold = 0.90f;auto device_mem_usage = _engine->get_used_device_memory(cldnn::allocation_type::usm_device);- if (desired_buffer_size > _engine->get_device_info().max_alloc_mem_size)+ if (desired_buffer_size > _engine->get_device_info().max_alloc_mem_size) {return false;+ }return device_mem_usage + desired_buffer_size < _engine->get_device_info().max_global_mem_size * memory_threshold;}@@ -65,9 +70,8 @@ std::pair<bool, ov::Shape> ShapePredictor::predict_preallocation_shape(const stdconst size_t out_idx,int32_t custom_next_iters_prealloc_count,int32_t custom_prealloc_dim) {- size_t next_iters_prealloc_count = custom_next_iters_prealloc_count > 0- ? static_cast<size_t>(custom_next_iters_prealloc_count)- : _settings.next_iters_preallocation_count;+ size_t next_iters_prealloc_count =+ custom_next_iters_prealloc_count > 0 ? static_cast<size_t>(custom_next_iters_prealloc_count) : _settings.next_iters_preallocation_count;const auto& current_shape = layout.get_shape();auto dt_bitwidth = ov::element::Type(layout.data_type).bitwidth();@@ -80,8 +84,9 @@ std::pair<bool, ov::Shape> ShapePredictor::predict_preallocation_shape(const std// Save shape information and exit without pre-allocation suggestion if current// buffer can be reused- if (can_reuse_buffer)+ if (can_reuse_buffer) {return {false, {}};+ }// Avoid preallocation if spatial paddedif (static_cast<bool>(layout.data_padding) && !layout.data_padding.is_dynamic()) {@@ -116,8 +121,9 @@ std::pair<bool, ov::Shape> ShapePredictor::predict_preallocation_shape(const stdfor (size_t i = 0; i < min_shapes_num - 1; ++i) {auto result = shapes[shapes_num - i - 1] - shapes[shapes_num - i - 2];- if (result.empty())+ if (result.empty()) {break;+ }diffs.push_back(result);}bool can_use_iterations_preallocation = diffs.size() == min_shapes_num - 1;@@ -128,8 +134,9 @@ std::pair<bool, ov::Shape> ShapePredictor::predict_preallocation_shape(const std}}- if (can_use_iterations_preallocation)+ if (can_use_iterations_preallocation) {can_use_iterations_preallocation = !all_zeroes(diffs[0]);+ }// Allow iterations preallocation only for per-dimension diff less than// '_max_per_dim_diff' and iteration size less than `_max_per_iter_size`@@ -143,11 +150,13 @@ std::pair<bool, ov::Shape> ShapePredictor::predict_preallocation_shape(const std}ov::Shape single_iter_shape;- for (size_t i = 0; i < current_shape.size(); ++i)+ for (size_t i = 0; i < current_shape.size(); ++i) {single_iter_shape.push_back(diffs[0][i] == 0 ? current_shape[i] : 1);+ }- if (ceil_div(ov::shape_size(single_iter_shape) * dt_bitwidth, 8) > _settings.max_per_iter_size)+ if (ceil_div(ov::shape_size(single_iter_shape) * dt_bitwidth, 8) > _settings.max_per_iter_size) {can_use_iterations_preallocation = false;+ }}if (can_use_iterations_preallocation) {@@ -158,8 +167,9 @@ std::pair<bool, ov::Shape> ShapePredictor::predict_preallocation_shape(const stdreturn {true, new_shape};}if (_settings.buffers_preallocation_ratio > 1.0f) {- if (format::is_blocked(layout.format))+ if (format::is_blocked(layout.format)) {return {false, {}};+ }// Apply percentage buffer preallocationauto current_shape_size = ov::shape_size(current_shape);ov::Shape new_shape_size(current_shape.size(), 1);diff --git a/src/plugins/intel_gpu/src/runtime/stream.cpp b/src/plugins/intel_gpu/src/runtime/stream.cppindex e81a0f8d623..678b1a1506f 100644--- a/src/plugins/intel_gpu/src/runtime/stream.cpp+++ b/src/plugins/intel_gpu/src/runtime/stream.cpp@@ -16,11 +16,13 @@ SyncMethods stream::get_expected_sync_method(const ExecutionConfig& config) {}event::ptr stream::aggregate_events(const std::vector<event::ptr>& events, bool group, bool is_output) {- if (events.size() == 1 && !is_output)+ if (events.size() == 1 && !is_output) {return events[0];+ }- if (group && !is_output)+ if (group && !is_output) {return group_events(events);+ }return events.empty() ? (is_output ? create_user_event(true) : nullptr) : enqueue_marker(events, is_output);}