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
[Snippets][CPU] Enable clang-tidy (#31063)
Arseniy Obolenskiy05aba449656e
diff --git a/src/common/snippets/.clang-tidy b/src/common/snippets/.clang-tidynew file mode 100644index 00000000000..9b2226454cb--- /dev/null+++ b/src/common/snippets/.clang-tidy@@ -0,0 +1,163 @@+---++### NOTE:+# The 'Checks: >' is a multiline string here. Comment must not be moved into the string.+#+### Checks that are turned off for a reason:+#+# -cppcoreguidelines-avoid-c-arrays. There are a lot of code which uses C-style arrays+# -cppcoreguidelines-avoid-do-while. Just stylistic preference+# -cppcoreguidelines-explicit-virtual-functions. Forbids 'override final' usage+# -cppcoreguidelines-macro-usage. There are macros defined by OV that are matching this check+# -cppcoreguidelines-misleading-capture-default-by-value. Commonly used in the transformations code+# -cppcoreguidelines-non-private-member-variables-in-classes. There are a lot of code which uses protected members directly+# -cppcoreguidelines-owning-memory. There is a code which uses raw pointers+# -cppcoreguidelines-pro-bounds-array-to-pointer-decay. There are a lot of code which uses array to pointer conversion+# -cppcoreguidelines-pro-bounds-constant-array-index. Size is deduced incorrectly from the array type+# -cppcoreguidelines-pro-bounds-pointer-arithmetic+# -cppcoreguidelines-pro-type-const-cast. There is some code which uses const_cast and cannot get rid of that+# -cppcoreguidelines-pro-type-reinterpret-cast. There are a lot of code which uses reinterpret_cast+# -cppcoreguidelines-pro-type-static-cast-downcast. Performance impact+# -cppcoreguidelines-pro-type-union-access. There are a lot of code which uses unions+# -cppcoreguidelines-pro-type-vararg. There are a lot of code which uses vararg functions+# -cppcoreguidelines-rvalue-reference-param-not-moved. There are a lot of code which uses rvalue references+# -cppcoreguidelines-special-member-functions. There are a lot of code which does not define all copy/move constructors/assignment operators+# -google-readability-todo. No big reason to enforce+# -modernize-use-trailing-return-type. Just stylistic preference+# -misc-const-correctness. No big reason to enforce+# -misc-no-recursion. No big reason to enforce+# -readability-identifier-length. A lot of code use short names for readability, i.e. 'B' for batch+# -readability-uppercase-literal-suffix.+#+### Checks that are turned off but better be enabled later:+# -bugprone-narrowing-conversions+# -bugprone-easily-swappable-parameters+# -bugprone-exception-escape. There are a lot of legacy code which does not handle exceptions properly and just catches them all. Major refactoring is required to correct this.+# -bugprone-implicit-widening-of-multiplication-result+# -bugprone-incorrect-roundings. There are explicit ways to perform rounding (i.e. std::floor(), std::round(), etc). Requires careful updates case by case+# -bugprone-signed-char-misuse. The source code contains valid logic when pointer to the data is interpreted as int8_t (i.e. weights tensor)+# -cppcoreguidelines-avoid-const-or-ref-data-members+# -cppcoreguidelines-avoid-non-const-global-variables+# -cppcoreguidelines-narrowing-conversions+# -google-default-arguments,+# -google-explicit-constructor,+# -google-readability-casting,+# -modernize-avoid-c-arrays,+# -misc-header-include-cycle,+# -misc-non-private-member-variables-in-classes,+# -misc-use-anonymous-namespace,+# -readability-const-return-type+# -readability-function-cognitive-complexity. Reasonable way to enforce splitting complex code into simple functions+# -readability-isolate-declaration+# -readability-magic-numbers, cppcoreguidelines-avoid-magic-numbers+# -readability-simplify-boolean-expr+# -readability-suspicious-call-argument+# Remove warning disablement after CI pipeline migrates to C++17 from C++20 for:+# -modernize-use-constraints,+# -modernize-use-std-numbers++Checks: >+ -*,+ bugprone-*,+ cppcoreguidelines-*,+ performance-*,+ google-*,+ modernize-*,+ misc-*,+ readability-*,+ -bugprone-easily-swappable-parameters,+ -bugprone-exception-escape,+ -bugprone-implicit-widening-of-multiplication-result,+ -bugprone-incorrect-roundings,+ -bugprone-narrowing-conversions,+ -bugprone-signed-char-misuse,+ -cppcoreguidelines-avoid-c-arrays,+ -cppcoreguidelines-avoid-const-or-ref-data-members,+ -cppcoreguidelines-avoid-do-while,+ -cppcoreguidelines-avoid-magic-numbers,+ -cppcoreguidelines-avoid-non-const-global-variables,+ -cppcoreguidelines-explicit-virtual-functions,+ -cppcoreguidelines-macro-usage,+ -cppcoreguidelines-misleading-capture-default-by-value,+ -cppcoreguidelines-narrowing-conversions,+ -cppcoreguidelines-non-private-member-variables-in-classes,+ -cppcoreguidelines-owning-memory,+ -cppcoreguidelines-pro-bounds-array-to-pointer-decay,+ -cppcoreguidelines-pro-bounds-constant-array-index,+ -cppcoreguidelines-pro-bounds-pointer-arithmetic,+ -cppcoreguidelines-pro-type-const-cast,+ -cppcoreguidelines-pro-type-reinterpret-cast,+ -cppcoreguidelines-pro-type-static-cast-downcast,+ -cppcoreguidelines-pro-type-union-access,+ -cppcoreguidelines-pro-type-vararg,+ -cppcoreguidelines-rvalue-reference-param-not-moved,+ -cppcoreguidelines-special-member-functions,+ -google-build-using-namespace,+ -google-explicit-constructor,+ -google-readability-casting,+ -google-readability-todo,+ -modernize-avoid-c-arrays,+ -modernize-use-constraints,+ -modernize-use-std-numbers,+ -modernize-use-trailing-return-type,+ -misc-header-include-cycle,+ -misc-const-correctness,+ -misc-no-recursion,+ -misc-non-private-member-variables-in-classes,+ -misc-use-anonymous-namespace,+ -readability-const-return-type,+ -readability-function-cognitive-complexity,+ -readability-identifier-length,+ -readability-isolate-declaration,+ -readability-magic-numbers,+ -readability-simplify-boolean-expr,+ -readability-suspicious-call-argument,+ -readability-uppercase-literal-suffix,+# Treat warnings as errors+WarningsAsErrors: '*'+# Use clang-format for applied fixes+FormatStyle: file+HeaderFilterRegex: 'src/common/snippets/.*\.h(pp)?$'+CheckOptions:+ - key: cppcoreguidelines-avoid-do-while.IgnoreMacros+ value: true+ # use = instead of {} for initialization+ - key: cppcoreguidelines-pro-type-member-init.UseAssignment+ value: true+ - key: modernize-use-default-member-init.UseAssignment+ value: true+ # matches with corresponding cpplink check+ - key: google-readability-namespace-comments.ShortNamespaceLines+ value: "10"+ # matches with corresponding cpplink check+ - key: google-readability-namespace-comments.SpacesBeforeComments+ value: "2"+ - key: modernize-loop-convert.MinConfidence+ value: reasonable+ - key: modernize-pass-by-value.IncludeStyle+ value: google+ - key: modernize-use-auto.MinTypeNameLength+ value: "3"+ - key: modernize-use-override.AllowOverrideAndFinal+ value: true+ - key: readability-implicit-bool-conversion.AllowIntegerConditions+ value: true+ - key: readability-implicit-bool-conversion.AllowPointerConditions+ value: true+ # Unifies the usage of the statements+ - key: readability-braces-around-statements.ShortStatementLines+ value: "1"+ # itt and conditional compilation are implemented via tricky macro combinations+ - key: misc-include-cleaner.IgnoreHeaders+ # TODO: remove snippets/*.hpp from the list+ value: >+ .*/itt.hpp;+ snippets/runtime_configurator.hpp;+ snippets/lowered/loop_manager.hpp;+# Reasonable way to enforce splitting complex code into simple functions+ - key: readability-function-size.StatementThreshold+ value: "800"+ - key: performance-unnecessary-value-param.AllowedTypes+ value: >+ ov::snippets::lowered::LinearIR::constExprReverseIt+---diff --git a/src/common/snippets/CMakeLists.txt b/src/common/snippets/CMakeLists.txtindex 240687b00a6..6d940e78cf3 100644--- a/src/common/snippets/CMakeLists.txt+++ b/src/common/snippets/CMakeLists.txt@@ -22,6 +22,15 @@ add_library(${TARGET_NAME} STATICadd_library(openvino::snippets ALIAS ${TARGET_NAME})set_target_properties(${TARGET_NAME} PROPERTIES EXPORT_NAME snippets)+if (ENABLE_CLANG_TIDY)+ set(clang_tidy_options "--extra-arg=-Wno-unused-command-line-argument")+ if(ENABLE_CLANG_TIDY_FIX)+ list(APPEND clang_tidy_options "--fix-errors")+ endif()+ set_target_properties(${TARGET_NAME} PROPERTIES+ CXX_CLANG_TIDY "${CLANG_TIDY};${clang_tidy_options}")+endif()+ov_build_target_faster(${TARGET_NAME}UNITYdiff --git a/src/common/snippets/include/snippets/emitter.hpp b/src/common/snippets/include/snippets/emitter.hppindex b329e2d6818..6cef3584601 100644--- a/src/common/snippets/include/snippets/emitter.hpp+++ b/src/common/snippets/include/snippets/emitter.hpp@@ -4,19 +4,20 @@#pragma once+#include <cstddef>#include <cstdint>+#include <limits>+#include <ostream>+#include <utility>#include <vector>-#include "openvino/core/node.hpp"--namespace ov {-namespace snippets {+namespace ov::snippets {/*** @interface RegType* @brief Register type of input and output operations*/-enum class RegType {+enum class RegType : uint8_t {gpr,vec,mask,@@ -35,10 +36,10 @@ struct Reg {Reg() = default;Reg(RegType type_, size_t idx_) : type(type_), idx(idx_) {}- bool is_address() const {+ [[nodiscard]] bool is_address() const {return type == RegType::address;}- bool is_defined() const {+ [[nodiscard]] bool is_defined() const {return is_address() || (type != RegType::undefined && idx != UNDEFINED_IDX);}RegType type = RegType::undefined;@@ -62,7 +63,7 @@ public:/*** @brief Default constructor*/- Emitter() {}+ Emitter() = default;/*** @brief called by generator to generate code to produce target code for a specific operation@@ -105,5 +106,4 @@ private:const std::vector<size_t>& gpr) const = 0;};-} // namespace snippets-} // namespace ov+} // namespace ov::snippetsdiff --git a/src/common/snippets/include/snippets/generator.hpp b/src/common/snippets/include/snippets/generator.hppindex 86827dfd5b7..c866f8f7c27 100644--- a/src/common/snippets/include/snippets/generator.hpp+++ b/src/common/snippets/include/snippets/generator.hpp@@ -8,14 +8,17 @@*/#pragma once+#include <memory>+#include <vector>++#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "snippets/emitter.hpp"#include "snippets/kernel_executor_table.hpp"#include "snippets/lowered/linear_ir.hpp"-#include "snippets/shape_types.hpp"-#include "snippets_isa.hpp"#include "target_machine.hpp"-namespace ov {-namespace snippets {+namespace ov::snippets {class Generator;/**@@ -29,7 +32,7 @@ class LoweringResult {// Some emitters rely on other precompiled kernels.// We need to keep the pointers to such emitters alive, so the kernels or nodes would still be accessible at// runtime.- std::vector<std::shared_ptr<Emitter>> m_saved_emitters{};+ std::vector<std::shared_ptr<Emitter>> m_saved_emitters;public:CompiledSnippetPtr compiled_snippet = nullptr;@@ -108,12 +111,11 @@ protected:* @brief returns true if an emitter can use precompiled kernel.* @return bool*/- virtual bool uses_precompiled_kernel(const std::shared_ptr<Emitter>& emitter) const {+ virtual bool uses_precompiled_kernel([[maybe_unused]] const std::shared_ptr<Emitter>& emitter) const {return false;}std::shared_ptr<TargetMachine> target;};-} // namespace snippets-} // namespace ov+} // namespace ov::snippetsdiff --git a/src/common/snippets/include/snippets/itt.hpp b/src/common/snippets/include/snippets/itt.hppindex 12b2aaea507..e542f112bdd 100644--- a/src/common/snippets/include/snippets/itt.hpp+++ b/src/common/snippets/include/snippets/itt.hpp@@ -11,15 +11,9 @@#include <openvino/cc/pass/itt.hpp>-namespace ov {-namespace pass {-namespace itt {-namespace domains {+namespace ov::pass::itt::domains {OV_ITT_DOMAIN(SnippetsTransform);-} // namespace domains-} // namespace itt-} // namespace pass-} // namespace ov+} // namespace ov::pass::itt::domainsOV_CC_DOMAINS(internal_op);diff --git a/src/common/snippets/include/snippets/kernel_executor_table.hpp b/src/common/snippets/include/snippets/kernel_executor_table.hppindex ff7825c249f..7a0d2f5e76a 100644--- a/src/common/snippets/include/snippets/kernel_executor_table.hpp+++ b/src/common/snippets/include/snippets/kernel_executor_table.hpp@@ -4,15 +4,27 @@#pragma once+#include <cassert>+#include <cstddef>+#include <cstdlib>+#include <functional>+#include <memory>+#include <string>+#include <type_traits>#include <typeinfo>+#include <unordered_map>+#include <utility>+#include <vector>+#include "openvino/core/except.hpp"#include "openvino/util/pp.hpp"+#include "snippets/lowered/expression.hpp"#include "snippets/lowered/linear_ir.hpp"#if defined(SNIPPETS_DEBUG_CAPS) && !defined(_WIN32)# include <cxxabi.h>#endif-namespace ov {-namespace snippets {++namespace ov::snippets {/*** @brief Base class for all kernel executors. This class should not be instantiated directly.@@ -27,18 +39,18 @@ public:* Configs for static kernels should be completed on code emission stage,* while dynamic kernels will be completed only in runtime, when all the shapes are known.*/- virtual bool is_completed() const = 0;+ [[nodiscard]] virtual bool is_completed() const = 0;/*** Return deep copy of the config */- virtual std::unique_ptr<GenericConfig> get_clone_ptr() const = 0;+ [[nodiscard]] virtual std::unique_ptr<GenericConfig> get_clone_ptr() const = 0;/*** Compute hash for fast comparison operations or caching support */- virtual size_t hash() const = 0;+ [[nodiscard]] virtual size_t hash() const = 0;virtual ~GenericConfig() = default;/** serialize config for debug purposes */#ifdef SNIPPETS_DEBUG_CAPS- virtual std::string to_string() const = 0;+ [[nodiscard]] virtual std::string to_string() const = 0;#endif};/**@@ -54,24 +66,22 @@ public:*/virtual void update_by_config(const GenericConfig& new_config) = 0;- virtual const GenericConfig& get_config() const = 0;+ [[nodiscard]] virtual const GenericConfig& get_config() const = 0;/** serialize for debug purposes */#ifdef SNIPPETS_DEBUG_CAPS- virtual std::string to_string() const = 0;+ [[nodiscard]] virtual std::string to_string() const = 0;#endifvirtual ~KernelExecutorBase() = default;private:KernelExecutorBase() = default;- template <typename Conf,- typename KernelType,- typename std::enable_if<std::is_base_of<GenericConfig, Conf>::value, bool>::type>+ template <typename Conf, typename KernelType, std::enable_if_t<std::is_base_of_v<GenericConfig, Conf>, bool>>friend class KernelExecutor;};template <typename Conf,typename KernelType,- typename std::enable_if<std::is_base_of<KernelExecutorBase::GenericConfig, Conf>::value, bool>::type = true>+ std::enable_if_t<std::is_base_of_v<KernelExecutorBase::GenericConfig, Conf>, bool> = true>class KernelExecutor : public KernelExecutorBase {public:explicit KernelExecutor(Conf c) : KernelExecutorBase(), m_config{std::move(c)} {}@@ -85,25 +95,26 @@ public:OPENVINO_ASSERT(m_kernel, "Failed to compile kernel executor");}void update_by_config(const GenericConfig& new_config) override final { // NOLINT- if (m_config.hash() == new_config.hash())+ if (m_config.hash() == new_config.hash()) {return;+ }const auto& new_ptr = dynamic_cast<const Conf*>(&new_config);OPENVINO_ASSERT(new_config.is_completed() && new_ptr, "Failed to update kernel config in get_config");m_config = *new_ptr;update_kernel(m_config, m_kernel);OPENVINO_ASSERT(m_kernel, "Failed to compile kernel executor");}- const GenericConfig& get_config() const override {+ [[nodiscard]] const GenericConfig& get_config() const override {return m_config;}std::shared_ptr<const KernelType> get_kernel() const {return m_kernel;}#ifdef SNIPPETS_DEBUG_CAPS- std::string to_string() const override {+ [[nodiscard]] std::string to_string() const override {std::string type_name = typeid(KernelType).name();# ifndef _WIN32- int status;+ int status = 0;std::unique_ptr<char, void (*)(void*)> demangled_name(abi::__cxa_demangle(type_name.c_str(), nullptr, nullptr, &status),std::free);@@ -132,9 +143,7 @@ private:class KernelExecutorTable {public:/*** Register KernelExecutor in the KernelExecutorTable so it can be later updated in runtime. */- template <typename T,- class... C,- typename std::enable_if<std::is_base_of<KernelExecutorBase, T>::value, bool>::type = true>+ template <typename T, class... C, std::enable_if_t<std::is_base_of_v<KernelExecutorBase, T>, bool> = true>std::shared_ptr<T> register_kernel(const lowered::ExpressionPtr& expr, C... args) {const auto& instance = std::make_shared<T>(args...);OPENVINO_ASSERT(m_table.insert({expr->get_exec_num(), instance}).second,@@ -172,9 +181,9 @@ public:virtual ~KernelExecutorTable() = default;protected:- std::unordered_map<double, std::shared_ptr<KernelExecutorBase>> m_table{};+ std::unordered_map<double, std::shared_ptr<KernelExecutorBase>> m_table;- typedef std::vector<std::pair<double, std::shared_ptr<const KernelExecutorBase::GenericConfig>>> ExecTableState;+ using ExecTableState = std::vector<std::pair<double, std::shared_ptr<const KernelExecutorBase::GenericConfig>>>;/*** Restore the table state previously obtained by get_state() */void reset_state(const ExecTableState& state);@@ -186,5 +195,4 @@ protected:using KernelExecutorTablePtr = std::shared_ptr<KernelExecutorTable>;-} // namespace snippets-} // namespace ov+} // namespace ov::snippetsdiff --git a/src/common/snippets/include/snippets/lowered/expression.hpp b/src/common/snippets/include/snippets/lowered/expression.hppindex 1090aa2f7a7..9e6bb443342 100644--- a/src/common/snippets/include/snippets/lowered/expression.hpp+++ b/src/common/snippets/include/snippets/lowered/expression.hpp@@ -4,17 +4,23 @@#pragma once+#include <cstddef>+#include <memory>#include <openvino/core/node.hpp>-#include <openvino/opsets/opset1.hpp>+#include <set>+#include <unordered_map>+#include <utility>+#include <vector>+#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/type.hpp"#include "snippets/emitter.hpp"#include "snippets/lowered/expression_port.hpp"#include "snippets/lowered/port_connector.hpp"+#include "snippets/lowered/port_descriptor.hpp"#include "snippets/shape_inference/shape_inference.hpp"-namespace ov {-namespace snippets {-namespace lowered {+namespace ov::snippets::lowered {class ExpressionFactory;class LinearIR;@@ -138,13 +144,13 @@ protected:std::shared_ptr<Node> m_source_node{nullptr};std::shared_ptr<Emitter> m_emitter{nullptr};- std::vector<PortConnectorPtr> m_input_port_connectors{};- std::vector<PortConnectorPtr> m_output_port_connectors{};- std::vector<PortDescriptorPtr> m_input_port_descriptors{};- std::vector<PortDescriptorPtr> m_output_port_descriptors{};+ std::vector<PortConnectorPtr> m_input_port_connectors;+ std::vector<PortConnectorPtr> m_output_port_connectors;+ std::vector<PortDescriptorPtr> m_input_port_descriptors;+ std::vector<PortDescriptorPtr> m_output_port_descriptors;// The order Loops identifies: Outer ---> Inner// Note: The loops with the same dimension index (splitted dimension) should be successively nested- std::vector<size_t> m_loop_ids{};+ std::vector<size_t> m_loop_ids;std::shared_ptr<IShapeInferSnippets> m_shapeInference{nullptr};const bool m_need_shape_infer = true;@@ -154,9 +160,7 @@ protected:// 2. This number can be changed and updated during whole pipeline, so its absolute values are meaningless.// 3. This number can be negative, positive and zero.double m_exec_num = 0;- std::set<Reg> m_live_regs{};+ std::set<Reg> m_live_regs;};-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/include/snippets/lowered/expression_factory.hpp b/src/common/snippets/include/snippets/lowered/expression_factory.hppindex becb2d44e52..96eeb601943 100644--- a/src/common/snippets/include/snippets/lowered/expression_factory.hpp+++ b/src/common/snippets/include/snippets/lowered/expression_factory.hpp@@ -4,16 +4,22 @@#pragma once+#include <memory>+#include <type_traits>+#include <utility>+#include <vector>+#include "expression.hpp"-#include "expressions/buffer_expression.hpp"-#include "snippets/op/buffer.hpp"+#include "openvino/core/node.hpp"+#include "openvino/op/parameter.hpp"+#include "openvino/op/result.hpp"+#include "snippets/lowered/port_connector.hpp"#include "snippets/op/loop.hpp"#include "snippets/op/perf_count.hpp"#include "snippets/op/reg_spill.hpp"+#include "snippets/shape_inference/shape_inference.hpp"-namespace ov {-namespace snippets {-namespace lowered {+namespace ov::snippets::lowered {class ExpressionFactory {public:@@ -22,7 +28,7 @@ public:template <typename T = Expression,typename... Args,- typename std::enable_if<std::is_base_of<Expression, T>::value, bool>::type = true>+ std::enable_if_t<std::is_base_of_v<Expression, T>, bool> = true>std::shared_ptr<T> build(const std::shared_ptr<Node>& n,const std::vector<PortConnectorPtr>& inputs,Args... args) {@@ -65,7 +71,7 @@ private:template <typename T = Expression,typename... Args,- typename std::enable_if<std::is_base_of<Expression, T>::value, bool>::type = true>+ std::enable_if_t<std::is_base_of_v<Expression, T>, bool> = true>static std::shared_ptr<T> create(const std::shared_ptr<ov::Node>& n,const std::vector<PortConnectorPtr>& inputs,const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory,@@ -76,8 +82,9 @@ private:expr->validate();// todo: here we blindly synchronize input shapes from parent and child. Remove this when shapes will be stored// in port connector itself- if (shape_infer_factory)+ if (shape_infer_factory) {expr->updateShapes();+ }return expr;}@@ -94,6 +101,4 @@ template <>std::shared_ptr<Expression> ExpressionFactory::build(const std::shared_ptr<Node>& n,const std::vector<PortConnectorPtr>& inputs);-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/include/snippets/lowered/expression_port.hpp b/src/common/snippets/include/snippets/lowered/expression_port.hppindex 0df110de1a6..82366a60983 100644--- a/src/common/snippets/include/snippets/lowered/expression_port.hpp+++ b/src/common/snippets/include/snippets/lowered/expression_port.hpp@@ -4,20 +4,20 @@#pragma once+#include <cstddef>+#include <cstdint>#include <memory>-#include <vector>+#include <set>#include "port_descriptor.hpp"-namespace ov {-namespace snippets {-namespace lowered {+namespace ov::snippets::lowered {class PortConnector;class Expression;class ExpressionPort {public:- enum Type { Input, Output };+ enum Type : uint8_t { Input, Output };ExpressionPort() = default;explicit ExpressionPort(const std::shared_ptr<Expression>& expr, Type type, size_t port);@@ -25,22 +25,23 @@ public:* @interface clone_with_new_expr* @brief Creates similar Expression port, but for new expression*/- std::shared_ptr<ExpressionPort> clone_with_new_expr(const std::shared_ptr<Expression>& new_expr) const;+ [[nodiscard]] std::shared_ptr<ExpressionPort> clone_with_new_expr(+ const std::shared_ptr<Expression>& new_expr) const;- std::shared_ptr<Expression> get_expr() const;- Type get_type() const {+ [[nodiscard]] std::shared_ptr<Expression> get_expr() const;+ [[nodiscard]] Type get_type() const {return m_type;}- size_t get_index() const {+ [[nodiscard]] size_t get_index() const {return m_port_index;}- const PortDescriptorPtr& get_descriptor_ptr() const;- const std::shared_ptr<PortConnector>& get_port_connector_ptr() const;+ [[nodiscard]] const PortDescriptorPtr& get_descriptor_ptr() const;+ [[nodiscard]] const std::shared_ptr<PortConnector>& get_port_connector_ptr() const;// Returns connected ports to the current:// - Input port returns one source (parent) port// - Output port returns all consumer ports (children)- std::set<ExpressionPort> get_connected_ports() const;+ [[nodiscard]] std::set<ExpressionPort> get_connected_ports() const;// Note: It may be called only for input expression ports// since output ports don't support PortConnector changing (this is determined by the creation of the@@ -59,6 +60,4 @@ private:void replace_input_port_connectors(const std::set<ExpressionPort>& consumers, const std::shared_ptr<PortConnector>& to);-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/include/snippets/lowered/expressions/buffer_expression.hpp b/src/common/snippets/include/snippets/lowered/expressions/buffer_expression.hppindex 523f7638fbb..bd4d990351a 100644--- a/src/common/snippets/include/snippets/lowered/expressions/buffer_expression.hpp+++ b/src/common/snippets/include/snippets/lowered/expressions/buffer_expression.hpp@@ -4,12 +4,18 @@#pragma once+#include <cstddef>+#include <memory>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/rtti.hpp"+#include "openvino/core/type/element_type.hpp"#include "snippets/lowered/expression.hpp"+#include "snippets/shape_inference/shape_inference.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {+namespace ov::snippets::lowered {// To avoid cycle-dependancy of includes, we forward-declare LoopManagerclass LoopManager;@@ -83,6 +89,4 @@ protected:};using BufferExpressionPtr = std::shared_ptr<BufferExpression>;-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/include/snippets/lowered/linear_ir.hpp b/src/common/snippets/include/snippets/lowered/linear_ir.hppindex 8e7b394a927..b4425ee97cd 100644--- a/src/common/snippets/include/snippets/lowered/linear_ir.hpp+++ b/src/common/snippets/include/snippets/lowered/linear_ir.hpp@@ -4,20 +4,33 @@#pragma once+#include <cassert>+#include <cstddef>#include <list>-+#include <memory>+#include <set>+#include <type_traits>+#include <unordered_map>+#include <utility>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/model.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_vector.hpp"#include "snippets/lowered/expression.hpp"#include "snippets/lowered/expression_factory.hpp"+#include "snippets/lowered/expression_port.hpp"#include "snippets/lowered/expressions/buffer_expression.hpp"+#include "snippets/lowered/port_connector.hpp"#include "snippets/shape_inference/shape_inference.hpp"+#include "snippets/shape_types.hpp"#include "snippets/target_machine.hpp"#ifdef SNIPPETS_DEBUG_CAPS# include "snippets/utils/debug_caps_config.hpp"#endif-namespace ov {-namespace snippets {-namespace lowered {+namespace ov::snippets::lowered {class Config {public:@@ -207,7 +220,7 @@ public:*/template <typename T>exprIt insert_node(const std::shared_ptr<ov::Node>& new_node,- const std::vector<T>& inputs,+ const std::vector<T>& args,const std::vector<size_t>& loop_ids,bool update_loop_ports,const constExprIt& place,@@ -243,14 +256,13 @@ public:* @param args ov::Node constructor arguments* @return Pair of iterator on the inserted expr and the constructed node.*/- template <typename T,- typename... Args,- typename std::enable_if<std::is_base_of<ov::Node, T>::value, bool>::type = true>+ template <typename T, typename... Args, std::enable_if_t<std::is_base_of_v<ov::Node, T>, bool> = true>std::pair<constExprIt, std::shared_ptr<T>> insert_node(constExprIt pos, Args&&... args) {const auto node = std::make_shared<T>(std::forward<Args>(args)...);const auto expr_it = insert(pos, node);- if (node->is_dynamic())+ if (node->is_dynamic()) {expr_it->get()->updateShapes();+ }return std::make_pair(expr_it, node);}@@ -331,9 +343,7 @@ public:* @param args ov::Node constructor arguments* @return Pair of iterator on the inserted expr and the constructed node.*/- template <typename T,- typename... Args,- typename std::enable_if<std::is_base_of<ov::Node, T>::value, bool>::type = true>+ template <typename T, typename... Args, std::enable_if_t<std::is_base_of_v<ov::Node, T>, bool> = true>std::pair<constExprIt, std::shared_ptr<T>> push_node(Args&&... args) {return insert_node<T>(end(), std::forward<Args>(args)...);}@@ -368,13 +378,13 @@ private:// return execution number for new expression which will be inserted before `insert_pos`double get_inserted_expr_exec_num(constExprIt insertion_pos) const;- container m_expressions{};+ container m_expressions;std::unordered_map<std::shared_ptr<Node>, std::shared_ptr<Expression>> m_node2expression_map;// Note: Parameters and Results are stored in the order of Subgraph inputs/outputs- std::vector<ExpressionPtr> m_parameter_expressions{};- std::vector<ExpressionPtr> m_result_expressions{};+ std::vector<ExpressionPtr> m_parameter_expressions;+ std::vector<ExpressionPtr> m_result_expressions;// Note: BufferExpressions are not stored in the order of execution numbers- std::vector<BufferExpressionPtr> m_buffer_expressions{};+ std::vector<BufferExpressionPtr> m_buffer_expressions;Config m_config{};LoopManagerPtr m_loop_manager;std::shared_ptr<IShapeInferSnippetsFactory> m_shape_infer_factory = nullptr;@@ -395,6 +405,4 @@ iterator LinearIR::find(iterator begin, iterator end, const ExpressionPtr& targereturn found;}-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/include/snippets/lowered/linear_ir_builder.hpp b/src/common/snippets/include/snippets/lowered/linear_ir_builder.hppindex ebe4a9ad9d1..b70a7a250ca 100644--- a/src/common/snippets/include/snippets/lowered/linear_ir_builder.hpp+++ b/src/common/snippets/include/snippets/lowered/linear_ir_builder.hpp@@ -4,11 +4,12 @@#pragma once+#include <memory>++#include "snippets/lowered/expression.hpp"#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {+namespace ov::snippets::lowered {/* The helper class that can make a copy of LinearIR or range of it by specific rules.* The rules are described in config.@@ -23,7 +24,7 @@ public:const bool deep_copy_of_shapes = true;};- LinearIRBuilder(Config config = {}) : m_config(std::move(config)) {}+ LinearIRBuilder(Config config = {}) : m_config(config) {}/*** @brief Make a full copy of LinearIR by rules described in `m_config`@@ -31,17 +32,16 @@ public:* @param expression_map expression map* @return clone of `linear_ir`*/- inline std::shared_ptr<LinearIR> clone(const std::shared_ptr<LinearIR>& linear_ir,- ExpressionMap& expression_map) const {+ std::shared_ptr<LinearIR> clone(const std::shared_ptr<LinearIR>& linear_ir, ExpressionMap& expression_map) const {auto result = std::make_shared<LinearIR>();clone(linear_ir.get(), result.get(), expression_map);return result;}- inline std::shared_ptr<LinearIR> clone(const std::shared_ptr<LinearIR>& linear_ir) const {+ [[nodiscard]] std::shared_ptr<LinearIR> clone(const std::shared_ptr<LinearIR>& linear_ir) const {ExpressionMap expression_map;return clone(linear_ir, expression_map);}- inline LinearIR clone(const LinearIR& linear_ir) const {+ [[nodiscard]] LinearIR clone(const LinearIR& linear_ir) const {LinearIR result;ExpressionMap expression_map;clone(&linear_ir, &result, expression_map);@@ -60,9 +60,7 @@ public:private:void clone(const LinearIR* src, LinearIR* dst, ExpressionMap& expression_map) const;- Config m_config = {};+ Config m_config;};-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/include/snippets/lowered/loop_info.hpp b/src/common/snippets/include/snippets/lowered/loop_info.hppindex 44d2ce6c472..dfb6f0674be 100644--- a/src/common/snippets/include/snippets/lowered/loop_info.hpp+++ b/src/common/snippets/include/snippets/lowered/loop_info.hpp@@ -4,12 +4,27 @@#pragma once+#include <algorithm>+#include <cstddef>+#include <cstdint>+#include <functional>+#include <memory>+#include <unordered_map>+#include <unordered_set>+#include <utility>+#include <vector>++#include "openvino/core/rtti.hpp"+#include "openvino/core/type.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/expression_port.hpp"#include "snippets/lowered/loop_port.hpp"+#include "snippets/lowered/pass/pass.hpp"#include "snippets/lowered/specific_loop_iter_handlers.hpp"+#include "snippets/lowered/specific_loop_iter_types.hpp"+#include "snippets/shape_inference/shape_inference.hpp"-namespace ov {-namespace snippets {-namespace lowered {+namespace ov::snippets::lowered {class LoopInfo;using LoopInfoMap = std::unordered_map<const LoopInfo*, std::shared_ptr<LoopInfo>>;@@ -135,7 +150,7 @@ public:* @brief Iterates through all loop ports and call `caller` for each of them* @param caller - function that called for each loop port*/- inline void iterate_through_ports(const std::function<void(const LoopPort&)>& caller) const {+ void iterate_through_ports(const std::function<void(const LoopPort&)>& caller) const {std::for_each(m_input_ports.cbegin(), m_input_ports.cend(), caller);std::for_each(m_output_ports.cbegin(), m_output_ports.cend(), caller);}@@ -194,8 +209,8 @@ protected:// - The position before first input expr is Loop Begin position// - The position after last output expr is Loop End position// Note: Scalars aren't input expressions but can be before first input expr in Linear IR- std::vector<LoopPort> m_input_ports = {};- std::vector<LoopPort> m_output_ports = {};+ std::vector<LoopPort> m_input_ports;+ std::vector<LoopPort> m_output_ports;};/**@@ -219,8 +234,8 @@ public:int64_t finalization_offset = 0;int64_t data_size = 0;- bool is_dynamic() const;- bool is_static() const;+ [[nodiscard]] bool is_dynamic() const;+ [[nodiscard]] bool is_static() const;friend bool operator==(const LoopPortDesc& lhs, const LoopPortDesc& rhs);friend bool operator!=(const LoopPortDesc& lhs, const LoopPortDesc& rhs);@@ -230,10 +245,10 @@ public:// instead of the separate vectors with descriptors.struct LoopPortInfo {LoopPortInfo() = default;- LoopPortInfo(LoopPort port_, LoopPortDesc desc_) : port(std::move(port_)), desc(std::move(desc_)) {}+ LoopPortInfo(LoopPort port_, LoopPortDesc desc_) : port(std::move(port_)), desc(desc_) {}- LoopPort port = {};- LoopPortDesc desc = {};+ LoopPort port;+ LoopPortDesc desc;};UnifiedLoopInfo() = default;@@ -243,17 +258,18 @@ public:const std::vector<LoopPort>& exits,const std::vector<LoopPortDesc>& in_descs,const std::vector<LoopPortDesc>& out_descs,- const SpecificIterationHandlers& handlers = SpecificIterationHandlers());+ SpecificIterationHandlers handlers = SpecificIterationHandlers());UnifiedLoopInfo(size_t work_amount,size_t increment,const std::vector<LoopPort>& entries,const std::vector<LoopPort>& exits,- const SpecificIterationHandlers& handlers = SpecificIterationHandlers());+ SpecificIterationHandlers handlers = SpecificIterationHandlers());UnifiedLoopInfo(size_t work_amount,size_t increment,const std::vector<ExpressionPort>& entries,const std::vector<ExpressionPort>& exits,- const SpecificIterationHandlers& handlers = SpecificIterationHandlers());++ SpecificIterationHandlers handlers = SpecificIterationHandlers());/*** @brief Clone LoopInfo with new Expressions@@ -331,7 +347,7 @@ public:*/template <SpecificLoopIterType Type, typename T, class... Args>void register_pass_to_handler(Args&&... args) {- m_handlers.register_pass<Type, T>(args...);+ m_handlers.register_pass<Type, T>(std::forward<Args>(args)...);}/**@@ -358,7 +374,7 @@ public:* @brief Iterates through all LoopPortDesc and call `caller` for each of them* @param caller - function that called for each LoopPortDesc*/- inline void iterate_through_descs(const std::function<void(LoopPortDesc&)>& caller) {+ void iterate_through_descs(const std::function<void(LoopPortDesc&)>& caller) {std::for_each(m_input_port_descs.begin(), m_input_port_descs.end(), caller);std::for_each(m_output_port_descs.begin(), m_output_port_descs.end(), caller);}@@ -366,7 +382,7 @@ public:* @brief Iterates through all loop ports and call `caller` for each of them* @param caller - function that called for each loop port*/- inline void iterate_through_descs(const std::function<void(const LoopPortDesc&)>& caller) const {+ void iterate_through_descs(const std::function<void(const LoopPortDesc&)>& caller) const {std::for_each(m_input_port_descs.cbegin(), m_input_port_descs.cend(), caller);std::for_each(m_output_port_descs.cbegin(), m_output_port_descs.cend(), caller);}@@ -374,21 +390,25 @@ public:* @brief Iterates through all pairs <LoopPort, LoopPortDesc> and call `caller` for each of them* @param caller - function that called for each pair*/- inline void iterate_through_infos(const std::function<void(LoopPort&, LoopPortDesc&)>& caller) {- for (size_t i = 0; i < get_input_count(); ++i)+ void iterate_through_infos(const std::function<void(LoopPort&, LoopPortDesc&)>& caller) {+ for (size_t i = 0; i < get_input_count(); ++i) {caller(m_input_ports[i], m_input_port_descs[i]);- for (size_t i = 0; i < get_output_count(); ++i)+ }+ for (size_t i = 0; i < get_output_count(); ++i) {caller(m_output_ports[i], m_output_port_descs[i]);+ }}/*** @brief Iterates through all pairs <LoopPort, LoopPortDesc> and call `caller` for each of them* @param caller - function that called for each pair*/- inline void iterate_through_infos(const std::function<void(const LoopPort&, const LoopPortDesc&)>& caller) const {- for (size_t i = 0; i < get_input_count(); ++i)+ void iterate_through_infos(const std::function<void(const LoopPort&, const LoopPortDesc&)>& caller) const {+ for (size_t i = 0; i < get_input_count(); ++i) {caller(m_input_ports[i], m_input_port_descs[i]);- for (size_t i = 0; i < get_output_count(); ++i)+ }+ for (size_t i = 0; i < get_output_count(); ++i) {caller(m_output_ports[i], m_output_port_descs[i]);+ }}/**@@ -406,9 +426,9 @@ protected:*/void replace_with_cloned_descs(size_t actual_port_idx, size_t new_count, bool is_input);- SpecificIterationHandlers m_handlers = {};- std::vector<LoopPortDesc> m_input_port_descs = {};- std::vector<LoopPortDesc> m_output_port_descs = {};+ SpecificIterationHandlers m_handlers;+ std::vector<LoopPortDesc> m_input_port_descs;+ std::vector<LoopPortDesc> m_output_port_descs;};using UnifiedLoopInfoPtr = std::shared_ptr<UnifiedLoopInfo>;@@ -597,17 +617,15 @@ public:void sort_ports() override;private:- std::vector<int64_t> m_ptr_increments = {};- std::vector<int64_t> m_finalization_offsets = {};- std::vector<int64_t> m_data_sizes = {};+ std::vector<int64_t> m_ptr_increments;+ std::vector<int64_t> m_finalization_offsets;+ std::vector<int64_t> m_data_sizes;const SpecificLoopIterType m_type = {};- std::shared_ptr<UnifiedLoopInfo> m_unified_loop_info = {};+ std::shared_ptr<UnifiedLoopInfo> m_unified_loop_info;bool m_evaluate_once = false;};using ExpandedLoopInfoPtr = std::shared_ptr<ExpandedLoopInfo>;-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/include/snippets/lowered/loop_manager.hpp b/src/common/snippets/include/snippets/lowered/loop_manager.hppindex 63f23e0373b..8eb1528be2a 100644--- a/src/common/snippets/include/snippets/lowered/loop_manager.hpp+++ b/src/common/snippets/include/snippets/lowered/loop_manager.hpp@@ -3,17 +3,25 @@//#pragma once-#include <openvino/core/node.hpp>-#include <openvino/opsets/opset1.hpp>+#include <algorithm>+#include <cstddef>+#include <cstdint>+#include <map>+#include <memory>+#include <type_traits>+#include <utility>+#include <vector>+#include "openvino/core/except.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/expression_port.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/loop_port.hpp"+#include "snippets/lowered/specific_loop_iter_handlers.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {+namespace ov::snippets::lowered {class LoopManager {public:@@ -24,14 +32,14 @@ public:* @param expr_map map of new and old expressions* @return the copy*/- std::shared_ptr<LoopManager> clone_with_new_expr(const ExpressionMap& expr_map) const;+ [[nodiscard]] std::shared_ptr<LoopManager> clone_with_new_expr(const ExpressionMap& expr_map) const;/*** @brief Get target Loop Info* @param index loop ID* @return the LoopInfo shared ptr*/- template <typename T = LoopInfo, typename std::enable_if<std::is_base_of<LoopInfo, T>::value, bool>::type = true>- std::shared_ptr<T> get_loop_info(size_t index) const {+ template <typename T = LoopInfo, std::enable_if_t<std::is_base_of_v<LoopInfo, T>, bool> = true>+ [[nodiscard]] std::shared_ptr<T> get_loop_info(size_t index) const {const auto it = m_map.find(index);OPENVINO_ASSERT(it != m_map.end(), "LoopInfo hasn't been found!");const auto loop_info = ov::as_type_ptr<T>(it->second);@@ -42,14 +50,14 @@ public:* @brief Get count of loops* @return count of loops in the map*/- size_t get_loop_count() const {+ [[nodiscard]] size_t get_loop_count() const {return m_map.size();}/*** @brief Get loop map [loop_id -> loop info]* @return loop map*/- const std::map<size_t, LoopInfoPtr>& get_map() const;+ [[nodiscard]] const std::map<size_t, LoopInfoPtr>& get_map() const;/*** @brief Get loop IDs of expression that are outer (upper) than `loop_id`* @param expr the target expression@@ -106,9 +114,10 @@ public:const auto normalized_increment =utils::is_dynamic_value(work_amount) || work_amount == 0 ? increment : std::min(increment, work_amount);const auto loop_info = std::make_shared<UnifiedLoopInfo>(work_amount, normalized_increment, entries, exits);- if (set_default_handlers)+ if (set_default_handlers) {loop_info->set_handlers(SpecificIterationHandlers(work_amount, normalized_increment, loop_info->get_dim_idx()));+ }const auto loop_id = this->add_loop_info(loop_info);for (auto expr_it = loop_begin_pos; expr_it != loop_end_pos; ++expr_it) {@@ -163,7 +172,7 @@ public:LinearIR::constExprIt loop_begin_pos,LinearIR::constExprIt loop_end_pos,const LoopInfoPtr& loop_info,- const size_t old_id);+ size_t old_id);/*** @brief Fuse two UnifiedLoopInfos: fuse their informations to the one* @param linear_ir linear IR@@ -198,8 +207,7 @@ public:* @param target_ports vector of the new ports*/template <typename T,- typename = typename std::- enable_if<(std::is_same<T, ExpressionPort>::value || std::is_same<T, LoopPort>::value), bool>::type>+ typename = std::enable_if_t<(std::is_same_v<T, ExpressionPort> || std::is_same_v<T, LoopPort>), bool>>void replace_loop_port(size_t loop_id, const T& actual_port, const std::vector<T>& target_ports) {const auto& loop_info = get_loop_info(loop_id);loop_info->replace_with_new_ports(actual_port, target_ports);@@ -211,8 +219,7 @@ public:* @param target_ports vector of the new ports*/template <typename T,- typename = typename std::- enable_if<(std::is_same<T, ExpressionPort>::value || std::is_same<T, LoopPort>::value), bool>::type>+ typename = std::enable_if_t<(std::is_same_v<T, ExpressionPort> || std::is_same_v<T, LoopPort>), bool>>void replace_loop_ports(const std::vector<size_t>& loop_ids,const T& actual_port,const std::vector<T>& target_ports) {@@ -238,12 +245,12 @@ public:* consumer input ports) with the target expression input ports.* @param expr the target expression*/- void update_loop_ports(const ExpressionPtr& expr);+ void update_loop_ports(const ExpressionPtr& expr) const;/*** @brief Sort all loop ports of loop with ids from `loop_ids` by expression execution number* @param loop_ids IDs of loops*/- void sort_loop_ports(const std::vector<size_t>& loop_ids);+ void sort_loop_ports(const std::vector<size_t>& loop_ids) const;/*** @brief When the previous expression was replaced with new expressions (decomposition), the method updates the* corresponding Loop. If ports of decomposed expression were the Loop ports, these Loop ports may be updated by@@ -274,7 +281,7 @@ public:* @param loop_id target Loop ID* @return the pair of loop_begin_pos and loop_end_pos iterators*/- LoopBounds get_loop_bounds(const LinearIR& linear_ir, size_t loop_id) const;+ [[nodiscard]] LoopBounds get_loop_bounds(const LinearIR& linear_ir, size_t loop_id) const;/*** @brief Find bounds of Loop:* - If the explicit Loop exprs with the target `loop_id` have been inserted,@@ -299,7 +306,7 @@ public:* @param loop_id target Loop ID* @return loop port*/- LoopPort get_loop_port_by_expr_port(const ExpressionPort& expr_port, const size_t loop_id);+ [[nodiscard]] LoopPort get_loop_port_by_expr_port(const ExpressionPort& expr_port, size_t loop_id) const;/*** @brief Reorder ALL Loop IDs in `m_map` using `loop_id_map`@@ -347,7 +354,7 @@ private:// Notes:// - These methods don't update the corresponding LoopInfovoid replace_loop_id(const ExpressionPtr& expr, size_t prev_id, size_t new_id);- void remove_loop_id(const ExpressionPtr& expr, size_t id);+ static void remove_loop_id(const ExpressionPtr& expr, size_t id);// Insert loop ID before (as outer Loop) or after (as inner Loop) target ID in vector of identifiers// Before: | After:// loop_ids: [.., new_id, target_id, ..] | loop_ids: [.., target_id, new_id, ..]@@ -360,11 +367,9 @@ private:size_t target_id = SIZE_MAX);static bool is_loop_id_found(const ExpressionPtr& expr, size_t id);- std::map<size_t, LoopInfoPtr> m_map = {};+ std::map<size_t, LoopInfoPtr> m_map;size_t next_id = 0;};using LoopManagerPtr = std::shared_ptr<LoopManager>;-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/include/snippets/lowered/loop_port.hpp b/src/common/snippets/include/snippets/lowered/loop_port.hppindex 5f6695e0d22..6feb5ac53ef 100644--- a/src/common/snippets/include/snippets/lowered/loop_port.hpp+++ b/src/common/snippets/include/snippets/lowered/loop_port.hpp@@ -4,20 +4,25 @@#pragma once+#include <cstddef>+#include <cstdint>+#include <limits>+#include <memory>+#include <ostream>+#include <type_traits>++#include "openvino/core/except.hpp"#include "snippets/lowered/expression.hpp"#include "snippets/lowered/expression_port.hpp"-#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {+namespace ov::snippets::lowered {/* The class describes port of Loop: expression port that connected to Expressions from other Loops.*/class LoopPort {public:- enum { UNDEFINED_DIM_IDX = std::numeric_limits<size_t>::max() };- enum class Type {+ static constexpr auto UNDEFINED_DIM_IDX = std::numeric_limits<size_t>::max();+ enum class Type : uint8_t {Incremented, // Loop port which data ptr should be incremented after each Loop iterationNotIncremented, // Loop port which data ptr should not be incremented (for example, to avoid double increment)NotProcessed, // LoopPort which doesn't process the dim by `dim_idx` (UNDEFINED_DIM_IDX) and is used only for@@ -26,54 +31,50 @@ public:LoopPort() = default;- template <LoopPort::Type T,- typename std::enable_if<T == Type::Incremented || T == Type::NotIncremented, bool>::type = true>+ template <LoopPort::Type T, std::enable_if_t<T == Type::Incremented || T == Type::NotIncremented, bool> = true>static LoopPort create(const ExpressionPort& port, size_t dim_idx = 0) {- return LoopPort(port, dim_idx, T);+ return {port, dim_idx, T};}- template <LoopPort::Type T, typename std::enable_if<T == Type::NotProcessed, bool>::type = true>+ template <LoopPort::Type T, std::enable_if_t<T == Type::NotProcessed, bool> = true>static LoopPort create(const ExpressionPort& port) {- return LoopPort(port, UNDEFINED_DIM_IDX, Type::NotProcessed);+ return {port, UNDEFINED_DIM_IDX, Type::NotProcessed};}- std::shared_ptr<LoopPort> clone_with_new_expr(const ExpressionPtr& new_expr) const;+ [[nodiscard]] std::shared_ptr<LoopPort> clone_with_new_expr(const ExpressionPtr& new_expr) const;friend bool operator==(const LoopPort& lhs, const LoopPort& rhs);friend bool operator!=(const LoopPort& lhs, const LoopPort& rhs);friend bool operator<(const LoopPort& lhs, const LoopPort& rhs);- const std::shared_ptr<ExpressionPort>& get_expr_port() const {+ [[nodiscard]] const std::shared_ptr<ExpressionPort>& get_expr_port() const {return m_expr_port;}- Type get_type() const {+ [[nodiscard]] Type get_type() const {return m_type;}- size_t get_dim_idx() const;+ [[nodiscard]] size_t get_dim_idx() const;void set_expr_port(std::shared_ptr<ExpressionPort> p);void set_dim_idx(size_t idx);- template <LoopPort::Type T,- typename std::enable_if<T == Type::Incremented || T == Type::NotIncremented, bool>::type = true>+ template <LoopPort::Type T, std::enable_if_t<T == Type::Incremented || T == Type::NotIncremented, bool> = true>void convert_to_type() {OPENVINO_ASSERT(is_processed(), "NotProcessed LoopPort cannot change type!");m_type = T;}- bool is_processed() const;- bool is_incremented() const;+ [[nodiscard]] bool is_processed() const;+ [[nodiscard]] bool is_incremented() const;private:LoopPort(const ExpressionPort& port, size_t dim_idx, Type type);- std::shared_ptr<ExpressionPort> m_expr_port = {};+ std::shared_ptr<ExpressionPort> m_expr_port;size_t m_dim_idx = 0; // The numeration starts from the end (dim_idx = 0 -> is the most inner dimension)Type m_type = Type::Incremented;};std::ostream& operator<<(std::ostream& out, const LoopPort::Type& type);-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/include/snippets/lowered/pass/allocate_buffers.hpp b/src/common/snippets/include/snippets/lowered/pass/allocate_buffers.hppindex 5f5c048ae12..db7ca339e16 100644--- a/src/common/snippets/include/snippets/lowered/pass/allocate_buffers.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/allocate_buffers.hpp@@ -4,12 +4,11 @@#pragma once+#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface AllocateBuffers@@ -40,7 +39,4 @@ private:bool m_is_optimized_mode = true;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/assign_registers.hpp b/src/common/snippets/include/snippets/lowered/pass/assign_registers.hppindex 164e1eba98b..e5076e337a0 100644--- a/src/common/snippets/include/snippets/lowered/pass/assign_registers.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/assign_registers.hpp@@ -4,14 +4,16 @@#pragma once+#include <map>+#include <set>++#include "openvino/core/rtti.hpp"#include "pass.hpp"-#include "snippets/generator.hpp"+#include "snippets/emitter.hpp"+#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/reg_manager.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface AssignRegisters@@ -27,12 +29,9 @@ public:private:using RegMap = std::map<Reg, Reg>;- RegMap assign_regs_manually(const LinearIR& linear_ir, std::set<Reg>& gpr_pool, std::set<Reg>& vec_pool);+ static RegMap assign_regs_manually(const LinearIR& linear_ir, std::set<Reg>& gpr_pool, std::set<Reg>& vec_pool);RegManager& m_reg_manager;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/brgemm_blocking.hpp b/src/common/snippets/include/snippets/lowered/pass/brgemm_blocking.hppindex 4bf247f6d09..926817306f3 100644--- a/src/common/snippets/include/snippets/lowered/pass/brgemm_blocking.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/brgemm_blocking.hpp@@ -4,16 +4,24 @@#pragma once+#include <cstddef>+#include <tuple>+#include <type_traits>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/rtti.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_manager.hpp"-#include "snippets/lowered/pass/iter_handler.hpp"+#include "snippets/lowered/loop_port.hpp"+#include "snippets/lowered/pass/pass.hpp"#include "snippets/lowered/specific_loop_iter_handlers.hpp"#include "snippets/op/brgemm.hpp"+#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface BrgemmBlockingBase@@ -23,6 +31,7 @@ namespace pass {*/class BrgemmBlockingBase {public:+ virtual ~BrgemmBlockingBase() = default;static snippets::lowered::SpecificIterationHandlers get_default_blocking_loop_handlers(size_t work_amount,size_t block_size);@@ -33,7 +42,7 @@ protected:* @param brgemm_expr Brgemm expression* @return tuple in format (m_block, n_block, k_block)*/- virtual std::tuple<size_t, size_t, size_t> get_blocking_params(+ [[nodiscard]] virtual std::tuple<size_t, size_t, size_t> get_blocking_params(const ov::snippets::lowered::ExpressionPtr& brgemm_expr) const;/*** @interface get_brgemm_dimensions@@ -79,15 +88,11 @@ protected:const std::vector<snippets::lowered::LoopPort>& exits,size_t block_size_k);- virtual SpecificIterationHandlers get_m_loop_handlers(size_t work_amount, size_t block_size) const;- virtual SpecificIterationHandlers get_n_loop_handlers(size_t work_amount, size_t block_size) const;- virtual SpecificIterationHandlers get_k_loop_handlers(size_t work_amount, size_t block_size) const;+ [[nodiscard]] virtual SpecificIterationHandlers get_m_loop_handlers(size_t work_amount, size_t block_size) const;+ [[nodiscard]] virtual SpecificIterationHandlers get_n_loop_handlers(size_t work_amount, size_t block_size) const;+ [[nodiscard]] virtual SpecificIterationHandlers get_k_loop_handlers(size_t work_amount, size_t block_size) const;- static inline size_t get_corrected_blk_size_by_dim(const size_t dim, const size_t default_blk) {- if (!utils::is_dynamic_value(dim) && dim <= default_blk)- return utils::get_full_dim_value();- return default_blk;- }+ static size_t get_corrected_blk_size_by_dim(size_t dim, size_t default_blk);};/**@@ -95,8 +100,7 @@ protected:* @brief Base class for brgemm blocking passes* @ingroup snippets*/-template <typename BRGEMM_TYPE,- typename std::enable_if<std::is_base_of<ov::snippets::op::Brgemm, BRGEMM_TYPE>::value, bool>::type = true>+template <typename BRGEMM_TYPE, std::enable_if_t<std::is_base_of_v<ov::snippets::op::Brgemm, BRGEMM_TYPE>, bool> = true>class BrgemmBlocking : public snippets::lowered::pass::RangedPass, public BrgemmBlockingBase {public:OPENVINO_RTTI("BrgemmBlocking", "", RangedPass)@@ -110,18 +114,15 @@ public:for (auto expr_it = begin; expr_it != end; expr_it++) {const auto& brgemm_expr = *expr_it;const auto brgemm = ov::as_type_ptr<BRGEMM_TYPE>(brgemm_expr->get_node());- if (!brgemm)+ if (!brgemm) {continue;+ }OPENVINO_ASSERT(!blocking_loop_exists(loop_manager, brgemm_expr),"Brgemm mustn't be covered in loops before blocking pass");- size_t m_block, n_block, k_block;- std::tie(m_block, n_block, k_block) = get_blocking_params(brgemm_expr);+ auto [m_block, n_block, k_block] = get_blocking_params(brgemm_expr);modified = mark_blocking_loops(linear_ir, expr_it, m_block, n_block, k_block);}return modified;}};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/clean_repeated_ptr_shifts.hpp b/src/common/snippets/include/snippets/lowered/pass/clean_repeated_ptr_shifts.hppindex 3c7eb1e108a..e41a0d82433 100644--- a/src/common/snippets/include/snippets/lowered/pass/clean_repeated_ptr_shifts.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/clean_repeated_ptr_shifts.hpp@@ -4,12 +4,12 @@#pragma once+#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface CleanRepeatedDataPointerShifts@@ -31,10 +31,7 @@ public:lowered::LinearIR::constExprIt end) override;private:- bool reuse_increments(const LoopManagerPtr& loop_manager, const ExpressionPtr& loop_end_expr);+ static bool reuse_increments(const LoopManagerPtr& loop_manager, const ExpressionPtr& loop_end_expr);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/cleanup_loop_offsets.hpp b/src/common/snippets/include/snippets/lowered/pass/cleanup_loop_offsets.hppindex 6a6c5cb676c..d78f0d1be8a 100644--- a/src/common/snippets/include/snippets/lowered/pass/cleanup_loop_offsets.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/cleanup_loop_offsets.hpp@@ -4,12 +4,11 @@#pragma once+#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface CleanupLoopOffsets@@ -26,7 +25,4 @@ public:lowered::LinearIR::constExprIt end) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/compute_buffer_allocation_size.hpp b/src/common/snippets/include/snippets/lowered/pass/compute_buffer_allocation_size.hppindex 1f1ecb7ec0f..e27f3304d5c 100644--- a/src/common/snippets/include/snippets/lowered/pass/compute_buffer_allocation_size.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/compute_buffer_allocation_size.hpp@@ -4,13 +4,11 @@#pragma once+#include "openvino/core/rtti.hpp"#include "pass.hpp"-#include "snippets/lowered/loop_manager.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface ComputeBufferAllocationSize@@ -26,7 +24,4 @@ public:bool run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/define_buffer_clusters.hpp b/src/common/snippets/include/snippets/lowered/pass/define_buffer_clusters.hppindex 14a6d0752b7..16d209586c2 100644--- a/src/common/snippets/include/snippets/lowered/pass/define_buffer_clusters.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/define_buffer_clusters.hpp@@ -4,13 +4,20 @@#pragma once+#include <cstddef>+#include <set>+#include <unordered_map>+#include <utility>+#include <vector>++#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/expressions/buffer_expression.hpp"+#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_info.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface DefineBufferClusters@@ -145,7 +152,4 @@ private:BufferClusters m_clusters;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/extract_loop_invariants.hpp b/src/common/snippets/include/snippets/lowered/pass/extract_loop_invariants.hppindex 11d2782a299..e71a9bc744b 100644--- a/src/common/snippets/include/snippets/lowered/pass/extract_loop_invariants.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/extract_loop_invariants.hpp@@ -4,13 +4,11 @@#pragma once+#include "openvino/core/rtti.hpp"#include "pass.hpp"-#include "snippets/lowered/loop_manager.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface ExtractLoopInvariants@@ -25,7 +23,4 @@ public:bool run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/fuse_loops.hpp b/src/common/snippets/include/snippets/lowered/pass/fuse_loops.hppindex 2c579865e94..bc3c70b6016 100644--- a/src/common/snippets/include/snippets/lowered/pass/fuse_loops.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/fuse_loops.hpp@@ -4,13 +4,17 @@#pragma once+#include <cstddef>+#include <memory>++#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/expression_port.hpp"+#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/loop_manager.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface FuseLoops@@ -58,7 +62,7 @@ private:LinearIR::constExprIt& current_loop_end_pos);static bool fuse_lower_into_current(LinearIR& linear_ir,const LoopManagerPtr& loop_manager,- const std::shared_ptr<ExpressionPort>& current_input_port,+ const std::shared_ptr<ExpressionPort>& current_output_port,size_t current_loop_id,size_t target_loop_id,LinearIR::constExprIt& current_loop_begin_pos,@@ -71,7 +75,4 @@ private:LinearIR::constExprIt pos);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/init_buffers_default.hpp b/src/common/snippets/include/snippets/lowered/pass/init_buffers_default.hppindex 15d30d7102d..27039887cda 100644--- a/src/common/snippets/include/snippets/lowered/pass/init_buffers_default.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/init_buffers_default.hpp@@ -4,12 +4,13 @@#pragma once+#include <cstddef>++#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface InitBuffersDefault@@ -38,7 +39,4 @@ private:size_t& m_buffer_scratchpad_size;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/init_live_ranges.hpp b/src/common/snippets/include/snippets/lowered/pass/init_live_ranges.hppindex 21bb0017a79..d5cb7586b5d 100644--- a/src/common/snippets/include/snippets/lowered/pass/init_live_ranges.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/init_live_ranges.hpp@@ -4,14 +4,12 @@#pragma once+#include "openvino/core/rtti.hpp"#include "pass.hpp"-#include "snippets/generator.hpp"+#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/reg_manager.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface InitLiveRanges@@ -29,7 +27,4 @@ private:RegManager& m_reg_manager;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/init_loops.hpp b/src/common/snippets/include/snippets/lowered/pass/init_loops.hppindex f56f21283c8..1094d0948ee 100644--- a/src/common/snippets/include/snippets/lowered/pass/init_loops.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/init_loops.hpp@@ -4,13 +4,12 @@#pragma once+#include "openvino/core/rtti.hpp"#include "pass.hpp"-#include "snippets/lowered/loop_manager.hpp"+#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/loop_info.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface InitLoops@@ -27,7 +26,4 @@ private:static void update_compile_parameters(const UnifiedLoopInfoPtr& loop_info);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/init_registers.hpp b/src/common/snippets/include/snippets/lowered/pass/init_registers.hppindex 0cf9c294982..9e0b7c367a1 100644--- a/src/common/snippets/include/snippets/lowered/pass/init_registers.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/init_registers.hpp@@ -4,14 +4,16 @@#pragma once+#include <memory>++#include "openvino/core/rtti.hpp"#include "pass.hpp"#include "snippets/generator.hpp"+#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/pass/pass_config.hpp"#include "snippets/lowered/reg_manager.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface InitRegisters@@ -29,7 +31,4 @@ private:const std::shared_ptr<PassConfig>& m_pass_config;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/insert_broadcastmove.hpp b/src/common/snippets/include/snippets/lowered/pass/insert_broadcastmove.hppindex 3f025298838..0719a6ba747 100644--- a/src/common/snippets/include/snippets/lowered/pass/insert_broadcastmove.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/insert_broadcastmove.hpp@@ -4,12 +4,17 @@#pragma once+#include <cstddef>+#include <memory>+#include <vector>++#include "openvino/core/node.hpp"+#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface InsertMovebroadcast@@ -29,7 +34,4 @@ private:static size_t get_max_dim(const std::vector<size_t>& last_dims);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/insert_buffers.hpp b/src/common/snippets/include/snippets/lowered/pass/insert_buffers.hppindex 6432195a850..646db5c8412 100644--- a/src/common/snippets/include/snippets/lowered/pass/insert_buffers.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/insert_buffers.hpp@@ -4,13 +4,16 @@#pragma once+#include <vector>++#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/expression_port.hpp"+#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_manager.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface InsertBuffers@@ -28,12 +31,11 @@ public:bool run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) override;private:- void insertion(LinearIR& linear_ir,- const LinearIR::constExprIt& begin_it,- const LinearIR::constExprIt& end_it,- const LoopManagerPtr& loop_manager,- const std::vector<ExpressionPort>& loop_entries,- const std::vector<ExpressionPort>& loop_exits) const;+ static void insertion(LinearIR& linear_ir,+ const LinearIR::constExprIt& begin_it,+ const LoopManagerPtr& loop_manager,+ const std::vector<ExpressionPort>& loop_entries,+ const std::vector<ExpressionPort>& loop_exits);static LinearIR::constExprIt insertion_position(const LinearIR& linear_ir,const LoopManagerPtr& loop_manager,@@ -41,7 +43,4 @@ private:const ExpressionPtr& down_expr);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/insert_load_store.hpp b/src/common/snippets/include/snippets/lowered/pass/insert_load_store.hppindex 0ab623a5b56..986150955cb 100644--- a/src/common/snippets/include/snippets/lowered/pass/insert_load_store.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/insert_load_store.hpp@@ -4,13 +4,14 @@#pragma once+#include <cstddef>++#include "openvino/core/rtti.hpp"#include "pass.hpp"-#include "snippets/lowered/loop_manager.hpp"+#include "snippets/lowered/expression_port.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface InsertLoadStore@@ -34,7 +35,4 @@ private:size_t m_vector_size;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/insert_loops.hpp b/src/common/snippets/include/snippets/lowered/pass/insert_loops.hppindex 9ef77d6de4d..e8a420feda4 100644--- a/src/common/snippets/include/snippets/lowered/pass/insert_loops.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/insert_loops.hpp@@ -4,14 +4,14 @@#pragma once+#include <cstddef>++#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_manager.hpp"-#include "snippets/op/loop.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface InsertLoops@@ -28,7 +28,4 @@ private:static void insertion(LinearIR& linear_ir, const LoopManagerPtr& loop_manager, size_t loop_id);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/insert_perf_count.hpp b/src/common/snippets/include/snippets/lowered/pass/insert_perf_count.hppindex 99698c05807..4532ed77bba 100644--- a/src/common/snippets/include/snippets/lowered/pass/insert_perf_count.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/insert_perf_count.hpp@@ -1,17 +1,18 @@// Copyright (C) 2018-2025 Intel Corporation// SPDX-License-Identifier: Apache-2.0//+#include <map>+#include <string>++#include "openvino/core/rtti.hpp"+#include "snippets/lowered/linear_ir.hpp"#ifdef SNIPPETS_DEBUG_CAPS# pragma once# include "pass.hpp"-# include "snippets/op/perf_count.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface InsertPerfCount@@ -30,8 +31,6 @@ private:std::map<std::string, std::string> m_boundary_op_names;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::pass+#endif // SNIPPETS_DEBUG_CAPSdiff --git a/src/common/snippets/include/snippets/lowered/pass/insert_perf_count_verbose.hpp b/src/common/snippets/include/snippets/lowered/pass/insert_perf_count_verbose.hppindex b5d2a7d327b..188a2266d15 100644--- a/src/common/snippets/include/snippets/lowered/pass/insert_perf_count_verbose.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/insert_perf_count_verbose.hpp@@ -2,21 +2,21 @@// SPDX-License-Identifier: Apache-2.0//+#include <string>++#include "openvino/core/rtti.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/pass/pass.hpp"#ifdef SNIPPETS_DEBUG_CAPS# pragma once+# include <utility>+# include "snippets/itt.hpp"-# include "snippets/lowered/loop_manager.hpp"-# include "snippets/lowered/pass/iter_handler.hpp"-# include "snippets/lowered/specific_loop_iter_handlers.hpp"-# include "snippets/op/brgemm.hpp"-# include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface InsertPerfCountVerbose@@ -25,7 +25,7 @@ namespace pass {*/class InsertPerfCountVerbose : public snippets::lowered::pass::RangedPass {public:- InsertPerfCountVerbose(const std::string& subgraph_name) : m_subgraph_name(subgraph_name) {}+ InsertPerfCountVerbose(std::string subgraph_name) : m_subgraph_name(std::move(subgraph_name)) {}OPENVINO_RTTI("InsertPerfCountVerbose", "", RangedPass);bool run(snippets::lowered::LinearIR& linear_ir,@@ -39,9 +39,6 @@ private:std::string m_subgraph_name;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::pass#endif // SNIPPETS_DEBUG_CAPSdiff --git a/src/common/snippets/include/snippets/lowered/pass/insert_reg_spills.hpp b/src/common/snippets/include/snippets/lowered/pass/insert_reg_spills.hppindex a8fbb53c861..bcfaa53d83d 100644--- a/src/common/snippets/include/snippets/lowered/pass/insert_reg_spills.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/insert_reg_spills.hpp@@ -4,13 +4,18 @@#pragma once+#include <functional>+#include <utility>++#include "openvino/core/rtti.hpp"+#include "openvino/core/type.hpp"#include "pass.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/reg_manager.hpp"+#include "snippets/op/brgemm.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @brief Default function to enable RegSpill insertion@@ -39,7 +44,4 @@ private:std::function<bool(const ExpressionPtr&)> m_needs_reg_spill;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/insert_specific_iterations.hpp b/src/common/snippets/include/snippets/lowered/pass/insert_specific_iterations.hppindex 0affddad452..377b24649a9 100644--- a/src/common/snippets/include/snippets/lowered/pass/insert_specific_iterations.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/insert_specific_iterations.hpp@@ -4,18 +4,23 @@#pragma once+#include <cstddef>+#include <memory>+#include <vector>++#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/loop_manager.hpp"+#include "snippets/lowered/loop_port.hpp"#include "snippets/lowered/specific_loop_iter_types.hpp"#include "snippets/op/loop.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/**- * @interface InsertSpecificIterations+ * @ interface InsertSpecificIterations* @brief Inserts separate loop bodies for first/last iterations if needed.* Also calls previously registered SpecificIterationHandlers for the inserted bodies and the main body.* @ingroup snippets@@ -83,7 +88,7 @@ private:* @return LoopBounds: iterators of new LoopBegin and LoopEnd*/static LoopManager::LoopBounds insert_copy_loop(LinearIR& linear_ir,- const size_t loop_id,+ size_t loop_id,const LinearIR::constExprIt& insert_pos,std::vector<LoopPort>& new_entry_ports,std::vector<LoopPort>& new_exit_ports);@@ -104,7 +109,4 @@ private:const std::shared_ptr<op::LoopEnd>& decomposed_loop_end);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/iter_handler.hpp b/src/common/snippets/include/snippets/lowered/pass/iter_handler.hppindex 60c59f02fd2..f1812773309 100644--- a/src/common/snippets/include/snippets/lowered/pass/iter_handler.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/iter_handler.hpp@@ -4,13 +4,14 @@#pragma once+#include <cstddef>+#include <memory>++#include "openvino/core/rtti.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/pass/pass.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface UpdateMemoryAccessCounts* @brief The pass changes counts of all MemoryAccess ops@@ -64,7 +65,4 @@ public:const std::shared_ptr<snippets::lowered::pass::PassBase>& other) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/load_movebroadcast_to_broadcastload.hpp b/src/common/snippets/include/snippets/lowered/pass/load_movebroadcast_to_broadcastload.hppindex 6c2cff8dfd2..79efb93903b 100644--- a/src/common/snippets/include/snippets/lowered/pass/load_movebroadcast_to_broadcastload.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/load_movebroadcast_to_broadcastload.hpp@@ -4,12 +4,11 @@#pragma once+#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface LoadMoveBroadcastToBroadcastLoad@@ -23,7 +22,4 @@ public:bool run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/mark_invariant_shape_path.hpp b/src/common/snippets/include/snippets/lowered/pass/mark_invariant_shape_path.hppindex 73a41d19876..f69b34fbb98 100644--- a/src/common/snippets/include/snippets/lowered/pass/mark_invariant_shape_path.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/mark_invariant_shape_path.hpp@@ -4,12 +4,15 @@#pragma once+#include <cstddef>++#include "openvino/core/any.hpp"+#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/expression_port.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface MarkInvariantShapePath@@ -59,7 +62,4 @@ private:static ov::RTMap& get_rt_info(const ExpressionPort& port);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/mark_loops.hpp b/src/common/snippets/include/snippets/lowered/pass/mark_loops.hppindex 6213984aa91..3d3d4fbe50f 100644--- a/src/common/snippets/include/snippets/lowered/pass/mark_loops.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/mark_loops.hpp@@ -4,12 +4,13 @@#pragma once+#include <cstddef>++#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface MarkLoops@@ -29,7 +30,4 @@ private:size_t m_vector_size;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/mha_parallel_wa_optimizer.hpp b/src/common/snippets/include/snippets/lowered/pass/mha_parallel_wa_optimizer.hppindex 878c5f5c848..252cd853ab0 100644--- a/src/common/snippets/include/snippets/lowered/pass/mha_parallel_wa_optimizer.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/mha_parallel_wa_optimizer.hpp@@ -4,14 +4,18 @@#pragma once+#include <cstddef>+#include <unordered_set>+#include <vector>++#include "openvino/core/rtti.hpp"+#include "snippets/lowered/expression.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/pass/runtime_optimizer.hpp"+#include "snippets/runtime_configurator.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {class SetDynamicWAToOuterMostLoop;/**@@ -47,16 +51,13 @@ private:const lowered::LinearIRCPtr& linear_ir,const std::unordered_set<size_t>& unsqueezed_params);- std::vector<lowered::ExpandedLoopInfoPtr> m_loops_to_split{};- std::unordered_set<size_t> m_unsqueezed_params{};- std::vector<std::vector<size_t>> m_optimized_layouts{};- std::vector<size_t> m_dim_M_idces{};+ std::vector<lowered::ExpandedLoopInfoPtr> m_loops_to_split;+ std::unordered_set<size_t> m_unsqueezed_params;+ std::vector<std::vector<size_t>> m_optimized_layouts;+ std::vector<size_t> m_dim_M_idces;size_t m_concurrency = 0;static const size_t m_dim_M_idx;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/move_result_out_of_loop.hpp b/src/common/snippets/include/snippets/lowered/pass/move_result_out_of_loop.hppindex 82e88a89c3b..2989319567b 100644--- a/src/common/snippets/include/snippets/lowered/pass/move_result_out_of_loop.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/move_result_out_of_loop.hpp@@ -4,12 +4,11 @@#pragma once+#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface MoveResultOutOfLoop@@ -26,7 +25,4 @@ public:bool run(LinearIR& linear_ir) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/move_scalar_to_consumer.hpp b/src/common/snippets/include/snippets/lowered/pass/move_scalar_to_consumer.hppindex afdfbbb616e..ebf13bb0065 100644--- a/src/common/snippets/include/snippets/lowered/pass/move_scalar_to_consumer.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/move_scalar_to_consumer.hpp@@ -4,12 +4,11 @@#pragma once+#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface MoveScalarToConsumer@@ -28,7 +27,4 @@ public:bool run(LinearIR& linear_ir) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/normalize_buffer_reg_groups.hpp b/src/common/snippets/include/snippets/lowered/pass/normalize_buffer_reg_groups.hppindex 2a0685c8c42..ef58c720e81 100644--- a/src/common/snippets/include/snippets/lowered/pass/normalize_buffer_reg_groups.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/normalize_buffer_reg_groups.hpp@@ -4,12 +4,11 @@#pragma once+#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface NormalizeBufferRegisterGroups@@ -36,7 +35,4 @@ public:lowered::LinearIR::constExprIt end) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/normalize_loop_ids.hpp b/src/common/snippets/include/snippets/lowered/pass/normalize_loop_ids.hppindex 7e58843b453..e09db95e7ca 100644--- a/src/common/snippets/include/snippets/lowered/pass/normalize_loop_ids.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/normalize_loop_ids.hpp@@ -4,12 +4,14 @@#pragma once+#include <cstddef>+#include <map>++#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface NormalizeLoopIDs@@ -37,12 +39,9 @@ private:// [ original Loop ID -> new normalized and sorted ]using IDMapper = std::map<size_t, size_t>;- static void update_linear_ir(lowered::LinearIR& linear_ir, const IDMapper& loop_ids);+ static void update_linear_ir(lowered::LinearIR& linear_ir, const IDMapper& loop_id_map);bool m_has_specific_loops = true;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/optimize_domain.hpp b/src/common/snippets/include/snippets/lowered/pass/optimize_domain.hppindex 8a1ea53ebb0..16e943f1402 100644--- a/src/common/snippets/include/snippets/lowered/pass/optimize_domain.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/optimize_domain.hpp@@ -4,13 +4,15 @@#pragma once+#include <cstddef>+#include <vector>++#include "openvino/core/rtti.hpp"+#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/pass/pass.hpp"#include "snippets/shape_types.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface OptimizeDomain@@ -63,7 +65,4 @@ private:size_t total_work_amount);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/optimize_loop_single_evaluation.hpp b/src/common/snippets/include/snippets/lowered/pass/optimize_loop_single_evaluation.hppindex 4f0167720d2..1f6d85df167 100644--- a/src/common/snippets/include/snippets/lowered/pass/optimize_loop_single_evaluation.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/optimize_loop_single_evaluation.hpp@@ -4,12 +4,11 @@#pragma once+#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface OptimizeLoopSingleEvaluation@@ -26,7 +25,4 @@ public:lowered::LinearIR::constExprIt end) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/pass.hpp b/src/common/snippets/include/snippets/lowered/pass/pass.hppindex 3eb2cc30eb0..b062806cf86 100644--- a/src/common/snippets/include/snippets/lowered/pass/pass.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/pass.hpp@@ -4,16 +4,18 @@#pragma once+#include <memory>+#include <type_traits>+#include <vector>+#include "openvino/core/rtti.hpp"#include "openvino/core/type.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/pass/pass_config.hpp"#include "snippets/pass/positioned_pass.hpp"+#include "snippets/shape_inference/shape_inference.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface PassBase@@ -47,7 +49,7 @@ public:* @attention If 'other' pass is empty (aka nullptr), it can be merged to any other pass.* @attention If the merge fails, then nullptr is returned.*/- virtual std::shared_ptr<PassBase> merge(const std::shared_ptr<PassBase>& other) {+ virtual std::shared_ptr<PassBase> merge([[maybe_unused]] const std::shared_ptr<PassBase>& other) {return nullptr;}};@@ -111,13 +113,13 @@ public:PassPipeline();PassPipeline(const std::shared_ptr<PassConfig>& pass_config);- const std::vector<std::shared_ptr<PassBase>>& get_passes() const {+ [[nodiscard]] const std::vector<std::shared_ptr<PassBase>>& get_passes() const {return m_passes;}- const std::shared_ptr<PassConfig>& get_pass_config() const {+ [[nodiscard]] const std::shared_ptr<PassConfig>& get_pass_config() const {return m_pass_config;}- bool empty() const {+ [[nodiscard]] bool empty() const {return m_passes.empty();}@@ -133,7 +135,7 @@ public:template <typename T,class Pos,class... Args,- std::enable_if<std::is_same<snippets::pass::PassPosition, Pos>::value, bool>() = true>+ std::enable_if<std::is_same_v<snippets::pass::PassPosition, Pos>, bool>() = true>void register_pass(const snippets::pass::PassPosition& position, Args&&... args) {static_assert(std::is_base_of<PassBase, T>::value, "Pass not derived from lowered::Pass");auto pass = std::make_shared<T>(std::forward<Args>(args)...);@@ -163,7 +165,4 @@ private:std::vector<std::shared_ptr<PassBase>> m_passes;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/pass_config.hpp b/src/common/snippets/include/snippets/lowered/pass/pass_config.hppindex 4feec5a2651..06626f5265d 100644--- a/src/common/snippets/include/snippets/lowered/pass/pass_config.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/pass_config.hpp@@ -4,14 +4,11 @@#pragma once-#include "openvino/core/rtti.hpp"+#include <unordered_set>+#include "openvino/core/type.hpp"-#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface PassConfig@@ -55,7 +52,4 @@ private:std::unordered_set<DiscreteTypeInfo> m_enabled;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/propagate_buffer_offset.hpp b/src/common/snippets/include/snippets/lowered/pass/propagate_buffer_offset.hppindex c892be5003c..822b57c168d 100644--- a/src/common/snippets/include/snippets/lowered/pass/propagate_buffer_offset.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/propagate_buffer_offset.hpp@@ -4,12 +4,12 @@#pragma once+#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/expressions/buffer_expression.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface PropagateBufferOffset@@ -37,7 +37,4 @@ private:static void propagate(const BufferExpressionPtr& buffer_expr);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/propagate_subtensors.hpp b/src/common/snippets/include/snippets/lowered/pass/propagate_subtensors.hppindex f4a62ce7ca3..3bf90d9e02d 100644--- a/src/common/snippets/include/snippets/lowered/pass/propagate_subtensors.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/propagate_subtensors.hpp@@ -4,13 +4,14 @@#pragma once+#include <cstddef>+#include <memory>++#include "openvino/core/rtti.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/pass/pass.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface UpdateSubtensors* @brief The pass updates subtensors of all operations in Loop based on tail size.@@ -30,7 +31,4 @@ private:size_t m_tail_size;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/reduce_decomposition.hpp b/src/common/snippets/include/snippets/lowered/pass/reduce_decomposition.hppindex 0142d5d3dce..433414005ac 100644--- a/src/common/snippets/include/snippets/lowered/pass/reduce_decomposition.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/reduce_decomposition.hpp@@ -4,12 +4,13 @@#pragma once+#include <cstddef>++#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface ReduceDecomposition@@ -27,7 +28,4 @@ private:size_t m_vector_size = 0;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/runtime_optimizer.hpp b/src/common/snippets/include/snippets/lowered/pass/runtime_optimizer.hppindex 9159a4baeb6..13b23197464 100644--- a/src/common/snippets/include/snippets/lowered/pass/runtime_optimizer.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/runtime_optimizer.hpp@@ -4,14 +4,14 @@#pragma once-#include "snippets/lowered/linear_ir.hpp"+#include <type_traits>++#include "openvino/core/except.hpp"+#include "openvino/core/rtti.hpp"#include "snippets/lowered/pass/pass.hpp"#include "snippets/runtime_configurator.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @class RuntimeOptimizer* @brief Base class for runtime optimizers that operate on LinearIR and RuntimeConfigurator during@@ -38,7 +38,7 @@ public:*/template <typename OptimizerType,typename... Args,- typename = std::enable_if<std::is_base_of<RuntimeOptimizer, OptimizerType>::value>>+ typename = std::enable_if_t<std::is_base_of_v<RuntimeOptimizer, OptimizerType>>>static void register_if_applicable(PassPipeline& pipeline, Args&&... args) {auto pass = std::make_shared<OptimizerType>(std::forward<Args>(args)...);if (pass->applicable()) {@@ -50,7 +50,4 @@ protected:const RuntimeConfigurator* m_configurator = nullptr;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/serialize_base.hpp b/src/common/snippets/include/snippets/lowered/pass/serialize_base.hppindex f12083784d0..106c52b704b 100644--- a/src/common/snippets/include/snippets/lowered/pass/serialize_base.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/serialize_base.hpp@@ -6,10 +6,7 @@#include "pass.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface SerializeBase@@ -19,16 +16,13 @@ namespace pass {class SerializeBase : public ConstPass {public:OPENVINO_RTTI("SerializeBase", "", ConstPass)- SerializeBase(const std::string& xml_path);+ SerializeBase(std::string xml_path);protected:- std::string get_bin_path_from_xml(const std::string& xml_path);+ static std::string get_bin_path();const std::string m_xml_path;const std::string m_bin_path;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/serialize_control_flow.hpp b/src/common/snippets/include/snippets/lowered/pass/serialize_control_flow.hppindex 354a0feeef7..e18b3c75393 100644--- a/src/common/snippets/include/snippets/lowered/pass/serialize_control_flow.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/serialize_control_flow.hpp@@ -4,13 +4,13 @@#pragma once+#include <string>++#include "openvino/core/rtti.hpp"#include "serialize_base.hpp"#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface SerializeControlFlow@@ -29,7 +29,4 @@ private:const bool m_update_dynamic_ops = false;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/serialize_data_flow.hpp b/src/common/snippets/include/snippets/lowered/pass/serialize_data_flow.hppindex 75a2a42a3bb..0d336706a9a 100644--- a/src/common/snippets/include/snippets/lowered/pass/serialize_data_flow.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/serialize_data_flow.hpp@@ -4,13 +4,13 @@#pragma once+#include <string>++#include "openvino/core/rtti.hpp"#include "serialize_base.hpp"#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface SerializeDataFlow@@ -26,7 +26,4 @@ public:bool run(const LinearIR& linear_ir) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/set_buffer_reg_group.hpp b/src/common/snippets/include/snippets/lowered/pass/set_buffer_reg_group.hppindex 555e2c7be1c..2cb7d063a33 100644--- a/src/common/snippets/include/snippets/lowered/pass/set_buffer_reg_group.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/set_buffer_reg_group.hpp@@ -4,14 +4,17 @@#pragma once+#include <cstddef>+#include <map>+#include <vector>++#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/expressions/buffer_expression.hpp"+#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_info.hpp"-#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface SetBufferRegGroup@@ -122,7 +125,4 @@ private:static BufferMap get_buffer_loop_inside(const LinearIR::constExprIt& loop_end_it);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/set_dynamic_wa_to_outermost_loop.hpp b/src/common/snippets/include/snippets/lowered/pass/set_dynamic_wa_to_outermost_loop.hppindex 033de2358f2..6d1b439dfdc 100644--- a/src/common/snippets/include/snippets/lowered/pass/set_dynamic_wa_to_outermost_loop.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/set_dynamic_wa_to_outermost_loop.hpp@@ -4,12 +4,11 @@#pragma once+#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface SetDynamicWAToOuterMostLoop@@ -24,7 +23,4 @@ public:bool run(LinearIR& linear_ir) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/set_load_store_scalar.hpp b/src/common/snippets/include/snippets/lowered/pass/set_load_store_scalar.hppindex 148954080a4..b112fb62072 100644--- a/src/common/snippets/include/snippets/lowered/pass/set_load_store_scalar.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/set_load_store_scalar.hpp@@ -4,12 +4,11 @@#pragma once+#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface SetLoadStoreScalar@@ -24,7 +23,4 @@ public:bool run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/solve_buffer_memory.hpp b/src/common/snippets/include/snippets/lowered/pass/solve_buffer_memory.hppindex d7230eaefc4..d5e5b8c05ea 100644--- a/src/common/snippets/include/snippets/lowered/pass/solve_buffer_memory.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/solve_buffer_memory.hpp@@ -4,13 +4,17 @@#pragma once+#include <cstddef>+#include <utility>+#include <vector>++#include "openvino/core/rtti.hpp"#include "openvino/runtime/memory_solver.hpp"#include "pass.hpp"+#include "snippets/lowered/expressions/buffer_expression.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface SolveBufferMemory@@ -46,14 +50,14 @@ private:* @param buffer_expressions buffer expressions* @return the pair of static and dynamic buffer expressions*/- std::pair<Buffers, Buffers> extract_static_and_dynamic_buffers(const Buffers& buffer_expressions);+ static std::pair<Buffers, Buffers> extract_static_and_dynamic_buffers(const Buffers& buffer_expressions);/*** @brief Initializes boxes for MemorySolver* @param buffer_expressions buffer expressions* @param linear_ir linear ir* @return vector of boxes for MemorySolver*/- std::vector<ov::MemorySolver::Box> init_boxes(const Buffers& buffer_expressions, const LinearIR& linear_ir);+ static std::vector<ov::MemorySolver::Box> init_boxes(const Buffers& buffer_expressions, const LinearIR& linear_ir);/*** @brief Calculate memory size and set offset to buffer with defined allocation size* @param static_buffer_expressions static buffer expressions@@ -65,12 +69,9 @@ private:* Note: should be called after `solve_static_buffer_memory`* @param dynamic_buffer_expressions dynamic buffer expressions*/- void set_dynamic_buffer_offset(const Buffers& dynamic_buffer_expressions);+ void set_dynamic_buffer_offset(const Buffers& dynamic_buffer_expressions) const;size_t& m_static_buffer_scratchpad_size;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/split_loops.hpp b/src/common/snippets/include/snippets/lowered/pass/split_loops.hppindex 6f0394284bc..4f078c37cf5 100644--- a/src/common/snippets/include/snippets/lowered/pass/split_loops.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/split_loops.hpp@@ -4,13 +4,15 @@#pragma once+#include <cstddef>+#include <memory>++#include "openvino/core/rtti.hpp"#include "pass.hpp"-#include "snippets/lowered/loop_manager.hpp"+#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/loop_info.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {// clang-format off/**@@ -38,7 +40,7 @@ public:bool run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) override;private:- static bool can_be_split(const UnifiedLoopInfoPtr& current, const UnifiedLoopInfoPtr& target);+ static bool can_be_split(const UnifiedLoopInfoPtr& loop_to_split, const UnifiedLoopInfoPtr& loop_to_fuse);static void split(LinearIR& linear_ir, size_t loop_to_split_id, size_t outer_increment);@@ -57,7 +59,4 @@ private:};};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/validate.hpp b/src/common/snippets/include/snippets/lowered/pass/validate.hppindex d9c1490d73f..dda26bdb652 100644--- a/src/common/snippets/include/snippets/lowered/pass/validate.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/validate.hpp@@ -4,12 +4,16 @@#pragma once+#include <functional>+#include <unordered_map>++#include "openvino/core/rtti.hpp"+#include "openvino/core/type.hpp"#include "pass.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface Validate@@ -27,7 +31,4 @@ private:std::unordered_map<ov::DiscreteTypeInfo, Validator> m_validation_map;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/validate_buffers.hpp b/src/common/snippets/include/snippets/lowered/pass/validate_buffers.hppindex 254b4aba11a..92dccf877fe 100644--- a/src/common/snippets/include/snippets/lowered/pass/validate_buffers.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/validate_buffers.hpp@@ -4,12 +4,11 @@#pragma once+#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface ValidateBuffers@@ -23,7 +22,4 @@ public:bool run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/validate_expanded_loops.hpp b/src/common/snippets/include/snippets/lowered/pass/validate_expanded_loops.hppindex 0198a4888bd..b201386a5c9 100644--- a/src/common/snippets/include/snippets/lowered/pass/validate_expanded_loops.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/validate_expanded_loops.hpp@@ -4,12 +4,11 @@#pragma once+#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface ValidateExpandedLoops@@ -27,7 +26,4 @@ private:static void validate_loop_expressions(const LinearIR& linear_ir);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/validate_shapes.hpp b/src/common/snippets/include/snippets/lowered/pass/validate_shapes.hppindex f1bf99216aa..6df8a011b75 100644--- a/src/common/snippets/include/snippets/lowered/pass/validate_shapes.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/validate_shapes.hpp@@ -4,12 +4,11 @@#pragma once+#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface ValidateShapes@@ -25,7 +24,4 @@ public:lowered::LinearIR::constExprIt end) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/pass/validate_unified_loops.hpp b/src/common/snippets/include/snippets/lowered/pass/validate_unified_loops.hppindex 50424c994cb..aa621065e37 100644--- a/src/common/snippets/include/snippets/lowered/pass/validate_unified_loops.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/validate_unified_loops.hpp@@ -4,13 +4,12 @@#pragma once+#include "openvino/core/rtti.hpp"#include "pass.hpp"+#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_manager.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {/*** @interface ValidateUnifiedLoops@@ -34,7 +33,4 @@ private:static void validate_loop_port_presence(const LinearIR& linear_ir);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/include/snippets/lowered/port_connector.hpp b/src/common/snippets/include/snippets/lowered/port_connector.hppindex 271778f5202..7321560f789 100644--- a/src/common/snippets/include/snippets/lowered/port_connector.hpp+++ b/src/common/snippets/include/snippets/lowered/port_connector.hpp@@ -5,14 +5,11 @@#pragma once#include <memory>-#include <vector>+#include <set>#include "expression_port.hpp"-#include "port_descriptor.hpp"-namespace ov {-namespace snippets {-namespace lowered {+namespace ov::snippets::lowered {class Expression;@@ -21,17 +18,17 @@ public:PortConnector() = default;explicit PortConnector(ExpressionPort source_descriptor, const std::set<ExpressionPort>& consumer_descriptors = {});- const ExpressionPort& get_source() const {+ [[nodiscard]] const ExpressionPort& get_source() const {return m_source_port;}- std::set<ExpressionPort> get_consumers() const {+ [[nodiscard]] std::set<ExpressionPort> get_consumers() const {return m_consumer_ports;}void add_consumer(const ExpressionPort& consumer);void remove_consumer(const ExpressionPort& consumer);- bool found_consumer(const ExpressionPort& consumer) const;- std::set<ExpressionPort>::const_iterator find_consumer(const ExpressionPort& consumer) const;+ [[nodiscard]] bool found_consumer(const ExpressionPort& consumer) const;+ [[nodiscard]] std::set<ExpressionPort>::const_iterator find_consumer(const ExpressionPort& consumer) const;std::set<ExpressionPort>::iterator find_consumer(const ExpressionPort& consumer);private:@@ -40,6 +37,4 @@ private:};using PortConnectorPtr = std::shared_ptr<PortConnector>;-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/include/snippets/lowered/port_descriptor.hpp b/src/common/snippets/include/snippets/lowered/port_descriptor.hppindex 1b55c5212d9..3f509113d53 100644--- a/src/common/snippets/include/snippets/lowered/port_descriptor.hpp+++ b/src/common/snippets/include/snippets/lowered/port_descriptor.hpp@@ -4,14 +4,20 @@#pragma once+#include <cstddef>+#include <memory>+#include <string>+#include <utility>+#include <vector>+#include "openvino/core/attribute_visitor.hpp"-#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/rtti.hpp"+#include "openvino/core/runtime_attribute.hpp"#include "snippets/emitter.hpp"#include "snippets/shape_types.hpp"-namespace ov {-namespace snippets {-namespace lowered {+namespace ov::snippets::lowered {class LinearIRBuilder;class PortDescriptor;@@ -20,30 +26,31 @@ class PortDescriptor {friend class LinearIRBuilder;public:- explicit PortDescriptor(const ov::Input<ov::Node>& node,+ explicit PortDescriptor(const ov::Input<ov::Node>& in,VectorDims subtensor_shape = {},std::vector<size_t> layout = {});- explicit PortDescriptor(const ov::Input<const ov::Node>& node,+ explicit PortDescriptor(const ov::Input<const ov::Node>& in,VectorDims subtensor_shape = {},std::vector<size_t> layout = {});- explicit PortDescriptor(const ov::Output<ov::Node>& node,+ explicit PortDescriptor(const ov::Output<ov::Node>& out,VectorDims subtensor_shape = {},std::vector<size_t> layout = {});- explicit PortDescriptor(const ov::Output<const ov::Node>& node,+ explicit PortDescriptor(const ov::Output<const ov::Node>& out,VectorDims subtensor_shape = {},std::vector<size_t> layout = {});PortDescriptor(VectorDims shape, VectorDims subtensor_shape, std::vector<size_t> layout = {}, Reg reg = {});PortDescriptor(VectorDimsPtr shape, VectorDims subtensor_shape, std::vector<size_t> layout = {}, Reg reg = {});PortDescriptor();- const VectorDims& get_shape() const;- const VectorDims& get_subtensor() const {+ [[nodiscard]] const VectorDims& get_shape() const;++ [[nodiscard]] const VectorDims& get_subtensor() const {return m_subtensor_shape;}- const std::vector<size_t>& get_layout() const {+ [[nodiscard]] const std::vector<size_t>& get_layout() const {return m_layout;}- const Reg& get_reg() const {+ [[nodiscard]] const Reg& get_reg() const {return m_reg;}@@ -56,11 +63,11 @@ public:// Indexing starts from the end (rbegin() + idx)void set_subtensor_dim(size_t idx, VectorDims::value_type value);- std::string serialize() const;- bool empty() const {+ [[nodiscard]] std::string serialize() const;+ [[nodiscard]] bool empty() const {return m_layout.empty() && m_subtensor_shape.empty();}- PortDescriptorPtr clone() const;+ [[nodiscard]] PortDescriptorPtr clone() const;friend bool operator==(const PortDescriptor& lhs, const PortDescriptor& rhs);friend bool operator!=(const PortDescriptor& lhs, const PortDescriptor& rhs) {@@ -72,9 +79,9 @@ private:/// \brief Original tensor shapeVectorDimsPtr m_tensor_shape = nullptr;/// \brief Order of dimensions: NCHW == {0, 1, 2, 3}, NHWC == {0, 2, 3, 1}, NCHW16c == {0, 1, 2, 3, 1}- std::vector<size_t> m_layout{};+ std::vector<size_t> m_layout;/// \brief Minimal tensor size that could be processed in one call- VectorDims m_subtensor_shape{};+ VectorDims m_subtensor_shape;/// \brief The corresponding abstract/physical registerReg m_reg{RegType::gpr, 0};@@ -131,14 +138,12 @@ public:: inputs(std::move(in_descs)),outputs(std::move(out_descs)) {}- bool is_copyable() const override {+ [[nodiscard]] bool is_copyable() const override {return false;}- std::vector<PortDescriptorPtr> inputs{};- std::vector<PortDescriptorPtr> outputs{};+ std::vector<PortDescriptorPtr> inputs;+ std::vector<PortDescriptorPtr> outputs;};-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/include/snippets/lowered/reg_manager.hpp b/src/common/snippets/include/snippets/lowered/reg_manager.hppindex f439f0ba56e..972f895ac21 100644--- a/src/common/snippets/include/snippets/lowered/reg_manager.hpp+++ b/src/common/snippets/include/snippets/lowered/reg_manager.hpp@@ -3,9 +3,18 @@//#pragma once-#include <type_traits>+#include <algorithm>+#include <cassert>+#include <cstdint>+#include <map>+#include <memory>+#include <set>+#include <utility>+#include <vector>+#include "openvino/core/except.hpp"#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"#include "snippets/emitter.hpp"#include "snippets/generator.hpp"#include "snippets/lowered/expression.hpp"@@ -16,9 +25,8 @@* @brief The class holds supplementary info about assigned registers and live ranges* @ingroup snippets*/-namespace ov {-namespace snippets {-namespace lowered {++namespace ov::snippets::lowered {// LiveInterval is a pair of (start, stop) expression execution numbers, where:// start - exec number of the expression that produced the value@@ -28,29 +36,31 @@ class RegManager {public:RegManager() = delete;RegManager(const std::shared_ptr<const Generator>& generator) : m_generator(generator) {}- inline RegType get_reg_type(const ov::Output<Node>& out) const {+ [[nodiscard]] RegType get_reg_type(const ov::Output<Node>& out) const {return m_generator->get_op_out_reg_type(out);}- inline std::vector<Reg> get_vec_reg_pool() const {+ [[nodiscard]] std::vector<Reg> get_vec_reg_pool() const {return m_generator->get_target_machine()->get_vec_reg_pool();}- inline void set_live_range(const Reg& reg, const LiveInterval& interval) {+ void set_live_range(const Reg& reg, const LiveInterval& interval) {OPENVINO_ASSERT(m_reg_live_range.insert({reg, interval}).second, "Live range for this reg is already set");}- inline std::vector<Reg> get_kernel_call_regs(const std::shared_ptr<snippets::op::Kernel>& kernel) const {+ [[nodiscard]] std::vector<Reg> get_kernel_call_regs(const std::shared_ptr<snippets::op::Kernel>& kernel) const {const auto& abi_regs = m_generator->get_target_machine()->get_abi_arg_regs();const auto num_kernel_args = kernel->get_num_call_args();assert(abi_regs.size() > num_kernel_args && "Too many kernel args requested");return {abi_regs.begin(), abi_regs.begin() + static_cast<int64_t>(num_kernel_args)};}- inline std::vector<Reg> get_gp_regs_except_kernel_call(const std::shared_ptr<snippets::op::Kernel>& kernel) const {+ [[nodiscard]] std::vector<Reg> get_gp_regs_except_kernel_call(+ const std::shared_ptr<snippets::op::Kernel>& kernel) const {auto res = m_generator->get_target_machine()->get_gp_reg_pool();std::set<Reg> kernel_call;- for (auto r : get_kernel_call_regs(kernel))+ for (auto r : get_kernel_call_regs(kernel)) {kernel_call.insert(r);+ }res.erase(std::remove_if(res.begin(),res.end(),[&kernel_call](const Reg& r) {@@ -60,11 +70,11 @@ public:return res;}- inline const LiveInterval& get_live_range(const Reg& reg) const {+ [[nodiscard]] const LiveInterval& get_live_range(const Reg& reg) const {assert(m_reg_live_range.count(reg) && "Live range for this reg was not set");return m_reg_live_range.at(reg);}- inline const std::map<Reg, LiveInterval>& get_live_range_map() const {+ [[nodiscard]] const std::map<Reg, LiveInterval>& get_live_range_map() const {return m_reg_live_range;}@@ -74,6 +84,4 @@ private:const std::shared_ptr<const Generator> m_generator;};-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/include/snippets/lowered/specific_loop_iter_handlers.hpp b/src/common/snippets/include/snippets/lowered/specific_loop_iter_handlers.hppindex cd77e105a7b..0a7092b6898 100644--- a/src/common/snippets/include/snippets/lowered/specific_loop_iter_handlers.hpp+++ b/src/common/snippets/include/snippets/lowered/specific_loop_iter_handlers.hpp@@ -4,12 +4,13 @@#pragma once+#include <cstddef>+#include <type_traits>+#include "snippets/lowered/pass/pass.hpp"#include "snippets/lowered/specific_loop_iter_types.hpp"-namespace ov {-namespace snippets {-namespace lowered {+namespace ov::snippets::lowered {class SpecificIterationHandlers {public:@@ -19,46 +20,43 @@ public:pass::PassPipeline main_body_handlers,pass::PassPipeline last_iter_handlers);- template <SpecificLoopIterType Type,- typename std::enable_if<Type == SpecificLoopIterType::FIRST_ITER, bool>::type = true>- const pass::PassPipeline& get_passes() const {+ template <SpecificLoopIterType Type, std::enable_if_t<Type == SpecificLoopIterType::FIRST_ITER, bool> = true>+ [[nodiscard]] const pass::PassPipeline& get_passes() const {return m_first_iter_handlers;}- template <SpecificLoopIterType Type,- typename std::enable_if<Type == SpecificLoopIterType::MAIN_BODY, bool>::type = true>- const pass::PassPipeline& get_passes() const {+ template <SpecificLoopIterType Type, std::enable_if_t<Type == SpecificLoopIterType::MAIN_BODY, bool> = true>+ [[nodiscard]] const pass::PassPipeline& get_passes() const {return m_main_body_handlers;}- template <SpecificLoopIterType Type,- typename std::enable_if<Type == SpecificLoopIterType::LAST_ITER, bool>::type = true>- const pass::PassPipeline& get_passes() const {+ template <SpecificLoopIterType Type, std::enable_if_t<Type == SpecificLoopIterType::LAST_ITER, bool> = true>+ [[nodiscard]] const pass::PassPipeline& get_passes() const {return m_last_iter_handlers;}template <SpecificLoopIterType Type,typename T,class... Args,- typename std::enable_if<Type == SpecificLoopIterType::FIRST_ITER, bool>::type = true>+ std::enable_if_t<Type == SpecificLoopIterType::FIRST_ITER, bool> = true>void register_pass(Args&&... args) {- m_first_iter_handlers.register_pass<T>(args...);+ m_first_iter_handlers.register_pass<T>(std::forward<Args>(args)...);}template <SpecificLoopIterType Type,typename T,class... Args,- typename std::enable_if<Type == SpecificLoopIterType::MAIN_BODY, bool>::type = true>+ std::enable_if_t<Type == SpecificLoopIterType::MAIN_BODY, bool> = true>void register_pass(Args&&... args) {- m_main_body_handlers.register_pass<T>(args...);+ m_main_body_handlers.register_pass<T>(std::forward<Args>(args)...);}template <SpecificLoopIterType Type,typename T,class... Args,- typename std::enable_if<Type == SpecificLoopIterType::LAST_ITER, bool>::type = true>+ std::enable_if_t<Type == SpecificLoopIterType::LAST_ITER, bool> = true>void register_pass(Args&&... args) {- m_last_iter_handlers.register_pass<T>(args...);+ m_last_iter_handlers.register_pass<T>(std::forward<Args>(args)...);}static SpecificIterationHandlers merge_handlers(const SpecificIterationHandlers& lhs,@@ -70,6 +68,4 @@ private:pass::PassPipeline m_last_iter_handlers;};-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/include/snippets/lowered/specific_loop_iter_types.hpp b/src/common/snippets/include/snippets/lowered/specific_loop_iter_types.hppindex 10408ba0499..d1c98eebf3c 100644--- a/src/common/snippets/include/snippets/lowered/specific_loop_iter_types.hpp+++ b/src/common/snippets/include/snippets/lowered/specific_loop_iter_types.hpp@@ -4,11 +4,14 @@#pragma once-namespace ov {-namespace snippets {-namespace lowered {+#include <cstdint>+#include <iostream>-enum class SpecificLoopIterType { FIRST_ITER, MAIN_BODY, LAST_ITER };+#include "openvino/core/except.hpp"++namespace ov::snippets::lowered {++enum class SpecificLoopIterType : uint8_t { FIRST_ITER, MAIN_BODY, LAST_ITER };inline std::ostream& operator<<(std::ostream& out, const SpecificLoopIterType& type) {switch (type) {@@ -27,6 +30,4 @@ inline std::ostream& operator<<(std::ostream& out, const SpecificLoopIterType& treturn out;}-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/include/snippets/op/brgemm.hpp b/src/common/snippets/include/snippets/op/brgemm.hppindex aad1eeb4189..dfd583e4c60 100644--- a/src/common/snippets/include/snippets/op/brgemm.hpp+++ b/src/common/snippets/include/snippets/op/brgemm.hpp@@ -8,9 +8,7 @@#include "openvino/op/op.hpp"#include "snippets/shape_inference/shape_inference.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface Brgemm@@ -22,20 +20,20 @@ public:OPENVINO_OP("Brgemm", "SnippetsOpset");Brgemm(const Output<Node>& A,const Output<Node>& B,- const size_t offset_a = 0lu,- const size_t offset_b = 0lu,- const size_t offset_c = 0lu,- std::vector<size_t> layout_a = {},- std::vector<size_t> layout_b = {},- std::vector<size_t> layout_c = {});+ size_t offset_a = 0lu,+ size_t offset_b = 0lu,+ size_t offset_c = 0lu,+ const std::vector<size_t>& layout_a = {},+ const std::vector<size_t>& layout_b = {},+ const std::vector<size_t>& layout_c = {});Brgemm(const Output<Node>& A,const Output<Node>& B,const PortDescriptor& desc_a,const PortDescriptor& desc_b,const PortDescriptor& desc_c,- std::vector<size_t> layout_a = {},- std::vector<size_t> layout_b = {},- std::vector<size_t> layout_c = {});+ const std::vector<size_t>& layout_a = {},+ const std::vector<size_t>& layout_b = {},+ const std::vector<size_t>& layout_c = {});Brgemm() = default;size_t get_offset_a() const {@@ -60,16 +58,14 @@ public:protected:virtual ov::element::Type get_output_type() const;- std::vector<ov::PartialShape> get_planar_input_shapes(const std::vector<ov::Input<ov::Node>>& inputs) const;- ov::PartialShape infer_output_partial_shape(const std::vector<ov::PartialShape>& input_shapes) const;+ static std::vector<ov::PartialShape> get_planar_input_shapes(const std::vector<ov::Input<ov::Node>>& inputs);+ static ov::PartialShape infer_output_partial_shape(const std::vector<ov::PartialShape>& input_shapes);ov::PartialShape get_planar_output_shape(const ov::PartialShape& output_shape) const;private:- void custom_constructor_validate_and_infer_types(std::vector<size_t> layout_a,- std::vector<size_t> layout_b,- std::vector<size_t> layout_c);+ void custom_constructor_validate_and_infer_types(const std::vector<size_t>& layout_a,+ const std::vector<size_t>& layout_b,+ const std::vector<size_t>& layout_c);};-} // namespace op-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/broadcastload.hpp b/src/common/snippets/include/snippets/op/broadcastload.hppindex 3f09d15da16..7ed8e2ccf4a 100644--- a/src/common/snippets/include/snippets/op/broadcastload.hpp+++ b/src/common/snippets/include/snippets/op/broadcastload.hpp@@ -4,14 +4,20 @@#pragma once+#include <cstddef>+#include <memory>#include <snippets/op/memory_access.hpp>+#include <utility>+#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/dimension.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"#include "openvino/op/op.hpp"#include "snippets/shape_inference/shape_infer_instances.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface BroadcastLoad@@ -36,8 +42,8 @@ public:const ov::Dimension& get_bcast_dimension() {return bcast_dimension;}- void set_bcast_dimension(ov::Dimension new_dim) {- bcast_dimension = std::move(new_dim);+ void set_bcast_dimension(const ov::Dimension& new_dim) {+ bcast_dimension = new_dim;}// Note:BroadcastMove and BroadcastLoad are implemented as separate classes,@@ -52,6 +58,4 @@ private:ov::Dimension bcast_dimension;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/broadcastmove.hpp b/src/common/snippets/include/snippets/op/broadcastmove.hppindex da6049f99f5..473b8d7cb43 100644--- a/src/common/snippets/include/snippets/op/broadcastmove.hpp+++ b/src/common/snippets/include/snippets/op/broadcastmove.hpp@@ -4,12 +4,18 @@#pragma once+#include <memory>+#include <utility>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/dimension.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"#include "openvino/op/op.hpp"#include "snippets/shape_inference/shape_infer_instances.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface BroadcastMove@@ -31,8 +37,8 @@ public:const ov::Dimension& get_bcast_dimension() {return bcast_dimension;}- void set_bcast_dimension(ov::Dimension new_dim) {- bcast_dimension = std::move(new_dim);+ void set_bcast_dimension(const ov::Dimension& new_dim) {+ bcast_dimension = new_dim;}// Note:BroadcastMove and BroadcastLoad are implemented as separate classes,// but have identical shapeInfer semantics. In order to avoid code duplication,@@ -46,6 +52,4 @@ protected:ov::Dimension bcast_dimension;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/buffer.hpp b/src/common/snippets/include/snippets/op/buffer.hppindex db5b1dea0b8..b227d7bcccd 100644--- a/src/common/snippets/include/snippets/op/buffer.hpp+++ b/src/common/snippets/include/snippets/op/buffer.hpp@@ -4,13 +4,22 @@#pragma once+#include <cstddef>+#include <memory>+#include <vector>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/core/type/element_type.hpp"#include "openvino/op/op.hpp"#include "snippets/shape_inference/shape_inference.hpp"+#include "snippets/shape_types.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface Buffer@@ -55,11 +64,11 @@ private:public:BaseImpl() = default;virtual ~BaseImpl() = default;- virtual size_t get_allocation_size() const = 0;- virtual std::shared_ptr<BaseImpl> clone() const = 0;+ [[nodiscard]] virtual size_t get_allocation_size() const = 0;+ [[nodiscard]] virtual std::shared_ptr<BaseImpl> clone() const = 0;virtual void validate_and_infer_types(Buffer* buffer) const = 0;virtual bool visit_attributes(AttributeVisitor& visitor) = 0;- virtual std::shared_ptr<IShapeInferSnippets> get_shape_infer() const = 0;+ [[nodiscard]] virtual std::shared_ptr<IShapeInferSnippets> get_shape_infer() const = 0;};// IntermediateMemoryImpl represents intermediate memory.@@ -68,15 +77,15 @@ private:public:IntermediateMemoryImpl() = default;- size_t get_allocation_size() const override {+ [[nodiscard]] size_t get_allocation_size() const override {return utils::get_dynamic_value<size_t>();}- std::shared_ptr<BaseImpl> clone() const override;+ [[nodiscard]] std::shared_ptr<BaseImpl> clone() const override;void validate_and_infer_types(Buffer* buffer) const override;- bool visit_attributes(AttributeVisitor& visitor) override {+ bool visit_attributes([[maybe_unused]] AttributeVisitor& visitor) override {return true;}- std::shared_ptr<IShapeInferSnippets> get_shape_infer() const override {+ [[nodiscard]] std::shared_ptr<IShapeInferSnippets> get_shape_infer() const override {return std::make_shared<ShapeInfer>();}@@ -93,11 +102,11 @@ private:public:NewMemoryImpl(const ov::Shape& shape, ov::element::Type element_type);- size_t get_allocation_size() const override;- std::shared_ptr<BaseImpl> clone() const override;+ [[nodiscard]] size_t get_allocation_size() const override;+ [[nodiscard]] std::shared_ptr<BaseImpl> clone() const override;void validate_and_infer_types(Buffer* buffer) const override;bool visit_attributes(AttributeVisitor& visitor) override;- std::shared_ptr<IShapeInferSnippets> get_shape_infer() const override {+ [[nodiscard]] std::shared_ptr<IShapeInferSnippets> get_shape_infer() const override {return std::make_shared<ShapeInfer>(m_shape);}@@ -106,7 +115,7 @@ private:ov::Shape m_shape;public:- explicit ShapeInfer(ov::Shape shape);+ explicit ShapeInfer(const ov::Shape& shape);Result infer(const std::vector<VectorDimsRef>& input_shapes) override;};@@ -120,6 +129,4 @@ private:const std::shared_ptr<BaseImpl> m_impl{nullptr};};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/convert_saturation.hpp b/src/common/snippets/include/snippets/op/convert_saturation.hppindex 52f746b0e23..db2465dd31a 100644--- a/src/common/snippets/include/snippets/op/convert_saturation.hpp+++ b/src/common/snippets/include/snippets/op/convert_saturation.hpp@@ -4,13 +4,16 @@#pragma once+#include <memory>#include <openvino/op/convert.hpp>+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/type/element_type.hpp"#include "openvino/op/op.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface ConvertSaturation@@ -36,6 +39,4 @@ public:}};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/convert_truncation.hpp b/src/common/snippets/include/snippets/op/convert_truncation.hppindex 1cffa09b2c3..8e6c0551bc2 100644--- a/src/common/snippets/include/snippets/op/convert_truncation.hpp+++ b/src/common/snippets/include/snippets/op/convert_truncation.hpp@@ -4,13 +4,16 @@#pragma once+#include <memory>#include <openvino/op/convert.hpp>+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/type/element_type.hpp"#include "openvino/op/op.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface ConvertTruncation@@ -35,6 +38,4 @@ public:}};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/fill.hpp b/src/common/snippets/include/snippets/op/fill.hppindex 82feb9f2c84..19cc52ad1df 100644--- a/src/common/snippets/include/snippets/op/fill.hpp+++ b/src/common/snippets/include/snippets/op/fill.hpp@@ -4,11 +4,17 @@#pragma once+#include <cstddef>+#include <cstdint>+#include <memory>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"#include "openvino/op/op.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface Fill@@ -24,7 +30,7 @@ class Fill : public ov::op::Op {public:OPENVINO_OP("Fill", "SnippetsOpset");- Fill(const Output<Node>& x, const size_t offset, const uint32_t fill_value = 0x0);+ Fill(const Output<Node>& x, size_t offset, uint32_t fill_value = 0x0);Fill() = default;size_t get_offset() const {@@ -50,6 +56,4 @@ protected:uint32_t m_fill_value = 0x0;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/horizon_max.hpp b/src/common/snippets/include/snippets/op/horizon_max.hppindex 5709e5bd6b2..acc08cac680 100644--- a/src/common/snippets/include/snippets/op/horizon_max.hpp+++ b/src/common/snippets/include/snippets/op/horizon_max.hpp@@ -4,11 +4,15 @@#pragma once+#include <memory>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"#include "openvino/op/op.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface HorizonMax@@ -22,13 +26,8 @@ public:HorizonMax(const Output<Node>& x);HorizonMax() = default;- bool visit_attributes(AttributeVisitor& visitor) override {- return true;- }std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;void validate_and_infer_types() override;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/horizon_sum.hpp b/src/common/snippets/include/snippets/op/horizon_sum.hppindex d2d836bb284..6269f72031e 100644--- a/src/common/snippets/include/snippets/op/horizon_sum.hpp+++ b/src/common/snippets/include/snippets/op/horizon_sum.hpp@@ -4,11 +4,15 @@#pragma once+#include <memory>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"#include "openvino/op/op.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface HorizonSum@@ -22,13 +26,8 @@ public:HorizonSum(const Output<Node>& x);HorizonSum() = default;- bool visit_attributes(AttributeVisitor& visitor) override {- return true;- }std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;void validate_and_infer_types() override;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/kernel.hpp b/src/common/snippets/include/snippets/op/kernel.hppindex 48f32fb8c26..258bae6bd23 100644--- a/src/common/snippets/include/snippets/op/kernel.hpp+++ b/src/common/snippets/include/snippets/op/kernel.hpp@@ -4,12 +4,15 @@#pragma once+#include <cstddef>+#include <memory>++#include "openvino/core/node.hpp"+#include "openvino/core/node_vector.hpp"#include "openvino/op/op.hpp"#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface Kernel@@ -26,7 +29,7 @@ public:static std::shared_ptr<Kernel> make_kernel(bool is_dynamic, ArgTypes&&... args);virtual size_t get_num_call_args() const = 0;- std::shared_ptr<lowered::LinearIR> region;+ std::shared_ptr<lowered::LinearIR> region = nullptr;const void* compile_params = nullptr;};@@ -56,11 +59,8 @@ template <typename... ArgTypes>std::shared_ptr<Kernel> Kernel::make_kernel(bool is_dynamic, ArgTypes&&... args) {if (is_dynamic) {return std::make_shared<KernelDynamic>(std::forward<ArgTypes>(args)...);- } else {- return std::make_shared<KernelStatic>(std::forward<ArgTypes>(args)...);}+ return std::make_shared<KernelStatic>(std::forward<ArgTypes>(args)...);}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/load.hpp b/src/common/snippets/include/snippets/op/load.hppindex f7002566866..f87336900f7 100644--- a/src/common/snippets/include/snippets/op/load.hpp+++ b/src/common/snippets/include/snippets/op/load.hpp@@ -4,13 +4,20 @@#pragma once+#include <cstddef>+#include <memory>+#include <vector>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"#include "openvino/op/op.hpp"#include "snippets/op/memory_access.hpp"#include "snippets/shape_inference/shape_inference.hpp"+#include "snippets/shape_types.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface Load@@ -24,7 +31,7 @@ class Load : public modifier::MemoryAccess, public ov::op::Op {public:OPENVINO_OP("Load", "SnippetsOpset");- Load(const Output<Node>& x, const size_t count = 1lu, const size_t offset = 0lu);+ Load(const Output<Node>& x, size_t count = 1lu, size_t offset = 0lu);Load() = default;size_t get_offset() const {@@ -59,7 +66,7 @@ protected:class LoadReorder : public Load {public:OPENVINO_OP("LoadReorder", "SnippetsOpset", Load);- LoadReorder(const Output<Node>& x, size_t count = 1lu, const size_t offset = 0lu, std::vector<size_t> order = {});+ LoadReorder(const Output<Node>& x, size_t count = 1lu, size_t offset = 0lu, std::vector<size_t> order = {});LoadReorder() = default;void set_offset(size_t offset) {@@ -84,6 +91,4 @@ public:protected:std::vector<size_t> m_order;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/loop.hpp b/src/common/snippets/include/snippets/op/loop.hppindex 78c8430e13a..3bb62f2da8f 100644--- a/src/common/snippets/include/snippets/op/loop.hpp+++ b/src/common/snippets/include/snippets/op/loop.hpp@@ -4,12 +4,18 @@#pragma once+#include <cstddef>+#include <cstdint>+#include <memory>+#include <vector>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"#include "openvino/op/op.hpp"-#include "snippets/emitter.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface LoopBase@@ -105,10 +111,10 @@ public:void set_id(size_t id);protected:- std::vector<bool> m_is_incremented = {};- std::vector<int64_t> m_ptr_increments = {};- std::vector<int64_t> m_finalization_offsets = {};- std::vector<int64_t> m_element_type_sizes = {};+ std::vector<bool> m_is_incremented;+ std::vector<int64_t> m_ptr_increments;+ std::vector<int64_t> m_finalization_offsets;+ std::vector<int64_t> m_element_type_sizes;size_t m_work_amount = 0;size_t m_work_amount_increment = 0;size_t m_input_num = 0;@@ -119,6 +125,4 @@ protected:bool m_evaluate_once = false;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/memory_access.hpp b/src/common/snippets/include/snippets/op/memory_access.hppindex 6425a910d0d..1ad30c98fd5 100644--- a/src/common/snippets/include/snippets/op/memory_access.hpp+++ b/src/common/snippets/include/snippets/op/memory_access.hpp@@ -4,11 +4,15 @@#pragma once-#include "openvino/op/op.hpp"+#include <cstddef>+#include <map>+#include <memory>+#include <set>-namespace ov {-namespace snippets {-namespace modifier {+#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/node.hpp"++namespace ov::snippets::modifier {/*** @interface MemoryAccess@@ -57,51 +61,49 @@ public:void set_input_stride(size_t stride, size_t idx = 0);void set_output_stride(size_t stride, size_t idx = 0);- size_t get_input_count(size_t idx = 0) const;- size_t get_output_count(size_t idx = 0) const;- size_t get_input_offset(size_t idx = 0) const;- size_t get_output_offset(size_t idx = 0) const;- size_t get_input_stride(size_t idx = 0) const;- size_t get_output_stride(size_t idx = 0) const;+ [[nodiscard]] size_t get_input_count(size_t idx = 0) const;+ [[nodiscard]] size_t get_output_count(size_t idx = 0) const;+ [[nodiscard]] size_t get_input_offset(size_t idx = 0) const;+ [[nodiscard]] size_t get_output_offset(size_t idx = 0) const;+ [[nodiscard]] size_t get_input_stride(size_t idx = 0) const;+ [[nodiscard]] size_t get_output_stride(size_t idx = 0) const;- PortMap get_memory_access_input_ports() const {+ [[nodiscard]] PortMap get_memory_access_input_ports() const {return m_input_ports;}- PortMap get_memory_access_output_ports() const {+ [[nodiscard]] PortMap get_memory_access_output_ports() const {return m_output_ports;}- bool is_memory_access_input_port(size_t idx) const;- bool is_memory_access_output_port(size_t idx) const;+ [[nodiscard]] bool is_memory_access_input_port(size_t idx) const;+ [[nodiscard]] bool is_memory_access_output_port(size_t idx) const;/*** @brief Checks if the provided operation memory access on all ports*/- bool is_full_memory_access_op(const std::shared_ptr<ov::Node>& op) const;+ [[nodiscard]] bool is_full_memory_access_op(const std::shared_ptr<ov::Node>& op) const;bool visit_attributes(AttributeVisitor& visitor);protected:explicit MemoryAccess(size_t input_count, size_t output_count = 0);explicit MemoryAccess(const std::set<size_t>& input_ports, const std::set<size_t>& output_ports);- explicit MemoryAccess(const PortMap& input_ports, const PortMap& output_ports);+ explicit MemoryAccess(PortMap input_ports, PortMap output_ports);MemoryAccess() = default;// This method can be called only in ctorsvoid ctor_initialize(const std::set<size_t>& input_ports, const std::set<size_t>& output_ports);- void set_input_port_descriptor(const PortDescriptor& desc, const size_t i);- void set_output_port_descriptor(const PortDescriptor& desc, const size_t i);- const PortDescriptor& get_input_port_descriptor(const size_t i) const;- const PortDescriptor& get_output_port_descriptor(const size_t i) const;- PortDescriptor& get_input_port_descriptor(const size_t i);- PortDescriptor& get_output_port_descriptor(const size_t i);+ void set_input_port_descriptor(const PortDescriptor& desc, size_t i);+ void set_output_port_descriptor(const PortDescriptor& desc, size_t i);+ [[nodiscard]] const PortDescriptor& get_input_port_descriptor(size_t i) const;+ [[nodiscard]] const PortDescriptor& get_output_port_descriptor(size_t i) const;+ PortDescriptor& get_input_port_descriptor(size_t i);+ PortDescriptor& get_output_port_descriptor(size_t i);// [port_num, port_desc]PortMap m_input_ports;PortMap m_output_ports;};-} // namespace modifier-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::modifierdiff --git a/src/common/snippets/include/snippets/op/nop.hpp b/src/common/snippets/include/snippets/op/nop.hppindex ade30b095ca..fff0a95aba3 100644--- a/src/common/snippets/include/snippets/op/nop.hpp+++ b/src/common/snippets/include/snippets/op/nop.hpp@@ -4,11 +4,13 @@#pragma once+#include <memory>++#include "openvino/core/node.hpp"+#include "openvino/core/node_vector.hpp"#include "openvino/op/op.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface Nop@@ -22,11 +24,9 @@ public:Nop(const OutputVector& arguments, const OutputVector& results);Nop() = default;- std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& inputs) const override {+ std::shared_ptr<Node> clone_with_new_inputs([[maybe_unused]] const OutputVector& inputs) const override {return std::make_shared<Nop>();}};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/perf_count.hpp b/src/common/snippets/include/snippets/op/perf_count.hppindex eab81cf6704..f41fa3742f7 100644--- a/src/common/snippets/include/snippets/op/perf_count.hpp+++ b/src/common/snippets/include/snippets/op/perf_count.hpp@@ -2,6 +2,15 @@// SPDX-License-Identifier: Apache-2.0//+#include <cstdint>+#include <map>+#include <memory>+#include <string>+#include <vector>++#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"#ifdef SNIPPETS_DEBUG_CAPS# pragma once@@ -11,8 +20,7 @@# include "openvino/op/op.hpp"# include "openvino/runtime/threading/thread_local.hpp"-namespace ov {-namespace snippets {+namespace ov::snippets {namespace op {class PerfCountEnd;@@ -51,8 +59,8 @@ public:void update(const op::PerfCountEnd* node) override;private:- ov::threading::ThreadLocal<uint64_t> m_accumulation;- ov::threading::ThreadLocal<uint32_t> m_iteration;+ ov::threading::ThreadLocal<uint64_t> m_accumulation = 0;+ ov::threading::ThreadLocal<uint32_t> m_iteration = 0;};/**@@ -62,7 +70,7 @@ private:*/class CSVDumper : public Dumper {public:- CSVDumper(const std::string csv_path);+ CSVDumper(std::string csv_path);~CSVDumper() override;void update(const op::PerfCountEnd* node) override;@@ -87,7 +95,6 @@ public:PerfCountBeginBase() = default;void validate_and_infer_types() override;- bool visit_attributes(AttributeVisitor& visitor) override;protected:void validate_and_infer_types_except_PerfCountEnd();@@ -105,7 +112,6 @@ public:PerfCountEndBase() = default;void validate_and_infer_types() override;- bool visit_attributes(AttributeVisitor& visitor) override;};/**@@ -138,8 +144,8 @@ public:PerfCountEnd(const Output<Node>& pc_begin,std::vector<std::shared_ptr<utils::Dumper>> dumpers = {},const std::string& params = "");- PerfCountEnd();- ~PerfCountEnd();+ PerfCountEnd() = default;+ ~PerfCountEnd() override;std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& inputs) const override;@@ -163,6 +169,6 @@ private:};} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets+#endif // SNIPPETS_DEBUG_CAPSdiff --git a/src/common/snippets/include/snippets/op/powerstatic.hpp b/src/common/snippets/include/snippets/op/powerstatic.hppindex 26d93c19d80..8ea3e9f5c40 100644--- a/src/common/snippets/include/snippets/op/powerstatic.hpp+++ b/src/common/snippets/include/snippets/op/powerstatic.hpp@@ -4,13 +4,16 @@#pragma once-#include <snippets/snippets_isa.hpp>+#include <memory>+#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"#include "openvino/op/op.hpp"+#include "openvino/op/util/unary_elementwise_arithmetic.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface PowerStatic@@ -41,6 +44,4 @@ public:private:float power = 0;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/rank_normalization.hpp b/src/common/snippets/include/snippets/op/rank_normalization.hppindex b978d9ec4f8..8c5b74a6c49 100644--- a/src/common/snippets/include/snippets/op/rank_normalization.hpp+++ b/src/common/snippets/include/snippets/op/rank_normalization.hpp@@ -4,12 +4,20 @@#pragma once+#include <cstddef>+#include <memory>+#include <vector>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/op/op.hpp"#include "shape_infer_op.hpp"#include "snippets/shape_inference/shape_inference.hpp"+#include "snippets/shape_types.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface RankNormalization@@ -55,6 +63,4 @@ private:size_t m_num_append = 0;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/reduce.hpp b/src/common/snippets/include/snippets/op/reduce.hppindex 03c9cd52128..f8b365f266a 100644--- a/src/common/snippets/include/snippets/op/reduce.hpp+++ b/src/common/snippets/include/snippets/op/reduce.hpp@@ -4,12 +4,16 @@#pragma once+#include <cstddef>+#include <memory>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"#include "openvino/op/op.hpp"-#include "snippets/shape_inference/shape_infer_instances.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface ReduceBase@@ -51,6 +55,4 @@ public:std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/reg_spill.hpp b/src/common/snippets/include/snippets/op/reg_spill.hppindex 0244a46cbd8..b1ce0ae915a 100644--- a/src/common/snippets/include/snippets/op/reg_spill.hpp+++ b/src/common/snippets/include/snippets/op/reg_spill.hpp@@ -5,14 +5,22 @@#pragma once#include <cassert>+#include <cstddef>+#include <memory>+#include <set>+#include <vector>+#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/type.hpp"#include "openvino/op/op.hpp"#include "snippets/emitter.hpp"#include "snippets/shape_inference/shape_inference.hpp"+#include "snippets/shape_types.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface RegSpillBase@@ -55,7 +63,7 @@ public:protected:void validate_and_infer_types_except_RegSpillEnd();- std::set<Reg> m_regs_to_spill = {};+ std::set<Reg> m_regs_to_spill;};/*** @interface RegSpillEnd@@ -81,6 +89,4 @@ public:}};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/reorder.hpp b/src/common/snippets/include/snippets/op/reorder.hppindex 559a40a9f79..3ce31e9686c 100644--- a/src/common/snippets/include/snippets/op/reorder.hpp+++ b/src/common/snippets/include/snippets/op/reorder.hpp@@ -4,12 +4,20 @@#pragma once+#include <cstddef>+#include <memory>+#include <vector>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/op/op.hpp"#include "shape_infer_op.hpp"#include "snippets/shape_inference/shape_inference.hpp"+#include "snippets/shape_types.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface Reorder* @brief Reorder reshapes input tensor shape by reqiured target order.@@ -21,14 +29,14 @@ class Reorder : public ShapeInferOp {public:OPENVINO_OP("Reorder", "SnippetsOpset", ShapeInferOp);Reorder() = default;- Reorder(const Output<Node>& x, std::vector<size_t> order);+ Reorder(const Output<Node>& arg, const std::vector<size_t>& order);bool visit_attributes(AttributeVisitor& visitor) override;std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;void validate_and_infer_types() override;class ShapeInfer : public IShapeInferSnippets {- std::vector<size_t> m_target_order{};+ std::vector<size_t> m_target_order;public:explicit ShapeInfer(const std::shared_ptr<Node>& n);@@ -36,9 +44,7 @@ public:};private:- void custom_constructor_validate_and_infer_types(std::vector<size_t> order);+ void custom_constructor_validate_and_infer_types(const std::vector<size_t>& order);};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/reshape.hpp b/src/common/snippets/include/snippets/op/reshape.hppindex 53e5c5252b4..ca3bf4a42de 100644--- a/src/common/snippets/include/snippets/op/reshape.hpp+++ b/src/common/snippets/include/snippets/op/reshape.hpp@@ -4,12 +4,21 @@#pragma once+#include <cstddef>+#include <memory>+#include <vector>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/partial_shape.hpp"+#include "openvino/op/op.hpp"#include "shape_infer_op.hpp"#include "snippets/shape_inference/shape_inference.hpp"+#include "snippets/shape_types.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface Reshape@@ -19,7 +28,7 @@ namespace op {class Reshape : public ShapeInferOp {public:OPENVINO_OP("Reshape", "SnippetsOpset", ShapeInferOp);- Reshape(const Output<Node>& x, ov::PartialShape target_shape);+ Reshape(const Output<Node>& arg, ov::PartialShape target_shape);Reshape() = default;bool visit_attributes(AttributeVisitor& visitor) override;@@ -39,9 +48,7 @@ public:};private:- ov::PartialShape m_target_shape = {};+ ov::PartialShape m_target_shape;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/scalar.hpp b/src/common/snippets/include/snippets/op/scalar.hppindex 3458d7bff57..efe1b75e007 100644--- a/src/common/snippets/include/snippets/op/scalar.hpp+++ b/src/common/snippets/include/snippets/op/scalar.hpp@@ -4,12 +4,19 @@#pragma once+#include <memory>+#include <type_traits>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/core/type/element_type.hpp"#include "openvino/op/constant.hpp"#include "openvino/op/op.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface Scalar@@ -22,7 +29,7 @@ public:Scalar() = default;- template <class T, class = typename std::enable_if<std::is_fundamental<T>::value>::type>+ template <class T, class = std::enable_if_t<std::is_fundamental_v<T>>>Scalar(const element::Type& type, Shape shape, T value) : Constant(type, shape, value) {constructor_validate_and_infer_types();}@@ -34,7 +41,7 @@ public:}Scalar& operator=(const Scalar&) = delete;- template <class T, class = typename std::enable_if<std::is_fundamental<T>::value>::type>+ template <class T, class = std::enable_if_t<std::is_fundamental_v<T>>>T get_value() const {const auto vec = cast_vector<T>();OPENVINO_ASSERT(vec.size() == 1, "Scalar must have a single value");@@ -50,6 +57,4 @@ public:}};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/serialization_node.hpp b/src/common/snippets/include/snippets/op/serialization_node.hppindex 2c36b591f09..0e6065aa6ca 100644--- a/src/common/snippets/include/snippets/op/serialization_node.hpp+++ b/src/common/snippets/include/snippets/op/serialization_node.hpp@@ -4,14 +4,16 @@#pragma once+#include <cstdint>+#include <memory>#include <snippets/lowered/expression.hpp>-#include <snippets/snippets_isa.hpp>+#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_vector.hpp"#include "openvino/op/op.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface SerializationNode@@ -22,7 +24,7 @@ class SerializationNode : public ov::op::Op {public:OPENVINO_OP("SerializationNode", "SnippetsOpset");- enum SerializationMode { DATA_FLOW, CONTROL_FLOW };+ enum SerializationMode : uint8_t { DATA_FLOW, CONTROL_FLOW };SerializationNode() = default;SerializationNode(const ov::OutputVector& args,const std::shared_ptr<lowered::Expression>& expr,@@ -34,9 +36,7 @@ public:private:std::shared_ptr<lowered::Expression> m_expr;- SerializationMode m_mode;+ SerializationMode m_mode = SerializationMode::CONTROL_FLOW;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/shape_infer_op.hpp b/src/common/snippets/include/snippets/op/shape_infer_op.hppindex 126bf69fbcf..c1dd51369ef 100644--- a/src/common/snippets/include/snippets/op/shape_infer_op.hpp+++ b/src/common/snippets/include/snippets/op/shape_infer_op.hpp@@ -4,11 +4,10 @@#pragma once+#include "openvino/core/node_vector.hpp"#include "openvino/op/op.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface ShapeInferOp@@ -22,6 +21,4 @@ public:ShapeInferOp(const OutputVector& args) : ov::op::Op(args) {}};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/store.hpp b/src/common/snippets/include/snippets/op/store.hppindex f446223ddc6..d9b208f5db3 100644--- a/src/common/snippets/include/snippets/op/store.hpp+++ b/src/common/snippets/include/snippets/op/store.hpp@@ -4,12 +4,17 @@#pragma once+#include <cstddef>+#include <memory>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"#include "openvino/op/op.hpp"#include "snippets/op/memory_access.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface Store@@ -23,7 +28,7 @@ class Store : public modifier::MemoryAccess, public ov::op::Op {public:OPENVINO_OP("Store", "SnippetsOpset");- Store(const Output<Node>& x, const size_t count = 1lu, const size_t offset = 0lu);+ Store(const Output<Node>& x, size_t count = 1lu, size_t offset = 0lu);Store() = default;size_t get_offset() const {@@ -45,6 +50,4 @@ public:bool visit_attributes(AttributeVisitor& visitor) override;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/subgraph.hpp b/src/common/snippets/include/snippets/op/subgraph.hppindex c81d1ff2eed..aa81f1da9d4 100644--- a/src/common/snippets/include/snippets/op/subgraph.hpp+++ b/src/common/snippets/include/snippets/op/subgraph.hpp@@ -4,22 +4,36 @@#pragma once+#include <cassert>+#include <cstddef>#include <memory>#include <openvino/core/model.hpp>#include <openvino/op/util/sub_graph_base.hpp>-+#include <string>+#include <utility>+#include <vector>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"#include "openvino/core/rt_info.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"#include "openvino/op/op.hpp"+#include "openvino/op/parameter.hpp"+#include "openvino/op/result.hpp"#include "snippets/generator.hpp"+#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/pass/pass.hpp"+#include "snippets/lowered/pass/pass_config.hpp"#include "snippets/pass/manager.hpp"-#include "snippets/pass/positioned_pass.hpp"#include "snippets/runtime_configurator.hpp"#include "snippets/shape_inference/shape_inference.hpp"+#include "snippets/shape_types.hpp"+#include "snippets/utils/debug_caps_config.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface Subgraph@@ -157,10 +171,11 @@ public:static auto is_domain_sensitive_op(const std::shared_ptr<ov::Node>& op) -> bool;static auto is_shape_infer_op(const std::shared_ptr<ov::Node>& op) -> bool;- void data_flow_transformations(const BlockedShapeVector& blocked_input_shapes = {},- const std::vector<ov::element::Type>& input_precisions = {},- const std::vector<ov::element::Type>& output_precisions = {},- const std::vector<snippets::pass::Manager::PositionedPassBase>& = {}) const;+ void data_flow_transformations(+ const BlockedShapeVector& blocked_input_shapes = {},+ const std::vector<ov::element::Type>& input_precisions = {},+ const std::vector<ov::element::Type>& output_precisions = {},+ const std::vector<snippets::pass::Manager::PositionedPassBase>& backend_passes = {}) const;void control_flow_transformations(size_t min_parallel_work_amount = 8,@@ -176,7 +191,7 @@ public:const BlockedShapeVector& blocked_input_shapes = {},const std::vector<ov::element::Type>& input_precisions = {},const std::vector<ov::element::Type>& output_precisions = {},- const std::vector<snippets::pass::Manager::PositionedPassBase>& data_flow_passes = {},+ const std::vector<snippets::pass::Manager::PositionedPassBase>& data_flow_backend_passes = {},const std::shared_ptr<lowered::pass::PassConfig>& lowered_pass_config =std::make_shared<lowered::pass::PassConfig>(),const std::vector<snippets::lowered::pass::PassPipeline::PositionedPassLowered>& lowered_backend_passes = {},@@ -272,6 +287,4 @@ auto inline update_out_tensor_name(const std::shared_ptr<ov::snippets::op::Subgr}}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/vector_buffer.hpp b/src/common/snippets/include/snippets/op/vector_buffer.hppindex 4ac76ec43b9..50ffb2972fb 100644--- a/src/common/snippets/include/snippets/op/vector_buffer.hpp+++ b/src/common/snippets/include/snippets/op/vector_buffer.hpp@@ -4,12 +4,15 @@#pragma once+#include <memory>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/type/element_type.hpp"#include "openvino/op/op.hpp"-#include "snippets/shape_inference/shape_inference.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {/*** @interface VectorBuffer@@ -20,7 +23,7 @@ class VectorBuffer : public ov::op::Op {public:OPENVINO_OP("VectorBuffer", "SnippetsOpset");- VectorBuffer(const ov::element::Type element_type = ov::element::f32);+ VectorBuffer(ov::element::Type element_type = ov::element::f32);bool visit_attributes(AttributeVisitor& visitor) override;std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;@@ -30,6 +33,4 @@ private:ov::element::Type m_element_type;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/pass/align_element_types.hpp b/src/common/snippets/include/snippets/pass/align_element_types.hppindex cb8698dd7f6..290d819fc6e 100644--- a/src/common/snippets/include/snippets/pass/align_element_types.hpp+++ b/src/common/snippets/include/snippets/pass/align_element_types.hpp@@ -4,13 +4,14 @@#pragma once+#include <memory>+#include <vector>++#include "openvino/core/model.hpp"+#include "openvino/core/type/element_type.hpp"#include "openvino/pass/pass.hpp"-#include "snippets/op/subgraph.hpp"-#include "transformations_visibility.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface AlignElementTypes@@ -29,6 +30,4 @@ private:std::vector<ov::element::Type> m_output_precisions;};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/analyze_broadcastable_inputs.hpp b/src/common/snippets/include/snippets/pass/analyze_broadcastable_inputs.hppindex e62b9f7c1de..2a3d76218de 100644--- a/src/common/snippets/include/snippets/pass/analyze_broadcastable_inputs.hpp+++ b/src/common/snippets/include/snippets/pass/analyze_broadcastable_inputs.hpp@@ -4,11 +4,14 @@#pragma once+#include <cstddef>+#include <map>+#include <memory>++#include "openvino/core/model.hpp"#include "openvino/pass/pass.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface AnalyzeBroadcastableInputs@@ -25,12 +28,10 @@ public:using BroadcastableInputsMap = std::map<size_t, size_t>;AnalyzeBroadcastableInputs(BroadcastableInputsMap& map);- bool run_on_model(const std::shared_ptr<ov::Model>& m) override;+ bool run_on_model(const std::shared_ptr<ov::Model>& body) override;private:BroadcastableInputsMap& m_broadcastable_inputs;};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/broadcast_to_movebroadcast.hpp b/src/common/snippets/include/snippets/pass/broadcast_to_movebroadcast.hppindex 04bcdfcd43e..e6e9be6142f 100644--- a/src/common/snippets/include/snippets/pass/broadcast_to_movebroadcast.hpp+++ b/src/common/snippets/include/snippets/pass/broadcast_to_movebroadcast.hpp@@ -5,11 +5,8 @@#pragma once#include "openvino/pass/matcher_pass.hpp"-#include "openvino/pass/pattern/matcher.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface BroadcastToMoveBroadcast@@ -23,6 +20,4 @@ public:BroadcastToMoveBroadcast();};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/canonicalization.hpp b/src/common/snippets/include/snippets/pass/canonicalization.hppindex beacabed1df..9dbd2d1f963 100644--- a/src/common/snippets/include/snippets/pass/canonicalization.hpp+++ b/src/common/snippets/include/snippets/pass/canonicalization.hpp@@ -4,14 +4,16 @@#pragma once+#include <cstddef>+#include <memory>+#include <vector>++#include "openvino/core/model.hpp"#include "openvino/pass/pass.hpp"#include "snippets/op/subgraph.hpp"#include "snippets/shape_types.hpp"-#include "transformations_visibility.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface Canonicalization@@ -34,6 +36,4 @@ private:bool m_has_dynamic_inputs = false;};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/collapse_subgraph.hpp b/src/common/snippets/include/snippets/pass/collapse_subgraph.hppindex 3a6cf780a69..e1278c676e5 100644--- a/src/common/snippets/include/snippets/pass/collapse_subgraph.hpp+++ b/src/common/snippets/include/snippets/pass/collapse_subgraph.hpp@@ -4,12 +4,15 @@#pragma once+#include <memory>+#include <set>++#include "openvino/core/node.hpp"+#include "openvino/core/type/element_type.hpp"#include "openvino/pass/matcher_pass.hpp"#include "snippets/pass/tokenization.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface TokenizeSnippets@@ -40,11 +43,9 @@ public:OPENVINO_MATCHER_PASS_RTTI("snippets::pass::TokenizeSnippets");explicit TokenizeSnippets(const SnippetsTokenization::Config& config);- static bool AppropriateForSubgraph(const std::shared_ptr<const Node>&);+ static bool AppropriateForSubgraph(const std::shared_ptr<const Node>& node);static const std::set<ov::element::Type>& get_supported_element_types();};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/common_optimizations.hpp b/src/common/snippets/include/snippets/pass/common_optimizations.hppindex 94224d78007..b74ed1b03d3 100644--- a/src/common/snippets/include/snippets/pass/common_optimizations.hpp+++ b/src/common/snippets/include/snippets/pass/common_optimizations.hpp@@ -7,9 +7,7 @@#include "openvino/pass/matcher_pass.hpp"#include "snippets/pass/tokenization.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {class CommonOptimizations : public ov::pass::MatcherPass {class SubgraphPass;@@ -23,6 +21,4 @@ public:CommonOptimizations(const SnippetsTokenization::Config& config);};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/convert_constants.hpp b/src/common/snippets/include/snippets/pass/convert_constants.hppindex 0ad8614de29..010cfac4bdf 100644--- a/src/common/snippets/include/snippets/pass/convert_constants.hpp+++ b/src/common/snippets/include/snippets/pass/convert_constants.hpp@@ -5,11 +5,8 @@#pragma once#include "openvino/pass/matcher_pass.hpp"-#include "openvino/pass/pattern/matcher.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface ConvertConstantsToScalars@@ -23,6 +20,4 @@ public:ConvertConstantsToScalars();};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/convert_power_to_powerstatic.hpp b/src/common/snippets/include/snippets/pass/convert_power_to_powerstatic.hppindex 8b3f715ba23..f74b65bff91 100644--- a/src/common/snippets/include/snippets/pass/convert_power_to_powerstatic.hpp+++ b/src/common/snippets/include/snippets/pass/convert_power_to_powerstatic.hpp@@ -6,9 +6,7 @@#include "openvino/pass/matcher_pass.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface ConvertConstantsToScalars@@ -21,6 +19,4 @@ public:ConvertPowerToPowerStatic();};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/explicit_transpose_matmul_inputs.hpp b/src/common/snippets/include/snippets/pass/explicit_transpose_matmul_inputs.hppindex 26108bc6265..845ecfe7dcb 100644--- a/src/common/snippets/include/snippets/pass/explicit_transpose_matmul_inputs.hpp+++ b/src/common/snippets/include/snippets/pass/explicit_transpose_matmul_inputs.hpp@@ -4,11 +4,13 @@#pragma once+#include <memory>++#include "openvino/core/node.hpp"+#include "openvino/core/node_input.hpp"#include "openvino/pass/matcher_pass.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface ExplicitTransposeMatMulInputs@@ -35,6 +37,4 @@ private:static void extract(const ov::Input<ov::Node>& input);};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/extract_constants.hpp b/src/common/snippets/include/snippets/pass/extract_constants.hppindex e9ce0a3e77d..e2efdea84ed 100644--- a/src/common/snippets/include/snippets/pass/extract_constants.hpp+++ b/src/common/snippets/include/snippets/pass/extract_constants.hpp@@ -4,11 +4,14 @@#pragma once+#include <memory>++#include "openvino/core/rtti.hpp"+#include "snippets/op/subgraph.hpp"+#include "snippets/pass/common_optimizations.hpp"#include "subgraph_pass.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface ExtractConstants@@ -24,6 +27,4 @@ public:bool run_on_subgraph(const std::shared_ptr<op::Subgraph>& subgraph) override;};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/extract_reshapes_from_mha.hpp b/src/common/snippets/include/snippets/pass/extract_reshapes_from_mha.hppindex 0683ddceb31..8663d5c3afc 100644--- a/src/common/snippets/include/snippets/pass/extract_reshapes_from_mha.hpp+++ b/src/common/snippets/include/snippets/pass/extract_reshapes_from_mha.hpp@@ -7,9 +7,7 @@#include "openvino/pass/graph_rewrite.hpp"#include "openvino/pass/matcher_pass.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface ExtractPairsAfterMatmul@@ -72,6 +70,4 @@ public:}};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/extract_unsupported_transposes.hpp b/src/common/snippets/include/snippets/pass/extract_unsupported_transposes.hppindex 7006e6868e9..8f993b1656c 100644--- a/src/common/snippets/include/snippets/pass/extract_unsupported_transposes.hpp+++ b/src/common/snippets/include/snippets/pass/extract_unsupported_transposes.hpp@@ -4,11 +4,14 @@#pragma once+#include <memory>++#include "openvino/core/rtti.hpp"+#include "snippets/op/subgraph.hpp"+#include "snippets/pass/common_optimizations.hpp"#include "subgraph_pass.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface ExtractUnsupportedTransposes@@ -23,6 +26,4 @@ public:bool run_on_subgraph(const std::shared_ptr<op::Subgraph>& subgraph) override;};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/fc_tokenization.hpp b/src/common/snippets/include/snippets/pass/fc_tokenization.hppindex d962371398a..fab7d294af9 100644--- a/src/common/snippets/include/snippets/pass/fc_tokenization.hpp+++ b/src/common/snippets/include/snippets/pass/fc_tokenization.hpp@@ -7,9 +7,7 @@#include "openvino/pass/matcher_pass.hpp"#include "snippets/pass/tokenization.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface TokenizeFCSnippets@@ -22,6 +20,4 @@ public:TokenizeFCSnippets(const SnippetsTokenization::Config& config);};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/fq_decomposition.hpp b/src/common/snippets/include/snippets/pass/fq_decomposition.hppindex 83945385b4e..8f2ba86c83e 100644--- a/src/common/snippets/include/snippets/pass/fq_decomposition.hpp+++ b/src/common/snippets/include/snippets/pass/fq_decomposition.hpp@@ -4,12 +4,16 @@#pragma once+#include <memory>+#include <vector>++#include "openvino/core/model.hpp"+#include "openvino/core/type/element_type.hpp"#include "openvino/op/fake_quantize.hpp"#include "openvino/pass/matcher_pass.hpp"+#include "openvino/pass/pass.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface FakeQuantizeDecomposition@@ -88,6 +92,4 @@ public:static bool is_supported_fq(const std::shared_ptr<const ov::op::v0::FakeQuantize>& fq);};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/fuse_transpose_brgemm.hpp b/src/common/snippets/include/snippets/pass/fuse_transpose_brgemm.hppindex e2ff17d309a..0db79d55319 100644--- a/src/common/snippets/include/snippets/pass/fuse_transpose_brgemm.hpp+++ b/src/common/snippets/include/snippets/pass/fuse_transpose_brgemm.hpp@@ -4,13 +4,14 @@#pragma once-#include "openvino/op/transpose.hpp"+#include <cstdint>+#include <vector>++#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"#include "openvino/pass/matcher_pass.hpp"-#include "snippets/lowered/port_descriptor.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface FuseTransposeBrgemm@@ -29,6 +30,4 @@ public:static bool is_supported_transpose_order(const std::vector<int32_t>& order);};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/gated_mlp_tokenization.hpp b/src/common/snippets/include/snippets/pass/gated_mlp_tokenization.hppindex 35e8ccb91df..9a662e0edcc 100644--- a/src/common/snippets/include/snippets/pass/gated_mlp_tokenization.hpp+++ b/src/common/snippets/include/snippets/pass/gated_mlp_tokenization.hpp@@ -7,9 +7,7 @@#include "openvino/pass/matcher_pass.hpp"#include "snippets/pass/tokenization.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface TokenizeGatedMLPSnippets@@ -32,6 +30,4 @@ public:TokenizeGatedMLPSnippets(const SnippetsTokenization::Config& config);};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/gn_decomposition.hpp b/src/common/snippets/include/snippets/pass/gn_decomposition.hppindex 4c2145b85fd..05f632fa769 100644--- a/src/common/snippets/include/snippets/pass/gn_decomposition.hpp+++ b/src/common/snippets/include/snippets/pass/gn_decomposition.hpp@@ -6,9 +6,7 @@#include "openvino/pass/matcher_pass.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface GNDecomposition@@ -21,6 +19,4 @@ public:GNDecomposition();};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/gn_tokenization.hpp b/src/common/snippets/include/snippets/pass/gn_tokenization.hppindex 2d97cc9a72b..5ae0145b485 100644--- a/src/common/snippets/include/snippets/pass/gn_tokenization.hpp+++ b/src/common/snippets/include/snippets/pass/gn_tokenization.hpp@@ -4,12 +4,9 @@#pragma once-#include "openvino/pass/pattern/matcher.hpp"-#include "snippets/pass/tokenization.hpp"+#include "openvino/pass/matcher_pass.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface TokenizeGNSnippets@@ -22,6 +19,4 @@ public:TokenizeGNSnippets();};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/hash.hpp b/src/common/snippets/include/snippets/pass/hash.hppindex 2c399818cec..9c0bbbd0067 100644--- a/src/common/snippets/include/snippets/pass/hash.hpp+++ b/src/common/snippets/include/snippets/pass/hash.hpp@@ -4,14 +4,13 @@#pragma once+#include <cstdint>+#include <memory>#include <openvino/pass/pass.hpp>-#include <string>#include "openvino/core/model.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @brief Hash transformation calculates hash value for snippets. Don't care about names as no difference from execution@@ -21,7 +20,7 @@ class Hash : public ov::pass::ModelPass {public:OPENVINO_MODEL_PASS_RTTI("snippets::pass::Hash");- bool run_on_model(const std::shared_ptr<ov::Model>& f) override;+ bool run_on_model(const std::shared_ptr<ov::Model>& m) override;/*** @brief Hash pass constructor@@ -35,6 +34,4 @@ private:uint64_t& m_hash;};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/insert_movebroadcast.hpp b/src/common/snippets/include/snippets/pass/insert_movebroadcast.hppindex 6794456f23c..26576f4888f 100644--- a/src/common/snippets/include/snippets/pass/insert_movebroadcast.hpp+++ b/src/common/snippets/include/snippets/pass/insert_movebroadcast.hpp@@ -4,11 +4,12 @@#pragma once+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/partial_shape.hpp"#include "openvino/pass/matcher_pass.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface InsertMoveBroadcast@@ -26,6 +27,4 @@ public:const ov::PartialShape& normalized_shape);};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/manager.hpp b/src/common/snippets/include/snippets/pass/manager.hppindex 3c98e3eba25..6acae12d991 100644--- a/src/common/snippets/include/snippets/pass/manager.hpp+++ b/src/common/snippets/include/snippets/pass/manager.hpp@@ -4,14 +4,18 @@#pragma once+#include <memory>+#include <string>+#include <type_traits>+#include <vector>+#include "openvino/pass/manager.hpp"#include "openvino/pass/pass.hpp"+#include "openvino/pass/pass_config.hpp"#include "openvino/pass/validate.hpp"#include "positioned_pass.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @brief Manager is like ov::pass::Manager, but allows to insert new passes at arbitrary places in the pipeline@@ -28,14 +32,11 @@ public:template <typename T, class... Args>std::shared_ptr<T> register_pass(Args&&... args) {- return ov::pass::Manager::register_pass<T>(args...);+ return ov::pass::Manager::register_pass<T>(std::forward<Args>(args)...);}- template <typename T,- class Pos,- class... Args,- std::enable_if<std::is_same<PassPosition, Pos>::value, bool>() = true>+ template <typename T, class Pos, class... Args, std::enable_if<std::is_same_v<PassPosition, Pos>, bool>() = true>std::shared_ptr<T> register_pass(const PassPosition& position, Args&&... args) {- static_assert(std::is_base_of<PassBase, T>::value, "Attempt to insert pass that is not derived from PassBase");+ static_assert(std::is_base_of_v<PassBase, T>, "Attempt to insert pass that is not derived from PassBase");auto pass = std::make_shared<T>(std::forward<Args>(args)...);auto rc = insert_pass_instance(position, pass);rc->set_pass_config(m_pass_config);@@ -45,7 +46,7 @@ public:return rc;}- std::shared_ptr<PassBase> register_pass_instance(const PassPosition& pass_id,+ std::shared_ptr<PassBase> register_pass_instance(const PassPosition& position,const std::shared_ptr<PassBase>& pass);void register_positioned_passes(const std::vector<PositionedPassBase>& pos_passes);@@ -53,6 +54,4 @@ protected:std::shared_ptr<PassBase> insert_pass_instance(const PassPosition& position, const std::shared_ptr<PassBase>& pass);};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/matmul_to_brgemm.hpp b/src/common/snippets/include/snippets/pass/matmul_to_brgemm.hppindex 4aabcc3491c..cc514e62a39 100644--- a/src/common/snippets/include/snippets/pass/matmul_to_brgemm.hpp+++ b/src/common/snippets/include/snippets/pass/matmul_to_brgemm.hpp@@ -5,11 +5,8 @@#pragma once#include "openvino/pass/matcher_pass.hpp"-#include "snippets/op/brgemm.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface MatMulToBrgemm@@ -22,6 +19,4 @@ public:MatMulToBrgemm();};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/mha_tokenization.hpp b/src/common/snippets/include/snippets/pass/mha_tokenization.hppindex 116f21b4909..b7da99d92b1 100644--- a/src/common/snippets/include/snippets/pass/mha_tokenization.hpp+++ b/src/common/snippets/include/snippets/pass/mha_tokenization.hpp@@ -4,12 +4,16 @@#pragma once+#include <cstddef>+#include <cstdint>+#include <memory>+#include <vector>++#include "openvino/opsets/opset1.hpp"#include "openvino/pass/matcher_pass.hpp"#include "snippets/pass/tokenization.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface TokenizeMHASnippets@@ -48,6 +52,4 @@ public:static bool is_matmul0_supported(const std::shared_ptr<ov::opset1::MatMul>& matmul);};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/mlp_seq_tokenization.hpp b/src/common/snippets/include/snippets/pass/mlp_seq_tokenization.hppindex 87ba54106f0..e93658d7ef3 100644--- a/src/common/snippets/include/snippets/pass/mlp_seq_tokenization.hpp+++ b/src/common/snippets/include/snippets/pass/mlp_seq_tokenization.hpp@@ -4,12 +4,15 @@#pragma once+#include <cstddef>+#include <memory>++#include "openvino/core/descriptor/tensor.hpp"+#include "openvino/core/node.hpp"#include "openvino/pass/matcher_pass.hpp"#include "snippets/pass/tokenization.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface TokenizeMLPSeqSnippets@@ -40,6 +43,4 @@ private:static const size_t m_rank;};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/positioned_pass.hpp b/src/common/snippets/include/snippets/pass/positioned_pass.hppindex 650be587017..d633320819a 100644--- a/src/common/snippets/include/snippets/pass/positioned_pass.hpp+++ b/src/common/snippets/include/snippets/pass/positioned_pass.hpp@@ -4,15 +4,17 @@#pragma once-#include <typeinfo>+#include <algorithm>+#include <cstddef>+#include <cstdint>+#include <memory>+#include <utility>+#include <vector>-#include "openvino/pass/manager.hpp"-#include "openvino/pass/pass.hpp"-#include "openvino/pass/validate.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @brief PassPosition describes a particular position in a transformation pipeline,@@ -29,7 +31,7 @@ namespace pass {*/class PassPosition {public:- enum class Place { Before, After, PipelineStart, PipelineEnd };+ enum class Place : uint8_t { Before, After, PipelineStart, PipelineEnd };explicit PassPosition(Place pass_place);explicit PassPosition(Place pass_place, const DiscreteTypeInfo& pass_type_info, size_t pass_instance = 0);@@ -47,7 +49,7 @@ private:template <typename PassType>struct PositionedPass {PositionedPass(PassPosition arg_pos, std::shared_ptr<PassType> arg_pass)- : position(arg_pos),+ : position(std::move(arg_pos)),pass(std::move(arg_pass)) {}PassPosition position;@@ -60,8 +62,9 @@ typename std::vector<std::shared_ptr<PassType>>::const_iterator PassPosition::gesize_t pass_count = 0;auto match = [this, &pass_count](const std::shared_ptr<PassType>& p) {if (p->get_type_info() == m_pass_type_info) {- if (m_pass_instance == pass_count)+ if (m_pass_instance == pass_count) {return true;+ }pass_count++;}return false;@@ -82,6 +85,4 @@ typename std::vector<std::shared_ptr<PassType>>::const_iterator PassPosition::ge}}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/propagate_precision.hpp b/src/common/snippets/include/snippets/pass/propagate_precision.hppindex dbfe00567d3..4a34f465e5f 100644--- a/src/common/snippets/include/snippets/pass/propagate_precision.hpp+++ b/src/common/snippets/include/snippets/pass/propagate_precision.hpp@@ -5,13 +5,16 @@#pragma once#include <memory>+#include <set>+#include <vector>+#include "openvino/core/model.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/type/element_type.hpp"#include "openvino/pass/pass.hpp"-#include "snippets/generator.hpp"+#include "snippets/target_machine.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @class PropagatePrecision@@ -42,6 +45,4 @@ private:const std::shared_ptr<const TargetMachine> target_machine;};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/reduce_to_snippets_reduce.hpp b/src/common/snippets/include/snippets/pass/reduce_to_snippets_reduce.hppindex 15b44b8e8e9..4fa1b628bc3 100644--- a/src/common/snippets/include/snippets/pass/reduce_to_snippets_reduce.hpp+++ b/src/common/snippets/include/snippets/pass/reduce_to_snippets_reduce.hpp@@ -6,9 +6,7 @@#include "openvino/pass/matcher_pass.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface ReduceToSnippetsReduce@@ -22,6 +20,4 @@ public:ReduceToSnippetsReduce();};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/softmax_decomposition.hpp b/src/common/snippets/include/snippets/pass/softmax_decomposition.hppindex 403df8c0883..8ac6de14f02 100644--- a/src/common/snippets/include/snippets/pass/softmax_decomposition.hpp+++ b/src/common/snippets/include/snippets/pass/softmax_decomposition.hpp@@ -6,9 +6,7 @@#include "openvino/pass/matcher_pass.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface SoftmaxDecomposition@@ -21,6 +19,4 @@ public:SoftmaxDecomposition();};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/softmax_reshape_elimination.hpp b/src/common/snippets/include/snippets/pass/softmax_reshape_elimination.hppindex 87679554989..5e7233c8b1b 100644--- a/src/common/snippets/include/snippets/pass/softmax_reshape_elimination.hpp+++ b/src/common/snippets/include/snippets/pass/softmax_reshape_elimination.hpp@@ -6,9 +6,7 @@#include "openvino/pass/matcher_pass.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface SoftmaxReshapeElimination@@ -21,6 +19,4 @@ public:SoftmaxReshapeElimination();};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/split_dimension_m.hpp b/src/common/snippets/include/snippets/pass/split_dimension_m.hppindex 28f0ea61251..f604e2649fa 100644--- a/src/common/snippets/include/snippets/pass/split_dimension_m.hpp+++ b/src/common/snippets/include/snippets/pass/split_dimension_m.hpp@@ -4,11 +4,21 @@#pragma once+#include <cstddef>+#include <memory>+#include <utility>+#include <vector>++#include "openvino/core/node.hpp"+#include "openvino/core/rtti.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/op/matmul.hpp"+#include "snippets/op/subgraph.hpp"+#include "snippets/pass/common_optimizations.hpp"+#include "snippets/shape_types.hpp"#include "subgraph_pass.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface SplitDimensionM@@ -94,10 +104,10 @@ private:size_t m_dim,size_t optimal_parallelism_work_amount);- void reshape_subgraph(const std::shared_ptr<op::Subgraph>& subgraph,- const ov::Shape& shape,- size_t batch_m_dim,- size_t new_m_dim);+ static void reshape_subgraph(const std::shared_ptr<op::Subgraph>& subgraph,+ const ov::Shape& shape,+ size_t batch_m_dim,+ size_t new_m_dim);static size_t get_dim_M(const ov::Shape& shape) {if (shape.size() < dim_M_index + 1) {@@ -111,6 +121,4 @@ private:static const size_t min_kernel_m;static const size_t dim_M_index;};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/subgraph_manager.hpp b/src/common/snippets/include/snippets/pass/subgraph_manager.hppindex 7eb152f2ff2..76fdde2282d 100644--- a/src/common/snippets/include/snippets/pass/subgraph_manager.hpp+++ b/src/common/snippets/include/snippets/pass/subgraph_manager.hpp@@ -5,16 +5,14 @@#pragma once#include <memory>-#include <typeinfo>+#include <type_traits>#include <vector>#include "snippets/op/subgraph.hpp"#include "snippets/pass/common_optimizations.hpp"#include "snippets/pass/subgraph_pass.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @brief Manager class allows to manage transformation passes (SubgraphPasses) on Subgraph ops.* See SubgraphPasses description for more details.@@ -39,11 +37,9 @@ public:/// @brief Runs registered transformations on a given model/// @param subgraph Input model/// @return Returns true if the model was changed by transformations, false otherwise.- bool run_passes(std::shared_ptr<ov::snippets::op::Subgraph> subgraph);+ bool run_passes(const std::shared_ptr<ov::snippets::op::Subgraph>& subgraph);protected:std::vector<std::shared_ptr<SubgraphPass>> m_pass_list;};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/subgraph_pass.hpp b/src/common/snippets/include/snippets/pass/subgraph_pass.hppindex b38f54d1157..ad04f67c05c 100644--- a/src/common/snippets/include/snippets/pass/subgraph_pass.hpp+++ b/src/common/snippets/include/snippets/pass/subgraph_pass.hpp@@ -4,13 +4,14 @@#pragma once-#include <typeinfo>+#include <memory>+#include <string>+#include "openvino/core/type.hpp"+#include "snippets/op/subgraph.hpp"#include "snippets/pass/common_optimizations.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @brief Base class for Subgraph passes.@@ -31,17 +32,15 @@ public:void set_name(const std::string& name) {m_name = name;}- std::string get_name() const {+ [[nodiscard]] std::string get_name() const {return m_name;}using type_info_t = DiscreteTypeInfo;- virtual const type_info_t& get_type_info() const = 0;+ [[nodiscard]] virtual const type_info_t& get_type_info() const = 0;private:std::string m_name;};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/tokenization.hpp b/src/common/snippets/include/snippets/pass/tokenization.hppindex 5bde74624c0..c0d70f2058e 100644--- a/src/common/snippets/include/snippets/pass/tokenization.hpp+++ b/src/common/snippets/include/snippets/pass/tokenization.hpp@@ -4,31 +4,40 @@#pragma once-#include "openvino/pass/matcher_pass.hpp"+#include <cstddef>+#include <cstdint>+#include <functional>+#include <memory>+#include <set>+#include <utility>++#include "openvino/core/except.hpp"+#include "openvino/core/model.hpp"+#include "openvino/core/node.hpp"+#include "openvino/op/matmul.hpp"+#include "openvino/pass/pass.hpp"#include "snippets/op/subgraph.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*NotSet - default value returned by GetSnippetsNodeType(...) if the node wasn't markedSkippedByPlugin - indicate that snippets can't include this node in subgraph. Can be set by Plugin viaSetSnippetsNodeType(...).*/-enum class SnippetsNodeType : int64_t { NotSet, SkippedByPlugin };+enum class SnippetsNodeType : uint8_t { NotSet, SkippedByPlugin };/*NotSet - default value returned if the subgraph wasn't marked and snippets can include nodes in this subgraphCompleted - indicate that snippets can't include any nodes in this subgraph.It's used in separate tokenization pass, for example, tokenization by matcher (MHA Tokenization).*/-enum class SnippetsSubgraphType : int64_t { NotSet, Completed };-void SetSnippetsNodeType(const std::shared_ptr<Node>&, SnippetsNodeType);-void SetSnippetsSubgraphType(const std::shared_ptr<op::Subgraph>&, SnippetsSubgraphType);-SnippetsNodeType GetSnippetsNodeType(const std::shared_ptr<const Node>&);-SnippetsSubgraphType GetSnippetsSubgraphType(const std::shared_ptr<const op::Subgraph>&);-void SetTopologicalOrder(const std::shared_ptr<Node>&, int64_t);-int64_t GetTopologicalOrder(const std::shared_ptr<const Node>&);+enum class SnippetsSubgraphType : uint8_t { NotSet, Completed };+void SetSnippetsNodeType(const std::shared_ptr<Node>& node, SnippetsNodeType nodeType);+void SetSnippetsSubgraphType(const std::shared_ptr<op::Subgraph>& node, SnippetsSubgraphType nodeType);+SnippetsNodeType GetSnippetsNodeType(const std::shared_ptr<const Node>& node);+SnippetsSubgraphType GetSnippetsSubgraphType(const std::shared_ptr<const op::Subgraph>& node);+void SetTopologicalOrder(const std::shared_ptr<Node>& node, int64_t order);+int64_t GetTopologicalOrder(const std::shared_ptr<const Node>& node);/*** @interface EnumerateNodes@@ -39,7 +48,7 @@ class EnumerateNodes : public ov::pass::ModelPass {public:OPENVINO_MODEL_PASS_RTTI("snippets::pass::EnumerateNodes");EnumerateNodes() : ModelPass() {}- bool run_on_model(const std::shared_ptr<ov::Model>&) override;+ bool run_on_model(const std::shared_ptr<ov::Model>& m) override;};/**@@ -83,7 +92,7 @@ public:m_mha_token_enable_transpose_on_output(enable_transpose_on_output),m_is_dynamic_mha_token_enabled(dyn_mha_token),m_mha_supported_transpose_ranks(std::move(mha_transpose_ranks)),- m_can_be_fused_as_postop(can_be_fused_as_postop) {+ m_can_be_fused_as_postop(std::move(can_be_fused_as_postop)) {OPENVINO_ASSERT(concurrency > 0, "Concurrency should be greater than 0");OPENVINO_ASSERT(data_ptr_gpr_count > 0, "data_ptr_gpr_count should be greater than 0");}@@ -92,31 +101,31 @@ public:m_concurrency = concur;}- size_t get_concurrency() const {+ [[nodiscard]] size_t get_concurrency() const {return m_concurrency;}- size_t get_data_ptr_gpr_count() const {+ [[nodiscard]] size_t get_data_ptr_gpr_count() const {return m_data_ptr_gpr_count;}- bool get_split_m_dimension() const {+ [[nodiscard]] bool get_split_m_dimension() const {return m_split_m_dimension;}- bool get_mha_token_enable_transpose_on_output() const {+ [[nodiscard]] bool get_mha_token_enable_transpose_on_output() const {return m_mha_token_enable_transpose_on_output;}- bool is_dynamic_mha_token_enabled() const {+ [[nodiscard]] bool is_dynamic_mha_token_enabled() const {return m_is_dynamic_mha_token_enabled;}- std::set<size_t> get_mha_supported_transpose_ranks() const {+ [[nodiscard]] std::set<size_t> get_mha_supported_transpose_ranks() const {return m_mha_supported_transpose_ranks;}- const CanBeFusedAsPostOpPred& get_can_be_fused_as_postop() const {+ [[nodiscard]] const CanBeFusedAsPostOpPred& get_can_be_fused_as_postop() const {return m_can_be_fused_as_postop;}@@ -144,13 +153,11 @@ public:CanBeFusedAsPostOpPred m_can_be_fused_as_postop = nullptr;};- SnippetsTokenization(const Config& config) : m_config(config) {}+ SnippetsTokenization(Config config) : m_config(std::move(config)) {}bool run_on_model(const std::shared_ptr<ov::Model>& m) override;private:Config m_config;};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/transform_convert.hpp b/src/common/snippets/include/snippets/pass/transform_convert.hppindex 0814b231abd..40ac95cc89c 100644--- a/src/common/snippets/include/snippets/pass/transform_convert.hpp+++ b/src/common/snippets/include/snippets/pass/transform_convert.hpp@@ -6,9 +6,7 @@#include "openvino/pass/matcher_pass.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface TransformConvertToConvertTruncation@@ -23,6 +21,4 @@ public:TransformConvertToConvertTruncation();};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/transpose_decomposition.hpp b/src/common/snippets/include/snippets/pass/transpose_decomposition.hppindex 1f0a8a057ae..d5375e80b32 100644--- a/src/common/snippets/include/snippets/pass/transpose_decomposition.hpp+++ b/src/common/snippets/include/snippets/pass/transpose_decomposition.hpp@@ -4,11 +4,14 @@#pragma once+#include <cstdint>+#include <vector>++#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"#include "openvino/pass/matcher_pass.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {/*** @interface TransposeDecomposition@@ -24,6 +27,4 @@ public:static bool is_supported_transpose_order(const std::vector<int32_t>& order);};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/pass/validate.hpp b/src/common/snippets/include/snippets/pass/validate.hppindex 221fa8fb03f..3cc46307149 100644--- a/src/common/snippets/include/snippets/pass/validate.hpp+++ b/src/common/snippets/include/snippets/pass/validate.hpp@@ -4,11 +4,14 @@#pragma once-#include "openvino/pass/matcher_pass.hpp"+#include <memory>-namespace ov {-namespace snippets {-namespace pass {+#include "openvino/core/model.hpp"+#include "openvino/core/node.hpp"+#include "openvino/pass/pass.hpp"+#include "openvino/pass/pass_config.hpp"++namespace ov::snippets::pass {/*** @interface Validate@@ -23,18 +26,16 @@ public:bool run_on_model(const std::shared_ptr<ov::Model>& m) override;private:- bool is_supported_constant(const std::shared_ptr<const ov::Node>& op);- bool is_supported_convert(const std::shared_ptr<const ov::Node>& op);+ static bool is_supported_constant(const std::shared_ptr<const ov::Node>& op);+ static bool is_supported_convert(const std::shared_ptr<const ov::Node>& op);bool is_supported_matmul(const std::shared_ptr<const ov::Node>& op);- bool is_supported_softmax(const std::shared_ptr<const ov::Node>& op);+ static bool is_supported_softmax(const std::shared_ptr<const ov::Node>& op);bool is_supported_fq(const std::shared_ptr<const ov::Node>& node);- bool is_supported_transpose(const std::shared_ptr<const ov::Node>& node);- bool is_supported_op(const std::shared_ptr<const ov::Node>& node);+ static bool is_supported_transpose(const std::shared_ptr<const ov::Node>& node);+ static bool is_supported_op(const std::shared_ptr<const ov::Node>& node);// Pass config of CommonOptimizations that contains information: which of common passes are disabledstd::shared_ptr<ov::pass::PassConfig> m_pass_config;};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/runtime_configurator.hpp b/src/common/snippets/include/snippets/runtime_configurator.hppindex 3dfd593dffb..8b31c6d5bcf 100644--- a/src/common/snippets/include/snippets/runtime_configurator.hpp+++ b/src/common/snippets/include/snippets/runtime_configurator.hpp@@ -4,13 +4,26 @@#pragma once+#include <cstddef>+#include <cstdint>+#include <map>+#include <memory>+#include <set>+#include <string>+#include <unordered_map>+#include <vector>++#include "openvino/core/type.hpp"#include "snippets/kernel_executor_table.hpp"+#include "snippets/lowered/expressions/buffer_expression.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/pass/pass.hpp"+#include "snippets/lowered/port_descriptor.hpp"+#include "snippets/shape_inference/shape_inference.hpp"+#include "snippets/shape_types.hpp"-namespace ov {-namespace snippets {+namespace ov::snippets {/*** @interface RuntimeConfig@@ -29,30 +42,30 @@ public:return type_info_static;}- virtual const DiscreteTypeInfo& get_type_info() const {+ [[nodiscard]] virtual const DiscreteTypeInfo& get_type_info() const {return get_type_info_static();}- const char* get_type_name() const {+ [[nodiscard]] const char* get_type_name() const {return get_type_info().name;}#ifdef SNIPPETS_DEBUG_CAPS- virtual std::string to_string() const;+ [[nodiscard]] virtual std::string to_string() const;#endifsize_t tensor_rank = 0;size_t tile_rank = 0;- std::vector<ov::snippets::VectorDims> io_shapes = {};- std::vector<ov::snippets::VectorDims> io_layouts = {};- std::vector<ov::snippets::VectorDims> io_data_offsets = {};- ov::snippets::VectorDims master_shape = {};+ std::vector<ov::snippets::VectorDims> io_shapes;+ std::vector<ov::snippets::VectorDims> io_layouts;+ std::vector<ov::snippets::VectorDims> io_data_offsets;+ ov::snippets::VectorDims master_shape;size_t buffer_scratchpad_size = 0;- std::vector<size_t> buffer_cluster_offsets{};+ std::vector<size_t> buffer_cluster_offsets;KernelExecutorTablePtr kernel_executor_table = std::make_shared<ov::snippets::KernelExecutorTable>();- std::vector<ov::snippets::VectorDims> latest_shapes = {};+ std::vector<ov::snippets::VectorDims> latest_shapes;};/**@@ -74,7 +87,7 @@ public:* @brief Returns pointer to KernelExecutorTable owned by the config* @return updated KernelExecutorTable*/- const std::shared_ptr<KernelExecutorTable>& get_kernel_executor_table() const {+ [[nodiscard]] const std::shared_ptr<KernelExecutorTable>& get_kernel_executor_table() const {return m_config->kernel_executor_table;}/**@@ -89,22 +102,22 @@ public:void reset_kernel_executor_table() const;// Getters for private members- std::shared_ptr<RuntimeConfig> get_config() const {+ [[nodiscard]] std::shared_ptr<RuntimeConfig> get_config() const {return m_config;}- size_t get_io_num() const {+ [[nodiscard]] size_t get_io_num() const {return m_io_num;}- size_t get_in_num() const {+ [[nodiscard]] size_t get_in_num() const {return m_in_num;}- const std::vector<snippets::lowered::PortDescriptorPtr>& get_io_descs() const {+ [[nodiscard]] const std::vector<snippets::lowered::PortDescriptorPtr>& get_io_descs() const {return m_io_descs;}- const std::vector<size_t>& get_io_data_sizes() const {+ [[nodiscard]] const std::vector<size_t>& get_io_data_sizes() const {return m_io_data_sizes;}- const std::map<size_t, std::set<lowered::BufferExpressionPtr>>& get_dynamic_buffer_clusters() const {+ [[nodiscard]] const std::map<size_t, std::set<lowered::BufferExpressionPtr>>& get_dynamic_buffer_clusters() const {return m_dynamic_buffer_clusters;}@@ -142,7 +155,7 @@ public:* @param initialized_info_map A map containing the initialized runtime parameters for UnifiedLoopInfo.*/static void update_expanded_loop_info(const lowered::ExpandedLoopInfoPtr& expanded_loop_info,- LoopInfoRuntimeParamsMap& initializated_info_map);+ LoopInfoRuntimeParamsMap& initialized_info);/*** @brief Update tensor rank based on master shape* @param master_shape Master shape@@ -196,20 +209,20 @@ protected:/*** @brief Extract shapes from m_io_descs*/- std::vector<ov::snippets::VectorDims> extract_shapes() const;+ [[nodiscard]] std::vector<ov::snippets::VectorDims> extract_shapes() const;/*** @brief Extract layouts from m_io_descs*/- std::vector<std::vector<size_t>> extract_layouts() const;+ [[nodiscard]] std::vector<std::vector<size_t>> extract_layouts() const;std::shared_ptr<RuntimeConfig> m_config = nullptr;size_t m_io_num = 0;size_t m_in_num = 0;- std::vector<snippets::lowered::PortDescriptorPtr> m_io_descs = {};- std::vector<size_t> m_io_data_sizes = {};+ std::vector<snippets::lowered::PortDescriptorPtr> m_io_descs;+ std::vector<size_t> m_io_data_sizes;// [cluster_id -> buffer expressions ]- std::map<size_t, std::set<lowered::BufferExpressionPtr>> m_dynamic_buffer_clusters = {};+ std::map<size_t, std::set<lowered::BufferExpressionPtr>> m_dynamic_buffer_clusters;// WA: until ticket 148891 is not implemented, 2 pass pipelines for runtime optimizers are necessary since different// optimizers must be called at different pipeline stages.@@ -221,5 +234,4 @@ protected:lowered::pass::PassPipeline m_final_optimizers;};-} // namespace snippets-} // namespace ov+} // namespace ov::snippetsdiff --git a/src/common/snippets/include/snippets/shape_inference/shape_infer_instances.hpp b/src/common/snippets/include/snippets/shape_inference/shape_infer_instances.hppindex fc4c4209f7d..1ee8418be51 100644--- a/src/common/snippets/include/snippets/shape_inference/shape_infer_instances.hpp+++ b/src/common/snippets/include/snippets/shape_inference/shape_infer_instances.hpp@@ -4,10 +4,17 @@#pragma once+#include <cstddef>+#include <memory>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/op/util/attr_types.hpp"#include "shape_inference.hpp"+#include "snippets/shape_types.hpp"-namespace ov {-namespace snippets {+namespace ov::snippets {bool broadcast_merge_into(VectorDims& dst,const VectorDims& src,@@ -31,7 +38,7 @@ public:class PassThroughShapeInfer : public IShapeInferSnippets {public:- inline Result infer(const std::vector<VectorDimsRef>& input_shapes) override {+ Result infer(const std::vector<VectorDimsRef>& input_shapes) override {OPENVINO_ASSERT(!input_shapes.empty(), "Empty Input shapes are not allowed for PassThroughShapeInfer");return {{input_shapes[0].get()}, ShapeInferStatus::success};}@@ -39,14 +46,14 @@ public:class EmptyShapeInfer : public IShapeInferSnippets {public:- inline Result infer(const std::vector<VectorDimsRef>& input_shapes) override {+ Result infer([[maybe_unused]] const std::vector<VectorDimsRef>& input_shapes) override {return {{}, ShapeInferStatus::success};}};class SingleElementShapeInfer : public IShapeInferSnippets {public:- inline Result infer(const std::vector<VectorDimsRef>& input_shapes) override {+ Result infer([[maybe_unused]] const std::vector<VectorDimsRef>& input_shapes) override {return {{{1}}, ShapeInferStatus::success};}};@@ -80,5 +87,4 @@ public:Result infer(const std::vector<VectorDimsRef>& input_shapes) override;};-} // namespace snippets-} // namespace ov+} // namespace ov::snippetsdiff --git a/src/common/snippets/include/snippets/shape_inference/shape_inference.hpp b/src/common/snippets/include/snippets/shape_inference/shape_inference.hppindex 5d0b49794f0..17188bb8b40 100644--- a/src/common/snippets/include/snippets/shape_inference/shape_inference.hpp+++ b/src/common/snippets/include/snippets/shape_inference/shape_inference.hpp@@ -4,14 +4,20 @@#pragma once+#include <cstdint>+#include <functional>+#include <memory>#include <openvino/core/core.hpp>+#include <unordered_map>+#include <vector>+#include "openvino/core/node.hpp"+#include "openvino/core/type.hpp"#include "snippets/shape_types.hpp"-namespace ov {-namespace snippets {+namespace ov::snippets {-enum class ShapeInferStatus {+enum class ShapeInferStatus : uint8_t {success, ///< shapes were successfully calculatedskip ///< shape inference was skipped.};@@ -23,7 +29,7 @@ class IShapeInferSnippets {public:struct Result {std::vector<VectorDims> dims;- ShapeInferStatus status;+ ShapeInferStatus status{};};virtual ~IShapeInferSnippets() = default;@@ -80,10 +86,10 @@ protected:* @brief get shape infer instances for operations from backend-specific opset* @return Pointer to shape inference object or nullptr if failed to construct the object.*/- virtual ShapeInferPtr get_specific_op_shape_infer(const ov::DiscreteTypeInfo& key,- const std::shared_ptr<ov::Node>& op) const;+ [[nodiscard]] virtual ShapeInferPtr get_specific_op_shape_infer(const ov::DiscreteTypeInfo& key,+ const std::shared_ptr<ov::Node>& op) const;};std::shared_ptr<IShapeInferSnippets> make_shape_inference(const std::shared_ptr<ov::Node>& op,const std::shared_ptr<IShapeInferSnippetsFactory>& factory);-} // namespace snippets-} // namespace ov++} // namespace ov::snippetsdiff --git a/src/common/snippets/include/snippets/shape_types.hpp b/src/common/snippets/include/snippets/shape_types.hppindex e6b4adb576d..6f8c92d99f3 100644--- a/src/common/snippets/include/snippets/shape_types.hpp+++ b/src/common/snippets/include/snippets/shape_types.hpp@@ -4,11 +4,12 @@#pragma once+#include <cstddef>+#include <functional>#include <memory>#include <vector>-namespace ov {-namespace snippets {+namespace ov::snippets {/** This header file contain declarations of shape-relevant classes used cross several snippets subsystems.* The main purpose of storing such declarations here is to eliminate false dependencies. For example,@@ -20,5 +21,4 @@ using VectorDimsPtr = std::shared_ptr<VectorDims>;using VectorDimsCPtr = std::shared_ptr<const VectorDims>;using VectorDimsRef = std::reference_wrapper<const VectorDims>;-} // namespace snippets-} // namespace ov+} // namespace ov::snippetsdiff --git a/src/common/snippets/include/snippets/snippets_isa.hpp b/src/common/snippets/include/snippets/snippets_isa.hppdeleted file mode 100644index 5028c175a60..00000000000--- a/src/common/snippets/include/snippets/snippets_isa.hpp+++ /dev/null@@ -1,41 +0,0 @@-// Copyright (C) 2018-2025 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include "op/brgemm.hpp"-#include "op/broadcastload.hpp"-#include "op/broadcastmove.hpp"-#include "op/buffer.hpp"-#include "op/convert_saturation.hpp"-#include "op/convert_truncation.hpp"-#include "op/fill.hpp"-#include "op/horizon_max.hpp"-#include "op/horizon_sum.hpp"-#include "op/kernel.hpp"-#include "op/load.hpp"-#include "op/loop.hpp"-#include "op/nop.hpp"-#include "op/perf_count.hpp"-#include "op/powerstatic.hpp"-#include "op/rank_normalization.hpp"-#include "op/reduce.hpp"-#include "op/reg_spill.hpp"-#include "op/reorder.hpp"-#include "op/reshape.hpp"-#include "op/scalar.hpp"-#include "op/store.hpp"-#include "op/vector_buffer.hpp"-#include "openvino/core/node.hpp"-#include "openvino/opsets/opset1.hpp"--namespace ov {-namespace snippets {-namespace isa {-#define OV_OP(a, b) using b::a;-#include "snippets_isa_tbl.hpp"-#undef OV_OP-} // namespace isa-} // namespace snippets-} // namespace ovdiff --git a/src/common/snippets/include/snippets/target_machine.hpp b/src/common/snippets/include/snippets/target_machine.hppindex 3d1e2424844..d78d8e48109 100644--- a/src/common/snippets/include/snippets/target_machine.hpp+++ b/src/common/snippets/include/snippets/target_machine.hpp@@ -8,23 +8,33 @@*/#pragma once+#include <cstddef>+#include <cstdint>+#include <functional>+#include <map>+#include <memory>+#include <set>+#include <utility>+#include <vector>+#include "emitter.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"#include "snippets/lowered/expression.hpp"-namespace ov {-namespace snippets {+namespace ov::snippets {struct CompiledSnippet {- virtual const uint8_t* get_code() const = 0;- virtual size_t get_code_size() const = 0;- virtual bool empty() const = 0;+ [[nodiscard]] virtual const uint8_t* get_code() const = 0;+ [[nodiscard]] virtual size_t get_code_size() const = 0;+ [[nodiscard]] virtual bool empty() const = 0;virtual ~CompiledSnippet() = default;};using CompiledSnippetPtr = std::shared_ptr<CompiledSnippet>;-typedef std::pair<std::function<std::shared_ptr<Emitter>(const lowered::ExpressionPtr&)>,- std::function<std::set<ov::element::TypeVector>(const std::shared_ptr<ov::Node>&)>>- jitters_value;+using jitters_value = std::pair<std::function<std::shared_ptr<Emitter>(const lowered::ExpressionPtr&)>,+ std::function<std::set<ov::element::TypeVector>(const std::shared_ptr<ov::Node>&)>>;class RuntimeConfigurator;@@ -44,7 +54,7 @@ public:* @brief checks if target is natively supported* @return true, if supported*/- virtual bool is_supported() const = 0;+ [[nodiscard]] virtual bool is_supported() const = 0;/*** @brief finalizes code generation@@ -56,64 +66,64 @@ public:* @brief gets number of lanes supported by target's vector ISA* @return number of lanes*/- virtual size_t get_lanes() const = 0;+ [[nodiscard]] virtual size_t get_lanes() const = 0;/*** @brief Get all possible ABI argument registers.* The number of actually used register depends on the signature of the called binary.* @return vector os snippets::Reg*/- virtual std::vector<snippets::Reg> get_abi_arg_regs() const = 0;+ [[nodiscard]] virtual std::vector<snippets::Reg> get_abi_arg_regs() const = 0;/*** @brief Get all available general-purpose registers.* Returns only registers that are not reserved for special purposes (e.g. stack pointer or instruction address).* @return vector os snippets::Reg*/- virtual std::vector<snippets::Reg> get_gp_reg_pool() const = 0;+ [[nodiscard]] virtual std::vector<snippets::Reg> get_gp_reg_pool() const = 0;/*** @brief Get all available vector registers.* Returns only registers that are not reserved for special purposes* @return vector os snippets::Reg*/- virtual std::vector<snippets::Reg> get_vec_reg_pool() const = 0;+ [[nodiscard]] virtual std::vector<snippets::Reg> get_vec_reg_pool() const = 0;/*** @brief called by generator to all the emitter for a target machine* @return a map by node's type info with callbacks to create an instance of emitter for corresponding operation* type*/- std::function<std::shared_ptr<Emitter>(const lowered::ExpressionPtr&)> get(const ov::DiscreteTypeInfo& type) const;+ [[nodiscard]] std::function<std::shared_ptr<Emitter>(const lowered::ExpressionPtr&)> get(+ const ov::DiscreteTypeInfo& type) const;/*** @brief called by generator to all the emitter for a target machine* @return a map by node's type info with callbacks to create an set of supported precisions for corresponding* operation type*/- std::function<std::set<ov::element::TypeVector>(const std::shared_ptr<ov::Node>&)> get_supported_precisions(- const ov::DiscreteTypeInfo& type) const;+ [[nodiscard]] std::function<std::set<ov::element::TypeVector>(const std::shared_ptr<ov::Node>&)>+ get_supported_precisions(const ov::DiscreteTypeInfo& type) const;/*** @brief checks if emitter for a specific operation is supported* @return true, if supported*/- bool has(const ov::DiscreteTypeInfo& type) const;+ [[nodiscard]] bool has(const ov::DiscreteTypeInfo& type) const;/*** @brief clone the current state* @return shared pointer with cloned instance*/- virtual std::shared_ptr<TargetMachine> clone() const = 0;+ [[nodiscard]] virtual std::shared_ptr<TargetMachine> clone() const = 0;/*** @brief gets runtime configurator* @return shared pointer with runtime configurator*/- const std::shared_ptr<RuntimeConfigurator>& get_runtime_configurator() const;+ [[nodiscard]] const std::shared_ptr<RuntimeConfigurator>& get_runtime_configurator() const;protected:std::map<const ov::DiscreteTypeInfo, jitters_value> jitters;std::shared_ptr<RuntimeConfigurator> configurator;};-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippetsdiff --git a/src/common/snippets/include/snippets/utils/debug_caps_config.hpp b/src/common/snippets/include/snippets/utils/debug_caps_config.hppindex 8c3c8ef7091..c857961fa1f 100644--- a/src/common/snippets/include/snippets/utils/debug_caps_config.hpp+++ b/src/common/snippets/include/snippets/utils/debug_caps_config.hpp@@ -1,21 +1,20 @@// Copyright (C) 2024 Intel Corporation// SPDX-License-Identifier: Apache-2.0//+#include <cstddef>+#include <cstdint>#ifdef SNIPPETS_DEBUG_CAPS# pragma once# include <bitset># include <memory>-# include <unordered_map># include <utility># include <vector>-# include "openvino/core/except.hpp"# include "openvino/util/common_util.hpp"-namespace ov {-namespace snippets {+namespace ov::snippets {class DebugCapsConfig {private:@@ -43,6 +42,7 @@ public:};struct PropertyGroup {+ virtual ~PropertyGroup() = default;virtual std::vector<PropertySetterPtr> getPropertySetters() = 0;void parseAndSet(const std::string& str);};@@ -79,7 +79,7 @@ public:// requirment. For example, in sake of more light overhead and more accurate result, x86 CPU specific mode via read// RDTSC register is implemented, which take ~50ns, while Chrono mode take 260ns for a pair of perf count start and// perf count end execution, on ICX. This mode only support single thread.- enum PerfCountMode {+ enum PerfCountMode : uint8_t {Disabled,Chrono,BackendSpecific,@@ -91,8 +91,8 @@ private:PropertySetter(std::string name) : propertyName(std::move(name)) {}virtual ~PropertySetter() = default;virtual bool parseAndSet(const std::string& str) = 0;- virtual std::string getPropertyValueDescription() const = 0;- const std::string& getPropertyName() const {+ [[nodiscard]] virtual std::string getPropertyValueDescription() const = 0;+ [[nodiscard]] const std::string& getPropertyName() const {return propertyName;}@@ -111,7 +111,7 @@ private:property = str;return true;}- std::string getPropertyValueDescription() const override {+ [[nodiscard]] std::string getPropertyValueDescription() const override {return propertyValueDescription;}@@ -134,7 +134,7 @@ private:return true;}- std::string getPropertyValueDescription() const override {+ [[nodiscard]] std::string getPropertyValueDescription() const override {return propertyValueDescription;}@@ -170,8 +170,9 @@ private:std::find_if(propertyTokens.begin(), propertyTokens.end(), [tokenName](const Token& token) {return token.name == tokenName;});- if (foundToken == propertyTokens.end())+ if (foundToken == propertyTokens.end()) {return false;+ }for (const auto& bit : foundToken->bits) {property.set(bit, tokenVal);@@ -179,11 +180,12 @@ private:}return true;}- std::string getPropertyValueDescription() const override {+ [[nodiscard]] std::string getPropertyValueDescription() const override {std::string supportedTokens = "comma separated filter tokens: ";for (size_t i = 0; i < propertyTokens.size(); i++) {- if (i)+ if (i) {supportedTokens.push_back(',');+ }supportedTokens.append(propertyTokens[i].name);}supportedTokens.append(@@ -199,7 +201,6 @@ private:void readProperties();};-} // namespace snippets-} // namespace ov+} // namespace ov::snippets#endif // SNIPPETS_DEBUG_CAPSdiff --git a/src/common/snippets/include/snippets/utils/linear_ir_pass_dumper.hpp b/src/common/snippets/include/snippets/utils/linear_ir_pass_dumper.hppindex 7dc9262fd5b..b36cd47ef80 100644--- a/src/common/snippets/include/snippets/utils/linear_ir_pass_dumper.hpp+++ b/src/common/snippets/include/snippets/utils/linear_ir_pass_dumper.hpp@@ -3,6 +3,8 @@//#pragma once+#include <string>+#include <utility>#ifdef SNIPPETS_DEBUG_CAPS# include "openvino/util/file_util.hpp"@@ -11,8 +13,7 @@# include "snippets/lowered/pass/serialize_data_flow.hpp"# include "snippets/utils/debug_caps_config.hpp"-namespace ov {-namespace snippets {+namespace ov::snippets {class LIRPassDump {public:@@ -53,12 +54,11 @@ private:const DebugCapsConfig& debug_config;};-} // namespace snippets-} // namespace ov+} // namespace ov::snippets# define SNIPPETS_DEBUG_LIR_PASS_DUMP(_linear_ir, _pass) \- auto dumpLIR = _linear_ir.get_config().debug_config->dumpLIR; \- auto pass_name = std::string(_pass->get_type_name()); \+ auto dumpLIR = (_linear_ir).get_config().debug_config->dumpLIR; \+ auto pass_name = std::string((_pass)->get_type_name()); \auto dump_name = dumpLIR.passes; \auto dumperPtr = \((std::find(dump_name.begin(), dump_name.end(), ov::util::to_lower(pass_name)) != dump_name.end()) || \diff --git a/src/common/snippets/include/snippets/utils/loop_utils.hpp b/src/common/snippets/include/snippets/utils/loop_utils.hppindex 111a2a4da96..44d87528e59 100644--- a/src/common/snippets/include/snippets/utils/loop_utils.hpp+++ b/src/common/snippets/include/snippets/utils/loop_utils.hpp@@ -8,11 +8,12 @@*/#pragma once+#include <cstddef>++#include "snippets/lowered/expression_port.hpp"#include "snippets/lowered/loop_info.hpp"-namespace ov {-namespace snippets {-namespace utils {+namespace ov::snippets::utils {/*** @brief Updates ptr_increments and finalization offsets of the provided "loop_info" based on current work amount*/@@ -28,6 +29,4 @@ void update_runtime_parameters(const ov::snippets::lowered::UnifiedLoopInfoPtr&*/bool should_be_loop_port(const ov::snippets::lowered::ExpressionPort& port, size_t loop_id);-} // namespace utils-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippets::utilsdiff --git a/src/common/snippets/include/snippets/utils/reg_utils.hpp b/src/common/snippets/include/snippets/utils/reg_utils.hppindex 1edeeaeef7a..878d41e626a 100644--- a/src/common/snippets/include/snippets/utils/reg_utils.hpp+++ b/src/common/snippets/include/snippets/utils/reg_utils.hpp@@ -4,11 +4,13 @@#pragma once+#include <cstddef>+#include <iterator>+#include <vector>+#include "snippets/emitter.hpp"-namespace ov {-namespace snippets {-namespace utils {+namespace ov::snippets::utils {inline static std::vector<size_t> transform_snippets_regs_to_idxs(const std::vector<snippets::Reg>& regs,snippets::RegType expected_type) {std::vector<size_t> idxs;@@ -29,6 +31,4 @@ inline static std::vector<size_t> transform_snippets_regs_to_idxs(const std::vecreturn idxs;}-} // namespace utils-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippets::utilsdiff --git a/src/common/snippets/include/snippets/utils/tokenization_utils.hpp b/src/common/snippets/include/snippets/utils/tokenization_utils.hppindex 34d188bf07a..be71bbd0f48 100644--- a/src/common/snippets/include/snippets/utils/tokenization_utils.hpp+++ b/src/common/snippets/include/snippets/utils/tokenization_utils.hpp@@ -8,12 +8,14 @@*/#pragma once+#include <memory>++#include "openvino/core/node.hpp"+#include "openvino/core/node_vector.hpp"#include "snippets/op/subgraph.hpp"#include "snippets/pass/tokenization.hpp"-namespace ov {-namespace snippets {-namespace utils {+namespace ov::snippets::utils {/*** @brief Tokenizes a node into Subgraph. 2 options are possible (depending on config's values and internal logic)L* 1. The node is wrapped in a trivial Subgraph which contains only this node@@ -32,6 +34,4 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node,* @return tokenized subgraph*/std::shared_ptr<ov::snippets::op::Subgraph> tokenize_ordered_nodes(const ov::NodeVector& ordered_ops);-} // namespace utils-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippets::utilsdiff --git a/src/common/snippets/include/snippets/utils/utils.hpp b/src/common/snippets/include/snippets/utils/utils.hppindex 3036fde135e..a406ae86d0a 100644--- a/src/common/snippets/include/snippets/utils/utils.hpp+++ b/src/common/snippets/include/snippets/utils/utils.hpp@@ -8,45 +8,59 @@*/#pragma once+#include <algorithm>+#include <cstddef>+#include <cstdint>+#include <functional>+#include <iterator>+#include <limits>+#include <memory>+#include <numeric>+#include <sstream>+#include <string>+#include <type_traits>+#include <unordered_set>+#include <vector>++#include "openvino/core/dimension.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_input.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/partial_shape.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/core/type.hpp"#include "openvino/op/constant.hpp"#include "openvino/op/fake_quantize.hpp"-#include "snippets/emitter.hpp"#include "snippets/lowered/expression.hpp"#include "snippets/lowered/expression_port.hpp"#include "snippets/lowered/port_descriptor.hpp"#include "snippets/shape_types.hpp"-namespace ov {-namespace snippets {-namespace utils {+namespace ov::snippets::utils {/* --- Special values --- */-template <- typename T,- typename = typename std::enable_if<(std::is_same<T, size_t>::value || std::is_same<T, int64_t>::value), bool>::type>-constexpr inline T get_dynamic_value() {+template <typename T, typename = std::enable_if_t<(std::is_same_v<T, size_t> || std::is_same_v<T, int64_t>), bool>>+constexpr T get_dynamic_value() {return std::numeric_limits<T>::max();}-template <- typename T,- typename = typename std::enable_if<(std::is_same<T, size_t>::value || std::is_same<T, int64_t>::value), bool>::type>-constexpr inline bool is_dynamic_value(T value) {+template <typename T, typename = std::enable_if_t<(std::is_same_v<T, size_t> || std::is_same_v<T, int64_t>), bool>>+constexpr bool is_dynamic_value(T value) {return value == get_dynamic_value<T>();}// This value means full dimension// For example, for the subtensor it means that scheduling should be by full dimension-constexpr inline size_t get_full_dim_value() {+constexpr size_t get_full_dim_value() {return get_dynamic_value<size_t>() - 1;}-constexpr inline bool is_full_dim_value(size_t value) {+constexpr bool is_full_dim_value(size_t value) {return value == get_full_dim_value();}/* ---------------------- */-template <typename T,- typename = typename std::enable_if<(std::is_same<T, ov::Output<Node>>::value ||- std::is_same<T, ov::Input<Node>>::value),- void>::type>+template <+ typename T,+ typename = std::enable_if_t<(std::is_same_v<T, ov::Output<Node>> || std::is_same_v<T, ov::Input<Node>>), void>>void set_full_port_desc(const T& port, size_t rank = 2) {const auto& shape_rank = port.get_partial_shape().size();const std::vector<size_t> full_dim_subtensor(std::min(shape_rank, rank), ov::snippets::utils::get_full_dim_value());@@ -86,32 +100,36 @@ constexpr bool everyone_is(T val, P item, Args... item_others) {return val == item && everyone_is(val, item_others...);}-constexpr inline bool implication(bool cause, bool cond) {+constexpr bool implication(bool cause, bool cond) {return !cause || !!cond;}template <typename T, typename U>static inline auto div_up(const T lhs, const U rhs) -> decltype((lhs + rhs - 1) / rhs) {OPENVINO_ASSERT(rhs != 0, "Divider must not be zero");- if (((std::is_same<T, size_t>::value || std::is_same<T, int64_t>::value) && utils::is_dynamic_value(lhs)) ||- ((std::is_same<U, size_t>::value || std::is_same<U, int64_t>::value) && utils::is_dynamic_value(rhs)))+ if (((std::is_same_v<T, size_t> || std::is_same_v<T, int64_t>)&&utils::is_dynamic_value(lhs)) ||+ ((std::is_same_v<U, size_t> || std::is_same_v<U, int64_t>)&&utils::is_dynamic_value(rhs))) {return utils::get_dynamic_value<T>();+ }return (lhs + rhs - 1) / rhs;}template <typename T, typename U>static inline auto rnd_up(const T lhs, const U rhs) -> decltype(div_up(lhs, rhs) * rhs) {const T div_up_res = div_up(lhs, rhs);- if (((std::is_same<T, size_t>::value || std::is_same<T, int64_t>::value) && utils::is_dynamic_value(div_up_res)) ||- ((std::is_same<U, size_t>::value || std::is_same<U, int64_t>::value) && utils::is_dynamic_value(rhs)))+ if (((std::is_same_v<T, size_t> || std::is_same_v<T, int64_t>)&&utils::is_dynamic_value(div_up_res)) ||+ ((std::is_same_v<U, size_t> || std::is_same_v<U, int64_t>)&&utils::is_dynamic_value(rhs))) {return utils::get_dynamic_value<T>();+ }return div_up_res * rhs;}static inline bool is_planar_layout(const std::vector<size_t>& order) {- for (size_t i = 0; i < order.size(); ++i)- if (order[i] != i)+ for (size_t i = 0; i < order.size(); ++i) {+ if (order[i] != i) {return false;+ }+ }return true;}@@ -125,9 +143,7 @@ inline bool is_dynamic_vdims(const VectorDimsPtr& shape) {return is_dynamic_vdims(*shape);}-template <- typename T,- typename = typename std::enable_if<(std::is_same<T, size_t>::value || std::is_same<T, int64_t>::value), bool>::type>+template <typename T, typename = std::enable_if_t<(std::is_same_v<T, size_t> || std::is_same_v<T, int64_t>), bool>>inline T dynamic_safe_add(const T& lhs, const T& rhs) {if (utils::is_dynamic_value(lhs) || utils::is_dynamic_value(rhs)) {return utils::get_dynamic_value<T>();@@ -135,9 +151,7 @@ inline T dynamic_safe_add(const T& lhs, const T& rhs) {return lhs + rhs;}-template <- typename T,- typename = typename std::enable_if<(std::is_same<T, size_t>::value || std::is_same<T, int64_t>::value), bool>::type>+template <typename T, typename = std::enable_if_t<(std::is_same_v<T, size_t> || std::is_same_v<T, int64_t>), bool>>inline T dynamic_safe_mul(const T& lhs, const T& rhs) {if (utils::is_dynamic_value(lhs) || utils::is_dynamic_value(rhs)) {return utils::get_dynamic_value<T>();@@ -145,16 +159,12 @@ inline T dynamic_safe_mul(const T& lhs, const T& rhs) {return lhs * rhs;}-template <- typename T,- typename = typename std::enable_if<(std::is_same<T, size_t>::value || std::is_same<T, int64_t>::value), bool>::type>+template <typename T, typename = std::enable_if_t<(std::is_same_v<T, size_t> || std::is_same_v<T, int64_t>), bool>>inline std::string value2str(const T& value) {return utils::is_dynamic_value(value) ? "?" : std::to_string(value);}-template <- typename T,- typename = typename std::enable_if<(std::is_same<T, size_t>::value || std::is_same<T, int64_t>::value), bool>::type>+template <typename T, typename = std::enable_if_t<(std::is_same_v<T, size_t> || std::is_same_v<T, int64_t>), bool>>std::string vector2str(const std::vector<T>& values) {std::ostringstream str;bool first = true;@@ -175,8 +185,8 @@ bool broadcast_merge_dim(size_t& dst, const size_t& d1, const size_t& d2);// Can be used in SpecificLoopIterationHandlersbool merge_dynamic_dim(size_t& dst, const size_t& d1, const size_t& d2);-VectorDims pshape_to_vdims(const PartialShape&);-ov::PartialShape vdims_to_pshape(const VectorDims&);+VectorDims pshape_to_vdims(const PartialShape& pshape);+ov::PartialShape vdims_to_pshape(const VectorDims& vdims);inline size_t dimension_to_size_t(const ov::Dimension& dim) {return dim.is_dynamic() ? snippets::utils::get_dynamic_value<VectorDims::value_type>()@@ -291,7 +301,7 @@ VectorDims get_projected_subtensor(const snippets::lowered::ExpressionPort& expr* @return element count of input shape*/inline auto get_shape_size(const VectorDims& shape) -> size_t {- return std::accumulate(shape.begin(), shape.end(), static_cast<size_t>(1), std::multiplies<size_t>());+ return std::accumulate(shape.begin(), shape.end(), static_cast<size_t>(1), std::multiplies<>());}/**@@ -370,7 +380,7 @@ void init_strides(const VectorDims& shape, size_t rank, size_t data_size, size_t*/void visit_path(const lowered::ExpressionPtr& expr,std::unordered_set<lowered::ExpressionPtr>& visited,- std::function<void(lowered::ExpressionPtr)> func,+ const std::function<void(lowered::ExpressionPtr)>& func,bool visit_parent_path);/**@@ -382,6 +392,4 @@ void visit_path(const lowered::ExpressionPtr& expr,*/std::string tensor2str(const VectorDims& tensor, const std::string& delimiter = ", ");-} // namespace utils-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::utilsdiff --git a/src/common/snippets/src/emitter.cpp b/src/common/snippets/src/emitter.cppindex f0364bb2890..b4c27a1d3d7 100644--- a/src/common/snippets/src/emitter.cpp+++ b/src/common/snippets/src/emitter.cpp@@ -4,8 +4,12 @@#include "snippets/emitter.hpp"-namespace ov {-namespace snippets {+#include <ostream>+#include <string>++#include "openvino/core/except.hpp"++namespace ov::snippets {bool operator==(const Reg& lhs, const Reg& rhs) {return lhs.type == rhs.type && lhs.idx == rhs.idx;@@ -41,5 +45,4 @@ std::ostream& operator<<(std::ostream& s, const Reg& r) {return s;}-} // namespace snippets-} // namespace ov+} // namespace ov::snippetsdiff --git a/src/common/snippets/src/generator.cpp b/src/common/snippets/src/generator.cppindex 7dd5433c336..1acc432e7c0 100644--- a/src/common/snippets/src/generator.cpp+++ b/src/common/snippets/src/generator.cpp@@ -4,17 +4,48 @@#include "snippets/generator.hpp"+#include <memory>+#include <string>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/type.hpp"+#include "openvino/op/convert.hpp"+#include "openvino/op/logical_not.hpp"+#include "openvino/op/parameter.hpp"+#include "openvino/op/prelu.hpp"+#include "openvino/op/result.hpp"+#include "openvino/op/select.hpp"+#include "openvino/op/util/op_types.hpp"+#include "snippets/emitter.hpp"#include "snippets/itt.hpp"-#include "snippets/lowered/expression.hpp"#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/port_connector.hpp"#include "snippets/lowered/reg_manager.hpp"+#include "snippets/op/brgemm.hpp"+#include "snippets/op/broadcastload.hpp"+#include "snippets/op/broadcastmove.hpp"+#include "snippets/op/buffer.hpp"+#include "snippets/op/fill.hpp"+#include "snippets/op/horizon_max.hpp"+#include "snippets/op/horizon_sum.hpp"#include "snippets/op/kernel.hpp"-#include "snippets/op/memory_access.hpp"+#include "snippets/op/load.hpp"+#include "snippets/op/loop.hpp"+#include "snippets/op/perf_count.hpp"+#include "snippets/op/rank_normalization.hpp"+#include "snippets/op/reorder.hpp"+#include "snippets/op/reshape.hpp"+#include "snippets/op/scalar.hpp"+#include "snippets/op/store.hpp"+#include "snippets/op/vector_buffer.hpp"#include "snippets/runtime_configurator.hpp"+#include "snippets/target_machine.hpp"#include "snippets/utils/reg_utils.hpp"-namespace ov {-namespace snippets {+namespace ov::snippets {LoweringResult Generator::generate(const lowered::LinearIRPtr& linear_ir, const void* compile_params) const {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::Generator::generate")@@ -40,7 +71,7 @@ LoweringResult Generator::generate(const lowered::LinearIRPtr& linear_ir, constutils::transform_snippets_regs_to_idxs(reg_manager.get_gp_regs_except_kernel_call(kernel_op)));OV_ITT_TASK_NEXT(GENERATE, "::EmitData")- for (auto& l : linear_ir->get_ops()) {+ for (const auto& l : linear_ir->get_ops()) {l->get_emitter()->emit_data();}OV_ITT_TASK_NEXT(GENERATE, "::GetSnippet")@@ -51,16 +82,18 @@ LoweringResult Generator::generate(const lowered::LinearIRPtr& linear_ir, const// 3. Emitters with segfault detector debug capabilty also need to be accessible at runtime.for (const auto& expr : *linear_ir) {const auto& emitter = expr->get_emitter();- if (uses_precompiled_kernel(emitter))+ if (uses_precompiled_kernel(emitter)) {result.m_saved_emitters.emplace_back(emitter);+ }}result.compiled_snippet = target->get_snippet();result.kernel_executor_table = target->get_runtime_configurator()->get_kernel_executor_table();// In static case some kernel executors might've been registered during code emission.// We need to update them, so appropriate kernels will be compiled.// In dynamic case it should be handled by RuntimeConfigurator- if (!linear_ir->is_dynamic())+ if (!linear_ir->is_dynamic()) {result.kernel_executor_table->update_state(linear_ir);+ }return result;}@@ -71,8 +104,9 @@ std::shared_ptr<const TargetMachine> Generator::get_target_machine() const {RegType Generator::get_op_out_reg_type(const ov::Output<Node>& out) const {auto reg_type = get_specific_op_out_reg_type(out);- if (reg_type != RegType::undefined)+ if (reg_type != RegType::undefined) {return reg_type;+ }const auto op = out.get_node_shared_ptr();if (is_type_any_of<ov::op::v0::Parameter,ov::op::v0::Result,@@ -89,24 +123,23 @@ RegType Generator::get_op_out_reg_type(const ov::Output<Node>& out) const {#endif)return RegType::gpr;- else if (ov::op::util::is_unary_elementwise_arithmetic(op) || ov::op::util::is_binary_elementwise_arithmetic(op) ||- ov::op::util::is_binary_elementwise_comparison(op) || ov::op::util::is_binary_elementwise_logical(op) ||- is_type_any_of<snippets::op::Load,- snippets::op::BroadcastLoad,- ov::op::v1::LogicalNot,- ov::op::v0::PRelu,- ov::op::v0::Convert,- ov::op::v1::Select,- op::VectorBuffer,- op::BroadcastMove,- op::Scalar,- op::HorizonMax,- op::HorizonSum,- op::Fill>(op))+ if (ov::op::util::is_unary_elementwise_arithmetic(op) || ov::op::util::is_binary_elementwise_arithmetic(op) ||+ ov::op::util::is_binary_elementwise_comparison(op) || ov::op::util::is_binary_elementwise_logical(op) ||+ is_type_any_of<snippets::op::Load,+ snippets::op::BroadcastLoad,+ ov::op::v1::LogicalNot,+ ov::op::v0::PRelu,+ ov::op::v0::Convert,+ ov::op::v1::Select,+ op::VectorBuffer,+ op::BroadcastMove,+ op::Scalar,+ op::HorizonMax,+ op::HorizonSum,+ op::Fill>(op)) {return RegType::vec;- else- OPENVINO_THROW("Register type of the operation " + std::string(op->get_type_name()) + " isn't determined!");- return reg_type;+ }+ OPENVINO_THROW("Register type of the operation " + std::string(op->get_type_name()) + " isn't determined!");}RegType Generator::get_specific_op_out_reg_type(const ov::Output<Node>& out) const {@@ -114,5 +147,4 @@ RegType Generator::get_specific_op_out_reg_type(const ov::Output<Node>& out) con" isn't determined!");}-} // namespace snippets-} // namespace ov+} // namespace ov::snippetsdiff --git a/src/common/snippets/src/kernel_executor_table.cpp b/src/common/snippets/src/kernel_executor_table.cppindex be406a6f9d8..aa2f723f141 100644--- a/src/common/snippets/src/kernel_executor_table.cpp+++ b/src/common/snippets/src/kernel_executor_table.cpp@@ -4,8 +4,11 @@#include "snippets/kernel_executor_table.hpp"-namespace ov {-namespace snippets {+#include <utility>++#include "openvino/core/except.hpp"++namespace ov::snippets {void KernelExecutorTable::reset_state(const ExecTableState& state) {OPENVINO_ASSERT(state.size() == m_table.size(), "Invalid state in restore_state: size mismatch");@@ -22,10 +25,10 @@ KernelExecutorTable::ExecTableState KernelExecutorTable::get_state() const {ExecTableState result;// Note: we need to clone configs when saving the state, since the configs still stored in the table can// be modified e.g. by calling update_by_expression();- for (const auto& record : m_table)+ for (const auto& record : m_table) {result.emplace_back(std::make_pair(record.first, record.second->get_config().get_clone_ptr()));+ }return result;}-} // namespace snippets-} // namespace ov+} // namespace ov::snippetsdiff --git a/src/common/snippets/src/lowered/expression.cpp b/src/common/snippets/src/lowered/expression.cppindex ff0da7fa73a..15fde35f703 100644--- a/src/common/snippets/src/lowered/expression.cpp+++ b/src/common/snippets/src/lowered/expression.cpp@@ -5,23 +5,35 @@#include "snippets/lowered/expression.hpp"#include <cassert>--#include "openvino/core/graph_util.hpp"-#include "openvino/core/type.hpp"+#include <cstddef>+#include <exception>+#include <memory>+#include <sstream>+#include <string>+#include <unordered_set>+#include <utility>+#include <vector>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/partial_shape.hpp"+#include "snippets/emitter.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/port_connector.hpp"+#include "snippets/lowered/port_descriptor.hpp"+#include "snippets/shape_inference/shape_inference.hpp"+#include "snippets/shape_types.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {+namespace ov::snippets::lowered {Expression::Expression(const std::shared_ptr<Node>& n,const std::shared_ptr<IShapeInferSnippetsFactory>& factory,bool need_shape_infer): m_source_node{n},m_emitter{nullptr},- m_input_port_connectors{},- m_output_port_connectors{},+m_shapeInference(make_shape_inference(n, factory)),m_need_shape_infer(need_shape_infer) {m_input_port_descriptors.reserve(n->get_input_size());@@ -57,8 +69,9 @@ const PortDescriptorPtr& Expression::get_output_port_descriptor(size_t i) const}std::shared_ptr<Node> Expression::get_node() const {- if (!m_source_node)+ if (!m_source_node) {OPENVINO_THROW("An attempt to get uninitialized node from lowered expression");+ }return m_source_node;}@@ -70,10 +83,12 @@ RegInfo Expression::get_reg_info() const {RegInfo reg_info;reg_info.first.reserve(m_input_port_descriptors.size());reg_info.second.reserve(m_output_port_descriptors.size());- for (const auto& port : m_input_port_descriptors)+ for (const auto& port : m_input_port_descriptors) {reg_info.first.push_back(port->get_reg());- for (const auto& port : m_output_port_descriptors)+ }+ for (const auto& port : m_output_port_descriptors) {reg_info.second.push_back(port->get_reg());+ }return reg_info;}@@ -102,8 +117,9 @@ void Expression::set_input_port_connector(size_t port, PortConnectorPtr to) {OPENVINO_ASSERT(port < get_input_count(),"Failed to set input PortConnector: target input port must be less than input count!");const auto& from = get_input_port_connector(port);- if (from == to)+ if (from == to) {return;+ }const auto input_port = get_input_port(port);if (!to->found_consumer(input_port)) {@@ -129,8 +145,9 @@ ExpressionPtr Expression::clone_with_new_inputs(const std::shared_ptr<Node>& newconst std::vector<PortDescriptorPtr>& new_in_descs) const {auto clone_ports_descriptors = [](const std::vector<PortDescriptorPtr>& src) {std::vector<PortDescriptorPtr> dst(src.size());- for (size_t i = 0; i < src.size(); i++)+ for (size_t i = 0; i < src.size(); i++) {dst[i] = src[i]->clone();+ }return dst;};const auto& cloned = clone();@@ -147,14 +164,16 @@ ExpressionPtr Expression::clone_with_new_inputs(const std::shared_ptr<Node>& newfor (size_t i = 0; i < cloned->m_input_port_connectors.size(); i++) {const auto& i_con = cloned->m_input_port_connectors[i];const auto& i_port = cloned->get_input_port(i);- if (!i_con->found_consumer(i_port))+ if (!i_con->found_consumer(i_port)) {i_con->add_consumer(i_port);+ }}cloned->m_output_port_descriptors = clone_ports_descriptors(m_output_port_descriptors);OPENVINO_ASSERT(cloned->m_output_port_connectors.size() == cloned->m_output_port_descriptors.size(),"Can't create Expression with new inputs: output port attributes are not compatible");- for (size_t i = 0; i < cloned->m_output_port_descriptors.size(); i++)+ for (size_t i = 0; i < cloned->m_output_port_descriptors.size(); i++) {cloned->m_output_port_connectors[i] = std::make_shared<PortConnector>(cloned->get_output_port(i));+ }cloned->validate();return cloned;@@ -178,7 +197,7 @@ ExpressionPtr Expression::clone_with_new_inputs(const ExpressionMap& expr_map,}ExpressionPtr Expression::clone() const {- return std::shared_ptr<Expression>(new Expression(*this));+ return std::make_shared<Expression>(*this);}bool Expression::visit_attributes(AttributeVisitor& visitor) {@@ -189,32 +208,38 @@ bool Expression::visit_attributes(AttributeVisitor& visitor) {for (size_t i = 0; i < get_input_count(); i++) {const auto& desc = m_input_port_descriptors[i];const auto& shape = desc->get_shape();- if (!shape.empty())+ if (!shape.empty()) {shapes.emplace_back("in_shape_" + std::to_string(i), ov::PartialShape(shape));+ }const auto& subtensor = desc->get_subtensor();- if (!subtensor.empty())+ if (!subtensor.empty()) {subtensors.emplace_back("in_subtensor_" + std::to_string(i), utils::tensor2str(subtensor));+ }const auto& layout = desc->get_layout();- if (!layout.empty() && !utils::is_planar_layout(layout))+ if (!layout.empty() && !utils::is_planar_layout(layout)) {layouts.emplace_back("in_layout_" + std::to_string(i), layout);+ }in_regs << desc->get_reg() << " ";}for (size_t i = 0; i < get_output_count(); i++) {const auto& desc = m_output_port_descriptors[i];const auto& shape = desc->get_shape();- if (!shape.empty())+ if (!shape.empty()) {shapes.emplace_back("out_shape_" + std::to_string(i), ov::PartialShape(shape));+ }const auto& subtensor = desc->get_subtensor();- if (!subtensor.empty())+ if (!subtensor.empty()) {subtensors.emplace_back("out_subtensor_" + std::to_string(i), utils::tensor2str(subtensor));+ }const auto& layout = desc->get_layout();- if (!layout.empty() && !utils::is_planar_layout(layout))+ if (!layout.empty() && !utils::is_planar_layout(layout)) {layouts.emplace_back("out_layout_" + std::to_string(i), layout);+ }out_regs << desc->get_reg() << " ";}@@ -227,12 +252,15 @@ bool Expression::visit_attributes(AttributeVisitor& visitor) {std::vector<std::string> tmp{out_regs.str()};visitor.on_attribute("out_regs", tmp);}- for (auto& s : shapes)+ for (auto& s : shapes) {visitor.on_attribute(s.first, s.second);- for (auto& s : subtensors)+ }+ for (auto& s : subtensors) {visitor.on_attribute(s.first, s.second);- for (auto& s : layouts)+ }+ for (auto& s : layouts) {visitor.on_attribute(s.first, s.second);+ }visitor.on_attribute("loop_ids", m_loop_ids);visitor.on_attribute("execution_number", m_exec_num);m_source_node->visit_attributes(visitor);@@ -286,10 +314,9 @@ void Expression::updateShapes() {"Shape inference of " + (m_source_node->get_friendly_name()) + " didn't return success status");OPENVINO_ASSERT(result.dims.size() == m_output_port_descriptors.size(),"shapeInference call returned invalid number of output shapes");- for (size_t i = 0; i < m_output_port_descriptors.size(); i++)+ for (size_t i = 0; i < m_output_port_descriptors.size(); i++) {m_output_port_descriptors[i]->set_shape(result.dims[i]);+ }}-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/src/lowered/expression_factory.cpp b/src/common/snippets/src/lowered/expression_factory.cppindex db1fb715a53..a66e67092e9 100644--- a/src/common/snippets/src/lowered/expression_factory.cpp+++ b/src/common/snippets/src/lowered/expression_factory.cpp@@ -4,36 +4,61 @@#include "snippets/lowered/expression_factory.hpp"-#include "snippets/snippets_isa.hpp"--namespace ov {-namespace snippets {-namespace lowered {+#include <algorithm>+#include <cstddef>+#include <memory>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/type.hpp"+#include "openvino/op/parameter.hpp"+#include "openvino/op/result.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/expression_port.hpp"+#include "snippets/lowered/expressions/buffer_expression.hpp"+#include "snippets/lowered/port_connector.hpp"+#include "snippets/lowered/port_descriptor.hpp"+#include "snippets/op/buffer.hpp"+#include "snippets/op/loop.hpp"+#include "snippets/op/perf_count.hpp"+#include "snippets/op/reg_spill.hpp"+#include "snippets/shape_inference/shape_inference.hpp"++namespace ov::snippets::lowered {template <>std::shared_ptr<Expression> ExpressionFactory::build(const std::shared_ptr<Node>& n,const std::vector<PortConnectorPtr>& inputs) {if (const auto par = ov::as_type_ptr<ov::op::v0::Parameter>(n)) {return create(par, inputs, m_shape_infer_factory);- } else if (const auto res = ov::as_type_ptr<ov::op::v0::Result>(n)) {+ }+ if (const auto res = ov::as_type_ptr<ov::op::v0::Result>(n)) {return create(res, inputs, m_shape_infer_factory);- } else if (const auto loop_begin = ov::as_type_ptr<op::LoopBegin>(n)) {+ }+ if (const auto loop_begin = ov::as_type_ptr<op::LoopBegin>(n)) {return create(loop_begin, inputs, m_shape_infer_factory);- } else if (const auto loop_end = ov::as_type_ptr<op::LoopEnd>(n)) {+ }+ if (const auto loop_end = ov::as_type_ptr<op::LoopEnd>(n)) {return create(loop_end, inputs, m_shape_infer_factory);- } else if (const auto spill_begin = ov::as_type_ptr<op::RegSpillBegin>(n)) {+ }+ if (const auto spill_begin = ov::as_type_ptr<op::RegSpillBegin>(n)) {return create(spill_begin, inputs, m_shape_infer_factory);- } else if (const auto spill_end = ov::as_type_ptr<op::RegSpillEnd>(n)) {+ }+ if (const auto spill_end = ov::as_type_ptr<op::RegSpillEnd>(n)) {return create(spill_end, inputs, m_shape_infer_factory);- } else if (const auto buffer = ov::as_type_ptr<op::Buffer>(n)) {+ }+ if (const auto buffer = ov::as_type_ptr<op::Buffer>(n)) {return create<BufferExpression>(buffer, inputs, m_shape_infer_factory);+ }#ifdef SNIPPETS_DEBUG_CAPS- } else if (const auto perf_counter = ov::as_type_ptr<op::PerfCountBeginBase>(n)) {+ if (const auto perf_counter = ov::as_type_ptr<op::PerfCountBeginBase>(n)) {return create(perf_counter, inputs, m_shape_infer_factory);- } else if (const auto perf_counter = ov::as_type_ptr<op::PerfCountEndBase>(n)) {+ }+ if (const auto perf_counter = ov::as_type_ptr<op::PerfCountEndBase>(n)) {return create(perf_counter, inputs, m_shape_infer_factory);-#endif}+#endifreturn create(n, inputs, m_shape_infer_factory);}@@ -128,8 +153,9 @@ ExpressionPtr ExpressionFactory::create(const std::shared_ptr<op::RegSpillBegin>OPENVINO_ASSERT(inputs.empty(), "RegSpillBegin expression expects no inputs");const auto num_to_spill = n->get_regs_to_spill().size();expr->m_output_port_descriptors.resize(num_to_spill, nullptr);- for (size_t i = 0; i < num_to_spill; i++)+ for (size_t i = 0; i < num_to_spill; i++) {expr->m_output_port_descriptors[i] = std::make_shared<PortDescriptor>();+ }expr->m_output_port_connectors.resize(num_to_spill, nullptr);for (size_t i = 0; i < num_to_spill; i++) {const auto source = expr->get_output_port(i);@@ -179,6 +205,4 @@ ExpressionPtr ExpressionFactory::create_without_connections(}#endif-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/src/lowered/expression_port.cpp b/src/common/snippets/src/lowered/expression_port.cppindex 85c08d81423..49349aaa60c 100644--- a/src/common/snippets/src/lowered/expression_port.cpp+++ b/src/common/snippets/src/lowered/expression_port.cpp@@ -5,12 +5,16 @@#include "snippets/lowered/expression_port.hpp"#include <cassert>+#include <cstddef>+#include <memory>+#include <set>+#include <utility>-#include "snippets/utils/utils.hpp"+#include "openvino/core/except.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/port_descriptor.hpp"-namespace ov {-namespace snippets {-namespace lowered {+namespace ov::snippets::lowered {ExpressionPort::ExpressionPort(const std::shared_ptr<Expression>& expr, Type type, size_t port): m_expr(expr),@@ -57,8 +61,9 @@ void ExpressionPort::replace_input_port_connector(std::shared_ptr<PortConnector>}bool operator==(const ExpressionPort& lhs, const ExpressionPort& rhs) {- if (&lhs == &rhs)+ if (&lhs == &rhs) {return true;+ }OPENVINO_ASSERT(lhs.get_type() == rhs.get_type(), "Incorrect ExpressionPort comparison");return lhs.get_index() == rhs.get_index() && lhs.get_expr() == rhs.get_expr();}@@ -78,6 +83,4 @@ void replace_input_port_connectors(const std::set<ExpressionPort>& consumers,}}-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/src/lowered/expressions/buffer_expression.cpp b/src/common/snippets/src/lowered/expressions/buffer_expression.cppindex 1f31fb93970..14188cdf6ce 100644--- a/src/common/snippets/src/lowered/expressions/buffer_expression.cpp+++ b/src/common/snippets/src/lowered/expressions/buffer_expression.cpp@@ -4,12 +4,26 @@#include "snippets/lowered/expressions/buffer_expression.hpp"+#include <algorithm>+#include <cstddef>+#include <memory>+#include <set>+#include <vector>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/loop_manager.hpp"+#include "snippets/lowered/loop_port.hpp"#include "snippets/op/buffer.hpp"+#include "snippets/shape_inference/shape_inference.hpp"+#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {+namespace ov::snippets::lowered {BufferExpression::BufferExpression(const std::shared_ptr<Node>& n,const std::shared_ptr<IShapeInferSnippetsFactory>& factory)@@ -20,7 +34,7 @@ BufferExpression::BufferExpression(const std::shared_ptr<Node>& n,}ExpressionPtr BufferExpression::clone() const {- return std::shared_ptr<BufferExpression>(new BufferExpression(*this));+ return std::make_shared<BufferExpression>(*this);}bool BufferExpression::visit_attributes(AttributeVisitor& visitor) {@@ -45,8 +59,9 @@ ov::element::Type BufferExpression::get_data_type() const {}size_t BufferExpression::get_byte_size() const {- if (is_defined())+ if (is_defined()) {return m_allocation_size * get_data_type().size();+ }return utils::get_dynamic_value<size_t>();}@@ -55,9 +70,10 @@ std::vector<size_t> get_parent_inner_loops(const std::vector<size_t>& parent_looconst std::vector<size_t>& current_loops) {const auto common_rank = std::min(parent_loops.size(), current_loops.size());size_t i = 0;- while (i < common_rank && parent_loops[i] == current_loops[i])+ while (i < common_rank && parent_loops[i] == current_loops[i]) {++i;- return std::vector<size_t>(parent_loops.cbegin() + i, parent_loops.cend());+ }+ return {parent_loops.cbegin() + i, parent_loops.cend()};}} // namespace@@ -72,7 +88,7 @@ void BufferExpression::init_allocation_size(const std::shared_ptr<LoopManager>&const auto planar_shape = utils::get_preordered_vdims(parent_port);OPENVINO_ASSERT(allocation_rank > 0, "Allocation size must be positive");- const size_t rank = std::min(static_cast<size_t>(allocation_rank), planar_shape.size());+ const size_t rank = std::min(allocation_rank, planar_shape.size());const auto& subtensor = ov::snippets::utils::get_projected_subtensor(parent_port);@@ -83,17 +99,16 @@ void BufferExpression::init_allocation_size(const std::shared_ptr<LoopManager>&const auto& port = *loop_port.get_expr_port();// Check semantic of LoopPortif (parent_port.get_index() != port.get_index() ||- port.get_expr()->get_node()->get_type_info() != parent_port.get_expr()->get_node()->get_type_info())+ port.get_expr()->get_node()->get_type_info() != parent_port.get_expr()->get_node()->get_type_info()) {return false;+ }// Check that this LoopPort is connected to the same by semantic Bufferconst auto consumers = port.get_connected_ports();- for (const auto& consumer : consumers) {- if (const auto buffer_consumer = ov::as_type_ptr<BufferExpression>(consumer.get_expr())) {- if (buffer_consumer->get_cluster_id() == m_cluster_id && consumer.get_index() == buffer_in_idx)- return true;- }- }- return false;+ return std::any_of(consumers.begin(), consumers.end(), [&](const auto& consumer) {+ const auto buffer_consumer = ov::as_type_ptr<BufferExpression>(consumer.get_expr());+ return buffer_consumer && buffer_consumer->get_cluster_id() == m_cluster_id &&+ consumer.get_index() == buffer_in_idx;+ });};m_allocation_size = 1;@@ -110,18 +125,20 @@ void BufferExpression::init_allocation_size(const std::shared_ptr<LoopManager>&"compute_allocation_shape: output port of parent loop can not be found");}const auto& loop_port = *it;- if (!loop_port.is_processed())+ if (!loop_port.is_processed()) {continue;+ }const auto& dim_idx = loop_port.get_dim_idx();if (dim_idx < rank) {- if (const auto& unified_loop_info = ov::as_type_ptr<UnifiedLoopInfo>(loop_info))+ if (const auto& unified_loop_info = ov::as_type_ptr<UnifiedLoopInfo>(loop_info)) {m_allocation_size = utils::dynamic_safe_mul(m_allocation_size, unified_loop_info->get_work_amount());- else if (const auto& expanded_loop_info = ov::as_type_ptr<ExpandedLoopInfo>(loop_info))+ } else if (const auto& expanded_loop_info = ov::as_type_ptr<ExpandedLoopInfo>(loop_info)) {m_allocation_size =utils::dynamic_safe_mul(m_allocation_size,expanded_loop_info->get_unified_loop_info()->get_work_amount());- else+ } else {OPENVINO_THROW("Unknown LoopInfo type");+ }processed_dim_idxs.insert(dim_idx);}}@@ -142,6 +159,4 @@ void BufferExpression::init_allocation_size(const std::shared_ptr<LoopManager>&}}-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/src/lowered/linear_ir.cpp b/src/common/snippets/src/lowered/linear_ir.cppindex ceae35b8e2a..5191695ab3f 100644--- a/src/common/snippets/src/lowered/linear_ir.cpp+++ b/src/common/snippets/src/lowered/linear_ir.cpp@@ -4,23 +4,49 @@#include "snippets/lowered/linear_ir.hpp"+#include <algorithm>+#include <cassert>+#include <cstddef>+#include <cstdint>+#include <cstdlib>+#include <iostream>+#include <iterator>+#include <limits>+#include <map>+#include <memory>+#include <set>+#include <utility>+#include <vector>++#include "openvino/core/except.hpp"#include "openvino/core/graph_util.hpp"+#include "openvino/core/model.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_vector.hpp"#include "openvino/core/type.hpp"+#include "openvino/op/parameter.hpp"+#include "openvino/op/result.hpp"+#include "snippets/emitter.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression.hpp"#include "snippets/lowered/expression_factory.hpp"+#include "snippets/lowered/expression_port.hpp"+#include "snippets/lowered/expressions/buffer_expression.hpp"#include "snippets/lowered/loop_manager.hpp"-#include "snippets/op/subgraph.hpp"+#include "snippets/lowered/port_connector.hpp"+#include "snippets/lowered/port_descriptor.hpp"+#include "snippets/op/brgemm.hpp"+#include "snippets/op/scalar.hpp"+#include "snippets/shape_inference/shape_infer_instances.hpp"+#include "snippets/shape_inference/shape_inference.hpp"+#include "snippets/shape_types.hpp"+#include "snippets/target_machine.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {+namespace ov::snippets::lowered {LinearIR::LinearIR(Config config, const std::shared_ptr<IShapeInferSnippetsFactory>& factory)- : m_expressions{},- m_parameter_expressions{},- m_result_expressions{},- m_config(std::move(config)),+ : m_config(std::move(config)),m_loop_manager(std::make_shared<LoopManager>()),m_shape_infer_factory(factory),m_shape_infer(std::make_shared<LIRShapeInfer>(m_expressions, m_parameter_expressions, m_result_expressions)),@@ -29,10 +55,10 @@ LinearIR::LinearIR(Config config, const std::shared_ptr<IShapeInferSnippetsFactoLinearIR::LinearIR(const std::shared_ptr<ov::Model>& model,const std::shared_ptr<IShapeInferSnippetsFactory>& factory,Config config)- : LinearIR(config, factory) {- constExprIt last_param = m_expressions.end();+ : LinearIR(std::move(config), factory) {+ auto last_param = m_expressions.end();for (const auto& n : get_ordered_ops(model)) {- constExprIt insertion_pos = m_expressions.end();+ auto insertion_pos = m_expressions.end();const auto expr = get_expr_factory()->build(n, get_expression_inputs_by_node(n));// Scalar should be on the Linear IR beginning after Parameters to have valid expression order after Loop@@ -44,13 +70,16 @@ LinearIR::LinearIR(const std::shared_ptr<ov::Model>& model,register_expression(expr, true, 0);const auto& it = m_expressions.insert(insertion_pos, expr);- if (ov::is_type<ov::op::v0::Parameter>(n))+ if (ov::is_type<ov::op::v0::Parameter>(n)) {last_param = it;+ }}- for (const auto& param_expr : m_parameter_expressions)+ for (const auto& param_expr : m_parameter_expressions) {m_is_dynamic = m_is_dynamic || utils::is_dynamic_vdims(param_expr->get_output_port_descriptor(0)->get_shape());- for (const auto& result_expr : m_result_expressions)+ }+ for (const auto& result_expr : m_result_expressions) {m_is_dynamic = m_is_dynamic || utils::is_dynamic_vdims(result_expr->get_input_port_descriptor(0)->get_shape());+ }enumerate_expressions();}@@ -79,8 +108,9 @@ void update_consumers_and_regs(const ExpressionPtr& new_expr, const std::vector<for (size_t i = 0; i < consumers.size(); ++i) {const auto& port_consumers = consumers[i];replace_input_port_connectors(port_consumers, new_expr->get_output_port_connector(i));- if (!port_consumers.empty())+ if (!port_consumers.empty()) {new_expr->get_output_port_descriptor(i)->set_reg(port_consumers.cbegin()->get_descriptor_ptr()->get_reg());+ }}for (size_t i = 0; i < new_expr->get_input_count(); ++i) {new_expr->get_input_port_descriptor(i)->set_reg(@@ -105,8 +135,9 @@ ExpressionPtr LinearIR::create_expression(const std::shared_ptr<Node>& n,}ov::NodeVector LinearIR::get_ordered_ops(const std::shared_ptr<ov::Model>& m) {- if (!m->get_sinks().empty())+ if (!m->get_sinks().empty()) {OPENVINO_THROW("Linear IR is not supposed to work for model with sinks. Check your transformation pipeline.");+ }// Note that an important difference between this impl and Model::get_ordered_ops is that Results and Parameters// are added in REVERSE order, so they will be visited in DIRECT order compared to get_parameters() and@@ -127,11 +158,13 @@ bool LinearIR::is_dynamic() const {void LinearIR::debug_print(bool tds_as_pointers) const {auto print_rinfo = [](const RegInfo& rinfo) {std::cerr << " : {";- for (auto i : rinfo.first)+ for (auto i : rinfo.first) {std::cerr << i << " ";+ }std::cerr << " => ";- for (auto i : rinfo.second)+ for (auto i : rinfo.second) {std::cerr << i << " ";+ }std::cerr << "}";};std::map<PortConnectorPtr, int> td2int;@@ -142,27 +175,32 @@ void LinearIR::debug_print(bool tds_as_pointers) const {std::cerr << counter++ << " : " << node->get_friendly_name() << " : ";if (tds_as_pointers) {for (const auto& in : expr->m_input_port_connectors) {- if (td2int.count(in) == 0)+ if (td2int.count(in) == 0) {OPENVINO_THROW("Undefined input descriptor for op");+ }std::cerr << td2int.at(in) << ", ";}std::cerr << "\b\b => ";for (const auto& out : expr->m_output_port_connectors) {- if (td2int.count(out) == 0)+ if (td2int.count(out) == 0) {td2int.insert({out, td_counter++});+ }std::cerr << td2int.at(out) << ", ";}} else {- for (const auto& port_desc : expr->m_input_port_descriptors)+ for (const auto& port_desc : expr->m_input_port_descriptors) {std::cerr << port_desc << ", ";+ }std::cerr << "\b\b => ";- for (const auto& port_desc : expr->m_output_port_descriptors)+ for (const auto& port_desc : expr->m_output_port_descriptors) {std::cerr << port_desc << ", ";+ }}std::cerr << "\b\b";const auto& rinfo = expr->get_reg_info();- if (!rinfo.first.empty() || !rinfo.second.empty())+ if (!rinfo.first.empty() || !rinfo.second.empty()) {print_rinfo(expr->get_reg_info());+ }std::cerr << "\n";}}@@ -190,12 +228,15 @@ void LinearIR::register_expression(const ExpressionPtr& expr, bool io_allowed, dconst auto& res = m_node2expression_map.insert({node, expr});OPENVINO_ASSERT(res.second, "Duplicate node is detected in linear IR: ", node);- if (ov::is_type<ov::op::v0::Parameter>(node))+ if (ov::is_type<ov::op::v0::Parameter>(node)) {m_parameter_expressions.push_back(expr);- if (ov::is_type<ov::op::v0::Result>(node))+ }+ if (ov::is_type<ov::op::v0::Result>(node)) {m_result_expressions.push_back(expr);- if (const auto buffer_expr = ov::as_type_ptr<BufferExpression>(expr))+ }+ if (const auto buffer_expr = ov::as_type_ptr<BufferExpression>(expr)) {m_buffer_expressions.push_back(buffer_expr);+ }expr->m_exec_num = exec_num;}@@ -228,15 +269,14 @@ LinearIR::exprIt LinearIR::insert(constExprIt pos, const container::value_type&}LinearIR::exprIt LinearIR::insert(constExprIt pos, exprIt begin, exprIt end) {- constExprIt cbegin = begin;- constExprIt cend = end;- return insert(pos, cbegin, cend);+ return insert(pos, static_cast<constExprIt>(begin), static_cast<constExprIt>(end));}LinearIR::exprIt LinearIR::insert(constExprIt pos, constExprIt begin, constExprIt end) {// nothing to insert- if (begin == end)+ if (begin == end) {return m_expressions.erase(pos, pos); // to convert constExprIt to exprIt+ }const auto count = std::distance(begin, end);auto ret = m_expressions.end();for (auto b = begin; b != end; b++) {@@ -248,11 +288,13 @@ LinearIR::exprIt LinearIR::insert(constExprIt pos, constExprIt begin, constExprILinearIR::exprIt LinearIR::insert(LinearIR::constExprIt pos, const NodeVector& nodes) {// nothing to insert- if (nodes.empty())+ if (nodes.empty()) {return m_expressions.erase(pos, pos); // to convert constExprIt to exprIt+ }auto ret = m_expressions.end();- for (const auto& n : nodes)+ for (const auto& n : nodes) {ret = insert(pos, n);+ }// Need to return iterator to the first of the inserted valuesreturn std::prev(ret, static_cast<int64_t>(nodes.size()) - 1);}@@ -274,8 +316,9 @@ LinearIR::exprIt LinearIR::erase(LinearIR::constExprIt pos) {}void LinearIR::move(LinearIR::constExprIt from, LinearIR::constExprIt to) {- if (from == std::prev(to))+ if (from == std::prev(to)) {return;+ }// Instead of `insert()` + `erase()`, we use `splice()` for the same list(*from)->m_exec_num = get_inserted_expr_exec_num(to);m_expressions.splice(to, m_expressions, from);@@ -334,12 +377,12 @@ VectorDims LinearIR::get_master_shape() const {template <>LinearIR::exprIt LinearIR::insert_node(const std::shared_ptr<ov::Node>& new_node,- const std::vector<PortConnectorPtr>& new_inputs,+ const std::vector<PortConnectorPtr>& args,const std::vector<size_t>& loop_ids,bool update_loop_ports,const constExprIt& place,const std::vector<std::set<ExpressionPort>>& consumers) {- const auto new_expr = create_expression(new_node, new_inputs, loop_ids, update_loop_ports, consumers);+ const auto new_expr = create_expression(new_node, args, loop_ids, update_loop_ports, consumers);const auto expr_it = insert(place, new_expr);get_loop_manager()->sort_loop_ports(loop_ids);return expr_it;@@ -368,8 +411,9 @@ LinearIR::exprIt LinearIR::insert_expr(const ExpressionPtr& new_expr,new_expr->set_loop_ids(loop_ids);const auto expr_it = insert(place, new_expr);- if (update_loop_ports)+ if (update_loop_ports) {get_loop_manager()->update_loop_ports(new_expr);+ }return expr_it;}@@ -389,11 +433,12 @@ LinearIR::exprIt LinearIR::replace_with_node(const std::vector<ExpressionPtr>& onew_inputs[i] = get_expr_by_node(source.get_node_shared_ptr())->get_output_port_connector(source.get_index());}- const auto last_old_expr = old_exprs.back();- for (size_t i = 0; i < new_node->get_output_size(); ++i)+ const auto& last_old_expr = old_exprs.back();+ for (size_t i = 0; i < new_node->get_output_size(); ++i) {snippets::lowered::PortDescriptorUtils::set_port_descriptor_ptr(new_node->output(i),last_old_expr->get_output_port_descriptor(0)->clone());+ }const auto new_expr = create_expression(new_node, new_inputs, loop_ids, false);return replace_with_expr(old_exprs, new_expr, place);@@ -523,32 +568,36 @@ void LinearIR::enumerate_expressions() const {}double LinearIR::get_inserted_expr_exec_num(constExprIt insertion_pos) const {- if (empty())+ if (empty()) {return 0;+ }const auto& right_pos = insertion_pos;const auto& left_pos = std::prev(insertion_pos);double left_order = 0, right_order = 0;if (right_pos == cbegin()) { // On the list begin- if (right_pos->get()->get_exec_num() == -1 * std::numeric_limits<double>::max())+ if (right_pos->get()->get_exec_num() == -1 * std::numeric_limits<double>::max()) {enumerate_expressions();+ }return right_pos->get()->get_exec_num() - 1;- } else if (right_pos == cend()) { // On the list end- if (left_pos->get()->get_exec_num() == std::numeric_limits<double>::max())+ }+ if (right_pos == cend()) { // On the list end+ if (left_pos->get()->get_exec_num() == std::numeric_limits<double>::max()) {enumerate_expressions();+ }return left_pos->get()->get_exec_num() + 1;- } else { // In the list middle+ } // In the list middle+ left_order = left_pos->get()->get_exec_num();+ right_order = right_pos->get()->get_exec_num();+ OPENVINO_ASSERT(right_order > left_order, "Incorrect expression enumeration!");++ // sync point to enumerate expressions+ // 10 * eps - is to avoid meaningless result after (right_order + left_order) / 2 below+ if (std::abs(1 - left_order / right_order) <= 10 * std::numeric_limits<double>::epsilon()) {+ enumerate_expressions();left_order = left_pos->get()->get_exec_num();right_order = right_pos->get()->get_exec_num();- OPENVINO_ASSERT(right_order > left_order, "Incorrect expression enumeration!");-- // sync point to enumerate expressions- // 10 * eps - is to avoid meaningless result after (right_order + left_order) / 2 below- if (std::abs(1 - left_order / right_order) <= 10 * std::numeric_limits<double>::epsilon()) {- enumerate_expressions();- left_order = left_pos->get()->get_exec_num();- right_order = right_pos->get()->get_exec_num();- }}+// to avoid possible oveflow in (right_order + left_order) / 2;return left_order + (right_order - left_order) / 2;}@@ -579,12 +628,14 @@ IShapeInferSnippets::Result LinearIR::LIRShapeInfer::infer(const std::vector<VecOPENVINO_ASSERT(m_input_exprs.size() == input_shapes.size(),"Got invalid number of input shapes in LIR ShapeInfer");size_t input_count = 0;- for (const auto& expr : m_input_exprs)+ for (const auto& expr : m_input_exprs) {expr->get_output_port_descriptor(0)->set_shape(input_shapes[input_count++]);+ }for (const auto& expr : m_exprs) {- if (expr->needShapeInfer())+ if (expr->needShapeInfer()) {expr->updateShapes();+ }}std::vector<VectorDims> outputDims;@@ -596,6 +647,4 @@ IShapeInferSnippets::Result LinearIR::LIRShapeInfer::infer(const std::vector<Vecreturn m_last_result;}-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/src/lowered/linear_ir_builder.cpp b/src/common/snippets/src/lowered/linear_ir_builder.cppindex 346a064c7a3..d6c6299c30e 100644--- a/src/common/snippets/src/lowered/linear_ir_builder.cpp+++ b/src/common/snippets/src/lowered/linear_ir_builder.cpp@@ -4,11 +4,22 @@#include "snippets/lowered/linear_ir_builder.hpp"+#include <algorithm>+#include <cstddef>+#include <memory>+#include <unordered_map>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/graph_util.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_manager.hpp"-namespace ov {-namespace snippets {-namespace lowered {+namespace ov::snippets::lowered {namespace {using NodeMap = std::unordered_map<ov::Node*, std::shared_ptr<ov::Node>>;@@ -26,7 +37,7 @@ std::vector<std::shared_ptr<ov::Node>> clone_nodes(const std::vector<std::sharedcloned_args.push_back(output.for_node(node_map.at(output.get_node())));}std::vector<std::shared_ptr<Node>> cloned_dependencies;- for (auto& dependency : node->get_control_dependencies()) {+ for (const auto& dependency : node->get_control_dependencies()) {std::shared_ptr<Node>& dependent = node_map.at(dependency.get());if (find(cloned_dependencies.begin(), cloned_dependencies.end(), dependent) ==cloned_dependencies.end()) {@@ -58,6 +69,7 @@ std::vector<std::shared_ptr<ov::Node>> clone_nodes(const std::vector<std::shared// create and return vector of cloned nodes// order matches input vector (not necessarily topological)std::vector<std::shared_ptr<ov::Node>> cloned_nodes;+ cloned_nodes.reserve(nodes.size());for (const auto& node : nodes) {cloned_nodes.push_back(node_map.at(node.get()));}@@ -115,18 +127,18 @@ LinearIR::container LinearIRBuilder::clone_range(LinearIR::container::const_iter"Expressions after copying aren't matched!");// Copy tensor shapes as shared pointer if neededif (!m_config.deep_copy_of_shapes) {- for (size_t i = 0; i < original_expr->get_input_count(); ++i)+ for (size_t i = 0; i < original_expr->get_input_count(); ++i) {result_expr->get_input_port_descriptor(i)->m_tensor_shape =original_expr->get_input_port_descriptor(i)->m_tensor_shape;- for (size_t i = 0; i < original_expr->get_output_count(); ++i)+ }+ for (size_t i = 0; i < original_expr->get_output_count(); ++i) {result_expr->get_output_port_descriptor(i)->m_tensor_shape =original_expr->get_output_port_descriptor(i)->m_tensor_shape;+ }}}return result;}-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/src/lowered/loop_info.cpp b/src/common/snippets/src/lowered/loop_info.cppindex cd881ff2154..1bea8a3709f 100644--- a/src/common/snippets/src/lowered/loop_info.cpp+++ b/src/common/snippets/src/lowered/loop_info.cpp@@ -4,11 +4,29 @@#include "snippets/lowered/loop_info.hpp"+#include <algorithm>+#include <cassert>+#include <cstddef>+#include <cstdint>+#include <functional>+#include <iterator>+#include <memory>+#include <numeric>+#include <set>+#include <utility>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/expression_port.hpp"+#include "snippets/lowered/loop_port.hpp"+#include "snippets/lowered/pass/pass.hpp"+#include "snippets/lowered/specific_loop_iter_handlers.hpp"+#include "snippets/lowered/specific_loop_iter_types.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {+namespace ov::snippets::lowered {LoopInfo::LoopInfo(size_t work_amount,size_t increment,@@ -27,10 +45,12 @@ LoopInfo::LoopInfo(size_t work_amount,m_increment(increment) {m_input_ports.reserve(entries.size());m_output_ports.reserve(exits.size());- for (const auto& port : entries)+ for (const auto& port : entries) {m_input_ports.push_back(LoopPort::create<LoopPort::Type::Incremented>(port));- for (const auto& port : exits)+ }+ for (const auto& port : exits) {m_output_ports.push_back(LoopPort::create<LoopPort::Type::Incremented>(port));+ }}bool LoopInfo::is_dynamic() const {@@ -46,8 +66,9 @@ size_t LoopInfo::get_dim_idx() const {auto is_processed_it = std::find_if(m_input_ports.begin(), m_input_ports.end(), is_processed);if (is_processed_it == m_input_ports.end()) {is_processed_it = std::find_if(m_output_ports.begin(), m_output_ports.end(), is_processed);- if (is_processed_it == m_output_ports.end())+ if (is_processed_it == m_output_ports.end()) {return LoopPort::UNDEFINED_DIM_IDX;+ }}const auto dim_idx = is_processed_it->get_dim_idx();@@ -57,9 +78,8 @@ size_t LoopInfo::get_dim_idx() const {if (std::all_of(m_input_ports.begin(), m_input_ports.end(), equal_dim_idxes) &&std::all_of(m_output_ports.begin(), m_output_ports.end(), equal_dim_idxes)) {return dim_idx;- } else {- return LoopPort::UNDEFINED_DIM_IDX;}+ return LoopPort::UNDEFINED_DIM_IDX;}size_t LoopInfo::get_input_count() const {@@ -105,8 +125,9 @@ void LoopInfo::set_increment(size_t increment) {void LoopInfo::set_dim_idx(size_t dim_idx) {auto setter = [dim_idx](LoopPort& port) {- if (port.is_processed())+ if (port.is_processed()) {port.set_dim_idx(dim_idx);+ }};std::for_each(m_input_ports.begin(), m_input_ports.end(), setter);std::for_each(m_output_ports.begin(), m_output_ports.end(), setter);@@ -123,10 +144,10 @@ std::vector<LoopPort>::iterator LoopInfo::find_loop_port(const LoopPort& loop_po}template <>-std::vector<LoopPort>::iterator LoopInfo::find_loop_port(const ExpressionPort& expr_port) {- auto& ports = expr_port.get_type() == ExpressionPort::Input ? m_input_ports : m_output_ports;- const auto it = std::find_if(ports.begin(), ports.end(), [&expr_port](const LoopPort& port) {- return *port.get_expr_port() == expr_port;+std::vector<LoopPort>::iterator LoopInfo::find_loop_port(const ExpressionPort& loop_port) {+ auto& ports = loop_port.get_type() == ExpressionPort::Input ? m_input_ports : m_output_ports;+ const auto it = std::find_if(ports.begin(), ports.end(), [&loop_port](const LoopPort& port) {+ return *port.get_expr_port() == loop_port;});return it;}@@ -178,8 +199,9 @@ void LoopInfo::replace_with_new_ports(const ExpressionPort& actual_port,auto port_it = find_loop_port(actual_port);// In some cases actual ExpressionPort may not be LoopPort. We shouldn't throw exception here since ExpressionPort// is not strong condition as LoopPort For example, not all inner loop ports are ports of outer loops- if (port_it == ports.end())+ if (port_it == ports.end()) {return;+ }// to save other parameters except expression portstd::vector<LoopPort> target_loop_ports(target_ports.size(), *port_it);@@ -218,8 +240,9 @@ bool UnifiedLoopInfo::LoopPortDesc::is_static() const {}bool operator==(const UnifiedLoopInfo::LoopPortDesc& lhs, const UnifiedLoopInfo::LoopPortDesc& rhs) {- if (&lhs == &rhs)+ if (&lhs == &rhs) {return true;+ }return lhs.ptr_increment == rhs.ptr_increment && lhs.finalization_offset == rhs.finalization_offset &&lhs.data_size == rhs.data_size;}@@ -231,9 +254,9 @@ UnifiedLoopInfo::UnifiedLoopInfo(size_t work_amount,size_t increment,const std::vector<LoopPort>& entries,const std::vector<LoopPort>& exits,- const SpecificIterationHandlers& handlers)+ SpecificIterationHandlers handlers): LoopInfo(work_amount, increment, entries, exits),- m_handlers(handlers),+ m_handlers(std::move(handlers)),m_input_port_descs(std::vector<LoopPortDesc>(entries.size())),m_output_port_descs(std::vector<LoopPortDesc>(exits.size())) {sort_ports();@@ -243,9 +266,9 @@ UnifiedLoopInfo::UnifiedLoopInfo(size_t work_amount,size_t increment,const std::vector<ExpressionPort>& entries,const std::vector<ExpressionPort>& exits,- const SpecificIterationHandlers& handlers)+ SpecificIterationHandlers handlers): LoopInfo(work_amount, increment, entries, exits),- m_handlers(handlers),+ m_handlers(std::move(handlers)),m_input_port_descs(std::vector<LoopPortDesc>(entries.size())),m_output_port_descs(std::vector<LoopPortDesc>(exits.size())) {sort_ports();@@ -255,13 +278,13 @@ UnifiedLoopInfo::UnifiedLoopInfo(size_t work_amount,size_t increment,const std::vector<LoopPort>& entries,const std::vector<LoopPort>& exits,- const std::vector<LoopPortDesc>& in_shifts,- const std::vector<LoopPortDesc>& out_shifts,- const SpecificIterationHandlers& handlers)+ const std::vector<LoopPortDesc>& in_descs,+ const std::vector<LoopPortDesc>& out_descs,+ SpecificIterationHandlers handlers): LoopInfo(work_amount, increment, entries, exits),- m_handlers(handlers),- m_input_port_descs(in_shifts),- m_output_port_descs(out_shifts) {+ m_handlers(std::move(handlers)),+ m_input_port_descs(in_descs),+ m_output_port_descs(out_descs) {sort_ports();}@@ -347,16 +370,18 @@ const std::vector<UnifiedLoopInfo::LoopPortDesc>& UnifiedLoopInfo::get_output_postd::vector<UnifiedLoopInfo::LoopPortInfo> UnifiedLoopInfo::get_input_ports_info() const {assert(m_input_ports.size() == m_input_port_descs.size() && "Incompatible count of input port and descs");std::vector<UnifiedLoopInfo::LoopPortInfo> info(get_input_count());- for (size_t i = 0; i < get_input_count(); ++i)+ for (size_t i = 0; i < get_input_count(); ++i) {info[i] = {m_input_ports[i], m_input_port_descs[i]};+ }return info;}std::vector<UnifiedLoopInfo::LoopPortInfo> UnifiedLoopInfo::get_output_ports_info() const {assert(m_output_ports.size() == m_output_port_descs.size() && "Incompatible count of output port and descs");std::vector<UnifiedLoopInfo::LoopPortInfo> info(get_output_count());- for (size_t i = 0; i < get_output_count(); ++i)+ for (size_t i = 0; i < get_output_count(); ++i) {info[i] = {m_output_ports[i], m_output_port_descs[i]};+ }return info;}@@ -380,8 +405,9 @@ std::vector<size_t> get_port_index_order(const std::vector<LoopPort>& ports) {std::sort(new_indexes.begin(), new_indexes.end(), [ports](size_t l, size_t r) {const auto& expr_port_l = ports[l].get_expr_port();const auto& expr_port_r = ports[r].get_expr_port();- if (expr_port_l->get_expr() == expr_port_r->get_expr())+ if (expr_port_l->get_expr() == expr_port_r->get_expr()) {return expr_port_l->get_index() < expr_port_r->get_index();+ }return expr_port_l->get_expr()->get_exec_num() < expr_port_r->get_expr()->get_exec_num();});return new_indexes;@@ -452,8 +478,9 @@ void UnifiedLoopInfo::replace_with_new_ports(const ExpressionPort& actual_port,auto port_it = find_loop_port(actual_port);// In some cases actual ExpressionPort may not be LoopPort. We shouldn't throw exception here since ExpressionPort// is not strong condition as LoopPort For example, not all inner loop ports are ports of outer loops- if (port_it == ports.end())+ if (port_it == ports.end()) {return;+ }replace_with_cloned_descs(std::distance(ports.begin(), port_it), target_ports.size(), is_input);LoopInfo::replace_with_new_ports(actual_port, target_ports);@@ -510,7 +537,7 @@ LoopInfoPtr InnerSplittedUnifiedLoopInfo::get_outer_splitted_loop_info() const {return m_outer_splitted_loop_info;}-void InnerSplittedUnifiedLoopInfo::set_work_amount(size_t work_amount) {+void InnerSplittedUnifiedLoopInfo::set_work_amount([[maybe_unused]] size_t work_amount) {OPENVINO_THROW("InnerSplittedUnifiedLoopInfo doesn't support `set_work_amount`");}@@ -679,6 +706,4 @@ void ExpandedLoopInfo::sort_ports() {reorder(m_output_ports, get_output_count(), get_input_count());}-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/src/lowered/loop_manager.cpp b/src/common/snippets/src/lowered/loop_manager.cppindex 089f6c568ec..9a8ba46ae29 100644--- a/src/common/snippets/src/lowered/loop_manager.cpp+++ b/src/common/snippets/src/lowered/loop_manager.cpp@@ -4,17 +4,33 @@#include "snippets/lowered/loop_manager.hpp"-#include "openvino/core/graph_util.hpp"+#include <algorithm>+#include <cassert>+#include <cstddef>+#include <cstdint>+#include <iterator>+#include <map>+#include <memory>+#include <set>+#include <string>+#include <unordered_set>+#include <utility>+#include <vector>++#include "openvino/core/except.hpp"#include "openvino/core/type.hpp"+#include "openvino/op/constant.hpp"#include "snippets/itt.hpp"#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/expression_port.hpp"+#include "snippets/lowered/loop_info.hpp"+#include "snippets/lowered/loop_port.hpp"+#include "snippets/lowered/specific_loop_iter_handlers.hpp"#include "snippets/op/loop.hpp"#include "snippets/utils/loop_utils.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {+namespace ov::snippets::lowered {std::shared_ptr<LoopManager> LoopManager::clone_with_new_expr(const ExpressionMap& expr_map) const {auto new_loop_manager = std::make_shared<LoopManager>();@@ -22,8 +38,9 @@ std::shared_ptr<LoopManager> LoopManager::clone_with_new_expr(const ExpressionMa// because some LoopInfo types contains pointer to another LoopInfo// so we should recurrently make a cloning of LoopInfos'LoopInfoMap loop_info_map; // [ old - > cloned ]- for (const auto& id_info : m_map)+ for (const auto& id_info : m_map) {new_loop_manager->m_map.insert({id_info.first, id_info.second->clone_with_new_expr(expr_map, loop_info_map)});+ }new_loop_manager->next_id = next_id;return new_loop_manager;}@@ -47,7 +64,7 @@ std::vector<size_t> LoopManager::get_outer_expr_loops(const ExpressionPtr& expr,const auto& loop_ids = expr->get_loop_ids();const auto it = std::find(loop_ids.cbegin(), loop_ids.cend(), loop_id);assert(it != loop_ids.cend() && "Loop ID hasn't been found");- return std::vector<size_t>(loop_ids.cbegin(), it);+ return {loop_ids.cbegin(), it};}std::vector<size_t> LoopManager::get_common_outer_loops(const ExpressionPtr& lhs, const ExpressionPtr& rhs) {@@ -57,7 +74,7 @@ std::vector<size_t> LoopManager::get_common_outer_loops(const ExpressionPtr& lhswhile (idx < std::min(rhs_ids.size(), lhs_ids.size()) && rhs_ids[idx] == lhs_ids[idx]) {idx++;}- return std::vector<size_t>(rhs_ids.cbegin(), rhs_ids.cbegin() + idx);+ return {rhs_ids.cbegin(), rhs_ids.cbegin() + idx};}std::vector<size_t> LoopManager::get_common_outer_loops(const std::vector<ExpressionPtr>& exprs) {@@ -76,7 +93,7 @@ std::vector<size_t> LoopManager::get_common_outer_loops(const std::vector<Expresfor (size_t i = 1; i < exprs.size(); ++i) {common_idx = std::min(common_idx, get_first_diff_id_idx(first_loop_ids, exprs[i]->get_loop_ids()));}- return std::vector<size_t>(first_loop_ids.cbegin(), first_loop_ids.cbegin() + common_idx);+ return {first_loop_ids.cbegin(), first_loop_ids.cbegin() + common_idx};}std::pair<LinearIR::constExprIt, LinearIR::constExprIt> LoopManager::get_loop_bounds(const LinearIR& linear_ir,@@ -128,7 +145,7 @@ std::pair<LinearIR::constExprIt, LinearIR::constExprIt> LoopManager::get_loop_boreturn std::make_pair(loop_begin_pos, loop_end_pos);}-LoopPort LoopManager::get_loop_port_by_expr_port(const ExpressionPort& expr_port, const size_t loop_id) {+LoopPort LoopManager::get_loop_port_by_expr_port(const ExpressionPort& expr_port, const size_t loop_id) const {const auto& loop_info = get_loop_info(loop_id);return loop_info->get_loop_port(expr_port);}@@ -171,8 +188,9 @@ void LoopManager::mark_loop(LinearIR::constExprIt loop_begin_pos,LoopManager::get_io_loop_ports(loop_begin_pos, loop_end_pos, loop_input_ports, loop_output_ports);auto broadcast = [](std::vector<size_t>& lhs, const std::vector<size_t>& rhs, size_t index) -> void {- if (rhs == lhs)+ if (rhs == lhs) {return;+ }const auto lhs_size = lhs.size();const auto rhs_size = rhs.size();const auto size = std::max(lhs_size, rhs_size);@@ -199,10 +217,12 @@ void LoopManager::mark_loop(LinearIR::constExprIt loop_begin_pos,}const size_t resizing_value = is_outside_loop(subtensor) ? utils::get_full_dim_value() : 1;- while (subtensor.size() < loop_depth)+ while (subtensor.size() < loop_depth) {subtensor.insert(subtensor.begin(), resizing_value);- if (loop_subtensor.empty())+ }+ if (loop_subtensor.empty()) {loop_subtensor = subtensor;+ }OPENVINO_ASSERT(std::equal(loop_subtensor.crbegin(), loop_subtensor.crbegin() + loop_depth, subtensor.crbegin()),@@ -307,8 +327,9 @@ void LoopManager::fuse_loops(LinearIR::constExprIt loop_begin_target,for (const auto& p : m_map) {if (const auto inner_splitted_loop_info = ov::as_type_ptr<InnerSplittedUnifiedLoopInfo>(p.second)) {const auto outer = inner_splitted_loop_info->get_outer_splitted_loop_info();- if (utils::one_of(outer, loop_info_upper, loop_info_lower))+ if (utils::one_of(outer, loop_info_upper, loop_info_lower)) {inner_splitted_loop_info->set_outer_splitted_loop_info(m_map[to]);+ }}}@@ -336,7 +357,7 @@ void LoopManager::fuse_loop_ports(std::vector<LoopPort>& output_ports,for (const auto& consumer_input : consumers_inputs) {const auto input_port_it =std::find_if(input_ports.begin(), input_ports.end(), [&consumer_input](const LoopPort& port) {- return *port.get_expr_port().get() == consumer_input;+ return *port.get_expr_port() == consumer_input;});if (input_port_it != input_ports.end()) {mapped_input_ports.insert(*input_port_it);@@ -366,7 +387,7 @@ void LoopManager::fuse_loop_ports(std::vector<LoopPort>& output_ports,output_ports = new_output_ports;}-void LoopManager::update_loop_ports(const ExpressionPtr& expr) {+void LoopManager::update_loop_ports(const ExpressionPtr& expr) const {auto update_ports = [&](const ov::snippets::lowered::ExpressionPort& connected_port) {const auto is_output = connected_port.get_type() == ExpressionPort::Output;// Iterate through all Loops of the connected expression@@ -374,23 +395,27 @@ void LoopManager::update_loop_ports(const ExpressionPtr& expr) {const auto& loop_info = get_loop_info(loop_id);// If the connected expression port is not Loop port - nothing to update// If the target expression is not from the same Loop - nothing to update- if (!loop_info->is_loop_port(connected_port) || !is_loop_id_found(expr, loop_id))+ if (!loop_info->is_loop_port(connected_port) || !is_loop_id_found(expr, loop_id)) {continue;+ }std::vector<ExpressionPort> new_ports;// Check if some ports of target expression must be Loop portconst auto target_expr_ports = is_output ? expr->get_output_ports() : expr->get_input_ports();for (const auto& port : target_expr_ports) {- if (utils::should_be_loop_port(port, loop_id))+ if (utils::should_be_loop_port(port, loop_id)) {new_ports.push_back(port);+ }}// Leave the connected expression port as Loop port if needed- if (utils::should_be_loop_port(connected_port, loop_id))+ if (utils::should_be_loop_port(connected_port, loop_id)) {new_ports.push_back(connected_port);+ }// Nothing should be updated- if (new_ports.size() == 1 && new_ports.front() == connected_port)+ if (new_ports.size() == 1 && new_ports.front() == connected_port) {continue;+ }loop_info->replace_with_new_ports(connected_port, new_ports);}@@ -410,9 +435,10 @@ void LoopManager::update_loop_ports(const ExpressionPtr& expr) {}}-void LoopManager::sort_loop_ports(const std::vector<size_t>& loop_ids) {- for (auto& loop_id : loop_ids)+void LoopManager::sort_loop_ports(const std::vector<size_t>& loop_ids) const {+ for (const auto& loop_id : loop_ids) {get_loop_info(loop_id)->sort_ports();+ }}void LoopManager::expression_replacement(LinearIR::constExprIt new_expr_begin,@@ -528,6 +554,4 @@ bool LoopManager::is_loop_id_found(const ExpressionPtr& expr, size_t id) {return std::find(loop_ids.cbegin(), loop_ids.cend(), id) != loop_ids.cend();}-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/src/lowered/loop_port.cpp b/src/common/snippets/src/lowered/loop_port.cppindex 9434a7fa9fa..1fa924527e6 100644--- a/src/common/snippets/src/lowered/loop_port.cpp+++ b/src/common/snippets/src/lowered/loop_port.cpp@@ -4,11 +4,16 @@#include "snippets/lowered/loop_port.hpp"-#include "snippets/utils/utils.hpp"+#include <cstddef>+#include <memory>+#include <ostream>+#include <utility>-namespace ov {-namespace snippets {-namespace lowered {+#include "openvino/core/except.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/expression_port.hpp"++namespace ov::snippets::lowered {LoopPort::LoopPort(const ExpressionPort& port, size_t dim_idx, Type type): m_expr_port(std::make_shared<ExpressionPort>(port)),@@ -66,8 +71,9 @@ void LoopPort::set_dim_idx(size_t idx) {}bool operator==(const LoopPort& lhs, const LoopPort& rhs) {- if (&lhs == &rhs)+ if (&lhs == &rhs) {return true;+ }return *lhs.m_expr_port == *rhs.m_expr_port && lhs.m_type == rhs.m_type && lhs.m_dim_idx == rhs.m_dim_idx;}@@ -98,6 +104,4 @@ std::ostream& operator<<(std::ostream& out, const LoopPort::Type& type) {return out;}-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/src/lowered/pass/allocate_buffers.cpp b/src/common/snippets/src/lowered/pass/allocate_buffers.cppindex 0ada643f948..e9759d872b9 100644--- a/src/common/snippets/src/lowered/pass/allocate_buffers.cpp+++ b/src/common/snippets/src/lowered/pass/allocate_buffers.cpp@@ -4,27 +4,27 @@#include "snippets/lowered/pass/allocate_buffers.hpp"+#include <cstddef>+#include "snippets/itt.hpp"+#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/pass/compute_buffer_allocation_size.hpp"#include "snippets/lowered/pass/define_buffer_clusters.hpp"#include "snippets/lowered/pass/init_buffers_default.hpp"#include "snippets/lowered/pass/mark_invariant_shape_path.hpp"#include "snippets/lowered/pass/normalize_buffer_reg_groups.hpp"+#include "snippets/lowered/pass/pass.hpp"#include "snippets/lowered/pass/propagate_buffer_offset.hpp"#include "snippets/lowered/pass/set_buffer_reg_group.hpp"#include "snippets/lowered/pass/solve_buffer_memory.hpp"-#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {AllocateBuffers::AllocateBuffers(bool is_optimized) : m_is_optimized_mode(is_optimized) {}bool AllocateBuffers::run(lowered::LinearIR& linear_ir,- lowered::LinearIR::constExprIt begin,- lowered::LinearIR::constExprIt end) {+ [[maybe_unused]] lowered::LinearIR::constExprIt begin,+ [[maybe_unused]] lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::AllocateBuffers");size_t buffer_scratchpad_size = 0;@@ -47,7 +47,4 @@ bool AllocateBuffers::run(lowered::LinearIR& linear_ir,return buffer_scratchpad_size > 0;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/assign_registers.cpp b/src/common/snippets/src/lowered/pass/assign_registers.cppindex 3fef5b61441..a008ebc3ad4 100644--- a/src/common/snippets/src/lowered/pass/assign_registers.cpp+++ b/src/common/snippets/src/lowered/pass/assign_registers.cpp@@ -4,19 +4,31 @@#include "snippets/lowered/pass/assign_registers.hpp"+#include <algorithm>+#include <cstddef>+#include <cstdint>+#include <iterator>+#include <map>+#include <set>+#include <stack>+#include <tuple>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"+#include "snippets/emitter.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/expressions/buffer_expression.hpp"#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/reg_manager.hpp"+#include "snippets/op/fill.hpp"+#include "snippets/op/horizon_max.hpp"+#include "snippets/op/horizon_sum.hpp"#include "snippets/op/kernel.hpp"-#include "snippets/snippets_isa.hpp"-#include "snippets/utils/utils.hpp"--// This header is needed to avoid MSVC warning "C2039: 'inserter': is not a member of 'std'"-#include <iterator>+#include "snippets/op/vector_buffer.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {AssignRegisters::RegMap AssignRegisters::assign_regs_manually(const LinearIR& linear_ir,std::set<Reg>& gpr_pool,@@ -43,12 +55,12 @@ AssignRegisters::RegMap AssignRegisters::assign_regs_manually(const LinearIR& ligpr_pool.erase(gpr_pool.begin());}- long int max_buffer_group = -1;+ int64_t max_buffer_group = -1;for (const auto& expr : linear_ir) {auto op = expr->get_node();if (const auto& buffer = ov::as_type_ptr<BufferExpression>(expr)) {// All buffers have one common data pointer- const auto reg_group = static_cast<long int>(buffer->get_reg_group());+ const auto reg_group = static_cast<int64_t>(buffer->get_reg_group());max_buffer_group = std::max(max_buffer_group, reg_group);OPENVINO_ASSERT(gpr_pool.size() > static_cast<size_t>(max_buffer_group),"Not enough gp registers in the pool to perform manual assignment");@@ -57,10 +69,12 @@ AssignRegisters::RegMap AssignRegisters::assign_regs_manually(const LinearIR& limanually_assigned[out_reg] = assigned;// Buffer abstract registers validation:bool all_equal = true;- for (const auto& pd : buffer->get_input_port_descriptors())+ for (const auto& pd : buffer->get_input_port_descriptors()) {all_equal &= pd->get_reg() == out_reg;- for (const auto& pd : buffer->get_output_port_descriptors())+ }+ for (const auto& pd : buffer->get_output_port_descriptors()) {all_equal &= pd->get_reg() == out_reg;+ }OPENVINO_ASSERT(all_equal, "Buffer must have same register on all inputs and outputs");} else if (ov::is_type_any_of<op::HorizonMax, op::HorizonSum>(op)) {// Only in ReduceDecomposition Reduce ops use HorizonMax/HorizonSum and VectorBuffer.@@ -107,8 +121,9 @@ bool AssignRegisters::run(LinearIR& linear_ir) {std::set<Reg> vec_pool = vec2set(m_reg_manager.get_vec_reg_pool());auto assigned_reg_map = assign_regs_manually(linear_ir, gpr_pool, vec_pool);- for (const auto& item : assigned_reg_map)+ for (const auto& item : assigned_reg_map) {global_regs.insert(item.second);+ }struct by_starting {auto operator()(const LiveInterval& lhs, const LiveInterval& rhs) const -> bool {@@ -129,8 +144,9 @@ bool AssignRegisters::run(LinearIR& linear_ir) {const auto& reg = regint.first;const auto& interval = regint.second;// If a register is assigned manually, we should ignore it during automatic assignment- if (assigned_reg_map.count(reg))+ if (assigned_reg_map.count(reg)) {continue;+ }switch (reg.type) {case (RegType::gpr):OPENVINO_ASSERT(!live_intervals_gpr.count(interval), "GPR live interval is already in the map");@@ -154,8 +170,9 @@ bool AssignRegisters::run(LinearIR& linear_ir) {std::map<Reg, Reg> register_map;std::stack<Reg> bank;// regs are stored in ascending order in reg_pool, so walk in reverse to assign them the same way- for (auto rit = reg_pool.crbegin(); rit != reg_pool.crend(); rit++)+ for (auto rit = reg_pool.crbegin(); rit != reg_pool.crend(); rit++) {bank.push(*rit);+ }LiveInterval interval, active_interval;Reg unique_reg, active_unique_reg;@@ -189,8 +206,9 @@ bool AssignRegisters::run(LinearIR& linear_ir) {for (const auto& expr : exprs) {// Note: manually assigned regs are always live => add them to all expressionsstd::set<Reg> mapped_live_regs = global_regs;- for (const auto& live_reg : expr->get_live_regs())+ for (const auto& live_reg : expr->get_live_regs()) {mapped_live_regs.insert(assigned_reg_map[live_reg]);+ }expr->set_live_regs(mapped_live_regs);for (const auto& in : expr->get_input_port_descriptors()) {if (!in->get_reg().is_address()) {@@ -206,7 +224,4 @@ bool AssignRegisters::run(LinearIR& linear_ir) {return false;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/brgemm_blocking.cpp b/src/common/snippets/src/lowered/pass/brgemm_blocking.cppindex 87208cb0164..34878a9efc8 100644--- a/src/common/snippets/src/lowered/pass/brgemm_blocking.cpp+++ b/src/common/snippets/src/lowered/pass/brgemm_blocking.cpp@@ -4,19 +4,25 @@#include "snippets/lowered/pass/brgemm_blocking.hpp"+#include <algorithm>+#include <cstddef>+#include <iterator>+#include <tuple>+#include <vector>++#include "openvino/core/except.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression.hpp"#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/loop_manager.hpp"-#include "snippets/lowered/pass/iter_handler.hpp"-#include "snippets/lowered/pass/pass.hpp"+#include "snippets/lowered/loop_port.hpp"#include "snippets/lowered/pass/propagate_subtensors.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/lowered/specific_loop_iter_handlers.hpp"+#include "snippets/lowered/specific_loop_iter_types.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {using namespace ov::snippets::utils;using PortType = LoopPort::Type;@@ -26,8 +32,9 @@ lowered::SpecificIterationHandlers BrgemmBlockingBase::get_default_blocking_loopSpecificIterationHandlers handlers;const auto tail_size =utils::is_dynamic_value(work_amount) ? utils::get_dynamic_value<size_t>() : work_amount % block_size;- if (tail_size != 0)+ if (tail_size != 0) {handlers.register_pass<lowered::SpecificLoopIterType::LAST_ITER, lowered::pass::UpdateSubtensors>(tail_size);+ }return handlers;}@@ -37,14 +44,11 @@ bool BrgemmBlockingBase::blocking_loop_exists(const lowered::LoopManagerPtr& looreturn p.get_expr_port()->get_expr() == brgemm_expr && one_of(p.get_dim_idx(), 0ul, 1ul);};const auto& loop_ids = brgemm_expr->get_loop_ids();- for (const auto& id : loop_ids) {+ return std::any_of(loop_ids.begin(), loop_ids.end(), [&](const auto& id) {const auto loop = loop_manager->get_loop_info(id);- if (std::any_of(loop->get_input_ports().begin(), loop->get_input_ports().end(), check_port) ||- std::any_of(loop->get_output_ports().begin(), loop->get_output_ports().end(), check_port)) {- return true;- }- }- return false;+ return std::any_of(loop->get_input_ports().begin(), loop->get_input_ports().end(), check_port) ||+ std::any_of(loop->get_output_ports().begin(), loop->get_output_ports().end(), check_port);+ });}void BrgemmBlockingBase::mark_m_blocking(const LoopManagerPtr& loop_manager,@@ -158,7 +162,12 @@ bool BrgemmBlockingBase::mark_blocking_loops(LinearIR& linear_ir,}return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file++size_t BrgemmBlockingBase::get_corrected_blk_size_by_dim(size_t dim, size_t default_blk) {+ if (!utils::is_dynamic_value(dim) && dim <= default_blk) {+ return utils::get_full_dim_value();+ }+ return default_blk;+}++} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/clean_repeated_ptr_shifts.cpp b/src/common/snippets/src/lowered/pass/clean_repeated_ptr_shifts.cppindex 0e55cb1d5b9..e690966a1f9 100644--- a/src/common/snippets/src/lowered/pass/clean_repeated_ptr_shifts.cpp+++ b/src/common/snippets/src/lowered/pass/clean_repeated_ptr_shifts.cpp@@ -4,21 +4,28 @@#include "snippets/lowered/pass/clean_repeated_ptr_shifts.hpp"+#include <cstddef>+#include <set>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/expressions/buffer_expression.hpp"#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/loop_manager.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/lowered/loop_port.hpp"+#include "snippets/op/loop.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {bool CleanRepeatedDataPointerShifts::reuse_increments(const LoopManagerPtr& loop_manager,const ExpressionPtr& loop_end_expr) {const auto loop_end = ov::as_type_ptr<op::LoopEnd>(loop_end_expr->get_node());- if (!loop_end)+ if (!loop_end) {return false;+ }const auto& loop_connectors = loop_end_expr->get_input_port_connectors();const auto input_count = loop_end->get_input_num();@@ -79,8 +86,9 @@ bool CleanRepeatedDataPointerShifts::reuse_increments(const LoopManagerPtr& loop}}- if (resetting_data_indexes.empty())+ if (resetting_data_indexes.empty()) {return false;+ }// TODO [133463]: We have to update LoopEnd and LoopInfo since the both entities must be valid.// To avoid the both changes, we have to insert Loop ops to LinearIR in the end of pipeline.@@ -129,7 +137,4 @@ bool CleanRepeatedDataPointerShifts::run(lowered::LinearIR& linear_ir,return modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/cleanup_loop_offsets.cpp b/src/common/snippets/src/lowered/pass/cleanup_loop_offsets.cppindex f6f5bd26213..be239253913 100644--- a/src/common/snippets/src/lowered/pass/cleanup_loop_offsets.cpp+++ b/src/common/snippets/src/lowered/pass/cleanup_loop_offsets.cpp@@ -4,17 +4,23 @@#include "snippets/lowered/pass/cleanup_loop_offsets.hpp"+#include <cstddef>+#include <cstdint>+#include <iterator>+#include <unordered_map>+#include <vector>++#include "openvino/core/type.hpp"+#include "openvino/op/result.hpp"#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/port_connector.hpp"#include "snippets/op/loop.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {-bool CleanupLoopOffsets::run(lowered::LinearIR& linear_ir,+bool CleanupLoopOffsets::run(lowered::LinearIR& /*linear_ir*/,lowered::LinearIR::constExprIt begin,lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::CleanupLoopOffsets")@@ -38,8 +44,9 @@ bool CleanupLoopOffsets::run(lowered::LinearIR& linear_ir,auto fin_offsets = loop_end->get_finalization_offsets();std::unordered_map<PortConnectorPtr, size_t> per_port_connector_offset;const auto& loop_inputs = expr_it->get()->get_input_port_connectors();- for (size_t i = 0; i < fin_offsets.size(); i++)+ for (size_t i = 0; i < fin_offsets.size(); i++) {per_port_connector_offset[loop_inputs[i]] = i;+ }const auto& outer_is_incremented = outer_loop_end->get_is_incremented();const auto& outer_data_sizes = outer_loop_end->get_element_type_sizes();@@ -47,16 +54,19 @@ bool CleanupLoopOffsets::run(lowered::LinearIR& linear_ir,auto outer_ptr_increments = outer_loop_end->get_ptr_increments();const auto& outer_loop_inputs = next_expr_it->get()->get_input_port_connectors();for (size_t i = 0; i < outer_ptr_increments.size(); i++) {- if (!outer_is_incremented[i])+ if (!outer_is_incremented[i]) {continue;+ }const auto& managed_connector = outer_loop_inputs[i];const auto& found = per_port_connector_offset.find(managed_connector);if (found != per_port_connector_offset.end()) {- if (!is_incremented[found->second] || outer_data_sizes[i] != data_sizes[found->second])+ if (!is_incremented[found->second] || outer_data_sizes[i] != data_sizes[found->second]) {continue;+ }if (utils::is_dynamic_value(outer_ptr_increments[i]) ||- utils::is_dynamic_value(fin_offsets[found->second]))+ utils::is_dynamic_value(fin_offsets[found->second])) {continue;+ }// Since data ptr is incremented on [ptr_increment x increment],// we should guarantee proportionality of ptr shifts.// If the data ptr can't be proportionally shifted, the optimization is not applied@@ -86,7 +96,4 @@ bool CleanupLoopOffsets::run(lowered::LinearIR& linear_ir,return is_modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/compute_buffer_allocation_size.cpp b/src/common/snippets/src/lowered/pass/compute_buffer_allocation_size.cppindex 328a7165261..5378a02f00c 100644--- a/src/common/snippets/src/lowered/pass/compute_buffer_allocation_size.cpp+++ b/src/common/snippets/src/lowered/pass/compute_buffer_allocation_size.cpp@@ -5,17 +5,13 @@#include "snippets/lowered/pass/compute_buffer_allocation_size.hpp"#include "snippets/itt.hpp"-#include "snippets/op/buffer.hpp"-#include "snippets/utils/utils.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {bool ComputeBufferAllocationSize::run(LinearIR& linear_ir,- lowered::LinearIR::constExprIt begin,- lowered::LinearIR::constExprIt end) {+ [[maybe_unused]] lowered::LinearIR::constExprIt begin,+ [[maybe_unused]] lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::ComputeBufferAllocationSize")const auto& allocation_rank = linear_ir.get_config().m_loop_depth;@@ -23,14 +19,12 @@ bool ComputeBufferAllocationSize::run(LinearIR& linear_ir,for (const auto& buffer_expr : linear_ir.get_buffers()) {// If the current size is undefined, update it// TODO [143395] : MemoryManager will return container with only dynamic buffers without any `is_defined()`- if (!buffer_expr->is_defined())+ if (!buffer_expr->is_defined()) {buffer_expr->init_allocation_size(loop_manager, allocation_rank);+ }}return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/define_buffer_clusters.cpp b/src/common/snippets/src/lowered/pass/define_buffer_clusters.cppindex a426222108b..de31fbf4527 100644--- a/src/common/snippets/src/lowered/pass/define_buffer_clusters.cpp+++ b/src/common/snippets/src/lowered/pass/define_buffer_clusters.cpp@@ -4,25 +4,42 @@#include "snippets/lowered/pass/define_buffer_clusters.hpp"+#include <algorithm>+#include <cassert>+#include <cstddef>+#include <cstdint>+#include <iterator>+#include <limits>+#include <memory>+#include <set>+#include <tuple>+#include <utility>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/expressions/buffer_expression.hpp"+#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/loop_manager.hpp"#include "snippets/lowered/pass/mark_invariant_shape_path.hpp"#include "snippets/lowered/pass/set_buffer_reg_group.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/op/loop.hpp"+#include "snippets/op/memory_access.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {namespace {// Find Loops which are connected to the current `buffer_expr` (consumer of Buffer is port of these Loops)std::vector<size_t> get_connected_loops(const BufferExpressionPtr& buffer_expr, const ExpressionPtr& consumer_expr) {// [133463] Remove it please- if (ov::is_type<op::LoopEnd>(consumer_expr->get_node()))+ if (ov::is_type<op::LoopEnd>(consumer_expr->get_node())) {return {};+ }const auto& buffer_loops_ids = buffer_expr->get_loop_ids();const auto& consumer_loop_ids = consumer_expr->get_loop_ids();OPENVINO_ASSERT(buffer_loops_ids.size() <= consumer_loop_ids.size(), "Buffer with consumer are in incorrect loops");@@ -60,8 +77,9 @@ void DefineBufferClusters::add_buffers_to_cluster(BufferCluster& existing_clusteif (std::any_of(existing_cluster.cbegin(), existing_cluster.cend(), [](const BufferExpressionPtr& buffer) {return !buffer->is_defined();})) {- for (const auto& buffer : existing_cluster)+ for (const auto& buffer : existing_cluster) {buffer->set_allocation_size(utils::get_dynamic_value<size_t>());+ }}}@@ -84,8 +102,9 @@ std::pair<DefineBufferClusters::BufferMap, DefineBufferClusters::BufferMap> Defifor (const auto& port_info : loop_inputs) {const auto& buffer_expr = ov::as_type_ptr<BufferExpression>(port_info.port.get_expr_port()->get_port_connector_ptr()->get_source().get_expr());- if (!is_direct_buffer(buffer_expr, loop_expr))+ if (!is_direct_buffer(buffer_expr, loop_expr)) {continue;+ }if (input_buffers.count(buffer_expr) > 0) {const auto& port_desc = port_info.desc;OPENVINO_ASSERT(input_buffers[buffer_expr].desc == port_desc,@@ -102,8 +121,9 @@ std::pair<DefineBufferClusters::BufferMap, DefineBufferClusters::BufferMap> Deficonst auto& consumer_inputs = port_info.port.get_expr_port()->get_port_connector_ptr()->get_consumers();for (const auto& consumer_input : consumer_inputs) {const auto& buffer_expr = ov::as_type_ptr<BufferExpression>(consumer_input.get_expr());- if (!is_direct_buffer(buffer_expr, loop_expr))+ if (!is_direct_buffer(buffer_expr, loop_expr)) {continue;+ }OPENVINO_ASSERT(output_buffers.count(buffer_expr) == 0, "Only one Buffer can be on node output!");output_buffers[buffer_expr] = port_info;}@@ -120,8 +140,9 @@ void DefineBufferClusters::parse_loop(const LoopManagerPtr& loop_manager, constBufferMap input_buffers, output_buffers;std::tie(input_buffers, output_buffers) = get_direct_buffers(loop_info, expr);- for (const auto& in : input_buffers)+ for (const auto& in : input_buffers) {create_new_cluster(in.first);+ }std::set<ExpressionPtr> visited_buffers;for (const auto& out : output_buffers) {@@ -132,13 +153,15 @@ void DefineBufferClusters::parse_loop(const LoopManagerPtr& loop_manager, constfor (const auto& in : input_buffers) {const auto& input_buffer_expr = in.first;const auto& input_buffer_port_info = in.second;- if (visited_buffers.count(input_buffer_expr) > 0)+ if (visited_buffers.count(input_buffer_expr) > 0) {continue;+ }// Memory can be reused if reading and writing are executed proportionally:// - output buffer can have precision with data size less than input buffer- if ((input_buffer_expr->get_data_type().size() < output_buffer_expr->get_data_type().size()))+ if ((input_buffer_expr->get_data_type().size() < output_buffer_expr->get_data_type().size())) {continue;+ }const auto in_path =MarkInvariantShapePath::getInvariantPortShapePath(*input_buffer_port_info.port.get_expr_port());@@ -150,21 +173,24 @@ void DefineBufferClusters::parse_loop(const LoopManagerPtr& loop_manager, const// `is_incremented`.const auto in_is_incremented = input_buffer_port_info.port.is_incremented();const auto out_is_incremented = output_buffer_port_info.port.is_incremented();- if (in_path != out_path || in_is_incremented != out_is_incremented)+ if (in_path != out_path || in_is_incremented != out_is_incremented) {continue;+ }// - Memory can be shared if Buffer has the same allocation size.if (input_buffer_expr->is_defined() && output_buffer_expr->is_defined()) {- if (input_buffer_expr->get_allocation_size() != output_buffer_expr->get_allocation_size())+ if (input_buffer_expr->get_allocation_size() != output_buffer_expr->get_allocation_size()) {continue;+ }} else {// If allocation sizes are undefined, we can check if they have the same allocation sizes in runtime:// - they should calculate allocation size using the common algorithm from// `BufferExpression::init_allocation_size`.if (!utils::everyone_is(BufferExpression::get_type_info_static(),input_buffer_expr->get_type_info(),- output_buffer_expr->get_type_info()))+ output_buffer_expr->get_type_info())) {continue;+ }}const auto cluster_it = find_cluster_by_expr(input_buffer_expr);@@ -190,16 +216,18 @@ void DefineBufferClusters::parse_nested_loops(const LoopManagerPtr& loop_managerconst BufferMap& input_buffers,const BufferMap& output_buffers,const LinearIR::constExprIt& outer_loop_end_expr_it) {- if (input_buffers.empty() && output_buffers.empty())+ if (input_buffers.empty() && output_buffers.empty()) {return;+ }auto can_be_data_ptr_proportionally_shifted = [](const LoopPortInfo& outer_port_info,const LoopPortInfo& inner_port_info) {// Outer Buffer ptr should be shifted to emulate "window" slidingconst auto& outer_desc = outer_port_info.desc;if (!outer_port_info.port.is_incremented() ||- (!utils::is_dynamic_value(outer_desc.ptr_increment) && outer_desc.ptr_increment == 0))+ (!utils::is_dynamic_value(outer_desc.ptr_increment) && outer_desc.ptr_increment == 0)) {return false;+ }OPENVINO_ASSERT(inner_port_info.port.get_expr_port() && outer_port_info.port.get_expr_port(),"Expression ports are nullptr!");@@ -219,13 +247,15 @@ void DefineBufferClusters::parse_nested_loops(const LoopManagerPtr& loop_managerconst auto inner_cluster_it = find_cluster_by_expr(inner_buffer_expr);OPENVINO_ASSERT(inner_cluster_it != m_clusters.cend(), "Buffer cluster has not been found");const auto inner_cluster_id = get_cluster_buffer_id(*inner_cluster_it);- if (inner_cluster_id == SIZE_MAX)+ if (inner_cluster_id == SIZE_MAX) {continue;+ }// If inner Buffer is not connected to the Loop - `window` sliding effect is not possibleLoopPortInfo final_loop_info;- if (!init_buffer_last_loop_port_info(loop_manager, inner_buffer_expr, final_loop_info))+ if (!init_buffer_last_loop_port_info(loop_manager, inner_buffer_expr, final_loop_info)) {continue;+ }auto unite = [&](const BufferMap& ports, const bool is_input) {bool applied = false;@@ -233,12 +263,14 @@ void DefineBufferClusters::parse_nested_loops(const LoopManagerPtr& loop_managerconst auto cluster_it = find_cluster_by_expr(port.first);OPENVINO_ASSERT(cluster_it != m_clusters.cend(), "Buffer cluster has not been found");// If the buffers are already in the same cluster or have different Buffer ID - skip- if (cluster_it == inner_cluster_it)+ if (cluster_it == inner_cluster_it) {continue;+ }// Buffer from one cluster must be only defined (with known allocation_size) or dynamic (with// unknown allocation_size)- if (inner_buffer_expr->is_defined() != port.first->is_defined())+ if (inner_buffer_expr->is_defined() != port.first->is_defined()) {continue;+ }// The inner Buffer can reuse memory of the outer Buffer using `window` sliding only if:// - The finalization offset of the latest Loop connected to the inner Buffer is equal to// pointer increment of outer Buffer to emulate `window` sliding@@ -247,20 +279,24 @@ void DefineBufferClusters::parse_nested_loops(const LoopManagerPtr& loop_manager// It's needed because all Loops reset data pointers of connected Buffer after full work.// To avoid rewriting of outer Buffer data we have to have the same Buffer ID (GPR) to// proportionally shift pointers both Buffers.- if (!can_be_data_ptr_proportionally_shifted(port.second, final_loop_info))+ if (!can_be_data_ptr_proportionally_shifted(port.second, final_loop_info)) {continue;+ }applied = unite_nested_clusters(loop_manager, inner_cluster_it, *cluster_it, port.first, is_input);- if (applied)+ if (applied) {break;+ }}return applied;};- if (unite(input_buffers, true))+ if (unite(input_buffers, true)) {continue;- if (unite(output_buffers, false))+ }+ if (unite(output_buffers, false)) {continue;+ }}}}@@ -271,8 +307,9 @@ bool DefineBufferClusters::init_buffer_last_loop_port_info(const LoopManagerPtr&auto get_direct_loop_for_buffer_out = [&](const BufferExpressionPtr& buffer_expr,const ExpressionPtr& consumer_expr) -> UnifiedLoopInfoPtr {const auto inner_loops = get_connected_loops(buffer_expr, consumer_expr);- if (inner_loops.empty())+ if (inner_loops.empty()) {return nullptr;+ }return loop_manager->get_loop_info<UnifiedLoopInfo>(inner_loops.front());};@@ -314,14 +351,16 @@ bool DefineBufferClusters::unite_nested_clusters(const LoopManagerPtr& loop_manafor (const auto& loop_id : connected_loops) {const auto& common_loop_info = loop_manager->get_loop_info<UnifiedLoopInfo>(loop_id);if (!common_loop_info->is_loop_port(lower_buffer_source) ||- !common_loop_info->is_loop_port(upper_buffer_consumer))+ !common_loop_info->is_loop_port(upper_buffer_consumer)) {continue;+ }const auto upper_port_desc = common_loop_info->get_loop_port_info(upper_buffer_consumer);const auto lower_port_desc = common_loop_info->get_loop_port_info(lower_buffer_source);if (SetBufferRegGroup::can_be_in_one_reg_group(upper_port_desc, lower_port_desc)) {- for (const auto& inner_buffer : *inner_cluster_it)+ for (const auto& inner_buffer : *inner_cluster_it) {inner_buffer->set_reg_group(outer_buffer->get_reg_group());+ }add_buffers_to_cluster(outer_cluster, *inner_cluster_it);m_clusters.erase(inner_cluster_it);@@ -339,14 +378,16 @@ void DefineBufferClusters::parse_memory_access_op(const ExpressionPtr& expr) {// Need to add mechanism of inplace ports using MemoryAccess::PortDescriptor::inplacefor (const auto& input : expr->get_input_port_connectors()) {const auto& buffer_expr = ov::as_type_ptr<BufferExpression>(input->get_source().get_expr());- if (is_direct_buffer(buffer_expr, expr))+ if (is_direct_buffer(buffer_expr, expr)) {create_new_cluster(buffer_expr);+ }}for (const auto& output : expr->get_output_port_connectors()) {for (const auto& consumer : output->get_consumers()) {const auto& buffer_expr = ov::as_type_ptr<BufferExpression>(consumer.get_expr());- if (is_direct_buffer(buffer_expr, expr))+ if (is_direct_buffer(buffer_expr, expr)) {create_new_cluster(buffer_expr);+ }}}}@@ -382,7 +423,4 @@ bool DefineBufferClusters::run(lowered::LinearIR& linear_ir,return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/extract_loop_invariants.cpp b/src/common/snippets/src/lowered/pass/extract_loop_invariants.cppindex c4cbd79b7b1..a24e32451ea 100644--- a/src/common/snippets/src/lowered/pass/extract_loop_invariants.cpp+++ b/src/common/snippets/src/lowered/pass/extract_loop_invariants.cpp@@ -4,15 +4,26 @@#include "snippets/lowered/pass/extract_loop_invariants.hpp"+#include <algorithm>+#include <cstddef>+#include <cstdint>+#include <memory>+#include <tuple>+#include <unordered_set>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression.hpp"#include "snippets/lowered/linear_ir.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/lowered/loop_info.hpp"+#include "snippets/lowered/loop_manager.hpp"+#include "snippets/lowered/loop_port.hpp"+#include "snippets/op/scalar.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {namespace {// Sort Loop IDs by execution order of these Loops@@ -20,8 +31,9 @@ std::vector<size_t> get_reordered_loop_ids(const LoopManagerPtr& loop_manager) {const auto& loop_map = loop_manager->get_map();std::vector<size_t> loop_ids_need_extract;loop_ids_need_extract.reserve(loop_map.size());- for (const auto& p : loop_map)+ for (const auto& p : loop_map) {loop_ids_need_extract.push_back(p.first);+ }auto sorter = [&](size_t lhs, size_t rhs) {const auto lhs_last_expr =@@ -32,10 +44,12 @@ std::vector<size_t> get_reordered_loop_ids(const LoopManagerPtr& loop_manager) {// IDs.if (lhs_last_expr == rhs_last_expr) {for (const auto& id : lhs_last_expr->get_loop_ids()) {- if (id == lhs)+ if (id == lhs) {return false;- if (id == rhs)+ }+ if (id == rhs) {return true;+ }}OPENVINO_THROW("Incorrect Loop IDs");} else {@@ -61,9 +75,8 @@ int64_t get_stride_after_move_outer(const LoopPort& loop_port) {int64_t stride = utils::get_stride(shape_dim_idx, shape);if (utils::is_dynamic_value(stride) || utils::is_dynamic_value(shape[shape_dim_idx])) {return utils::get_dynamic_value<int64_t>();- } else {- return stride * static_cast<int64_t>(shape[shape_dim_idx]);}+ return stride * static_cast<int64_t>(shape[shape_dim_idx]);}bool is_extraction_applicable(const ExpressionPtr& expr, const UnifiedLoopInfoPtr& inner_loop_info, size_t loop_id) {@@ -71,13 +84,15 @@ bool is_extraction_applicable(const ExpressionPtr& expr, const UnifiedLoopInfoPt// We cannot extract Expression from the outermost or any intermediate Loop with other Loops insideconst auto& loop_ids = expr->get_loop_ids();OPENVINO_ASSERT(!loop_ids.empty(), "Expression must be in a Loop");- if (loop_ids.back() != loop_id)+ if (loop_ids.back() != loop_id) {return false;+ }const auto& expr_input_ports = expr->get_input_ports();const auto& input_port_size = expr_input_ports.size();- if (input_port_size == 0)+ if (input_port_size == 0) {return false;+ }for (size_t i = 0; i < input_port_size; ++i) {const auto& parent = expr->get_input_port_connector(i)->get_source().get_expr();@@ -158,8 +173,8 @@ void update_loop_ports(const ExpressionPtr& expr, const LoopManagerPtr& loop_manstd::vector<ExpressionPtr> get_loop_input_exprs(const std::vector<LoopPort>& loop_in_ports) {std::vector<ExpressionPtr> input_exprs;std::unordered_set<ExpressionPtr> seen_exprs;- for (size_t port_num = 0; port_num < loop_in_ports.size(); ++port_num) {- const auto& expr = loop_in_ports[port_num].get_expr_port()->get_expr();+ for (const auto& loop_in_port : loop_in_ports) {+ const auto& expr = loop_in_port.get_expr_port()->get_expr();if (seen_exprs.count(expr) == 0) {input_exprs.push_back(expr);seen_exprs.insert(expr);@@ -208,22 +223,23 @@ bool extract_from_loop(const size_t& inner_loop_id, LinearIR& linear_ir) {// while() to start again.}}- if (inner_loop_input_ports.size() == 0 && inner_loop_info->get_output_ports().size() == 0) {+ if (inner_loop_input_ports.empty() && inner_loop_info->get_output_ports().empty()) {// If the loop becomes empty (inner_loop_input_ports is ref) after extraction, remove it from loop_managerloop_manager->remove_loop_info(inner_loop_id);break;}// no more extractable expr in this loop after go through all potential_extractable_exprs, done for this loop.- if (!expr_extracted)+ if (!expr_extracted) {continue_to_extract = false;+ }}return status;}} // namespacebool ExtractLoopInvariants::run(LinearIR& linear_ir,- lowered::LinearIR::constExprIt begin,- lowered::LinearIR::constExprIt end) {+ [[maybe_unused]] lowered::LinearIR::constExprIt begin,+ [[maybe_unused]] lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::ExtractLoopInvariants")bool modified = false;@@ -236,7 +252,4 @@ bool ExtractLoopInvariants::run(LinearIR& linear_ir,return modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/fuse_loops.cpp b/src/common/snippets/src/lowered/pass/fuse_loops.cppindex b2dab156fa0..9284341c3f6 100644--- a/src/common/snippets/src/lowered/pass/fuse_loops.cpp+++ b/src/common/snippets/src/lowered/pass/fuse_loops.cpp@@ -4,16 +4,31 @@#include "snippets/lowered/pass/fuse_loops.hpp"+#include <algorithm>+#include <cstddef>+#include <iterator>+#include <memory>+#include <set>+#include <tuple>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/parameter.hpp"+#include "openvino/op/result.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression_port.hpp"#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/loop_manager.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/lowered/loop_port.hpp"+#include "snippets/lowered/pass/pass.hpp"+#include "snippets/lowered/specific_loop_iter_types.hpp"+#include "snippets/op/buffer.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {namespace {bool is_loop_id_found(const std::vector<size_t>& ids, size_t id) {return std::find(ids.cbegin(), ids.cend(), id) != ids.cend();@@ -25,29 +40,32 @@ FuseLoops::FuseLoops() : RangedPass() {}bool FuseLoops::loop_ports_are_compatible(const LoopInfoPtr& loop_upper, const LoopInfoPtr& loop_lower) {auto found_port = [](const std::vector<LoopPort>& loop_ports, const ExpressionPort& target_port) {return std::find_if(loop_ports.cbegin(), loop_ports.cend(), [&target_port](const LoopPort& loop_port) {- return *(loop_port.get_expr_port().get()) == target_port;+ return *(loop_port.get_expr_port()) == target_port;});};const auto& upper_exit_ports = loop_upper->get_output_ports();const auto& lower_entry_ports = loop_lower->get_input_ports();- for (const auto& lower_entry_port : lower_entry_ports) {+ return std::all_of(lower_entry_ports.cbegin(), lower_entry_ports.cend(), [&](const LoopPort& lower_entry_port) {const auto& src_port = lower_entry_port.get_expr_port()->get_port_connector_ptr()->get_source();const auto upper_exit_port_it = found_port(upper_exit_ports, src_port);if (upper_exit_port_it != upper_exit_ports.cend()) {const auto& upper_exit_port = *upper_exit_port_it;- if (!lower_entry_port.is_incremented() || !upper_exit_port.is_incremented())+ if (!lower_entry_port.is_incremented() || !upper_exit_port.is_incremented()) {return false;- if (lower_entry_port.get_dim_idx() != upper_exit_port.get_dim_idx())+ }+ if (lower_entry_port.get_dim_idx() != upper_exit_port.get_dim_idx()) {return false;+ }}- }- return true;+ return true;+ });}bool FuseLoops::can_be_fused(const UnifiedLoopInfoPtr& loop_upper, const UnifiedLoopInfoPtr& loop_lower) {OPENVINO_ASSERT(loop_upper != nullptr && loop_lower != nullptr, "LoopInfo is nullptr!");- if (!loop_ports_are_compatible(loop_upper, loop_lower))+ if (!loop_ports_are_compatible(loop_upper, loop_lower)) {return false;+ }// Loop fusion is supported only if Loops have equal/broadcastable increments and work amounts.// Note: For example, Broadcastable work amounts are possible in the following case:// Relu_0 [16x1] Relu_1 [16x128]@@ -115,8 +133,9 @@ bool FuseLoops::fuse_upper_into_current(LinearIR& linear_ir,LinearIR::constExprIt& current_loop_end_pos) {const auto& loop_current = loop_manager->get_loop_info<UnifiedLoopInfo>(current_loop_id);const auto& loop_target = loop_manager->get_loop_info<UnifiedLoopInfo>(target_loop_id);- if (!can_be_fused(loop_target, loop_current))+ if (!can_be_fused(loop_target, loop_current)) {return false;+ }// We can fuse Loop_up to Loop_down only in cases when other consumers of Loop_up are after Loop_down// Because Loop_up should be explicitly moved before Loop_down in linear IR, and we must save control dependency@@ -126,8 +145,9 @@ bool FuseLoops::fuse_upper_into_current(LinearIR& linear_ir,const auto consumer_inputs = target_output_port.get_expr_port()->get_connected_ports();for (const auto& consumer_input : consumer_inputs) {const auto& consumer = consumer_input.get_expr();- if (ov::is_type<ov::op::v0::Result>(consumer->get_node()) || consumer == current_input_port->get_expr())+ if (ov::is_type<ov::op::v0::Result>(consumer->get_node()) || consumer == current_input_port->get_expr()) {continue;+ }// The fusing is only valid if target Loop consumer (the Consumer is outside of target Loop)// is after current Loop (after Loop_down).is_fusion_allowed =@@ -137,16 +157,18 @@ bool FuseLoops::fuse_upper_into_current(LinearIR& linear_ir,}}- if (!is_fusion_allowed)+ if (!is_fusion_allowed) {return false;+ }LinearIR::constExprIt target_loop_begin_pos, target_loop_end_pos;std::tie(target_loop_begin_pos, target_loop_end_pos) = loop_manager->get_loop_bounds(linear_ir, target_loop_id);loop_manager->fuse_loops(target_loop_begin_pos, target_loop_end_pos, target_loop_id, current_loop_id, false);const auto insertion_place = current_loop_begin_pos;const auto is_move_needed = target_loop_end_pos != current_loop_begin_pos;- if (is_move_needed)+ if (is_move_needed) {move(linear_ir, loop_manager, current_loop_id, target_loop_begin_pos, target_loop_end_pos, insertion_place);+ }// Update current Loop bounds:current_loop_begin_pos = target_loop_begin_pos;@@ -163,8 +185,9 @@ bool FuseLoops::fuse_lower_into_current(LinearIR& linear_ir,LinearIR::constExprIt& current_loop_end_pos) {const auto& loop_current = loop_manager->get_loop_info<UnifiedLoopInfo>(current_loop_id);const auto& loop_target = loop_manager->get_loop_info<UnifiedLoopInfo>(target_loop_id);- if (!can_be_fused(loop_current, loop_target))+ if (!can_be_fused(loop_current, loop_target)) {return false;+ }// We can fuse Loop_down to Loop_up only in cases when other parents of Loop_down are before Loop_up// Because Loop_down should be explicitly moved after Loop_up in linear IR, and we must save control dependency@@ -174,16 +197,18 @@ bool FuseLoops::fuse_lower_into_current(LinearIR& linear_ir,const auto parent_expr_output = *target_entry_port.get_expr_port()->get_connected_ports().begin();const auto& parent_expr = parent_expr_output.get_expr();if (ov::is_type<ov::op::v0::Parameter>(parent_expr->get_node()) ||- parent_expr == current_output_port->get_expr())+ parent_expr == current_output_port->get_expr()) {continue;+ }is_fusion_allowed = is_loop_id_found(parent_expr->get_loop_ids(),current_loop_id) || // The parent expr is from the same current Loopparent_expr->get_exec_num() <(*current_loop_begin_pos)->get_exec_num(); // The parent is before current Loop}- if (!is_fusion_allowed)+ if (!is_fusion_allowed) {return false;+ }LinearIR::constExprIt target_loop_begin_pos, target_loop_end_pos;std::tie(target_loop_begin_pos, target_loop_end_pos) = loop_manager->get_loop_bounds(linear_ir, target_loop_id);@@ -205,10 +230,11 @@ bool FuseLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lstd::set<size_t> prev_fused_loops;for (auto expr_it = begin; expr_it != end; expr_it++) {- const auto expr = *expr_it;+ const auto& expr = *expr_it;const auto& node = expr->get_node();- if (ov::is_type_any_of<ov::op::v0::Parameter, ov::op::v0::Constant, ov::op::v0::Result>(node))+ if (ov::is_type_any_of<ov::op::v0::Parameter, ov::op::v0::Constant, ov::op::v0::Result>(node)) {continue;+ }// Outer Loop ----> Inner Loopconst auto& current_expr_loops = expr->get_loop_ids();@@ -217,8 +243,9 @@ bool FuseLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lconst auto current_loop_id = current_expr_loops[i];// If the current Loop ID is in prev fused Loops, it means that on previous step all possible fusions are// completed- if (prev_fused_loops.count(current_loop_id) != 0)+ if (prev_fused_loops.count(current_loop_id) != 0) {continue;+ }// We fuse upper Loops into the current till we can do it.// After that we fuse lower Loops into the current till we can do it.@@ -247,18 +274,21 @@ bool FuseLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, l}const auto& upper_loop_ids = parent_expr->get_loop_ids();- if (upper_loop_ids.empty())+ if (upper_loop_ids.empty()) {continue;+ }size_t loop_idx = 0;bool allowed = true;for (; loop_idx < std::min(i, upper_loop_ids.size()) && allowed; ++loop_idx) {- if (current_expr_loops[loop_idx] != upper_loop_ids[loop_idx])+ if (current_expr_loops[loop_idx] != upper_loop_ids[loop_idx]) {allowed = false;+ }}// There are different outer loops or all Loop IDs are the same- if (!allowed || loop_idx == upper_loop_ids.size())+ if (!allowed || loop_idx == upper_loop_ids.size()) {continue;+ }const auto upper_loop_id = upper_loop_ids[loop_idx];OPENVINO_ASSERT(current_loop_id != upper_loop_id,@@ -279,8 +309,9 @@ bool FuseLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, l}// If Loops were fused and there are new input_ports, we should check for possible fusion again- if (was_fusion_up && input_ports != current_loop_info->get_input_ports())+ if (was_fusion_up && input_ports != current_loop_info->get_input_ports()) {continue;+ }// Loop_0 (Current) Loop_0 + Loop_1 => new `Loop_0`// | => |@@ -298,24 +329,28 @@ bool FuseLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, l}const auto& lower_loop_ids = consumer_expr->get_loop_ids();- if (lower_loop_ids.empty())+ if (lower_loop_ids.empty()) {continue;+ }size_t loop_idx = 0;bool allowed = true;for (; loop_idx < std::min(i, lower_loop_ids.size()) && allowed; ++loop_idx) {- if (current_expr_loops[loop_idx] != lower_loop_ids[loop_idx])+ if (current_expr_loops[loop_idx] != lower_loop_ids[loop_idx]) {allowed = false;+ }}// There are different outer loops or all Loop IDs are the same- if (!allowed || loop_idx == lower_loop_ids.size())+ if (!allowed || loop_idx == lower_loop_ids.size()) {continue;+ }const auto lower_loop_id = lower_loop_ids[loop_idx];// if expressions have the same loop ID, it means that they're from the same Loop (one of// consumers is in Loop)- if (current_loop_id == lower_loop_id)+ if (current_loop_id == lower_loop_id) {continue;+ }if (fuse_lower_into_current(linear_ir,loop_manager,@@ -335,8 +370,9 @@ bool FuseLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, l// We iterated by each output port and didn't fuse new Loops -> we can finish check for possible fusions// on outputs.- if (!was_fusion_down)+ if (!was_fusion_down) {need_fusion_checks = false;+ }}}}@@ -344,7 +380,4 @@ bool FuseLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lreturn true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/init_buffers_default.cpp b/src/common/snippets/src/lowered/pass/init_buffers_default.cppindex 0077b33416e..4e6f908dc2f 100644--- a/src/common/snippets/src/lowered/pass/init_buffers_default.cpp+++ b/src/common/snippets/src/lowered/pass/init_buffers_default.cpp@@ -4,17 +4,17 @@#include "snippets/lowered/pass/init_buffers_default.hpp"+#include <cstddef>+#include "snippets/itt.hpp"-#include "snippets/op/buffer.hpp"+#include "snippets/lowered/linear_ir.hpp"+#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {bool InitBuffersDefault::run(lowered::LinearIR& linear_ir,- lowered::LinearIR::constExprIt begin,- lowered::LinearIR::constExprIt end) {+ [[maybe_unused]] lowered::LinearIR::constExprIt begin,+ [[maybe_unused]] lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::InitBuffersDefault");size_t idx = 0;@@ -36,7 +36,4 @@ bool InitBuffersDefault::run(lowered::LinearIR& linear_ir,return m_buffer_scratchpad_size > 0;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/init_live_ranges.cpp b/src/common/snippets/src/lowered/pass/init_live_ranges.cppindex 56906196b16..3f290375e1c 100644--- a/src/common/snippets/src/lowered/pass/init_live_ranges.cpp+++ b/src/common/snippets/src/lowered/pass/init_live_ranges.cpp@@ -4,14 +4,25 @@#include "snippets/lowered/pass/init_live_ranges.hpp"+#include <algorithm>+#include <cstddef>+#include <iterator>+#include <map>+#include <set>+#include <stack>+#include <utility>++#include "openvino/core/type.hpp"+#include "snippets/emitter.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression.hpp"#include "snippets/lowered/expressions/buffer_expression.hpp"+#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/port_connector.hpp"+#include "snippets/op/perf_count.hpp"#include "snippets/op/subgraph.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {namespace {// Expressions that don't affect lifetime of registers, e.g. Buffer or RankNormalizationinline bool pass_through_expr(const ExpressionPtr& expr) {@@ -48,8 +59,9 @@ bool InitLiveRanges::run(LinearIR& linear_ir) {regs_to_expire.erase(regs_to_expire.begin(),regs_to_expire.lower_bound(start)); // remove all elements lower than start (not equal)- for (const auto& time_reg : regs_to_expire)+ for (const auto& time_reg : regs_to_expire) {live_regs.insert(time_reg.second.begin(), time_reg.second.end());+ }expr->set_live_regs(std::move(live_regs));}@@ -58,8 +70,9 @@ bool InitLiveRanges::run(LinearIR& linear_ir) {// expressions) and to propagate new registers to the consumersfor (size_t i = 0; i < expr->get_output_count(); ++i) {const auto& out_pd = expr->get_output_port_descriptor(i);- if (out_pd->get_reg().is_defined())+ if (out_pd->get_reg().is_defined()) {continue;+ }const auto reg_type = m_reg_manager.get_reg_type(op->output(i));const auto& reg = Reg(reg_type, reg_counter[reg_type]++);double stop = start;@@ -77,8 +90,9 @@ bool InitLiveRanges::run(LinearIR& linear_ir) {// Note: pass_through expression don't affect registers' life times,// so we should examine their consumers to understand when the register will actually be usedif (pass_through_expr(consumer_expr)) {- for (const auto& connector : consumer_expr->get_output_port_connectors())+ for (const auto& connector : consumer_expr->get_output_port_connectors()) {to_visit.push(connector);+ }}}}@@ -90,7 +104,4 @@ bool InitLiveRanges::run(LinearIR& linear_ir) {return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/init_loops.cpp b/src/common/snippets/src/lowered/pass/init_loops.cppindex c77541cb870..04f9971c4fc 100644--- a/src/common/snippets/src/lowered/pass/init_loops.cpp+++ b/src/common/snippets/src/lowered/pass/init_loops.cpp@@ -4,16 +4,21 @@#include "snippets/lowered/pass/init_loops.hpp"+#include <cstdint>+#include <memory>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression_port.hpp"#include "snippets/lowered/linear_ir.hpp"-#include "snippets/op/buffer.hpp"+#include "snippets/lowered/loop_info.hpp"+#include "snippets/lowered/loop_manager.hpp"+#include "snippets/lowered/loop_port.hpp"#include "snippets/op/memory_access.hpp"#include "snippets/utils/loop_utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {namespace {inline void init_is_incremented(LoopPort& port) {@@ -28,12 +33,12 @@ inline int64_t get_data_size(const LoopPort& loop_port) {if (expr_port->get_type() == ExpressionPort::Input) {return static_cast<int64_t>(expr_port->get_expr()->get_node()->get_input_element_type(expr_port->get_index()).size());- } else if (expr_port->get_type() == ExpressionPort::Output) {+ }+ if (expr_port->get_type() == ExpressionPort::Output) {return static_cast<int64_t>(expr_port->get_expr()->get_node()->get_output_element_type(expr_port->get_index()).size());- } else {- OPENVINO_THROW("Unsupported expression port type!");}+ OPENVINO_THROW("Unsupported expression port type!");}} // namespace@@ -47,8 +52,9 @@ void InitLoops::update_compile_parameters(const UnifiedLoopInfoPtr& loop_info) {bool InitLoops::run(LinearIR& linear_ir) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::InitLoops")- if (linear_ir.empty())+ if (linear_ir.empty()) {return false;+ }const auto& loops = linear_ir.get_loop_manager()->get_map();for (const auto& loop : loops) {@@ -60,7 +66,4 @@ bool InitLoops::run(LinearIR& linear_ir) {return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/init_registers.cpp b/src/common/snippets/src/lowered/pass/init_registers.cppindex 1d4c1bc8b13..a6907e0ac05 100644--- a/src/common/snippets/src/lowered/pass/init_registers.cpp+++ b/src/common/snippets/src/lowered/pass/init_registers.cpp@@ -4,15 +4,18 @@#include "snippets/lowered/pass/init_registers.hpp"+#include <memory>++#include "snippets/generator.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/pass/assign_registers.hpp"#include "snippets/lowered/pass/init_live_ranges.hpp"#include "snippets/lowered/pass/insert_reg_spills.hpp"+#include "snippets/lowered/pass/pass.hpp"+#include "snippets/lowered/pass/pass_config.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {InitRegisters::InitRegisters(const std::shared_ptr<const Generator>& generator,const std::shared_ptr<PassConfig>& pass_config)@@ -30,7 +33,4 @@ bool InitRegisters::run(LinearIR& linear_ir) {return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/insert_broadcastmove.cpp b/src/common/snippets/src/lowered/pass/insert_broadcastmove.cppindex 399965c72a4..101e228746a 100644--- a/src/common/snippets/src/lowered/pass/insert_broadcastmove.cpp+++ b/src/common/snippets/src/lowered/pass/insert_broadcastmove.cpp@@ -4,16 +4,29 @@#include "snippets/lowered/pass/insert_broadcastmove.hpp"+#include <algorithm>+#include <cstddef>+#include <memory>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/type.hpp"+#include "openvino/op/prelu.hpp"+#include "openvino/op/util/attr_types.hpp"+#include "openvino/op/util/op_types.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression.hpp"#include "snippets/lowered/linear_ir.hpp"-#include "snippets/lowered/loop_manager.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/lowered/port_connector.hpp"+#include "snippets/lowered/port_descriptor.hpp"+#include "snippets/op/broadcastmove.hpp"+#include "snippets/op/fill.hpp"+#include "snippets/op/memory_access.hpp"+#include "snippets/op/vector_buffer.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {bool InsertBroadcastMove::is_broadcasting_supported(const std::shared_ptr<ov::Node>& n) {return !std::dynamic_pointer_cast<modifier::MemoryAccess>(n) &&@@ -37,7 +50,7 @@ std::vector<size_t> InsertBroadcastMove::get_last_dims(const ExpressionPtr& exprdescriptors.end(),last_dims.begin(),[](const std::shared_ptr<PortDescriptor>& d) {- return d->get_shape().size() > 0 ? d->get_shape().back() : 1;+ return !d->get_shape().empty() ? d->get_shape().back() : 1;});return last_dims;}@@ -46,8 +59,9 @@ size_t InsertBroadcastMove::get_max_dim(const std::vector<size_t>& last_dims) {// Specially set 0 to distinguish it from scalar or dynamic value (it's max value)size_t broadcast_dim = 0;for (const auto& last_dim : last_dims) {- if (!utils::is_dynamic_value(last_dim) && last_dim > broadcast_dim)+ if (!utils::is_dynamic_value(last_dim) && last_dim > broadcast_dim) {broadcast_dim = last_dim;+ }}return broadcast_dim;}@@ -61,13 +75,15 @@ bool InsertBroadcastMove::run(LinearIR& linear_ir,for (auto expr_it = begin; expr_it != end; expr_it++) {const auto& expr = *expr_it;const auto& node = expr->get_node();- if (!is_broadcasting_supported(node) || expr->get_input_count() < 2)+ if (!is_broadcasting_supported(node) || expr->get_input_count() < 2) {continue;+ }const auto last_dims = get_last_dims(expr);const auto broadcasted_dim = get_max_dim(last_dims);- if (broadcasted_dim == 0)+ if (broadcasted_dim == 0) {continue;+ }for (size_t i = 0; i < last_dims.size(); i++) {const auto& input = expr->get_input_port_connector(i);@@ -104,7 +120,4 @@ bool InsertBroadcastMove::run(LinearIR& linear_ir,return modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/insert_buffers.cpp b/src/common/snippets/src/lowered/pass/insert_buffers.cppindex df28e9afadb..3000c57a529 100644--- a/src/common/snippets/src/lowered/pass/insert_buffers.cpp+++ b/src/common/snippets/src/lowered/pass/insert_buffers.cpp@@ -4,15 +4,30 @@#include "snippets/lowered/pass/insert_buffers.hpp"+#include <algorithm>+#include <cstddef>+#include <iterator>+#include <memory>+#include <set>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/parameter.hpp"+#include "openvino/op/result.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/expression_port.hpp"#include "snippets/lowered/linear_ir.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/lowered/loop_port.hpp"+#include "snippets/op/buffer.hpp"+#include "snippets/op/memory_access.hpp"+#include "snippets/op/rank_normalization.hpp"+#include "snippets/op/vector_buffer.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {namespace {std::vector<size_t> get_buffer_loop_ids(const std::vector<size_t>& lhs,const std::vector<size_t>& rhs,@@ -51,8 +66,9 @@ LinearIR::constExprIt InsertBuffers::insertion_position(const LinearIR& linear_iconst auto down_loop_count = down_loops.size();size_t loop_idx = 0;for (; loop_idx < std::min(up_loop_count, down_loop_count); ++loop_idx) {- if (up_loops[loop_idx] != down_loops[loop_idx])+ if (up_loops[loop_idx] != down_loops[loop_idx]) {break;+ }}// If upper expression is inside Loop, we should insert Buffer after this Loopif (loop_idx < up_loop_count) {@@ -73,10 +89,9 @@ LinearIR::constExprIt InsertBuffers::insertion_position(const LinearIR& linear_ivoid InsertBuffers::insertion(LinearIR& linear_ir,const LinearIR::constExprIt& begin_it,- const LinearIR::constExprIt& end_it,const LoopManagerPtr& loop_manager,const std::vector<ExpressionPort>& loop_entries,- const std::vector<ExpressionPort>& loop_exits) const {+ const std::vector<ExpressionPort>& loop_exits) {for (const auto& entry_port : loop_entries) {const auto& expr = entry_port.get_expr();const auto port_idx = entry_port.get_index();@@ -99,8 +114,9 @@ void InsertBuffers::insertion(LinearIR& linear_ir,op::VectorBuffer,ov::op::v0::Parameter,ov::op::v0::Constant,- op::RankNormalization>(parent))+ op::RankNormalization>(parent)) {continue;+ }// Each MemoryAccess op needs Bufferconst auto parent_ma = std::dynamic_pointer_cast<modifier::MemoryAccess>(parent);@@ -132,7 +148,7 @@ void InsertBuffers::insertion(LinearIR& linear_ir,const auto& expr = exit_port.get_expr();const auto port_idx = exit_port.get_index();const auto node = expr->get_node();- const auto output_connector = exit_port.get_port_connector_ptr();+ const auto& output_connector = exit_port.get_port_connector_ptr();const auto child_exprs_inputs = output_connector->get_consumers();const auto& current_loops = expr->get_loop_ids();@@ -150,8 +166,9 @@ void InsertBuffers::insertion(LinearIR& linear_ir,const auto& child_expr = child_expr_input.get_expr();const auto child_port = child_expr_input.get_index();const auto& child = child_expr->get_node();- if (ov::is_type<ov::op::v0::Result>(child))+ if (ov::is_type<ov::op::v0::Result>(child)) {continue;+ }if (ov::is_type<op::Buffer>(child)) {update_buffer_loop_ids(child_expr->get_loop_ids());buffers.insert(child_expr);@@ -239,15 +256,16 @@ bool InsertBuffers::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begireturn expr_ports;};// using begin() as expr_it because we work with LoopInfo, not expressions in Linear IR- insertion(linear_ir, begin, end, loop_manager, cvt_to_expr_ports(loop_entries), cvt_to_expr_ports(loop_exits));+ insertion(linear_ir, begin, loop_manager, cvt_to_expr_ports(loop_entries), cvt_to_expr_ports(loop_exits));}for (auto expr_it = begin; expr_it != end; expr_it++) {- const auto expr = *expr_it;+ const auto& expr = *expr_it;const auto node = (*expr_it)->get_node();const auto ma = std::dynamic_pointer_cast<modifier::MemoryAccess>(node);- if (!ma)+ if (!ma) {continue;+ }const auto input_ports = ma->get_memory_access_input_ports();const auto output_ports = ma->get_memory_access_output_ports();@@ -259,13 +277,10 @@ bool InsertBuffers::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begiloop_exits[p.first] = expr->get_output_port(p.first);}- insertion(linear_ir, expr_it, end, loop_manager, loop_entries, loop_exits);+ insertion(linear_ir, expr_it, loop_manager, loop_entries, loop_exits);}return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/insert_load_store.cpp b/src/common/snippets/src/lowered/pass/insert_load_store.cppindex 84d194a0f9f..ac3b90dd689 100644--- a/src/common/snippets/src/lowered/pass/insert_load_store.cpp+++ b/src/common/snippets/src/lowered/pass/insert_load_store.cpp@@ -4,17 +4,27 @@#include "snippets/lowered/pass/insert_load_store.hpp"+#include <algorithm>+#include <cstddef>+#include <iterator>+#include <memory>+#include <vector>++#include "openvino/core/type.hpp"+#include "openvino/op/parameter.hpp"+#include "openvino/op/result.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/expression_port.hpp"+#include "snippets/lowered/expressions/buffer_expression.hpp"#include "snippets/lowered/linear_ir.hpp"-#include "snippets/lowered/loop_manager.hpp"-#include "snippets/op/rank_normalization.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/lowered/port_connector.hpp"+#include "snippets/op/load.hpp"+#include "snippets/op/memory_access.hpp"+#include "snippets/op/store.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {InsertLoadStore::InsertLoadStore(size_t vector_size) : m_vector_size(vector_size) {}@@ -33,8 +43,9 @@ bool InsertLoadStore::insert_load(LinearIR& linear_ir, const LinearIR::constExprconst auto& consumer_expr = consumer_input.get_expr();const auto& consumer = consumer_expr->get_node();const auto ma = std::dynamic_pointer_cast<modifier::MemoryAccess>(consumer);- if (ma && ma->is_memory_access_input_port(consumer_input.get_index()))+ if (ma && ma->is_memory_access_input_port(consumer_input.get_index())) {continue;+ }const auto load = std::make_shared<op::Load>(data_ngraph_output, get_count(data_expr->get_output_port(0)));linear_ir.insert_node(load,@@ -58,8 +69,9 @@ bool InsertLoadStore::insert_store(LinearIR& linear_ir, const LinearIR::constExpconst auto port = parent_output.get_index();const auto& parent = parent_expr->get_node();const auto ma = std::dynamic_pointer_cast<modifier::MemoryAccess>(parent);- if (ma && ma->is_memory_access_output_port(port))+ if (ma && ma->is_memory_access_output_port(port)) {return false;+ }const auto& loop_ids = parent_expr->get_loop_ids();const auto store = std::make_shared<op::Store>(parent->output(port), get_count(data_expr->get_input_port(0)));@@ -82,7 +94,7 @@ bool InsertLoadStore::run(LinearIR& linear_ir,bool modified = false;for (auto expr_it = begin; expr_it != end; expr_it++) {- const auto expr = *expr_it;+ const auto& expr = *expr_it;const auto& node = expr->get_node();if (ov::is_type<ov::op::v0::Parameter>(node)) {modified |= insert_load(linear_ir, expr_it);@@ -90,14 +102,12 @@ bool InsertLoadStore::run(LinearIR& linear_ir,modified |= insert_store(linear_ir, expr_it);} else if (ov::is_type<BufferExpression>(expr)) {modified |= insert_load(linear_ir, expr_it);- if (expr->get_input_count() > 0)+ if (expr->get_input_count() > 0) {modified |= insert_store(linear_ir, expr_it);+ }}}return modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/insert_loops.cpp b/src/common/snippets/src/lowered/pass/insert_loops.cppindex 5a4739dc856..5ff4d8b461c 100644--- a/src/common/snippets/src/lowered/pass/insert_loops.cpp+++ b/src/common/snippets/src/lowered/pass/insert_loops.cpp@@ -4,16 +4,23 @@#include "snippets/lowered/pass/insert_loops.hpp"+#include <cstddef>+#include <memory>+#include <set>+#include <vector>++#include "openvino/core/type.hpp"+#include "openvino/op/parameter.hpp"+#include "openvino/op/result.hpp"#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/loop_manager.hpp"-#include "snippets/snippets_isa.hpp"-#include "snippets/utils/utils.hpp"+#include "snippets/lowered/loop_port.hpp"+#include "snippets/lowered/port_connector.hpp"+#include "snippets/op/loop.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {void InsertLoops::insertion(LinearIR& linear_ir, const LoopManagerPtr& loop_manager, size_t loop_id) {const auto loop_info = loop_manager->get_loop_info<UnifiedLoopInfo>(loop_id);@@ -61,10 +68,11 @@ bool InsertLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin,std::set<size_t> inserted_loops;for (auto expr_it = begin; expr_it != end; expr_it++) {- const auto expr = *expr_it;+ const auto& expr = *expr_it;const auto& node = expr->get_node();- if (ov::is_type_any_of<op::LoopBase, ov::op::v0::Parameter, ov::op::v0::Result>(node))+ if (ov::is_type_any_of<op::LoopBase, ov::op::v0::Parameter, ov::op::v0::Result>(node)) {continue;+ }// Outer Loop ----> Inner Loopconst auto& expr_loops = expr->get_loop_ids();@@ -81,7 +89,4 @@ bool InsertLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin,return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/insert_perf_count.cpp b/src/common/snippets/src/lowered/pass/insert_perf_count.cppindex f71332410f3..ab6597f65de 100644--- a/src/common/snippets/src/lowered/pass/insert_perf_count.cpp+++ b/src/common/snippets/src/lowered/pass/insert_perf_count.cpp@@ -5,13 +5,22 @@# include "snippets/lowered/pass/insert_perf_count.hpp"+# include <cstddef>+# include <iterator>+# include <map>+# include <memory>+# include <string>+# include <utility>+# include <vector>++# include "openvino/core/except.hpp"# include "snippets/itt.hpp"# include "snippets/lowered/linear_ir.hpp"+# include "snippets/lowered/pass/pass.hpp"+# include "snippets/lowered/port_connector.hpp"+# include "snippets/op/perf_count.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {InsertPerfCount::InsertPerfCount(std::map<std::string, std::string> boundary_op_names): RangedPass(),@@ -68,8 +77,6 @@ bool InsertPerfCount::run(LinearIR& linear_ir,return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::pass+#endif // SNIPPETS_DEBUG_CAPSdiff --git a/src/common/snippets/src/lowered/pass/insert_perf_count_verbose.cpp b/src/common/snippets/src/lowered/pass/insert_perf_count_verbose.cppindex edaae22691a..926e2857903 100644--- a/src/common/snippets/src/lowered/pass/insert_perf_count_verbose.cpp+++ b/src/common/snippets/src/lowered/pass/insert_perf_count_verbose.cpp@@ -2,22 +2,27 @@// SPDX-License-Identifier: Apache-2.0//+#include <cstddef>+#include <cstdint>+#include <iterator>+#include <memory>+#include <sstream>+#include <string>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/port_connector.hpp"+#include "snippets/op/brgemm.hpp"+#include "snippets/op/perf_count.hpp"#ifdef SNIPPETS_DEBUG_CAPS-# include "snippets/lowered/pass/insert_perf_count_verbose.hpp"-# include "snippets/itt.hpp"# include "snippets/lowered/linear_ir.hpp"-# include "snippets/lowered/loop_manager.hpp"-# include "snippets/lowered/pass/iter_handler.hpp"-# include "snippets/lowered/pass/pass.hpp"-# include "snippets/lowered/pass/propagate_subtensors.hpp"-# include "snippets/snippets_isa.hpp"+# include "snippets/lowered/pass/insert_perf_count_verbose.hpp"# include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {bool InsertPerfCountVerbose::run(snippets::lowered::LinearIR& linear_ir,snippets::lowered::LinearIR::constExprIt begin,@@ -38,8 +43,9 @@ bool InsertPerfCountVerbose::run(snippets::lowered::LinearIR& linear_ir,for (auto expr_it = begin; expr_it != end; expr_it++) {const auto& brgemm_expr = *expr_it;const auto brgemm = ov::as_type_ptr<ov::snippets::op::Brgemm>(brgemm_expr->get_node());- if (!brgemm)+ if (!brgemm) {continue;+ }// Collect brgemm parametersauto params = collect_params(brgemm_expr, linear_ir);@@ -60,7 +66,7 @@ bool InsertPerfCountVerbose::run(snippets::lowered::LinearIR& linear_ir,}std::string InsertPerfCountVerbose::collect_params(const ov::snippets::lowered::ExpressionPtr& brgemm_expr,- const snippets::lowered::LinearIR& linear_ir) {+ const snippets::lowered::LinearIR& /*linear_ir*/) {const auto brgemm = ov::as_type_ptr<ov::snippets::op::Brgemm>(brgemm_expr->get_node());OPENVINO_ASSERT(brgemm, "Brgemm is nullptr!");std::stringstream ss;@@ -86,7 +92,7 @@ std::string InsertPerfCountVerbose::collect_params(const ov::snippets::lowered::ss << utils::tensor2str(shape, " ");ss << ';';}- ss.seekp(-1, ss.cur);+ ss.seekp(-1, std::stringstream::cur);ss << ',';for (size_t i = 0; i < brgemm->outputs().size(); ++i) {const auto& port_desc = brgemm_expr->get_output_port_descriptor(i);@@ -94,7 +100,7 @@ std::string InsertPerfCountVerbose::collect_params(const ov::snippets::lowered::ss << utils::tensor2str(shape, " ");ss << ';';}- ss.seekp(-1, ss.cur);+ ss.seekp(-1, std::stringstream::cur);ss << ',';for (size_t i = 0; i < brgemm->inputs().size(); ++i) {const auto& port_desc = brgemm_expr->get_input_port_descriptor(i);@@ -150,9 +156,6 @@ std::string InsertPerfCountVerbose::collect_params(const ov::snippets::lowered::return ss.str();}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::pass#endif // SNIPPETS_DEBUG_CAPSdiff --git a/src/common/snippets/src/lowered/pass/insert_reg_spills.cpp b/src/common/snippets/src/lowered/pass/insert_reg_spills.cppindex 9103ddeaf82..5829bed937c 100644--- a/src/common/snippets/src/lowered/pass/insert_reg_spills.cpp+++ b/src/common/snippets/src/lowered/pass/insert_reg_spills.cpp@@ -4,16 +4,24 @@#include "snippets/lowered/pass/insert_reg_spills.hpp"+#include <algorithm>+#include <iterator>+#include <memory>+#include <set>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"+#include "snippets/emitter.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression_port.hpp"#include "snippets/lowered/linear_ir.hpp"-#include "snippets/op/brgemm.hpp"+#include "snippets/lowered/port_connector.hpp"+#include "snippets/op/kernel.hpp"+#include "snippets/op/loop.hpp"#include "snippets/op/reg_spill.hpp"-#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {bool InsertRegSpills::run(LinearIR& linear_ir) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::InsertRegSpills")@@ -21,8 +29,9 @@ bool InsertRegSpills::run(LinearIR& linear_ir) {bool modified = false;for (auto it = linear_ir.begin(); it != linear_ir.end(); it++) {const auto& expr = *it;- if (!m_needs_reg_spill(expr))+ if (!m_needs_reg_spill(expr)) {continue;+ }auto start_it = std::prev(it);auto stop_it = std::next(it);while (ov::is_type<snippets::op::LoopBegin>(start_it->get()->get_node()) &&@@ -47,10 +56,12 @@ bool InsertRegSpills::run(LinearIR& linear_ir) {// we also need to keep kernel regs alive (actually only abi_param_1 is used in emitters, but save all for// consistency)for (const auto& r :- m_reg_manager.get_kernel_call_regs(snippets::op::Kernel::make_kernel(linear_ir.is_dynamic())))+ m_reg_manager.get_kernel_call_regs(snippets::op::Kernel::make_kernel(linear_ir.is_dynamic()))) {regs_to_spill.erase(r);- if (regs_to_spill.empty())+ }+ if (regs_to_spill.empty()) {continue;+ }// All spilled regs are not live anymore => update live_regs for affected expressionsfor (auto affected_it = start_it; affected_it != stop_it; affected_it++) {const auto& affected_expr = *affected_it;@@ -96,7 +107,4 @@ bool InsertRegSpills::run(LinearIR& linear_ir) {return modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/insert_specific_iterations.cpp b/src/common/snippets/src/lowered/pass/insert_specific_iterations.cppindex 8eeeb9343d3..b17ebe1d190 100644--- a/src/common/snippets/src/lowered/pass/insert_specific_iterations.cpp+++ b/src/common/snippets/src/lowered/pass/insert_specific_iterations.cpp@@ -4,20 +4,33 @@#include "snippets/lowered/pass/insert_specific_iterations.hpp"+#include <algorithm>#include <array>+#include <cstddef>+#include <cstdint>+#include <iterator>+#include <memory>+#include <tuple>+#include <vector>+#include "openvino/core/except.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/type.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/expressions/buffer_expression.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/linear_ir_builder.hpp"+#include "snippets/lowered/loop_info.hpp"+#include "snippets/lowered/loop_port.hpp"+#include "snippets/lowered/port_connector.hpp"+#include "snippets/lowered/port_descriptor.hpp"#include "snippets/lowered/specific_loop_iter_types.hpp"-#include "snippets/op/buffer.hpp"+#include "snippets/op/loop.hpp"#include "snippets/op/memory_access.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {namespace {void connect_cloned_body_with_buffers_outside(LinearIR::constExprIt cur_begin,@@ -231,8 +244,9 @@ bool InsertSpecificIterations::decompose(LinearIR& linear_ir,std::for_each(decomposed_finalization_offsets.begin(),decomposed_finalization_offsets.end(),[](int64_t& offset) {- if (!utils::is_dynamic_value(offset))+ if (!utils::is_dynamic_value(offset)) {offset = 0;+ }});}@@ -281,7 +295,4 @@ bool InsertSpecificIterations::run(LinearIR& linear_ir,return modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/iter_handler.cpp b/src/common/snippets/src/lowered/pass/iter_handler.cppindex 34faa41658b..0d20cc88aa8 100644--- a/src/common/snippets/src/lowered/pass/iter_handler.cpp+++ b/src/common/snippets/src/lowered/pass/iter_handler.cpp@@ -4,16 +4,22 @@#include "snippets/lowered/pass/iter_handler.hpp"+#include <cstddef>+#include <memory>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/loop_manager.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/lowered/pass/pass.hpp"+#include "snippets/op/fill.hpp"+#include "snippets/op/loop.hpp"+#include "snippets/op/memory_access.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {UpdateMemoryAccessCounts::UpdateMemoryAccessCounts(size_t count) : RangedPass(), m_count(count) {}bool UpdateMemoryAccessCounts::run(LinearIR& linear_ir, LinearIR::constExprIt begin, LinearIR::constExprIt end) {@@ -23,8 +29,9 @@ bool UpdateMemoryAccessCounts::run(LinearIR& linear_ir, LinearIR::constExprIt beconst auto loop_begin = ov::as_type_ptr<op::LoopBegin>(expr_it->get()->get_node());if (loop_begin) {expr_it = linear_ir.find(expr_it, end, linear_ir.get_expr_by_node(loop_begin->get_loop_end()));- if (expr_it == end)+ if (expr_it == end) {return status;+ }continue;}@@ -49,18 +56,20 @@ bool UpdateMemoryAccessCounts::run(LinearIR& linear_ir, LinearIR::constExprIt be}std::shared_ptr<pass::PassBase> UpdateMemoryAccessCounts::merge(const std::shared_ptr<pass::PassBase>& other) {- if (!other)+ if (!other) {return shared_from_this();+ }const auto casted_pass = ov::as_type_ptr<UpdateMemoryAccessCounts>(other);- size_t merged_count;- if (!casted_pass || !ov::snippets::utils::merge_dynamic_dim(merged_count, m_count, casted_pass->m_count))+ size_t merged_count = 0;+ if (!casted_pass || !ov::snippets::utils::merge_dynamic_dim(merged_count, m_count, casted_pass->m_count)) {return nullptr;+ }return std::make_shared<UpdateMemoryAccessCounts>(merged_count);}SetFillOffset::SetFillOffset(size_t offset) : RangedPass(), m_offset(offset) {}-bool SetFillOffset::run(LinearIR& linear_ir, LinearIR::constExprIt begin, LinearIR::constExprIt end) {+bool SetFillOffset::run([[maybe_unused]] LinearIR& linear_ir, LinearIR::constExprIt begin, LinearIR::constExprIt end) {for (auto expr_it = begin; expr_it != end; expr_it++) {const auto& node = expr_it->get()->get_node();if (const auto fill = ov::as_type_ptr<ov::snippets::op::Fill>(node)) {@@ -71,16 +80,20 @@ bool SetFillOffset::run(LinearIR& linear_ir, LinearIR::constExprIt begin, Linear}std::shared_ptr<pass::PassBase> SetFillOffset::merge(const std::shared_ptr<pass::PassBase>& other) {- if (!other)+ if (!other) {return shared_from_this();+ }const auto casted_pass = ov::as_type_ptr<SetFillOffset>(other);- size_t merged_offset;- if (!casted_pass || !ov::snippets::utils::merge_dynamic_dim(merged_offset, m_offset, casted_pass->m_offset))+ size_t merged_offset = 0;+ if (!casted_pass || !ov::snippets::utils::merge_dynamic_dim(merged_offset, m_offset, casted_pass->m_offset)) {return nullptr;+ }return std::make_shared<SetFillOffset>(merged_offset);}-bool SetLoopIncrementOne::run(LinearIR& linear_ir, LinearIR::constExprIt begin, LinearIR::constExprIt end) {+bool SetLoopIncrementOne::run(LinearIR& linear_ir,+ [[maybe_unused]] LinearIR::constExprIt begin,+ LinearIR::constExprIt end) {const auto& loop_end = ov::as_type_ptr<snippets::op::LoopEnd>(end->get()->get_node());OPENVINO_ASSERT(loop_end, "SetLoopIncrementOne expected LoopEnd node in iterator `end`.");const auto& loop_info =@@ -95,7 +108,4 @@ std::shared_ptr<snippets::lowered::pass::PassBase> SetLoopIncrementOne::merge(return !other || ov::is_type<SetLoopIncrementOne>(other) ? std::make_shared<SetLoopIncrementOne>() : nullptr;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/load_movebroadcast_to_broadcastload.cpp b/src/common/snippets/src/lowered/pass/load_movebroadcast_to_broadcastload.cppindex 87c3e27a6f4..fd833e313cd 100644--- a/src/common/snippets/src/lowered/pass/load_movebroadcast_to_broadcastload.cpp+++ b/src/common/snippets/src/lowered/pass/load_movebroadcast_to_broadcastload.cpp@@ -4,15 +4,19 @@#include "snippets/lowered/pass/load_movebroadcast_to_broadcastload.hpp"+#include <cstddef>+#include <memory>+#include <utility>++#include "openvino/core/type.hpp"#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"-#include "snippets/lowered/loop_manager.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/op/broadcastload.hpp"+#include "snippets/op/broadcastmove.hpp"+#include "snippets/op/load.hpp"+#include "snippets/op/loop.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {bool LoadMoveBroadcastToBroadcastLoad::run(LinearIR& linear_ir,lowered::LinearIR::constExprIt begin,@@ -30,8 +34,9 @@ bool LoadMoveBroadcastToBroadcastLoad::run(LinearIR& linear_ir,const auto load = ov::as_type_ptr<op::Load>(load_expr->get_node());if (!load || load->get_input_element_type(0) != load->get_output_element_type(0) ||load_expr->get_input_port_descriptor(0)->get_shape() !=- load_expr->get_output_port_descriptor(0)->get_shape())+ load_expr->get_output_port_descriptor(0)->get_shape()) {continue;+ }// Cannot rewrite Broadcast + Load if load has more than 1 user// or more than one input, or if Broadcast has several inputs@@ -39,12 +44,14 @@ bool LoadMoveBroadcastToBroadcastLoad::run(LinearIR& linear_ir,size_t count = 0;for (const auto& consumer_expr_input : load_consumers_inputs) {const auto consumer = consumer_expr_input.get_expr()->get_node();- if (!ov::is_type<op::LoopEnd>(consumer))+ if (!ov::is_type<op::LoopEnd>(consumer)) {count++;+ }}- if (count > 1)+ if (count > 1) {continue;+ }const auto& load_parent_node = load_expr->get_input_port_connector(0)->get_source().get_expr()->get_node();const auto& outshape = move_broadcast->get_output_partial_shape(0);@@ -64,7 +71,4 @@ bool LoadMoveBroadcastToBroadcastLoad::run(LinearIR& linear_ir,return modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/mark_invariant_shape_path.cpp b/src/common/snippets/src/lowered/pass/mark_invariant_shape_path.cppindex 2991b814a6f..5270e773db8 100644--- a/src/common/snippets/src/lowered/pass/mark_invariant_shape_path.cpp+++ b/src/common/snippets/src/lowered/pass/mark_invariant_shape_path.cpp@@ -4,28 +4,46 @@#include "snippets/lowered/pass/mark_invariant_shape_path.hpp"+#include <cassert>+#include <cstddef>+#include <cstdint>+#include <map>++#include "openvino/core/any.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/core/type.hpp"+#include "openvino/op/util/attr_types.hpp"#include "snippets/itt.hpp"-#include "snippets/lowered/expressions/buffer_expression.hpp"-#include "snippets/op/memory_access.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/expression_port.hpp"+#include "snippets/lowered/linear_ir.hpp"+#include "snippets/op/brgemm.hpp"+#include "snippets/op/broadcastmove.hpp"+#include "snippets/op/horizon_max.hpp"+#include "snippets/op/horizon_sum.hpp"+#include "snippets/op/load.hpp"+#include "snippets/op/loop.hpp"+#include "snippets/op/reduce.hpp"+#include "snippets/op/reshape.hpp"+#include "snippets/op/scalar.hpp"+#include "snippets/op/vector_buffer.hpp"+#include "snippets/shape_types.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {namespace {// Specific value to mark ports which doesn't affect output shape of broadcastable ops.// For example, ops with output scalar shape or Horizon ops.-static const size_t NOT_AFFECTING_PATH = SIZE_MAX;+const size_t NOT_AFFECTING_PATH = SIZE_MAX;-static bool is_shape_broadcastable_op(const ExpressionPtr& expr) {+bool is_shape_broadcastable_op(const ExpressionPtr& expr) {return expr->get_node()->get_autob() != ov::op::AutoBroadcastType::NONE;}-static bool is_not_affecting_op(const ExpressionPtr& expr) {+bool is_not_affecting_op(const ExpressionPtr& expr) {const auto& node = expr->get_node();return ov::is_type_any_of<ov::snippets::op::HorizonMax,ov::snippets::op::HorizonSum,@@ -36,7 +54,7 @@ static bool is_not_affecting_op(const ExpressionPtr& expr) {ov::snippets::op::Scalar>(node);}-static bool is_affecting_op(const ExpressionPtr& expr) {+bool is_affecting_op(const ExpressionPtr& expr) {const auto& node = expr->get_node();return ov::is_type_any_of<ov::snippets::op::Brgemm, ov::snippets::op::Reshape, ov::snippets::op::LoadReorder>(node);}@@ -65,7 +83,7 @@ ov::RTMap& MarkInvariantShapePath::get_rt_info(const ExpressionPort& port) {return node->output(port_idx).get_rt_info();}-bool MarkInvariantShapePath::run(lowered::LinearIR& linear_ir,+bool MarkInvariantShapePath::run(lowered::LinearIR& /*linear_ir*/,lowered::LinearIR::constExprIt begin,lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::MarkInvariantShapePath");@@ -78,21 +96,24 @@ bool MarkInvariantShapePath::run(lowered::LinearIR& linear_ir,size_t color_path = 0;auto merge_paths = [&color_path](size_t lhs, size_t rhs) {- if (lhs == rhs || rhs == NOT_AFFECTING_PATH)+ if (lhs == rhs || rhs == NOT_AFFECTING_PATH) {return lhs;- if (lhs == NOT_AFFECTING_PATH)+ }+ if (lhs == NOT_AFFECTING_PATH) {return rhs;+ }return ++color_path;};for (auto expr_it = begin; expr_it != end; ++expr_it) {const auto& expr = *expr_it;- if (ov::is_type<ov::snippets::op::LoopBase>(expr->get_node()))+ if (ov::is_type<ov::snippets::op::LoopBase>(expr->get_node())) {continue;+ }for (size_t out_idx = 0; out_idx < expr->get_output_count(); ++out_idx) {const auto& out_shape = expr->get_output_port_descriptor(out_idx)->get_shape();- size_t current_color_path;+ size_t current_color_path = 0;if (colored_shapes.count(out_shape)) {current_color_path = colored_shapes.at(out_shape);} else if (!utils::is_dynamic_vdims(out_shape) && ov::shape_size(out_shape) == 1) {@@ -113,8 +134,9 @@ bool MarkInvariantShapePath::run(lowered::LinearIR& linear_ir,expr->get_input_count() > 0 ? getInvariantPortShapePath(expr->get_input_port(0)) : ++color_path;}- if (!utils::is_dynamic_vdims(out_shape))+ if (!utils::is_dynamic_vdims(out_shape)) {colored_shapes[out_shape] = current_color_path;+ }}SetInvariantPortShapePath(expr->get_output_port(out_idx), current_color_path);@@ -125,7 +147,4 @@ bool MarkInvariantShapePath::run(lowered::LinearIR& linear_ir,return modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/mark_loops.cpp b/src/common/snippets/src/lowered/pass/mark_loops.cppindex 43d5efb8ba5..73a728a5784 100644--- a/src/common/snippets/src/lowered/pass/mark_loops.cpp+++ b/src/common/snippets/src/lowered/pass/mark_loops.cpp@@ -4,15 +4,24 @@#include "snippets/lowered/pass/mark_loops.hpp"+#include <cstddef>+#include <iterator>+#include <memory>++#include "openvino/core/node.hpp"+#include "openvino/core/type.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/parameter.hpp"+#include "openvino/op/result.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression_port.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_manager.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/lowered/pass/pass.hpp"+#include "snippets/op/rank_normalization.hpp"+#include "snippets/op/reshape.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {MarkLoops::MarkLoops(size_t vector_size) : RangedPass(), m_vector_size(vector_size) {}@@ -41,8 +50,9 @@ bool MarkLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lfor (auto expr_it = begin; expr_it != end; expr_it++) {const auto expr = *expr_it;const auto& node = expr->get_node();- if (is_loop_outside_op(node))+ if (is_loop_outside_op(node)) {continue;+ }auto loop_begin_pos = expr_it;auto loop_end_pos = loop_begin_pos;@@ -52,13 +62,15 @@ bool MarkLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lconst auto& prev_expr = *loop_end_pos;loop_end_pos++;// If iterator is the last, we should finish Loop- if (loop_end_pos == end)+ if (loop_end_pos == end) {break;+ }// If iterator is the last, we should finish Loopconst auto& current_expr = *loop_end_pos;- if (is_loop_outside_op(current_expr->get_node()))+ if (is_loop_outside_op(current_expr->get_node())) {break;+ }// We finish Loop if// - the next expr isn't real consumer@@ -86,7 +98,4 @@ bool MarkLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lreturn true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/mha_parallel_wa_optimizer.cpp b/src/common/snippets/src/lowered/pass/mha_parallel_wa_optimizer.cppindex 2d38c590ff8..c0c25188f10 100644--- a/src/common/snippets/src/lowered/pass/mha_parallel_wa_optimizer.cpp+++ b/src/common/snippets/src/lowered/pass/mha_parallel_wa_optimizer.cpp@@ -4,17 +4,30 @@#include "snippets/lowered/pass/mha_parallel_wa_optimizer.hpp"+#include <algorithm>+#include <cstddef>+#include <iterator>+#include <set>+#include <unordered_set>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"+#include "openvino/op/parameter.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/loop_manager.hpp"+#include "snippets/lowered/loop_port.hpp"+#include "snippets/lowered/pass/runtime_optimizer.hpp"+#include "snippets/op/brgemm.hpp"#include "snippets/pass/split_dimension_m.hpp"+#include "snippets/runtime_configurator.hpp"#include "snippets/utils/loop_utils.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {using namespace ov::snippets::pass;const size_t MHAParallelWAOptimizer::m_dim_M_idx = 1;@@ -22,12 +35,14 @@ const size_t MHAParallelWAOptimizer::m_dim_M_idx = 1;MHAParallelWAOptimizer::MHAParallelWAOptimizer(const lowered::LinearIRCPtr& linear_ir,const RuntimeConfigurator* configurator): lowered::pass::RuntimeOptimizer(configurator) {- if (linear_ir->get_config().m_enable_domain_optimization || !linear_ir->is_dynamic())+ if (linear_ir->get_config().m_enable_domain_optimization || !linear_ir->is_dynamic()) {return;+ }const auto brgemms = find_applicable_brgemms(linear_ir);- if (brgemms.empty())+ if (brgemms.empty()) {return;+ }m_concurrency = linear_ir->get_config().m_min_parallel_work_amount;m_unsqueezed_params = find_unsqueezed_params(linear_ir, brgemms);@@ -46,12 +61,13 @@ MHAParallelWAOptimizer::MHAParallelWAOptimizer(const lowered::LinearIRCPtr& line}}-bool MHAParallelWAOptimizer::run(const lowered::LinearIR& linear_ir) {+bool MHAParallelWAOptimizer::run(const lowered::LinearIR& /*linear_ir*/) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::MHAParallelWAOptimizer")const auto& config = m_configurator->get_config();- size_t new_batch_dim, new_kernel_dim;- if (!SplitDimensionM::split(config->master_shape, m_concurrency, new_batch_dim, new_kernel_dim))+ size_t new_batch_dim = 0, new_kernel_dim = 0;+ if (!SplitDimensionM::split(config->master_shape, m_concurrency, new_batch_dim, new_kernel_dim)) {return false;+ }auto& master_shape = config->master_shape;*++master_shape.rbegin() = new_kernel_dim;master_shape.insert(master_shape.cbegin() + master_shape.size() - 2, new_batch_dim);@@ -61,13 +77,14 @@ bool MHAParallelWAOptimizer::run(const lowered::LinearIR& linear_ir) {auto updater = [&](const lowered::LoopInfoPtr& loop_info) {if (const auto unified_loop_info = ov::as_type_ptr<lowered::UnifiedLoopInfo>(loop_info)) {if (initialized_info.count(unified_loop_info) == 0) {- if (!ov::is_type<lowered::InnerSplittedUnifiedLoopInfo>(unified_loop_info))+ if (!ov::is_type<lowered::InnerSplittedUnifiedLoopInfo>(unified_loop_info)) {unified_loop_info->set_work_amount(new_kernel_dim);+ }snippets::utils::update_data_pointer_shifts(unified_loop_info);initialized_info[unified_loop_info] = RuntimeConfigurator::get_loop_runtime_params(unified_loop_info);}} else if (const auto expanded_loop_info = ov::as_type_ptr<lowered::ExpandedLoopInfo>(loop_info)) {- m_configurator->update_expanded_loop_info(expanded_loop_info, initialized_info);+ ov::snippets::RuntimeConfigurator::update_expanded_loop_info(expanded_loop_info, initialized_info);} else {OPENVINO_THROW("Failed to update loop info: unknown type!");}@@ -102,15 +119,18 @@ std::unordered_set<lowered::ExpressionPtr> MHAParallelWAOptimizer::find_applicabconst auto& loop_manager = linear_ir->get_loop_manager();auto applicable_brgemm = [&loop_manager, check_dynamic_wa](const lowered::ExpressionPtr& expr) {const auto& loop_idces = expr->get_loop_ids();- if (loop_idces.empty())+ if (loop_idces.empty()) {return false;+ }const auto& outermost_loop = loop_manager->get_loop_info(loop_idces[0]);- if (check_dynamic_wa && !snippets::utils::is_dynamic_value(outermost_loop->get_work_amount()))+ if (check_dynamic_wa && !snippets::utils::is_dynamic_value(outermost_loop->get_work_amount())) {return false;+ }bool loop_by_m = true;outermost_loop->iterate_through_ports([&loop_by_m](const lowered::LoopPort& port) {- if (port.is_processed() && port.get_dim_idx() != m_dim_M_idx)+ if (port.is_processed() && port.get_dim_idx() != m_dim_M_idx) {loop_by_m = false;+ }});return loop_by_m;};@@ -163,19 +183,19 @@ std::vector<lowered::ExpandedLoopInfoPtr> MHAParallelWAOptimizer::find_loops_to_size_t i = 0;std::unordered_set<lowered::ExpressionPtr> visited;for (const auto& param : linear_ir->get_parameters()) {- if (unsqueezed_params.count(i++))+ if (unsqueezed_params.count(i++) != 0u) {continue;+ }utils::visit_path(param, visited, add_loop_idx_to_split, false);}const auto& loops_map = linear_ir->get_loop_manager()->get_map();std::vector<lowered::ExpandedLoopInfoPtr> loops_to_split;- for (const auto& id : loop_idces_to_split)+ loops_to_split.reserve(loop_idces_to_split.size());+ for (const auto& id : loop_idces_to_split) {loops_to_split.push_back(ov::as_type_ptr<lowered::ExpandedLoopInfo>(loops_map.at(id)));+ }return loops_to_split;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/move_result_out_of_loop.cpp b/src/common/snippets/src/lowered/pass/move_result_out_of_loop.cppindex 5c8872f0c54..9686300bf6c 100644--- a/src/common/snippets/src/lowered/pass/move_result_out_of_loop.cpp+++ b/src/common/snippets/src/lowered/pass/move_result_out_of_loop.cpp@@ -4,20 +4,22 @@#include "snippets/lowered/pass/move_result_out_of_loop.hpp"+#include <algorithm>+#include <iterator>++#include "openvino/core/type.hpp"+#include "openvino/op/result.hpp"#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_manager.hpp"-#include "snippets/snippets_isa.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {bool MoveResultOutOfLoop::run(LinearIR& linear_ir) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::MoveResultOutOfLoop")- if (linear_ir.empty())+ if (linear_ir.empty()) {return false;+ }bool modified = false;const auto loop_manager = linear_ir.get_loop_manager();@@ -66,7 +68,4 @@ bool MoveResultOutOfLoop::run(LinearIR& linear_ir) {return modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/move_scalar_to_consumer.cpp b/src/common/snippets/src/lowered/pass/move_scalar_to_consumer.cppindex 8a149be360c..1543f631303 100644--- a/src/common/snippets/src/lowered/pass/move_scalar_to_consumer.cpp+++ b/src/common/snippets/src/lowered/pass/move_scalar_to_consumer.cpp@@ -4,26 +4,27 @@#include "snippets/lowered/pass/move_scalar_to_consumer.hpp"+#include <iterator>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"-#include "snippets/lowered/loop_manager.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/op/scalar.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {bool MoveScalarToConsumer::run(LinearIR& linear_ir) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::MoveScalarToConsumer")- if (linear_ir.empty())+ if (linear_ir.empty()) {return false;+ }bool modified = false;// Visit expressions in reverse order, so we'll move Scalar to an already visited area.// This is needed to avoid extra hits, when we match to the same Scalar twicefor (auto expr_it = linear_ir.rbegin(); expr_it != linear_ir.rend(); expr_it++) {- const auto expr = expr_it->get();+ auto* const expr = expr_it->get();if (ov::is_type<op::Scalar>(expr->get_node())) {const auto consumers = expr->get_output_port_connector(0)->get_consumers();OPENVINO_ASSERT(!consumers.empty(), "Scalar expression should have at least one consumer");@@ -45,8 +46,9 @@ bool MoveScalarToConsumer::run(LinearIR& linear_ir) {if (consumer_expr != next_expr && !ov::is_type<op::Scalar>(next_expr->get_node())) {expr_it = std::prev(expr_it); // save iterator before movingauto consumer_it = forward_it;- while (*consumer_it != consumer_expr)+ while (*consumer_it != consumer_expr) {consumer_it++;+ }linear_ir.move(forward_it, consumer_it);modified = true;}@@ -56,7 +58,4 @@ bool MoveScalarToConsumer::run(LinearIR& linear_ir) {return modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/normalize_buffer_reg_groups.cpp b/src/common/snippets/src/lowered/pass/normalize_buffer_reg_groups.cppindex 7e9eb7c171a..654d2012a53 100644--- a/src/common/snippets/src/lowered/pass/normalize_buffer_reg_groups.cpp+++ b/src/common/snippets/src/lowered/pass/normalize_buffer_reg_groups.cpp@@ -4,17 +4,17 @@#include "snippets/lowered/pass/normalize_buffer_reg_groups.hpp"+#include <cstddef>+#include <map>+#include "snippets/itt.hpp"-#include "snippets/op/buffer.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {bool NormalizeBufferRegisterGroups::run(lowered::LinearIR& linear_ir,- lowered::LinearIR::constExprIt begin,- lowered::LinearIR::constExprIt end) {+ [[maybe_unused]] lowered::LinearIR::constExprIt begin,+ [[maybe_unused]] lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::NormalizeBufferRegisterGroups");// [ original Buffer reg group -> normalized ]@@ -27,10 +27,7 @@ bool NormalizeBufferRegisterGroups::run(lowered::LinearIR& linear_ir,}buffer_expr->set_reg_group(buffer_reg_groups[group]);}- return buffer_reg_groups.size();+ return !buffer_reg_groups.empty();}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/normalize_loop_ids.cpp b/src/common/snippets/src/lowered/pass/normalize_loop_ids.cppindex 249c83aaa77..259c08244ef 100644--- a/src/common/snippets/src/lowered/pass/normalize_loop_ids.cpp+++ b/src/common/snippets/src/lowered/pass/normalize_loop_ids.cpp@@ -4,14 +4,19 @@#include "snippets/lowered/pass/normalize_loop_ids.hpp"+#include <algorithm>+#include <cstddef>+#include <utility>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_manager.hpp"#include "snippets/op/loop.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {void NormalizeLoopIDs::update_linear_ir(lowered::LinearIR& linear_ir, const IDMapper& loop_id_map) {std::pair<std::vector<size_t>, std::vector<size_t>> previous_loop_ids;@@ -23,8 +28,9 @@ void NormalizeLoopIDs::update_linear_ir(lowered::LinearIR& linear_ir, const IDMa}auto expr_loop_ids = expr->get_loop_ids();- if (expr_loop_ids.empty())+ if (expr_loop_ids.empty()) {continue;+ }if (expr_loop_ids == previous_loop_ids.first) {expr->set_loop_ids(previous_loop_ids.second);continue;@@ -62,8 +68,9 @@ bool NormalizeLoopIDs::run(lowered::LinearIR& linear_ir) {// Secondly, we blend `LoopInfo` in the LoopManager::m_map by new Loop IDsconst auto updated = linear_ir.get_loop_manager()->reorder_identifiers(loop_id_map);- if (!updated)+ if (!updated) {return false;+ }// Thirdly, we should update expressions in LinearIRupdate_linear_ir(linear_ir, loop_id_map);@@ -71,7 +78,4 @@ bool NormalizeLoopIDs::run(lowered::LinearIR& linear_ir) {return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/optimize_domain.cpp b/src/common/snippets/src/lowered/pass/optimize_domain.cppindex 39064249573..e6c6827c614 100644--- a/src/common/snippets/src/lowered/pass/optimize_domain.cpp+++ b/src/common/snippets/src/lowered/pass/optimize_domain.cpp@@ -4,16 +4,23 @@#include "snippets/lowered/pass/optimize_domain.hpp"+#include <algorithm>+#include <cstddef>+#include <functional>+#include <numeric>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression.hpp"#include "snippets/lowered/linear_ir.hpp"-#include "snippets/shape_inference/shape_inference.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/lowered/pass/pass.hpp"+#include "snippets/op/rank_normalization.hpp"+#include "snippets/shape_types.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {OptimizeDomain::OptimizeDomain(size_t& tile_rank) : Pass(), m_tile_rank(tile_rank) {}size_t OptimizeDomain::optimize(std::vector<VectorDims>& input_shapes,@@ -21,14 +28,16 @@ size_t OptimizeDomain::optimize(std::vector<VectorDims>& input_shapes,const size_t total_work_amount,const size_t min_parallel_work_amount,const size_t min_jit_work_amount) {- if (master_shape.size() <= 2)- return false;+ if (master_shape.size() <= 2) {+ return 0u;+ }auto CollapseLastDim = [](VectorDims& dims) {OPENVINO_ASSERT(dims.size() >= 2, "CollapseLastDim can't process shape with less than two dims");dims[dims.size() - 1] *= dims[dims.size() - 2];- for (auto i = dims.size() - 2; i > 0; i--)+ for (auto i = dims.size() - 2; i > 0; i--) {dims[i] = dims[i - 1];+ }dims[0] = 1;};// Check that neither of the two last dims is broadcasted, so they can be collapsed@@ -37,15 +46,19 @@ size_t OptimizeDomain::optimize(std::vector<VectorDims>& input_shapes,const auto master_prelast = *++master_shape.rbegin();return std::all_of(input_shapes.begin(), input_shapes.end(), [=](const VectorDims& s) {OPENVINO_ASSERT(s.size() >= 2, "LastDimsNotBroadcasted can't process shape with less than two dims");- return *s.rbegin() == master_last && *++s.rbegin() == master_prelast;+ auto it = s.rbegin();+ auto last_val = *it;+ ++it;+ return (last_val == master_last) && (*it == master_prelast);});};// Index of InputShape with the minimal ranksize_t min_rank_idx = 0;for (size_t i = 1; i < input_shapes.size(); ++i) {- if (input_shapes[i].size() < input_shapes[min_rank_idx].size())+ if (input_shapes[i].size() < input_shapes[min_rank_idx].size()) {min_rank_idx = i;+ }}size_t jit_work_amount = master_shape.back();@@ -53,8 +66,9 @@ size_t OptimizeDomain::optimize(std::vector<VectorDims>& input_shapes,while (jit_work_amount < min_jit_work_amount && (num_dims_collapsed + 1) < input_shapes[min_rank_idx].size() &&can_increase_jit_work_amount(master_shape, min_parallel_work_amount, total_work_amount) &&LastDimsNotBroadcasted(input_shapes, master_shape)) {- for (auto& s : input_shapes)+ for (auto& s : input_shapes) {CollapseLastDim(s);+ }CollapseLastDim(master_shape);num_dims_collapsed++;@@ -74,8 +88,9 @@ inline bool OptimizeDomain::can_increase_jit_work_amount(const VectorDims& mastebool OptimizeDomain::run(snippets::lowered::LinearIR& linear_ir) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::OptimizeDomain")const auto& config = linear_ir.get_config();- if (linear_ir.empty())+ if (linear_ir.empty()) {return false;+ }m_tile_rank = 1;@@ -103,8 +118,9 @@ bool OptimizeDomain::run(snippets::lowered::LinearIR& linear_ir) {if (auto rank_norm = as_type_ptr<op::RankNormalization>(first_consumer->get_node())) {// If RankNormalization appends dims, then the appended dims will be broadcasted// so collapsing is not allowed. We may increment tile rank though.- if (rank_norm->get_num_append() != 0)+ if (rank_norm->get_num_append() != 0) {blocked_input_shapes = true;+ }// If RankNormalization prepends dims, then the dims should be ignored during domain optimization// to avoid passing already incremented shapes to linear_ir.shape_infer()}@@ -119,7 +135,7 @@ bool OptimizeDomain::run(snippets::lowered::LinearIR& linear_ir) {input_shapes.emplace_back(shape);}const auto total_work_amount =- std::accumulate(master_shape.begin(), master_shape.end(), (size_t)1, std::multiplies<size_t>());+ std::accumulate(master_shape.begin(), master_shape.end(), (size_t)1, std::multiplies<>());const auto num_dims_collapsed = blocked_input_shapes ? 0: optimize(input_shapes,master_shape,@@ -129,19 +145,18 @@ bool OptimizeDomain::run(snippets::lowered::LinearIR& linear_ir) {if (num_dims_collapsed > 0) {std::vector<VectorDimsRef> infer_shapes;infer_shapes.reserve(input_shapes.size());- for (const auto& is : input_shapes)+ for (const auto& is : input_shapes) {infer_shapes.emplace_back(is);+ }// Need to propagate updated shapes through LIRlinear_ir.shape_infer(infer_shapes);}// We can still try to increment tile rank after dimension collapsingif (can_increase_jit_work_amount(master_shape, config.m_min_parallel_work_amount, total_work_amount) &&- num_dims_collapsed != master_shape.size() - 1)+ num_dims_collapsed != master_shape.size() - 1) {m_tile_rank++;+ }return num_dims_collapsed > 0;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/optimize_loop_single_evaluation.cpp b/src/common/snippets/src/lowered/pass/optimize_loop_single_evaluation.cppindex 05cdb9f48db..75e62b0336a 100644--- a/src/common/snippets/src/lowered/pass/optimize_loop_single_evaluation.cpp+++ b/src/common/snippets/src/lowered/pass/optimize_loop_single_evaluation.cpp@@ -4,16 +4,19 @@#include "snippets/lowered/pass/optimize_loop_single_evaluation.hpp"+#include <cstddef>+#include <cstdint>+#include <vector>++#include "openvino/core/type.hpp"#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/loop_manager.hpp"#include "snippets/op/loop.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {bool OptimizeLoopSingleEvaluation::run(lowered::LinearIR& linear_ir,lowered::LinearIR::constExprIt begin,@@ -50,7 +53,4 @@ bool OptimizeLoopSingleEvaluation::run(lowered::LinearIR& linear_ir,return is_modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/pass.cpp b/src/common/snippets/src/lowered/pass/pass.cppindex a181e2eaa12..12af73a7a03 100644--- a/src/common/snippets/src/lowered/pass/pass.cpp+++ b/src/common/snippets/src/lowered/pass/pass.cpp@@ -4,13 +4,18 @@#include "snippets/lowered/pass/pass.hpp"+#include <memory>+#include <unordered_map>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"+#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/pass/pass_config.hpp"+#include "snippets/pass/positioned_pass.hpp"#include "snippets/utils/linear_ir_pass_dumper.hpp"-#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {PassPipeline::PassPipeline() : m_pass_config(std::make_shared<PassConfig>()) {}PassPipeline::PassPipeline(const std::shared_ptr<PassConfig>& pass_config) : m_pass_config(pass_config) {@@ -69,8 +74,9 @@ void PassPipeline::run(LinearIR& linear_ir, LinearIR::constExprIt begin, LinearI}void PassPipeline::register_positioned_passes(const std::vector<PositionedPassLowered>& pos_passes) {- for (const auto& pp : pos_passes)+ for (const auto& pp : pos_passes) {register_pass(pp.position, pp.pass);+ }}PassPipeline PassPipeline::merge_pipelines(const PassPipeline& lhs, const PassPipeline& rhs) {@@ -98,7 +104,4 @@ PassPipeline PassPipeline::merge_pipelines(const PassPipeline& lhs, const PassPireturn merged_pipeline;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/pass_config.cpp b/src/common/snippets/src/lowered/pass/pass_config.cppindex cb0528f34b0..529aeaa4d47 100644--- a/src/common/snippets/src/lowered/pass/pass_config.cpp+++ b/src/common/snippets/src/lowered/pass/pass_config.cpp@@ -4,10 +4,9 @@#include "snippets/lowered/pass/pass_config.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+#include "openvino/core/type.hpp"++namespace ov::snippets::lowered::pass {void PassConfig::disable(const DiscreteTypeInfo& type_info) {m_enabled.erase(type_info);@@ -20,11 +19,11 @@ void PassConfig::enable(const DiscreteTypeInfo& type_info) {}bool PassConfig::is_disabled(const DiscreteTypeInfo& type_info) const {- return m_disabled.count(type_info);+ return m_disabled.count(type_info) != 0u;}bool PassConfig::is_enabled(const DiscreteTypeInfo& type_info) const {- return m_enabled.count(type_info);+ return m_enabled.count(type_info) != 0u;}bool operator==(const PassConfig& lhs, const PassConfig& rhs) {@@ -35,7 +34,4 @@ bool operator!=(const PassConfig& lhs, const PassConfig& rhs) {return !(lhs == rhs);}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/propagate_buffer_offset.cpp b/src/common/snippets/src/lowered/pass/propagate_buffer_offset.cppindex 7c7f72140ab..fed0eb81318 100644--- a/src/common/snippets/src/lowered/pass/propagate_buffer_offset.cpp+++ b/src/common/snippets/src/lowered/pass/propagate_buffer_offset.cpp@@ -4,16 +4,18 @@#include "snippets/lowered/pass/propagate_buffer_offset.hpp"+#include <memory>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"#include "snippets/itt.hpp"-#include "snippets/op/buffer.hpp"+#include "snippets/lowered/expressions/buffer_expression.hpp"+#include "snippets/lowered/linear_ir.hpp"#include "snippets/op/loop.hpp"#include "snippets/op/memory_access.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {void PropagateBufferOffset::propagate(const BufferExpressionPtr& buffer_expr) {// If Buffer has offset We set this offset in the connected MemoryAccess ops@@ -59,13 +61,11 @@ void PropagateBufferOffset::propagate(const BufferExpressionPtr& buffer_expr) {bool PropagateBufferOffset::run(lowered::LinearIR& linear_ir) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::PropagateBufferOffset");- for (const auto& buffer_expr : linear_ir.get_buffers())+ for (const auto& buffer_expr : linear_ir.get_buffers()) {propagate(buffer_expr);+ }return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/propagate_subtensors.cpp b/src/common/snippets/src/lowered/pass/propagate_subtensors.cppindex 2f08f13f964..0824762c04a 100644--- a/src/common/snippets/src/lowered/pass/propagate_subtensors.cpp+++ b/src/common/snippets/src/lowered/pass/propagate_subtensors.cpp@@ -4,16 +4,29 @@#include "snippets/lowered/pass/propagate_subtensors.hpp"+#include <algorithm>+#include <cstddef>+#include <cstdint>+#include <iterator>+#include <map>+#include <memory>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/loop_manager.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/lowered/pass/pass.hpp"+#include "snippets/lowered/port_descriptor.hpp"+#include "snippets/op/broadcastload.hpp"+#include "snippets/op/broadcastmove.hpp"+#include "snippets/op/loop.hpp"+#include "snippets/shape_types.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {namespace {// The algorithm uses the following special values in subtensors/shapes:@@ -111,10 +124,15 @@ void propagate_updated_subtensor_through_loop(const LinearIR& linear_ir,for (size_t i = 0; i < new_subtensor.size(); ++i) {// If user forces dynamic value to set in subtensor, set real dynamic dimension using// `get_dynamic_value<size_t>()`- new_subtensor[i] = new_subtensor[i] == FORCED_DYNAMIC_VALUE ? utils::get_dynamic_value<size_t>()- : utils::is_full_dim_value(subtensor[i])- ? subtensor[i]- : std::min(new_subtensor[i], subtensor[i]);+ new_subtensor[i] = [&]() -> size_t {+ if (new_subtensor[i] == FORCED_DYNAMIC_VALUE) {+ return utils::get_dynamic_value<size_t>();+ }+ if (utils::is_full_dim_value(subtensor[i])) {+ return subtensor[i];+ }+ return std::min(new_subtensor[i], subtensor[i]);+ }();}desc->set_subtensor(new_subtensor);}@@ -127,8 +145,9 @@ void propagate_updated_subtensor_through_loop(const LinearIR& linear_ir,// For inner loops propagation function is called recursivelyfor (auto expr_it = begin; expr_it != end; expr_it++) {const auto expr = *expr_it;- if (ov::is_type<snippets::op::LoopEnd>(expr->get_node()))+ if (ov::is_type<snippets::op::LoopEnd>(expr->get_node())) {continue;+ }if (auto loop_begin = ov::as_type_ptr<snippets::op::LoopBegin>(expr->get_node())) {const auto loop_end = loop_begin->get_loop_end();const auto inner_loop_info = linear_ir.get_loop_manager()->get_loop_info(loop_end->get_id());@@ -137,8 +156,9 @@ void propagate_updated_subtensor_through_loop(const LinearIR& linear_ir,// The corresponding shapes of inner loops input ports must be updated using existing subtensor valuesif (!most_outer_loop) {- for (const auto& port : loop_info->get_input_ports())+ for (const auto& port : loop_info->get_input_ports()) {update_only_dim_idx_with_subtensor_value(port);+ }}propagate_updated_subtensor_through_loop(linear_ir, inner_loop_info, inner_begin, inner_end, false);expr_it = inner_end;@@ -159,12 +179,14 @@ void propagate_updated_subtensor_through_loop(const LinearIR& linear_ir,}// After subtensor propagation, the original shapes must be restored- for (const auto& elem : original_shapes)+ for (const auto& elem : original_shapes) {elem.first->set_shape(elem.second);+ }for (auto expr_it = begin; expr_it != shape_inference_end_it; expr_it++) {- const auto expr = *expr_it;- if (ov::is_type<snippets::op::LoopBase>(expr->get_node()))+ const auto& expr = *expr_it;+ if (ov::is_type<snippets::op::LoopBase>(expr->get_node())) {continue;+ }expr->updateShapes();}}@@ -185,16 +207,15 @@ bool UpdateSubtensors::run(LinearIR& linear_ir, LinearIR::constExprIt begin, Lin}std::shared_ptr<pass::PassBase> UpdateSubtensors::merge(const std::shared_ptr<pass::PassBase>& other) {- if (!other)+ if (!other) {return shared_from_this();+ }const auto casted_pass = ov::as_type_ptr<UpdateSubtensors>(other);- size_t merged_size;- if (!casted_pass || !ov::snippets::utils::merge_dynamic_dim(merged_size, m_tail_size, casted_pass->m_tail_size))+ size_t merged_size = 0;+ if (!casted_pass || !ov::snippets::utils::merge_dynamic_dim(merged_size, m_tail_size, casted_pass->m_tail_size)) {return nullptr;+ }return std::make_shared<UpdateSubtensors>(merged_size);}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/reduce_decomposition.cpp b/src/common/snippets/src/lowered/pass/reduce_decomposition.cppindex 01a0edf3b93..2f037084019 100644--- a/src/common/snippets/src/lowered/pass/reduce_decomposition.cpp+++ b/src/common/snippets/src/lowered/pass/reduce_decomposition.cpp@@ -4,17 +4,36 @@#include "snippets/lowered/pass/reduce_decomposition.hpp"+#include <cstddef>+#include <cstdint>+#include <map>+#include <memory>+#include <utility>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/type.hpp"+#include "openvino/op/add.hpp"+#include "openvino/op/maximum.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression_port.hpp"#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/loop_manager.hpp"#include "snippets/lowered/pass/iter_handler.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/lowered/pass/pass.hpp"+#include "snippets/lowered/specific_loop_iter_types.hpp"+#include "snippets/op/fill.hpp"+#include "snippets/op/horizon_max.hpp"+#include "snippets/op/horizon_sum.hpp"+#include "snippets/op/memory_access.hpp"+#include "snippets/op/reduce.hpp"+#include "snippets/op/vector_buffer.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {ReduceDecomposition::ReduceDecomposition(size_t vector_size) : RangedPass(), m_vector_size{vector_size} {}@@ -38,11 +57,11 @@ bool ReduceDecomposition::run(LinearIR& linear_ir, LinearIR::constExprIt begin,const ov::DiscreteTypeInfo& type_info) -> std::pair<LinearIR::constExprIt, std::shared_ptr<ov::Node>> {if (type_info == op::ReduceMax::get_type_info_static()) {return linear_ir.insert_node<ov::op::v1::Maximum>(expr_it, input0, input1);- } else if (type_info == op::ReduceSum::get_type_info_static()) {+ }+ if (type_info == op::ReduceSum::get_type_info_static()) {return linear_ir.insert_node<ov::op::v1::Add>(expr_it, input0, input1);- } else {- OPENVINO_THROW("Unsupported reduce type: ", type_info);}+ OPENVINO_THROW("Unsupported reduce type: ", type_info);};auto insert_horizon_node =@@ -52,11 +71,11 @@ bool ReduceDecomposition::run(LinearIR& linear_ir, LinearIR::constExprIt begin,const ov::DiscreteTypeInfo& type_info) -> std::pair<LinearIR::constExprIt, std::shared_ptr<ov::Node>> {if (type_info == op::ReduceMax::get_type_info_static()) {return linear_ir.insert_node<op::HorizonMax>(expr_it, input);- } else if (type_info == op::ReduceSum::get_type_info_static()) {+ }+ if (type_info == op::ReduceSum::get_type_info_static()) {return linear_ir.insert_node<op::HorizonSum>(expr_it, input);- } else {- OPENVINO_THROW("Unsupported reduce type: ", type_info);}+ OPENVINO_THROW("Unsupported reduce type: ", type_info);};bool modified = false;@@ -64,8 +83,9 @@ bool ReduceDecomposition::run(LinearIR& linear_ir, LinearIR::constExprIt begin,for (auto expr_it = begin; expr_it != end; expr_it++) {const auto& reduce_expr = *expr_it;const auto& reduce = ov::as_type_ptr<ov::snippets::op::ReduceBase>(reduce_expr->get_node());- if (!reduce || std::dynamic_pointer_cast<modifier::MemoryAccess>(reduce_expr->get_node()))+ if (!reduce || std::dynamic_pointer_cast<modifier::MemoryAccess>(reduce_expr->get_node())) {continue;+ }const auto& reduce_type_info = reduce->get_type_info();const auto& input_shape = reduce_expr->get_input_port_descriptor(0)->get_shape();@@ -127,7 +147,4 @@ bool ReduceDecomposition::run(LinearIR& linear_ir, LinearIR::constExprIt begin,return modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/serialize_base.cpp b/src/common/snippets/src/lowered/pass/serialize_base.cppindex 9c69ee655bd..42dc5e943b8 100644--- a/src/common/snippets/src/lowered/pass/serialize_base.cpp+++ b/src/common/snippets/src/lowered/pass/serialize_base.cpp@@ -4,18 +4,16 @@#include "snippets/lowered/pass/serialize_base.hpp"+#include <string>+#include <utility>+#include "snippets/itt.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {-SerializeBase::SerializeBase(const std::string& xml_path)- : m_xml_path(xml_path),- m_bin_path(get_bin_path_from_xml(xml_path)) {}+SerializeBase::SerializeBase(std::string xml_path) : m_xml_path(std::move(xml_path)), m_bin_path(get_bin_path()) {}-std::string SerializeBase::get_bin_path_from_xml(const std::string& xml_path) {+std::string SerializeBase::get_bin_path() {#if defined(__linux__)return "/dev/null";#else@@ -23,7 +21,4 @@ std::string SerializeBase::get_bin_path_from_xml(const std::string& xml_path) {#endif}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/serialize_control_flow.cpp b/src/common/snippets/src/lowered/pass/serialize_control_flow.cppindex ccc9835c06f..8caeede9ce7 100644--- a/src/common/snippets/src/lowered/pass/serialize_control_flow.cpp+++ b/src/common/snippets/src/lowered/pass/serialize_control_flow.cpp@@ -4,23 +4,33 @@#include "snippets/lowered/pass/serialize_control_flow.hpp"+#include <cstddef>+#include <map>+#include <memory>++#include "openvino/core/except.hpp"+#include "openvino/core/model.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"+#include "openvino/op/parameter.hpp"+#include "openvino/op/result.hpp"#include "openvino/pass/serialize.hpp"#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/linear_ir_builder.hpp"+#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/loop_manager.hpp"+#include "snippets/op/loop.hpp"#include "snippets/op/serialization_node.hpp"-#include "snippets/snippets_isa.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {bool SerializeControlFlow::run(const LinearIR& original_linear_ir) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::SerializeControlFlow")- if (original_linear_ir.empty())+ if (original_linear_ir.empty()) {return false;+ }const auto& linear_ir = m_update_dynamic_ops ? LinearIRBuilder().clone(original_linear_ir) : original_linear_ir;const auto& loop_manager = linear_ir.get_loop_manager();@@ -47,12 +57,15 @@ bool SerializeControlFlow::run(const LinearIR& original_linear_ir) {loop_end->set_work_amount(loop_info->get_work_amount());loop_end->set_increment(loop_info->get_increment());loop_end->set_is_incremented(loop_info->get_is_incremented());+ auto set_loop_end_data = [&loop_end](const auto& info) {+ loop_end->set_ptr_increments(info->get_ptr_increments());+ loop_end->set_finalization_offsets(info->get_finalization_offsets());+ };+if (auto unified = ov::as_type_ptr<UnifiedLoopInfo>(loop_info)) {- loop_end->set_ptr_increments(unified->get_ptr_increments());- loop_end->set_finalization_offsets(unified->get_finalization_offsets());+ set_loop_end_data(unified);} else if (auto expanded = ov::as_type_ptr<ExpandedLoopInfo>(loop_info)) {- loop_end->set_ptr_increments(expanded->get_ptr_increments());- loop_end->set_finalization_offsets(expanded->get_finalization_offsets());+ set_loop_end_data(expanded);} else {OPENVINO_THROW("Unknown LoopInfo type");}@@ -74,7 +87,4 @@ bool SerializeControlFlow::run(const LinearIR& original_linear_ir) {return ov::pass::Serialize(m_xml_path, m_bin_path).run_on_model(model);}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/serialize_data_flow.cpp b/src/common/snippets/src/lowered/pass/serialize_data_flow.cppindex 5ba2ebb9b86..3d09696d857 100644--- a/src/common/snippets/src/lowered/pass/serialize_data_flow.cpp+++ b/src/common/snippets/src/lowered/pass/serialize_data_flow.cpp@@ -4,21 +4,31 @@#include "snippets/lowered/pass/serialize_data_flow.hpp"+#include <cstddef>+#include <map>+#include <memory>++#include "openvino/core/except.hpp"+#include "openvino/core/model.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"+#include "openvino/op/parameter.hpp"+#include "openvino/op/result.hpp"#include "openvino/pass/serialize.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/op/serialization_node.hpp"-#include "snippets/snippets_isa.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {bool SerializeDataFlow::run(const LinearIR& linear_ir) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::SerializeDataFlow")- if (linear_ir.empty())+ if (linear_ir.empty()) {return false;+ }ov::ResultVector results;ov::ParameterVector parameters;@@ -50,7 +60,4 @@ bool SerializeDataFlow::run(const LinearIR& linear_ir) {return ov::pass::Serialize(m_xml_path, m_bin_path).run_on_model(model);}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/set_buffer_reg_group.cpp b/src/common/snippets/src/lowered/pass/set_buffer_reg_group.cppindex adb0875e292..3a24d0f1986 100644--- a/src/common/snippets/src/lowered/pass/set_buffer_reg_group.cpp+++ b/src/common/snippets/src/lowered/pass/set_buffer_reg_group.cpp@@ -4,16 +4,26 @@#include "snippets/lowered/pass/set_buffer_reg_group.hpp"+#include <algorithm>+#include <cassert>+#include <cstddef>+#include <functional>+#include <iterator>+#include <map>+#include <numeric>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"#include "snippets/itt.hpp"#include "snippets/lowered/expressions/buffer_expression.hpp"#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/loop_manager.hpp"#include "snippets/lowered/pass/mark_invariant_shape_path.hpp"+#include "snippets/op/loop.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {namespace {inline size_t index(size_t col_num, size_t row, size_t col) {@@ -48,20 +58,20 @@ bool SetBufferRegGroup::are_adjacent(const BufferMap::value_type& lhs, const Bufconst auto equal_loop_ids = lhs_ids == rhs_ids;if (equal_loop_ids) { // Buffers are connected to the same Loop and have the same outer Loopsreturn !can_be_in_one_reg_group(lhs.second, rhs.second);- } else { // Buffers are connected to the same Loop, but one of Buffers - inside this Loop, another - outside- // Buffers are adjacent if outer Buffer has non-zero data shift params- // If the count of outer Loops are equal, it means that outer loops are already different- if (lhs_ids.size() == rhs_ids.size())- return true;- const auto& outer_buffer = lhs_ids.size() < rhs_ids.size() ? lhs : rhs;- const auto count_outer_loops = std::min(lhs_ids.size(), rhs_ids.size());- const auto are_outer_loops_the_same =- lhs_ids.size() != rhs_ids.size() &&- std::equal(rhs_ids.cbegin(), rhs_ids.cbegin() + count_outer_loops, lhs_ids.cbegin());- const auto outer_buffer_has_zero_shifts =- outer_buffer.second.desc.ptr_increment == 0 && outer_buffer.second.desc.finalization_offset == 0;- return !(are_outer_loops_the_same && outer_buffer_has_zero_shifts);+ } // Buffers are connected to the same Loop, but one of Buffers - inside this Loop, another - outside+ // Buffers are adjacent if outer Buffer has non-zero data shift params+ // If the count of outer Loops are equal, it means that outer loops are already different+ if (lhs_ids.size() == rhs_ids.size()) {+ return true;}+ const auto& outer_buffer = lhs_ids.size() < rhs_ids.size() ? lhs : rhs;+ const auto count_outer_loops = std::min(lhs_ids.size(), rhs_ids.size());+ const auto are_outer_loops_the_same =+ lhs_ids.size() != rhs_ids.size() &&+ std::equal(rhs_ids.cbegin(), rhs_ids.cbegin() + count_outer_loops, lhs_ids.cbegin());+ const auto outer_buffer_has_zero_shifts =+ outer_buffer.second.desc.ptr_increment == 0 && outer_buffer.second.desc.finalization_offset == 0;+ return !(are_outer_loops_the_same && outer_buffer_has_zero_shifts);}void SetBufferRegGroup::update_adj_matrix(const BufferMap::value_type& lhs,@@ -72,8 +82,9 @@ void SetBufferRegGroup::update_adj_matrix(const BufferMap::value_type& lhs,const auto lhs_idx = get_buffer_idx(lhs.first, buffers);const auto rhs_idx = get_buffer_idx(rhs.first, buffers);// Already adjacent - skip- if (adj[index(size, rhs_idx, lhs_idx)])+ if (adj[index(size, rhs_idx, lhs_idx)]) {return;+ }if (are_adjacent(lhs, rhs)) {adj[index(size, rhs_idx, lhs_idx)] = adj[index(size, lhs_idx, rhs_idx)] = true;@@ -89,14 +100,16 @@ std::vector<bool> SetBufferRegGroup::create_adjacency_matrix(const LoopManagerPt// they are called as adjacentconst auto size = pool.size();std::vector<bool> adj(size * size, false);- for (size_t i = 0; i < size; ++i)+ for (size_t i = 0; i < size; ++i) {adj[index(size, i, i)] = true;+ }for (auto expr_it = begin; expr_it != end; expr_it++) {const auto& expr = *expr_it;const auto& loop_end = ov::as_type_ptr<op::LoopEnd>(expr->get_node());- if (!loop_end)+ if (!loop_end) {continue;+ }const auto& loop_info = loop_manager->get_loop_info<UnifiedLoopInfo>(loop_end->get_id());const auto buffer_loop_neighbours = get_buffer_loop_neighbours(loop_info);@@ -113,8 +126,8 @@ std::vector<bool> SetBufferRegGroup::create_adjacency_matrix(const LoopManagerPt// Loop - must be adjacent: after each the Loop iteration GPR will be shifted using ptr increment of Buffer// outside. But if inner Buffers have the same GPR - it means that these Buffers will work with shifted// memory.- for (auto inner_it = buffers_loop_inside.cbegin(); inner_it != buffers_loop_inside.cend(); ++inner_it) {- update_adj_matrix(*buffer_it, *inner_it, pool, adj);+ for (const auto& inner_it : buffers_loop_inside) {+ update_adj_matrix(*buffer_it, inner_it, pool, adj);}}}@@ -145,8 +158,9 @@ SetBufferRegGroup::BufferMap SetBufferRegGroup::get_buffer_loop_neighbours(constconst auto& consumer_inputs = port_info.port.get_expr_port()->get_port_connector_ptr()->get_consumers();for (const auto& consumer_input : consumer_inputs) {const auto& child_expr = consumer_input.get_expr();- if (const auto buffer_expr = ov::as_type_ptr<BufferExpression>(child_expr))+ if (const auto buffer_expr = ov::as_type_ptr<BufferExpression>(child_expr)) {buffer_neighbours[buffer_expr] = port_info;+ }}}@@ -161,8 +175,9 @@ SetBufferRegGroup::BufferMap SetBufferRegGroup::get_buffer_loop_inside(const Linconst auto& inner_expr = *it;if (const auto buffer_expr = ov::as_type_ptr<BufferExpression>(inner_expr)) {// Set default value (zeroes) since it's not used for adjacency definition in case with Buffers in Loop- if (inner_buffers.count(buffer_expr) == 0)+ if (inner_buffers.count(buffer_expr) == 0) {inner_buffers[buffer_expr] = UnifiedLoopInfo::LoopPortInfo();+ }}}return inner_buffers;@@ -174,8 +189,9 @@ auto SetBufferRegGroup::coloring(BufferPool& buffers, std::vector<bool>& adj) ->const auto size = buffers.size();for (size_t i = 0; i < size; ++i) {// The Buffer is already colored (visited) - skip- if (!buffers[i])+ if (!buffers[i]) {continue;+ }const auto& buffer = buffers[i];color_groups[color].push_back(buffer); // Add to Color Group@@ -183,18 +199,20 @@ auto SetBufferRegGroup::coloring(BufferPool& buffers, std::vector<bool>& adj) ->// While Buffer `i` has non-coloured non-neighbours (while row `i` contains 0)while ((i + 1 < size) &&- !std::accumulate(adj.begin() + i * size, adj.begin() + (i + 1) * size, true, std::logical_and<bool>())) {+ !std::accumulate(adj.begin() + i * size, adj.begin() + (i + 1) * size, true, std::logical_and<>())) {size_t j = i + 1;// Find first non-adjacent and non-visited (non-colored) Buffer to color him to the same colorfor (; j < size; ++j) {- if (!adj[index(size, i, j)] && buffers[j])+ if (!adj[index(size, i, j)] && buffers[j]) {break;+ }}// If we don't have the corresponding non-adjacent and non-colored Buffers,// we should make break - all potential Buffers for the current color are already colored- if (j == size)+ if (j == size) {break;+ }const auto& neighbour_buffer = buffers[j];color_groups[color].push_back(neighbour_buffer); // Add to Color Group@@ -208,7 +226,7 @@ auto SetBufferRegGroup::coloring(BufferPool& buffers, std::vector<bool>& adj) ->adj.begin() + (i + 1) * size,adj.begin() + j * size,adj.begin() + i * size,- std::logical_or<bool>());+ std::logical_or<>());}color++;@@ -240,14 +258,12 @@ bool SetBufferRegGroup::run(LinearIR& linear_ir,for (const auto& pair : color_groups) {const auto color = pair.first;const auto& united_buffers = pair.second;- for (const auto& buffer_expr : united_buffers)+ for (const auto& buffer_expr : united_buffers) {buffer_expr->set_reg_group(color);+ }}return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/set_dynamic_wa_to_outermost_loop.cpp b/src/common/snippets/src/lowered/pass/set_dynamic_wa_to_outermost_loop.cppindex 8f653de5b8e..c4f554ac9fe 100644--- a/src/common/snippets/src/lowered/pass/set_dynamic_wa_to_outermost_loop.cpp+++ b/src/common/snippets/src/lowered/pass/set_dynamic_wa_to_outermost_loop.cpp@@ -4,27 +4,34 @@#include "snippets/lowered/pass/set_dynamic_wa_to_outermost_loop.hpp"+#include <cstddef>+#include <limits>+#include <memory>+#include <unordered_set>++#include "openvino/core/except.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression.hpp"#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/loop_manager.hpp"#include "snippets/lowered/pass/mha_parallel_wa_optimizer.hpp"-#include "snippets/op/brgemm.hpp"#include "snippets/utils/loop_utils.hpp"+#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {bool SetDynamicWAToOuterMostLoop::run(LinearIR& linear_ir) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::SetDynamicWAToOuterMostLoop")- if (linear_ir.empty() || !linear_ir.is_dynamic() || linear_ir.get_config().m_enable_domain_optimization)+ if (linear_ir.empty() || !linear_ir.is_dynamic() || linear_ir.get_config().m_enable_domain_optimization) {return false;+ }const auto linear_ir_ptr = std::make_shared<const LinearIR>(linear_ir);const auto brgemms = MHAParallelWAOptimizer::find_applicable_brgemms(linear_ir_ptr, false);- if (brgemms.empty())+ if (brgemms.empty()) {return false;+ }const auto unsqueezed_params = MHAParallelWAOptimizer::find_unsqueezed_params(linear_ir_ptr, brgemms);OPENVINO_ASSERT(!unsqueezed_params.empty(), "unsqueezed_params mustn't be empty after initialization");@@ -36,8 +43,9 @@ bool SetDynamicWAToOuterMostLoop::run(LinearIR& linear_ir) {auto add_affected_loop = [&](const lowered::ExpressionPtr& expr) {const auto& loop_idces = expr->get_loop_ids();- if (loop_idces.empty() || loop_idces.front() == prev_loop_id)+ if (loop_idces.empty() || loop_idces.front() == prev_loop_id) {return;+ }prev_loop_id = loop_idces.front();const auto loop_info = loop_manager->get_loop_info<lowered::UnifiedLoopInfo>(prev_loop_id);@@ -49,8 +57,9 @@ bool SetDynamicWAToOuterMostLoop::run(LinearIR& linear_ir) {size_t i = 0;std::unordered_set<lowered::ExpressionPtr> visited;for (const auto& param : linear_ir_ptr->get_parameters()) {- if (unsqueezed_params.count(i++))+ if (unsqueezed_params.count(i++) != 0u) {continue;+ }utils::visit_path(param, visited, add_affected_loop, false);}@@ -66,7 +75,4 @@ bool SetDynamicWAToOuterMostLoop::run(LinearIR& linear_ir) {return modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/set_load_store_scalar.cpp b/src/common/snippets/src/lowered/pass/set_load_store_scalar.cppindex ef46d6e052f..5bae4826b72 100644--- a/src/common/snippets/src/lowered/pass/set_load_store_scalar.cpp+++ b/src/common/snippets/src/lowered/pass/set_load_store_scalar.cpp@@ -4,19 +4,17 @@#include "snippets/lowered/pass/set_load_store_scalar.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"#include "snippets/itt.hpp"-#include "snippets/lowered/loop_manager.hpp"-#include "snippets/lowered/pass/insert_load_store.hpp"+#include "snippets/lowered/linear_ir.hpp"#include "snippets/op/load.hpp"#include "snippets/op/store.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {-bool SetLoadStoreScalar::run(LinearIR& linear_ir,+bool SetLoadStoreScalar::run([[maybe_unused]] LinearIR& linear_ir,lowered::LinearIR::constExprIt begin,lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::SetLoadStoreScalar")@@ -44,7 +42,4 @@ bool SetLoadStoreScalar::run(LinearIR& linear_ir,return modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/solve_buffer_memory.cpp b/src/common/snippets/src/lowered/pass/solve_buffer_memory.cppindex 68c91767186..14dd0a579ed 100644--- a/src/common/snippets/src/lowered/pass/solve_buffer_memory.cpp+++ b/src/common/snippets/src/lowered/pass/solve_buffer_memory.cpp@@ -4,16 +4,27 @@#include "snippets/lowered/pass/solve_buffer_memory.hpp"+#include <algorithm>+#include <cstddef>+#include <cstdint>+#include <limits>+#include <map>+#include <set>+#include <tuple>+#include <utility>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"+#include "openvino/runtime/memory_solver.hpp"#include "snippets/itt.hpp"-#include "snippets/lowered/pass/allocate_buffers.hpp"-#include "snippets/op/buffer.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/expressions/buffer_expression.hpp"+#include "snippets/lowered/linear_ir.hpp"#include "snippets/op/loop.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {namespace {std::map<double, int> create_execution_number_mapping(const LinearIR& linear_ir) {std::map<double, int> mapping;@@ -130,23 +141,26 @@ void SolveBufferMemory::solve_static_buffer_memory(const Buffers& static_buffer_}}-void SolveBufferMemory::set_dynamic_buffer_offset(const Buffers& dynamic_buffer_expressions) {- size_t offset = utils::get_dynamic_value<size_t>();+void SolveBufferMemory::set_dynamic_buffer_offset(const Buffers& dynamic_buffer_expressions) const {+ auto offset = utils::get_dynamic_value<size_t>();// If there are not allocated memory for static buffers in LinearIR and there is only one cluster of dynamic buffer// exprs, we can force offset = 0if (m_static_buffer_scratchpad_size == 0) {std::set<size_t> dynamic_clusters;- for (const auto& dynamic_buffer_expr : dynamic_buffer_expressions)+ for (const auto& dynamic_buffer_expr : dynamic_buffer_expressions) {dynamic_clusters.insert(dynamic_buffer_expr->get_cluster_id());+ }- if (dynamic_clusters.size() == 1)+ if (dynamic_clusters.size() == 1) {offset = 0;+ }}// Set offsets for Buffers- for (const auto& buffer_expr : dynamic_buffer_expressions)+ for (const auto& buffer_expr : dynamic_buffer_expressions) {buffer_expr->set_offset(offset);+ }}bool SolveBufferMemory::run(LinearIR& linear_ir) {@@ -157,16 +171,15 @@ bool SolveBufferMemory::run(LinearIR& linear_ir) {Buffers static_buffer_exprs, dynamic_buffer_exprs;std::tie(static_buffer_exprs, dynamic_buffer_exprs) = extract_static_and_dynamic_buffers(linear_ir.get_buffers());- if (!static_buffer_exprs.empty())+ if (!static_buffer_exprs.empty()) {solve_static_buffer_memory(static_buffer_exprs, linear_ir);+ }- if (!dynamic_buffer_exprs.empty())+ if (!dynamic_buffer_exprs.empty()) {set_dynamic_buffer_offset(dynamic_buffer_exprs);+ }return !static_buffer_exprs.empty() && !dynamic_buffer_exprs.empty();}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/split_loops.cpp b/src/common/snippets/src/lowered/pass/split_loops.cppindex 4b2170d249f..9a5d2e0c5c2 100644--- a/src/common/snippets/src/lowered/pass/split_loops.cpp+++ b/src/common/snippets/src/lowered/pass/split_loops.cpp@@ -4,19 +4,24 @@#include "snippets/lowered/pass/split_loops.hpp"+#include <cstddef>+#include <iterator>+#include <memory>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/loop_manager.hpp"+#include "snippets/lowered/loop_port.hpp"#include "snippets/lowered/pass/fuse_loops.hpp"-#include "snippets/lowered/pass/init_loops.hpp"-#include "snippets/lowered/pass/iter_handler.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/lowered/pass/pass.hpp"+#include "snippets/lowered/specific_loop_iter_types.hpp"+#include "snippets/op/loop.hpp"#include "snippets/utils/loop_utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {bool SplitLoops::can_be_split(const UnifiedLoopInfoPtr& loop_to_split, const UnifiedLoopInfoPtr& loop_to_fuse) {OPENVINO_ASSERT(loop_to_split != nullptr && loop_to_fuse != nullptr, "LoopInfo is nullptr!");@@ -37,8 +42,9 @@ bool SplitLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin,for (auto expr_it = begin; expr_it != end; ++expr_it) {const auto& expr = *expr_it;const auto& loop_ids = expr->get_loop_ids();- if (loop_ids.empty())+ if (loop_ids.empty()) {continue;+ }// Ticket: 113755// Note: we currently consider only the outermost loops for splitting@@ -50,8 +56,9 @@ bool SplitLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin,const auto& parent_port = input_port.get_expr_port()->get_port_connector_ptr()->get_source();const auto& parent_expr = parent_port.get_expr();const auto& parent_loop_ids = parent_expr->get_loop_ids();- if (parent_loop_ids.empty())+ if (parent_loop_ids.empty()) {continue;+ }const auto& parent_loop_id = parent_loop_ids.front();const auto parent_loop = loop_manager->get_loop_info<UnifiedLoopInfo>(parent_loop_id);@@ -59,10 +66,11 @@ bool SplitLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin,const bool split_parent = parent_loop->get_increment() < loop->get_increment();const auto upper_loop = std::make_shared<UnifiedLoopInfo>(*parent_loop);const auto lower_loop = std::make_shared<UnifiedLoopInfo>(*loop);- if (split_parent)+ if (split_parent) {upper_loop->set_increment(loop->get_increment());- else+ } else {lower_loop->set_increment(parent_loop->get_increment());+ }const auto& loop_to_split = split_parent ? parent_loop : loop;const auto& loop_to_fuse = !split_parent ? parent_loop : loop;@@ -77,8 +85,9 @@ bool SplitLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin,// Ticket: 113666// FuseLoops pass is explicitly run here in order to avoid unnecessary computations// in case if loops are not split but FuseLoops is registered in pass manager after SplitLoops- if (loop_was_split)+ if (loop_was_split) {FuseLoops().run(linear_ir, begin, end);+ }return loop_was_split;}@@ -171,16 +180,18 @@ bool SplitLoops::TransformInnerSplitLoop::run(LinearIR& linear_ir,for (auto it = begin; it != end; ++it) {const auto& expr = *it;const auto inner_loop_end = ov::as_type_ptr<op::LoopEnd>(expr->get_node());- if (!inner_loop_end)+ if (!inner_loop_end) {continue;+ }// There is already ExpandedLoopInfoconst auto& inner_expanded_loop_info = loop_manager->get_loop_info<ExpandedLoopInfo>(inner_loop_end->get_id());const auto inner_unified_loop_info =ov::as_type_ptr<InnerSplittedUnifiedLoopInfo>(inner_expanded_loop_info->get_unified_loop_info());if (!inner_unified_loop_info ||- inner_unified_loop_info->get_outer_splitted_loop_info() != outer_loop_info->get_unified_loop_info())+ inner_unified_loop_info->get_outer_splitted_loop_info() != outer_loop_info->get_unified_loop_info()) {continue;+ }OPENVINO_ASSERT(current_dim_idx == inner_unified_loop_info->get_dim_idx(),"Incorrect processing dim index of splitted loops");@@ -221,7 +232,4 @@ std::shared_ptr<pass::PassBase> SplitLoops::TransformInnerSplitLoop::merge(: nullptr;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/validate.cpp b/src/common/snippets/src/lowered/pass/validate.cppindex 7a305ea9252..d458e17cf4d 100644--- a/src/common/snippets/src/lowered/pass/validate.cpp+++ b/src/common/snippets/src/lowered/pass/validate.cpp@@ -4,15 +4,31 @@#include "snippets/lowered/pass/validate.hpp"+#include <algorithm>+#include <cstddef>+#include <limits>+#include <memory>+#include <set>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"+#include "openvino/op/parameter.hpp"+#include "openvino/op/result.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/expressions/buffer_expression.hpp"+#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/loop_manager.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/lowered/port_descriptor.hpp"+#include "snippets/op/buffer.hpp"+#include "snippets/op/loop.hpp"+#include "snippets/op/memory_access.hpp"+#include "snippets/op/perf_count.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {namespace {@@ -30,7 +46,7 @@ void validate_ports(const ExpressionPtr& expr) {std::for_each(out_descs.cbegin(), out_descs.cend(), validate_descriptor);}-void validate_parameter(const ExpressionPtr& expr, const LinearIR& linear_ir) {+void validate_parameter(const ExpressionPtr& expr, [[maybe_unused]] const LinearIR& linear_ir) {OPENVINO_ASSERT(ov::is_type<ov::op::v0::Parameter>(expr->get_node()), "Parameter validation expects Parameter op");const auto& shape_infer_seq = utils::get_first_child_shape_infer_expr_seq(expr);const auto& expr_val = shape_infer_seq.empty() ? expr : shape_infer_seq.back();@@ -50,7 +66,7 @@ void validate_parameter(const ExpressionPtr& expr, const LinearIR& linear_ir) {OPENVINO_ASSERT(layouts.size() == 1, "All consumers of Parameter must have the same layout");}-void validate_result(const ExpressionPtr& expr, const LinearIR& linear_ir) {+void validate_result(const ExpressionPtr& expr, [[maybe_unused]] const LinearIR& linear_ir) {OPENVINO_ASSERT(ov::is_type<ov::op::v0::Result>(expr->get_node()), "Result validation expects Result op");const auto& shape_infer_seq = utils::get_first_parent_shape_infer_expr_seq(expr);const auto& expr_val = shape_infer_seq.empty() ? expr : shape_infer_seq.back();@@ -59,7 +75,7 @@ void validate_result(const ExpressionPtr& expr, const LinearIR& linear_ir) {OPENVINO_ASSERT(ma && ma->is_memory_access_output_port(source.get_index()), "Result expects MemoryAccess parent");}-void validate_buffer(const ExpressionPtr& expr, const LinearIR& linear_ir) {+void validate_buffer(const ExpressionPtr& expr, [[maybe_unused]] const LinearIR& linear_ir) {OPENVINO_ASSERT(ov::is_type<op::Buffer>(expr->get_node()), "Buffer validation expects Buffer op");OPENVINO_ASSERT(ov::is_type<BufferExpression>(expr), "Buffer validation expects Buffer expression");for (const auto& input : expr->get_input_port_connectors()) {@@ -143,7 +159,7 @@ bool Validate::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lodouble prev_exec_order = -1 * std::numeric_limits<double>::max();for (auto expr_it = begin; expr_it != end; ++expr_it) {- const auto expr = *expr_it;+ const auto& expr = *expr_it;const auto node = expr->get_node();const auto found = m_validation_map.find(node->get_type_info());if (found != m_validation_map.cend()) {@@ -159,8 +175,9 @@ bool Validate::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lo"Incorrect count of output port descriptors!");expr->validate();// Loop expr doesn't have shapes and layouts- if (!ov::is_type<op::LoopBase>(node))+ if (!ov::is_type<op::LoopBase>(node)) {validate_ports(expr);+ }OPENVINO_ASSERT(expr->get_exec_num() > prev_exec_order, "Invalid execution order of expression");prev_exec_order = expr->get_exec_num();@@ -169,7 +186,4 @@ bool Validate::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, loreturn false;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/validate_buffers.cpp b/src/common/snippets/src/lowered/pass/validate_buffers.cppindex 50092ac29ca..3709fcbd326 100644--- a/src/common/snippets/src/lowered/pass/validate_buffers.cpp+++ b/src/common/snippets/src/lowered/pass/validate_buffers.cpp@@ -4,26 +4,32 @@#include "snippets/lowered/pass/validate_buffers.hpp"+#include <algorithm>+#include <cstddef>+#include <map>+#include <set>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"#include "snippets/itt.hpp"-#include "snippets/utils/utils.hpp"+#include "snippets/lowered/expressions/buffer_expression.hpp"+#include "snippets/lowered/linear_ir.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {bool ValidateBuffers::run(LinearIR& linear_ir,- lowered::LinearIR::constExprIt begin,- lowered::LinearIR::constExprIt end) {+ [[maybe_unused]] lowered::LinearIR::constExprIt begin,+ [[maybe_unused]] lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::ValidateBuffers")const auto& lir_buffers = linear_ir.get_buffers();// Firstly we check that all BufferExpression are in "get_buffers()"for (const auto& expr : linear_ir) {- if (const auto& buffer_expr = ov::as_type_ptr<BufferExpression>(expr))+ if (const auto& buffer_expr = ov::as_type_ptr<BufferExpression>(expr)) {OPENVINO_ASSERT(std::find(lir_buffers.cbegin(), lir_buffers.cend(), buffer_expr) != lir_buffers.cend(),"All BufferExpressions must be in LinearIR.get_buffers()");+ }}// Secondly we should validate buffers and their clusters@@ -51,7 +57,7 @@ bool ValidateBuffers::run(LinearIR& linear_ir,OPENVINO_ASSERT(dynamic_buffer_clusters.count(cluster_id) == 0,"Buffers from the same cluster must be only static or dynamic");- OPENVINO_ASSERT(cluster.size() > 0, "Incorrect size of buffer cluster");+ OPENVINO_ASSERT(!cluster.empty(), "Incorrect size of buffer cluster");size_t cluster_offset = (*cluster.cbegin())->get_offset();for (const auto& buffer_expr : cluster) {OPENVINO_ASSERT(cluster_offset == buffer_expr->get_offset(),@@ -62,7 +68,4 @@ bool ValidateBuffers::run(LinearIR& linear_ir,return !lir_buffers.empty();}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/validate_expanded_loops.cpp b/src/common/snippets/src/lowered/pass/validate_expanded_loops.cppindex 9f322a5f5ce..7db49a6b475 100644--- a/src/common/snippets/src/lowered/pass/validate_expanded_loops.cpp+++ b/src/common/snippets/src/lowered/pass/validate_expanded_loops.cpp@@ -4,15 +4,25 @@#include "snippets/lowered/pass/validate_expanded_loops.hpp"+#include <cstddef>+#include <cstdint>+#include <set>+#include <string>+#include <unordered_map>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/loop_manager.hpp"+#include "snippets/lowered/specific_loop_iter_types.hpp"#include "snippets/op/loop.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {#define INFORMATIVE_ASSERT(cond, ...) OPENVINO_ASSERT((cond), "Failed to validate ExpandedLoops: ", __VA_ARGS__)@@ -24,11 +34,13 @@ bool is_inner_splitted_tail(const ExpressionPtr& loop_expr, const LoopManagerPtrconst auto expanded_loop_info = ov::as_type_ptr<ExpandedLoopInfo>(loop_manager->get_loop_info(loop_id));INFORMATIVE_ASSERT(expanded_loop_info, "expects only ExpandedLoopInfo in LoopManager");// Inner Splitted Tail Loop has `MAIN_BODY` type for now after InsertSpecificIteration pass- if (expanded_loop_info->get_type() != SpecificLoopIterType::MAIN_BODY)+ if (expanded_loop_info->get_type() != SpecificLoopIterType::MAIN_BODY) {return false;+ }const auto outer_loops = loop_expr->get_loop_ids();- if (outer_loops.empty())+ if (outer_loops.empty()) {return false;+ }const auto outer_loop_id = outer_loops.front();const auto outer_expanded_loop_info = ov::as_type_ptr<ExpandedLoopInfo>(loop_manager->get_loop_info(outer_loop_id));INFORMATIVE_ASSERT(outer_expanded_loop_info, "expects only ExpandedLoopInfo in LoopManager");@@ -77,9 +89,10 @@ void ValidateExpandedLoops::validate_loop_information(const LinearIR& linear_ir)const auto& finalization_offsets = expanded_loop_info->get_finalization_offsets();INFORMATIVE_ASSERT(finalization_offsets.size() == current_info.finalization_offsets.size(),"incompatible finalization offset count");- for (size_t i = 0; i < current_info.num_ports; ++i)+ for (size_t i = 0; i < current_info.num_ports; ++i) {current_info.finalization_offsets[i] =utils::dynamic_safe_add(current_info.finalization_offsets[i], finalization_offsets[i]);+ }}// Validation of total information@@ -108,8 +121,9 @@ void ValidateExpandedLoops::validate_loop_expressions(const LinearIR& linear_ir)// At the moment, InnerSpliitedTail LoopEnd is not compatible with ExpandedLoopInfo// Validation is not supported- if (is_inner_splitted_tail(expr, loop_manager))+ if (is_inner_splitted_tail(expr, loop_manager)) {continue;+ }const auto expanded_loop_info = ov::as_type_ptr<ExpandedLoopInfo>(loop_manager->get_loop_info(loop_id));INFORMATIVE_ASSERT(expanded_loop_info, "expects only ExpandedLoopInfo in LoopManager");@@ -143,7 +157,4 @@ bool ValidateExpandedLoops::run(LinearIR& linear_ir) {#undef INFORMATIVE_ASSERT-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/validate_shapes.cpp b/src/common/snippets/src/lowered/pass/validate_shapes.cppindex 1a16ece6d54..68b9f10ff5b 100644--- a/src/common/snippets/src/lowered/pass/validate_shapes.cpp+++ b/src/common/snippets/src/lowered/pass/validate_shapes.cpp@@ -4,17 +4,17 @@#include "snippets/lowered/pass/validate_shapes.hpp"+#include <cstddef>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/op/loop.hpp"-#include "snippets/shape_inference/shape_inference.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {-bool ValidateShapes::run(lowered::LinearIR& linear_ir,+bool ValidateShapes::run([[maybe_unused]] LinearIR& linear_ir,lowered::LinearIR::constExprIt begin,lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::ValidateShapes")@@ -27,8 +27,9 @@ bool ValidateShapes::run(lowered::LinearIR& linear_ir,OPENVINO_ASSERT(port_connectors.size() == num_inputs, "Invalid number of port connectors detected");OPENVINO_ASSERT(port_descriptors.size() == num_inputs, "Invalid number of port descriptors detected");for (size_t i = 0; i < num_inputs; i++) {- if (ov::is_type<ov::snippets::op::LoopBase>(expr->get_node()))+ if (ov::is_type<ov::snippets::op::LoopBase>(expr->get_node())) {continue;+ }const auto& descr = port_descriptors[i];const auto& layout = descr->get_layout();const auto& shape = descr->get_shape();@@ -48,7 +49,4 @@ bool ValidateShapes::run(lowered::LinearIR& linear_ir,return false;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/pass/validate_unified_loops.cpp b/src/common/snippets/src/lowered/pass/validate_unified_loops.cppindex 012102aa481..0ceb8dc5b81 100644--- a/src/common/snippets/src/lowered/pass/validate_unified_loops.cpp+++ b/src/common/snippets/src/lowered/pass/validate_unified_loops.cpp@@ -4,16 +4,24 @@#include "snippets/lowered/pass/validate_unified_loops.hpp"+#include <algorithm>+#include <cstddef>+#include <set>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression_port.hpp"#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/loop_manager.hpp"+#include "snippets/lowered/loop_port.hpp"+#include "snippets/op/loop.hpp"#include "snippets/utils/loop_utils.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {-namespace pass {+namespace ov::snippets::lowered::pass {void ValidateUnifiedLoops::validate_loop_infos(const LoopManagerPtr& loop_manager) {// Already validated vectors of Loop IDs@@ -21,12 +29,9 @@ void ValidateUnifiedLoops::validate_loop_infos(const LoopManagerPtr& loop_manageauto is_already_verified = [&validated_nested_loops](const std::vector<size_t>& ids) {// If `ids` is subsequence of one of loop_ids in `validated_nested_loops` set,// it means that `ids` is already validated too- for (const auto& loop : validated_nested_loops) {- if (std::search(ids.cbegin(), ids.cend(), loop.cbegin(), loop.cend()) != ids.cend()) {- return true;- }- }- return false;+ return std::any_of(validated_nested_loops.begin(), validated_nested_loops.end(), [&ids](const auto& loop) {+ return std::search(ids.cbegin(), ids.cend(), loop.cbegin(), loop.cend()) != ids.cend();+ });};std::vector<size_t> dim_indexes;@@ -36,8 +41,9 @@ void ValidateUnifiedLoops::validate_loop_infos(const LoopManagerPtr& loop_manageconst auto expr = loop_port.get_expr_port()->get_expr();const auto& loop_ids = expr->get_loop_ids();// If loop_ids of the current port is subsequence of already validated IDs, skip- if (is_already_verified(loop_ids))+ if (is_already_verified(loop_ids)) {return;+ }dim_indexes.clear();dim_indexes.reserve(loop_ids.size());@@ -47,8 +53,9 @@ void ValidateUnifiedLoops::validate_loop_infos(const LoopManagerPtr& loop_manageconst auto dim_idx = loop_manager->get_loop_info(id)->get_dim_idx();// if the loop has different dimension indexes, it don't have to meet the split loop related// requirements- if (dim_idx == LoopPort::UNDEFINED_DIM_IDX)+ if (dim_idx == LoopPort::UNDEFINED_DIM_IDX) {continue;+ }if (i > 0) {if (std::find(dim_indexes.cbegin(), dim_indexes.cend(), dim_idx) != dim_indexes.cend()) {OPENVINO_ASSERT(*dim_indexes.rbegin() == dim_idx,@@ -80,8 +87,9 @@ void ValidateUnifiedLoops::validate_loop_infos(const LoopManagerPtr& loop_manage: ov::snippets::utils::get_preordered_vdims(*loop_port.get_expr_port());const auto& dim = *(planar_shape.rbegin() + loop_port.get_dim_idx());// Since dim == 1 can be broadcasted to any value, it's not necessary to add it to unique dims- if (!utils::is_dynamic_value(dim) && dim != 1)+ if (!utils::is_dynamic_value(dim) && dim != 1) {unique_dimensions.insert(dim);+ }}});OPENVINO_ASSERT(unique_dimensions.size() <= 1,@@ -111,25 +119,29 @@ void ValidateUnifiedLoops::validate_loop_port_presence(const LinearIR& linear_irconst auto& loop_manager = linear_ir.get_loop_manager();for (const auto& expr : linear_ir) {const auto& op = expr->get_node();- if (ov::is_type<ov::snippets::op::LoopBase>(op))+ if (ov::is_type<ov::snippets::op::LoopBase>(op)) {continue;+ }for (const auto& loop_id : expr->get_loop_ids()) {const auto& loop_info = loop_manager->get_loop_info(loop_id);- for (size_t i = 0; i < expr->get_input_count(); ++i)+ for (size_t i = 0; i < expr->get_input_count(); ++i) {validate_loop_port(expr->get_input_port(i), loop_info, loop_id);+ }- for (size_t i = 0; i < expr->get_output_count(); ++i)+ for (size_t i = 0; i < expr->get_output_count(); ++i) {validate_loop_port(expr->get_output_port(i), loop_info, loop_id);+ }}}}bool ValidateUnifiedLoops::run(LinearIR& linear_ir) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::ValidateUnifiedLoops")- if (linear_ir.empty())+ if (linear_ir.empty()) {return false;+ }validate_loop_infos(linear_ir.get_loop_manager());validate_loop_port_presence(linear_ir);@@ -137,7 +149,4 @@ bool ValidateUnifiedLoops::run(LinearIR& linear_ir) {return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowered::passdiff --git a/src/common/snippets/src/lowered/port_connector.cpp b/src/common/snippets/src/lowered/port_connector.cppindex 0aba531e341..0327f2fc455 100644--- a/src/common/snippets/src/lowered/port_connector.cpp+++ b/src/common/snippets/src/lowered/port_connector.cpp@@ -4,12 +4,15 @@#include "snippets/lowered/port_connector.hpp"+#include <algorithm>+#include <set>+#include <utility>++#include "openvino/core/except.hpp"#include "snippets/itt.hpp"-#include "snippets/utils/utils.hpp"+#include "snippets/lowered/expression_port.hpp"-namespace ov {-namespace snippets {-namespace lowered {+namespace ov::snippets::lowered {PortConnector::PortConnector(ExpressionPort source_descriptor, const std::set<ExpressionPort>& consumer_descriptors): m_source_port(std::move(source_descriptor)),@@ -45,6 +48,4 @@ void PortConnector::remove_consumer(const ExpressionPort& consumer) {m_consumer_ports.erase(found);}-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/src/lowered/port_descriptor.cpp b/src/common/snippets/src/lowered/port_descriptor.cppindex 11d36b81c33..75e2dec035c 100644--- a/src/common/snippets/src/lowered/port_descriptor.cpp+++ b/src/common/snippets/src/lowered/port_descriptor.cpp@@ -5,11 +5,22 @@#include "snippets/lowered/port_descriptor.hpp"#include <cassert>+#include <cstddef>+#include <memory>#include <snippets/utils/utils.hpp>+#include <sstream>+#include <string>+#include <utility>+#include <vector>-namespace ov {-namespace snippets {-namespace lowered {+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_input.hpp"+#include "openvino/core/node_output.hpp"+#include "snippets/emitter.hpp"+#include "snippets/shape_types.hpp"++namespace ov::snippets::lowered {PortDescriptor::PortDescriptor(const ov::Input<ov::Node>& in, VectorDims subtensor_shape, std::vector<size_t> layout): PortDescriptor(ov::Input<const Node>(in.get_node(), in.get_index()),@@ -35,13 +46,13 @@ PortDescriptor::PortDescriptor(VectorDims shape, VectorDims subtensor_shape, std: PortDescriptor(std::make_shared<VectorDims>(std::move(shape)),std::move(subtensor_shape),std::move(layout),- std::move(reg)) {}+ reg) {}PortDescriptor::PortDescriptor(VectorDimsPtr shape, VectorDims subtensor_shape, std::vector<size_t> layout, Reg reg): m_tensor_shape(std::move(shape)),m_layout(std::move(layout)),m_subtensor_shape(std::move(subtensor_shape)),- m_reg(std::move(reg)) {+ m_reg(reg) {validate_arguments();}@@ -83,7 +94,7 @@ void PortDescriptor::set_subtensor(const VectorDims& subtensor) {void PortDescriptor::set_reg(Reg reg) {OPENVINO_ASSERT(m_reg.type != RegType::address, "Failed to set reg: reg with 'address' type mustn't be changed");- m_reg = std::move(reg);+ m_reg = reg;}void PortDescriptor::set_reg_type(RegType type) {@@ -106,14 +117,17 @@ std::string PortDescriptor::serialize() const {std::stringstream ss;OPENVINO_ASSERT(m_tensor_shape, "TensorShape is nullptr!");ss << m_tensor_shape->size() << " ";- for (auto val : *m_tensor_shape)+ for (auto val : *m_tensor_shape) {ss << val << " ";+ }ss << m_subtensor_shape.size() << " ";- for (auto val : m_subtensor_shape)+ for (auto val : m_subtensor_shape) {ss << val << " ";+ }ss << m_layout.size() << " ";- for (auto val : m_layout)+ for (auto val : m_layout) {ss << val << " ";+ }ss << m_reg;return ss.str();}@@ -147,8 +161,9 @@ void PortDescriptorUtils::set_port_descriptor_ptr(const ov::Input<ov::Node>& in,rt_info[key] = PortDescriptorVectorAttribute(in_descs, out_descs);} else {auto& in_descs = found->second.as<PortDescriptorVectorAttribute>().inputs;- if (in_descs.size() != node->get_input_size())+ if (in_descs.size() != node->get_input_size()) {OPENVINO_THROW("Set input port descriptor is failed: incorrect count");+ }in_descs[in.get_index()] = desc;}}@@ -165,8 +180,9 @@ void PortDescriptorUtils::set_port_descriptor_ptr(const ov::Output<ov::Node>& ourt_info[key] = PortDescriptorVectorAttribute(in_descs, out_descs);} else {auto& out_descs = found->second.as<PortDescriptorVectorAttribute>().outputs;- if (out_descs.size() != node->get_output_size())+ if (out_descs.size() != node->get_output_size()) {OPENVINO_THROW("Set output port descriptor is failed: incorrect count");+ }out_descs[out.get_index()] = desc;}}@@ -177,8 +193,9 @@ void set_port_desc(const T& port, std::vector<size_t> subtensor, std::vector<sizconst auto& shape = utils::pshape_to_vdims(port.get_partial_shape());for (size_t i = 1; i <= std::min(subtensor.size(), shape.size()); i++) {auto& dim = subtensor[subtensor.size() - i];- if (!utils::is_full_dim_value(dim))+ if (!utils::is_full_dim_value(dim)) {dim = std::min(dim, shape[shape.size() - i]);+ }}PortDescriptorUtils::set_port_descriptor_ptr(port, std::make_shared<PortDescriptor>(shape, subtensor, layout));}@@ -200,15 +217,16 @@ PortDescriptorPtr PortDescriptorUtils::get_port_descriptor_ptr(const ov::Input<o}PortDescriptorPtr PortDescriptorUtils::get_port_descriptor_ptr(const ov::Input<const ov::Node>& in) {const auto& node = in.get_node();- auto& rt_info = node->get_rt_info();+ const auto& rt_info = node->get_rt_info();const auto& key = PortDescriptorVectorAttribute::get_type_info_static();const auto& found = rt_info.find(key);if (found == rt_info.end()) {return std::make_shared<PortDescriptor>(in);}const auto& in_descs = found->second.as<PortDescriptorVectorAttribute>().inputs;- if (in_descs.size() != node->get_input_size())+ if (in_descs.size() != node->get_input_size()) {OPENVINO_THROW("Get input port descriptor is failed: incorrect count");+ }return in_descs[in.get_index()];}@@ -224,8 +242,9 @@ PortDescriptorPtr PortDescriptorUtils::get_port_descriptor_ptr(const Output<consreturn std::make_shared<PortDescriptor>(out);}const auto& out_descs = found->second.as<PortDescriptorVectorAttribute>().outputs;- if (out_descs.size() != node->get_output_size())+ if (out_descs.size() != node->get_output_size()) {OPENVINO_THROW("Get output port descriptor is failed: incorrect count");+ }return out_descs[out.get_index()];}@@ -245,6 +264,4 @@ void PortDescriptorUtils::clean(const std::shared_ptr<ov::Node>& node) {auto& rt_info = node->get_rt_info();rt_info.erase(PortDescriptorVectorAttribute::get_type_info_static());}-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/src/lowered/specific_loop_iter_handlers.cpp b/src/common/snippets/src/lowered/specific_loop_iter_handlers.cppindex e92348484e7..da859123fa0 100644--- a/src/common/snippets/src/lowered/specific_loop_iter_handlers.cpp+++ b/src/common/snippets/src/lowered/specific_loop_iter_handlers.cpp@@ -4,20 +4,21 @@#include "snippets/lowered/specific_loop_iter_handlers.hpp"+#include <cstddef>+#include <utility>+#include "snippets/lowered/pass/iter_handler.hpp"#include "snippets/lowered/pass/propagate_subtensors.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace lowered {+namespace ov::snippets::lowered {SpecificIterationHandlers::SpecificIterationHandlers(size_t loop_work_amount,size_t loop_increment,size_t processing_dim_idx) {// The following handlers are set only for Last Iter processingif (loop_increment > 1) {- size_t last_iter_increment = utils::get_dynamic_value<size_t>();+ auto last_iter_increment = utils::get_dynamic_value<size_t>();if (!utils::is_dynamic_value(loop_work_amount)) {last_iter_increment = loop_work_amount % loop_increment;} else if (utils::is_dynamic_value(loop_work_amount) && processing_dim_idx == 0) {@@ -29,8 +30,9 @@ SpecificIterationHandlers::SpecificIterationHandlers(size_t loop_work_amount,m_last_iter_handlers.register_pass<lowered::pass::UpdateMemoryAccessCounts>(last_iter_increment);m_last_iter_handlers.register_pass<lowered::pass::UpdateSubtensors>(last_iter_increment);// Last Iterations of Loop processed last dimensions with Eltwise nodes inside should have increment = 1- if (last_iter_increment == 1)+ if (last_iter_increment == 1) {m_last_iter_handlers.register_pass<lowered::pass::SetLoopIncrementOne>();+ }}}}@@ -44,12 +46,9 @@ SpecificIterationHandlers::SpecificIterationHandlers(lowered::pass::PassPipelineSpecificIterationHandlers SpecificIterationHandlers::merge_handlers(const SpecificIterationHandlers& lhs,const SpecificIterationHandlers& rhs) {- return SpecificIterationHandlers(- pass::PassPipeline::merge_pipelines(lhs.m_first_iter_handlers, rhs.m_first_iter_handlers),- pass::PassPipeline::merge_pipelines(lhs.m_main_body_handlers, rhs.m_main_body_handlers),- pass::PassPipeline::merge_pipelines(lhs.m_last_iter_handlers, rhs.m_last_iter_handlers));+ return {pass::PassPipeline::merge_pipelines(lhs.m_first_iter_handlers, rhs.m_first_iter_handlers),+ pass::PassPipeline::merge_pipelines(lhs.m_main_body_handlers, rhs.m_main_body_handlers),+ pass::PassPipeline::merge_pipelines(lhs.m_last_iter_handlers, rhs.m_last_iter_handlers)};}-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::lowereddiff --git a/src/common/snippets/src/lowered/target_machine.cpp b/src/common/snippets/src/lowered/target_machine.cppindex b6db7cdcaad..8e910193647 100644--- a/src/common/snippets/src/lowered/target_machine.cpp+++ b/src/common/snippets/src/lowered/target_machine.cpp@@ -4,6 +4,16 @@#include "snippets/target_machine.hpp"+#include <functional>+#include <memory>+#include <set>++#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"+#include "snippets/emitter.hpp"+#include "snippets/lowered/expression.hpp"#include "snippets/runtime_configurator.hpp"using namespace ov::snippets;diff --git a/src/common/snippets/src/op/brgemm.cpp b/src/common/snippets/src/op/brgemm.cppindex 7fe89a0e013..144348e1d4f 100644--- a/src/common/snippets/src/op/brgemm.cpp+++ b/src/common/snippets/src/op/brgemm.cpp@@ -5,24 +5,38 @@#include "snippets/op/brgemm.hpp"#include <cassert>--#include "openvino/core/rt_info.hpp"+#include <cstddef>+#include <iterator>+#include <memory>+#include <set>+#include <utility>+#include <vector>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_input.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/partial_shape.hpp"+#include "openvino/core/type/element_type.hpp"+#include "openvino/op/op.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/port_descriptor.hpp"+#include "snippets/op/memory_access.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {namespace {std::vector<size_t> get_output_layout(const std::shared_ptr<const ov::Node>& n) {const auto& key = lowered::PortDescriptorVectorAttribute::get_type_info_static();- auto& rt_info = n->get_rt_info();+ const auto& rt_info = n->get_rt_info();const auto& found = rt_info.find(key);if (found != rt_info.end()) {const auto& out_descs = found->second.as<lowered::PortDescriptorVectorAttribute>().outputs;- if (out_descs.size() != n->get_output_size())+ if (out_descs.size() != n->get_output_size()) {OPENVINO_THROW("Get output port descriptor is failed: incorrect count");+ }const auto& port_desc = out_descs[0];return port_desc->get_layout();}@@ -33,19 +47,19 @@ std::vector<size_t> get_output_layout(const std::shared_ptr<const ov::Node>& n)Brgemm::Brgemm(const Output<Node>& A,const Output<Node>& B,- const size_t offset_a,- const size_t offset_b,- const size_t offset_c,- std::vector<size_t> layout_a,- std::vector<size_t> layout_b,- std::vector<size_t> layout_c)+ size_t offset_a,+ size_t offset_b,+ size_t offset_c,+ const std::vector<size_t>& layout_a,+ const std::vector<size_t>& layout_b,+ const std::vector<size_t>& layout_c): MemoryAccess(std::set<size_t>{0, 1}, std::set<size_t>{0}),Op({A, B}) {set_output_size(1);set_input_offset(offset_a, 0);set_input_offset(offset_b, 1);set_output_offset(offset_c, 0);- custom_constructor_validate_and_infer_types(std::move(layout_a), std::move(layout_b), std::move(layout_c));+ custom_constructor_validate_and_infer_types(layout_a, layout_b, layout_c);}Brgemm::Brgemm(const Output<Node>& A,@@ -53,18 +67,18 @@ Brgemm::Brgemm(const Output<Node>& A,const PortDescriptor& desc_a,const PortDescriptor& desc_b,const PortDescriptor& desc_c,- std::vector<size_t> layout_a,- std::vector<size_t> layout_b,- std::vector<size_t> layout_c)+ const std::vector<size_t>& layout_a,+ const std::vector<size_t>& layout_b,+ const std::vector<size_t>& layout_c): MemoryAccess(PortMap{{0, desc_a}, {1, desc_b}}, PortMap{{0, desc_c}}),Op({A, B}) {set_output_size(1);- custom_constructor_validate_and_infer_types(std::move(layout_a), std::move(layout_b), std::move(layout_c));+ custom_constructor_validate_and_infer_types(layout_a, layout_b, layout_c);}-void Brgemm::custom_constructor_validate_and_infer_types(std::vector<size_t> layout_a,- std::vector<size_t> layout_b,- std::vector<size_t> layout_c) {+void Brgemm::custom_constructor_validate_and_infer_types(const std::vector<size_t>& layout_a,+ const std::vector<size_t>& layout_b,+ const std::vector<size_t>& layout_c) {INTERNAL_OP_SCOPE(BrgemmCPU_constructor_validate_and_infer_types);// During ctor call, Brgemm doesn't know his port descriptors.@@ -108,11 +122,11 @@ ov::element::Type Brgemm::get_output_type(const ov::element::Type& in_type0, conconst bool is_f16 = utils::everyone_is(element::f16, in_type0, in_type1);if (is_f32 || is_bf16 || is_f16) {return element::f32;- } else if (is_int8) {+ }+ if (is_int8) {return element::i32;- } else {- return element::dynamic;}+ return element::dynamic;}ov::element::Type Brgemm::get_output_type() const {@@ -125,7 +139,7 @@ ov::element::Type Brgemm::get_output_type() const {return output_type;}-std::vector<ov::PartialShape> Brgemm::get_planar_input_shapes(const std::vector<ov::Input<ov::Node>>& inputs) const {+std::vector<ov::PartialShape> Brgemm::get_planar_input_shapes(const std::vector<ov::Input<ov::Node>>& inputs) {assert(inputs.size() == 2 && "Brgemm::get_planar_input_shapes() expects 2 inputs");return {utils::get_planar_pshape(inputs[0]), utils::get_planar_pshape(inputs[1])};}@@ -133,19 +147,20 @@ std::vector<ov::PartialShape> Brgemm::get_planar_input_shapes(const std::vector<ov::PartialShape Brgemm::get_planar_output_shape(const ov::PartialShape& output_shape) const {// This method can be safely called from validate_and_infer_types() before output creationconst auto& out_layout = get_output_layout(shared_from_this());- if (!out_layout.empty())+ if (!out_layout.empty()) {return utils::get_planar_pshape(output_shape, out_layout);+ }return output_shape;}-ov::PartialShape Brgemm::infer_output_partial_shape(const std::vector<ov::PartialShape>& input_shapes) const {+ov::PartialShape Brgemm::infer_output_partial_shape(const std::vector<ov::PartialShape>& input_shapes) {OPENVINO_ASSERT(input_shapes.size() == 2, "BRGEMM expects 2 input shapes for shape inference");// Note: All majors checks are missed because Brgemm is transformed from MatMul with whole shape infer support- const auto arg0_shape = input_shapes[0];- const auto arg1_shape = input_shapes[1];+ const auto& arg0_shape = input_shapes[0];+ const auto& arg1_shape = input_shapes[1];size_t arg0_rank = arg0_shape.size(), arg1_rank = arg1_shape.size();@@ -180,10 +195,11 @@ ov::PartialShape Brgemm::infer_output_partial_shape(const std::vector<ov::Partiaarg1_row_dim);// add 1 to begin to align shape ranks if needed- if (arg0_rank < arg1_rank)+ if (arg0_rank < arg1_rank) {arg0_shape_tmp.insert(arg0_shape_tmp.begin(), arg1_rank - arg0_rank, 1);- else if (arg0_rank > arg1_rank)+ } else if (arg0_rank > arg1_rank) {arg1_shape_tmp.insert(arg1_shape_tmp.begin(), arg0_rank - arg1_rank, 1);+ }size_t max_rank = arg0_shape_tmp.size();std::vector<DimType> output_shape(max_rank);@@ -204,6 +220,4 @@ ov::PartialShape Brgemm::infer_output_partial_shape(const std::vector<ov::Partia}return output_shape;}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/op/broadcastload.cpp b/src/common/snippets/src/op/broadcastload.cppindex 33b09228f4f..e668781f7fd 100644--- a/src/common/snippets/src/op/broadcastload.cpp+++ b/src/common/snippets/src/op/broadcastload.cpp@@ -4,12 +4,21 @@#include "snippets/op/broadcastload.hpp"-#include "openvino/reference/broadcast.hpp"+#include <cstddef>+#include <memory>+#include <set>+#include <utility>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/dimension.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/op/op.hpp"#include "snippets/itt.hpp"+#include "snippets/op/memory_access.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {BroadcastLoad::BroadcastLoad(const Output<Node>& x, ov::Dimension bcast_dimension, size_t offset): MemoryAccess(std::set<size_t>{0}, std::set<size_t>{}),@@ -36,14 +45,13 @@ void BroadcastLoad::validate_and_infer_types() {const auto output_ma_ports = get_memory_access_output_ports();OPENVINO_ASSERT(input_ma_ports.size() == 1 && is_memory_access_input_port(0),"BroadcastLoad node must have memory access input port");- OPENVINO_ASSERT(output_ma_ports.size() == 0, "BroadcastLoad node mustn't have memory access output port");+ OPENVINO_ASSERT(output_ma_ports.empty(), "BroadcastLoad node mustn't have memory access output port");auto broadcasted_shape = get_input_partial_shape(0);- if (broadcasted_shape.size() == 0)+ if (broadcasted_shape.size() == 0) {broadcasted_shape.resize(1);+ }*broadcasted_shape.rbegin() = bcast_dimension;set_output_type(0, get_input_element_type(0), broadcasted_shape);}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/op/broadcastmove.cpp b/src/common/snippets/src/op/broadcastmove.cppindex d48c1bc46a4..caf3519c2cd 100644--- a/src/common/snippets/src/op/broadcastmove.cpp+++ b/src/common/snippets/src/op/broadcastmove.cpp@@ -4,11 +4,17 @@#include "snippets/op/broadcastmove.hpp"+#include <memory>+#include <utility>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/dimension.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/op/op.hpp"#include "snippets/itt.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {BroadcastMove::BroadcastMove(const Output<Node>& x, ov::Dimension bcast_dimension): Op({x}),@@ -29,12 +35,11 @@ std::shared_ptr<Node> BroadcastMove::clone_with_new_inputs(const OutputVector& nvoid BroadcastMove::validate_and_infer_types() {auto broadcasted_shape = get_input_partial_shape(0);- if (broadcasted_shape.size() == 0)+ if (broadcasted_shape.size() == 0) {broadcasted_shape.resize(1);+ }*broadcasted_shape.rbegin() = bcast_dimension;set_output_type(0, get_input_element_type(0), broadcasted_shape);}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/op/buffer.cpp b/src/common/snippets/src/op/buffer.cppindex 2ce520dfbdc..e7f696fb8f8 100644--- a/src/common/snippets/src/op/buffer.cpp+++ b/src/common/snippets/src/op/buffer.cpp@@ -4,12 +4,25 @@#include "snippets/op/buffer.hpp"+#include <algorithm>+#include <cstddef>+#include <memory>+#include <utility>+#include <vector>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"+#include "openvino/op/op.hpp"#include "snippets/itt.hpp"-#include "snippets/utils/utils.hpp"+#include "snippets/shape_inference/shape_inference.hpp"+#include "snippets/shape_types.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {Buffer::Buffer(const ov::Output<ov::Node>& arg) : Buffer(ov::OutputVector{arg}) {}@@ -17,8 +30,7 @@ Buffer::Buffer(const OutputVector& arguments) : Op(arguments), m_impl(std::make_constructor_validate_and_infer_types();}Buffer::Buffer(const ov::Shape& shape, ov::element::Type element_type)- : Op(),- m_impl(std::make_shared<NewMemoryImpl>(shape, element_type)) {+ : m_impl(std::make_shared<NewMemoryImpl>(shape, element_type)) {constructor_validate_and_infer_types();}Buffer::Buffer(const OutputVector& arguments, std::shared_ptr<BaseImpl> impl) : Op(arguments), m_impl(std::move(impl)) {@@ -100,7 +112,7 @@ bool Buffer::NewMemoryImpl::visit_attributes(AttributeVisitor& visitor) {return true;}-Buffer::NewMemoryImpl::ShapeInfer::ShapeInfer(ov::Shape shape) : m_shape(std::move(shape)) {}+Buffer::NewMemoryImpl::ShapeInfer::ShapeInfer(const ov::Shape& shape) : m_shape(shape) {}Buffer::NewMemoryImpl::ShapeInfer::Result Buffer::NewMemoryImpl::ShapeInfer::infer(const std::vector<VectorDimsRef>& input_shapes) {@@ -108,6 +120,4 @@ Buffer::NewMemoryImpl::ShapeInfer::Result Buffer::NewMemoryImpl::ShapeInfer::infreturn {{m_shape}, ShapeInferStatus::success};}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/op/convert_saturation.cpp b/src/common/snippets/src/op/convert_saturation.cppindex b913e27110e..157b78183fb 100644--- a/src/common/snippets/src/op/convert_saturation.cpp+++ b/src/common/snippets/src/op/convert_saturation.cpp@@ -4,6 +4,13 @@#include "snippets/op/convert_saturation.hpp"+#include <memory>++#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/type/element_type.hpp"+#include "openvino/op/convert.hpp"#include "snippets/itt.hpp"ov::snippets::op::ConvertSaturation::ConvertSaturation(const Output<Node>& x, const ov::element::Type& destination_type)diff --git a/src/common/snippets/src/op/convert_truncation.cpp b/src/common/snippets/src/op/convert_truncation.cppindex 24321b4bce4..f03826f5a36 100644--- a/src/common/snippets/src/op/convert_truncation.cpp+++ b/src/common/snippets/src/op/convert_truncation.cpp@@ -4,6 +4,13 @@#include "snippets/op/convert_truncation.hpp"+#include <memory>++#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/type/element_type.hpp"+#include "openvino/op/convert.hpp"#include "snippets/itt.hpp"ov::snippets::op::ConvertTruncation::ConvertTruncation(const Output<Node>& x, const ov::element::Type& destination_type)diff --git a/src/common/snippets/src/op/fill.cpp b/src/common/snippets/src/op/fill.cppindex bd76ec26411..3cb0254c007 100644--- a/src/common/snippets/src/op/fill.cpp+++ b/src/common/snippets/src/op/fill.cpp@@ -4,11 +4,19 @@#include "snippets/op/fill.hpp"+#include <cstddef>+#include <cstdint>+#include <memory>+#include <string>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/op/op.hpp"#include "snippets/itt.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {Fill::Fill(const Output<Node>& x, const size_t offset, const uint32_t fill_value): Op({x}),@@ -39,6 +47,4 @@ void Fill::validate_and_infer_types() {set_output_type(0, get_input_element_type(0), get_input_partial_shape(0));}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/op/horizon_max.cpp b/src/common/snippets/src/op/horizon_max.cppindex 7f4911ccf43..d0b48348f62 100644--- a/src/common/snippets/src/op/horizon_max.cpp+++ b/src/common/snippets/src/op/horizon_max.cpp@@ -4,11 +4,15 @@#include "snippets/op/horizon_max.hpp"+#include <memory>++#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/op/op.hpp"#include "snippets/itt.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {HorizonMax::HorizonMax(const Output<Node>& x) : Op({x}) {constructor_validate_and_infer_types();@@ -29,6 +33,4 @@ void HorizonMax::validate_and_infer_types() {set_output_type(0, get_input_element_type(0), new_shape);}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/op/horizon_sum.cpp b/src/common/snippets/src/op/horizon_sum.cppindex 7c8594d5a6a..c854e0e6a04 100644--- a/src/common/snippets/src/op/horizon_sum.cpp+++ b/src/common/snippets/src/op/horizon_sum.cpp@@ -4,11 +4,15 @@#include "snippets/op/horizon_sum.hpp"+#include <memory>++#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/op/op.hpp"#include "snippets/itt.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {HorizonSum::HorizonSum(const Output<Node>& x) : Op({x}) {constructor_validate_and_infer_types();@@ -29,6 +33,4 @@ void HorizonSum::validate_and_infer_types() {set_output_type(0, get_input_element_type(0), new_shape);}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/op/kernel.cpp b/src/common/snippets/src/op/kernel.cppindex ac983407c48..b7a6ac84c2e 100644--- a/src/common/snippets/src/op/kernel.cpp+++ b/src/common/snippets/src/op/kernel.cpp@@ -4,26 +4,27 @@#include "snippets/op/kernel.hpp"-#include "snippets/op/loop.hpp"+#include <memory>+#include <utility>-namespace ov {-namespace snippets {-namespace op {+#include "openvino/core/node.hpp"+#include "openvino/core/node_vector.hpp"+#include "snippets/lowered/linear_ir.hpp"-Kernel::Kernel(lowered::LinearIR nested) : Op(), region(std::make_shared<lowered::LinearIR>(std::move(nested))) {}+namespace ov::snippets::op {-KernelStatic::KernelStatic(lowered::LinearIR nested) : Kernel(std::move(nested)) {}+Kernel::Kernel(lowered::LinearIR region) : region(std::make_shared<lowered::LinearIR>(std::move(region))) {}-KernelDynamic::KernelDynamic(lowered::LinearIR nested) : Kernel(std::move(nested)) {}+KernelStatic::KernelStatic(lowered::LinearIR region) : Kernel(std::move(region)) {}-std::shared_ptr<Node> KernelStatic::clone_with_new_inputs(const OutputVector& inputs) const {- return std::make_shared<KernelStatic>(*region.get());+KernelDynamic::KernelDynamic(lowered::LinearIR region) : Kernel(std::move(region)) {}++std::shared_ptr<Node> KernelStatic::clone_with_new_inputs([[maybe_unused]] const OutputVector& inputs) const {+ return std::make_shared<KernelStatic>(*region);}-std::shared_ptr<Node> KernelDynamic::clone_with_new_inputs(const OutputVector& inputs) const {- return std::make_shared<KernelDynamic>(*region.get());+std::shared_ptr<Node> KernelDynamic::clone_with_new_inputs([[maybe_unused]] const OutputVector& inputs) const {+ return std::make_shared<KernelDynamic>(*region);}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/op/load.cpp b/src/common/snippets/src/op/load.cppindex 2aacd94fc78..ca3dd3b9824 100644--- a/src/common/snippets/src/op/load.cpp+++ b/src/common/snippets/src/op/load.cpp@@ -4,12 +4,26 @@#include "snippets/op/load.hpp"+#include <algorithm>+#include <cstddef>+#include <memory>+#include <set>+#include <utility>+#include <vector>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/type.hpp"+#include "openvino/op/op.hpp"#include "snippets/itt.hpp"+#include "snippets/op/memory_access.hpp"+#include "snippets/shape_inference/shape_inference.hpp"+#include "snippets/shape_types.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {Load::Load(const Output<Node>& x, const size_t count, const size_t offset): MemoryAccess(std::set<size_t>{0}, std::set<size_t>{}),@@ -24,7 +38,7 @@ void Load::validate_memory_access_params() const {const auto output_ma_ports = get_memory_access_output_ports();OPENVINO_ASSERT(input_ma_ports.size() == 1 && is_memory_access_input_port(0),"Load node must have memory access input port");- OPENVINO_ASSERT(output_ma_ports.size() == 0, "Load node mustn't have memory access output port");+ OPENVINO_ASSERT(output_ma_ports.empty(), "Load node mustn't have memory access output port");}void Load::validate_and_infer_types() {@@ -51,8 +65,8 @@ LoadReorder::LoadReorder(const Output<ov::Node>& x, const size_t count, const siOPENVINO_ASSERT(*std::max_element(m_order.begin(), m_order.end()) == in_shape_size - 1 &&*std::min_element(m_order.begin(), m_order.end()) == 0,"LoadReorder detected invalid values in new_order");- const std::set<size_t> unique_dims(order.begin(), order.end());- OPENVINO_ASSERT(unique_dims.size() == order.size(), "LoadReorder order must not contain repeated elements");+ const std::set<size_t> unique_dims(m_order.begin(), m_order.end());+ OPENVINO_ASSERT(unique_dims.size() == m_order.size(), "LoadReorder order must not contain repeated elements");constructor_validate_and_infer_types();}@@ -60,8 +74,9 @@ void LoadReorder::validate_and_infer_types() {validate_memory_access_params();const auto& old_shape = get_input_partial_shape(0);ov::PartialShape new_shape;- for (const auto idx : m_order)+ for (const auto idx : m_order) {new_shape.push_back(old_shape[idx]);+ }set_output_type(0, get_input_element_type(0), new_shape);}@@ -85,6 +100,4 @@ IShapeInferSnippets::Result LoadReorder::ShapeInfer::infer(const std::vector<VecOPENVINO_ASSERT(input_shapes.size() == 1, "Got unexpected number of input shapes");return {{utils::get_planar_vdims(input_shapes[0], m_order)}, ShapeInferStatus::success};}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/op/loop.cpp b/src/common/snippets/src/op/loop.cppindex 7958ae0b74d..7c24b2e70f0 100644--- a/src/common/snippets/src/op/loop.cpp+++ b/src/common/snippets/src/op/loop.cpp@@ -4,17 +4,29 @@#include "snippets/op/loop.hpp"+#include <algorithm>#include <cassert>-+#include <cstddef>+#include <cstdint>+#include <memory>+#include <utility>+#include <vector>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"+#include "openvino/op/op.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {LoopBase::LoopBase(const std::vector<Output<Node>>& args) : Op(args) {}-LoopBegin::LoopBegin() : LoopBase() {+LoopBegin::LoopBegin() {validate_and_infer_types_except_LoopEnd();}@@ -65,8 +77,7 @@ LoopEnd::LoopEnd(const Output<Node>& loop_begin,m_work_amount_increment(work_amount_increment),m_input_num(input_num),m_output_num(output_num),- m_id(id),- m_evaluate_once(false) {+ m_id(id) {constructor_validate_and_infer_types();}@@ -78,14 +89,14 @@ void LoopEnd::validate_and_infer_types() {#define VALIDATE_VALUES(values, name, default_value) \NODE_VALIDATION_CHECK(this, \- values.empty() || values.size() == io_size, \+ (values).empty() || (values).size() == io_size, \name, \" must be either empty or defined per every input & output of joined Loop. Expected size: ", \io_size, \" got ", \- values.size()); \- if (values.empty()) \- values.resize(io_size, default_value);+ (values).size()); \+ if ((values).empty()) \+ (values).resize(io_size, default_value);VALIDATE_VALUES(m_is_incremented, "is_incremented", true)VALIDATE_VALUES(m_ptr_increments, "ptr_increments", 0)@@ -219,6 +230,4 @@ void LoopEnd::set_id(size_t id) {m_id = id;}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/op/memory_access.cpp b/src/common/snippets/src/op/memory_access.cppindex faad24dc3fc..93c95eb8830 100644--- a/src/common/snippets/src/op/memory_access.cpp+++ b/src/common/snippets/src/op/memory_access.cpp@@ -5,18 +5,27 @@#include "snippets/op/memory_access.hpp"#include <cassert>-+#include <cstddef>+#include <memory>+#include <numeric>+#include <set>+#include <string>+#include <utility>+#include <vector>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"#include "snippets/itt.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace modifier {+namespace ov::snippets::modifier {MemoryAccess::MemoryAccess(size_t input_count, size_t output_count) {auto init_iota_set = [](size_t num) {- if (num == 0)+ if (num == 0) {return std::set<size_t>{};+ }std::vector<size_t> vec(num);std::iota(vec.begin(), vec.end(), 0);return std::set<size_t>(vec.begin(), vec.end());@@ -28,9 +37,9 @@ MemoryAccess::MemoryAccess(const std::set<size_t>& input_ports, const std::set<sctor_initialize(input_ports, output_ports);}-MemoryAccess::MemoryAccess(const PortMap& input_ports, const PortMap& output_ports)- : m_input_ports(input_ports),- m_output_ports(output_ports) {}+MemoryAccess::MemoryAccess(PortMap input_ports, PortMap output_ports)+ : m_input_ports(std::move(input_ports)),+ m_output_ports(std::move(output_ports)) {}void MemoryAccess::ctor_initialize(const std::set<size_t>& input_ports, const std::set<size_t>& output_ports) {for (auto port : input_ports) {@@ -43,12 +52,14 @@ void MemoryAccess::ctor_initialize(const std::set<size_t>& input_ports, const stbool MemoryAccess::is_full_memory_access_op(const std::shared_ptr<ov::Node>& op) const {for (size_t i = 0; i < op->get_input_size(); ++i) {- if (!is_memory_access_input_port(i))+ if (!is_memory_access_input_port(i)) {return false;+ }}for (size_t i = 0; i < op->get_output_size(); ++i) {- if (!is_memory_access_output_port(i))+ if (!is_memory_access_output_port(i)) {return false;+ }}return true;}@@ -170,6 +181,4 @@ size_t MemoryAccess::get_output_stride(size_t idx) const {return get_output_port_descriptor(idx).stride;}-} // namespace modifier-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::modifierdiff --git a/src/common/snippets/src/op/nop.cpp b/src/common/snippets/src/op/nop.cppindex dd9f4270737..ff0fcbd1cc5 100644--- a/src/common/snippets/src/op/nop.cpp+++ b/src/common/snippets/src/op/nop.cpp@@ -4,6 +4,9 @@#include "snippets/op/nop.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/op/op.hpp"+ov::snippets::op::Nop::Nop(const OutputVector& arguments, const OutputVector& results): Op([arguments, results]() -> OutputVector {OutputVector x;diff --git a/src/common/snippets/src/op/perf_count.cpp b/src/common/snippets/src/op/perf_count.cppindex d2c25dff2af..e8040ac06b2 100644--- a/src/common/snippets/src/op/perf_count.cpp+++ b/src/common/snippets/src/op/perf_count.cpp@@ -1,14 +1,31 @@// Copyright (C) 2018-2025 Intel Corporation// SPDX-License-Identifier: Apache-2.0//+#include <chrono>+#include <cstdint>+#include <ios>+#include <iostream>+#include <memory>+#include <ostream>+#include <string>+#include <utility>+#include <vector>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"+#include "openvino/op/op.hpp"#ifdef SNIPPETS_DEBUG_CAPS-# include "snippets/op/perf_count.hpp"-# include <fstream>-namespace ov {-namespace snippets {+# include "snippets/op/perf_count.hpp"++namespace ov::snippets {//////////////////utils///////////////@@ -32,8 +49,9 @@ ConsoleDumper::~ConsoleDumper() {const auto iter = *iterator_iter;const auto acc = *iterator_acc;uint64_t avg = iter == 0 ? 0 : acc / iter;- if (avg > avg_max)+ if (avg > avg_max) {avg_max = avg;+ }}// max time of all threads: combine for reduce max@@ -43,9 +61,9 @@ ConsoleDumper::~ConsoleDumper() {// max accumulationuint64_t acc_max = m_accumulation.combine(BinaryFunc);- std::cout << "max accumulated time:" << acc_max << "ns" << std::endl;+ std::cout << "max accumulated time:" << acc_max << "ns" << '\n';// max avg- std::cout << "max avg time:" << avg_max << "ns" << std::endl;+ std::cout << "max avg time:" << avg_max << "ns" << '\n';}void ConsoleDumper::update(const op::PerfCountEnd* node) {@@ -63,7 +81,7 @@ void ConsoleDumper::update(const op::PerfCountEnd* node) {//////////////////utils::CSVDumper///////////////-CSVDumper::CSVDumper(const std::string csv_path) : csv_path(std::move(csv_path)) {}+CSVDumper::CSVDumper(std::string csv_path) : csv_path(std::move(csv_path)) {}CSVDumper::~CSVDumper() {if (m_debug_params_map.empty() || csv_path.empty()) {@@ -94,8 +112,9 @@ void CSVDumper::update(const op::PerfCountEnd* node) {const auto iter = *iterator_iter;const auto acc = *iterator_acc;uint64_t avg = iter == 0 ? 0 : acc / iter;- if (avg > avg_max)+ if (avg > avg_max) {avg_max = avg;+ }}// max time of all threads: combine for reduce max@@ -114,7 +133,7 @@ void CSVDumper::update(const op::PerfCountEnd* node) {namespace op {/////////////////PerfCountBeginBase/////////////////-PerfCountBeginBase::PerfCountBeginBase(const std::vector<Output<Node>>& args) : Op() {}+PerfCountBeginBase::PerfCountBeginBase([[maybe_unused]] const std::vector<Output<Node>>& args) {}void PerfCountBeginBase::validate_and_infer_types() {validate_and_infer_types_except_PerfCountEnd();@@ -126,10 +145,6 @@ void PerfCountBeginBase::validate_and_infer_types() {OPENVINO_ASSERT(pc_end != nullptr, "PerfCountBegin must have PerfCountEnd connected to its last output");}-bool PerfCountBeginBase::visit_attributes(AttributeVisitor& visitor) {- return true;-}-void PerfCountBeginBase::validate_and_infer_types_except_PerfCountEnd() {NODE_VALIDATION_CHECK(this, get_input_size() == 0, "PerfCountBegin doesn't expect any inputs");set_output_type(0, element::f32, {});@@ -147,16 +162,12 @@ void PerfCountEndBase::validate_and_infer_types() {set_output_type(0, element::f32, {});}-bool PerfCountEndBase::visit_attributes(AttributeVisitor& visitor) {- return true;-}-/////////////////PerfCountBegin/////////////////-PerfCountBegin::PerfCountBegin() : PerfCountBeginBase() {+PerfCountBegin::PerfCountBegin() {validate_and_infer_types_except_PerfCountEnd();}-std::shared_ptr<Node> PerfCountBegin::clone_with_new_inputs(const OutputVector& inputs) const {+std::shared_ptr<Node> PerfCountBegin::clone_with_new_inputs([[maybe_unused]] const OutputVector& inputs) const {return std::make_shared<PerfCountBegin>();}@@ -170,8 +181,6 @@ void PerfCountBegin::set_start_time() {//////////////////PerfCountEnd///////////////-PerfCountEnd::PerfCountEnd() : PerfCountEndBase() {}-PerfCountEnd::PerfCountEnd(const Output<Node>& pc_begin,std::vector<std::shared_ptr<utils::Dumper>> dumpers,const std::string& params)@@ -181,7 +190,7 @@ PerfCountEnd::PerfCountEnd(const Output<Node>& pc_begin,dumpers(std::move(dumpers)) {constructor_validate_and_infer_types();init_pc_begin();- for (const auto& dumper : dumpers) {+ for (const auto& dumper : this->dumpers) {dumper->init(params);}}@@ -209,6 +218,6 @@ void PerfCountEnd::init_pc_begin() {}} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets+#endif // SNIPPETS_DEBUG_CAPSdiff --git a/src/common/snippets/src/op/rank_normalization.cpp b/src/common/snippets/src/op/rank_normalization.cppindex d781bd458b7..a5a20dc672e 100644--- a/src/common/snippets/src/op/rank_normalization.cpp+++ b/src/common/snippets/src/op/rank_normalization.cpp@@ -4,11 +4,22 @@#include "snippets/op/rank_normalization.hpp"+#include <cstddef>+#include <memory>+#include <vector>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/dimension.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/type.hpp"+#include "snippets/op/shape_infer_op.hpp"+#include "snippets/shape_inference/shape_inference.hpp"+#include "snippets/shape_types.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {RankNormalization::RankNormalization(const Output<Node>& data, size_t num_prepend, size_t num_append): ShapeInferOp({data}),@@ -55,6 +66,4 @@ IShapeInferSnippets::Result RankNormalization::ShapeInfer::infer(const std::vectreturn {{out_shape}, ShapeInferStatus::success};}-} // namespace op-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/op/reduce.cpp b/src/common/snippets/src/op/reduce.cppindex 7388134dc22..8ba5cc9fd18 100644--- a/src/common/snippets/src/op/reduce.cpp+++ b/src/common/snippets/src/op/reduce.cpp@@ -4,13 +4,20 @@#include "snippets/op/reduce.hpp"+#include <cstddef>+#include <memory>+#include <vector>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/op/op.hpp"#include "snippets/itt.hpp"#include "snippets/lowered/port_descriptor.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {ReduceBase::ReduceBase(const Output<Node>& x, size_t axis) : Op({x}), m_axis(axis) {constructor_validate_and_infer_types();}@@ -33,8 +40,9 @@ void ReduceBase::compute_and_set_reduce_subtensors(const std::shared_ptr<ReduceBconst auto axis = reduce->get_axis();std::vector<size_t> subtensor(reduce_rank, 1);- for (size_t i = axis; i < reduce_rank; ++i)+ for (size_t i = axis; i < reduce_rank; ++i) {subtensor[i] = utils::get_full_dim_value();+ }lowered::PortDescriptorUtils::set_port_descriptor_ptr(reduce->input(0),std::make_shared<lowered::PortDescriptor>(reduce->input(0), subtensor));@@ -55,6 +63,4 @@ std::shared_ptr<Node> ReduceMax::clone_with_new_inputs(const OutputVector& new_areturn std::make_shared<ReduceMax>(new_args.at(0), m_axis);}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/op/reg_spill.cpp b/src/common/snippets/src/op/reg_spill.cppindex b380bb90314..af1e887c166 100644--- a/src/common/snippets/src/op/reg_spill.cpp+++ b/src/common/snippets/src/op/reg_spill.cpp@@ -4,11 +4,28 @@#include "snippets/op/reg_spill.hpp"-#include "snippets/utils/utils.hpp"--namespace ov {-namespace snippets {-namespace op {+#include <cassert>+#include <iterator>+#include <memory>+#include <set>+#include <sstream>+#include <string>+#include <utility>+#include <vector>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"+#include "openvino/op/op.hpp"+#include "snippets/emitter.hpp"+#include "snippets/shape_inference/shape_inference.hpp"+#include "snippets/shape_types.hpp"++namespace ov::snippets::op {RegSpillBase::RegSpillBase(const std::vector<Output<Node>>& args) : Op(args) {}@@ -17,8 +34,9 @@ bool RegSpillBase::visit_attributes(AttributeVisitor& visitor) {const auto& regs_to_spill = get_regs_to_spill();for (auto reg_it = regs_to_spill.begin(); reg_it != regs_to_spill.end(); reg_it++) {ss << *reg_it;- if (std::next(reg_it) != regs_to_spill.end())+ if (std::next(reg_it) != regs_to_spill.end()) {ss << ", ";+ }}std::string spilled = ss.str();visitor.on_attribute("regs_to_spill", spilled);@@ -63,7 +81,8 @@ RegSpillBegin::ShapeInfer::ShapeInfer(const std::shared_ptr<ov::Node>& n) {num_out_shapes = reg_spill_begin->get_regs_to_spill().size();}-RegSpillBegin::ShapeInfer::Result RegSpillBegin::ShapeInfer::infer(const std::vector<VectorDimsRef>& input_shapes) {+RegSpillBegin::ShapeInfer::Result RegSpillBegin::ShapeInfer::infer(+ [[maybe_unused]] const std::vector<VectorDimsRef>& input_shapes) {return {std::vector<VectorDims>(num_out_shapes, VectorDims{1}), ShapeInferStatus::success};}@@ -83,6 +102,4 @@ std::shared_ptr<Node> RegSpillEnd::clone_with_new_inputs(const OutputVector& inpreturn std::make_shared<RegSpillEnd>(inputs.at(0));}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/op/reorder.cpp b/src/common/snippets/src/op/reorder.cppindex c39549f3dca..dc5a5eeef92 100644--- a/src/common/snippets/src/op/reorder.cpp+++ b/src/common/snippets/src/op/reorder.cpp@@ -4,18 +4,29 @@#include "snippets/op/reorder.hpp"+#include <cstddef>+#include <memory>+#include <vector>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/type.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/port_descriptor.hpp"+#include "snippets/op/shape_infer_op.hpp"+#include "snippets/shape_inference/shape_inference.hpp"+#include "snippets/shape_types.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {-Reorder::Reorder(const Output<Node>& arg, std::vector<size_t> order) : ShapeInferOp({arg}) {- custom_constructor_validate_and_infer_types(std::move(order));+Reorder::Reorder(const Output<Node>& arg, const std::vector<size_t>& order) : ShapeInferOp({arg}) {+ custom_constructor_validate_and_infer_types(order);}-void Reorder::custom_constructor_validate_and_infer_types(std::vector<size_t> order) {+void Reorder::custom_constructor_validate_and_infer_types(const std::vector<size_t>& order) {INTERNAL_OP_SCOPE(Reorder_constructor_validate_and_infer_types);const auto& input_pshape = get_input_partial_shape(0);@@ -60,6 +71,4 @@ IShapeInferSnippets::Result Reorder::ShapeInfer::infer(const std::vector<VectorDreturn {{ov::snippets::utils::get_planar_vdims(input_shapes[0].get(), m_target_order)}, ShapeInferStatus::success};}-} // namespace op-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/op/reshape.cpp b/src/common/snippets/src/op/reshape.cppindex 1fdecdb0ae6..3bb5cef67d1 100644--- a/src/common/snippets/src/op/reshape.cpp+++ b/src/common/snippets/src/op/reshape.cpp@@ -4,12 +4,23 @@#include "snippets/op/reshape.hpp"+#include <memory>+#include <utility>+#include <vector>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/partial_shape.hpp"+#include "openvino/core/type.hpp"#include "snippets/itt.hpp"+#include "snippets/op/shape_infer_op.hpp"+#include "snippets/shape_inference/shape_inference.hpp"+#include "snippets/shape_types.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {Reshape::Reshape(const Output<Node>& arg, ov::PartialShape target_shape): ShapeInferOp({arg}),@@ -58,6 +69,4 @@ IShapeInferSnippets::Result Reshape::ShapeInfer::infer(const std::vector<VectorDreturn {{target_shape}, ShapeInferStatus::success};}-} // namespace op-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/op/scalar.cpp b/src/common/snippets/src/op/scalar.cppindex 16266a7b241..855ce51ae07 100644--- a/src/common/snippets/src/op/scalar.cpp+++ b/src/common/snippets/src/op/scalar.cpp@@ -4,9 +4,15 @@#include "snippets/op/scalar.hpp"-namespace ov {-namespace snippets {-namespace op {+#include <memory>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/op/constant.hpp"++namespace ov::snippets::op {std::shared_ptr<ov::Node> Scalar::clone_with_new_inputs(const OutputVector& new_args) const {check_new_args_count(this, new_args);@@ -35,6 +41,4 @@ bool Scalar::visit_attributes(AttributeVisitor& visitor) {return true;}-} // namespace op-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/op/serialization_node.cpp b/src/common/snippets/src/op/serialization_node.cppindex bef13704e7f..c88f6c895d2 100644--- a/src/common/snippets/src/op/serialization_node.cpp+++ b/src/common/snippets/src/op/serialization_node.cpp@@ -4,9 +4,19 @@#include "snippets/op/serialization_node.hpp"-namespace ov {-namespace snippets {-namespace op {+#include <cstddef>+#include <memory>+#include <string>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/type/element_type.hpp"+#include "openvino/op/op.hpp"+#include "snippets/lowered/expression.hpp"++namespace ov::snippets::op {SerializationNode::SerializationNode(const ov::OutputVector& args,const std::shared_ptr<lowered::Expression>& expr,@@ -29,8 +39,9 @@ void SerializationNode::validate_and_infer_types() {if (m_mode == SerializationMode::CONTROL_FLOW) {set_output_type(0, element::f32, {});} else if (m_mode == SerializationMode::DATA_FLOW) {- for (size_t i = 0; i < m_expr->get_output_count(); ++i)+ for (size_t i = 0; i < m_expr->get_output_count(); ++i) {set_output_type(i, element::f32, {});+ }}}@@ -43,6 +54,4 @@ bool SerializationNode::visit_attributes(AttributeVisitor& visitor) {return m_expr->visit_attributes(visitor);}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/op/store.cpp b/src/common/snippets/src/op/store.cppindex ea3256b1514..c9ad9b13919 100644--- a/src/common/snippets/src/op/store.cpp+++ b/src/common/snippets/src/op/store.cpp@@ -4,11 +4,19 @@#include "snippets/op/store.hpp"+#include <cstddef>+#include <memory>+#include <set>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/op/op.hpp"#include "snippets/itt.hpp"+#include "snippets/op/memory_access.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {snippets::op::Store::Store(const Output<Node>& x, const size_t count, const size_t offset): MemoryAccess(std::set<size_t>{}, std::set<size_t>{0}),@@ -21,7 +29,7 @@ void snippets::op::Store::validate_and_infer_types() {// Store has memory access port only on outputconst auto input_ma_ports = get_memory_access_input_ports();const auto output_ma_ports = get_memory_access_output_ports();- OPENVINO_ASSERT(input_ma_ports.size() == 0, "Store node mustn't have memory access input port");+ OPENVINO_ASSERT(input_ma_ports.empty(), "Store node mustn't have memory access input port");OPENVINO_ASSERT(output_ma_ports.size() == 1 && is_memory_access_output_port(0),"Store node must have memory access output port");set_output_type(0, get_input_element_type(0), get_input_partial_shape(0));@@ -35,6 +43,4 @@ std::shared_ptr<Node> snippets::op::Store::clone_with_new_inputs(const OutputVecbool snippets::op::Store::visit_attributes(AttributeVisitor& visitor) {return MemoryAccess::visit_attributes(visitor);}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/op/subgraph.cpp b/src/common/snippets/src/op/subgraph.cppindex 2c795d771a9..30bf9070b97 100644--- a/src/common/snippets/src/op/subgraph.cpp+++ b/src/common/snippets/src/op/subgraph.cpp@@ -5,12 +5,43 @@#include "snippets/op/subgraph.hpp"#include <algorithm>-#include <array>+#include <cassert>+#include <cstddef>+#include <functional>+#include <map>#include <memory>-+#include <ostream>+#include <utility>+#include <vector>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/model.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_input.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/rt_info.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"+#include "openvino/op/broadcast.hpp"+#include "openvino/op/fake_quantize.hpp"+#include "openvino/op/group_normalization.hpp"+#include "openvino/op/matmul.hpp"+#include "openvino/op/parameter.hpp"+#include "openvino/op/reshape.hpp"+#include "openvino/op/result.hpp"+#include "openvino/op/softmax.hpp"+#include "openvino/op/transpose.hpp"+#include "openvino/op/util/attr_types.hpp"+#include "openvino/op/util/binary_elementwise_arithmetic.hpp"+#include "openvino/op/util/sub_graph_base.hpp"+#include "openvino/opsets/opset1.hpp"#include "openvino/pass/constant_folding.hpp"-#include "ov_ops/type_relaxed.hpp"+#include "openvino/pass/pass_config.hpp"+#include "snippets/generator.hpp"#include "snippets/itt.hpp"+#include "snippets/lowered/expression.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/linear_ir_builder.hpp"#include "snippets/lowered/pass/allocate_buffers.hpp"@@ -33,6 +64,7 @@#include "snippets/lowered/pass/normalize_loop_ids.hpp"#include "snippets/lowered/pass/optimize_domain.hpp"#include "snippets/lowered/pass/optimize_loop_single_evaluation.hpp"+#include "snippets/lowered/pass/pass.hpp"#include "snippets/lowered/pass/pass_config.hpp"#include "snippets/lowered/pass/reduce_decomposition.hpp"#include "snippets/lowered/pass/set_dynamic_wa_to_outermost_loop.hpp"@@ -44,6 +76,8 @@#include "snippets/lowered/pass/validate_shapes.hpp"#include "snippets/lowered/pass/validate_unified_loops.hpp"#include "snippets/lowered/port_descriptor.hpp"+#include "snippets/op/reshape.hpp"+#include "snippets/op/shape_infer_op.hpp"#include "snippets/pass/align_element_types.hpp"#include "snippets/pass/broadcast_to_movebroadcast.hpp"#include "snippets/pass/canonicalization.hpp"@@ -59,15 +93,16 @@#include "snippets/pass/transpose_decomposition.hpp"#include "snippets/remarks.hpp"#include "snippets/runtime_configurator.hpp"+#include "snippets/shape_inference/shape_infer_instances.hpp"+#include "snippets/shape_inference/shape_inference.hpp"+#include "snippets/shape_types.hpp"+#include "snippets/utils/debug_caps_config.hpp"#include "snippets/utils/utils.hpp"-#include "transformations/utils/utils.hpp"using namespace std;using namespace ov::op::util;-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {void Subgraph::set_generator(std::shared_ptr<ov::snippets::Generator> generator) {m_generator = std::move(generator);@@ -149,10 +184,12 @@ auto Subgraph::get_estimated_buffer_count(const ov::NodeVector& ops) -> size_t {} else if (const auto matmul = ov::as_type_ptr<ov::op::v0::MatMul>(op)) {// Since all buffers around Matmul must be unique, we explicitely add values to the vector without any// checks- if (!ov::is_type<ov::op::v0::Parameter>(matmul->get_input_node_shared_ptr(0)))+ if (!ov::is_type<ov::op::v0::Parameter>(matmul->get_input_node_shared_ptr(0))) {used_precision_size.push_back(matmul->get_input_element_type(0).size());- if (!ov::is_type<ov::op::v0::Parameter>(matmul->get_input_node_shared_ptr(1)))+ }+ if (!ov::is_type<ov::op::v0::Parameter>(matmul->get_input_node_shared_ptr(1))) {used_precision_size.push_back(matmul->get_input_element_type(1).size());+ }const auto consumers = matmul->get_output_target_inputs(0);if (std::none_of(consumers.begin(), consumers.end(), [](const ov::Input<ov::Node>& in) {@@ -172,10 +209,12 @@ Subgraph::Subgraph(const OutputVector& args, const std::shared_ptr<ov::Model>& bSubGraphOp::set_function(body);init_config();constructor_validate_and_infer_types();- for (size_t i = 0; i < body->get_parameters().size(); ++i)+ for (size_t i = 0; i < body->get_parameters().size(); ++i) {m_input_descriptions[0].push_back(std::make_shared<InvariantInputDescription>(i, i));- for (size_t i = 0; i < body->get_output_size(); ++i)+ }+ for (size_t i = 0; i < body->get_output_size(); ++i) {m_output_descriptions[0].push_back(std::make_shared<BodyOutputDescription>(i, i));+ }m_transformations_allowed = false;m_shape_infer = std::make_shared<OVShapeInfer>(body);}@@ -314,12 +353,14 @@ IShapeInferSnippets::Result Subgraph::OVShapeInfer::infer(const std::vector<Vectconst ResultVector& results = m_ov_body->get_results();OPENVINO_ASSERT(parameters.size() == input_shapes.size(),"Got invalid number of input shapes to reshape subgraph body");- for (size_t i = 0; i < parameters.size(); ++i)+ for (size_t i = 0; i < parameters.size(); ++i) {parameters[i]->set_partial_shape(utils::vdims_to_pshape(input_shapes[i].get()));+ }m_ov_body->validate_nodes_and_infer_types();std::vector<VectorDims> outputDims;- for (const auto& res : results)+ for (const auto& res : results) {outputDims.emplace_back(utils::pshape_to_vdims(res->get_input_partial_shape(0)));+ }m_last_result = {outputDims, ShapeInferStatus::success};return m_last_result;}@@ -344,16 +385,18 @@ VectorDims Subgraph::infer_master_shape() {}}- if (output_dims.size() == 1)+ if (output_dims.size() == 1) {return output_dims.front();+ }const auto& default_broadcasting = std::make_shared<NumpyBroadcastShapeInfer>();// Note: we have to convert vector<VectorDims> to vector<reference_wrapper<const VectorDims>>// because of shape inference interfacestd::vector<std::reference_wrapper<const VectorDims>> inputs;inputs.reserve(output_dims.size());- for (const auto& d : output_dims)+ for (const auto& d : output_dims) {inputs.emplace_back(d);+ }return default_broadcasting->infer(inputs).dims.front();}@@ -381,7 +424,7 @@ std::shared_ptr<Subgraph> Subgraph::clone() const {ov::OutputVector subgraph_node_inputs;for (const auto& input : input_values()) {auto new_input = std::make_shared<ov::opset1::Parameter>(input.get_element_type(), input.get_partial_shape());- subgraph_node_inputs.push_back(new_input);+ subgraph_node_inputs.emplace_back(new_input);}std::shared_ptr<ov::Model> new_body = body_ptr()->clone();auto result = std::make_shared<snippets::op::Subgraph>(subgraph_node_inputs, new_body);@@ -389,13 +432,16 @@ std::shared_ptr<Subgraph> Subgraph::clone() const {// so we have to cast away constness to copy runtime infoov::copy_runtime_info(const_pointer_cast<Node>(shared_from_this()), result);result->set_friendly_name(get_friendly_name());- if (m_linear_ir)+ if (m_linear_ir) {result->m_linear_ir = lowered::LinearIRBuilder().clone(m_linear_ir);- if (m_shape_infer_linear_ir)+ }+ if (m_shape_infer_linear_ir) {result->m_shape_infer_linear_ir = lowered::LinearIRBuilder().clone(m_shape_infer_linear_ir);+ }// Note: we don't update shapeInfer here, since it's initialized in the constructor- if (m_generator)+ if (m_generator) {result->m_generator = m_generator->clone();+ }return result;}@@ -411,10 +457,12 @@ void Subgraph::data_flow_transformations(// If subgraph has its own specific canonicalization, which is different with common behavior, will skip the this// common one. for example in GN, scale and bias shape [c] are canonicalized to [1,c,1,1], not [1,1,1,c]. Common// canonicalization is disabled in this case.- if (blocked_input_shapes.empty() || config.m_has_broadcast_sensitive_ops)+ if (blocked_input_shapes.empty() || config.m_has_broadcast_sensitive_ops) {pass_config->disable<snippets::pass::Canonicalization>();- if (input_precisions.empty() || output_precisions.empty())+ }+ if (input_precisions.empty() || output_precisions.empty()) {pass_config->disable<snippets::pass::AlignElementTypes>();+ }ov::snippets::pass::Manager manager(pass_config, "SnippetsDataFlowManager");manager.register_pass<snippets::pass::Canonicalization>(blocked_input_shapes);@@ -591,27 +639,25 @@ const std::shared_ptr<RuntimeConfig>& Subgraph::update_runtime_config() const {void Subgraph::print() const {INTERNAL_OP_SCOPE(Subgraph);remark(13) << "subgraph " << this->get_friendly_name() << " " << this->get_type_name() << " which contains "- << body_ptr()->get_ops().size() << " nodes" << std::endl;+ << body_ptr()->get_ops().size() << " nodes" << '\n';int qqq = 0;for (const auto& op : body_ptr()->get_ordered_ops()) {remark(13) << "op " << qqq++ << " " << op->get_friendly_name() << " (" << op->get_type_name() << ") " << op- << std::endl;+ << '\n';}for (auto& in : this->inputs()) {remark(13) << " -> " << in.get_source_output().get_node_shared_ptr()->get_friendly_name() << " "- << in.get_source_output().get_node_shared_ptr() << std::endl;+ << in.get_source_output().get_node_shared_ptr() << '\n';}for (auto& out : this->outputs()) {- for (auto& user : out.get_target_inputs()) {- remark(13) << " <- " << user.get_node()->get_friendly_name() << " " << user.get_node() << std::endl;+ for (const auto& user : out.get_target_inputs()) {+ remark(13) << " <- " << user.get_node()->get_friendly_name() << " " << user.get_node() << '\n';}- remark(13) << std::endl;+ remark(13) << '\n';}}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/op/vector_buffer.cpp b/src/common/snippets/src/op/vector_buffer.cppindex 296ade7fab9..5724841b71a 100644--- a/src/common/snippets/src/op/vector_buffer.cpp+++ b/src/common/snippets/src/op/vector_buffer.cpp@@ -4,13 +4,17 @@#include "snippets/op/vector_buffer.hpp"+#include <memory>++#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/type/element_type.hpp"#include "snippets/itt.hpp"-namespace ov {-namespace snippets {-namespace op {+namespace ov::snippets::op {-VectorBuffer::VectorBuffer(const ov::element::Type element_type) : Op(), m_element_type(std::move(element_type)) {+VectorBuffer::VectorBuffer(const ov::element::Type element_type) : m_element_type(element_type) {constructor_validate_and_infer_types();}@@ -31,6 +35,4 @@ bool VectorBuffer::visit_attributes(AttributeVisitor& visitor) {return true;}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/pass/align_element_types.cpp b/src/common/snippets/src/pass/align_element_types.cppindex 79c6dba6431..b7f4932e2a8 100644--- a/src/common/snippets/src/pass/align_element_types.cpp+++ b/src/common/snippets/src/pass/align_element_types.cpp@@ -4,12 +4,26 @@#include "snippets/pass/align_element_types.hpp"+#include <algorithm>+#include <cstddef>+#include <memory>+#include <utility>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/model.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_input.hpp"+#include "openvino/core/rt_info.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"+#include "openvino/op/transpose.hpp"#include "snippets/itt.hpp"+#include "snippets/op/convert_saturation.hpp"#include "snippets/pass/propagate_precision.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {+namespace ov::snippets {pass::AlignElementTypes::AlignElementTypes(std::vector<ov::element::Type> input_precisions,std::vector<ov::element::Type> output_precisions)@@ -67,8 +81,9 @@ bool pass::AlignElementTypes::run_on_model(const std::shared_ptr<ov::Model>& m)consumer->set_argument(0, convert);consumer->validate_and_infer_types();- if (transpose)+ if (transpose) {results[i]->validate_and_infer_types();+ }is_modified = true;}}@@ -140,5 +155,4 @@ bool pass::AlignElementTypes::run_on_model(const std::shared_ptr<ov::Model>& m)return is_modified;}-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippetsdiff --git a/src/common/snippets/src/pass/analyze_broadcastable_inputs.cpp b/src/common/snippets/src/pass/analyze_broadcastable_inputs.cppindex cf71201cefa..19e45d8c33b 100644--- a/src/common/snippets/src/pass/analyze_broadcastable_inputs.cpp+++ b/src/common/snippets/src/pass/analyze_broadcastable_inputs.cpp@@ -4,13 +4,29 @@#include "snippets/pass/analyze_broadcastable_inputs.hpp"+#include <algorithm>+#include <cstddef>+#include <memory>+#include <set>+#include <stack>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/model.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_input.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/type.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/matmul.hpp"+#include "openvino/op/parameter.hpp"+#include "openvino/op/transpose.hpp"+#include "openvino/opsets/opset1.hpp"#include "snippets/itt.hpp"#include "snippets/lowered/pass/insert_broadcastmove.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {AnalyzeBroadcastableInputs::AnalyzeBroadcastableInputs(BroadcastableInputsMap& map) : m_broadcastable_inputs(map) {}@@ -31,14 +47,16 @@ bool pass::AnalyzeBroadcastableInputs::run_on_model(const std::shared_ptr<ov::Mo// Also MatMul has `transposed_b` which changes `processing_dim_idx`m_broadcastable_inputs.clear();// Currently Broadcasting can be changed only if there are several Parameters in body- if (body->get_parameters().size() < 2)+ if (body->get_parameters().size() < 2) {return false;+ }const auto& ops = body->get_ordered_ops();std::set<std::shared_ptr<ov::Node>> visited_ops = {};for (const auto& op : ops) {- if (!ov::snippets::lowered::pass::InsertBroadcastMove::is_broadcasting_supported(op))+ if (!ov::snippets::lowered::pass::InsertBroadcastMove::is_broadcasting_supported(op)) {continue;+ }size_t processing_dim_idx = 0;@@ -56,7 +74,7 @@ bool pass::AnalyzeBroadcastableInputs::run_on_model(const std::shared_ptr<ov::Moreturn ov::is_type<ov::op::v1::Transpose>(in.get_node());})) {OPENVINO_ASSERT(consumers.size() == 1, "Incorrect count of outputs of Parameter!");- const auto transpose = consumers.begin()->get_node();+ auto* const transpose = consumers.begin()->get_node();std::vector<size_t> order;const auto& constant =ov::as_type_ptr<const opset1::Constant>(transpose->get_input_node_shared_ptr(1));@@ -78,7 +96,8 @@ bool pass::AnalyzeBroadcastableInputs::run_on_model(const std::shared_ptr<ov::Mo}processing_dim_idx = 0;continue;- } else if (ov::is_type<ov::op::v0::Constant>(current_node)) {+ }+ if (ov::is_type<ov::op::v0::Constant>(current_node)) {visited_ops.insert(op);continue;}@@ -104,6 +123,4 @@ bool pass::AnalyzeBroadcastableInputs::run_on_model(const std::shared_ptr<ov::Moreturn true;}-} // namespace pass-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippets::passdiff --git a/src/common/snippets/src/pass/broadcast_to_movebroadcast.cpp b/src/common/snippets/src/pass/broadcast_to_movebroadcast.cppindex 4f49c347eb3..21d0d40ece6 100644--- a/src/common/snippets/src/pass/broadcast_to_movebroadcast.cpp+++ b/src/common/snippets/src/pass/broadcast_to_movebroadcast.cpp@@ -4,8 +4,17 @@#include "snippets/pass/broadcast_to_movebroadcast.hpp"+#include <memory>++#include "openvino/core/except.hpp"+#include "openvino/core/graph_util.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"#include "openvino/core/rt_info.hpp"-#include "openvino/opsets/opset1.hpp"+#include "openvino/core/type.hpp"+#include "openvino/op/broadcast.hpp"+#include "openvino/op/util/attr_types.hpp"+#include "openvino/pass/pattern/matcher.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"#include "snippets/itt.hpp"#include "snippets/op/broadcastmove.hpp"@@ -19,11 +28,13 @@ ov::snippets::pass::BroadcastToMoveBroadcast::BroadcastToMoveBroadcast() {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::op::BroadcastToMoveBroadcast")auto root = m.get_match_root();if (auto broadcast_v1 = ov::as_type_ptr<const ov::op::v1::Broadcast>(root)) {- if (broadcast_v1->get_broadcast_spec().m_type != ov::op::AutoBroadcastType::NUMPY)+ if (broadcast_v1->get_broadcast_spec().m_type != ov::op::AutoBroadcastType::NUMPY) {return false;+ }} else if (auto broadcast_v3 = ov::as_type_ptr<const ov::op::v3::Broadcast>(root)) {- if (broadcast_v3->get_broadcast_spec().m_type != ov::op::BroadcastType::NUMPY)+ if (broadcast_v3->get_broadcast_spec().m_type != ov::op::BroadcastType::NUMPY) {return false;+ }}const auto target_shape = root->get_output_partial_shape(0);diff --git a/src/common/snippets/src/pass/canonicalization.cpp b/src/common/snippets/src/pass/canonicalization.cppindex df459bb89f1..bbf3e258297 100644--- a/src/common/snippets/src/pass/canonicalization.cpp+++ b/src/common/snippets/src/pass/canonicalization.cpp@@ -4,13 +4,19 @@#include "snippets/pass/canonicalization.hpp"+#include <algorithm>+#include <cstddef>+#include <memory>+#include <set>++#include "openvino/core/except.hpp"+#include "openvino/core/model.hpp"+#include "openvino/op/parameter.hpp"#include "snippets/itt.hpp"-#include "snippets/lowered/port_descriptor.hpp"#include "snippets/op/rank_normalization.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {+namespace ov::snippets {pass::Canonicalization::Canonicalization(const BlockedShapeVector& blocked_input_shapes) {m_in_shapes.reserve(blocked_input_shapes.size());@@ -69,15 +75,16 @@ bool pass::Canonicalization::run_on_model(const std::shared_ptr<ov::Model>& m) {params[i]->set_partial_shape(snippets::utils::vdims_to_pshape(i_shape));is_modified = true;} else if (i_rank < max_rank) {- size_t num_append = base_is_blocked;+ auto num_append = static_cast<size_t>(base_is_blocked);OPENVINO_ASSERT(max_rank >= i_rank + num_append,"Unsupported blocked shapes combination in canonicalization");size_t num_prepend = max_rank - i_rank - num_append;const auto& out = params[i]->output(0);const auto& target_inputs = out.get_target_inputs();auto rank_norm = std::make_shared<op::RankNormalization>(out, num_prepend, num_append);- for (auto& in : target_inputs)+ for (const auto& in : target_inputs) {in.replace_source_output(rank_norm);+ }is_modified = true;} else {// todo: 4d blocked + 5d planar layouts are not supported: <N, C, H, W, c> + <N, C, D, H, W>@@ -89,5 +96,4 @@ bool pass::Canonicalization::run_on_model(const std::shared_ptr<ov::Model>& m) {return is_modified;}-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippetsdiff --git a/src/common/snippets/src/pass/collapse_subgraph.cpp b/src/common/snippets/src/pass/collapse_subgraph.cppindex aef075c00ac..6e19f384d9e 100644--- a/src/common/snippets/src/pass/collapse_subgraph.cpp+++ b/src/common/snippets/src/pass/collapse_subgraph.cpp@@ -4,17 +4,79 @@#include "snippets/pass/collapse_subgraph.hpp"+#include <algorithm>#include <cassert>#include <climits>+#include <cstdint>#include <memory>-#include <numeric>-#include <string>+#include <ostream>+#include <set>#include <vector>-#include "openvino/core/rt_info.hpp"+#include "openvino/core/descriptor/tensor.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_input.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"#include "openvino/core/validation_util.hpp"+#include "openvino/op/abs.hpp"+#include "openvino/op/add.hpp"+#include "openvino/op/broadcast.hpp"+#include "openvino/op/ceiling.hpp"+#include "openvino/op/clamp.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/convert.hpp"+#include "openvino/op/divide.hpp"+#include "openvino/op/elu.hpp"+#include "openvino/op/equal.hpp"+#include "openvino/op/erf.hpp"+#include "openvino/op/exp.hpp"+#include "openvino/op/floor.hpp"+#include "openvino/op/floor_mod.hpp"+#include "openvino/op/gelu.hpp"+#include "openvino/op/greater.hpp"+#include "openvino/op/greater_eq.hpp"+#include "openvino/op/hswish.hpp"+#include "openvino/op/less.hpp"+#include "openvino/op/less_eq.hpp"+#include "openvino/op/logical_and.hpp"+#include "openvino/op/logical_not.hpp"+#include "openvino/op/logical_or.hpp"+#include "openvino/op/logical_xor.hpp"+#include "openvino/op/loop.hpp"+#include "openvino/op/matmul.hpp"+#include "openvino/op/maximum.hpp"+#include "openvino/op/minimum.hpp"+#include "openvino/op/mish.hpp"+#include "openvino/op/mod.hpp"+#include "openvino/op/multiply.hpp"+#include "openvino/op/negative.hpp"+#include "openvino/op/not_equal.hpp"+#include "openvino/op/power.hpp"+#include "openvino/op/prelu.hpp"+#include "openvino/op/reduce_max.hpp"+#include "openvino/op/reduce_sum.hpp"+#include "openvino/op/relu.hpp"+#include "openvino/op/round.hpp"+#include "openvino/op/select.hpp"+#include "openvino/op/sigmoid.hpp"+#include "openvino/op/softmax.hpp"+#include "openvino/op/sqrt.hpp"+#include "openvino/op/squared_difference.hpp"+#include "openvino/op/subtract.hpp"+#include "openvino/op/swish.hpp"+#include "openvino/op/tanh.hpp"+#include "openvino/op/transpose.hpp"+#include "openvino/op/util/arithmetic_reductions_keep_dims.hpp"#include "openvino/op/util/attr_types.hpp"+#include "openvino/op/xor.hpp"#include "openvino/opsets/opset1.hpp"+#include "openvino/pass/matcher_pass.hpp"+#include "openvino/pass/pattern/matcher.hpp"+#include "openvino/pass/pattern/op/label.hpp"+#include "openvino/util/pp.hpp"#include "snippets/itt.hpp"#include "snippets/op/subgraph.hpp"#include "snippets/pass/fq_decomposition.hpp"@@ -23,12 +85,8 @@#include "snippets/pass/transpose_decomposition.hpp"#include "snippets/remarks.hpp"#include "snippets/utils/tokenization_utils.hpp"-#include "snippets/utils/utils.hpp"-#include "transformations/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {namespace {auto is_supported_op(const std::shared_ptr<const Node>& n) -> bool {@@ -36,8 +94,9 @@ auto is_supported_op(const std::shared_ptr<const Node>& n) -> bool {auto is_supported_matmul = [](const std::shared_ptr<const Node>& n) -> bool {const auto& matmul = ov::as_type_ptr<const opset1::MatMul>(n);const auto& out_rank = n->get_output_partial_shape(0).rank();- if (!matmul || out_rank.is_dynamic() || out_rank.get_length() != 4)+ if (!matmul || out_rank.is_dynamic() || out_rank.get_length() != 4) {return false;+ }const auto intype_0 = matmul->get_input_element_type(0);const auto intype_1 = matmul->get_input_element_type(1);const bool is_f32 = intype_0 == element::f32 && intype_1 == element::f32;@@ -130,8 +189,9 @@ auto is_supported_op(const std::shared_ptr<const Node>& n) -> bool {};auto is_supported_softmax = [](const std::shared_ptr<const Node>& n) -> bool {- if (n->get_input_size() != 1 || n->get_input_partial_shape(0).rank().is_dynamic())+ if (n->get_input_size() != 1 || n->get_input_partial_shape(0).rank().is_dynamic()) {return false;+ }int64_t axis = -1;const auto rank = n->get_input_partial_shape(0).rank();if (const auto softmax_v8 = ov::as_type_ptr<const ov::op::v8::Softmax>(n)) {@@ -150,7 +210,8 @@ auto is_supported_op(const std::shared_ptr<const Node>& n) -> bool {// Broadcast is supported only for MHA tokenization where there are needed and special checksif (auto broadcast_v1 = ov::as_type_ptr<const ov::op::v1::Broadcast>(n)) {return broadcast_v1->get_broadcast_spec().m_type == ov::op::AutoBroadcastType::NUMPY;- } else if (auto broadcast_v3 = ov::as_type_ptr<const ov::op::v3::Broadcast>(n)) {+ }+ if (auto broadcast_v3 = ov::as_type_ptr<const ov::op::v3::Broadcast>(n)) {return broadcast_v3->get_broadcast_spec().m_type == ov::op::BroadcastType::NUMPY;}return false;@@ -162,8 +223,9 @@ auto is_supported_op(const std::shared_ptr<const Node>& n) -> bool {const auto& axis_constant = ov::as_type_ptr<const ov::op::v0::Constant>(n->get_input_node_shared_ptr(1));const auto rank = n->get_input_partial_shape(0).rank();if (rank.is_dynamic() || !reduce_base->get_keep_dims() || !axis_constant ||- shape_size(axis_constant->get_shape()) != 1)+ shape_size(axis_constant->get_shape()) != 1) {return false;+ }const auto axis_value = axis_constant->cast_vector<int32_t>(1)[0];const auto normalized_axis = util::normalize(axis_value, rank.get_length());@@ -221,7 +283,7 @@ bool TokenizeSnippets::AppropriateForSubgraph(const std::shared_ptr<const Node>&TokenizeSnippets::TokenizeSnippets(const SnippetsTokenization::Config& config) {MATCHER_SCOPE(TokenizeSnippets);- auto label = ov::pass::pattern::any_input([](ov::Output<ov::Node> out) {+ auto label = ov::pass::pattern::any_input([](const ov::Output<ov::Node>& out) {const auto n = out.get_node_shared_ptr();// todo: MatMul and Transpose ops are always skipped by the SnippetsMarkSkipped pass.// This is a temporary solution. Either modify SnippetsMarkSkipped@@ -236,12 +298,10 @@ TokenizeSnippets::TokenizeSnippets(const SnippetsTokenization::Config& config) {if (transformation_callback(node)) {return false;}- remark(1) << "Match root: " << node->get_friendly_name() << " " << node << std::endl;+ remark(1) << "Match root: " << node->get_friendly_name() << " " << node << '\n';return ov::snippets::utils::tokenize_node(node, config);};auto matcher = std::make_shared<ov::pass::pattern::Matcher>(label, matcher_name);register_matcher(matcher, callback);}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/src/pass/common_optimizations.cpp b/src/common/snippets/src/pass/common_optimizations.cppindex cae092f63ad..b7540b34fe3 100644--- a/src/common/snippets/src/pass/common_optimizations.cpp+++ b/src/common/snippets/src/pass/common_optimizations.cpp@@ -4,6 +4,12 @@#include "snippets/pass/common_optimizations.hpp"+#include <memory>++#include "openvino/core/type.hpp"+#include "openvino/pass/manager.hpp"+#include "openvino/pass/matcher_pass.hpp"+#include "openvino/pass/pattern/matcher.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"#include "snippets/itt.hpp"#include "snippets/op/subgraph.hpp"@@ -11,18 +17,14 @@#include "snippets/pass/extract_constants.hpp"#include "snippets/pass/extract_unsupported_transposes.hpp"#include "snippets/pass/fq_decomposition.hpp"-#include "snippets/pass/fuse_transpose_brgemm.hpp"#include "snippets/pass/softmax_reshape_elimination.hpp"#include "snippets/pass/split_dimension_m.hpp"#include "snippets/pass/subgraph_manager.hpp"+#include "snippets/pass/tokenization.hpp"#include "snippets/pass/transform_convert.hpp"-#include "snippets/pass/transpose_decomposition.hpp"#include "snippets/pass/validate.hpp"-#include "transformations/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {#define REGISTER_SNIPPETS_PASS(manager, pass, enabled, ...) \if (enabled) \@@ -73,6 +75,4 @@ CommonOptimizations::CommonOptimizations(const SnippetsTokenization::Config& conthis->register_matcher(m, callback);}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/src/pass/convert_constants.cpp b/src/common/snippets/src/pass/convert_constants.cppindex 95c3e8f4435..87c85556004 100644--- a/src/common/snippets/src/pass/convert_constants.cpp+++ b/src/common/snippets/src/pass/convert_constants.cpp@@ -4,22 +4,32 @@#include "snippets/pass/convert_constants.hpp"+#include <memory>++#include "openvino/core/graph_util.hpp"+#include "openvino/core/node.hpp"#include "openvino/core/rt_info.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/core/type.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/pass/matcher_pass.hpp"+#include "openvino/pass/pattern/matcher.hpp"+#include "openvino/pass/pattern/op/label.hpp"#include "snippets/itt.hpp"#include "snippets/op/scalar.hpp"-#include "snippets/op/subgraph.hpp"ov::snippets::pass::ConvertConstantsToScalars::ConvertConstantsToScalars() {MATCHER_SCOPE(ConvertConstantsToScalars);- auto constants =- std::make_shared<ov::pass::pattern::op::Label>(ov::pass::pattern::any_input(), [](std::shared_ptr<Node> n) {- return ov::is_type<ov::op::v0::Constant>(n);- });+ auto constants = std::make_shared<ov::pass::pattern::op::Label>(ov::pass::pattern::any_input(),+ [](const std::shared_ptr<Node>& n) {+ return ov::is_type<ov::op::v0::Constant>(n);+ });ov::graph_rewrite_callback callback = [](ov::pass::pattern::Matcher& m) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::op::ConvertConstantsToScalars")auto constant = as_type_ptr<ov::op::v0::Constant>(m.get_match_root());- if (ov::shape_size(constant->get_output_shape(0)) != 1)+ if (ov::shape_size(constant->get_output_shape(0)) != 1) {return false;+ }// Note that all Constants {1,1,1,1} are converted to Scalar {1} here// This is needed to simplify shape inference, otherwise {1,1,1,1} Constants can increase output rank// Also some operations support only scalar shapes, so we need separate scalars and shape [1]diff --git a/src/common/snippets/src/pass/convert_power_to_powerstatic.cpp b/src/common/snippets/src/pass/convert_power_to_powerstatic.cppindex 4bffc9add19..be7d11fefb0 100644--- a/src/common/snippets/src/pass/convert_power_to_powerstatic.cpp+++ b/src/common/snippets/src/pass/convert_power_to_powerstatic.cpp@@ -4,14 +4,25 @@#include "snippets/pass/convert_power_to_powerstatic.hpp"+#include <memory>++#include "openvino/core/graph_util.hpp"+#include "openvino/core/node.hpp"#include "openvino/core/rt_info.hpp"+#include "openvino/core/type.hpp"+#include "openvino/op/power.hpp"+#include "openvino/pass/matcher_pass.hpp"+#include "openvino/pass/pattern/matcher.hpp"+#include "openvino/pass/pattern/op/label.hpp"#include "snippets/itt.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/op/powerstatic.hpp"+#include "snippets/op/scalar.hpp"ov::snippets::pass::ConvertPowerToPowerStatic::ConvertPowerToPowerStatic() {MATCHER_SCOPE(ConvertPowerToPowerStatic);- auto scalarPower =- std::make_shared<ov::pass::pattern::op::Label>(ov::pass::pattern::any_input(), [](std::shared_ptr<Node> n) {+ auto scalarPower = std::make_shared<ov::pass::pattern::op::Label>(+ ov::pass::pattern::any_input(),+ [](const std::shared_ptr<Node>& n) {return is_type<ov::op::v1::Power>(n) && is_type<snippets::op::Scalar>(n->get_input_node_shared_ptr(1));});ov::graph_rewrite_callback callback = [](ov::pass::pattern::Matcher& m) {diff --git a/src/common/snippets/src/pass/explicit_transpose_matmul_inputs.cpp b/src/common/snippets/src/pass/explicit_transpose_matmul_inputs.cppindex 7a551655041..d261573fd97 100644--- a/src/common/snippets/src/pass/explicit_transpose_matmul_inputs.cpp+++ b/src/common/snippets/src/pass/explicit_transpose_matmul_inputs.cpp@@ -4,11 +4,30 @@#include "snippets/pass/explicit_transpose_matmul_inputs.hpp"+#include <algorithm>+#include <cstddef>+#include <cstdint>+#include <memory>+#include <numeric>+#include <utility>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_input.hpp"#include "openvino/core/rt_info.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/matmul.hpp"+#include "openvino/op/parameter.hpp"+#include "openvino/op/transpose.hpp"+#include "openvino/opsets/opset1.hpp"#include "openvino/pass/pattern/matcher.hpp"-#include "openvino/pass/pattern/op/wrap_type.hpp"+#include "openvino/pass/pattern/op/label.hpp"+#include "openvino/util/pp.hpp"#include "snippets/itt.hpp"-#include "snippets/op/subgraph.hpp"bool ov::snippets::pass::ExplicitTransposeMatMulInputs::are_weights_scalar(const std::shared_ptr<ov::Node>& node) {const auto inputs = node->inputs();@@ -23,8 +42,9 @@ void ov::snippets::pass::ExplicitTransposeMatMulInputs::extract(const ov::Input<while (!transpose && !ov::is_type<ov::op::v0::Parameter>(parent)) {// We can set supported order and transposed_<a|b>=false only if ops have scalar shapes to avoid shape// mismatching- if (!are_weights_scalar(parent))+ if (!are_weights_scalar(parent)) {break;+ }parent = parent->get_input_node_shared_ptr(0);transpose = ov::as_type_ptr<ov::op::v1::Transpose>(parent);@@ -86,8 +106,9 @@ ov::snippets::pass::ExplicitTransposeMatMulInputs::ExplicitTransposeMatMulInputsbool rewritten = false;auto matmul = ov::as_type_ptr<ov::op::v0::MatMul>(root);- if (!matmul)+ if (!matmul) {return false;+ }if (matmul->get_transpose_a()) {extract(matmul->input(0));diff --git a/src/common/snippets/src/pass/extract_constants.cpp b/src/common/snippets/src/pass/extract_constants.cppindex 3e3e9ae0f6a..131c272be42 100644--- a/src/common/snippets/src/pass/extract_constants.cpp+++ b/src/common/snippets/src/pass/extract_constants.cpp@@ -4,8 +4,16 @@#include "snippets/pass/extract_constants.hpp"-#include "openvino/opsets/opset1.hpp"+#include <memory>++#include "openvino/core/graph_util.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/core/type.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/parameter.hpp"#include "snippets/itt.hpp"+#include "snippets/op/subgraph.hpp"bool ov::snippets::pass::ExtractConstants::run_on_subgraph(const std::shared_ptr<op::Subgraph>& subgraph) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::ExtractConstants");@@ -16,21 +24,23 @@ bool ov::snippets::pass::ExtractConstants::run_on_subgraph(const std::shared_ptrfor (auto& op : body->get_ops()) {auto constant = ov::as_type_ptr<ov::op::v0::Constant>(op);- if (!constant || ov::shape_size(constant->get_shape()) == 1ul)+ if (!constant || ov::shape_size(constant->get_shape()) == 1ul) {continue;+ }const auto child = constant->get_output_target_inputs(0).begin()->get_node()->shared_from_this();- if (ov::snippets::op::Subgraph::constant_input_should_be_inside_body(child))+ if (ov::snippets::op::Subgraph::constant_input_should_be_inside_body(child)) {continue;+ }auto parameter = std::make_shared<ov::op::v0::Parameter>(constant->get_element_type(), constant->get_shape());ov::replace_output_update_name(constant->output(0), parameter->output(0));- new_external_inputs.push_back(constant);+ new_external_inputs.emplace_back(constant);new_parameters.push_back(parameter);}- if (new_parameters.size() != 0) {+ if (!new_parameters.empty()) {body->add_parameters(new_parameters);body->validate_nodes_and_infer_types();subgraph->set_arguments(new_external_inputs);diff --git a/src/common/snippets/src/pass/extract_reshapes_from_mha.cpp b/src/common/snippets/src/pass/extract_reshapes_from_mha.cppindex 3c21f92efbb..e10f050b925 100644--- a/src/common/snippets/src/pass/extract_reshapes_from_mha.cpp+++ b/src/common/snippets/src/pass/extract_reshapes_from_mha.cpp@@ -4,15 +4,31 @@#include "snippets/pass/extract_reshapes_from_mha.hpp"+#include <algorithm>+#include <memory>#include <openvino/opsets/opset1.hpp>+#include "openvino/core/except.hpp"+#include "openvino/core/graph_util.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"#include "openvino/core/rt_info.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"#include "openvino/core/validation_util.hpp"+#include "openvino/op/util/attr_types.hpp"+#include "openvino/op/util/binary_elementwise_arithmetic.hpp"+#include "openvino/pass/matcher_pass.hpp"+#include "openvino/pass/pattern/matcher.hpp"+#include "openvino/pass/pattern/op/label.hpp"#include "openvino/pass/pattern/op/optional.hpp"+#include "openvino/pass/pattern/op/pattern.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"+#include "openvino/util/pp.hpp"#include "snippets/itt.hpp"#include "snippets/pass/mha_tokenization.hpp"-#include "transformations/utils/utils.hpp"using namespace ov::pass;@@ -37,27 +53,31 @@ ov::snippets::pass::ExtractPairsAfterMatmul::ExtractPairsAfterMatmul() {const auto& matmul = pattern_map.at(matmul_m);const auto matmul_node = ov::as_type_ptr<opset1::MatMul>(matmul.get_node_shared_ptr());if (!ov::snippets::pass::TokenizeMHASnippets::is_matmul0_supported(matmul_node) ||- transformation_callback(matmul_node))+ transformation_callback(matmul_node)) {return false;+ }const auto& reshape_2 = pattern_map.at(reshape_2_m);const auto& matmul_shape = matmul.get_shape();const auto& output_shape = reshape_2.get_shape();- if (matmul_shape != output_shape)+ if (matmul_shape != output_shape) {return false;+ }const auto add_1 = pattern_map.at(add_1_m).get_node_shared_ptr();const auto add_2 = pattern_map.at(add_2_m).get_node_shared_ptr();const auto& bcast_type = add_1->get_autob();- if (bcast_type != ov::op::AutoBroadcastType::NUMPY || bcast_type != add_2->get_autob())+ if (bcast_type != ov::op::AutoBroadcastType::NUMPY || bcast_type != add_2->get_autob()) {return false;+ }const auto& sparse_input_1 = pattern_map.at(sparse_input_1_m);const auto& sparse_input_2 = pattern_map.at(sparse_input_2_m);auto broadcasted_shape = sparse_input_1.get_partial_shape();ov::PartialShape::broadcast_merge_into(broadcasted_shape, sparse_input_2.get_partial_shape(), bcast_type);- if (ov::shape_size(matmul_shape) != ov::shape_size(broadcasted_shape.to_shape()))+ if (ov::shape_size(matmul_shape) != ov::shape_size(broadcasted_shape.to_shape())) {return false;+ }const auto extracted_add = std::make_shared<ov::opset1::Add>(sparse_input_1, sparse_input_2);const auto target_shape = ov::opset1::Constant::create(ov::element::i32, {matmul_shape.size()}, matmul_shape);@@ -83,7 +103,7 @@ ov::snippets::pass::RankUpgradeToRankReduction::RankUpgradeToRankReduction() {return false;}auto out_shape = out.get_shape();- if (out_shape.size() < 1 || out_shape[0] != 1) {+ if (out_shape.empty() || out_shape[0] != 1) {return false;}out_shape.erase(out_shape.begin());@@ -100,7 +120,7 @@ ov::snippets::pass::RankUpgradeToRankReduction::RankUpgradeToRankReduction() {return false;}const auto& out_shape = out.get_shape();- return ((out_shape.size() > 0) && (out_shape[0] == 1));+ return (!out_shape.empty() && out_shape[0] == 1);};// reshape_2_m delete leading dimension of 1.auto rank_reduction_reshape = [&](const ov::Output<ov::Node>& out) {@@ -112,7 +132,7 @@ ov::snippets::pass::RankUpgradeToRankReduction::RankUpgradeToRankReduction() {return false;}auto in_shape = in_shape_partial.to_shape();- if (in_shape.size() < 1 || in_shape[0] != 1) {+ if (in_shape.empty() || in_shape[0] != 1) {return false;}in_shape.erase(in_shape.begin());@@ -138,11 +158,12 @@ ov::snippets::pass::RankUpgradeToRankReduction::RankUpgradeToRankReduction() {const auto& matmul = pattern_map.at(matmul_m);const auto matmul_node = ov::as_type_ptr<opset1::MatMul>(matmul.get_node_shared_ptr());if (!ov::snippets::pass::TokenizeMHASnippets::is_matmul0_supported(matmul_node) ||- transformation_callback(matmul_node))+ transformation_callback(matmul_node)) {return false;+ }const auto& eltwise_2 = pattern_map.at(eltwise_2_m).get_node_shared_ptr();const auto& shapes = ov::util::get_node_input_partial_shapes(*eltwise_2);- OPENVINO_ASSERT(shapes.size() > 0, "Eltwise node should has at least one input.");+ OPENVINO_ASSERT(!shapes.empty(), "Eltwise node should has at least one input.");auto equal_rank = [&](const PartialShape& p) {return p.size() == shapes[0].size();};diff --git a/src/common/snippets/src/pass/extract_unsupported_transposes.cpp b/src/common/snippets/src/pass/extract_unsupported_transposes.cppindex b298d31f2fe..efbada5d23a 100644--- a/src/common/snippets/src/pass/extract_unsupported_transposes.cpp+++ b/src/common/snippets/src/pass/extract_unsupported_transposes.cpp@@ -4,8 +4,14 @@#include "snippets/pass/extract_unsupported_transposes.hpp"+#include <cstddef>+#include <memory>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"#include "openvino/opsets/opset1.hpp"#include "snippets/itt.hpp"+#include "snippets/op/subgraph.hpp"#include "snippets/pass/mha_tokenization.hpp"bool ov::snippets::pass::ExtractUnsupportedTransposes::run_on_subgraph(const std::shared_ptr<op::Subgraph>& subgraph) {@@ -22,12 +28,14 @@ bool ov::snippets::pass::ExtractUnsupportedTransposes::run_on_subgraph(const stdfor (size_t i = 0; i < parameters.size(); ++i) {const auto& parameter = parameters[i];const auto& consumers = parameter->get_output_target_inputs(0);- if (consumers.size() != 1)+ if (consumers.size() != 1) {continue;+ }const auto transpose = ov::as_type_ptr<opset1::Transpose>(consumers.begin()->get_node()->shared_from_this());- if (!transpose)+ if (!transpose) {continue;+ }const auto& order = ov::as_type_ptr<opset1::Constant>(transpose->get_input_node_shared_ptr(1));OPENVINO_ASSERT(order, "ExtractUnsupportedTransposes expects Transposes with constant order");@@ -39,8 +47,9 @@ bool ov::snippets::pass::ExtractUnsupportedTransposes::run_on_subgraph(const std// [116568]: It should be covered by TransposeDecomposition::is_supported or FuseTransposeBrgemm::is_supportedif (order_value.size() > 2 &&((is_brgemm_case && TokenizeMHASnippets::get_fusion_transpose_order(order_value.size()) == order_value) ||- (TokenizeMHASnippets::get_decomposed_transpose_order(order_value.size()) == order_value)))+ (TokenizeMHASnippets::get_decomposed_transpose_order(order_value.size()) == order_value))) {continue;+ }// If the transpose isn't supported - we have to extract it from Subgraphtranspose->set_argument(0, subgraph->input_value(i));diff --git a/src/common/snippets/src/pass/fc_tokenization.cpp b/src/common/snippets/src/pass/fc_tokenization.cppindex a0c6f41a4c2..d2ee9a68b58 100644--- a/src/common/snippets/src/pass/fc_tokenization.cpp+++ b/src/common/snippets/src/pass/fc_tokenization.cpp@@ -4,8 +4,16 @@#include "snippets/pass/fc_tokenization.hpp"+#include <memory>++#include "openvino/op/constant.hpp"+#include "openvino/opsets/opset1.hpp"+#include "openvino/pass/pattern/matcher.hpp"+#include "openvino/pass/pattern/op/label.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"+#include "openvino/util/pp.hpp"#include "snippets/itt.hpp"+#include "snippets/pass/tokenization.hpp"#include "snippets/utils/tokenization_utils.hpp"ov::snippets::pass::TokenizeFCSnippets::TokenizeFCSnippets(const SnippetsTokenization::Config& config) {diff --git a/src/common/snippets/src/pass/fq_decomposition.cpp b/src/common/snippets/src/pass/fq_decomposition.cppindex eb87baab88e..bfc66ca1465 100644--- a/src/common/snippets/src/pass/fq_decomposition.cpp+++ b/src/common/snippets/src/pass/fq_decomposition.cpp@@ -4,20 +4,48 @@#include "snippets/pass/fq_decomposition.hpp"+#include <algorithm>+#include <cstddef>+#include <cstdlib>+#include <memory>#include <numeric>-+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/graph_util.hpp"+#include "openvino/core/model.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/partial_shape.hpp"#include "openvino/core/rt_info.hpp"-#include "openvino/opsets/opset1.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"+#include "openvino/op/add.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/divide.hpp"+#include "openvino/op/fake_quantize.hpp"+#include "openvino/op/greater.hpp"+#include "openvino/op/maximum.hpp"+#include "openvino/op/minimum.hpp"+#include "openvino/op/multiply.hpp"+#include "openvino/op/round.hpp"+#include "openvino/op/subtract.hpp"+#include "openvino/op/util/attr_types.hpp"#include "openvino/pass/constant_folding.hpp"#include "openvino/pass/manager.hpp"+#include "openvino/pass/matcher_pass.hpp"+#include "openvino/pass/pattern/matcher.hpp"+#include "openvino/pass/pattern/op/label.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"#include "openvino/pass/validate.hpp"#include "openvino/reference/autobroadcast_binop.hpp"#include "openvino/reference/broadcast.hpp"+#include "openvino/util/pp.hpp"#include "snippets/itt.hpp"#include "snippets/op/convert_saturation.hpp"#include "snippets/utils/utils.hpp"-#include "transformations/utils/utils.hpp"ov::snippets::pass::FakeQuantizeDecomposition::FakeQuantizeDecomposition() {MATCHER_SCOPE(FakeQuantizeDecomposition);@@ -67,7 +95,7 @@ ov::snippets::pass::FakeQuantizeDecomposition::FakeQuantizeDecomposition() {[](float val) {return val == 0.f;})) ||- out_scales.size() != 0));+ !out_scales.empty()));const bool do_rounding = do_dequantize || fake_quantize_node->get_output_element_type(0) == ov::element::f32 ||fake_quantize_node->get_output_element_type(0) == ov::element::f16;@@ -86,7 +114,7 @@ ov::snippets::pass::FakeQuantizeDecomposition::FakeQuantizeDecomposition() {decomp_ops.push_back(min);std::shared_ptr<ov::Node> result = nullptr;- if (out_scales.size() != 0) {+ if (!out_scales.empty()) {PartialShape scale_shape = input_low.get_partial_shape();ov::PartialShape::broadcast_merge_into(scale_shape, input_high.get_partial_shape(), broadcast_type);const auto scales = std::make_shared<ov::op::v0::Constant>(input_low.get_element_type(),@@ -176,8 +204,9 @@ bool ov::snippets::pass::FakeQuantizeDecomposition::getScalesAndShifts(auto input_high_constant = ov::as_type_ptr<ov::op::v0::Constant>(fq_node->get_input_node_shared_ptr(2));auto output_low_constant = ov::as_type_ptr<ov::op::v0::Constant>(fq_node->get_input_node_shared_ptr(3));auto output_high_constant = ov::as_type_ptr<ov::op::v0::Constant>(fq_node->get_input_node_shared_ptr(4));- if (!input_low_constant || !input_high_constant || !output_low_constant || !output_high_constant)+ if (!input_low_constant || !input_high_constant || !output_low_constant || !output_high_constant) {return false;+ }const auto input_low_shape = input_low_constant->get_shape();const auto input_high_shape = input_high_constant->get_shape();@@ -369,8 +398,9 @@ bool ov::snippets::pass::CommonFakeQuantizeDecomposition::is_supported_fq(const auto greater_equal = std::make_shared<ov::op::v1::Greater>(il, ih);ov::OutputVector result(1);- if (!greater_equal->constant_fold(result, greater_equal->input_values()))+ if (!greater_equal->constant_fold(result, greater_equal->input_values())) {return false;+ }const auto res_node = ov::as_type_ptr<const ov::op::v0::Constant>(result[0].get_node_shared_ptr());const auto comp_result = res_node->cast_vector<bool>();@@ -386,13 +416,13 @@ bool ov::snippets::pass::CommonFakeQuantizeDecomposition::is_supported_fq(is_valid_range_values(fq);}-bool ov::snippets::pass::CommonFakeQuantizeDecomposition::run_on_model(const std::shared_ptr<ov::Model>& f) {+bool ov::snippets::pass::CommonFakeQuantizeDecomposition::run_on_model(const std::shared_ptr<ov::Model>& m) {RUN_ON_FUNCTION_SCOPE(CommonFakeQuantizeDecomposition);ov::pass::Manager manager("Snippets:CommonFakeQuantizeDecomposition");manager.set_per_pass_validation(false);manager.register_pass<ov::snippets::pass::FakeQuantizeDecomposition>();manager.register_pass<ov::pass::ConstantFolding>();manager.register_pass<ov::pass::Validate>();- manager.run_passes(f);+ manager.run_passes(m);return false;}diff --git a/src/common/snippets/src/pass/fuse_transpose_brgemm.cpp b/src/common/snippets/src/pass/fuse_transpose_brgemm.cppindex d1dc00246f6..9d4b1754015 100644--- a/src/common/snippets/src/pass/fuse_transpose_brgemm.cpp+++ b/src/common/snippets/src/pass/fuse_transpose_brgemm.cpp@@ -4,30 +4,44 @@#include "snippets/pass/fuse_transpose_brgemm.hpp"-#include "openvino/core/rt_info.hpp"+#include <cstddef>+#include <cstdint>+#include <memory>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/type.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/transpose.hpp"+#include "openvino/opsets/opset1.hpp"+#include "openvino/pass/pattern/matcher.hpp"+#include "openvino/pass/pattern/op/label.hpp"#include "openvino/pass/pattern/op/or.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"#include "snippets/itt.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/lowered/port_descriptor.hpp"+#include "snippets/op/brgemm.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {bool FuseTransposeBrgemm::is_supported_transpose(const Output<Node>& transpose_out) {const auto transpose = ov::as_type_ptr<const ov::opset1::Transpose>(transpose_out.get_node_shared_ptr());- if (!transpose)+ if (!transpose) {return false;+ }const auto order = ov::as_type_ptr<const ov::opset1::Constant>(transpose->get_input_node_shared_ptr(1));- if (!order)+ if (!order) {return false;+ }return is_supported_transpose_order(order->cast_vector<int32_t>());}bool FuseTransposeBrgemm::is_supported_transpose_order(const std::vector<int32_t>& order) {const auto size = order.size();- return order.size() > 0 && order.back() == (static_cast<int32_t>(size) - 1);+ return !order.empty() && order.back() == (static_cast<int32_t>(size) - 1);}FuseTransposeBrgemm::FuseTransposeBrgemm() {@@ -56,10 +70,12 @@ FuseTransposeBrgemm::FuseTransposeBrgemm() {auto brgemm = ov::as_type_ptr<op::Brgemm>(m.get_match_root());auto fuse_layouts = [](const std::vector<size_t>& layout_1, const std::vector<size_t>& layout_2) {- if (layout_1.empty())+ if (layout_1.empty()) {return layout_2;- if (layout_2.empty())+ }+ if (layout_2.empty()) {return layout_1;+ }OPENVINO_ASSERT(layout_1.size() == layout_2.size(), "Fused layouts must have equal ranks");std::vector<size_t> fused_layout(layout_1.size());for (size_t i = 0; i < layout_1.size(); ++i) {@@ -81,8 +97,9 @@ FuseTransposeBrgemm::FuseTransposeBrgemm() {const auto& out_layout = original_port->get_layout();const auto& transpose_order = const_order->cast_vector<size_t>();original_port->set_layout(fuse_layouts(out_layout, transpose_order));- for (const auto& in : transpose_out.get_target_inputs())+ for (const auto& in : transpose_out.get_target_inputs()) {in.replace_source_output(brgemm->output(0));+ }}for (size_t i = 0; i < brgemm->get_input_size(); i++) {@@ -110,6 +127,4 @@ FuseTransposeBrgemm::FuseTransposeBrgemm() {register_matcher(std::make_shared<ov::pass::pattern::Matcher>(m_brgemm_or_transpose, matcher_name), callback);}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/src/pass/gated_mlp_tokenization.cpp b/src/common/snippets/src/pass/gated_mlp_tokenization.cppindex b3388c9cafa..be066d6c9f1 100644--- a/src/common/snippets/src/pass/gated_mlp_tokenization.cpp+++ b/src/common/snippets/src/pass/gated_mlp_tokenization.cpp@@ -4,21 +4,35 @@#include "snippets/pass/gated_mlp_tokenization.hpp"-#include "openvino/core/rt_info.hpp"-#include "openvino/core/validation_util.hpp"+#include <memory>++#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/hard_sigmoid.hpp"+#include "openvino/op/matmul.hpp"+#include "openvino/op/prelu.hpp"+#include "openvino/op/swish.hpp"+#include "openvino/op/util/binary_elementwise_arithmetic.hpp"+#include "openvino/op/util/unary_elementwise_arithmetic.hpp"+#include "openvino/opsets/opset1.hpp"+#include "openvino/pass/pattern/matcher.hpp"+#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/predicate.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"+#include "openvino/util/pp.hpp"#include "snippets/itt.hpp"#include "snippets/op/brgemm.hpp"-#include "snippets/op/subgraph.hpp"#include "snippets/pass/collapse_subgraph.hpp"+#include "snippets/pass/tokenization.hpp"#include "snippets/utils/tokenization_utils.hpp"#include "snippets/utils/utils.hpp"-#include "transformations/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {using namespace ov::pass::pattern;@@ -112,6 +126,4 @@ TokenizeGatedMLPSnippets::TokenizeGatedMLPSnippets(const SnippetsTokenization::C});}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/src/pass/gn_decomposition.cpp b/src/common/snippets/src/pass/gn_decomposition.cppindex dacf3b315b8..46b2a09408d 100644--- a/src/common/snippets/src/pass/gn_decomposition.cpp+++ b/src/common/snippets/src/pass/gn_decomposition.cpp@@ -4,16 +4,32 @@#include "snippets/pass/gn_decomposition.hpp"-#include "openvino/core/rt_info.hpp"+#include <cstddef>+#include <memory>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/graph_util.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"+#include "openvino/op/add.hpp"+#include "openvino/op/constant.hpp"#include "openvino/op/group_normalization.hpp"+#include "openvino/op/multiply.hpp"+#include "openvino/op/power.hpp"+#include "openvino/op/sqrt.hpp"+#include "openvino/op/subtract.hpp"+#include "openvino/pass/matcher_pass.hpp"+#include "openvino/pass/pattern/matcher.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"#include "snippets/itt.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/op/convert_saturation.hpp"+#include "snippets/op/powerstatic.hpp"+#include "snippets/op/reduce.hpp"+#include "snippets/op/reshape.hpp"-namespace ov {-namespace snippets {-namespace pass {-using namespace lowered;+namespace ov::snippets::pass {// groupNorm -> reshape + mvn + reshape + mul + add,// where mvn = (x - mean) / Sqrt(ReduceMean((x - mean) ^ 2) + eps),@@ -33,7 +49,7 @@ GNDecomposition::GNDecomposition() {const auto bias = group_norm_node->input_value(2);const auto num_groups = static_cast<size_t>(group_norm_node->get_num_groups());- const float eps = static_cast<float>(group_norm_node->get_epsilon());+ const auto eps = static_cast<float>(group_norm_node->get_epsilon());////////////collapse to reduce lastDim to avoid nested loop overhead(e.g. reduce tails in inner loop)///////////// reshape [N, C, spatial] to [N, group, 1, (C / group) * spatial]@@ -123,6 +139,4 @@ GNDecomposition::GNDecomposition() {register_matcher(m, callback);}-} // namespace pass-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippets::passdiff --git a/src/common/snippets/src/pass/gn_tokenization.cpp b/src/common/snippets/src/pass/gn_tokenization.cppindex 75352e9d3a4..810fb2fc27c 100644--- a/src/common/snippets/src/pass/gn_tokenization.cpp+++ b/src/common/snippets/src/pass/gn_tokenization.cpp@@ -4,12 +4,18 @@#include "snippets/pass/gn_tokenization.hpp"-#include "openvino/core/rt_info.hpp"+#include <memory>++#include "openvino/core/graph_util.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"+#include "openvino/op/group_normalization.hpp"+#include "openvino/pass/matcher_pass.hpp"+#include "openvino/pass/pattern/matcher.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"#include "snippets/itt.hpp"#include "snippets/op/subgraph.hpp"-#include "snippets/pass/collapse_subgraph.hpp"-#include "snippets/utils/utils.hpp"+#include "snippets/pass/tokenization.hpp"ov::snippets::pass::TokenizeGNSnippets::TokenizeGNSnippets() {MATCHER_SCOPE(TokenizeGNSnippets);@@ -20,8 +26,9 @@ ov::snippets::pass::TokenizeGNSnippets::TokenizeGNSnippets() {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::pass::TokenizeGNSnippets")auto group_norm_node = ov::as_type_ptr<ov::op::v12::GroupNormalization>(m.get_match_root());if (group_norm_node->is_dynamic() || group_norm_node->get_element_type() != element::f32 ||- GetSnippetsNodeType(group_norm_node) == SnippetsNodeType::SkippedByPlugin)+ GetSnippetsNodeType(group_norm_node) == SnippetsNodeType::SkippedByPlugin) {return false;+ }auto subgraph = op::Subgraph::wrap_node_as_subgraph(group_norm_node);subgraph->get_rt_info()["originalLayersNames"] = group_norm_node->get_friendly_name();diff --git a/src/common/snippets/src/pass/hash.cpp b/src/common/snippets/src/pass/hash.cppindex 9a2d7745b7c..0fda88850cc 100644--- a/src/common/snippets/src/pass/hash.cpp+++ b/src/common/snippets/src/pass/hash.cpp@@ -4,23 +4,38 @@#include "snippets/pass/hash.hpp"+#include <algorithm>#include <array>#include <cassert>#include <cstdint>+#include <functional>+#include <memory>+#include <set>+#include <sstream>+#include <string>+#include <type_traits>#include <unordered_map>#include <unordered_set>+#include <vector>+#include "openvino/core/any.hpp"+#include "openvino/core/attribute_adapter.hpp"+#include "openvino/core/attribute_visitor.hpp"+#include "openvino/core/dimension.hpp"#include "openvino/core/except.hpp"#include "openvino/core/meta_data.hpp"#include "openvino/core/model.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/partial_shape.hpp"+#include "openvino/core/runtime_attribute.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"#include "openvino/op/util/framework_node.hpp"-#include "openvino/opsets/opset1.hpp"+#include "openvino/op/util/op_types.hpp"+#include "openvino/op/util/variable.hpp"#include "openvino/runtime/aligned_buffer.hpp"-#include "transformations/rt_info/primitives_priority_attribute.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {// helpernamespace {@@ -42,7 +57,7 @@ struct Edge {int to_port = 0;};-enum class AttrType {+enum class AttrType : uint8_t {layers,layer,id,@@ -68,22 +83,22 @@ enum class AttrType {size};-template <typename T, typename std::enable_if<!std::is_enum<T>::value, int>::type = 0>-static uint64_t hash_combine(uint64_t seed, const T& v) {+template <typename T, std::enable_if_t<!std::is_enum_v<T>, int> = 0>+uint64_t hash_combine(uint64_t seed, const T& v) {// Hash combine formula from boostreturn seed ^= std::hash<T>{}(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);}-template <typename T, typename std::enable_if<std::is_enum<T>::value, int>::type = 0>-static uint64_t hash_combine(uint64_t seed, const T& v) {- using underlying_t = typename std::underlying_type<T>::type;+template <typename T, std::enable_if_t<std::is_enum_v<T>, int> = 0>+uint64_t hash_combine(uint64_t seed, const T& v) {+ using underlying_t = std::underlying_type_t<T>;return hash_combine(seed, static_cast<underlying_t>(v));}namespace rt_info {// some node attr is not type of ov::RuntimeAttribute, need dedicate visitor.-static const std::vector<std::string> list_of_names{+const std::vector<std::string> list_of_names{"PrimitivesPriority","alt_width",};@@ -115,7 +130,7 @@ public:RTInfoHasher(uint64_t& rt_hash) : m_rt_hash(rt_hash) {}void on_adapter(const std::string& name, ov::ValueAccessor<void>& adapter) override {- if (auto a = ov::as_type<ov::AttributeAdapter<std::set<std::string>>>(&adapter)) {+ if (auto* a = ov::as_type<ov::AttributeAdapter<std::set<std::string>>>(&adapter)) {const auto& value = join(a->get());m_rt_hash = hash_combine(hash_combine(m_rt_hash, name), value);} else {@@ -164,7 +179,8 @@ public:m_rt_hash = hash_combine(hash_combine(m_rt_hash, name), value);}- void on_adapter(const std::string& name, ov::ValueAccessor<std::shared_ptr<ov::Model>>& adapter) override {+ void on_adapter([[maybe_unused]] const std::string& name,+ [[maybe_unused]] ov::ValueAccessor<std::shared_ptr<ov::Model>>& adapter) override {OPENVINO_THROW("Model type is unsupported for snippets rt info hash generation");}};@@ -195,7 +211,7 @@ public:m_hash = hash_combine(m_hash, AttrType::constant);const int64_t size = a->get()->size();m_hash = hash_combine(hash_combine(m_hash, AttrType::size), size);- auto data = static_cast<const char*>(a->get()->get_ptr());+ const auto* data = static_cast<const char*>(a->get()->get_ptr());for (int64_t i = 0; i < size; i++) {m_hash = hash_combine(m_hash, data[i]);}@@ -231,7 +247,7 @@ public:m_hash = hash_combine(hash_combine(m_hash, name), adapter.get());}void on_adapter(const std::string& name, ov::ValueAccessor<int64_t>& adapter) override {- m_hash = hash_combine(hash_combine(m_hash, name), static_cast<long long>(adapter.get()));+ m_hash = hash_combine(hash_combine(m_hash, name), static_cast<int64_t>(adapter.get()));}void on_adapter(const std::string& name, ov::ValueAccessor<double>& adapter) override {m_hash = hash_combine(hash_combine(m_hash, name), adapter.get());@@ -251,7 +267,8 @@ public:void on_adapter(const std::string& name, ov::ValueAccessor<std::vector<std::string>>& adapter) override {m_hash = hash_combine(hash_combine(m_hash, name), create_attribute_list(adapter));}- void on_adapter(const std::string& name, ov::ValueAccessor<std::shared_ptr<ov::Model>>& adapter) override {+ void on_adapter([[maybe_unused]] const std::string& name,+ ov::ValueAccessor<std::shared_ptr<ov::Model>>& adapter) override {ovfunction_2_hash(m_hash, *adapter.get());}};@@ -274,8 +291,8 @@ std::vector<Edge> create_edge_mapping(const std::unordered_map<ov::Node*, int>&for (const auto& i : node->inputs()) {auto source_output = i.get_source_output();- auto source_node = source_output.get_node();- auto current_node = i.get_node();+ auto* source_node = source_output.get_node();+ auto* current_node = i.get_node();if (layer_ids.find(source_node) == layer_ids.end() || layer_ids.find(current_node) == layer_ids.end()) {OPENVINO_THROW("Failed creat edge map in snippets hash generation");@@ -295,20 +312,20 @@ std::vector<Edge> create_edge_mapping(const std::unordered_map<ov::Node*, int>&return edges;}-void hash_rt_info(uint64_t& hash, const std::string& name, const ov::Any& data) {+void hash_rt_info(uint64_t& hash, const ov::Any& data) {if (data.is<std::shared_ptr<ov::Meta>>()) {- std::shared_ptr<ov::Meta> meta = data.as<std::shared_ptr<ov::Meta>>();+ const auto& meta = data.as<std::shared_ptr<ov::Meta>>();ov::AnyMap& map = *meta;for (const auto& it : map) {- hash_rt_info(hash, it.first, it.second);+ hash_rt_info(hash, it.second);}} else if (data.is<ov::AnyMap>()) {- const ov::AnyMap& any_map = data.as<ov::AnyMap>();+ const auto& any_map = data.as<ov::AnyMap>();for (const auto& it : any_map) {- hash_rt_info(hash, it.first, it.second);+ hash_rt_info(hash, it.second);}} else {- std::string value = data.as<std::string>();+ const auto& value = data.as<std::string>();hash = hash_combine(hash_combine(hash, AttrType::value), value);}}@@ -325,8 +342,9 @@ void ovfunction_2_hash(uint64_t& hash, const ov::Model& model) {ov::Node* node = n.get();const std::string& node_type_name{node->get_type_name()};- if (layer_ids.find(node) == layer_ids.end())+ if (layer_ids.find(node) == layer_ids.end()) {OPENVINO_THROW("Failed to find layer's id in snippets hash generation.");+ }// <layers>hash = hash_combine(hash, AttrType::layer);hash = hash_combine(hash_combine(hash, AttrType::id), layer_ids.find(node)->second);@@ -390,7 +408,7 @@ void ovfunction_2_hash(uint64_t& hash, const ov::Model& model) {// <edges>const std::vector<Edge> edge_mapping = create_edge_mapping(layer_ids, model);hash = hash_combine(hash, AttrType::edges);- for (auto& e : edge_mapping) {+ for (const auto& e : edge_mapping) {hash = hash_combine(hash, AttrType::edge);hash = hash_combine(hash_combine(hash, AttrType::from_layer), e.from_layer);hash = hash_combine(hash_combine(hash, AttrType::from_port), e.from_port);@@ -401,18 +419,18 @@ void ovfunction_2_hash(uint64_t& hash, const ov::Model& model) {// Serialize rt infohash = hash_combine(hash, AttrType::rt_info);for (const auto& it : model.get_rt_info()) {- hash_rt_info(hash, it.first, it.second);+ hash_rt_info(hash, it.second);}}} // namespace-bool Hash::run_on_model(const std::shared_ptr<ov::Model>& f) {+bool Hash::run_on_model(const std::shared_ptr<ov::Model>& m) {uint64_t seed = 0;std::string name = "net";SnippetsHasher visitor(seed, name);- std::shared_ptr<ov::Model> m(f); // for complilation error, on_attribute don't accept f- visitor.on_attribute(name, m);+ std::shared_ptr<ov::Model> model(m); // for complilation error, on_attribute don't accept f+ visitor.on_attribute(name, model);m_hash = seed;// Return false because we didn't change OpenVINO Modelreturn false;@@ -420,6 +438,4 @@ bool Hash::run_on_model(const std::shared_ptr<ov::Model>& f) {Hash::Hash(uint64_t& output_hash_value) : m_hash(output_hash_value) {}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/src/pass/insert_movebroadcast.cpp b/src/common/snippets/src/pass/insert_movebroadcast.cppindex 3c6c5f0ee3a..dbb986a61ff 100644--- a/src/common/snippets/src/pass/insert_movebroadcast.cpp+++ b/src/common/snippets/src/pass/insert_movebroadcast.cpp@@ -4,13 +4,29 @@#include "snippets/pass/insert_movebroadcast.hpp"-#include <numeric>-+#include <cstddef>+#include <memory>+#include <utility>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/partial_shape.hpp"#include "openvino/core/rt_info.hpp"+#include "openvino/core/type.hpp"+#include "openvino/op/mod.hpp"+#include "openvino/op/prelu.hpp"+#include "openvino/op/squared_difference.hpp"+#include "openvino/op/util/attr_types.hpp"#include "openvino/op/util/op_types.hpp"-#include "openvino/opsets/opset1.hpp"+#include "openvino/pass/matcher_pass.hpp"+#include "openvino/pass/pattern/matcher.hpp"+#include "openvino/pass/pattern/op/label.hpp"#include "snippets/itt.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/op/broadcastmove.hpp"+#include "snippets/op/vector_buffer.hpp"#include "snippets/utils/utils.hpp"namespace {@@ -19,8 +35,9 @@ std::pair<ov::PartialShape, std::vector<ov::PartialShape>> get_numpy_broadcast_pconst std::vector<ov::PartialShape>& input_shapes) {ov::PartialShape target_shape = input_shapes.front();for (size_t i = 1; i < input_shapes.size(); i++) {- if (!ov::PartialShape::broadcast_merge_into(target_shape, input_shapes[i], ov::op::AutoBroadcastType::NUMPY))+ if (!ov::PartialShape::broadcast_merge_into(target_shape, input_shapes[i], ov::op::AutoBroadcastType::NUMPY)) {OPENVINO_THROW("InsertMoveBroadcast: Failed broadcast-merge input shapes");+ }}std::vector<ov::PartialShape> normalized_shapes;for (const auto& input : input_shapes) {@@ -45,7 +62,6 @@ ov::Output<ov::Node> ov::snippets::pass::InsertMoveBroadcast::BroadcastNodeLastD// Insert BroadcastMove only if the last dimension needs to be broadcasted. Higher-level dims broadcasting// will be handled by pointer arithmetics inside outer LoopEmitterif (*target_shape.rbegin() != *normalized_shape.rbegin()) {- ov::PartialShape broadcasted_shape = normalized_shape;const auto broadcast_node = std::make_shared<ov::snippets::op::BroadcastMove>(value, *target_shape.rbegin());copy_runtime_info(value.get_node_shared_ptr(), broadcast_node);@@ -80,8 +96,9 @@ ov::snippets::pass::InsertMoveBroadcast::InsertMoveBroadcast() {// Do not insert MoveBroadcast if any of the last dims is dynamic,// since we don't know if we really need it. In these cases, broadcasting will be performed// by outer Loop based on runtime shapes.- if (!is_ignored.back() && !input_shapes.back().rbegin()->is_static())+ if (!is_ignored.back() && !input_shapes.back().rbegin()->is_static()) {return false;+ }}// find the output tensor's shape, then broadcast all inputs so that they are compatible with respect to thediff --git a/src/common/snippets/src/pass/manager.cpp b/src/common/snippets/src/pass/manager.cppindex 9e5719da31e..5e6f3a38f6f 100644--- a/src/common/snippets/src/pass/manager.cpp+++ b/src/common/snippets/src/pass/manager.cpp@@ -4,9 +4,18 @@#include "snippets/pass/manager.hpp"-namespace ov {-namespace snippets {-namespace pass {+#include <iterator>+#include <memory>+#include <string>+#include <utility>+#include <vector>++#include "openvino/pass/manager.hpp"+#include "openvino/pass/pass_config.hpp"+#include "openvino/pass/validate.hpp"+#include "snippets/pass/positioned_pass.hpp"++namespace ov::snippets::pass {Manager::Manager(std::shared_ptr<ov::pass::PassConfig> pass_config, std::string name): ov::pass::Manager(std::move(pass_config), std::move(name)) {}@@ -18,8 +27,9 @@ std::shared_ptr<Manager::PassBase> Manager::register_pass_instance(const PassPos}void Manager::register_positioned_passes(const std::vector<PositionedPassBase>& pos_passes) {- for (const auto& pp : pos_passes)+ for (const auto& pp : pos_passes) {register_pass_instance(pp.position, pp.pass);+ }}std::shared_ptr<Manager::PassBase> Manager::insert_pass_instance(const PassPosition& position,@@ -34,6 +44,4 @@ std::shared_ptr<Manager::PassBase> Manager::insert_pass_instance(const PassPositreturn pass;}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/src/pass/matmul_to_brgemm.cpp b/src/common/snippets/src/pass/matmul_to_brgemm.cppindex 015e93828b4..174362a52cb 100644--- a/src/common/snippets/src/pass/matmul_to_brgemm.cpp+++ b/src/common/snippets/src/pass/matmul_to_brgemm.cpp@@ -4,17 +4,27 @@#include "snippets/pass/matmul_to_brgemm.hpp"+#include <cstddef>+#include <memory>+#include <utility>+#include <vector>++#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.hpp"+#include "openvino/opsets/opset1.hpp"+#include "openvino/pass/pattern/matcher.hpp"+#include "openvino/pass/pattern/op/label.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"#include "snippets/itt.hpp"#include "snippets/lowered/port_descriptor.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/op/brgemm.hpp"+#include "snippets/op/convert_saturation.hpp"#include "snippets/utils/utils.hpp"-#include "transformations/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {using namespace lowered;@@ -28,13 +38,15 @@ MatMulToBrgemm::MatMulToBrgemm() {const auto& pm = m.get_pattern_value_map();const auto matmul = as_type_ptr<ov::opset1::MatMul>(pm.at(matmul_pattern).get_node_shared_ptr());// Brgemm doesn't support transposed inputs currently, so we don't convert such matmuls- if (matmul->get_transpose_a())+ if (matmul->get_transpose_a()) {return false;+ }auto generate_layout = [](const ov::PartialShape& shape, const bool transpose) {std::vector<size_t> layout = utils::get_planar_layout(shape.size());- if (transpose)+ if (transpose) {std::swap(*layout.rbegin(), *(layout.rbegin() + 1));+ }return layout;};@@ -62,6 +74,4 @@ MatMulToBrgemm::MatMulToBrgemm() {register_matcher(m, callback);}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/src/pass/mha_tokenization.cpp b/src/common/snippets/src/pass/mha_tokenization.cppindex 2a7b2e87f84..f80b0a9d6b2 100644--- a/src/common/snippets/src/pass/mha_tokenization.cpp+++ b/src/common/snippets/src/pass/mha_tokenization.cpp@@ -4,17 +4,44 @@#include "snippets/pass/mha_tokenization.hpp"-#include "openvino/core/rt_info.hpp"+#include <algorithm>+#include <cassert>+#include <cstddef>+#include <cstdint>+#include <iterator>+#include <memory>+#include <numeric>+#include <set>+#include <utility>+#include <vector>++#include "openvino/core/descriptor/tensor.hpp"+#include "openvino/core/dimension.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"#include "openvino/core/validation_util.hpp"-#include "openvino/pass/pattern/op/wrap_type.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/fake_quantize.hpp"+#include "openvino/op/select.hpp"+#include "openvino/op/softmax.hpp"+#include "openvino/op/util/attr_types.hpp"+#include "openvino/op/util/binary_elementwise_arithmetic.hpp"+#include "openvino/op/util/unary_elementwise_arithmetic.hpp"+#include "openvino/opsets/opset1.hpp"+#include "openvino/pass/pattern/matcher.hpp"+#include "openvino/pass/pattern/op/label.hpp"+#include "openvino/util/pp.hpp"#include "snippets/itt.hpp"#include "snippets/op/brgemm.hpp"#include "snippets/op/subgraph.hpp"#include "snippets/pass/collapse_subgraph.hpp"#include "snippets/pass/explicit_transpose_matmul_inputs.hpp"+#include "snippets/pass/tokenization.hpp"#include "snippets/utils/tokenization_utils.hpp"#include "snippets/utils/utils.hpp"-#include "transformations/utils/utils.hpp"namespace {bool is_supported_tensor(const ov::descriptor::Tensor& t) {@@ -34,11 +61,12 @@ bool is_supported_intermediate_op(const std::shared_ptr<ov::Node>& node) {bool is_valid_transpose(const std::shared_ptr<ov::opset1::Transpose>& node,const std::set<size_t>& supported_ranks,- std::vector<int32_t> expected_order) {+ const std::vector<int32_t>& expected_order) {auto is_valid_transpose_order = [expected_order, supported_ranks](const std::shared_ptr<ov::Node>& node) -> bool {const auto transpose_pattern = ov::as_type_ptr<ov::opset1::Constant>(node);- if (!transpose_pattern)+ if (!transpose_pattern) {return false;+ }const auto existing_order = transpose_pattern->cast_vector<int32_t>();return existing_order == expected_order && supported_ranks.count(existing_order.size()) != 0;};@@ -75,8 +103,9 @@ void tokenize_broadcast(const std::shared_ptr<ov::Node>& interm_op, ov::NodeVectif (broadcast && broadcast->get_broadcast_spec().m_type == ov::op::AutoBroadcastType::NUMPY &&broadcast->get_output_target_inputs(0).size() == 1) {// TODO: Add support of Broadcast with ShapeOf subgraph on second input- if (!ov::is_type<ov::op::v0::Constant>(broadcast->input_value(1).get_node_shared_ptr()))+ if (!ov::is_type<ov::op::v0::Constant>(broadcast->input_value(1).get_node_shared_ptr())) {continue;+ }broadcast_nodes.push_back(broadcast);@@ -87,7 +116,7 @@ void tokenize_broadcast(const std::shared_ptr<ov::Node>& interm_op, ov::NodeVect::ov::op::AutoBroadcastType::NUMPY);}} else {- const auto pshape = input.get_partial_shape();+ const auto& pshape = input.get_partial_shape();if (pshape.rank().is_static() && pshape.size() > 2) {ov::PartialShape::broadcast_merge_into(new_output_shape,skip_last_dim(pshape),@@ -109,16 +138,18 @@ bool tokenize_reshape_around_softmax(std::shared_ptr<ov::Node>& interm_op,reshape = ov::as_type_ptr<ov::opset1::Reshape>(interm_op);if (reshape) {// TODO: Add support of Reshape with ShapeOf subgraph on second input- if (!ov::is_type<ov::op::v0::Constant>(reshape->input_value(1).get_node_shared_ptr()))+ if (!ov::is_type<ov::op::v0::Constant>(reshape->input_value(1).get_node_shared_ptr())) {return false;+ }const auto in_shape = reshape->get_input_partial_shape(0);const auto out_shape = reshape->get_output_partial_shape(0);const auto in_last_dim = *in_shape.crbegin();const auto out_last_dim = *out_shape.crbegin();if (in_last_dim.is_dynamic() || out_last_dim.is_dynamic() || in_last_dim != out_last_dim ||- reshape->get_output_target_inputs(0).size() != 1)+ reshape->get_output_target_inputs(0).size() != 1) {return false;+ }ordered_ops.push_back(reshape);interm_op = reshape->get_output_target_inputs(0).begin()->get_node()->shared_from_this();@@ -146,8 +177,9 @@ bool update_intermediate_supported_ops(std::shared_ptr<ov::Node>& interm_op,size_t& potential_body_params_count) {while (is_supported_intermediate_op(interm_op)) {// All supported intermediate ops have only one output port- if (interm_op->get_output_target_inputs(0).size() != 1)+ if (interm_op->get_output_target_inputs(0).size() != 1) {return false;+ }// Check for supported ops on branches: Broadcast/Elementwise (for example, dequantize ops)if (interm_op->get_input_size() > 1) {@@ -172,19 +204,22 @@ bool update_intermediate_supported_ops(std::shared_ptr<ov::Node>& interm_op,auto parent = interm_op->get_input_node_shared_ptr(i);while (is_supported_branch_op(parent)) {// All supported ops have only one output port- if (parent->get_output_target_inputs(0).size() != 1)+ if (parent->get_output_target_inputs(0).size() != 1) {break;+ }// Add node only if there are scalar constants on inputs because of plugin-specific limitation- if (!ov::snippets::pass::ExplicitTransposeMatMulInputs::are_weights_scalar(parent))+ if (!ov::snippets::pass::ExplicitTransposeMatMulInputs::are_weights_scalar(parent)) {break;+ }ordered_ops.insert(ordered_ops.begin() + shift, parent);// TODO [107731]: We think that sequence of ops goes through input port 0// But can be Select here? If it can be, parent shouldn't be on input port 0. Need// another way?- if (parent->get_input_size() > 0)+ if (parent->get_input_size() > 0) {parent = parent->get_input_node_shared_ptr(0);+ }}}}@@ -218,8 +253,9 @@ std::vector<int32_t> ov::snippets::pass::TokenizeMHASnippets::get_decomposed_trabool ov::snippets::pass::TokenizeMHASnippets::is_matmul0_supported(const std::shared_ptr<ov::opset1::MatMul>& matmul) {if (!matmul || matmul->get_output_target_inputs(0).size() != 1 || matmul->get_transpose_a() ||- !is_supported_tensor(matmul->get_input_tensor(0)) || !is_supported_tensor(matmul->get_input_tensor(1)))+ !is_supported_tensor(matmul->get_input_tensor(0)) || !is_supported_tensor(matmul->get_input_tensor(1))) {return false;+ }const auto matmul_prc =op::Brgemm::get_output_type(matmul->get_input_element_type(0), matmul->get_input_element_type(1));@@ -263,7 +299,6 @@ ov::snippets::pass::TokenizeMHASnippets::TokenizeMHASnippets(const SnippetsToken// But operations after Transpose1 and before MatMul0 will be fused into one loop as well (look at// first point)size_t uniqie_buffer_reg_group_count = 1; // After MatMul0 there is always one Buffer- std::string fused_names;ov::NodeVector ordered_ops;/* ======== Matcher Pass ========== */@@ -283,8 +318,9 @@ ov::snippets::pass::TokenizeMHASnippets::TokenizeMHASnippets(const SnippetsToken*/const auto matmul0 =ov::as_type_ptr<ov::opset1::MatMul>(pattern_to_output.at(m_matmul0).get_node_shared_ptr());- if (!is_matmul0_supported(matmul0))+ if (!is_matmul0_supported(matmul0)) {return false;+ }ordered_ops.push_back(matmul0);@@ -295,12 +331,14 @@ ov::snippets::pass::TokenizeMHASnippets::TokenizeMHASnippets(const SnippetsTokenif (!update_intermediate_supported_ops(interm_op,ordered_ops,hidden_virtual_ports_count,- potential_body_params_count))+ potential_body_params_count)) {return false;+ }std::shared_ptr<ov::opset1::Reshape> reshape0 = nullptr;- if (!tokenize_reshape_around_softmax(interm_op, reshape0, ordered_ops))+ if (!tokenize_reshape_around_softmax(interm_op, reshape0, ordered_ops)) {return false;+ }int64_t axis = 0;const auto rank = interm_op->get_input_partial_shape(0).rank();@@ -312,37 +350,43 @@ ov::snippets::pass::TokenizeMHASnippets::TokenizeMHASnippets(const SnippetsTokenreturn false;}- if (axis != rank.get_length() - 1 || interm_op->get_output_target_inputs(0).size() != 1)+ if (axis != rank.get_length() - 1 || interm_op->get_output_target_inputs(0).size() != 1) {return false;+ }ordered_ops.push_back(interm_op);interm_op = interm_op->get_output_target_inputs(0).begin()->get_node()->shared_from_this();std::shared_ptr<ov::opset1::Reshape> reshape1 = nullptr;- if (!tokenize_reshape_around_softmax(interm_op, reshape1, ordered_ops))+ if (!tokenize_reshape_around_softmax(interm_op, reshape1, ordered_ops)) {return false;+ }if (((reshape0 == nullptr) != (reshape1 == nullptr)) ||(reshape0 && reshape1 &&- (reshape0->get_input_partial_shape(0) != reshape1->get_output_partial_shape(0))))+ (reshape0->get_input_partial_shape(0) != reshape1->get_output_partial_shape(0)))) {return false;+ }// Add supported operations which are between Softmax and MatMul1 to ordered_opsif (!update_intermediate_supported_ops(interm_op,ordered_ops,hidden_virtual_ports_count,- potential_body_params_count))+ potential_body_params_count)) {return false;+ }const auto matmul1 = ov::as_type_ptr<ov::opset1::MatMul>(interm_op);- if (!matmul1 || matmul1->get_transpose_a() || matmul1->get_transpose_b())+ if (!matmul1 || matmul1->get_transpose_a() || matmul1->get_transpose_b()) {return false;+ }const auto matmul1_out_type =op::Brgemm::get_output_type(matmul1->get_input_element_type(0), matmul1->get_input_element_type(1));if (matmul1_out_type == element::dynamic || !is_supported_tensor(matmul1->get_input_tensor(0)) ||- !is_supported_tensor(matmul1->get_input_tensor(1)))+ !is_supported_tensor(matmul1->get_input_tensor(1))) {return false;+ }if (transformation_callback(matmul0)) {return false;@@ -378,8 +422,9 @@ ov::snippets::pass::TokenizeMHASnippets::TokenizeMHASnippets(const SnippetsTokensize_t rank,const ov::NodeVector::const_iterator& pos) {// Transpose is redundant for rank <= 2- if (rank <= 2)+ if (rank <= 2) {return;+ }// If Transpose has valid order for the Transpose fusing (ExplicitTransposeMatMulInputs pass call),// tokenize him. Otherwise, skip the Transpose.auto order = get_fusion_transpose_order(rank);@@ -415,8 +460,9 @@ ov::snippets::pass::TokenizeMHASnippets::TokenizeMHASnippets(const SnippetsTokenwhile (can_be_ops_after_matmul1_tokenized && is_supported_intermediate_op(child)) {are_ops_after_matmul1 = true;// All supported ops have only one output port- if (child->get_output_target_inputs(0).size() != 1)+ if (child->get_output_target_inputs(0).size() != 1) {break;+ }// To avoid unsupported number of non-scalar Constants in the future after FakeQuantize decomposition// (plugin specific limitation) we should calculate potential number of non-scalar Constants for@@ -485,18 +531,21 @@ ov::snippets::pass::TokenizeMHASnippets::TokenizeMHASnippets(const SnippetsToken// parameters/results, the heuristic value of their number is `5`) the count of available// registers might be not enough and we have to not tokenize these subgraphs. So only for// these rare cases we decrement `available_regs` value.- if (io_count > 5)+ if (io_count > 5) {available_regs--;+ }- if (data_count > available_regs)+ if (data_count > available_regs) {return false;+ }// If backend doesn't enable dynamic MHA tokenization, return falseif (!config.is_dynamic_mha_token_enabled()) {if (std::any_of(ordered_ops.cbegin(), ordered_ops.cend(), [](const std::shared_ptr<ov::Node>& op) {return op->is_dynamic();- }))+ })) {return false;+ }}/* ================================ */diff --git a/src/common/snippets/src/pass/mlp_seq_tokenization.cpp b/src/common/snippets/src/pass/mlp_seq_tokenization.cppindex 28ef75a5a70..e642c0db0b8 100644--- a/src/common/snippets/src/pass/mlp_seq_tokenization.cpp+++ b/src/common/snippets/src/pass/mlp_seq_tokenization.cpp@@ -4,20 +4,38 @@#include "snippets/pass/mlp_seq_tokenization.hpp"-#include "openvino/core/rt_info.hpp"+#include <cstddef>+#include <cstdint>+#include <memory>++#include "openvino/core/descriptor/tensor.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"#include "openvino/core/validation_util.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/fake_quantize.hpp"+#include "openvino/op/matmul.hpp"+#include "openvino/op/softmax.hpp"+#include "openvino/op/util/binary_elementwise_arithmetic.hpp"+#include "openvino/op/util/unary_elementwise_arithmetic.hpp"+#include "openvino/opsets/opset1.hpp"+#include "openvino/pass/pattern/matcher.hpp"+#include "openvino/pass/pattern/op/label.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"+#include "openvino/util/pp.hpp"#include "snippets/itt.hpp"#include "snippets/op/brgemm.hpp"#include "snippets/op/subgraph.hpp"#include "snippets/pass/collapse_subgraph.hpp"+#include "snippets/pass/tokenization.hpp"#include "snippets/utils/tokenization_utils.hpp"#include "snippets/utils/utils.hpp"-#include "transformations/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {namespace {@@ -106,7 +124,6 @@ TokenizeMLPSeqSnippets::TokenizeMLPSeqSnippets(const SnippetsTokenization::Confi// we should calculate potential number of non-scalar Constants that will be moved up from body.// Heuiristic count of possible buffers - upper-bound valueconst size_t unique_buffer_reg_group_count = 2;- std::string fused_names;ov::NodeVector ordered_ops;/* ======== Matcher Pass ========== */@@ -178,8 +195,9 @@ TokenizeMLPSeqSnippets::TokenizeMLPSeqSnippets(const SnippetsTokenization::Confi// TODO [75567]: move this plugin-specific constraint to the plugin callback// +1 - for result- if (current_potential_body_params_count + unique_buffer_reg_group_count + 1 > available_regs)+ if (current_potential_body_params_count + unique_buffer_reg_group_count + 1 > available_regs) {break;+ }ordered_ops.push_back(interm_op);prev_op = interm_op;@@ -192,10 +210,11 @@ TokenizeMLPSeqSnippets::TokenizeMLPSeqSnippets(const SnippetsTokenization::Confi// Currently, sequence of MLP should contain 2 MatMuls at leastsize_t mm_count = 0;for (const auto& op : ordered_ops) {- mm_count += (ov::is_type<ov::op::v0::MatMul>(op));+ mm_count += static_cast<size_t>(ov::is_type<ov::op::v0::MatMul>(op));}- if (mm_count < 2)+ if (mm_count < 2) {return false;+ }/* ====== Subgraph creation ======= */@@ -208,6 +227,4 @@ TokenizeMLPSeqSnippets::TokenizeMLPSeqSnippets(const SnippetsTokenization::Confi});}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/src/pass/positioned_pass.cpp b/src/common/snippets/src/pass/positioned_pass.cppindex c8c038993b3..95b9aeeada6 100644--- a/src/common/snippets/src/pass/positioned_pass.cpp+++ b/src/common/snippets/src/pass/positioned_pass.cpp@@ -4,9 +4,12 @@#include "snippets/pass/positioned_pass.hpp"-namespace ov {-namespace snippets {-namespace pass {+#include <cstddef>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"++namespace ov::snippets::pass {PassPosition::PassPosition(Place pass_place) : m_place(pass_place) {OPENVINO_ASSERT(m_place == Place::PipelineStart || m_place == Place::PipelineEnd,@@ -23,6 +26,4 @@ PassPosition::PassPosition(Place pass_place, const DiscreteTypeInfo& pass_type_i"Invalid args combination: pass_place must be Place::Before/Place::After and pass_type_info must be non-empty");}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/src/pass/propagate_precision.cpp b/src/common/snippets/src/pass/propagate_precision.cppindex 8ba2cf57a62..f87cdd777ac 100644--- a/src/common/snippets/src/pass/propagate_precision.cpp+++ b/src/common/snippets/src/pass/propagate_precision.cpp@@ -4,29 +4,44 @@#include "snippets/pass/propagate_precision.hpp"+#include <algorithm>+#include <cstddef>#include <memory>-+#include <set>+#include <string>+#include <unordered_map>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/model.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"#include "openvino/core/rt_info.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"+#include "openvino/op/result.hpp"+#include "openvino/opsets/opset1.hpp"#include "ov_ops/type_relaxed.hpp"#include "snippets/itt.hpp"-#include "snippets/utils/utils.hpp"+#include "snippets/op/convert_saturation.hpp"+#include "snippets/target_machine.hpp"#include "transformations/utils/utils.hpp"ov::snippets::pass::PropagatePrecision::PropagatePrecision(const std::shared_ptr<const TargetMachine>& target_machine): target_machine(target_machine) {}-bool ov::snippets::pass::PropagatePrecision::run_on_model(const std::shared_ptr<ov::Model>& f) {+bool ov::snippets::pass::PropagatePrecision::run_on_model(const std::shared_ptr<ov::Model>& m) {RUN_ON_MODEL_SCOPE(PropagatePrecision);OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::op::PropagatePrecision")std::unordered_map<std::shared_ptr<ov::opset1::Result>, element::Type> result_types;- auto results = f->get_results();+ auto results = m->get_results();for (auto& result : results) {result_types.emplace(result, result->get_input_element_type(0));}bool was_updated = false;- for (const auto& op : f->get_ordered_ops()) {+ for (const auto& op : m->get_ordered_ops()) {ov::op::util::process_subgraph(*this, op);auto type_info = op->get_type_info();@@ -43,7 +58,7 @@ bool ov::snippets::pass::PropagatePrecision::run_on_model(const std::shared_ptr<// 2) Type relaxed based operations. Will be resolved by snippet opset.for (const auto& input : op->inputs()) {- const auto convert = ov::as_type<snippets::op::ConvertSaturation>(input.get_source_output().get_node());+ auto* const convert = ov::as_type<snippets::op::ConvertSaturation>(input.get_source_output().get_node());if (convert == nullptr) {continue;}@@ -82,10 +97,10 @@ bool ov::snippets::pass::PropagatePrecision::run_on_model(const std::shared_ptr<"there are no supported precisions for operation '" + std::string(type_info.version_id) +"::" + std::string(type_info.name) + "'");- auto find_convert = [](const ov::Output<ov::Node> parent_output,+ auto find_convert = [](const ov::Output<ov::Node>& parent_output,const ov::element::Type convert_type) -> snippets::op::ConvertSaturation* {for (const auto& input : parent_output.get_target_inputs()) {- const auto child = ov::as_type<snippets::op::ConvertSaturation>(input.get_node());+ auto* const child = ov::as_type<snippets::op::ConvertSaturation>(input.get_node());if ((child != nullptr) && (child->get_output_element_type(0) == convert_type)) {return child;}@@ -100,7 +115,7 @@ bool ov::snippets::pass::PropagatePrecision::run_on_model(const std::shared_ptr<const auto actual_before = parent_output.get_element_type();if (actual_before != required_after) {was_updated = true;- auto existing_convert = ov::as_type<ov::snippets::op::ConvertSaturation>(parent_output.get_node());+ auto* existing_convert = ov::as_type<ov::snippets::op::ConvertSaturation>(parent_output.get_node());if (existing_convert == nullptr) {existing_convert = find_convert(parent_output, required_after);@@ -155,11 +170,11 @@ bool ov::snippets::pass::PropagatePrecision::run_on_model(const std::shared_ptr<}}- for (auto it = result_types.begin(); it != result_types.end(); ++it) {- const auto result = it->first;+ for (auto& result_type : result_types) {+ const auto result = result_type.first;const auto actual_type = result->get_input_element_type(0);- const auto expected_type = it->second;- if (actual_type != it->second) {+ const auto expected_type = result_type.second;+ if (actual_type != result_type.second) {was_updated = true;auto convert = std::make_shared<ov::snippets::op::ConvertSaturation>(result->input_value(0), expected_type);copy_runtime_info(result->get_input_node_shared_ptr(0), convert);@@ -206,8 +221,8 @@ bool ov::snippets::pass::PropagatePrecision::validate_and_infer_types_and_restorauto convert = std::make_shared<ov::snippets::op::ConvertSaturation>(output, op_output_types[i]);copy_runtime_info(output.get_node_shared_ptr(), convert);- for (auto& input : output.get_target_inputs()) {- auto child = input.get_node();+ for (const auto& input : output.get_target_inputs()) {+ auto* child = input.get_node();if (child == convert.get()) {continue;}diff --git a/src/common/snippets/src/pass/reduce_to_snippets_reduce.cpp b/src/common/snippets/src/pass/reduce_to_snippets_reduce.cppindex dff653b2a69..d7472216b42 100644--- a/src/common/snippets/src/pass/reduce_to_snippets_reduce.cpp+++ b/src/common/snippets/src/pass/reduce_to_snippets_reduce.cpp@@ -4,19 +4,24 @@#include "snippets/pass/reduce_to_snippets_reduce.hpp"+#include <cstdint>+#include <memory>++#include "openvino/core/except.hpp"+#include "openvino/core/graph_util.hpp"#include "openvino/core/rt_info.hpp"+#include "openvino/core/type.hpp"#include "openvino/core/validation_util.hpp"+#include "openvino/op/constant.hpp"#include "openvino/op/reduce_max.hpp"#include "openvino/op/reduce_sum.hpp"+#include "openvino/op/util/arithmetic_reductions_keep_dims.hpp"+#include "openvino/pass/pattern/matcher.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"#include "snippets/itt.hpp"-#include "snippets/lowered/port_descriptor.hpp"#include "snippets/op/reduce.hpp"-namespace ov {-namespace snippets {-namespace pass {-using namespace lowered;+namespace ov::snippets::pass {snippets::pass::ReduceToSnippetsReduce::ReduceToSnippetsReduce() {MATCHER_SCOPE(ReduceToSnippetsReduce);auto reduce_pattern = ov::pass::pattern::wrap_type<ov::op::v1::ReduceSum, ov::op::v1::ReduceMax>();@@ -37,12 +42,13 @@ snippets::pass::ReduceToSnippetsReduce::ReduceToSnippetsReduce() {const auto axis = ov::util::try_normalize_axis(axis_constant->cast_vector<int32_t>(1)[0], reduce_rank, *reduce);std::shared_ptr<snippets::op::ReduceBase> snippets_reduce = nullptr;- if (ov::is_type<ov::op::v1::ReduceSum>(reduce))+ if (ov::is_type<ov::op::v1::ReduceSum>(reduce)) {snippets_reduce = std::make_shared<ov::snippets::op::ReduceSum>(data_input, axis);- else if (ov::is_type<ov::op::v1::ReduceMax>(reduce))+ } else if (ov::is_type<ov::op::v1::ReduceMax>(reduce)) {snippets_reduce = std::make_shared<ov::snippets::op::ReduceMax>(data_input, axis);- else+ } else {OPENVINO_THROW("Reduce ", reduce, " can't be converted to snippets opset.");+ }ov::snippets::op::ReduceBase::compute_and_set_reduce_subtensors(snippets_reduce);ov::replace_node(reduce, snippets_reduce);@@ -55,6 +61,4 @@ snippets::pass::ReduceToSnippetsReduce::ReduceToSnippetsReduce() {register_matcher(m, callback);}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/src/pass/softmax_decomposition.cpp b/src/common/snippets/src/pass/softmax_decomposition.cppindex 76ec53d7d91..fcc0c62315d 100644--- a/src/common/snippets/src/pass/softmax_decomposition.cpp+++ b/src/common/snippets/src/pass/softmax_decomposition.cpp@@ -4,18 +4,31 @@#include "snippets/pass/softmax_decomposition.hpp"+#include <cstddef>+#include <memory>+#include <utility>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/graph_util.hpp"+#include "openvino/core/rt_info.hpp"+#include "openvino/core/type.hpp"#include "openvino/core/validation_util.hpp"+#include "openvino/op/exp.hpp"+#include "openvino/op/multiply.hpp"#include "openvino/op/softmax.hpp"+#include "openvino/op/subtract.hpp"+#include "openvino/pass/matcher_pass.hpp"+#include "openvino/pass/pattern/matcher.hpp"#include "openvino/pass/pattern/op/or.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"#include "snippets/itt.hpp"#include "snippets/lowered/port_descriptor.hpp"+#include "snippets/op/powerstatic.hpp"#include "snippets/op/reduce.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {using namespace lowered;SoftmaxDecomposition::SoftmaxDecomposition() {@@ -32,7 +45,7 @@ SoftmaxDecomposition::SoftmaxDecomposition() {OPENVINO_ASSERT(!pshape.rank().is_dynamic(), "SoftmaxDecomposition doesn't support dynamic ranks");const auto rank = pshape.size();- size_t axis;+ size_t axis = 0;if (const auto softmax_v8 = ov::as_type_ptr<ov::op::v8::Softmax>(softmax)) {axis = ov::util::try_normalize_axis(softmax_v8->get_axis(), rank, *softmax);} else if (const auto softmax_v1 = ov::as_type_ptr<ov::op::v1::Softmax>(softmax)) {@@ -54,8 +67,9 @@ SoftmaxDecomposition::SoftmaxDecomposition() {OPENVINO_ASSERT(axis < rank, "Softmax has incorrect axis");std::vector<size_t> subtensor(rank, 1);- for (size_t i = axis; i < rank; ++i)+ for (size_t i = axis; i < rank; ++i) {subtensor[i] = utils::get_full_dim_value();+ }PortDescriptorUtils::set_port_descriptor(power->input(0), subtensor);PortDescriptorUtils::set_port_descriptor(power->output(0), std::move(subtensor));@@ -68,6 +82,4 @@ SoftmaxDecomposition::SoftmaxDecomposition() {register_matcher(m, callback);}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/src/pass/softmax_reshape_elimination.cpp b/src/common/snippets/src/pass/softmax_reshape_elimination.cppindex a8b6b07adce..5b79879c5df 100644--- a/src/common/snippets/src/pass/softmax_reshape_elimination.cpp+++ b/src/common/snippets/src/pass/softmax_reshape_elimination.cpp@@ -4,12 +4,21 @@#include "snippets/pass/softmax_reshape_elimination.hpp"+#include <cstdint>+#include <memory>++#include "openvino/core/graph_util.hpp"#include "openvino/core/rt_info.hpp"+#include "openvino/core/type.hpp"#include "openvino/core/validation_util.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/reshape.hpp"+#include "openvino/op/softmax.hpp"+#include "openvino/pass/pattern/matcher.hpp"+#include "openvino/pass/pattern/op/label.hpp"+#include "openvino/pass/pattern/op/pattern.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"#include "snippets/itt.hpp"-#include "snippets/remarks.hpp"-#include "snippets/snippets_isa.hpp"ov::snippets::pass::SoftmaxReshapeElimination::SoftmaxReshapeElimination() {MATCHER_SCOPE(SoftmaxReshapeElimination);@@ -34,8 +43,9 @@ ov::snippets::pass::SoftmaxReshapeElimination::SoftmaxReshapeElimination() {const auto input_shape = reshape0->get_input_partial_shape(0);const auto output_shape = reshape1->get_output_partial_shape(0);const auto softmax_shape = softmax->get_input_partial_shape(0);- if (input_shape != output_shape || input_shape.rank() != output_shape.rank())+ if (input_shape != output_shape || input_shape.rank() != output_shape.rank()) {return false;+ }const auto softmax_rank = softmax_shape.rank();int64_t axis = 0;@@ -48,16 +58,18 @@ ov::snippets::pass::SoftmaxReshapeElimination::SoftmaxReshapeElimination() {}// Supports only last axis- if (axis != softmax_rank.get_length() - 1)+ if (axis != softmax_rank.get_length() - 1) {return false;+ }// Dimensions by reduction axis should be equalconst auto in_last_dim = *input_shape.crbegin();const auto out_last_dim = *output_shape.crbegin();const auto softmax_last_dim = *softmax_shape.crbegin();if (in_last_dim.is_dynamic() || out_last_dim.is_dynamic() || softmax_last_dim.is_dynamic() ||- in_last_dim != out_last_dim || in_last_dim != softmax_last_dim)+ in_last_dim != out_last_dim || in_last_dim != softmax_last_dim) {return false;+ }// Eliminate Reshape before Softmaxreshape0->output(0).replace(reshape0->input_value(0));diff --git a/src/common/snippets/src/pass/split_dimension_m.cpp b/src/common/snippets/src/pass/split_dimension_m.cppindex e143782631b..0f30aaf2f6d 100644--- a/src/common/snippets/src/pass/split_dimension_m.cpp+++ b/src/common/snippets/src/pass/split_dimension_m.cpp@@ -4,27 +4,55 @@#include "snippets/pass/split_dimension_m.hpp"+#include <algorithm>+#include <cmath>+#include <cstddef>+#include <functional>+#include <iterator>+#include <memory>+#include <numeric>+#include <set>+#include <tuple>+#include <utility>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"+#include "openvino/op/broadcast.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/matmul.hpp"+#include "openvino/op/parameter.hpp"+#include "openvino/op/reshape.hpp"+#include "openvino/op/result.hpp"+#include "openvino/op/softmax.hpp"+#include "openvino/op/transpose.hpp"#include "snippets/itt.hpp"+#include "snippets/op/subgraph.hpp"+#include "snippets/shape_types.hpp"#include "snippets/utils/utils.hpp"namespace {bool is_prime_number(size_t value) {- if (ov::snippets::utils::one_of(value, 2lu, 3lu))+ if (ov::snippets::utils::one_of(value, 2lu, 3lu)) {return true;- if (value == 1 || value % 2 == 0 || value % 3 == 0)+ }+ if (value == 1 || value % 2 == 0 || value % 3 == 0) {return false;+ }const auto root = std::sqrt(value) + 1;for (size_t divisor = 5; divisor < root; divisor += 6) {- if ((value % divisor == 0) || (value % (divisor + 2) == 0))+ if ((value % divisor == 0) || (value % (divisor + 2) == 0)) {return false;+ }}return true;}} // namespace-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {const size_t SplitDimensionM::min_kernel_m = 32;const size_t SplitDimensionM::dim_M_index = 1;@@ -40,15 +68,17 @@ std::pair<size_t, size_t> SplitDimensionM::split_ideally(size_t batch_dim,// Ideal case #1: M can be split on the parts one of which complements the batch dimension to the optimal parallel// work amount In this case, each thread will execute the Snippets kernel onceconst size_t lower_bound = optimal_parallelism_work_amount / batch_dim;- if (lower_bound * batch_dim == optimal_parallelism_work_amount && m_dim % lower_bound == 0)+ if (lower_bound * batch_dim == optimal_parallelism_work_amount && m_dim % lower_bound == 0) {return std::make_pair(lower_bound, m_dim / lower_bound);+ }// Ideal case #2: M is divisible by optimal parallel work amount, and the new_m_dim is big enough// In this case, each thread will execute the Snippets kernel 'batch_dim' timesif (m_dim % optimal_parallelism_work_amount == 0) {const auto new_m_dim = m_dim / optimal_parallelism_work_amount;- if (new_m_dim >= min_kernel_m)+ if (new_m_dim >= min_kernel_m) {return std::make_pair(optimal_parallelism_work_amount, new_m_dim);+ }}return std::make_pair(1, m_dim);@@ -61,9 +91,10 @@ std::pair<size_t, size_t> SplitDimensionM::split_fallback_increase_parallel_wa(sconst size_t upper_bound = utils::div_up(2 * optimal_parallelism_work_amount, batch_dim);for (size_t divisor_0 = upper_bound - 1; divisor_0 > 1; divisor_0--) {size_t divisor_1 = m_dim / divisor_0;- if (divisor_1 * divisor_0 == m_dim)+ if (divisor_1 * divisor_0 == m_dim) {return divisor_0 * batch_dim >= optimal_parallelism_work_amount ? std::make_pair(divisor_0, divisor_1): splited;+ }}return splited;}@@ -76,12 +107,14 @@ std::pair<size_t, size_t> SplitDimensionM::split_minimize_kernel_wa(size_t batch// to this value.std::pair<size_t, size_t> best_result = {1, m_dim};for (size_t divisor = 2; divisor < std::sqrt(m_dim); ++divisor) {- if (m_dim % divisor != 0)+ if (m_dim % divisor != 0) {continue;+ }// If divisor is more than 'min_kernel_m', divisor becomes 'm_kernel',// guaranteeing the most optimal implementation from 'm_kernel' minimization perspective.- if (divisor >= min_kernel_m)+ if (divisor >= min_kernel_m) {return std::make_pair(m_dim / divisor, divisor);+ }// If divisor is less than 'min_kernel_m', divisor becomes m_batch.// However, it is not guaranteed that the current 'm_kernel = m_dim / divisor' is minimized, as one of the next@@ -92,15 +125,17 @@ std::pair<size_t, size_t> SplitDimensionM::split_minimize_kernel_wa(size_t batchbest_result.second = m_kernel;}}- if (best_result.first * batch_dim >= optimal_parallelism_work_amount)+ if (best_result.first * batch_dim >= optimal_parallelism_work_amount) {return best_result;+ }return std::make_pair(1, m_dim);}bool SplitDimensionM::can_be_optimized(const std::shared_ptr<const ov::Node>& node, size_t concurrency) {- if (!is_supported_matmul(node))+ if (!is_supported_matmul(node)) {return false;- size_t batch_m_dim, new_m_dim;+ }+ size_t batch_m_dim = 0, new_m_dim = 0;return split(node->get_shape(), concurrency, batch_m_dim, new_m_dim);}@@ -125,8 +160,9 @@ ov::snippets::VectorDims SplitDimensionM::reshape_m_dim(ov::snippets::VectorDimssize_t batch_m_dim,size_t new_m_dim) {OPENVINO_ASSERT(m_index < shape.size(), "Incorrect M index: it should be less than target shape rank");- if (shape[m_index] == 1)+ if (shape[m_index] == 1) {return unsqueeze_m_dim(std::move(shape), m_index);+ }shape[m_index] = new_m_dim;shape.insert(shape.begin() + m_index, batch_m_dim);return shape;@@ -151,10 +187,11 @@ std::shared_ptr<ov::op::v0::MatMul> SplitDimensionM::get_matmul(const std::shareconst auto mm_it = std::find_if(ops.cbegin(), ops.cend(), [](const std::shared_ptr<ov::Node>& node) {return ov::is_type<ov::op::v0::MatMul>(node);});- if (mm_it == ops.end())+ if (mm_it == ops.end()) {return nullptr;+ }- const auto matmul0 = *mm_it;+ const auto& matmul0 = *mm_it;return is_supported_matmul(matmul0) ? ov::as_type_ptr<ov::op::v0::MatMul>(matmul0) : nullptr;}@@ -167,28 +204,33 @@ bool SplitDimensionM::split(const ov::Shape& shape,batch_dim = std::accumulate(shape.rbegin() + 2, shape.rend(), batch_dim, std::multiplies<>()); // B (batch)}const auto m_dim = get_dim_M(shape); // M- if (is_prime_number(m_dim))+ if (is_prime_number(m_dim)) {return false;+ }// We skip optimization if the current batch is optimal for concurrency- if (batch_dim % optimal_parallelism_work_amount == 0)+ if (batch_dim % optimal_parallelism_work_amount == 0) {return false;+ }auto split_is_done = [&batch_m_dim]() {return batch_m_dim != 1;};std::tie(batch_m_dim, new_m_dim) = split_ideally(batch_dim, m_dim, optimal_parallelism_work_amount);- if (split_is_done())+ if (split_is_done()) {return true;+ }std::tie(batch_m_dim, new_m_dim) = split_minimize_kernel_wa(batch_dim, m_dim, optimal_parallelism_work_amount);- if (split_is_done())+ if (split_is_done()) {return true;+ }// If all the previous heuristics failed, fallback heuristic is used, which reflects the old splitting behavior- if (batch_dim < optimal_parallelism_work_amount)+ if (batch_dim < optimal_parallelism_work_amount) {std::tie(batch_m_dim, new_m_dim) =split_fallback_increase_parallel_wa(batch_dim, m_dim, optimal_parallelism_work_amount);+ }return split_is_done();}@@ -245,13 +287,15 @@ void SplitDimensionM::reshape_subgraph(const std::shared_ptr<op::Subgraph>& subgauto reshape_parameter = [&](const std::shared_ptr<ov::Node>& node, bool split_m_dim = true) {const auto param = ov::as_type_ptr<ov::op::v0::Parameter>(node);- if (!param || reshaped_params.count(param) > 0)+ if (!param || reshaped_params.count(param) > 0) {return;+ }const auto shape = param->get_partial_shape().get_shape();// if the index of dimension M is equal or greater than Shape rank, no need to reshape it.- if (shape.size() <= dim_M_index)+ if (shape.size() <= dim_M_index) {return;+ }const auto consumers = param->get_output_target_inputs(0);const auto shared_consumer = consumers.begin()->get_node()->shared_from_this();@@ -301,8 +345,9 @@ void SplitDimensionM::reshape_subgraph(const std::shared_ptr<op::Subgraph>& subg// Secondly, Update All M dimensions for remaining parametersfor (const auto& param : parameters) {- if (reshaped_params.count(param) == 0)+ if (reshaped_params.count(param) == 0) {reshape_parameter(param, true);+ }}// Update Transpose order on Result@@ -316,8 +361,9 @@ void SplitDimensionM::reshape_subgraph(const std::shared_ptr<op::Subgraph>& subg// Return the previous shape on outputsfor (size_t i = 0; i < subgraph->get_output_size(); ++i) {const auto output_shape = subgraph->get_output_shape(i);- if (is_scalar(output_shape))+ if (is_scalar(output_shape)) {continue;+ }const auto& target_inputs = subgraph->get_output_target_inputs(i);const auto shape_const =@@ -351,28 +397,29 @@ bool SplitDimensionM::run_on_subgraph(const std::shared_ptr<op::Subgraph>& subgr// - 2nd and 3rd dimensions are used in kernel// It's needed only for MHA patterns. Need to add support for common patterns- if (!subgraph->has_domain_sensitive_ops())+ if (!subgraph->has_domain_sensitive_ops()) {return false;+ }// The pass supports only static shapes on Subgraph inputs due to static `Reshape` insertion around Subgraph.const auto& params = subgraph->body_ptr()->get_parameters();const auto is_dynamic = [](const std::shared_ptr<ov::Node>& p) {return p->get_output_partial_shape(0).is_dynamic();};- if (std::any_of(params.cbegin(), params.cend(), is_dynamic))+ if (std::any_of(params.cbegin(), params.cend(), is_dynamic)) {return false;+ }if (const auto matmul0 = get_matmul(subgraph)) {const auto mm_shape = matmul0->get_shape();- size_t batch_m_dim, new_m_dim;- if (!split(mm_shape, m_concurrency, batch_m_dim, new_m_dim))+ size_t batch_m_dim = 0, new_m_dim = 0;+ if (!split(mm_shape, m_concurrency, batch_m_dim, new_m_dim)) {return false;+ }reshape_subgraph(subgraph, mm_shape, batch_m_dim, new_m_dim);return true;}return false;}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/src/pass/subgraph_manager.cpp b/src/common/snippets/src/pass/subgraph_manager.cppindex 8a31a117c76..10cd5970ca0 100644--- a/src/common/snippets/src/pass/subgraph_manager.cpp+++ b/src/common/snippets/src/pass/subgraph_manager.cpp@@ -4,11 +4,14 @@#include "snippets/pass/subgraph_manager.hpp"-namespace ov {-namespace snippets {-namespace pass {+#include <memory>-bool CommonOptimizations::SubgraphManager::run_passes(std::shared_ptr<ov::snippets::op::Subgraph> subgraph) {+#include "snippets/op/subgraph.hpp"+#include "snippets/pass/common_optimizations.hpp"++namespace ov::snippets::pass {++bool CommonOptimizations::SubgraphManager::run_passes(const std::shared_ptr<ov::snippets::op::Subgraph>& subgraph) {bool updated = false;for (const auto& pass : m_pass_list) {updated = pass->run_on_subgraph(subgraph) || updated;@@ -16,6 +19,4 @@ bool CommonOptimizations::SubgraphManager::run_passes(std::shared_ptr<ov::snippereturn updated;}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/src/pass/tokenization.cpp b/src/common/snippets/src/pass/tokenization.cppindex 0643939ea00..5dc1bb0667d 100644--- a/src/common/snippets/src/pass/tokenization.cpp+++ b/src/common/snippets/src/pass/tokenization.cpp@@ -4,9 +4,16 @@#include "snippets/pass/tokenization.hpp"+#include <cstdint>+#include <memory>++#include "openvino/core/except.hpp"+#include "openvino/core/model.hpp"+#include "openvino/core/node.hpp"#include "openvino/pass/graph_rewrite.hpp"#include "openvino/pass/manager.hpp"#include "snippets/itt.hpp"+#include "snippets/op/subgraph.hpp"#include "snippets/pass/collapse_subgraph.hpp"#include "snippets/pass/common_optimizations.hpp"#include "snippets/pass/extract_reshapes_from_mha.hpp"@@ -16,9 +23,7 @@#include "snippets/pass/mha_tokenization.hpp"#include "snippets/pass/mlp_seq_tokenization.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {void SetSnippetsNodeType(const std::shared_ptr<Node>& node, SnippetsNodeType nodeType) {auto& rt = node->get_rt_info();@@ -34,21 +39,24 @@ void SetSnippetsSubgraphType(const std::shared_ptr<op::Subgraph>& node, SnippetsSnippetsNodeType GetSnippetsNodeType(const std::shared_ptr<const Node>& node) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::GetSnippetsNodeType")- auto& rt = node->get_rt_info();+ const auto& rt = node->get_rt_info();const auto rinfo = rt.find("SnippetsNodeType");- if (rinfo == rt.end())+ if (rinfo == rt.end()) {return SnippetsNodeType::NotSet;+ }return rinfo->second.as<SnippetsNodeType>();}SnippetsSubgraphType GetSnippetsSubgraphType(const std::shared_ptr<const op::Subgraph>& node) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::GetSnippetsSubgraphType")- if (!node)+ if (!node) {return SnippetsSubgraphType::NotSet;- auto& rt = node->get_rt_info();+ }+ const auto& rt = node->get_rt_info();const auto rinfo = rt.find("SnippetsSubgraphType");- if (rinfo == rt.end())+ if (rinfo == rt.end()) {return SnippetsSubgraphType::NotSet;+ }return rinfo->second.as<SnippetsSubgraphType>();}@@ -59,10 +67,11 @@ void SetTopologicalOrder(const std::shared_ptr<Node>& node, int64_t order) {}int64_t GetTopologicalOrder(const std::shared_ptr<const Node>& node) {- auto& rt = node->get_rt_info();+ const auto& rt = node->get_rt_info();const auto rinfo = rt.find("TopologicalOrder");- if (rinfo == rt.end())+ if (rinfo == rt.end()) {OPENVINO_THROW("Topological order is required, but not set.");+ }return rinfo->second.as<int64_t>();}@@ -103,6 +112,4 @@ bool SnippetsTokenization::run_on_model(const std::shared_ptr<ov::Model>& m) {return false;}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/src/pass/transform_convert.cpp b/src/common/snippets/src/pass/transform_convert.cppindex 7ddbb0158e3..13de8ecdcee 100644--- a/src/common/snippets/src/pass/transform_convert.cpp+++ b/src/common/snippets/src/pass/transform_convert.cpp@@ -4,10 +4,20 @@#include "snippets/pass/transform_convert.hpp"+#include <memory>++#include "openvino/core/except.hpp"+#include "openvino/core/graph_util.hpp"+#include "openvino/core/node.hpp"#include "openvino/core/rt_info.hpp"+#include "openvino/core/type.hpp"+#include "openvino/opsets/opset1.hpp"+#include "openvino/pass/pattern/matcher.hpp"+#include "openvino/pass/pattern/op/label.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"#include "snippets/itt.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/op/convert_saturation.hpp"+#include "snippets/op/convert_truncation.hpp"ov::snippets::pass::TransformConvertToConvertTruncation::TransformConvertToConvertTruncation() {MATCHER_SCOPE(TransformConvertToConvertTruncation);diff --git a/src/common/snippets/src/pass/transpose_decomposition.cpp b/src/common/snippets/src/pass/transpose_decomposition.cppindex 4fb9af61bd6..762bf966725 100644--- a/src/common/snippets/src/pass/transpose_decomposition.cpp+++ b/src/common/snippets/src/pass/transpose_decomposition.cpp@@ -4,31 +4,46 @@#include "snippets/pass/transpose_decomposition.hpp"+#include <cstddef>+#include <cstdint>+#include <memory>+#include <vector>++#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/type.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/parameter.hpp"+#include "openvino/opsets/opset1.hpp"+#include "openvino/pass/matcher_pass.hpp"+#include "openvino/pass/pattern/matcher.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"+#include "openvino/util/pp.hpp"#include "snippets/itt.hpp"#include "snippets/lowered/port_descriptor.hpp"-#include "snippets/snippets_isa.hpp"-#include "transformations/utils/utils.hpp"+#include "snippets/op/load.hpp"+#include "snippets/op/store.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {using namespace lowered;bool TransposeDecomposition::is_supported_transpose(const Output<Node>& transpose_out) {const auto transpose = ov::as_type_ptr<const ov::opset1::Transpose>(transpose_out.get_node_shared_ptr());- if (!transpose)+ if (!transpose) {return false;+ }const auto order = ov::as_type_ptr<const ov::opset1::Constant>(transpose->get_input_node_shared_ptr(1));- if (!order)+ if (!order) {return false;+ }return is_supported_transpose_order(order->cast_vector<int32_t>());}bool TransposeDecomposition::is_supported_transpose_order(const std::vector<int32_t>& order) {const auto size = order.size();- if (size > 0)+ if (size > 0) {return order.back() != static_cast<int32_t>(size - 1);+ }return true;}@@ -51,12 +66,14 @@ TransposeDecomposition::TransposeDecomposition() {const auto order =ov::as_type_ptr<ov::op::v0::Constant>(pattern_to_output.at(match_order).get_node_shared_ptr());- if (transformation_callback(transpose))+ if (transformation_callback(transpose)) {return false;+ }auto order_value = order->cast_vector<int>();- if (!is_supported_transpose_order(order_value))+ if (!is_supported_transpose_order(order_value)) {return false;+ }// number of elements that can be processed on every iteration. For 0,1,2,3 -> 0,2,3,1 we can guarantee only// scalar access@@ -73,7 +90,7 @@ TransposeDecomposition::TransposeDecomposition() {PortDescriptorUtils::set_port_descriptor(store->input(0), subtensor);PortDescriptorUtils::set_port_descriptor(store->output(0), subtensor);- for (auto& input : transpose->output(0).get_target_inputs()) {+ for (const auto& input : transpose->output(0).get_target_inputs()) {input.replace_source_output(store->output(0));}@@ -84,6 +101,4 @@ TransposeDecomposition::TransposeDecomposition() {register_matcher(m, callback);}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/src/pass/validate.cpp b/src/common/snippets/src/pass/validate.cppindex 65489c41f38..5cd286f97b3 100644--- a/src/common/snippets/src/pass/validate.cpp+++ b/src/common/snippets/src/pass/validate.cpp@@ -4,11 +4,26 @@#include "snippets/pass/validate.hpp"+#include <algorithm>+#include <cstdint>+#include <memory>+#include <string>++#include "openvino/core/except.hpp"+#include "openvino/core/model.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_input.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/core/type.hpp"#include "openvino/core/validation_util.hpp"#include "openvino/op/broadcast.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/convert.hpp"#include "openvino/op/fake_quantize.hpp"#include "openvino/op/matmul.hpp"+#include "openvino/op/parameter.hpp"#include "openvino/op/reshape.hpp"+#include "openvino/op/result.hpp"#include "openvino/op/softmax.hpp"#include "openvino/op/transpose.hpp"#include "snippets/itt.hpp"@@ -18,16 +33,14 @@#include "snippets/pass/fq_decomposition.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace pass {+namespace ov::snippets::pass {namespace {-#define VALIDATE(op, op_type, validator) \- if (ov::is_type<op_type>(op)) \- OPENVINO_ASSERT(validator(op), \- "Snippets validation of OV body has been failed: " + std::string(op->get_type_name()) + \- " op " + op->get_friendly_name() + " is not supported"); \+#define VALIDATE(op, op_type, validator) \+ if (ov::is_type<op_type>(op)) \+ OPENVINO_ASSERT(validator(op), \+ "Snippets validation of OV body has been failed: " + std::string((op)->get_type_name()) + \+ " op " + (op)->get_friendly_name() + " is not supported"); \else} // namespace@@ -68,7 +81,7 @@ bool Validate::is_supported_softmax(const std::shared_ptr<const ov::Node>& op) {return axis == softmax_rank.get_length() - 1;}-bool Validate::is_supported_fq(const std::shared_ptr<const ov::Node>& node) {+bool Validate::is_supported_fq([[maybe_unused]] const std::shared_ptr<const ov::Node>& node) {// FQ is decomposed into ops in CommonFakeQuantizeDecomposition passreturn m_pass_config->is_disabled<ov::snippets::pass::CommonFakeQuantizeDecomposition>();}@@ -80,7 +93,7 @@ bool Validate::is_supported_transpose(const std::shared_ptr<const ov::Node>& nod(consumers.size() == 1 && ov::is_type<ov::op::v0::Result>(consumers.cbegin()->get_node()));}-bool Validate::is_supported_op(const std::shared_ptr<const ov::Node>& node) {+bool Validate::is_supported_op([[maybe_unused]] const std::shared_ptr<const ov::Node>& node) {return false;}@@ -101,6 +114,4 @@ bool Validate::run_on_model(const std::shared_ptr<ov::Model>& m) {return true;}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::passdiff --git a/src/common/snippets/src/runtime_configurator.cpp b/src/common/snippets/src/runtime_configurator.cppindex f6ced32c674..8e8c4e819c0 100644--- a/src/common/snippets/src/runtime_configurator.cpp+++ b/src/common/snippets/src/runtime_configurator.cpp@@ -4,18 +4,37 @@#include "snippets/runtime_configurator.hpp"-#include "snippets/lowered/pass/compute_buffer_allocation_size.hpp"-#include "snippets/lowered/pass/init_loops.hpp"+#include <algorithm>+#include <cstddef>+#include <cstdint>+#include <map>+#include <memory>+#include <set>+#include <sstream>+#include <string>+#include <utility>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"+#include "snippets/kernel_executor_table.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/expressions/buffer_expression.hpp"+#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/loop_info.hpp"#include "snippets/lowered/pass/insert_specific_iterations.hpp"#include "snippets/lowered/pass/mha_parallel_wa_optimizer.hpp"+#include "snippets/lowered/pass/runtime_optimizer.hpp"#include "snippets/lowered/pass/solve_buffer_memory.hpp"-#include "snippets/pass/split_dimension_m.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/lowered/port_descriptor.hpp"+#include "snippets/op/memory_access.hpp"+#include "snippets/op/reorder.hpp"#include "snippets/utils/loop_utils.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {+namespace ov::snippets {using namespace ov::snippets::pass;using namespace ov::snippets::lowered;@@ -30,14 +49,16 @@ std::string RuntimeConfig::to_string() const {<< "master_shape: " << ov::Shape(master_shape) << "\n";out << "io_data_offsets: "<< "\n";- for (size_t i = 0; i < io_data_offsets.size(); ++i)+ for (size_t i = 0; i < io_data_offsets.size(); ++i) {out << "\t[" << i << "]" << ov::Shape(io_data_offsets[i]) << "\n";+ }out << "buffer_scratchpad_size: " << buffer_scratchpad_size << "\n";out << "buffer_cluster_offsets: "<< "\n";- for (size_t i = 0; i < buffer_cluster_offsets.size(); ++i)+ for (size_t i = 0; i < buffer_cluster_offsets.size(); ++i) {out << "buffer_cluster_offsets: "<< "\n";+ }return out.str();}#endif@@ -52,8 +73,9 @@ void RuntimeConfigurator::reset_kernel_executor_table() const {const std::shared_ptr<RuntimeConfig>& RuntimeConfigurator::get_updated_config(const lowered::LinearIRCPtr& linear_ir) {// First initialization- if (m_io_num == 0)+ if (m_io_num == 0) {initialization(linear_ir);+ }update(linear_ir);// Note: after 'update' is finished, io_shapes can be corrupted, so we move it to latest_shapes to avoid copying@@ -78,8 +100,9 @@ void RuntimeConfigurator::update(const lowered::LinearIRCPtr& linear_ir) {m_config->master_shape = linear_ir->get_master_shape();m_config->io_shapes = extract_shapes();m_config->io_layouts = extract_layouts();- if (linear_ir->is_dynamic())+ if (linear_ir->is_dynamic()) {update_loop_info(linear_ir);+ }m_intermediate_optimizers.run(*linear_ir);@@ -184,7 +207,7 @@ void RuntimeConfigurator::init_buffer_info(const lowered::LinearIRCPtr& linear_iconst auto& cluster_id = p.first;const auto& cluster = p.second;- OPENVINO_ASSERT(cluster.size() > 0, "Incorrect size of buffer cluster");+ OPENVINO_ASSERT(!cluster.empty(), "Incorrect size of buffer cluster");size_t cluster_offset = (*cluster.cbegin())->get_offset();m_config->buffer_cluster_offsets[cluster_id] = cluster_offset;}@@ -210,8 +233,9 @@ void RuntimeConfigurator::update_expanded_loop_info(const lowered::ExpandedLoopIdecomposed_loop_type,current_work_amount)) {expanded_loop_info->set_work_amount(0);- if (expanded_loop_info->is_evaluate_once())+ if (expanded_loop_info->is_evaluate_once()) {expanded_loop_info->set_increment(0);+ }return;}@@ -229,8 +253,9 @@ void RuntimeConfigurator::update_expanded_loop_info(const lowered::ExpandedLoopIif (expanded_loop_info->is_evaluate_once()) {expanded_loop_info->set_increment(work_amount);// work_amount is equal to increment in cases with `evaluate_once`- for (size_t i = 0; i < updated_finalization_offsets.size(); ++i)+ for (size_t i = 0; i < updated_finalization_offsets.size(); ++i) {updated_finalization_offsets[i] += ptr_increments[i] * work_amount;+ }} else {expanded_loop_info->update_ptr_increments(ptr_increments);}@@ -283,8 +308,9 @@ void RuntimeConfigurator::update_buffer_scratchpad_size(const lowered::LinearIRCfor (const auto& buffer_expr : cluster) {// No need to calculate allocation size of Buffers which are in Loops with `work_amount = 0` - they won't be// executed- if (is_not_executed(buffer_expr))+ if (is_not_executed(buffer_expr)) {continue;+ }buffer_expr->init_allocation_size(loop_manager, m_config->tile_rank);const auto& allocation_size = buffer_expr->get_allocation_size();OPENVINO_ASSERT(!utils::is_dynamic_value(allocation_size), "Buffer scratchpad size must be defined!");@@ -320,10 +346,12 @@ void RuntimeConfigurator::update_data_offsets() const {// offsets: s1*s3, s3, 0, 1const auto& shape = shapes[i];OPENVINO_ASSERT(m_config->tensor_rank >= shape.size(), "Incorrect tensor rank!");- if (shape == m_config->latest_shapes[i])+ if (shape == m_config->latest_shapes[i]) {continue;- if (utils::is_dynamic_vdims(shape))+ }+ if (utils::is_dynamic_vdims(shape)) {return;+ }const auto idx_stride = m_config->tensor_rank - shape.size();compute_offsets(shape, i, idx_stride);@@ -345,15 +373,17 @@ void RuntimeConfigurator::update_data_offsets() const {std::vector<VectorDims> RuntimeConfigurator::extract_shapes() const {std::vector<VectorDims> shapes(m_io_num);- for (size_t i = 0; i < m_io_num; ++i)+ for (size_t i = 0; i < m_io_num; ++i) {shapes[i] = m_io_descs[i]->get_shape();+ }return shapes;}std::vector<std::vector<size_t>> RuntimeConfigurator::extract_layouts() const {std::vector<std::vector<size_t>> layouts(m_io_num);- for (size_t i = 0; i < m_io_num; ++i)+ for (size_t i = 0; i < m_io_num; ++i) {layouts[i] = m_io_descs[i]->get_layout();+ }return layouts;}@@ -382,5 +412,4 @@ RuntimeConfigurator::UnifiedLoopInfoRtParams RuntimeConfigurator::get_loop_runti});return rt_params;}-} // namespace snippets-} // namespace ov+} // namespace ov::snippetsdiff --git a/src/common/snippets/src/shape_inference/shape_infer_instances.cpp b/src/common/snippets/src/shape_inference/shape_infer_instances.cppindex a52ba87b887..91d0bf06ed2 100644--- a/src/common/snippets/src/shape_inference/shape_infer_instances.cpp+++ b/src/common/snippets/src/shape_inference/shape_infer_instances.cpp@@ -3,11 +3,27 @@//#include "snippets/shape_inference/shape_infer_instances.hpp"+#include <algorithm>+#include <cstddef>+#include <cstdint>+#include <memory>+#include <type_traits>+#include <utility>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"#include "openvino/op/select.hpp"-#include "snippets/snippets_isa.hpp"+#include "openvino/op/util/attr_types.hpp"+#include "snippets/lowered/port_descriptor.hpp"+#include "snippets/op/broadcastload.hpp"+#include "snippets/op/broadcastmove.hpp"+#include "snippets/op/reduce.hpp"+#include "snippets/shape_inference/shape_inference.hpp"+#include "snippets/shape_types.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {++namespace ov::snippets {using Result = IShapeInferSnippets::Result;/** Merge SRC to DST with broadcasting rules defined by the Autobroadcast specifier@@ -33,18 +49,21 @@ bool broadcast_merge_into(VectorDims& dst, const VectorDims& src, const ov::op::}case ov::op::AutoBroadcastType::PDPD: {int64_t axis = autob.m_axis;- if (src_rank > dst_rank || axis < -1)+ if (src_rank > dst_rank || axis < -1) {return false;+ }axis = (axis == -1) ? (dst_rank - src_rank) : axis;- if (src_rank + axis > dst_rank)+ if (src_rank + axis > dst_rank) {return false;+ }bool success = true;for (int64_t i = 0; i < src_rank; ++i) {if (!utils::is_dynamic_value(dst[axis + i]) && !utils::is_dynamic_value(src[i])) {- if (src[i] > dst[axis + i])+ if (src[i] > dst[axis + i]) {return false;+ }}success &= utils::broadcast_merge_dim(dst[axis + i], dst[axis + i], src[i]);}@@ -69,12 +88,14 @@ bool merge_into(VectorDims& dst, const VectorDims& src) {}return true;};- if (dst.size() != src.size())+ if (dst.size() != src.size()) {return false;+ }bool success = true;- for (size_t i = 0; i < dst.size(); i++)+ for (size_t i = 0; i < dst.size(); i++) {success &= merge_dim(dst[i], dst[i], src[i]);+ }return success;}@@ -89,11 +110,12 @@ Result NumpyBroadcastShapeInfer::infer(const std::vector<VectorDimsRef>& input_s}template <class BroadcastOP>-BroadcastShapeInfer<BroadcastOP>::BroadcastShapeInfer(const std::shared_ptr<Node>& n) {+BroadcastShapeInfer<BroadcastOP>::BroadcastShapeInfer(const std::shared_ptr<Node>& n)+ : broadcast_op(as_type_ptr<BroadcastOP>(n)) {static_assert(std::is_base_of<snippets::op::BroadcastMove, BroadcastOP>() ||std::is_base_of<snippets::op::BroadcastLoad, BroadcastOP>(),"This ShapeInfer class could be used only for BroadcastMove and BroadcastLoad operations.");- broadcast_op = as_type_ptr<BroadcastOP>(n);+OPENVINO_ASSERT(broadcast_op,"Invalid node passed to BroadcastShapeInfer.","Expected ",@@ -151,8 +173,9 @@ Result SelectShapeInfer::infer(const std::vector<VectorDimsRef>& input_shapes) {Result HorizonOpShapeInfer::infer(const std::vector<VectorDimsRef>& input_shapes) {OPENVINO_ASSERT(input_shapes.size() == 1, "Got invalid number of input shapes in HorizonShapeInfer");auto output_shapes = input_shapes[0].get();- if (!output_shapes.empty())+ if (!output_shapes.empty()) {output_shapes.back() = 1;+ }return {{output_shapes}, ShapeInferStatus::success};}@@ -196,21 +219,23 @@ Result BrgemmShapeInfer::infer(const std::vector<VectorDimsRef>& input_shapes) {}// add 1 to begin to align shape ranks if needed- if (arg0_rank < arg1_rank)+ if (arg0_rank < arg1_rank) {arg0_shape_tmp.insert(arg0_shape_tmp.begin(), arg1_rank - arg0_rank, 1);- else if (arg0_rank > arg1_rank)+ } else if (arg0_rank > arg1_rank) {arg1_shape_tmp.insert(arg1_shape_tmp.begin(), arg0_rank - arg1_rank, 1);+ }size_t max_rank = arg0_shape_tmp.size();VectorDims output_shape(max_rank);for (size_t i = 0; i < max_rank - 2; ++i) {- if (!utils::broadcast_merge_dim(output_shape[i], arg0_shape_tmp[i], arg1_shape_tmp[i]))+ if (!utils::broadcast_merge_dim(output_shape[i], arg0_shape_tmp[i], arg1_shape_tmp[i])) {OPENVINO_THROW("Incompatible MatMul batch dimension. Can't merge dim ",arg0_shape_tmp[i]," with dim ",arg1_shape_tmp[i]," at index=",i);+ }}output_shape[output_shape.size() - 2] = arg0_shape_tmp[arg0_shape_tmp.size() - 2]; // Moutput_shape[output_shape.size() - 1] = arg1_shape_tmp[arg1_shape_tmp.size() - 1]; // N@@ -239,5 +264,4 @@ Result ReduceShapeInfer::infer(const std::vector<VectorDimsRef>& input_shapes) {return {{result_shape}, ShapeInferStatus::success};}-} // namespace snippets-} // namespace ov+} // namespace ov::snippetsdiff --git a/src/common/snippets/src/shape_inference/shape_inference.cpp b/src/common/snippets/src/shape_inference/shape_inference.cppindex b0c2e5382ca..f312a869ce0 100644--- a/src/common/snippets/src/shape_inference/shape_inference.cpp+++ b/src/common/snippets/src/shape_inference/shape_inference.cpp@@ -3,37 +3,67 @@//#include "snippets/shape_inference/shape_inference.hpp"+#include <memory>#include <openvino/op/parameter.hpp>#include <openvino/op/result.hpp>#include <openvino/op/util/binary_elementwise_arithmetic.hpp>#include <openvino/op/util/binary_elementwise_comparison.hpp>#include <openvino/op/util/binary_elementwise_logical.hpp>#include <openvino/op/util/unary_elementwise_arithmetic.hpp>-#include <snippets/snippets_isa.hpp>+#include <string>+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/type.hpp"+#include "openvino/op/logical_not.hpp"+#include "openvino/op/prelu.hpp"+#include "openvino/opsets/opset1.hpp"+#include "snippets/op/brgemm.hpp"+#include "snippets/op/broadcastload.hpp"+#include "snippets/op/broadcastmove.hpp"+#include "snippets/op/buffer.hpp"+#include "snippets/op/convert_saturation.hpp"+#include "snippets/op/convert_truncation.hpp"+#include "snippets/op/fill.hpp"+#include "snippets/op/horizon_max.hpp"+#include "snippets/op/horizon_sum.hpp"+#include "snippets/op/kernel.hpp"+#include "snippets/op/load.hpp"+#include "snippets/op/loop.hpp"+#include "snippets/op/nop.hpp"+#include "snippets/op/perf_count.hpp"+#include "snippets/op/rank_normalization.hpp"+#include "snippets/op/reduce.hpp"+#include "snippets/op/reg_spill.hpp"+#include "snippets/op/reorder.hpp"+#include "snippets/op/reshape.hpp"+#include "snippets/op/scalar.hpp"+#include "snippets/op/store.hpp"+#include "snippets/op/vector_buffer.hpp"#include "snippets/shape_inference/shape_infer_instances.hpp"-namespace ov {-namespace snippets {+namespace ov::snippets {using ShapeInferPtr = IShapeInferSnippetsFactory::ShapeInferPtr;ShapeInferPtr IShapeInferSnippetsFactory::make(const ov::DiscreteTypeInfo& key, const std::shared_ptr<ov::Node>& op) {const auto& maker_iter = registry.find(key);- if (maker_iter != registry.end())+ if (maker_iter != registry.end()) {return maker_iter->second(op);+ }return get_specific_op_shape_infer(key, op);}-ShapeInferPtr IShapeInferSnippetsFactory::get_specific_op_shape_infer(const ov::DiscreteTypeInfo& key,- const std::shared_ptr<ov::Node>& op) const {+ShapeInferPtr IShapeInferSnippetsFactory::get_specific_op_shape_infer(+ [[maybe_unused]] const ov::DiscreteTypeInfo& key,+ [[maybe_unused]] const std::shared_ptr<ov::Node>& op) const {return {};}-#define SHAPE_INFER_PREDEFINED(OP, InferType) \- { \- OP::get_type_info_static(), [](const std::shared_ptr<ov::Node>& n) { \- return std::make_shared<InferType>(); \- } \+#define SHAPE_INFER_PREDEFINED(OP, InferType) \+ { \+ OP::get_type_info_static(), []([[maybe_unused]] const std::shared_ptr<ov::Node>& n) { \+ return std::make_shared<InferType>(); \+ } \}#define SHAPE_INFER_OP_SPECIFIC(OP) \{ \@@ -96,19 +126,20 @@ std::shared_ptr<IShapeInferSnippets> make_shape_inference(const std::shared_ptr<const std::shared_ptr<IShapeInferSnippetsFactory>& factory) {if (!factory) {return nullptr;- } else if (auto shape_infer = factory->make(op->get_type_info(), op)) {+ }+ if (auto shape_infer = factory->make(op->get_type_info(), op)) {return shape_infer;- } else if (ov::is_type<ov::op::util::UnaryElementwiseArithmetic>(op)) {+ }+ if (ov::is_type<ov::op::util::UnaryElementwiseArithmetic>(op)) {return std::make_shared<PassThroughShapeInfer>();- } else if (ov::is_type_any_of<ov::op::util::BinaryElementwiseArithmetic,- ov::op::util::BinaryElementwiseComparison,- ov::op::util::BinaryElementwiseLogical>(op)) {+ }+ if (ov::is_type_any_of<ov::op::util::BinaryElementwiseArithmetic,+ ov::op::util::BinaryElementwiseComparison,+ ov::op::util::BinaryElementwiseLogical>(op)) {return std::make_shared<NumpyBroadcastShapeInfer>();- } else {- OPENVINO_THROW("Operation type " + std::string(op->get_type_info().name) +- " is not supported in Snippets shape inference pipeline");}+ OPENVINO_THROW("Operation type " + std::string(op->get_type_info().name) ++ " is not supported in Snippets shape inference pipeline");}-} // namespace snippets-} // namespace ov+} // namespace ov::snippetsdiff --git a/src/common/snippets/src/utils/debug_caps_config.cpp b/src/common/snippets/src/utils/debug_caps_config.cppindex da4ae4238a5..b43e54c48be 100644--- a/src/common/snippets/src/utils/debug_caps_config.cpp+++ b/src/common/snippets/src/utils/debug_caps_config.cpp@@ -1,12 +1,16 @@// Copyright (C) 2024 Intel Corporation// SPDX-License-Identifier: Apache-2.0//+#include <algorithm>+#include <cstdlib>++#include "openvino/core/except.hpp"+#include "openvino/util/common_util.hpp"#ifdef SNIPPETS_DEBUG_CAPS# include "snippets/utils/debug_caps_config.hpp"-namespace ov {-namespace snippets {+namespace ov::snippets {void DebugCapsConfig::readProperties() {auto readEnv = [](const char* envVar) {@@ -18,12 +22,11 @@ void DebugCapsConfig::readProperties() {return static_cast<const char*>(nullptr);};- const char* envVarValue = nullptr;- if ((envVarValue = readEnv("OV_SNIPPETS_DUMP_LIR"))) {+ if (const auto* envVarValue = readEnv("OV_SNIPPETS_DUMP_LIR")) {dumpLIR.parseAndSet(envVarValue);OPENVINO_ASSERT(!dumpLIR.passes.empty(), "Passes option in OV_SNIPPETS_DUMP_LIR must be provided.");}- if ((envVarValue = readEnv("OV_SNIPPETS_DUMP_BRGEMM_PARAMS"))) {+ if (const auto* envVarValue = readEnv("OV_SNIPPETS_DUMP_BRGEMM_PARAMS")) {dumpParams.parseAndSet(envVarValue);}}@@ -34,8 +37,9 @@ void DebugCapsConfig::PropertyGroup::parseAndSet(const std::string& str) {bool failed = false;auto getHelp = [propertySetters]() {std::string help;- for (const auto& property : propertySetters)+ for (const auto& property : propertySetters) {help.append('\t' + property->getPropertyName() + "=<" + property->getPropertyValueDescription() + ">\n");+ }return help;};@@ -61,16 +65,16 @@ void DebugCapsConfig::PropertyGroup::parseAndSet(const std::string& str) {}}- if (failed)+ if (failed) {OPENVINO_THROW("Wrong syntax: ",str,"\n","The following space separated options are supported (option names are case insensitive):","\n",getHelp());+ }}-} // namespace snippets-} // namespace ov+} // namespace ov::snippets#endif // SNIPPETS_DEBUG_CAPSdiff --git a/src/common/snippets/src/utils/loop_utils.cpp b/src/common/snippets/src/utils/loop_utils.cppindex 9f1159be246..58ae7d7b260 100644--- a/src/common/snippets/src/utils/loop_utils.cpp+++ b/src/common/snippets/src/utils/loop_utils.cpp@@ -4,17 +4,25 @@#include "snippets/utils/loop_utils.hpp"+#include <algorithm>+#include <cstddef>+#include <cstdint>++#include "openvino/core/except.hpp"+#include "openvino/core/type.hpp"+#include "snippets/lowered/expression_port.hpp"+#include "snippets/lowered/loop_info.hpp"+#include "snippets/lowered/loop_port.hpp"#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace utils {+namespace ov::snippets::utils {using namespace ov::snippets::lowered;namespace {inline int64_t get_ptr_increment(const LoopPort& loop_port, size_t work_amount, size_t port_count) {- if (!loop_port.is_incremented())+ if (!loop_port.is_incremented()) {return 0;+ }const auto& expr_port = loop_port.get_expr_port();const auto& layout = expr_port->get_descriptor_ptr()->get_layout();@@ -30,17 +38,20 @@ inline int64_t get_ptr_increment(const LoopPort& loop_port, size_t work_amount,// When we cannot say about broadcastingif (is_dynamic_value(shape[dim]) && port_count > 1) {return get_dynamic_value<int64_t>();- } else if (!(shape[dim] == 1 && work_amount != 1)) {+ }+ if (!(shape[dim] == 1 && work_amount != 1)) {return get_stride(dim, shape);}return 0;}inline int64_t get_finalization_offset(size_t work_amount, int64_t ptr_increment) {- if (ptr_increment == 0 || work_amount == 0)+ if (ptr_increment == 0 || work_amount == 0) {return 0;- if (is_dynamic_value(work_amount) || is_dynamic_value(ptr_increment))+ }+ if (is_dynamic_value(work_amount) || is_dynamic_value(ptr_increment)) {return get_dynamic_value<int64_t>();+ }return -1 * ptr_increment * work_amount;}@@ -81,8 +92,9 @@ void update_data_pointer_shifts(const UnifiedLoopInfoPtr& loop_info) {void update_runtime_parameters(const UnifiedLoopInfoPtr& loop_info) {OPENVINO_ASSERT(loop_info != nullptr, "UnifiedLoopInfo is nullptr, nothing to update");- if (!ov::is_type<InnerSplittedUnifiedLoopInfo>(loop_info))+ if (!ov::is_type<InnerSplittedUnifiedLoopInfo>(loop_info)) {init_work_amount(loop_info);+ }update_data_pointer_shifts(loop_info);}@@ -94,6 +106,4 @@ bool should_be_loop_port(const ov::snippets::lowered::ExpressionPort& port, size});}-} // namespace utils-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace ov::snippets::utilsdiff --git a/src/common/snippets/src/utils/tokenization_utils.cpp b/src/common/snippets/src/utils/tokenization_utils.cppindex 9e5ace1730d..7f98ddebe9d 100644--- a/src/common/snippets/src/utils/tokenization_utils.cpp+++ b/src/common/snippets/src/utils/tokenization_utils.cpp@@ -4,21 +4,51 @@#include "snippets/utils/tokenization_utils.hpp"+#include <algorithm>#include <cassert>#include <climits>-+#include <cstddef>+#include <cstdint>+#include <map>+#include <memory>+#include <numeric>+#include <ostream>+#include <set>+#include <string>+#include <unordered_set>+#include <utility>+#include <vector>++#include "openvino/core/except.hpp"+#include "openvino/core/graph_util.hpp"+#include "openvino/core/model.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/core/partial_shape.hpp"+#include "openvino/core/rt_info.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/core/type.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/fake_quantize.hpp"+#include "openvino/op/parameter.hpp"+#include "openvino/op/result.hpp"+#include "openvino/op/util/attr_types.hpp"+#include "openvino/opsets/opset1.hpp"+#include "snippets/op/subgraph.hpp"+#include "snippets/pass/tokenization.hpp"#include "snippets/remarks.hpp"+#include "snippets/utils/utils.hpp"-namespace ov {-namespace snippets {-namespace utils {+namespace ov::snippets::utils {using namespace ov::snippets::op;using namespace ov::snippets::pass;namespace {auto has_result_child(const std::shared_ptr<const Node>& node) -> bool {- for (const auto& child : node->get_users()) {+ // TODO: fix segmentation fault in case of std::any_of+ for (const auto& child : node->get_users()) { // NOLINTif (ov::is_type<ov::opset1::Result>(child)) {return true;}@@ -38,8 +68,9 @@ auto get_num_result_children(const std::shared_ptr<const Node>& node) -> size_tauto outputs_are_not_broadcastable(const std::shared_ptr<const Node>& node) -> bool {const auto& outputs = node->outputs();- if (outputs.size() <= 1)+ if (outputs.size() <= 1) {return false;+ }ov::PartialShape ref_shape = outputs.front().get_partial_shape();bool success = true;for (size_t i = 1; i < outputs.size() && success; i++) {@@ -69,7 +100,7 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokeniza};auto abort = [&](const std::string& message) {- remark(3) << message << std::endl;+ remark(3) << message << '\n';create_single_node_subgraph(node);return true;};@@ -113,9 +144,10 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokenizastd::accumulate(parentNodes.begin(),parentNodes.end(),currentBounds.first,- [](int64_t maxOrder, std::shared_ptr<Node> n) {- if (ov::is_type_any_of<ov::op::v0::Constant, ov::op::v0::Parameter>(n))+ [](int64_t maxOrder, const std::shared_ptr<Node>& n) {+ if (ov::is_type_any_of<ov::op::v0::Constant, ov::op::v0::Parameter>(n)) {return maxOrder;+ }return std::max(maxOrder, GetTopologicalOrder(n));});const auto& childNodes = nodeToExamine->get_users();@@ -123,9 +155,10 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokenizaconst int64_t minChildOrder = std::accumulate(childNodes.begin(),childNodes.end(),currentBounds.second,- [&node](int64_t minOrder, std::shared_ptr<Node> n) {- if (ov::is_type<ov::op::v0::Result>(n) || n == node)+ [&node](int64_t minOrder, const std::shared_ptr<Node>& n) {+ if (ov::is_type<ov::op::v0::Result>(n) || n == node) {return minOrder;+ }return std::min(minOrder, GetTopologicalOrder(n));});if (maxParentOrder < minChildOrder) {@@ -137,7 +170,8 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokenizafor (const auto& input_node : ov::as_node_vector(input_values)) {if (auto subgraph = ov::as_type_ptr<op::Subgraph>(input_node)) {- if (!clones.count(input_node) && GetSnippetsSubgraphType(subgraph) != SnippetsSubgraphType::Completed) {+ if ((clones.count(input_node) == 0u) &&+ GetSnippetsSubgraphType(subgraph) != SnippetsSubgraphType::Completed) {auto f = subgraph->body().clone();f->set_friendly_name(subgraph->body_ptr()->get_friendly_name());clones[input_node] = f;@@ -148,7 +182,7 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokenizaif (clones.empty()) {create_single_node_subgraph(node);remark(1) << "Starting subgraph at: " << node->get_friendly_name() << " with " << node->inputs().size()- << " inputs and " << node->outputs().size() << " outputs" << std::endl;+ << " inputs and " << node->outputs().size() << " outputs" << '\n';return true;}std::string subgraph_name = node->get_friendly_name();@@ -199,7 +233,7 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokenizaif (current_input_index < body_parameters.size()) {remark(13) << "replacing " << *found << " " << current_input_index << " with "- << body_parameters[current_input_index] << std::endl;+ << body_parameters[current_input_index] << '\n';f->replace_parameter(i, body_parameters[current_input_index]);} else {external_inputs.push_back(subgraph->input_value(i));@@ -207,7 +241,7 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokeniza}} else if (is_recurrent(subgraph->input_value(i))) {remark(13) << "ternary merge is conducted " << subgraph->input_value(i).get_node_shared_ptr()- << std::endl;+ << '\n';auto internal = input_body_parameters[i];auto internal_consumers = internal->outputs();@@ -216,9 +250,10 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokeniza// todo: In principle, we can still attach the node to the subgraph if cyclic dependency is// introduced during ternary merge.// Need to support.- if (cyclicDependencyIsIntoduced(to_replace_with, currentTopoBounds))+ if (cyclicDependencyIsIntoduced(to_replace_with, currentTopoBounds)) {return abort("Attempt to perform recurrent merge for cyclic-dependent subgraphs. Aborting.");+ }for (const auto& output : internal_consumers) {for (auto consumer : output.get_target_inputs()) {auto other_body = clones[subgraph->get_input_node_shared_ptr(i)];@@ -270,14 +305,15 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokeniza}fusedNames += node->get_friendly_name();num_result_children += get_num_result_children(node);- if (num_result_children > 1)+ if (num_result_children > 1) {return abort("New subgraph is created since too many Result children are detected");+ }auto body_node = node->copy_with_new_inputs(internal_inputs);body_node->set_friendly_name(node->get_friendly_name());remark(1) << "Original node outputs = " << node->get_output_size()- << " body node outputs = " << body_node->get_output_size() << std::endl;+ << " body node outputs = " << body_node->get_output_size() << '\n';if (node->get_output_size() != body_node->get_output_size()) {OPENVINO_THROW("original node outputs size and extracted node outputs size doesn't much");@@ -296,7 +332,7 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokenizastd::vector<std::set<Input<Node>>> subgraph_result_inputs;ov::NodeVector ops_for_buffer_count;- for (auto subgraph : input_subgraphs) {+ for (const auto& subgraph : input_subgraphs) {// we should summurize additional needed data count (non-scalar Constants and Buffers) from all input subgraphs// because we will collapse them with our node and we should get total countconst auto subgraph_ptr = ov::as_type_ptr<ov::snippets::op::Subgraph>(subgraph);@@ -309,14 +345,14 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokenizaops_for_buffer_count.insert(ops_for_buffer_count.end(), ops.begin(), ops.end());}- for (auto output : subgraph->outputs()) {+ for (const auto& output : subgraph->outputs()) {bool first_side_consumer = true;for (auto target_input : output.get_target_inputs()) {auto target_node = target_input.get_node()->shared_from_this();if (input_subgraphs.count(target_node)) {- remark(13) << "ternary merge is conducted " << subgraph << " -> " << target_node << std::endl;+ remark(13) << "ternary merge is conducted " << subgraph << " -> " << target_node << '\n';}if (!input_subgraphs.count(target_node) && target_node != node) {@@ -324,7 +360,7 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokenizaauto& input_subgraph_body = clones[subgraph];body_results.push_back(std::make_shared<ov::op::v0::Result>(input_subgraph_body->get_results()[output.get_index()]->input_value(0)));- subgraph_result_inputs.push_back({});+ subgraph_result_inputs.emplace_back();first_side_consumer = false;}@@ -343,7 +379,7 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokenizaops_for_buffer_count.push_back(node);}- for (auto output : node->outputs()) {+ for (const auto& output : node->outputs()) {body_results.push_back(std::make_shared<ov::op::v0::Result>(body_node->output(output.get_index())));subgraph_result_inputs.push_back(output.get_target_inputs());}@@ -382,8 +418,9 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokenizaOPENVINO_THROW("newly create subgraph doesn't much number of results");}- if (outputs_are_not_broadcastable(subgraph))+ if (outputs_are_not_broadcastable(subgraph)) {return abort("New subgraph is created due to outputs of a subgraph not broadcastable.");+ }for (size_t i = 0; i < subgraph->get_output_size(); ++i) {for (auto target_input : subgraph_result_inputs[i]) {@@ -446,7 +483,7 @@ std::shared_ptr<ov::snippets::op::Subgraph> tokenize_ordered_nodes(const ov::Nod} else {const auto constant_copy = constant->clone_with_new_inputs({});node->set_argument(input.get_index(), constant_copy);- body_inputs.push_back(constant_copy);+ body_inputs.emplace_back(constant_copy);}}} else if (std::find(ordered_ops.begin(), ordered_ops.end(), parent) == ordered_ops.end()) {@@ -513,6 +550,4 @@ std::shared_ptr<ov::snippets::op::Subgraph> tokenize_ordered_nodes(const ov::Nodreturn subgraph;}-} // namespace utils-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::utilsdiff --git a/src/common/snippets/src/utils/utils.cpp b/src/common/snippets/src/utils/utils.cppindex 938098c5317..0657db6b984 100644--- a/src/common/snippets/src/utils/utils.cpp+++ b/src/common/snippets/src/utils/utils.cpp@@ -4,13 +4,37 @@#include "snippets/utils/utils.hpp"-#include "openvino/core/rt_info.hpp"+#include <algorithm>+#include <cstddef>+#include <cstdint>+#include <deque>+#include <functional>+#include <memory>+#include <numeric>+#include <set>+#include <sstream>+#include <string>+#include <unordered_set>+#include <vector>++#include "openvino/core/dimension.hpp"+#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_input.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/core/partial_shape.hpp"+#include "openvino/core/shape.hpp"+#include "openvino/core/type.hpp"+#include "openvino/op/fake_quantize.hpp"+#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/expression_port.hpp"+#include "snippets/lowered/port_descriptor.hpp"+#include "snippets/op/store.hpp"#include "snippets/op/subgraph.hpp"#include "snippets/pass/fq_decomposition.hpp"+#include "snippets/shape_types.hpp"-namespace ov {-namespace snippets {-namespace utils {+namespace ov::snippets::utils {namespace {template <typename Shape>@@ -27,19 +51,23 @@ void ordered_shape(const Shape& shape, const std::vector<size_t>& layout, bool i// - If `is_forward` is True, `result shape` is ordered `shape` by `layout`// - If `is_forward` is False, `result shape` is original shape to which the `layout` was appliedov::PartialShape get_pshape(const ov::PartialShape& shape, const std::vector<size_t>& layout, bool is_forward) {- if (layout.empty())+ if (layout.empty()) {return shape;+ }ov::PartialShape reordered_shape(std::vector<Dimension>(layout.size()));- if (shape.rank().is_dynamic())+ if (shape.rank().is_dynamic()) {OPENVINO_THROW("get_reordered_planar_shape can't be called for outputs with dynamic rank");+ }const size_t rank = shape.rank().get_length();- if (layout.size() > rank)+ if (layout.size() > rank) {OPENVINO_THROW("Layout rank can't be larger than tensor rank");+ }// Note that it can be smaller though, for example tensor shape can be prepended with 1 for scheduling purposesif (std::any_of(layout.begin(), layout.end(), [=](size_t x) {return x >= rank;- }))+ })) {OPENVINO_THROW("Invalid layout detected: all layout indexes must be smaller than the tensor rank");+ }ordered_shape(shape, layout, is_forward, reordered_shape);return reordered_shape;}@@ -59,7 +87,7 @@ auto get_non_scalar_constant_count_for_fq(const std::shared_ptr<ov::op::v0::Fakeish,osc,osh);- is_optimized = out_scales.size() != 0;+ is_optimized = !out_scales.empty();}const bool only_quantized = is_optimized || (status &&@@ -93,33 +121,41 @@ auto get_non_scalar_constant_count_for_fq(const std::shared_ptr<ov::op::v0::Fake// Some of them can be scalar or non-scalar. It depends on which original 4 Constants are non-scalar// To sum it up, below conditions check all possible cases to calculate count of new generated non-scalarsif (is_optimized) {- if (il && ih)+ if (il && ih) {return 3;- else if (il || ih)- return 2;- return 0;- } else {- if (ol && il && ih)- return 6;- else if ((ol && (il || ih)) || (il && ih && oh))- return 5;- else if ((il && oh) || (ih && oh) || (il && ih))- return 4;- else if (il || ih)- return 3;- else if (ol)+ }+ if (il || ih) {return 2;- else if (oh)- return 1;+ }return 0;}+ if (ol && il && ih) {+ return 6;+ }+ if ((ol && (il || ih)) || (il && ih && oh)) {+ return 5;+ }+ if ((il && oh) || (ih && oh) || (il && ih)) {+ return 4;+ }+ if (il || ih) {+ return 3;+ }+ if (ol) {+ return 2;+ }+ if (oh) {+ return 1;+ }+ return 0;}bool broadcast_merge_dim(size_t& dst, const size_t& d1, const size_t& d2) {if (d1 == d2 || d1 == 1 || (is_dynamic_value(d1) && d2 != 1)) {dst = d2;return true;- } else if (d2 == 1 || is_dynamic_value(d2)) {+ }+ if (d2 == 1 || is_dynamic_value(d2)) {dst = d1;return true;}@@ -130,7 +166,8 @@ bool merge_dynamic_dim(size_t& dst, const size_t& d1, const size_t& d2) {if (d1 == d2 || is_dynamic_value(d1)) {dst = d2;return true;- } else if (is_dynamic_value(d2)) {+ }+ if (is_dynamic_value(d2)) {dst = d1;return true;}@@ -140,8 +177,9 @@ bool merge_dynamic_dim(size_t& dst, const size_t& d1, const size_t& d2) {VectorDims pshape_to_vdims(const PartialShape& pshape) {VectorDims result;result.reserve(pshape.size());- for (const auto& d : pshape)+ for (const auto& d : pshape) {result.push_back(dimension_to_size_t(d));+ }// Note: PartialShape could be empty which designates scalar value. However, Scalars are represented as {1} in// Snippetsreturn result.empty() ? VectorDims{1} : result;@@ -150,19 +188,21 @@ VectorDims pshape_to_vdims(const PartialShape& pshape) {ov::PartialShape vdims_to_pshape(const VectorDims& vdims) {ov::PartialShape result;result.reserve(vdims.size());- for (const auto& v : vdims)+ for (const auto& v : vdims) {result.push_back(!is_dynamic_value(v) ? Dimension(static_cast<Dimension::value_type>(v)) : Dimension());+ }return result;}size_t get_dim_idx(const lowered::ExpressionPort& port, size_t dim_idx) {const auto& layout = port.get_descriptor_ptr()->get_layout();- if (port.get_type() == lowered::ExpressionPort::Type::Input)+ if (port.get_type() == lowered::ExpressionPort::Type::Input) {return utils::get_input_dim_idx(layout, dim_idx);- else if (port.get_type() == lowered::ExpressionPort::Type::Output)+ }+ if (port.get_type() == lowered::ExpressionPort::Type::Output) {return utils::get_output_dim_idx(layout, dim_idx);- else- OPENVINO_THROW("Unsupported type of expression port");+ }+ OPENVINO_THROW("Unsupported type of expression port");return 0;}@@ -239,8 +279,8 @@ VectorDims get_projected_subtensor(const snippets::lowered::ExpressionPort& exprstd::vector<lowered::ExpressionPtr> get_first_child_shape_infer_expr_seq(const lowered::ExpressionPtr& start_expr) {auto get_first_shape_infer_expr = [](const std::set<lowered::ExpressionPort>& consumers) -> lowered::ExpressionPtr {- for (auto it = consumers.begin(); it != consumers.end(); ++it) {- auto expr = it->get_expr();+ for (const auto& consumer : consumers) {+ auto expr = consumer.get_expr();if (op::Subgraph::is_shape_infer_op(expr->get_node())) {return expr;}@@ -253,14 +293,16 @@ std::vector<lowered::ExpressionPtr> get_first_child_shape_infer_expr_seq(const l"Shape infer ops are supposed to be the only consumer.");shape_infer_exprs.push_back(start_expr);}- if (start_expr->get_output_count() == 0)+ if (start_expr->get_output_count() == 0) {return shape_infer_exprs;+ }auto output_consumers = start_expr->get_output_port_connector(0)->get_consumers();while (auto shape_infer_child = get_first_shape_infer_expr(output_consumers)) {OPENVINO_ASSERT(output_consumers.size() == 1, "Shape infer ops are supposed to be the only consumer.");shape_infer_exprs.push_back(shape_infer_child);- if (shape_infer_child->get_output_count() == 0)+ if (shape_infer_child->get_output_count() == 0) {break;+ }output_consumers = shape_infer_child->get_output_port_connector(0)->get_consumers();}return shape_infer_exprs;@@ -274,15 +316,17 @@ std::vector<lowered::ExpressionPtr> get_first_parent_shape_infer_expr_seq(const"Shape infer ops are supposed to be the only consumer.");shape_infer_exprs.push_back(current_exp);}- if (current_exp->get_input_count() == 0)+ if (current_exp->get_input_count() == 0) {return shape_infer_exprs;+ }auto input = current_exp->get_input_port_connector(0);auto first_parent = input->get_source().get_expr();while (op::Subgraph::is_shape_infer_op(first_parent->get_node())) {shape_infer_exprs.push_back(first_parent);current_exp = first_parent;- if (current_exp->get_input_count() == 0)+ if (current_exp->get_input_count() == 0) {break;+ }input = current_exp->get_input_port_connector(0);first_parent = input->get_source().get_expr();if (!ov::is_type<snippets::op::Store>(first_parent->get_node())) {@@ -296,8 +340,8 @@ std::vector<lowered::ExpressionPtr> get_first_parent_shape_infer_expr_seq(conststd::shared_ptr<ov::Node> get_leaf_node_of_first_child_shape_infer_seq(const std::shared_ptr<ov::Node>& start_node) {auto get_first_shape_infer_node = [](const std::set<ov::Input<ov::Node>>& consumers) -> std::shared_ptr<ov::Node> {- for (auto it = consumers.begin(); it != consumers.end(); ++it) {- auto node = it->get_node()->shared_from_this();+ for (const auto& consumer : consumers) {+ auto node = consumer.get_node()->shared_from_this();if (op::Subgraph::is_shape_infer_op(node)) {return node;}@@ -310,14 +354,16 @@ std::shared_ptr<ov::Node> get_leaf_node_of_first_child_shape_infer_seq(const std"Shape infer ops are supposed to be the only consumer.");leaf_node = start_node;}- if (start_node->get_output_size() == 0)+ if (start_node->get_output_size() == 0) {return leaf_node;+ }auto output_consumers = start_node->get_output_target_inputs(0);while (auto first_child = get_first_shape_infer_node(output_consumers)) {OPENVINO_ASSERT(output_consumers.size() == 1, "Shape infer ops are supposed to be the only consumer.");leaf_node = first_child;- if (leaf_node->get_output_size() == 0)+ if (leaf_node->get_output_size() == 0) {break;+ }output_consumers = leaf_node->get_output_target_inputs(0);}return leaf_node;@@ -330,15 +376,17 @@ std::shared_ptr<ov::Node> get_leaf_node_of_first_parent_shape_infer_seq(const st"Shape infer ops are supposed to be the only consumer.");leaf_node = start_node;}- if (start_node->get_input_size() == 0)+ if (start_node->get_input_size() == 0) {return leaf_node;+ }auto first_parent = start_node->get_input_node_shared_ptr(0);while (op::Subgraph::is_shape_infer_op(first_parent)) {OPENVINO_ASSERT(first_parent->input(0).get_source_output().get_target_inputs().size() == 1,"Shape infer ops are supposed to be the only consumer.");leaf_node = first_parent;- if (leaf_node->get_input_size() == 0)+ if (leaf_node->get_input_size() == 0) {break;+ }first_parent = leaf_node->get_input_node_shared_ptr(0);}return leaf_node;@@ -378,7 +426,7 @@ void init_strides(const VectorDims& shape, size_t rank, size_t data_size, size_tvoid visit_path(const lowered::ExpressionPtr& expr,std::unordered_set<lowered::ExpressionPtr>& visited,- std::function<void(lowered::ExpressionPtr)> func,+ const std::function<void(lowered::ExpressionPtr)>& func,bool visit_parent_path) {std::deque<lowered::ExpressionPtr> exprs{expr};@@ -428,6 +476,4 @@ std::string tensor2str(const VectorDims& tensor, const std::string& delimiter) {return ss.str();}-} // namespace utils-} // namespace snippets-} // namespace ov+} // namespace ov::snippets::utilsdiff --git a/src/common/snippets/tests/src/lowered/pass/buffer_allocation.cpp b/src/common/snippets/tests/src/lowered/pass/buffer_allocation.cppindex 8d1cdd8bab0..9dfc779aba4 100644--- a/src/common/snippets/tests/src/lowered/pass/buffer_allocation.cpp+++ b/src/common/snippets/tests/src/lowered/pass/buffer_allocation.cpp@@ -4,8 +4,8 @@#include "lowered/pass/buffer_allocation.hpp"-#include "openvino/opsets/opset.hpp"-#include "snippets/snippets_isa.hpp"+#include "openvino/opsets/opset1.hpp"+#include "snippets/op/buffer.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/pass/mark_loops.hpp"#include "snippets/lowered/pass/init_loops.hpp"diff --git a/src/common/snippets/tests/src/lowered/pass/extracted_loop_invariants.cpp b/src/common/snippets/tests/src/lowered/pass/extracted_loop_invariants.cppindex 966b5291ebb..6f5243ec540 100644--- a/src/common/snippets/tests/src/lowered/pass/extracted_loop_invariants.cpp+++ b/src/common/snippets/tests/src/lowered/pass/extracted_loop_invariants.cpp@@ -3,12 +3,19 @@//#include "lir_test_utils.hpp"-#include "openvino/opsets/opset10.hpp"#include "snippets/lowered/pass/extract_loop_invariants.hpp"#include "snippets/lowered/pass/normalize_loop_ids.hpp"#include "snippets/lowered/pass/split_loops.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/op/brgemm.hpp"+#include "snippets/op/broadcastmove.hpp"+#include "snippets/op/horizon_max.hpp"+#include "snippets/op/horizon_sum.hpp"+#include "snippets/op/load.hpp"+#include "snippets/op/powerstatic.hpp"+#include "snippets/op/scalar.hpp"+#include "snippets/op/store.hpp"+#include "snippets/op/vector_buffer.hpp"namespace ov {namespace test {diff --git a/src/common/snippets/tests/src/lowered/pass/loop.cpp b/src/common/snippets/tests/src/lowered/pass/loop.cppindex 20be1303d7f..8447cbe0137 100644--- a/src/common/snippets/tests/src/lowered/pass/loop.cpp+++ b/src/common/snippets/tests/src/lowered/pass/loop.cpp@@ -5,7 +5,6 @@#include <gtest/gtest.h>#include "openvino/opsets/opset10.hpp"-#include "snippets/snippets_isa.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/pass/cleanup_loop_offsets.hpp"#include "snippets/lowered/pass/init_loops.hpp"@@ -18,6 +17,7 @@#include "snippets/lowered/pass/validate_unified_loops.hpp"#include "snippets/lowered/pass/validate_expanded_loops.hpp"#include "snippets/lowered/pass/normalize_loop_ids.hpp"+#include "snippets/op/brgemm.hpp"#include "snippets/shape_inference/shape_inference.hpp"using Snippets_TailProcessingTransformation = ::testing::Test;diff --git a/src/common/snippets/tests/src/lowered/pass/optimize_domain.cpp b/src/common/snippets/tests/src/lowered/pass/optimize_domain.cppindex dce95675e52..54a652fd321 100644--- a/src/common/snippets/tests/src/lowered/pass/optimize_domain.cpp+++ b/src/common/snippets/tests/src/lowered/pass/optimize_domain.cpp@@ -9,6 +9,7 @@#include "lowered/pass/optimize_domain.hpp"#include "subgraph_simple.hpp"#include "lowering_utils.hpp"+#include "openvino/op/add.hpp"namespace ov {namespace test {diff --git a/src/common/snippets/tests/src/lowering_utils.cpp b/src/common/snippets/tests/src/lowering_utils.cppindex 75832185a1d..71f129e86be 100644--- a/src/common/snippets/tests/src/lowering_utils.cpp+++ b/src/common/snippets/tests/src/lowering_utils.cpp@@ -9,6 +9,23 @@#include "snippets/pass/collapse_subgraph.hpp"#include "snippets/pass/gn_tokenization.hpp"#include "snippets/lowered/expression.hpp"+#include "openvino/opsets/opset1.hpp"+#include "snippets/op/powerstatic.hpp"+#include "snippets/op/horizon_max.hpp"+#include "snippets/op/horizon_sum.hpp"+#include "snippets/op/load.hpp"+#include "snippets/op/broadcastload.hpp"+#include "snippets/op/store.hpp"+#include "snippets/op/scalar.hpp"+#include "snippets/op/broadcastmove.hpp"+#include "snippets/op/kernel.hpp"+#include "snippets/op/brgemm.hpp"+#include "snippets/op/buffer.hpp"+#include "snippets/op/vector_buffer.hpp"+#include "snippets/op/fill.hpp"+#include "snippets/op/reduce.hpp"+#include "snippets/op/reshape.hpp"+#include "snippets/target_machine.hpp"namespace ov {diff --git a/src/common/snippets/tests/src/pass/canonicalization.cpp b/src/common/snippets/tests/src/pass/canonicalization.cppindex a9311b67598..bbb74017862 100644--- a/src/common/snippets/tests/src/pass/canonicalization.cpp+++ b/src/common/snippets/tests/src/pass/canonicalization.cpp@@ -8,6 +8,7 @@#include "snippets/pass/canonicalization.hpp"#include "snippets/op/rank_normalization.hpp"#include <subgraph_simple.hpp>+#include "openvino/opsets/opset1.hpp"namespace ov {namespace test {diff --git a/src/common/snippets/tests/src/pass/movebroadcast.cpp b/src/common/snippets/tests/src/pass/movebroadcast.cppindex 0cb73029298..9cffede7cc7 100644--- a/src/common/snippets/tests/src/pass/movebroadcast.cpp+++ b/src/common/snippets/tests/src/pass/movebroadcast.cpp@@ -4,8 +4,9 @@#include <gtest/gtest.h>-#include "snippets/snippets_isa.hpp"+#include "openvino/op/add.hpp"#include "snippets/pass/insert_movebroadcast.hpp"+#include "snippets/op/broadcastmove.hpp"#include "transformations/init_node_info.hpp"@@ -28,7 +29,7 @@ TEST_F(TransformationTestsF, InsertBroadcastMove) {{auto data0 = std::make_shared<ov::op::v0::Parameter>(element::f32, Shape{2, 3});auto data1 = std::make_shared<ov::op::v0::Parameter>(element::f32, Shape{1, 2, 1});- auto move1 = std::make_shared<snippets::isa::BroadcastMove>(data1, ov::Dimension{3});+ auto move1 = std::make_shared<snippets::op::BroadcastMove>(data1, ov::Dimension{3});auto add = std::make_shared<ov::op::v1::Add>(data0, move1);model_ref = std::make_shared<Model>(OutputVector{add}, ParameterVector{data0, data1});}diff --git a/src/common/snippets/tests/src/pass/precision_propagation.cpp b/src/common/snippets/tests/src/pass/precision_propagation.cppindex aa7531eb150..866f4488361 100644--- a/src/common/snippets/tests/src/pass/precision_propagation.cpp+++ b/src/common/snippets/tests/src/pass/precision_propagation.cpp@@ -6,6 +6,7 @@#include <gtest/gtest.h>+#include "openvino/opsets/opset1.hpp"#include "snippets/lowered/expression.hpp"#include "snippets/pass/propagate_precision.hpp"#include "snippets/op/convert_saturation.hpp"diff --git a/src/common/snippets/tests/src/pass/softmax_reshape_elimination.cpp b/src/common/snippets/tests/src/pass/softmax_reshape_elimination.cppindex 2745369f85d..92a85080adc 100644--- a/src/common/snippets/tests/src/pass/softmax_reshape_elimination.cpp+++ b/src/common/snippets/tests/src/pass/softmax_reshape_elimination.cpp@@ -4,7 +4,7 @@#include <gtest/gtest.h>-#include <snippets/snippets_isa.hpp>+#include <openvino/opsets/opset1.hpp>#include <snippets/pass/softmax_reshape_elimination.hpp>#include <transformations/init_node_info.hpp>diff --git a/src/common/transformations/include/ov_ops/nms_static_shape_ie.hpp b/src/common/transformations/include/ov_ops/nms_static_shape_ie.hppindex 7a483be1776..fae96ba1055 100644--- a/src/common/transformations/include/ov_ops/nms_static_shape_ie.hpp+++ b/src/common/transformations/include/ov_ops/nms_static_shape_ie.hpp@@ -9,19 +9,10 @@#include <string>#include <vector>+#include "openvino/op/matrix_nms.hpp"#include "openvino/op/op.hpp"#include "transformations_visibility.hpp"-namespace ov {-namespace op {-namespace v8 {--class MatrixNms;--} // namespace v8-} // namespace op-} // namespace ov-namespace ov {namespace op {namespace internal {diff --git a/src/plugins/intel_cpu/src/emitters/plugin/riscv64/jit_eltwise_emitters.cpp b/src/plugins/intel_cpu/src/emitters/plugin/riscv64/jit_eltwise_emitters.cppindex 050dc487f71..c53b50ffa8c 100644--- a/src/plugins/intel_cpu/src/emitters/plugin/riscv64/jit_eltwise_emitters.cpp+++ b/src/plugins/intel_cpu/src/emitters/plugin/riscv64/jit_eltwise_emitters.cpp@@ -5,6 +5,8 @@#include "jit_eltwise_emitters.hpp"#include "common/utils.hpp"+#include "openvino/op/clamp.hpp"+#include "openvino/op/relu.hpp"#include "transformations/cpu_opset/common/op/leaky_relu.hpp"namespace ov::intel_cpu::riscv64 {diff --git a/src/plugins/intel_cpu/src/emitters/plugin/riscv64/jit_emitter.hpp b/src/plugins/intel_cpu/src/emitters/plugin/riscv64/jit_emitter.hppindex b25fa25619c..31081527ca0 100644--- a/src/plugins/intel_cpu/src/emitters/plugin/riscv64/jit_emitter.hpp+++ b/src/plugins/intel_cpu/src/emitters/plugin/riscv64/jit_emitter.hpp@@ -11,7 +11,6 @@#include "nodes/kernels/riscv64/cpu_isa_traits.hpp"#include "nodes/kernels/riscv64/jit_generator.hpp"#include "snippets/generator.hpp"-#include "snippets/snippets_isa.hpp"namespace ov::intel_cpu::riscv64 {diff --git a/src/plugins/intel_cpu/src/emitters/snippets/aarch64/cpu_generator.cpp b/src/plugins/intel_cpu/src/emitters/snippets/aarch64/cpu_generator.cppindex 062721b29d9..b2db5aedc51 100644--- a/src/plugins/intel_cpu/src/emitters/snippets/aarch64/cpu_generator.cpp+++ b/src/plugins/intel_cpu/src/emitters/snippets/aarch64/cpu_generator.cpp@@ -20,13 +20,26 @@#include "emitters/utils.hpp"#include "jit_snippets_emitters.hpp"#include "openvino/core/type.hpp"-#include "openvino/op/prelu.hpp"-#include "openvino/op/round.hpp"-#include "openvino/op/sqrt.hpp"+#include "openvino/opsets/opset1.hpp"#include "snippets/emitter.hpp"#include "snippets/lowered/expression.hpp"+#include "snippets/op/broadcastload.hpp"+#include "snippets/op/broadcastmove.hpp"+#include "snippets/op/buffer.hpp"+#include "snippets/op/convert_saturation.hpp"+#include "snippets/op/convert_truncation.hpp"+#include "snippets/op/fill.hpp"+#include "snippets/op/horizon_max.hpp"+#include "snippets/op/horizon_sum.hpp"+#include "snippets/op/kernel.hpp"+#include "snippets/op/load.hpp"+#include "snippets/op/memory_access.hpp"+#include "snippets/op/powerstatic.hpp"+#include "snippets/op/rank_normalization.hpp"#include "snippets/op/reduce.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/op/scalar.hpp"+#include "snippets/op/store.hpp"+#include "snippets/op/vector_buffer.hpp"#include "transformations/cpu_opset/common/op/swish_cpu.hpp"#include "transformations/snippets/aarch64/op/gemm_copy_b.hpp"#include "transformations/snippets/aarch64/op/gemm_cpu.hpp"diff --git a/src/plugins/intel_cpu/src/extension.cpp b/src/plugins/intel_cpu/src/extension.cppindex 4e6fde3fac2..d2b33405be9 100644--- a/src/plugins/intel_cpu/src/extension.cpp+++ b/src/plugins/intel_cpu/src/extension.cpp@@ -31,6 +31,7 @@#include "openvino/op/logical_or.hpp"#include "openvino/op/logical_xor.hpp"#include "openvino/op/matmul.hpp"+#include "openvino/op/matrix_nms.hpp"#include "openvino/op/max_pool.hpp"#include "openvino/op/multiply.hpp"#include "openvino/op/mvn.hpp"diff --git a/src/plugins/intel_cpu/src/transformations/snippets/aarch64/op/gemm_cpu.cpp b/src/plugins/intel_cpu/src/transformations/snippets/aarch64/op/gemm_cpu.cppindex c5adf86f28a..95d8511826b 100644--- a/src/plugins/intel_cpu/src/transformations/snippets/aarch64/op/gemm_cpu.cpp+++ b/src/plugins/intel_cpu/src/transformations/snippets/aarch64/op/gemm_cpu.cpp@@ -6,7 +6,6 @@#include "snippets/itt.hpp"#include "snippets/lowered/port_descriptor.hpp"-#include "snippets/snippets_isa.hpp"#include "snippets/utils/utils.hpp"#include "utils/general_utils.h"diff --git a/src/plugins/intel_cpu/src/transformations/snippets/aarch64/pass/lowered/insert_gemm_copy_buffers.cpp b/src/plugins/intel_cpu/src/transformations/snippets/aarch64/pass/lowered/insert_gemm_copy_buffers.cppindex 78170e1f774..af3763c66f9 100644--- a/src/plugins/intel_cpu/src/transformations/snippets/aarch64/pass/lowered/insert_gemm_copy_buffers.cpp+++ b/src/plugins/intel_cpu/src/transformations/snippets/aarch64/pass/lowered/insert_gemm_copy_buffers.cpp@@ -7,6 +7,7 @@#include "expressions/gemm_copy_b_buffer_expressions.hpp"#include "snippets/itt.hpp"#include "snippets/lowered/loop_manager.hpp"+#include "snippets/op/buffer.hpp"#include "transformations/snippets/aarch64/op/gemm_copy_b.hpp"#include "transformations/snippets/aarch64/op/gemm_cpu.hpp"#include "transformations/snippets/aarch64/op/gemm_utils.hpp"diff --git a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/enforce_precision.cpp b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/enforce_precision.cppindex b825985b560..c640f0243a5 100644--- a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/enforce_precision.cpp+++ b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/enforce_precision.cpp@@ -41,12 +41,12 @@ EnforcePrecision::EnforcePrecision(OPENVINO_ASSERT(source != target, "source and target precisions have to be different");}-bool EnforcePrecision::run_on_model(const std::shared_ptr<ov::Model>& f) {+bool EnforcePrecision::run_on_model(const std::shared_ptr<ov::Model>& m) {RUN_ON_MODEL_SCOPE(EnforcePrecision);OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "ov::intel_cpu::pass::EnforcePrecision")bool was_updated = false;- for (const auto& op : f->get_ordered_ops()) {+ for (const auto& op : m->get_ordered_ops()) {ov::op::util::process_subgraph(*this, op);const auto& precisions = get_supported_precisions(op);diff --git a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/enforce_precision.hpp b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/enforce_precision.hppindex 17182b0ade4..56b352261e0 100644--- a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/enforce_precision.hpp+++ b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/enforce_precision.hpp@@ -25,7 +25,7 @@ public:const std::function<std::set<std::vector<element::Type>>(const std::shared_ptr<ov::Node>& op)>&get_supported_precisions = nullptr);- bool run_on_model(const std::shared_ptr<ov::Model>& f) override;+ bool run_on_model(const std::shared_ptr<ov::Model>& m) override;private:static std::set<std::vector<element::Type>> get_supported_precisions_default(diff --git a/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/x64/subgraph_caching.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/x64/subgraph_caching.cppindex f9f17154dcc..f3094f9257a 100644--- a/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/x64/subgraph_caching.cpp+++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/x64/subgraph_caching.cpp@@ -34,6 +34,7 @@#include "common_test_utils/ov_tensor_utils.hpp"#include "common_test_utils/node_builders/eltwise.hpp"#include "common_test_utils/node_builders/constant.hpp"+#include "openvino/opsets/opset1.hpp"#include "shared_test_classes/base/ov_subgraph.hpp"#include "utils/cpu_test_utils.hpp"#include "internal_properties.hpp"diff --git a/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/x64/subgraph_serialize.cpp b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/x64/subgraph_serialize.cppindex b403a6087c1..26eac9278a7 100644--- a/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/x64/subgraph_serialize.cpp+++ b/src/plugins/intel_cpu/tests/functional/custom/subgraph_tests/src/x64/subgraph_serialize.cpp@@ -4,8 +4,10 @@#include <gtest/gtest.h>+#include "openvino/core/node_vector.hpp"#include "openvino/core/model.hpp"#include "openvino/runtime/core.hpp"+#include "openvino/opsets/opset1.hpp"#include "openvino/opsets/opset9_decl.hpp"#include "utils/cpu_test_utils.hpp"#include "snippets/op/subgraph.hpp"diff --git a/src/plugins/intel_cpu/tests/unit/snippets_transformations/aarch64/snipptes_mark_skipped.cpp b/src/plugins/intel_cpu/tests/unit/snippets_transformations/aarch64/snipptes_mark_skipped.cppindex 0db91324f05..6395759380b 100644--- a/src/plugins/intel_cpu/tests/unit/snippets_transformations/aarch64/snipptes_mark_skipped.cpp+++ b/src/plugins/intel_cpu/tests/unit/snippets_transformations/aarch64/snipptes_mark_skipped.cpp@@ -6,6 +6,7 @@#include <snippets_helpers.hpp>#include <transformations/snippets/aarch64/pass/snippets_mark_skipped.hpp>#include "openvino/core/visibility.hpp"+#include "openvino/opsets/opset1.hpp"#include "snippets/pass/tokenization.hpp"#include "snippets/pass/collapse_subgraph.hpp"diff --git a/src/plugins/intel_cpu/tests/unit/snippets_transformations/common/mul_add_to_fma.cpp b/src/plugins/intel_cpu/tests/unit/snippets_transformations/common/mul_add_to_fma.cppindex 995b4a5c040..422319e8894 100644--- a/src/plugins/intel_cpu/tests/unit/snippets_transformations/common/mul_add_to_fma.cpp+++ b/src/plugins/intel_cpu/tests/unit/snippets_transformations/common/mul_add_to_fma.cpp@@ -3,6 +3,7 @@//#include <gtest/gtest.h>+#include <openvino/opsets/opset1.hpp>#include <subgraph_simple.hpp>#include <transformations/snippets/common/pass/mul_add_to_fma.hpp>#include <transformations/snippets/common/shape_inference.hpp>diff --git a/src/plugins/intel_cpu/tests/unit/snippets_transformations/x64/fake_quantize_tokenization_test.cpp b/src/plugins/intel_cpu/tests/unit/snippets_transformations/x64/fake_quantize_tokenization_test.cppindex 999e48db61b..7486bb08827 100644--- a/src/plugins/intel_cpu/tests/unit/snippets_transformations/x64/fake_quantize_tokenization_test.cpp+++ b/src/plugins/intel_cpu/tests/unit/snippets_transformations/x64/fake_quantize_tokenization_test.cpp@@ -4,6 +4,7 @@#include <gtest/gtest.h>+#include "openvino/opsets/opset1.hpp"#include "common_test_utils/ov_test_utils.hpp"#include "snippets/pass/fq_decomposition.hpp"#include "snippets/pass/tokenization.hpp"diff --git a/src/plugins/intel_cpu/tests/unit/snippets_transformations/x64/lowered/brgemm_blocking.cpp b/src/plugins/intel_cpu/tests/unit/snippets_transformations/x64/lowered/brgemm_blocking.cppindex 7830714b5df..d5711a82085 100644--- a/src/plugins/intel_cpu/tests/unit/snippets_transformations/x64/lowered/brgemm_blocking.cpp+++ b/src/plugins/intel_cpu/tests/unit/snippets_transformations/x64/lowered/brgemm_blocking.cpp@@ -10,7 +10,7 @@#include "lir_test_utils.hpp"#include "openvino/opsets/opset10_decl.hpp"#include "snippets/lowered/loop_info.hpp"-#include "snippets/snippets_isa.hpp"+#include "snippets/op/buffer.hpp"#include "transformations/snippets/x64/op/brgemm_copy_b.hpp"#include "transformations/snippets/x64/op/brgemm_cpu.hpp"#include "transformations/tpp/common/op/brgemm.hpp"diff --git a/src/plugins/intel_cpu/tests/unit/snippets_transformations/x64/lowered/buffer_allocation.cpp b/src/plugins/intel_cpu/tests/unit/snippets_transformations/x64/lowered/buffer_allocation.cppindex 3088ddf2be0..9eb508fd7b6 100644--- a/src/plugins/intel_cpu/tests/unit/snippets_transformations/x64/lowered/buffer_allocation.cpp+++ b/src/plugins/intel_cpu/tests/unit/snippets_transformations/x64/lowered/buffer_allocation.cpp@@ -2,9 +2,8 @@// SPDX-License-Identifier: Apache-2.0//-#include "openvino/opsets/opset.hpp"+#include "openvino/opsets/opset1.hpp"#include "openvino/runtime/system_conf.hpp"-#include "snippets/snippets_isa.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/pass/mark_loops.hpp"#include "snippets/lowered/pass/init_loops.hpp"@@ -15,6 +14,12 @@#include "snippets/lowered/pass/split_loops.hpp"#include "snippets/lowered/pass/insert_buffers.hpp"#include "snippets/lowered/pass/reduce_decomposition.hpp"+#include "snippets/op/load.hpp"+#include "snippets/op/store.hpp"+#include "snippets/op/buffer.hpp"+#include "snippets/op/convert_saturation.hpp"+#include "snippets/op/powerstatic.hpp"+#include "snippets/op/reduce.hpp"#include "transformations/snippets/common/shape_inference.hpp"#include "transformations/snippets/x64/pass/lowered/brgemm_cpu_blocking.hpp"diff --git a/src/plugins/intel_cpu/tests/unit/snippets_transformations/x64/snipptes_mark_skipped.cpp b/src/plugins/intel_cpu/tests/unit/snippets_transformations/x64/snipptes_mark_skipped.cppindex c87a4bb497a..4a624bfa510 100644--- a/src/plugins/intel_cpu/tests/unit/snippets_transformations/x64/snipptes_mark_skipped.cpp+++ b/src/plugins/intel_cpu/tests/unit/snippets_transformations/x64/snipptes_mark_skipped.cpp@@ -6,6 +6,7 @@#include <subgraph_customizable.hpp>#include <snippets_helpers.hpp>#include <transformations/snippets/x64/pass/snippets_mark_skipped.hpp>+#include "openvino/opsets/opset1.hpp"#include "snippets/pass/tokenization.hpp"#include "snippets/pass/collapse_subgraph.hpp"diff --git a/src/tests/functional/plugin/shared/src/snippets/conv_eltwise.cpp b/src/tests/functional/plugin/shared/src/snippets/conv_eltwise.cppindex 1b40abcf283..d595fe0cf9d 100644--- a/src/tests/functional/plugin/shared/src/snippets/conv_eltwise.cpp+++ b/src/tests/functional/plugin/shared/src/snippets/conv_eltwise.cpp@@ -3,6 +3,8 @@//#include "common_test_utils/common_utils.hpp"+#include "openvino/op/abs.hpp"+#include "openvino/op/sqrt.hpp"#include "snippets/conv_eltwise.hpp"#include "subgraph_customizable.hpp"diff --git a/src/tests/ov_helpers/ov_snippets_models/include/subgraph_customizable.hpp b/src/tests/ov_helpers/ov_snippets_models/include/subgraph_customizable.hppindex 177e4d0daab..4b0528c9a81 100644--- a/src/tests/ov_helpers/ov_snippets_models/include/subgraph_customizable.hpp+++ b/src/tests/ov_helpers/ov_snippets_models/include/subgraph_customizable.hpp@@ -4,6 +4,8 @@#pragma once+#include "openvino/op/add.hpp"+#include "openvino/op/util/op_types.hpp"#include "snippets_helpers.hpp"#include "snippets/utils/utils.hpp"diff --git a/src/tests/ov_helpers/ov_snippets_models/src/fake_quantize_helper.cpp b/src/tests/ov_helpers/ov_snippets_models/src/fake_quantize_helper.cppindex 44865140ead..9777d7c3096 100644--- a/src/tests/ov_helpers/ov_snippets_models/src/fake_quantize_helper.cpp+++ b/src/tests/ov_helpers/ov_snippets_models/src/fake_quantize_helper.cpp@@ -3,8 +3,9 @@//#include "fake_quantize_helper.hpp"+#include "openvino/opsets/opset1.hpp"#include "common_test_utils/data_utils.hpp"-#include <snippets/snippets_isa.hpp>+#include <snippets/op/convert_saturation.hpp>#include <snippets/op/subgraph.hpp>#include "function_helper.hpp"diff --git a/src/tests/ov_helpers/ov_snippets_models/src/function_helper.cpp b/src/tests/ov_helpers/ov_snippets_models/src/function_helper.cppindex e71c2f76326..877c7d7a8b1 100644--- a/src/tests/ov_helpers/ov_snippets_models/src/function_helper.cpp+++ b/src/tests/ov_helpers/ov_snippets_models/src/function_helper.cpp@@ -3,8 +3,8 @@//#include "function_helper.hpp"+#include "openvino/opsets/opset1.hpp"#include "common_test_utils/data_utils.hpp"-#include <snippets/snippets_isa.hpp>#include <snippets/op/subgraph.hpp>namespace ov {diff --git a/src/tests/ov_helpers/ov_snippets_models/src/snippets_helpers.cpp b/src/tests/ov_helpers/ov_snippets_models/src/snippets_helpers.cppindex 7ec89ad5620..81cfa305e4a 100644--- a/src/tests/ov_helpers/ov_snippets_models/src/snippets_helpers.cpp+++ b/src/tests/ov_helpers/ov_snippets_models/src/snippets_helpers.cpp@@ -3,6 +3,7 @@//#include "snippets_helpers.hpp"+#include "openvino/opsets/opset1.hpp"#include "snippets/op/subgraph.hpp"namespace ov {diff --git a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_convert.cpp b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_convert.cppindex 7cc7938be84..7afe8ed099e 100644--- a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_convert.cpp+++ b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_convert.cpp@@ -4,6 +4,7 @@#include "subgraph_converts.hpp"#include "common_test_utils/data_utils.hpp"+#include "openvino/opsets/opset1.hpp"#include <snippets/op/convert_truncation.hpp>#include <snippets/op/subgraph.hpp>diff --git a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_customizable.cpp b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_customizable.cppindex 384c55c93f5..4e085ceedda 100644--- a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_customizable.cpp+++ b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_customizable.cpp@@ -3,6 +3,7 @@//#include "subgraph_customizable.hpp"+#include "openvino/opsets/opset1.hpp"#include "openvino/op/util/op_types.hpp"#include <snippets/op/subgraph.hpp>#include "common_test_utils/data_utils.hpp"diff --git a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_fq.cpp b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_fq.cppindex 8a16b723755..44c10a17f9e 100644--- a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_fq.cpp+++ b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_fq.cpp@@ -5,6 +5,7 @@#include "subgraph_fq.hpp"#include "common_test_utils/data_utils.hpp"#include "ov_lpt_models/common/builders.hpp"+#include "openvino/opsets/opset1.hpp"#include <snippets/op/subgraph.hpp>namespace ov {diff --git a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_group_normalization.cpp b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_group_normalization.cppindex 11d5faf28a5..d2d127605ff 100644--- a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_group_normalization.cpp+++ b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_group_normalization.cpp@@ -3,7 +3,12 @@//#include "subgraph_group_normalization.hpp"+#include "openvino/opsets/opset1.hpp"#include <snippets/op/subgraph.hpp>+#include <snippets/op/reshape.hpp>+#include <snippets/op/reduce.hpp>+#include <snippets/op/powerstatic.hpp>+#include <snippets/op/scalar.hpp>namespace ov {namespace test {diff --git a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_lowered.cpp b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_lowered.cppindex f917760c3f1..69738ec251e 100644--- a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_lowered.cpp+++ b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_lowered.cpp@@ -4,7 +4,14 @@#include "subgraph_lowered.hpp"#include "common_test_utils/data_utils.hpp"-#include <snippets/snippets_isa.hpp>+#include "openvino/opsets/opset1.hpp"+#include <snippets/op/broadcastload.hpp>+#include <snippets/op/broadcastmove.hpp>+#include <snippets/op/convert_saturation.hpp>+#include <snippets/op/load.hpp>+#include <snippets/op/store.hpp>+#include <snippets/op/scalar.hpp>+#include <snippets/op/brgemm.hpp>namespace ov {namespace test {diff --git a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_matmul.cpp b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_matmul.cppindex a79b0bddd54..a5aecd46a18 100644--- a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_matmul.cpp+++ b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_matmul.cpp@@ -4,6 +4,7 @@#include "subgraph_matmul.hpp"#include "common_test_utils/data_utils.hpp"+#include "openvino/opsets/opset1.hpp"#include <snippets/op/subgraph.hpp>#include "common_test_utils/node_builders/constant.hpp"#include "ov_ops/type_relaxed.hpp"diff --git a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_mha.cpp b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_mha.cppindex 9d05858db37..2f9d3a8f368 100644--- a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_mha.cpp+++ b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_mha.cpp@@ -5,6 +5,7 @@#include "fake_quantize_helper.hpp"#include "subgraph_mha.hpp"+#include "openvino/opsets/opset1.hpp"#include "common_test_utils/data_utils.hpp"#include <snippets/op/subgraph.hpp>#include "common_test_utils/node_builders/constant.hpp"diff --git a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_mlp_seq.cpp b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_mlp_seq.cppindex a47d7be5dcc..f6334eb0ce5 100644--- a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_mlp_seq.cpp+++ b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_mlp_seq.cpp@@ -11,6 +11,7 @@#include "ov_lpt_models/common/dequantization_operations.hpp"#include "ov_lpt_models/common/fake_quantize_on_data.hpp"#include "snippets/op/subgraph.hpp"+#include "snippets/op/convert_saturation.hpp"namespace ov {namespace test {diff --git a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_reduce.cpp b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_reduce.cppindex 2ae05cb9395..5aac70ded6c 100644--- a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_reduce.cpp+++ b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_reduce.cpp@@ -6,6 +6,7 @@#include <snippets/op/subgraph.hpp>+#include "openvino/opsets/opset1.hpp"#include "common_test_utils/data_utils.hpp"#include "common_test_utils/node_builders/constant.hpp"#include "common_test_utils/node_builders/reduce.hpp"diff --git a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_simple.cpp b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_simple.cppindex c6d81c87c3e..0998723cabd 100644--- a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_simple.cpp+++ b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_simple.cpp@@ -3,6 +3,7 @@//#include "subgraph_simple.hpp"+#include "openvino/opsets/opset1.hpp"#include "common_test_utils/data_utils.hpp"#include "openvino/core/descriptor_tensor.hpp"#include <snippets/op/subgraph.hpp>diff --git a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_softmax.cpp b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_softmax.cppindex 13635d4ad59..a904ac29e84 100644--- a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_softmax.cpp+++ b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_softmax.cpp@@ -3,9 +3,12 @@//#include "subgraph_softmax.hpp"+#include "openvino/opsets/opset1.hpp"#include "common_test_utils/data_utils.hpp"#include "common_test_utils/node_builders/constant.hpp"#include <snippets/op/subgraph.hpp>+#include <snippets/op/reduce.hpp>+#include <snippets/op/powerstatic.hpp>#include "openvino/core/validation_util.hpp"namespace ov {diff --git a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_transpose.cpp b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_transpose.cppindex 1fe7344efa6..1935a1af039 100644--- a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_transpose.cpp+++ b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_transpose.cpp@@ -4,6 +4,7 @@#include "subgraph_transpose.hpp"#include "common_test_utils/data_utils.hpp"+#include "openvino/opsets/opset1.hpp"#include <snippets/op/subgraph.hpp>namespace ov {