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] Enable clang-format (#30752)
Arseniy Obolenskiy5d14a4a91551
diff --git a/src/common/snippets/.clang-format b/src/common/snippets/.clang-formatnew file mode 100644index 00000000000..d4de26be100--- /dev/null+++ b/src/common/snippets/.clang-format@@ -0,0 +1,29 @@+BasedOnStyle: Google+IndentWidth: 4+UseTab: Never+ColumnLimit: 120++Language: Cpp+Standard: Cpp11++AccessModifierOffset: -4+AlignConsecutiveMacros: true+AllowAllArgumentsOnNextLine: false+AllowAllConstructorInitializersOnNextLine: false+AllowAllParametersOfDeclarationOnNextLine: false+AllowShortFunctionsOnASingleLine: Empty+AllowShortIfStatementsOnASingleLine: Never+AllowShortLambdasOnASingleLine: Empty+AllowShortLoopsOnASingleLine: false+AlwaysBreakBeforeMultilineStrings: false+BinPackArguments: false+BinPackParameters: false+CommentPragmas: '^#'+DerivePointerAlignment: false+FixNamespaceComments: true+IndentCaseLabels: false+IndentPPDirectives: AfterHash+QualifierAlignment: Left+ForEachMacros:+ - foreach+ - FOREACH_CHILDdiff --git a/src/common/snippets/CMakeLists.txt b/src/common/snippets/CMakeLists.txtindex 841de923aa4..240687b00a6 100644--- a/src/common/snippets/CMakeLists.txt+++ b/src/common/snippets/CMakeLists.txt@@ -35,6 +35,7 @@ target_include_directories(${TARGET_NAME} PUBLIC $<BUILD_INTERFACE:${PUBLIC_HEADPRIVATE $<BUILD_INTERFACE:${SHAPE_INFER_INCLUDE_DIR}>)add_cpplint_target(${TARGET_NAME}_cpplint FOR_TARGETS ${TARGET_NAME})+ov_add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME})ov_mark_target_as_cc(${TARGET_NAME})diff --git a/src/common/snippets/include/snippets/emitter.hpp b/src/common/snippets/include/snippets/emitter.hppindex a90e00c6f2c..b329e2d6818 100644--- a/src/common/snippets/include/snippets/emitter.hpp+++ b/src/common/snippets/include/snippets/emitter.hpp@@ -4,8 +4,8 @@#pragma once-#include <vector>#include <cstdint>+#include <vector>#include "openvino/core/node.hpp"@@ -22,7 +22,8 @@ enum class RegType {mask,// Ticket: 166071// Need to move this type to a separate class- address, // address type should be ignored by the code generation logic, as it is handled outside the snippets pipeline.+ address, // address type should be ignored by the code generation logic, as it is handled outside the snippets+ // pipeline.undefined};/**@@ -30,12 +31,16 @@ enum class RegType {* @brief Register representation: type of register and index*/struct Reg {- enum {UNDEFINED_IDX = std::numeric_limits<size_t>::max()};+ enum { UNDEFINED_IDX = std::numeric_limits<size_t>::max() };Reg() = default;Reg(RegType type_, size_t idx_) : type(type_), idx(idx_) {}- bool is_address() const { return type == RegType::address; }- bool is_defined() const { return is_address() || (type != RegType::undefined && idx != UNDEFINED_IDX); }+ bool is_address() const {+ return type == RegType::address;+ }+ bool is_defined() const {+ return is_address() || (type != RegType::undefined && idx != UNDEFINED_IDX);+ }RegType type = RegType::undefined;size_t idx = UNDEFINED_IDX;@@ -71,9 +76,9 @@ public:* @return void*/void emit_code(const std::vector<size_t>& in,- const std::vector<size_t>& out,- const std::vector<size_t>& pool = {},- const std::vector<size_t>& gpr = {}) const {+ const std::vector<size_t>& out,+ const std::vector<size_t>& pool = {},+ const std::vector<size_t>& gpr = {}) const {emit_code_impl(in, out, pool, gpr);}@@ -100,5 +105,5 @@ private:const std::vector<size_t>& gpr) const = 0;};-} // namespace snippets-} // namespace ov+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/generator.hpp b/src/common/snippets/include/snippets/generator.hppindex 065bd275bde..86827dfd5b7 100644--- a/src/common/snippets/include/snippets/generator.hpp+++ b/src/common/snippets/include/snippets/generator.hpp@@ -8,17 +8,15 @@*/#pragma once-#include "snippets_isa.hpp"--#include "snippets/lowered/linear_ir.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 {-class Generator;/*** @interface LoweringResult@@ -29,7 +27,8 @@ class Generator;class LoweringResult {friend class Generator;// 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.+ // 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{};public:@@ -53,11 +52,12 @@ public:/*** @brief Returns callable instanse of code pointer*/- template<typename K> K get_callable() const {+ template <typename K>+ K get_callable() const {return reinterpret_cast<K>(const_cast<unsigned char*>(lowering_result.compiled_snippet->get_code()));}- LoweringResult lowering_result {};+ LoweringResult lowering_result{};};/**@@ -65,7 +65,7 @@ public:* @brief Target independent code generator interface* @ingroup snippets*/-class Generator : public std::enable_shared_from_this<Generator>{+class Generator : public std::enable_shared_from_this<Generator> {public:/*** @brief Default constructor@@ -100,18 +100,20 @@ public:protected:/**- * @brief gets register type by specific plugin op type- * @return register type- */+ * @brief gets register type by specific plugin op type+ * @return register type+ */virtual RegType get_specific_op_out_reg_type(const ov::Output<Node>& out) const;/**- * @brief returns true if an emitter can use precompiled kernel.- * @return bool- */- virtual bool uses_precompiled_kernel(const std::shared_ptr<Emitter>& emitter) const { return false; }+ * @brief returns true if an emitter can use precompiled kernel.+ * @return bool+ */+ virtual bool uses_precompiled_kernel(const std::shared_ptr<Emitter>& emitter) const {+ return false;+ }std::shared_ptr<TargetMachine> target;};-} // namespace snippets-} // namespace ov+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/itt.hpp b/src/common/snippets/include/snippets/itt.hppindex 45303ae36ac..12b2aaea507 100644--- a/src/common/snippets/include/snippets/itt.hpp+++ b/src/common/snippets/include/snippets/itt.hpp@@ -16,10 +16,10 @@ namespace pass {namespace itt {namespace domains {OV_ITT_DOMAIN(SnippetsTransform);-} // namespace domains-} // namespace itt-} // namespace pass-} // namespace ov+} // namespace domains+} // namespace itt+} // namespace pass+} // namespace ovOV_CC_DOMAINS(internal_op);@@ -30,14 +30,14 @@ OV_CC_DOMAINS(internal_op);*/#if defined(SELECTIVE_BUILD_ANALYZER)-#define INTERNAL_OP_SCOPE(region) OV_SCOPE(internal_op, region)+# define INTERNAL_OP_SCOPE(region) OV_SCOPE(internal_op, region)#elif defined(SELECTIVE_BUILD)-#define INTERNAL_OP_SCOPE(region) MATCHER_SCOPE_(internal_op, region)+# define INTERNAL_OP_SCOPE(region) MATCHER_SCOPE_(internal_op, region)#else-#define INTERNAL_OP_SCOPE(region)+# define INTERNAL_OP_SCOPE(region)#endifdiff --git a/src/common/snippets/include/snippets/kernel_executor_table.hpp b/src/common/snippets/include/snippets/kernel_executor_table.hppindex 4d2dea8338d..ff7825c249f 100644--- a/src/common/snippets/include/snippets/kernel_executor_table.hpp+++ b/src/common/snippets/include/snippets/kernel_executor_table.hpp@@ -4,28 +4,29 @@#pragma once+#include <typeinfo>+#include "openvino/util/pp.hpp"#include "snippets/lowered/linear_ir.hpp"-#include <typeinfo>#if defined(SNIPPETS_DEBUG_CAPS) && !defined(_WIN32)-#include <cxxabi.h>+# include <cxxabi.h>#endifnamespace ov {namespace snippets {/**-* @brief Base class for all kernel executors. This class should not be instantiated directly.+ * @brief Base class for all kernel executors. This class should not be instantiated directly.* Derive from KernelExecutor<> to create desired executor implementations.-*/+ */class KernelExecutorBase {public:class GenericConfig {public:/**- * @brief Returns true if the config specifies all the parameters necessary for kernel compilation.+ * @brief Returns true if the config specifies all the parameters necessary for kernel compilation.* 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;/*** Return deep copy of the config */@@ -41,14 +42,16 @@ public:#endif};/**- * @brief Update current kernel config in accordance with the passed expression. Corresponding kernel is recompiled if necessary.- * This method should be called to update KernelExecutor based on runtime info (e.g. shapes) available through expression ptr- */+ * @brief Update current kernel config in accordance with the passed expression. Corresponding kernel is recompiled+ * if necessary. This method should be called to update KernelExecutor based on runtime info (e.g. shapes) available+ * through expression ptr+ */virtual void update_by_expression(const lowered::ExpressionPtr& expr, const lowered::LinearIRCPtr& linear_ir) = 0;/**- * @brief Replace current kernel config with the provided value. Corresponding kernel is recompiled if necessary.- * This method should be called to restore a saved state of the executor, that was configured using update_by_expression().- */+ * @brief Replace current kernel config with the provided value. Corresponding kernel is recompiled if necessary.+ * This method should be called to restore a saved state of the executor, that was configured using+ * update_by_expression().+ */virtual void update_by_config(const GenericConfig& new_config) = 0;virtual const GenericConfig& get_config() const = 0;@@ -60,24 +63,28 @@ public:private:KernelExecutorBase() = default;- template<typename Conf, typename KernelType,- typename std::enable_if<std::is_base_of<GenericConfig, Conf>::value, bool>::type> friend class KernelExecutor;+ template <typename Conf,+ typename KernelType,+ typename std::enable_if<std::is_base_of<GenericConfig, Conf>::value, bool>::type>+ friend class KernelExecutor;};-template<typename Conf, typename KernelType,- typename std::enable_if<std::is_base_of<KernelExecutorBase::GenericConfig, Conf>::value, bool>::type = true>+template <typename Conf,+ typename KernelType,+ typename std::enable_if<std::is_base_of<KernelExecutorBase::GenericConfig, Conf>::value, bool>::type = true>class KernelExecutor : public KernelExecutorBase {public:explicit KernelExecutor(Conf c) : KernelExecutorBase(), m_config{std::move(c)} {}// Note: override when final is redundant, but needed to avoid warnings on some compilers- void update_by_expression(const lowered::ExpressionPtr& expr, const lowered::LinearIRCPtr& linear_ir) override final { // NOLINT+ void update_by_expression(const lowered::ExpressionPtr& expr,+ const lowered::LinearIRCPtr& linear_ir) override final { // NOLINTupdate_config(expr, linear_ir, m_config);OPENVINO_ASSERT(m_config.is_completed(), "Failed to update kernel config in update_by_expression");update_kernel(m_config, m_kernel);OPENVINO_ASSERT(m_kernel, "Failed to compile kernel executor");}- void update_by_config(const GenericConfig& new_config) override final { // NOLINT+ void update_by_config(const GenericConfig& new_config) override final { // NOLINTif (m_config.hash() == new_config.hash())return;const auto& new_ptr = dynamic_cast<const Conf*>(&new_config);@@ -86,32 +93,38 @@ public:update_kernel(m_config, m_kernel);OPENVINO_ASSERT(m_kernel, "Failed to compile kernel executor");}- const GenericConfig& get_config() const override { return m_config; }- std::shared_ptr<const KernelType> get_kernel() const { return m_kernel; }+ const GenericConfig& get_config() const override {+ return m_config;+ }+ std::shared_ptr<const KernelType> get_kernel() const {+ return m_kernel;+ }#ifdef SNIPPETS_DEBUG_CAPSstd::string to_string() const override {std::string type_name = typeid(KernelType).name();-#ifndef _WIN32+# ifndef _WIN32int status;std::unique_ptr<char, void (*)(void*)> demangled_name(- abi::__cxa_demangle(type_name.c_str(), nullptr, nullptr, &status),- std::free);+ abi::__cxa_demangle(type_name.c_str(), nullptr, nullptr, &status),+ std::free);type_name = demangled_name.get();-#endif- return "KernelExecutorType: " + std::string(type_name) + " KernelConfig: " + m_config.to_string();+# endif+ return "KernelExecutorType: " + std::string(type_name) + " KernelConfig: " + m_config.to_string();}#endifprotected:/*** Updates stored kernel config based on runtime info from expression (e.g. new input shapes). */- virtual void update_config(const lowered::ExpressionPtr& expr, const lowered::LinearIRCPtr& linear_ir, Conf& config) const = 0;+ virtual void update_config(const lowered::ExpressionPtr& expr,+ const lowered::LinearIRCPtr& linear_ir,+ Conf& config) const = 0;/*** Updates stored kernel in accordance with the passed config. Recompilation of the kernel is* performed if necessary. */virtual void update_kernel(const Conf& c, std::shared_ptr<KernelType>& kernel) const = 0;private:/** Contains all the necessary information to compile a desired kernel*/- Conf m_config {};+ Conf m_config{};/** Stores pointer to compiled kernel since the last update_kernel() call */std::shared_ptr<KernelType> m_kernel = nullptr;};@@ -119,11 +132,13 @@ 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,+ typename std::enable_if<std::is_base_of<KernelExecutorBase, T>::value, bool>::type = 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, "This expression execution number already has an alterable kernel");+ OPENVINO_ASSERT(m_table.insert({expr->get_exec_num(), instance}).second,+ "This expression execution number already has an alterable kernel");return instance;}@@ -131,7 +146,8 @@ public:return get_kernel_executor(expr->get_exec_num());}const std::shared_ptr<KernelExecutorBase>& get_kernel_executor(double expr_exec_num) const {- assert(m_table.count(expr_exec_num) && "This expression execution number doesn't have a registered kernel executor");+ assert(m_table.count(expr_exec_num) &&+ "This expression execution number doesn't have a registered kernel executor");return m_table.at(expr_exec_num);}@@ -148,25 +164,27 @@ public:/*** Returns lambda function that contains current state of the table, and restores this state when called */std::function<void()> get_state_reset() {auto current_state = get_state();- return [OV_CAPTURE_CPY_AND_THIS]() { reset_state(current_state); };+ return [OV_CAPTURE_CPY_AND_THIS]() {+ reset_state(current_state);+ };}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;/*** Restore the table state previously obtained by get_state() */void reset_state(const ExecTableState& state);- /*** Return cumulative state of all the executors in the table. The returned ExecTableState object can be passed to reset_state */+ /*** Return cumulative state of all the executors in the table. The returned ExecTableState object can be passed to+ * reset_state */ExecTableState get_state() const;};using KernelExecutorTablePtr = std::shared_ptr<KernelExecutorTable>;--} // namespace snippets-} // namespace ov+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/expression.hpp b/src/common/snippets/include/snippets/lowered/expression.hppindex 18ad65ad1d7..1090aa2f7a7 100644--- a/src/common/snippets/include/snippets/lowered/expression.hpp+++ b/src/common/snippets/include/snippets/lowered/expression.hpp@@ -8,9 +8,8 @@#include <openvino/opsets/opset1.hpp>#include "snippets/emitter.hpp"-#include "snippets/lowered/port_connector.hpp"#include "snippets/lowered/expression_port.hpp"-+#include "snippets/lowered/port_connector.hpp"#include "snippets/shape_inference/shape_inference.hpp"namespace ov {@@ -35,23 +34,41 @@ public:RegInfo get_reg_info() const;void set_reg_info(const RegInfo& rinfo);- const std::set<Reg>& get_live_regs() const {return m_live_regs; }- void set_live_regs(std::set<Reg> live_regs) { m_live_regs = std::move(live_regs); }+ const std::set<Reg>& get_live_regs() const {+ return m_live_regs;+ }+ void set_live_regs(std::set<Reg> live_regs) {+ m_live_regs = std::move(live_regs);+ }- double get_exec_num() const { return m_exec_num; }+ double get_exec_num() const {+ return m_exec_num;+ }const PortConnectorPtr& get_input_port_connector(size_t i) const;const PortConnectorPtr& get_output_port_connector(size_t i) const;- const std::vector<PortConnectorPtr>& get_input_port_connectors() const { return m_input_port_connectors; }- const std::vector<PortConnectorPtr>& get_output_port_connectors() const { return m_output_port_connectors; }+ const std::vector<PortConnectorPtr>& get_input_port_connectors() const {+ return m_input_port_connectors;+ }+ const std::vector<PortConnectorPtr>& get_output_port_connectors() const {+ return m_output_port_connectors;+ }const PortDescriptorPtr& get_input_port_descriptor(size_t i) const;const PortDescriptorPtr& get_output_port_descriptor(size_t i) const;- const std::vector<PortDescriptorPtr>& get_input_port_descriptors() const { return m_input_port_descriptors; }- const std::vector<PortDescriptorPtr>& get_output_port_descriptors() const { return m_output_port_descriptors; }+ const std::vector<PortDescriptorPtr>& get_input_port_descriptors() const {+ return m_input_port_descriptors;+ }+ const std::vector<PortDescriptorPtr>& get_output_port_descriptors() const {+ return m_output_port_descriptors;+ }- size_t get_input_count() const { return m_input_port_connectors.size(); }- size_t get_output_count() const { return m_output_port_connectors.size(); }+ size_t get_input_count() const {+ return m_input_port_connectors.size();+ }+ size_t get_output_count() const {+ return m_output_port_connectors.size();+ }void set_input_port_connector(size_t port, PortConnectorPtr to);@@ -64,7 +81,9 @@ public:std::vector<ExpressionPort> get_output_ports();void updateShapes();- bool needShapeInfer() const { return m_need_shape_infer; }+ bool needShapeInfer() const {+ return m_need_shape_infer;+ }const std::vector<size_t>& get_loop_ids() const;void set_loop_ids(const std::vector<size_t>& loops);@@ -78,7 +97,8 @@ public:* descriptors will be copied from the current expression* @return the copy*/- ExpressionPtr clone_with_new_inputs(const std::shared_ptr<Node>& new_node, const std::vector<PortConnectorPtr>& new_inputs,+ ExpressionPtr clone_with_new_inputs(const std::shared_ptr<Node>& new_node,+ const std::vector<PortConnectorPtr>& new_inputs,const std::vector<PortDescriptorPtr>& new_in_descs = {}) const;/*** @brief Clone Expression with new node using `expr_map` to connect to new parent expressions.@@ -88,12 +108,12 @@ public:*/ExpressionPtr clone_with_new_inputs(const ExpressionMap& expr_map, const std::shared_ptr<Node>& new_node) const;- virtual bool visit_attributes(AttributeVisitor &visitor);+ virtual bool visit_attributes(AttributeVisitor& visitor);// Note that get_type_info_static and get_type_info are needed to mimic OPENVINO_RTTI interface,// so the standard OPENVINO_RTTI(...) macros could be used in derived classes._OPENVINO_HIDDEN_METHOD static const ::ov::DiscreteTypeInfo& get_type_info_static() {- static ::ov::DiscreteTypeInfo type_info_static {"Expression"};+ static ::ov::DiscreteTypeInfo type_info_static{"Expression"};type_info_static.hash();return type_info_static;}@@ -109,7 +129,9 @@ public:protected:// Note: The constructor initialization is private since an expression can be created only by Linear IR.// The method must be used only by Linear IR builder of expressions!- Expression(const std::shared_ptr<Node>& n, const std::shared_ptr<IShapeInferSnippetsFactory>& factory, bool need_shape_infer = true);+ Expression(const std::shared_ptr<Node>& n,+ const std::shared_ptr<IShapeInferSnippetsFactory>& factory,+ bool need_shape_infer = true);// Virtual clone method which is called in clone_with_new_inputs with common logicvirtual ExpressionPtr clone() const;@@ -135,6 +157,6 @@ protected:std::set<Reg> m_live_regs{};};-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/expression_factory.hpp b/src/common/snippets/include/snippets/lowered/expression_factory.hppindex 30d789380e5..becb2d44e52 100644--- a/src/common/snippets/include/snippets/lowered/expression_factory.hpp+++ b/src/common/snippets/include/snippets/lowered/expression_factory.hpp@@ -6,9 +6,8 @@#include "expression.hpp"#include "expressions/buffer_expression.hpp"--#include "snippets/op/loop.hpp"#include "snippets/op/buffer.hpp"+#include "snippets/op/loop.hpp"#include "snippets/op/perf_count.hpp"#include "snippets/op/reg_spill.hpp"@@ -21,44 +20,62 @@ public:ExpressionFactory(std::shared_ptr<IShapeInferSnippetsFactory> shape_infer_factory): m_shape_infer_factory(std::move(shape_infer_factory)) {}- template <typename T = Expression, typename... Args,+ template <typename T = Expression,+ typename... Args,typename std::enable_if<std::is_base_of<Expression, T>::value, bool>::type = true>- std::shared_ptr<T> build(const std::shared_ptr<Node>& n, const std::vector<PortConnectorPtr>& inputs, Args... args) {+ std::shared_ptr<T> build(const std::shared_ptr<Node>& n,+ const std::vector<PortConnectorPtr>& inputs,+ Args... args) {return create<T>(n, inputs, m_shape_infer_factory, args...);}private:- static ExpressionPtr create(const std::shared_ptr<ov::op::v0::Parameter>& par, const std::vector<PortConnectorPtr>& inputs,+ static ExpressionPtr create(const std::shared_ptr<ov::op::v0::Parameter>& par,+ const std::vector<PortConnectorPtr>& inputs,const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory);- static ExpressionPtr create(const std::shared_ptr<ov::op::v0::Result>& res, const std::vector<PortConnectorPtr>& inputs,+ static ExpressionPtr create(const std::shared_ptr<ov::op::v0::Result>& res,+ const std::vector<PortConnectorPtr>& inputs,const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory);- static ExpressionPtr create(const std::shared_ptr<op::LoopBegin>& n, const std::vector<PortConnectorPtr>& inputs,+ static ExpressionPtr create(const std::shared_ptr<op::LoopBegin>& n,+ const std::vector<PortConnectorPtr>& inputs,const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory);- static ExpressionPtr create(const std::shared_ptr<op::LoopEnd>& n, const std::vector<PortConnectorPtr>& inputs,+ static ExpressionPtr create(const std::shared_ptr<op::LoopEnd>& n,+ const std::vector<PortConnectorPtr>& inputs,const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory);- static ExpressionPtr create(const std::shared_ptr<op::RegSpillBegin>& n, const std::vector<PortConnectorPtr>& inputs,+ static ExpressionPtr create(const std::shared_ptr<op::RegSpillBegin>& n,+ const std::vector<PortConnectorPtr>& inputs,const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory);- static ExpressionPtr create(const std::shared_ptr<op::RegSpillEnd>& n, const std::vector<PortConnectorPtr>& inputs,+ static ExpressionPtr create(const std::shared_ptr<op::RegSpillEnd>& n,+ const std::vector<PortConnectorPtr>& inputs,const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory);- // Note: PerfCountBegin nodes have a PerfCountEnd ov::Output, but corresponding expression should not have any outputs to avoid register allocation+ // Note: PerfCountBegin nodes have a PerfCountEnd ov::Output, but corresponding expression should not have any+ // outputs to avoid register allocation#ifdef SNIPPETS_DEBUG_CAPS- static ExpressionPtr create(const std::shared_ptr<op::PerfCountBeginBase>& n, const std::vector<PortConnectorPtr>& inputs,+ static ExpressionPtr create(const std::shared_ptr<op::PerfCountBeginBase>& n,+ const std::vector<PortConnectorPtr>& inputs,const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory);- static ExpressionPtr create(const std::shared_ptr<op::PerfCountEndBase>& n, const std::vector<PortConnectorPtr>& inputs,+ static ExpressionPtr create(const std::shared_ptr<op::PerfCountEndBase>& n,+ const std::vector<PortConnectorPtr>& inputs,const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory);- static ExpressionPtr create_without_connections(const std::shared_ptr<ov::Node>& n, const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory);+ static ExpressionPtr create_without_connections(+ const std::shared_ptr<ov::Node>& n,+ const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory);#endif- template <typename T = Expression, typename... Args,+ template <typename T = Expression,+ typename... Args,typename std::enable_if<std::is_base_of<Expression, T>::value, bool>::type = 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, Args... args) {+ 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,+ Args... args) {auto expr = std::shared_ptr<T>(new T(n, shape_infer_factory, args...));init_expression_inputs(expr, inputs);create_expression_outputs(expr);expr->validate();- // todo: here we blindly synchronize input shapes from parent and child. Remove this when shapes will be stored in port connector itself+ // todo: here we blindly synchronize input shapes from parent and child. Remove this when shapes will be stored+ // in port connector itselfif (shape_infer_factory)expr->updateShapes();return expr;@@ -73,9 +90,10 @@ private:};using ExpressionFactoryPtr = std::shared_ptr<ExpressionFactory>;-template<>-std::shared_ptr<Expression> ExpressionFactory::build(const std::shared_ptr<Node>& n, const std::vector<PortConnectorPtr>& inputs);+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 lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/expression_port.hpp b/src/common/snippets/include/snippets/lowered/expression_port.hppindex 38c57ce1b98..0df110de1a6 100644--- a/src/common/snippets/include/snippets/lowered/expression_port.hpp+++ b/src/common/snippets/include/snippets/lowered/expression_port.hpp@@ -9,7 +9,6 @@#include "port_descriptor.hpp"-namespace ov {namespace snippets {namespace lowered {@@ -18,22 +17,23 @@ class PortConnector;class Expression;class ExpressionPort {public:- enum Type {- Input,- Output- };+ enum Type { Input, Output };ExpressionPort() = default;explicit ExpressionPort(const std::shared_ptr<Expression>& expr, Type type, size_t port);/**- * @interface clone_with_new_expr- * @brief Creates similar Expression port, but for new expression+ * @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;std::shared_ptr<Expression> get_expr() const;- Type get_type() const { return m_type; }- size_t get_index() const { return m_port_index; }+ Type get_type() const {+ return m_type;+ }+ 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;@@ -43,7 +43,8 @@ public: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 expression)+ // since output ports don't support PortConnector changing (this is determined by the creation of the+ // expression)void replace_input_port_connector(std::shared_ptr<PortConnector> to) const;friend bool operator==(const ExpressionPort& lhs, const ExpressionPort& rhs);@@ -58,6 +59,6 @@ private:void replace_input_port_connectors(const std::set<ExpressionPort>& consumers, const std::shared_ptr<PortConnector>& to);-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/expressions/buffer_expression.hpp b/src/common/snippets/include/snippets/lowered/expressions/buffer_expression.hppindex 9174d9866db..523f7638fbb 100644--- a/src/common/snippets/include/snippets/lowered/expressions/buffer_expression.hpp+++ b/src/common/snippets/include/snippets/lowered/expressions/buffer_expression.hpp@@ -5,10 +5,8 @@#pragma once#include "snippets/lowered/expression.hpp"-#include "snippets/utils/utils.hpp"-namespace ov {namespace snippets {namespace lowered {@@ -22,28 +20,46 @@ class LoopManager;* @param m_allocation_size - memory size for allocation in bytes. Dynamic value means undefined size.* @param m_offset - offset in common Buffer scratchpad* @param m_reg_group - number of register group. The Buffers from the same register group will have the same GPR- * @param m_cluster_id - number of cluster. The Buffers from the same cluster shares memory between them and will have the same offset.+ * @param m_cluster_id - number of cluster. The Buffers from the same cluster shares memory between them and will have+ * the same offset.* @ingroup snippets*/class BufferExpression : public Expression {friend class ExpressionFactory;+public:OPENVINO_RTTI("BufferExpression", "0", Expression)BufferExpression() = default;- bool visit_attributes(AttributeVisitor &visitor) override;-- size_t get_reg_group() const { return m_reg_group; }- size_t get_cluster_id() const { return m_cluster_id; }- size_t get_offset() const { return m_offset; }- size_t get_allocation_size() const { return m_allocation_size; }+ bool visit_attributes(AttributeVisitor& visitor) override;++ size_t get_reg_group() const {+ return m_reg_group;+ }+ size_t get_cluster_id() const {+ return m_cluster_id;+ }+ size_t get_offset() const {+ return m_offset;+ }+ size_t get_allocation_size() const {+ return m_allocation_size;+ }size_t get_byte_size() const;ov::element::Type get_data_type() const;- void set_reg_group(size_t reg_group) { m_reg_group = reg_group; }- void set_cluster_id(size_t cluster) { m_cluster_id = cluster; }- void set_allocation_size(size_t size) { m_allocation_size = size; }- void set_offset(size_t offset) { m_offset = offset; }+ void set_reg_group(size_t reg_group) {+ m_reg_group = reg_group;+ }+ void set_cluster_id(size_t cluster) {+ m_cluster_id = cluster;+ }+ void set_allocation_size(size_t size) {+ m_allocation_size = size;+ }+ void set_offset(size_t offset) {+ m_offset = offset;+ }virtual void init_allocation_size(const std::shared_ptr<LoopManager>& loop_manager, size_t allocation_rank);@@ -51,7 +67,9 @@ public:bool is_defined() const;// Returns True, if the memory is independent - expression doesn't have parents (source)- bool is_independent_memory() const { return get_input_count() == 0; }+ bool is_independent_memory() const {+ return get_input_count() == 0;+ }protected:BufferExpression(const std::shared_ptr<Node>& n, const std::shared_ptr<IShapeInferSnippetsFactory>& factory);@@ -65,6 +83,6 @@ protected:};using BufferExpressionPtr = std::shared_ptr<BufferExpression>;-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/linear_ir.hpp b/src/common/snippets/include/snippets/lowered/linear_ir.hppindex 3d9396ba646..8e7b394a927 100644--- a/src/common/snippets/include/snippets/lowered/linear_ir.hpp+++ b/src/common/snippets/include/snippets/lowered/linear_ir.hpp@@ -9,10 +9,10 @@#include "snippets/lowered/expression.hpp"#include "snippets/lowered/expression_factory.hpp"#include "snippets/lowered/expressions/buffer_expression.hpp"-#include "snippets/target_machine.hpp"#include "snippets/shape_inference/shape_inference.hpp"+#include "snippets/target_machine.hpp"#ifdef SNIPPETS_DEBUG_CAPS-#include "snippets/utils/debug_caps_config.hpp"+# include "snippets/utils/debug_caps_config.hpp"#endifnamespace ov {@@ -29,8 +29,8 @@ public:// Minimal advised work amount for parallel execution.// Set by a backend, typically equals to the number of threads available on the machine.size_t m_min_parallel_work_amount = 8;- // Minimal advised work amount that should be processed during one call of the executable produced by Subgraph::generate- // Set by a backend, should be large enough to compensate for the kernel call overheads+ // Minimal advised work amount that should be processed during one call of the executable produced by+ // Subgraph::generate Set by a backend, should be large enough to compensate for the kernel call overheadssize_t m_min_kernel_work_amount = 256;// True if the Buffer scratchpad size of LinearIR will be optimized (all possible optimizations will be activated)// False if all Buffers will have uniqie ID and offsets in the Linear IR@@ -53,6 +53,7 @@ using LoopManagerPtr = std::shared_ptr<LoopManager>;*/class LinearIR {friend class LinearIRBuilder;+public:using container = std::list<ExpressionPtr>;using exprIt = container::iterator;@@ -61,52 +62,98 @@ public:using constExprReverseIt = container::const_reverse_iterator;LinearIR(Config config = {}, const std::shared_ptr<IShapeInferSnippetsFactory>& factory = {});- LinearIR(const std::shared_ptr<ov::Model>& m, const std::shared_ptr<IShapeInferSnippetsFactory>& factory, Config config = {});+ LinearIR(const std::shared_ptr<ov::Model>& m,+ const std::shared_ptr<IShapeInferSnippetsFactory>& factory,+ Config config = {});const ExpressionFactoryPtr& get_expr_factory() const;- const container& get_ops() const { return m_expressions; }- const std::vector<ExpressionPtr>& get_parameters() const { return m_parameter_expressions; }- const std::vector<ExpressionPtr>& get_results() const { return m_result_expressions; }- const std::vector<BufferExpressionPtr>& get_buffers() const { return m_buffer_expressions; }+ const container& get_ops() const {+ return m_expressions;+ }+ const std::vector<ExpressionPtr>& get_parameters() const {+ return m_parameter_expressions;+ }+ const std::vector<ExpressionPtr>& get_results() const {+ return m_result_expressions;+ }+ const std::vector<BufferExpressionPtr>& get_buffers() const {+ return m_buffer_expressions;+ }const Config& get_config() const {#ifdef SNIPPETS_DEBUG_CAPSassert(m_config.debug_config && "Debug config is not initialized");#endif // SNIPPETS_DEBUG_CAPSreturn m_config;}- size_t get_static_buffer_scratchpad_size() const { return m_static_buffer_scratchpad_size; }+ size_t get_static_buffer_scratchpad_size() const {+ return m_static_buffer_scratchpad_size;+ }- void set_loop_depth(size_t loop_depth) { m_config.m_loop_depth = loop_depth; }- void set_static_buffer_scratchpad_size(size_t size) { m_static_buffer_scratchpad_size = size; }+ void set_loop_depth(size_t loop_depth) {+ m_config.m_loop_depth = loop_depth;+ }+ void set_static_buffer_scratchpad_size(size_t size) {+ m_static_buffer_scratchpad_size = size;+ }const ExpressionPtr& get_expr_by_node(const std::shared_ptr<Node>& n) const;/**- * @brief Move an expression from the position "from" to the position immediately before "to".+ * @brief Move an expression from the position "from" to the position immediately before "to".* Note: this method does NOT take care about data dependencies and no relevant checks are performed.* and doesn't touch internal maps.- */+ */void move(constExprIt from, constExprIt to);- bool empty() const noexcept {return m_expressions.empty(); }+ bool empty() const noexcept {+ return m_expressions.empty();+ }void debug_print(bool tds_as_pointers = false) const;- container::reference back() noexcept {return m_expressions.back();}- container::const_reference back() const noexcept {return m_expressions.back();}- container::reference front() noexcept {return m_expressions.front();}- container::const_reference front() const noexcept {return m_expressions.front();}-- exprIt begin() noexcept {return m_expressions.begin();}- exprIt end() noexcept {return m_expressions.end();}- constExprIt begin() const noexcept {return cbegin();}- constExprIt end() const noexcept {return cend();}- constExprIt cbegin() const noexcept {return m_expressions.cbegin();}- constExprIt cend() const noexcept {return m_expressions.cend();}- exprReverseIt rbegin() noexcept {return m_expressions.rbegin();}- exprReverseIt rend() noexcept {return m_expressions.rend();}- constExprReverseIt crbegin() const noexcept {return m_expressions.crbegin();}- constExprReverseIt crend() const noexcept {return m_expressions.crend();}+ container::reference back() noexcept {+ return m_expressions.back();+ }+ container::const_reference back() const noexcept {+ return m_expressions.back();+ }+ container::reference front() noexcept {+ return m_expressions.front();+ }+ container::const_reference front() const noexcept {+ return m_expressions.front();+ }++ exprIt begin() noexcept {+ return m_expressions.begin();+ }+ exprIt end() noexcept {+ return m_expressions.end();+ }+ constExprIt begin() const noexcept {+ return cbegin();+ }+ constExprIt end() const noexcept {+ return cend();+ }+ constExprIt cbegin() const noexcept {+ return m_expressions.cbegin();+ }+ constExprIt cend() const noexcept {+ return m_expressions.cend();+ }+ exprReverseIt rbegin() noexcept {+ return m_expressions.rbegin();+ }+ exprReverseIt rend() noexcept {+ return m_expressions.rend();+ }+ constExprReverseIt crbegin() const noexcept {+ return m_expressions.crbegin();+ }+ constExprReverseIt crend() const noexcept {+ return m_expressions.crend();+ }exprIt insert(constExprIt pos, const ov::NodeVector& nodes);exprIt insert(constExprIt pos, const std::shared_ptr<Node>& n);@@ -119,19 +166,23 @@ public:exprIt erase(constExprIt pos);constExprIt find(const ExpressionPtr& target) const;- template<typename iterator>+ template <typename iterator>iterator find(iterator begin, iterator end, const ExpressionPtr& target) const;- template<typename iterator>+ template <typename iterator>iterator find_before(iterator it, const ExpressionPtr& target) const;- template<typename iterator>+ template <typename iterator>iterator find_after(iterator it, const ExpressionPtr& target) const;void init_emitters(const std::shared_ptr<TargetMachine>& target);- const LoopManagerPtr& get_loop_manager() const { return m_loop_manager; }+ const LoopManagerPtr& get_loop_manager() const {+ return m_loop_manager;+ }IShapeInferSnippets::Result shape_infer(const std::vector<VectorDimsRef>& input_shapes);- const std::shared_ptr<ShapeInferSnippetsNode>& get_shape_infer_instance() const {return m_shape_infer; }+ const std::shared_ptr<ShapeInferSnippetsNode>& get_shape_infer_instance() const {+ return m_shape_infer;+ }VectorDims get_master_shape() const;bool is_dynamic() const;@@ -154,9 +205,13 @@ public:* The vector may be empty or size of vector must be equal to output port count* @return new expression iterator in LinearIR*/- template<typename T>- exprIt insert_node(const std::shared_ptr<ov::Node>& new_node, const std::vector<T>& inputs, const std::vector<size_t>& loop_ids,- bool update_loop_ports, const constExprIt& place, const std::vector<std::set<ExpressionPort>>& consumers);+ template <typename T>+ exprIt insert_node(const std::shared_ptr<ov::Node>& new_node,+ const std::vector<T>& inputs,+ const std::vector<size_t>& loop_ids,+ bool update_loop_ports,+ const constExprIt& place,+ const std::vector<std::set<ExpressionPort>>& consumers);/*** @brief The same helper as the helpers above but for case when new_node has only one output.* @param new_node the target node@@ -170,10 +225,15 @@ public:* The vector may be empty or size of vector must be equal to output port count* @return new expression iterator in LinearIR*/- template<typename T>- exprIt insert_node(const std::shared_ptr<ov::Node>& new_node, const std::vector<T>& inputs, const std::vector<size_t>& loop_ids,- bool update_loop_ports, const constExprIt& place, const std::set<ExpressionPort>& consumers = {}) {- const auto consumers_py_port = consumers.empty() ? std::vector<std::set<ExpressionPort>>{} : std::vector<std::set<ExpressionPort>>{ consumers };+ template <typename T>+ exprIt insert_node(const std::shared_ptr<ov::Node>& new_node,+ const std::vector<T>& inputs,+ const std::vector<size_t>& loop_ids,+ bool update_loop_ports,+ const constExprIt& place,+ const std::set<ExpressionPort>& consumers = {}) {+ const auto consumers_py_port = consumers.empty() ? std::vector<std::set<ExpressionPort>>{}+ : std::vector<std::set<ExpressionPort>>{consumers};return insert_node(new_node, inputs, loop_ids, update_loop_ports, place, consumers_py_port);}@@ -183,7 +243,9 @@ 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,+ typename std::enable_if<std::is_base_of<ov::Node, T>::value, bool>::type = 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);@@ -193,8 +255,8 @@ public:}/**- * @brief Insert new Expression to LinearIR, sets `loops_ids` as loop identifiers and inserts the expression on the `place` in LinearIR.- * Also connects output ports to `consumers`+ * @brief Insert new Expression to LinearIR, sets `loops_ids` as loop identifiers and inserts the expression on the+ * `place` in LinearIR. Also connects output ports to `consumers`* @param new_expr the target expr which were created by ExpressionFactory* @param loop_ids vector of loops ids that will be set for the expression* @param update_loop_ports true - the helpers updates the corresponding loop ports after insertion otherwise - skip@@ -203,8 +265,11 @@ public:* The vector may be empty or size of vector must be equal to output port count* @return new expression iterator in LinearIR*/- exprIt insert_expr(const ExpressionPtr& new_expr, const std::vector<size_t>& loop_ids,- bool update_loop_ports, const constExprIt& place, const std::vector<std::set<ExpressionPort>>& consumers);+ exprIt insert_expr(const ExpressionPtr& new_expr,+ const std::vector<size_t>& loop_ids,+ bool update_loop_ports,+ const constExprIt& place,+ const std::vector<std::set<ExpressionPort>>& consumers);/*** @brief Replace the several existing expressions with the one new expression that contains `new_node`.@@ -212,8 +277,9 @@ public:* Also the helper move consumers from last expression in `old_exprs` to the new expression.* Notes:* - The helper supports only the sequence of `old_exprs`.- * It means that consumers of the expression in seq are expressions from this sequence (except of the last expr)- * and all sources of the `old_exprs` must be expression from this seq as well or must be source of `new_inputs`+ * It means that consumers of the expression in seq are expressions from this sequence (except of the last+ * expr) and all sources of the `old_exprs` must be expression from this seq as well or must be source of+ * `new_inputs`* - The helper set output PortDescriptors - clones from last removable expression* - The helpers updates LoopPorts of the corresponding loops using information about removable expressions* @param old_exprs the sequence of removable expressions@@ -222,11 +288,13 @@ public:* @param place before this place expression will be inserted* @return new expression iterator in LinearIR*/- exprIt replace_with_node(const std::vector<ExpressionPtr>& old_exprs, const std::shared_ptr<ov::Node>& new_node, const std::vector<size_t>& loop_ids,+ exprIt replace_with_node(const std::vector<ExpressionPtr>& old_exprs,+ const std::shared_ptr<ov::Node>& new_node,+ const std::vector<size_t>& loop_ids,const constExprIt& place);/**- * @brief Replace the several existing expressions with the one new expression that contains `new_node` that are in the same loops.- * Insert new expression on the place of last `old_exprs`+ * @brief Replace the several existing expressions with the one new expression that contains `new_node` that are in+ * the same loops. Insert new expression on the place of last `old_exprs`* @param old_exprs the sequence of removable expressions* @param new_node the target node* @return new expression iterator in LinearIR@@ -237,15 +305,18 @@ public:* The helper move consumers from last expression in `old_exprs` to the new expression.* Notes:* - The helper supports only the sequence of `old_exprs`.- * It means that consumers of the expression in seq are expressions from this sequence (except of the last expr)- * and all sources of the `old_exprs` must be expression from this seq as well or must be source of `new_inputs`+ * It means that consumers of the expression in seq are expressions from this sequence (except of the last+ * expr) and all sources of the `old_exprs` must be expression from this seq as well or must be source of+ * `new_inputs`* - The helpers updates LoopPorts of the corresponding loops using information about removable expressions* @param old_exprs the sequence of removable expressions* @param new_expr the new expr* @param place before this place expression will be inserted* @return new expression iterator in LinearIR*/- exprIt replace_with_expr(const std::vector<ExpressionPtr>& old_exprs, const ExpressionPtr& new_expr, const constExprIt& place);+ exprIt replace_with_expr(const std::vector<ExpressionPtr>& old_exprs,+ const ExpressionPtr& new_expr,+ const constExprIt& place);/*** @brief Replace the several existing expressions with the one new expression that are in the same loops.* Insert new expression on the place of last `old_exprs`@@ -260,7 +331,9 @@ 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,+ typename std::enable_if<std::is_base_of<ov::Node, T>::value, bool>::type = true>std::pair<constExprIt, std::shared_ptr<T>> push_node(Args&&... args) {return insert_node<T>(end(), std::forward<Args>(args)...);}@@ -268,7 +341,9 @@ public:private:class LIRShapeInfer : public ShapeInferSnippetsNode {public:- explicit LIRShapeInfer(const container& body_exprs, const std::vector<ExpressionPtr>& param_exprs, const std::vector<ExpressionPtr>& result_exprs);+ explicit LIRShapeInfer(const container& body_exprs,+ const std::vector<ExpressionPtr>& param_exprs,+ const std::vector<ExpressionPtr>& result_exprs);Result infer(const std::vector<VectorDimsRef>& input_shapes) override;private:@@ -278,10 +353,13 @@ private:};static ov::NodeVector get_ordered_ops(const std::shared_ptr<ov::Model>& model);- ExpressionPtr create_expression(const std::shared_ptr<Node>& n, const std::vector<PortConnectorPtr>& new_inputs,- const std::vector<size_t>& loop_ids, bool update_loop_ports, const std::vector<std::set<ExpressionPort>>& consumers = {});+ ExpressionPtr create_expression(const std::shared_ptr<Node>& n,+ const std::vector<PortConnectorPtr>& new_inputs,+ const std::vector<size_t>& loop_ids,+ bool update_loop_ports,+ const std::vector<std::set<ExpressionPort>>& consumers = {});- // Creates inputs for expression using parent output port connectors+ // Creates inputs for expression using parent output port connectorsstd::vector<PortConnectorPtr> get_expression_inputs_by_node(const std::shared_ptr<Node>& n) const;void register_expression(const ExpressionPtr& expr, bool io_allowed, double exec_num);@@ -310,13 +388,13 @@ private:using LinearIRPtr = std::shared_ptr<LinearIR>;using LinearIRCPtr = std::shared_ptr<const LinearIR>;-template<typename iterator>+template <typename iterator>iterator LinearIR::find(iterator begin, iterator end, const ExpressionPtr& target) const {auto found = std::find(begin, end, target);OPENVINO_ASSERT(found != end, "Expression has not been found");return found;}-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/linear_ir_builder.hpp b/src/common/snippets/include/snippets/lowered/linear_ir_builder.hppindex 346a68f1eba..ebe4a9ad9d1 100644--- a/src/common/snippets/include/snippets/lowered/linear_ir_builder.hpp+++ b/src/common/snippets/include/snippets/lowered/linear_ir_builder.hpp@@ -10,7 +10,6 @@ namespace ov {namespace snippets {namespace lowered {-/* The helper class that can make a copy of LinearIR or range of it by specific rules.* The rules are described in config.*/@@ -32,7 +31,8 @@ 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 {+ inline 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;@@ -54,14 +54,15 @@ public:* @param expression_map expression map* @return cloned range of `linear_ir`*/- LinearIR::container clone_range(LinearIR::container::const_iterator begin, LinearIR::container::const_iterator end,+ LinearIR::container clone_range(LinearIR::container::const_iterator begin,+ LinearIR::container::const_iterator end,ExpressionMap& expression_map) const;private:- void clone(const LinearIR* src, LinearIR* dst, ExpressionMap& expression_map) const;+ void clone(const LinearIR* src, LinearIR* dst, ExpressionMap& expression_map) const;Config m_config = {};};-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/loop_info.hpp b/src/common/snippets/include/snippets/lowered/loop_info.hppindex 65889d46002..44d2ce6c472 100644--- a/src/common/snippets/include/snippets/lowered/loop_info.hpp+++ b/src/common/snippets/include/snippets/lowered/loop_info.hpp@@ -7,7 +7,6 @@#include "snippets/lowered/loop_port.hpp"#include "snippets/lowered/specific_loop_iter_handlers.hpp"-namespace ov {namespace snippets {namespace lowered {@@ -19,15 +18,21 @@ using LoopInfoPtr = std::shared_ptr<LoopInfo>;/*** @interface LoopInfo- * @brief The base class that contains the common information about a Loop in Linear Intermediate Representation (Linear IR):- * work amount of the Loop, step of loop counter increment, input and output ports of the Loop.+ * @brief The base class that contains the common information about a Loop in Linear Intermediate Representation (Linear+ * IR): work amount of the Loop, step of loop counter increment, input and output ports of the Loop.* @ingroup snippets*/class LoopInfo : public std::enable_shared_from_this<LoopInfo> {public:LoopInfo() = default;- LoopInfo(size_t work_amount, size_t increment, const std::vector<LoopPort>& entries, const std::vector<LoopPort>& exits);- LoopInfo(size_t work_amount, size_t increment, const std::vector<ExpressionPort>& entries, const std::vector<ExpressionPort>& exits);+ LoopInfo(size_t work_amount,+ size_t increment,+ const std::vector<LoopPort>& entries,+ const std::vector<LoopPort>& exits);+ LoopInfo(size_t work_amount,+ size_t increment,+ const std::vector<ExpressionPort>& entries,+ const std::vector<ExpressionPort>& exits);virtual ~LoopInfo() = default;/**@@ -36,7 +41,8 @@ public:* @param loop_map map of new and old LoopInfo.* @return the copy*/- virtual std::shared_ptr<LoopInfo> clone_with_new_expr(const ExpressionMap& expr_map, LoopInfoMap& loop_map) const = 0;+ virtual std::shared_ptr<LoopInfo> clone_with_new_expr(const ExpressionMap& expr_map,+ LoopInfoMap& loop_map) const = 0;/*** @brief Apply the passed function to the current LoopInfo@@ -122,7 +128,8 @@ public:* @param actual_port actual port* @param target_ports new ports. The ports order is important. Can contain `actual_port`*/- virtual void replace_with_new_ports(const ExpressionPort& actual_port, const std::vector<ExpressionPort>& target_ports);+ virtual void replace_with_new_ports(const ExpressionPort& actual_port,+ const std::vector<ExpressionPort>& target_ports);/*** @brief Iterates through all loop ports and call `caller` for each of them@@ -141,7 +148,7 @@ public:// Note that get_type_info_static and get_type_info are needed to mimic OPENVINO_RTTI interface,// so the standard OPENVINO_RTTI(...) macros could be used in derived classes._OPENVINO_HIDDEN_METHOD static const ::ov::DiscreteTypeInfo& get_type_info_static() {- static ::ov::DiscreteTypeInfo type_info_static {"LoopInfoBase"};+ static ::ov::DiscreteTypeInfo type_info_static{"LoopInfoBase"};type_info_static.hash();return type_info_static;}@@ -171,13 +178,14 @@ protected:* @param loop_ports the loop ports that will be cloned* @return vector with new cloned loop ports*/- static std::vector<LoopPort> clone_loop_ports(const ExpressionMap& expr_map, const std::vector<LoopPort>& loop_ports);+ static std::vector<LoopPort> clone_loop_ports(const ExpressionMap& expr_map,+ const std::vector<LoopPort>& loop_ports);/*** @brief Find LoopPort in input and output ports* @param loop_port target port* @return iterator of the corresponding collection*/- template<typename T>+ template <typename T>std::vector<LoopPort>::iterator find_loop_port(const T& loop_port);size_t m_work_amount = 0;@@ -193,7 +201,8 @@ protected:/*** @interface UnifiedLoopInfo* @brief The structure describes unified (entire) Loop before decomposition into specific loop iterations.- * Contains passes for specific loop iterations that will be called for each iteration during the decomposition stage (`InsertSpecificIterations` pass).+ * Contains passes for specific loop iterations that will be called for each iteration during the decomposition+ * stage (`InsertSpecificIterations` pass).* @ingroup snippets*/class UnifiedLoopInfo : public LoopInfo {@@ -203,7 +212,9 @@ public:// pointer increment, finalization offset, element size of the portstruct LoopPortDesc {LoopPortDesc(int64_t inc = 0, int64_t fo = 0, int64_t ds = 0)- : ptr_increment(inc), finalization_offset(fo), data_size(ds) {}+ : ptr_increment(inc),+ finalization_offset(fo),+ data_size(ds) {}int64_t ptr_increment = 0;int64_t finalization_offset = 0;int64_t data_size = 0;@@ -226,15 +237,22 @@ public:};UnifiedLoopInfo() = default;- UnifiedLoopInfo(size_t work_amount, size_t increment,- const std::vector<LoopPort>& entries, const std::vector<LoopPort>& exits,- const std::vector<LoopPortDesc>& in_descs, const std::vector<LoopPortDesc>& out_descs,+ UnifiedLoopInfo(size_t work_amount,+ size_t increment,+ const std::vector<LoopPort>& entries,+ const std::vector<LoopPort>& exits,+ const std::vector<LoopPortDesc>& in_descs,+ const std::vector<LoopPortDesc>& out_descs,const SpecificIterationHandlers& handlers = SpecificIterationHandlers());- UnifiedLoopInfo(size_t work_amount, size_t increment,- const std::vector<LoopPort>& entries, const std::vector<LoopPort>& exits,+ UnifiedLoopInfo(size_t work_amount,+ size_t increment,+ const std::vector<LoopPort>& entries,+ const std::vector<LoopPort>& exits,const SpecificIterationHandlers& handlers = SpecificIterationHandlers());- UnifiedLoopInfo(size_t work_amount, size_t increment,- const std::vector<ExpressionPort>& entries, const std::vector<ExpressionPort>& exits,+ UnifiedLoopInfo(size_t work_amount,+ size_t increment,+ const std::vector<ExpressionPort>& entries,+ const std::vector<ExpressionPort>& exits,const SpecificIterationHandlers& handlers = SpecificIterationHandlers());/**@@ -333,7 +351,8 @@ public:* @param actual_port actual port* @param target_ports new ports. Ther order of ports is important. Can contains `actual_port`*/- void replace_with_new_ports(const ExpressionPort& actual_port, const std::vector<ExpressionPort>& target_ports) override;+ void replace_with_new_ports(const ExpressionPort& actual_port,+ const std::vector<ExpressionPort>& target_ports) override;/*** @brief Iterates through all LoopPortDesc and call `caller` for each of them@@ -404,9 +423,13 @@ public:OPENVINO_RTTI("InnerSplittedUnifiedLoopInfo", "0", UnifiedLoopInfo)InnerSplittedUnifiedLoopInfo() = default;- InnerSplittedUnifiedLoopInfo(size_t increment, const std::vector<LoopPort>& entries, const std::vector<LoopPort>& exits,- const std::vector<LoopPortDesc>& in_descs, const std::vector<LoopPortDesc>& out_descs,- const SpecificIterationHandlers& handlers, LoopInfoPtr outer_splitted_loop_info);+ InnerSplittedUnifiedLoopInfo(size_t increment,+ const std::vector<LoopPort>& entries,+ const std::vector<LoopPort>& exits,+ const std::vector<LoopPortDesc>& in_descs,+ const std::vector<LoopPortDesc>& out_descs,+ const SpecificIterationHandlers& handlers,+ LoopInfoPtr outer_splitted_loop_info);/*** @brief Clone LoopInfo with new Expressions@@ -454,18 +477,25 @@ using InnerSplittedUnifiedLoopInfoPtr = std::shared_ptr<InnerSplittedUnifiedLoop/*** @interface ExpandedLoopInfo- * @brief The structure describes expanded Loop (specific iterations) after unified loop decomposition into specific loop iterations.- * Contains type of specific iteration, pointer to the original unified loop and data pointer shifts for quick recalculation.+ * @brief The structure describes expanded Loop (specific iterations) after unified loop decomposition into specific+ * loop iterations. Contains type of specific iteration, pointer to the original unified loop and data pointer shifts+ * for quick recalculation.* @ingroup snippets*/class ExpandedLoopInfo : public LoopInfo {public:OPENVINO_RTTI("ExpandedLoopInfo", "0", LoopInfo)ExpandedLoopInfo() = default;- ExpandedLoopInfo(size_t work_amount, size_t increment,- const std::vector<LoopPort>& entries, const std::vector<LoopPort>& exits,- std::vector<int64_t> ptr_increments, std::vector<int64_t> final_offsets, std::vector<int64_t> data_sizes,- SpecificLoopIterType type, UnifiedLoopInfoPtr unified_loop_info, bool evaluate_once = false);+ ExpandedLoopInfo(size_t work_amount,+ size_t increment,+ const std::vector<LoopPort>& entries,+ const std::vector<LoopPort>& exits,+ std::vector<int64_t> ptr_increments,+ std::vector<int64_t> final_offsets,+ std::vector<int64_t> data_sizes,+ SpecificLoopIterType type,+ UnifiedLoopInfoPtr unified_loop_info,+ bool evaluate_once = false);/*** @brief Clone LoopInfo with new Expressions* @param expr_map map of new and old expressions@@ -558,7 +588,8 @@ public:* @param actual_port actual port* @param target_ports vector with the single target port!*/- void replace_with_new_ports(const ExpressionPort& actual_port, const std::vector<ExpressionPort>& target_ports) override;+ void replace_with_new_ports(const ExpressionPort& actual_port,+ const std::vector<ExpressionPort>& target_ports) override;/*** @brief Sort Loop Ports according to the execution order of underlying expressions@@ -577,6 +608,6 @@ private:};using ExpandedLoopInfoPtr = std::shared_ptr<ExpandedLoopInfo>;-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/loop_manager.hpp b/src/common/snippets/include/snippets/lowered/loop_manager.hppindex 387f3634cdb..63f23e0373b 100644--- a/src/common/snippets/include/snippets/lowered/loop_manager.hpp+++ b/src/common/snippets/include/snippets/lowered/loop_manager.hpp@@ -30,8 +30,7 @@ public:* @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>+ 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 {const auto it = m_map.find(index);OPENVINO_ASSERT(it != m_map.end(), "LoopInfo hasn't been found!");@@ -43,7 +42,9 @@ public:* @brief Get count of loops* @return count of loops in the map*/- size_t get_loop_count() const { return m_map.size(); }+ size_t get_loop_count() const {+ return m_map.size();+ }/*** @brief Get loop map [loop_id -> loop info]* @return loop map@@ -79,16 +80,19 @@ public:*/void mark_loop(LinearIR::constExprIt loop_begin_pos,LinearIR::constExprIt loop_end_pos,- size_t loop_depth, size_t vector_size);+ size_t loop_depth,+ size_t vector_size);/**- * @brief Create new UnifiedLoopInfo and mark all expressions in loop bounds by new loop ID with more manual parameters+ * @brief Create new UnifiedLoopInfo and mark all expressions in loop bounds by new loop ID with more manual+ * parameters* @param loop_begin_pos the first expression iterator* @param loop_end_pos the next iterator after last expression* @param work_amount work amount of the loop* @param increment the step of loop counter increment* @param entries input loop ports* @param exits output loop ports- * @param set_default_handlers flag defines whether it is needed to set default set of SpecificIterationHandlers or not+ * @param set_default_handlers flag defines whether it is needed to set default set of SpecificIterationHandlers or+ * not* @return new loop ID*/template <typename T>@@ -99,10 +103,12 @@ public:const std::vector<T>& entries,const std::vector<T>& exits,bool set_default_handlers = true) {- const auto normalized_increment = utils::is_dynamic_value(work_amount) || work_amount == 0 ? increment : std::min(increment, work_amount);+ 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)- loop_info->set_handlers(SpecificIterationHandlers(work_amount, normalized_increment, loop_info->get_dim_idx()));+ 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) {@@ -111,7 +117,8 @@ public:return loop_id;}/**- * @brief Create new UnifiedLoopInfo and mark all expressions in loop bounds by new loop ID with more manual parameters+ * @brief Create new UnifiedLoopInfo and mark all expressions in loop bounds by new loop ID with more manual+ * parameters* @param loop_begin_pos the first expression iterator* @param loop_end_pos the next iterator after last expression* @param work_amount work amount of the loop@@ -119,7 +126,8 @@ public:* @param dim_idx loop iterates by this index of dimension* @param entries input loop ports* @param exits output loop ports- * @param set_default_handlers flag defines whether it is needed to set default set of SpecificIterationHandlers or not+ * @param set_default_handlers flag defines whether it is needed to set default set of SpecificIterationHandlers or+ * not* @return new loop ID*/template <typename T>@@ -131,7 +139,8 @@ public:const std::vector<T>& entries,const std::vector<T>& exits,bool set_default_handlers = true) {- const auto loop_id = mark_loop(loop_begin_pos, loop_end_pos, work_amount, increment, entries, exits, set_default_handlers);+ const auto loop_id =+ mark_loop(loop_begin_pos, loop_end_pos, work_amount, increment, entries, exits, set_default_handlers);const auto loop_info = get_loop_info<UnifiedLoopInfo>(loop_id);loop_info->set_dim_idx(dim_idx);return loop_id;@@ -141,21 +150,27 @@ public:* remove the old LoopInfo from the map if no one expression isn't mark by this `old_id`* @param linear_ir linear IR* @param loop_begin_pos the first expression iterator. Must be the iterator of the `linear_ir`.- * If there is explicit LoopBegin expressions in IR, loop_begin_pos must be the iterator of the LoopBegin+ * If there is explicit LoopBegin expressions in IR, loop_begin_pos must be the iterator of+ * the LoopBegin* @param loop_end_pos the next iterator after last expression iterator. Must be the iterator of the `linear_ir`.- * If there is explicit LoopEnd expressions in IR, loop_end_pos must be the next iterator of the LoopEnd+ * If there is explicit LoopEnd expressions in IR, loop_end_pos must be the next iterator of the+ * LoopEnd* @param loop_info information about new Loop* @param old_id loop ID of the previos loop* @return new loop ID*/- size_t replace_with_new_loop(const LinearIR& linear_ir, LinearIR::constExprIt loop_begin_pos, LinearIR::constExprIt loop_end_pos,- const LoopInfoPtr& loop_info, const size_t old_id);+ size_t replace_with_new_loop(const LinearIR& linear_ir,+ LinearIR::constExprIt loop_begin_pos,+ LinearIR::constExprIt loop_end_pos,+ const LoopInfoPtr& loop_info,+ const size_t old_id);/*** @brief Fuse two UnifiedLoopInfos: fuse their informations to the one* @param linear_ir linear IR* @param loop_id_upper Loop ID of the Loop that is earlier in the linear IR* @param loop_id_lower Loop ID of the Loop that is later in the linear IR- * @param fuse_into_upper True if the Loop with `loop_id_upper` ID is left and the Loop with `loop_id_lower` is removed+ * @param fuse_into_upper True if the Loop with `loop_id_upper` ID is left and the Loop with `loop_id_lower` is+ * removed*/void fuse_loops(const LinearIR& linear_ir, size_t loop_id_upper, size_t loop_id_lower, bool fuse_into_upper = true);/**@@ -164,20 +179,27 @@ public:* @param loop_end_target the next ietartor for the last expression of the Loop that will be left after fusion* @param loop_id_upper Loop ID of the Loop that is earlier in the linear IR* @param loop_id_lower Loop ID of the Loop that is later in the linear IR- * @param fuse_into_upper True if the Loop with `loop_id_upper` ID is left and the Loop with `loop_id_lower` is removed+ * @param fuse_into_upper True if the Loop with `loop_id_upper` ID is left and the Loop with `loop_id_lower` is+ * removed*/- void fuse_loops(LinearIR::constExprIt loop_begin_target, LinearIR::constExprIt loop_end_target,- size_t loop_id_upper, size_t loop_id_lower, bool fuse_into_upper = true);+ void fuse_loops(LinearIR::constExprIt loop_begin_target,+ LinearIR::constExprIt loop_end_target,+ size_t loop_id_upper,+ size_t loop_id_lower,+ bool fuse_into_upper = true);/*** @brief Replace Loop port of Unified Loop with new ports.* Note:* - Update LoopPort - insert new loop target ports instead of existing.- * - Update ExpressionPort in the LoopPort - with saving of port parameters. It's softer method since ExpressionPort may not be port of Loop+ * - Update ExpressionPort in the LoopPort - with saving of port parameters. It's softer method since+ * ExpressionPort may not be port of Loop* @param loop_id the target Loop ID* @param actual_port the current port* @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>+ template <typename T,+ typename = typename std::+ enable_if<(std::is_same<T, ExpressionPort>::value || std::is_same<T, LoopPort>::value), bool>::type>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);@@ -188,23 +210,32 @@ public:* @param actual_port the current port* @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>- void replace_loop_ports(const std::vector<size_t>& loop_ids, const T& actual_port, const std::vector<T>& target_ports) {+ template <typename T,+ typename = typename std::+ enable_if<(std::is_same<T, ExpressionPort>::value || std::is_same<T, LoopPort>::value), bool>::type>+ void replace_loop_ports(const std::vector<size_t>& loop_ids,+ const T& actual_port,+ const std::vector<T>& target_ports) {for (auto loop_id : loop_ids) {replace_loop_port(loop_id, actual_port, target_ports);}}/**- * @brief The method checks the loops (LoopInfo) that the target expression is marked with and update the corresponding loop ports if needed:- * - If parent of the target expression and this expression are marked by one Loop and the parent is an output port of this Loop,- * the method replace parent output port with the target expression output ports as new output LoopPorts.- * If there are other consumers of parent output port that are not by the same Loop (like in the example below),- * the method just adds inserted expression output ports to existing parent output port as new output LoopPorts.+ * @brief The method checks the loops (LoopInfo) that the target expression is marked with and update the+ * corresponding loop ports if needed:+ * - If parent of the target expression and this expression are marked by one Loop and the parent is an+ * output port of this Loop, the method replace parent output port with the target expression output+ * ports as new output LoopPorts. If there are other consumers of parent output port that are not+ * by the same Loop (like in the example below), the method just adds inserted expression output ports+ * to existing parent output port as new output LoopPorts.* Parent [1, 0]- * / \ <- Adds the target expression outputs to the existing LoopPort (parent output) of Loop[1]- * Another expr [2] Target expression [1, 3] (If Another expr is marked by Loop [1] too, the method will replace loop ports (not add))- * - If the target expression and its consumers have the same outer loop ids and some of consumers are input ports of these Loops,- * the method just replace the existing input loop ports (that contains consumer input ports) with the target expression input ports.+ * / \ <- Adds the target expression outputs to the existing+ * Another expr [2] Target expression [1, 3] LoopPort (parent output) of Loop[1]+ * (If Another expr is marked by Loop [1] too,+ * the method will replace loop ports (not add))+ * - If the target expression and its consumers have the same outer loop ids and some of consumers are+ * input ports of these Loops, the method just replace the existing input loop ports (that contains+ * consumer input ports) with the target expression input ports.* @param expr the target expression*/void update_loop_ports(const ExpressionPtr& expr);@@ -214,8 +245,9 @@ public:*/void sort_loop_ports(const std::vector<size_t>& loop_ids);/**- * @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 parameters `entries` and `exits`+ * @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+ * parameters `entries` and `exits`* @param new_expr_begin the first expression iterator* @param new_expr_end the next iterator after the last expression* @param decomposed_expr the expression that is decomposed into several other exprs@@ -223,17 +255,21 @@ public:* @param new_entries new input loop ports* @param new_exits new output loop ports*/- void expression_replacement(LinearIR::constExprIt new_expr_begin, LinearIR::constExprIt new_expr_end, const ExpressionPtr& decomposed_expr,- size_t loop_id, const std::vector<ExpressionPort>& new_entries, const std::vector<ExpressionPort>& exits);+ void expression_replacement(LinearIR::constExprIt new_expr_begin,+ LinearIR::constExprIt new_expr_end,+ const ExpressionPtr& decomposed_expr,+ size_t loop_id,+ const std::vector<ExpressionPort>& new_entries,+ const std::vector<ExpressionPort>& exits);using LoopBounds = std::pair<LinearIR::constExprIt, LinearIR::constExprIt>;/*** @brief Find bounds of Loop:* - If the explicit Loop exprs with the target `loop_id` have been inserted,* Loop bounds are these iterators of the corresponding LoopBegin and LoopEnd.- * - Otherwise Loop bounds are iterators of the first input loop port (or Scalar, VectorBuffer and another LoopBegin that- * are in this Loop but have another `loop_id`) and the next iterator of the last output loop port (or another LoopEnd that- * are in this Loop but have another `loop_id`).+ * - Otherwise Loop bounds are iterators of the first input loop port (or Scalar, VectorBuffer and another+ * LoopBegin that are in this Loop but have another `loop_id`) and the next iterator of the last output+ * loop port (or another LoopEnd that are in this Loop but have another `loop_id`).* @param linear_ir linear IR* @param loop_id target Loop ID* @return the pair of loop_begin_pos and loop_end_pos iterators@@ -243,16 +279,19 @@ public:* @brief Find bounds of Loop:* - If the explicit Loop exprs with the target `loop_id` have been inserted,* Loop bounds are these iterators of the corresponding LoopBegin and LoopEnd.- * - Otherwise Loop bounds are iterators of the first input loop port (or Scalar, VectorBuffer and another LoopBegin that- * are in this Loop but have another `loop_id`) and the next iterator of the last output loop port (or another LoopEnd that- * are in this Loop but have another `loop_id`).+ * - Otherwise Loop bounds are iterators of the first input loop port (or Scalar, VectorBuffer and another+ * LoopBegin that are in this Loop but have another `loop_id`) and the next iterator of the last output+ * loop port (or another LoopEnd that are in this Loop but have another `loop_id`).* @param linear_ir linear IR* @param loop_id target Loop ID* @param entries input loop ports* @param exits output loop ports* @return the pair of loop_begin_pos and loop_end_pos iterators*/- static LoopBounds get_loop_bounds(const LinearIR& linear_ir, size_t loop_id, const std::vector<LoopPort>& entries, const std::vector<LoopPort>& exits);+ static LoopBounds get_loop_bounds(const LinearIR& linear_ir,+ size_t loop_id,+ const std::vector<LoopPort>& entries,+ const std::vector<LoopPort>& exits);/*** @brief Get LoopPort by ExpressionPort@@ -300,7 +339,9 @@ private:* @param input_ports ref of input LoopPorts of lower Loop* @param loop_id ID of the new Loop after fusion*/- static void fuse_loop_ports(std::vector<LoopPort>& output_ports, std::vector<LoopPort>& input_ports, size_t loop_id);+ static void fuse_loop_ports(std::vector<LoopPort>& output_ports,+ std::vector<LoopPort>& input_ports,+ size_t loop_id);/* ===== The methods for work with Loop IDs of Expression ===== */// Notes:@@ -313,7 +354,10 @@ private:// Default value of target ID - SIZE_MAX - for `after` the new Loop is the most inner Loop// for `before` the new Loop is the most outer Loopvoid insert_loop_id(const ExpressionPtr& expr, size_t new_id, bool before = true, size_t target_id = SIZE_MAX);- void insert_loop_ids(const ExpressionPtr& expr, const std::vector<size_t>& new_ids, bool before = true, size_t target_id = SIZE_MAX);+ void insert_loop_ids(const ExpressionPtr& expr,+ const std::vector<size_t>& new_ids,+ bool before = true,+ 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 = {};@@ -321,6 +365,6 @@ private:};using LoopManagerPtr = std::shared_ptr<LoopManager>;-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/loop_port.hpp b/src/common/snippets/include/snippets/lowered/loop_port.hppindex 119ab7fe703..5f6695e0d22 100644--- a/src/common/snippets/include/snippets/lowered/loop_port.hpp+++ b/src/common/snippets/include/snippets/lowered/loop_port.hpp@@ -4,11 +4,10 @@#pragma once-#include "snippets/lowered/expression_port.hpp"#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/expression_port.hpp"#include "snippets/utils/utils.hpp"-namespace ov {namespace snippets {namespace lowered {@@ -17,23 +16,23 @@ namespace lowered {*/class LoopPort {public:- enum {UNDEFINED_DIM_IDX = std::numeric_limits<size_t>::max()};+ enum { UNDEFINED_DIM_IDX = std::numeric_limits<size_t>::max() };enum class Type {- Incremented, // Loop port which data ptr should be incremented after each Loop iteration- NotIncremented, // 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 Loop bound definition+ Incremented, // Loop port which data ptr should be incremented after each Loop iteration+ NotIncremented, // 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+ // Loop bound definition};LoopPort() = default;- template<LoopPort::Type T,- typename std::enable_if<T == Type::Incremented || T == Type::NotIncremented, bool>::type = true>+ template <LoopPort::Type T,+ typename std::enable_if<T == Type::Incremented || T == Type::NotIncremented, bool>::type = true>static LoopPort create(const ExpressionPort& port, size_t dim_idx = 0) {return LoopPort(port, dim_idx, T);}- template<LoopPort::Type T,- typename std::enable_if<T == Type::NotProcessed, bool>::type = true>+ template <LoopPort::Type T, typename std::enable_if<T == Type::NotProcessed, bool>::type = true>static LoopPort create(const ExpressionPort& port) {return LoopPort(port, UNDEFINED_DIM_IDX, Type::NotProcessed);}@@ -44,15 +43,19 @@ public: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 { return m_expr_port; }- Type get_type() const { return m_type; }+ const std::shared_ptr<ExpressionPort>& get_expr_port() const {+ return m_expr_port;+ }+ Type get_type() const {+ return m_type;+ }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,+ typename std::enable_if<T == Type::Incremented || T == Type::NotIncremented, bool>::type = true>void convert_to_type() {OPENVINO_ASSERT(is_processed(), "NotProcessed LoopPort cannot change type!");m_type = T;@@ -65,12 +68,12 @@ private:LoopPort(const ExpressionPort& port, size_t dim_idx, Type type);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)+ 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 lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/pass/allocate_buffers.hpp b/src/common/snippets/include/snippets/lowered/pass/allocate_buffers.hppindex 1572d1653e3..5f5c048ae12 100644--- a/src/common/snippets/include/snippets/lowered/pass/allocate_buffers.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/allocate_buffers.hpp@@ -14,16 +14,17 @@ namespace pass {/*** @interface AllocateBuffers* @brief The pass allocates common memory for all Buffers.- * There are two modes: default and optimized allocation. Default allocation (non-optimized) mode sets unique offsets and ID to Buffers.- * Optimized mode allocates memory for Buffer ops using the following optimizations:+ * There are two modes: default and optimized allocation. Default allocation (non-optimized) mode sets unique+ * offsets and ID to Buffers. Optimized mode allocates memory for Buffer ops using the following optimizations:* - MemorySolver: helps to solve issue of optimal memory allocation;* - InPlace: Loop or MemoryAccess ops read from the memory and store data to the same memory if possible- * - Reusing Buffer RegGroups: Buffers have the same RegGroup (gpr) in cases when Buffers aren't connected or have the same data ptr shifts- * Note: All buffers are related to each other and represent common buffer scratchpad of Subgraph.- * The buffer scratchpad has one general data pointer. Each buffer has offset relative to the data pointer of buffer scratchpad.+ * - Reusing Buffer RegGroups: Buffers have the same RegGroup (gpr) in cases when Buffers aren't connected or+ * have the same data ptr shifts Note: All buffers are related to each other and represent common buffer+ * scratchpad of Subgraph. The buffer scratchpad has one general data pointer. Each buffer has offset+ * relative to the data pointer of buffer scratchpad.* @ingroup snippets*/-class AllocateBuffers: public RangedPass {+class AllocateBuffers : public RangedPass {public:OPENVINO_RTTI("AllocateBuffers", "", RangedPass)AllocateBuffers(bool is_optimized = true);@@ -39,7 +40,7 @@ private:bool m_is_optimized_mode = true;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/pass/assign_registers.hpp b/src/common/snippets/include/snippets/lowered/pass/assign_registers.hppindex 37d87373e3f..164e1eba98b 100644--- a/src/common/snippets/include/snippets/lowered/pass/assign_registers.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/assign_registers.hpp@@ -32,7 +32,7 @@ private:RegManager& m_reg_manager;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/pass/brgemm_blocking.hpp b/src/common/snippets/include/snippets/lowered/pass/brgemm_blocking.hppindex 5b924c9b865..4bf247f6d09 100644--- a/src/common/snippets/include/snippets/lowered/pass/brgemm_blocking.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/brgemm_blocking.hpp@@ -6,8 +6,8 @@#include "snippets/itt.hpp"#include "snippets/lowered/loop_manager.hpp"-#include "snippets/lowered/specific_loop_iter_handlers.hpp"#include "snippets/lowered/pass/iter_handler.hpp"+#include "snippets/lowered/specific_loop_iter_handlers.hpp"#include "snippets/op/brgemm.hpp"namespace ov {@@ -23,7 +23,8 @@ namespace pass {*/class BrgemmBlockingBase {public:- static snippets::lowered::SpecificIterationHandlers get_default_blocking_loop_handlers(size_t work_amount, size_t block_size);+ static snippets::lowered::SpecificIterationHandlers get_default_blocking_loop_handlers(size_t work_amount,+ size_t block_size);protected:/**@@ -32,14 +33,16 @@ 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(const ov::snippets::lowered::ExpressionPtr& brgemm_expr) const;+ virtual std::tuple<size_t, size_t, size_t> get_blocking_params(+ const ov::snippets::lowered::ExpressionPtr& brgemm_expr) const;/*** @interface get_brgemm_dimensions* @brief Extract current dimensions M,N,K of `brgemm_expr`* @param brgemm_expr Brgemm expression* @return tuple in format (M, N, K)*/- static std::tuple<size_t, size_t, size_t> get_brgemm_dimensions(const ov::snippets::lowered::ExpressionPtr& brgemm_expr);+ static std::tuple<size_t, size_t, size_t> get_brgemm_dimensions(+ const ov::snippets::lowered::ExpressionPtr& brgemm_expr);/*** @interface mark_blocking_loops* @brief Covers brgemm with blocking loops. Also should calculate optimal blocking parameters inside.@@ -118,7 +121,7 @@ public:return modified;}};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ov\ No newline at end of filediff --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 478db3d9522..3c7eb1e108a 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@@ -21,18 +21,20 @@ namespace pass {* This condition should be removed when Buffers stop being inplace by default.* @ingroup snippets*/-class CleanRepeatedDataPointerShifts: public RangedPass {+class CleanRepeatedDataPointerShifts : public RangedPass {public:OPENVINO_RTTI("CleanRepeatedDataPointerShifts", "", RangedPass)CleanRepeatedDataPointerShifts() = default;- bool run(lowered::LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) override;+ bool run(lowered::LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) override;private:bool reuse_increments(const LoopManagerPtr& loop_manager, const ExpressionPtr& loop_end_expr);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 5ee4efb2909..6a6c5cb676c 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@@ -14,16 +14,19 @@ namespace pass {/*** @interface CleanupLoopOffsets* @brief Loops are inserted with finalization offsets that reset all managed pointers to their initial values.- * This transformation "fuses" the offsets with an outer loop's ptr_increments, and zeroes the offsets before Results.+ * This transformation "fuses" the offsets with an outer loop's ptr_increments, and zeroes the offsets before+ * Results.* @ingroup snippets*/class CleanupLoopOffsets : public RangedPass {public:OPENVINO_RTTI("CleanupLoopOffsets", "", RangedPass);- bool run(lowered::LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) override;+ bool run(lowered::LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 8209e4adea9..1f1ecb7ec0f 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@@ -5,7 +5,6 @@#pragma once#include "pass.hpp"-#include "snippets/lowered/loop_manager.hpp"namespace ov {@@ -27,7 +26,7 @@ public:bool run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 aefb6ed39ac..14a6d0752b7 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@@ -5,7 +5,6 @@#pragma once#include "pass.hpp"-#include "snippets/lowered/loop_info.hpp"namespace ov {@@ -17,15 +16,17 @@ namespace pass {* @interface DefineBufferClusters* @brief The pass defines buffer clusters. The buffers from one cluster share the* same memory (has the same offset relative to the data pointer of buffer scratchpad).- * - If MemoryAccess op or Loop can read and write to the same (inplace behavior), the Buffers should be in the one cluster.- * - If Buffer is in the Loop which read or write from/to the other Buffers, this Buffer can emulate `window` slidings.- * It means that Buffer inside can reuse memory of Buffers outside in bounds of full Loop work.- * Demonstration:- * |-----------------------------------------------------|- * | |------------| |------------| | InnerLoops have work amount 128- * Buffer0 [3x128]-> | | InnerLoop0 | -> Buffer1 [3x128] -> | InnerLoop1 | | -> Buffer2 [3x128] OuterLoop has work amount 3- * | |------------| OuterLoop |------------| |- * |-----------------------------------------------------|+ * - If MemoryAccess op or Loop can read and write to the same (inplace behavior), the Buffers should be in the+ * one cluster.+ * - If Buffer is in the Loop which read or write from/to the other Buffers, this Buffer can emulate `window`+ * slidings. It means that Buffer inside can reuse memory of Buffers outside in bounds of full Loop work. Demonstration:+ * |-----------------------------------------------------|+ * | |------------| |------------| |+ * Buffer0 [3x128]-> | | InnerLoop0 | -> Buffer1 [3x128] -> | InnerLoop1 | | -> Buffer2 [3x128]+ * | |------------| OuterLoop |------------| |+ * |-----------------------------------------------------|+ * InnerLoops have work amount 128+ * OuterLoop has work amount 3* Buffer1 can reuse memory [128] of Buffer0 or Buffer2 in each iteration of OuterLoop* Note: The pass requires expression enumeration and buffer identification (for nested Buffers inplace).* These passes should be executed separately before this pass!@@ -42,7 +43,9 @@ public:* @param linear_ir the target Linear IR* @return status of the pass*/- bool run(lowered::LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) override;+ bool run(lowered::LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) override;private:using BufferCluster = std::set<BufferExpressionPtr>;@@ -55,14 +58,16 @@ private:*/BufferClusters::iterator find_cluster_by_expr(const BufferExpressionPtr& target);/**- * @brief Returns True if Buffer is direct source for the target expr (there aren't other loop between the Buffer and target expr)+ * @brief Returns True if Buffer is direct source for the target expr (there aren't other loop between the Buffer+ * and target expr)* @param buffer_expr expression with assumed Buffer op* @param target_expr expression with target op - LoopEnd or MemoryAccess op* @return boolean value*/static bool is_direct_buffer(const BufferExpressionPtr& buffer_expr, const ExpressionPtr& target_expr);/**- * @brief Creates new buffer cluster if buffer_exprs is missed in clusters. If buffer_exprs is already in clusters, do nothing+ * @brief Creates new buffer cluster if buffer_exprs is missed in clusters. If buffer_exprs is already in clusters,+ * do nothing* @param buffer_expr expression with Buffer op*/void create_new_cluster(const BufferExpressionPtr& buffer_expr);@@ -73,21 +78,23 @@ private:*/static void add_buffers_to_cluster(BufferCluster& existing_cluster, const std::set<BufferExpressionPtr>& buffers);/**- * @brief Returns common ID of cluster if all buffer inside have the same Buffer ID. Otherwise returns the default value SIZE_MAX- * that means that Buffers in cluster have different IDs.+ * @brief Returns common ID of cluster if all buffer inside have the same Buffer ID. Otherwise returns the default+ * value SIZE_MAX that means that Buffers in cluster have different IDs.* @param cluster set of Buffer expressions - cluster* @return common buffer ID or SIZE_MAX - size value*/static size_t get_cluster_buffer_id(const BufferCluster& cluster);/**- * @brief Analyzes Loop: if Loop has Buffer ops on inputs and outputs, Loop can read and write from/to the same memory.+ * @brief Analyzes Loop: if Loop has Buffer ops on inputs and outputs, Loop can read and write from/to the same+ * memory.* @param loop_manager loop manager* @param expr_it iterator of Linear IR which refers to the expression with LoopEnd*/void parse_loop(const LoopManagerPtr& loop_manager, const LinearIR::constExprIt& expr_it);/**- * @brief Analyzes full MemoryAccess op: if the op has Buffer ops on I/O, the op can read and write from/to the same memory.+ * @brief Analyzes full MemoryAccess op: if the op has Buffer ops on I/O, the op can read and write from/to the same+ * memory.* @param expr expression with full MemoryAccess op*/void parse_memory_access_op(const ExpressionPtr& expr);@@ -97,7 +104,8 @@ private:* @param loop_expr the target LoopEnd expression* @return input and output buffer maps*/- static std::pair<BufferMap, BufferMap> get_direct_buffers(const UnifiedLoopInfoPtr& loop_info, const ExpressionPtr& loop_expr);+ static std::pair<BufferMap, BufferMap> get_direct_buffers(const UnifiedLoopInfoPtr& loop_info,+ const ExpressionPtr& loop_expr);/*** @brief Analyzes nested Loops: unite nested buffer clusters if they can reproduce `window` sliding* @param loop_manager loop manager@@ -105,7 +113,9 @@ private:* @param output_buffers unordered map [Expression -> LoopPortInfo] which represents output Buffers of Loop* @param outer_loop_end_expr_it iterator of Linear IR which refers to the expression with outer LoopEnd*/- void parse_nested_loops(const LoopManagerPtr& loop_manager, const BufferMap& input_buffers, const BufferMap& output_buffers,+ void parse_nested_loops(const LoopManagerPtr& loop_manager,+ const BufferMap& input_buffers,+ const BufferMap& output_buffers,const LinearIR::constExprIt& outer_loop_end_expr_it);/*** @brief Finds the last connected Loop to the target Buffer and init the corresponding loop port info@@ -114,7 +124,8 @@ private:* @param port_info target loop port info to be initialized* @return status - True if loop port has been found. Otherwise, return false - not connected to the Loop.*/- static bool init_buffer_last_loop_port_info(const LoopManagerPtr& loop_manager, const BufferExpressionPtr& buffer_expr,+ static bool init_buffer_last_loop_port_info(const LoopManagerPtr& loop_manager,+ const BufferExpressionPtr& buffer_expr,UnifiedLoopInfo::LoopPortInfo& port_info);/*** @brief Unite clusters@@ -125,13 +136,16 @@ private:* @param is_outer_up true if outer buffer is upper in Linear IR than inner Buffers* @return Return True if clusters have been united*/- bool unite_nested_clusters(const LoopManagerPtr& loop_manager, const BufferClusters::iterator& inner_cluster_it, BufferCluster& outer_cluster,- const BufferExpressionPtr& outer_buffer, bool is_outer_up);+ bool unite_nested_clusters(const LoopManagerPtr& loop_manager,+ const BufferClusters::iterator& inner_cluster_it,+ BufferCluster& outer_cluster,+ const BufferExpressionPtr& outer_buffer,+ bool is_outer_up);BufferClusters m_clusters;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 99432e7ac88..11d2782a299 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@@ -25,7 +25,7 @@ public:bool run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/pass/fuse_loops.hpp b/src/common/snippets/include/snippets/lowered/pass/fuse_loops.hppindex 53b0585b0be..2c579865e94 100644--- a/src/common/snippets/include/snippets/lowered/pass/fuse_loops.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/fuse_loops.hpp@@ -5,7 +5,6 @@#pragma once#include "pass.hpp"-#include "snippets/lowered/loop_manager.hpp"namespace ov {@@ -23,7 +22,8 @@ namespace pass {* Loop_1 (Current) Loop_0 + Loop_1 => new `Loop_1`* * It's possible only if other consumers of Loop_0 are after Loop_1 in Linear IR.* Because Upper Loop_0 will be explicitly moved before Current Loop_1 in linear IR,- * and we must save control dependency (to avoid cases when after fusion some consumers of Loop_0 are before this Loop)+ * and we must save control dependency (to avoid cases when after fusion some consumers of Loop_0 are before+ * this Loop)** - Lower Loop is fused into the Current Loop* Loop_0 (Current) Loop_0 + Loop_1 => new `Loop_0`@@ -31,7 +31,8 @@ namespace pass {* Loop_1 (Lower) |* * It's possible only if other parents of Loop_1 are before Loop_0 in Linear IR.* Because Lower Loop_1 will be explicitly moved after Current Loop_0 in linear IR,- * and we must save control dependency (to avoid cases when after fusion some parents of Loop_1 are after this Loop)+ * and we must save control dependency (to avoid cases when after fusion some parents of Loop_1 are after+ * this Loop)** The main conditions of possible fusion is the equal increments and the equal/broadcastable work amounts.* @ingroup snippets@@ -45,22 +46,32 @@ public:static bool can_be_fused(const UnifiedLoopInfoPtr& loop_upper, const UnifiedLoopInfoPtr& loop_lower);private:- // This method checks that all ports which connect lower and upper loops are incremented.+ // This method checks that all ports which connect lower and upper loops are incremented.// This helps to avoid fusing for the ports with incompleted datastatic bool loop_ports_are_compatible(const LoopInfoPtr& loop_upper, const LoopInfoPtr& loop_lower);- static bool fuse_upper_into_current(LinearIR& linear_ir, const LoopManagerPtr& loop_manager,+ static bool fuse_upper_into_current(LinearIR& linear_ir,+ const LoopManagerPtr& loop_manager,const std::shared_ptr<ExpressionPort>& current_input_port,- size_t current_loop_id, size_t target_loop_id,- LinearIR::constExprIt& current_loop_begin_pos, LinearIR::constExprIt& current_loop_end_pos);- static bool fuse_lower_into_current(LinearIR& linear_ir, const LoopManagerPtr& loop_manager,+ size_t current_loop_id,+ size_t target_loop_id,+ LinearIR::constExprIt& current_loop_begin_pos,+ 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,- size_t current_loop_id, size_t target_loop_id,- LinearIR::constExprIt& current_loop_begin_pos, LinearIR::constExprIt& current_loop_end_pos);- static void move(LinearIR& linear_ir, const LoopManagerPtr& loop_manager, size_t loop_id,- LinearIR::constExprIt loop_begin_pos, LinearIR::constExprIt loop_end_pos, LinearIR::constExprIt pos);+ size_t current_loop_id,+ size_t target_loop_id,+ LinearIR::constExprIt& current_loop_begin_pos,+ LinearIR::constExprIt& current_loop_end_pos);+ static void move(LinearIR& linear_ir,+ const LoopManagerPtr& loop_manager,+ size_t loop_id,+ LinearIR::constExprIt loop_begin_pos,+ LinearIR::constExprIt loop_end_pos,+ LinearIR::constExprIt pos);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 6c48e1fb022..15d30d7102d 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@@ -13,7 +13,8 @@ namespace pass {/*** @interface InitBuffersDefault- * @brief The pass inits Buffer expressions in LinearIR default (non-optimized): sets unique offsets and reg groups to Buffers.+ * @brief The pass inits Buffer expressions in LinearIR default (non-optimized): sets unique offsets and reg groups to+ * Buffers.* @ingroup snippets*/@@ -29,13 +30,15 @@ public:* @param linear_ir the target Linear IR* @return status of the pass*/- bool run(lowered::LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) override;+ bool run(lowered::LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) override;private:size_t& m_buffer_scratchpad_size;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 7591dd28d09..21bb0017a79 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@@ -15,7 +15,8 @@ namespace pass {/*** @interface InitLiveRanges- * @brief Calculates live ranges of registers. This information will be used to assign registers and optimize ABI reg spills.+ * @brief Calculates live ranges of registers. This information will be used to assign registers and optimize ABI reg+ * spills.* @ingroup snippets*/class InitLiveRanges : public Pass {@@ -23,11 +24,12 @@ public:OPENVINO_RTTI("InitLiveRanges", "", Pass)explicit InitLiveRanges(RegManager& reg_manager) : m_reg_manager(reg_manager) {}bool run(LinearIR& linear_ir) override;+private:RegManager& m_reg_manager;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/pass/init_loops.hpp b/src/common/snippets/include/snippets/lowered/pass/init_loops.hppindex ce010716fbe..f56f21283c8 100644--- a/src/common/snippets/include/snippets/lowered/pass/init_loops.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/init_loops.hpp@@ -5,7 +5,6 @@#pragma once#include "pass.hpp"-#include "snippets/lowered/loop_manager.hpp"namespace ov {@@ -28,7 +27,7 @@ private:static void update_compile_parameters(const UnifiedLoopInfoPtr& loop_info);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/pass/init_registers.hpp b/src/common/snippets/include/snippets/lowered/pass/init_registers.hppindex d0f881636af..0cf9c294982 100644--- a/src/common/snippets/include/snippets/lowered/pass/init_registers.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/init_registers.hpp@@ -21,8 +21,7 @@ namespace pass {class InitRegisters : public Pass {public:OPENVINO_RTTI("InitRegisters", "0", Pass)- InitRegisters(const std::shared_ptr<const Generator>& generator,- const std::shared_ptr<PassConfig>& pass_config);+ InitRegisters(const std::shared_ptr<const Generator>& generator, const std::shared_ptr<PassConfig>& pass_config);bool run(LinearIR& linear_ir) override;private:@@ -30,7 +29,7 @@ private:const std::shared_ptr<PassConfig>& m_pass_config;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/pass/insert_broadcastmove.hpp b/src/common/snippets/include/snippets/lowered/pass/insert_broadcastmove.hppindex 876e0f84df0..3f025298838 100644--- a/src/common/snippets/include/snippets/lowered/pass/insert_broadcastmove.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/insert_broadcastmove.hpp@@ -22,13 +22,14 @@ public:bool run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) override;static bool is_broadcasting_supported(const std::shared_ptr<ov::Node>& n);+private:static bool is_broadcasting_needed(const std::shared_ptr<ov::Node>& n);static std::vector<size_t> get_last_dims(const ExpressionPtr& expr);static size_t get_max_dim(const std::vector<size_t>& last_dims);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/pass/insert_buffers.hpp b/src/common/snippets/include/snippets/lowered/pass/insert_buffers.hppindex c0e15ec94c1..6432195a850 100644--- a/src/common/snippets/include/snippets/lowered/pass/insert_buffers.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/insert_buffers.hpp@@ -5,7 +5,6 @@#pragma once#include "pass.hpp"-#include "snippets/lowered/loop_manager.hpp"namespace ov {@@ -18,7 +17,8 @@ namespace pass {* @brief The pass inserts Buffer between output ports of one loop (or Brgemm) and* input ports of another loop (or Brgemm) to store intermediate data.* The pass should be called after FuseLoops.- * @param m_buffer_allocation_rank - rank of shape for memory allocation: shape[shape_rank - normalize(m_allocation_rank) : shape_rank]+ * @param m_buffer_allocation_rank - rank of shape for memory allocation:+ * shape[shape_rank - normalize(m_allocation_rank) : shape_rank]* @ingroup snippets*/class InsertBuffers : public RangedPass {@@ -41,7 +41,7 @@ private:const ExpressionPtr& down_expr);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ov\ No newline at end of filediff --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 8aaf2eaa4cc..0ab623a5b56 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@@ -5,7 +5,6 @@#pragma once#include "pass.hpp"-#include "snippets/lowered/loop_manager.hpp"namespace ov {@@ -15,8 +14,9 @@ namespace pass {/*** @interface InsertLoadStore- * @brief The pass inserts Load and Store expressions in Linear IR after Parameters, Buffers and before Results, Buffers accordingly.- * Note: The pass should be called after FuseLoops and InsertBuffers passes to have all possible data expressions.+ * @brief The pass inserts Load and Store expressions in Linear IR after Parameters, Buffers and before Results, Buffers+ * accordingly. Note: The pass should be called after FuseLoops and InsertBuffers passes to have all possible data+ * expressions.* @param m_vector_size - the count of elements for loading/storing* @ingroup snippets*/@@ -34,7 +34,7 @@ private:size_t m_vector_size;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/pass/insert_loops.hpp b/src/common/snippets/include/snippets/lowered/pass/insert_loops.hppindex 62a8267fea2..9ef77d6de4d 100644--- a/src/common/snippets/include/snippets/lowered/pass/insert_loops.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/insert_loops.hpp@@ -5,9 +5,8 @@#pragma once#include "pass.hpp"--#include "snippets/op/loop.hpp"#include "snippets/lowered/loop_manager.hpp"+#include "snippets/op/loop.hpp"namespace ov {namespace snippets {@@ -24,11 +23,12 @@ public:OPENVINO_RTTI("InsertLoops", "", RangedPass);InsertLoops() = default;bool run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) override;+private:static void insertion(LinearIR& linear_ir, const LoopManagerPtr& loop_manager, size_t loop_id);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 a30efc84655..99698c05807 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@@ -3,11 +3,10 @@//#ifdef SNIPPETS_DEBUG_CAPS-#pragma once+# pragma once-#include "pass.hpp"--#include "snippets/op/perf_count.hpp"+# include "pass.hpp"+# include "snippets/op/perf_count.hpp"namespace ov {namespace snippets {@@ -21,7 +20,7 @@ namespace pass {* Developers could modify this to insert perf count pairs around interested sequence of nodes.* @ingroup snippets*/-class InsertPerfCount: public RangedPass {+class InsertPerfCount : public RangedPass {public:OPENVINO_RTTI("InsertPerfCount", "", RangedPass);InsertPerfCount(std::map<std::string, std::string> boundary_op_names);@@ -31,8 +30,8 @@ private:std::map<std::string, std::string> m_boundary_op_names;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ov#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 bc9ada61f68..b5d2a7d327b 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@@ -4,14 +4,14 @@#ifdef SNIPPETS_DEBUG_CAPS-#pragma once+# pragma once-#include "snippets/itt.hpp"-#include "snippets/lowered/loop_manager.hpp"-#include "snippets/lowered/specific_loop_iter_handlers.hpp"-#include "snippets/lowered/pass/iter_handler.hpp"-#include "snippets/op/brgemm.hpp"-#include "snippets/utils/utils.hpp"+# 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 {@@ -39,9 +39,9 @@ private:std::string m_subgraph_name;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ov#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 fa51db7df1f..a8fbb53c861 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@@ -29,8 +29,9 @@ class InsertRegSpills : public Pass {public:OPENVINO_RTTI("InsertRegSpills", "", Pass)explicit InsertRegSpills(RegManager& reg_manager,- std::function<bool(const ExpressionPtr&)> needs_reg_spill = needs_reg_spill_default) :- m_reg_manager(reg_manager), m_needs_reg_spill(std::move(needs_reg_spill)) {}+ std::function<bool(const ExpressionPtr&)> needs_reg_spill = needs_reg_spill_default)+ : m_reg_manager(reg_manager),+ m_needs_reg_spill(std::move(needs_reg_spill)) {}bool run(LinearIR& linear_ir) override;private:@@ -38,7 +39,7 @@ private:std::function<bool(const ExpressionPtr&)> m_needs_reg_spill;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 44acda6d8b0..0affddad452 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@@ -5,12 +5,10 @@#pragma once#include "pass.hpp"--#include "snippets/lowered/specific_loop_iter_types.hpp"#include "snippets/lowered/loop_manager.hpp"+#include "snippets/lowered/specific_loop_iter_types.hpp"#include "snippets/op/loop.hpp"-namespace ov {namespace snippets {namespace lowered {@@ -32,26 +30,35 @@ public:* @brief Check if specific Loop iterations needed* @param unified_loop_info loop info of the original (unified) Loop* @param type type of the specific loop iterations- * @param remaining_work_amount the work amount on the current moment (after applying of the previous loop decomposed parts)+ * @param remaining_work_amount the work amount on the current moment (after applying of the previous loop+ * decomposed parts)* @return True if needed otherwise - False*/- static bool is_decomposed_loop_needed(const UnifiedLoopInfoPtr& unified_loop_info, SpecificLoopIterType type, size_t remaining_work_amount);+ static bool is_decomposed_loop_needed(const UnifiedLoopInfoPtr& unified_loop_info,+ SpecificLoopIterType type,+ size_t remaining_work_amount);/*** @brief Calculate work amount of specific Loop iterations* @param unified_loop_info loop info of the original (unified) Loop* @param type type of the specific loop iterations- * @param remaining_work_amount the work amount on the current moment (after applying of the previous loop decomposed parts)+ * @param remaining_work_amount the work amount on the current moment (after applying of the previous loop+ * decomposed parts)* @return work amount*/- static size_t get_decomposed_loop_work_amount(const UnifiedLoopInfoPtr& unified_loop_info, SpecificLoopIterType type, size_t remaining_work_amount);+ static size_t get_decomposed_loop_work_amount(const UnifiedLoopInfoPtr& unified_loop_info,+ SpecificLoopIterType type,+ size_t remaining_work_amount);/*** @brief Calculate increment of specific Loop iterations* @param unified_loop_info loop info of the original (unified) Loop* @param type type of the specific loop iterations- * @param remaining_work_amount the work amount on the current moment (after applying of the previous loop decomposed parts)+ * @param remaining_work_amount the work amount on the current moment (after applying of the previous loop+ * decomposed parts)* @return increment*/- static size_t get_decomposed_loop_increment(const UnifiedLoopInfoPtr& unified_loop_info, SpecificLoopIterType type, size_t remaining_work_amount);+ static size_t get_decomposed_loop_increment(const UnifiedLoopInfoPtr& unified_loop_info,+ SpecificLoopIterType type,+ size_t remaining_work_amount);private:/**@@ -62,7 +69,10 @@ private:* @param loop_end the target LoopEnd* @return True if the Loop has been successfully decomposed, otherwise returns False.*/- static bool decompose(LinearIR& linear_ir, LinearIR::constExprIt begin, LinearIR::constExprIt end, const std::shared_ptr<op::LoopEnd>& loop_end);+ static bool decompose(LinearIR& linear_ir,+ LinearIR::constExprIt begin,+ LinearIR::constExprIt end,+ const std::shared_ptr<op::LoopEnd>& loop_end);/*** @brief Make a copy of Loop with ID `loop_id` and insert to LinearIR before `insert_pos`* @param linear_ir target Linear IR@@ -72,8 +82,11 @@ private:* @param new_exit_ports reference of vector with Loop output ports that will be updated after insertion* @return LoopBounds: iterators of new LoopBegin and LoopEnd*/- static LoopManager::LoopBounds insert_copy_loop(LinearIR& linear_ir, const size_t loop_id, const LinearIR::constExprIt& insert_pos,- std::vector<LoopPort>& new_entry_ports, std::vector<LoopPort>& new_exit_ports);+ static LoopManager::LoopBounds insert_copy_loop(LinearIR& linear_ir,+ const size_t loop_id,+ const LinearIR::constExprIt& insert_pos,+ std::vector<LoopPort>& new_entry_ports,+ std::vector<LoopPort>& new_exit_ports);/*** @brief Initializes decomposed loop: update ptr arithmetic, work_amout, increment, ID* @param linear_ir target Linear IR@@ -83,12 +96,15 @@ private:* @param unified_loop_id ID of the unified loop* @param decomposed_loop_end LoopEnd of the decomposed loop*/- static void init_decomposed_loop(LinearIR& linear_ir, LinearIR::constExprIt begin, LinearIR::constExprIt end,- const ExpandedLoopInfoPtr& decomposed_loop_info, size_t unified_loop_id,+ static void init_decomposed_loop(LinearIR& linear_ir,+ LinearIR::constExprIt begin,+ LinearIR::constExprIt end,+ const ExpandedLoopInfoPtr& decomposed_loop_info,+ size_t unified_loop_id,const std::shared_ptr<op::LoopEnd>& decomposed_loop_end);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/pass/iter_handler.hpp b/src/common/snippets/include/snippets/lowered/pass/iter_handler.hppindex 6fc2763f7db..60c59f02fd2 100644--- a/src/common/snippets/include/snippets/lowered/pass/iter_handler.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/iter_handler.hpp@@ -49,7 +49,8 @@ private:/*** @interface SetLoopIncrementOne- * @brief The pass set `increment = 1` to ExpandedLoopInfo which is mapped on LoopEnd in the passed iterator `end` and to this LoopEnd.+ * @brief The pass set `increment = 1` to ExpandedLoopInfo which is mapped on LoopEnd in the passed iterator `end` and+ * to this LoopEnd.* @ingroup snippets*/class SetLoopIncrementOne : public snippets::lowered::pass::RangedPass {@@ -59,10 +60,11 @@ public:bool run(snippets::lowered::LinearIR& linear_ir,snippets::lowered::LinearIR::constExprIt begin,snippets::lowered::LinearIR::constExprIt end) override;- std::shared_ptr<snippets::lowered::pass::PassBase> merge(const std::shared_ptr<snippets::lowered::pass::PassBase>& other) override;+ std::shared_ptr<snippets::lowered::pass::PassBase> merge(+ 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 pass+} // namespace lowered+} // namespace snippets+} // namespace ov\ No newline at end of filediff --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 5986b6f1874..6c2cff8dfd2 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@@ -16,7 +16,7 @@ namespace pass {* @brief Fuses consecutive Load and MoveBroadcast into a single load insctruction.* @ingroup snippets*/-class LoadMoveBroadcastToBroadcastLoad: public RangedPass {+class LoadMoveBroadcastToBroadcastLoad : public RangedPass {public:LoadMoveBroadcastToBroadcastLoad() = default;OPENVINO_RTTI("LoadMoveBroadcastToBroadcastLoad", "", RangedPass);diff --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 ba036586f57..73a41d19876 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@@ -20,7 +20,7 @@ namespace pass {* the same loop pointer arithmetic in runtime.* @ingroup snippets*/-class MarkInvariantShapePath: public RangedPass {+class MarkInvariantShapePath : public RangedPass {public:OPENVINO_RTTI("MarkInvariantShapePath", "", RangedPass);MarkInvariantShapePath() = default;@@ -59,7 +59,7 @@ private:static ov::RTMap& get_rt_info(const ExpressionPort& port);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/pass/mark_loops.hpp b/src/common/snippets/include/snippets/lowered/pass/mark_loops.hppindex 20056eae3da..6213984aa91 100644--- a/src/common/snippets/include/snippets/lowered/pass/mark_loops.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/mark_loops.hpp@@ -6,7 +6,6 @@#include "pass.hpp"-namespace ov {namespace snippets {namespace lowered {@@ -30,7 +29,7 @@ private:size_t m_vector_size;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 7a49f5942f1..878c5f5c848 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@@ -16,31 +16,32 @@ namespace pass {class SetDynamicWAToOuterMostLoop;/*** @class MHAParallelWAOptimizer- * @brief Optimizes the dynamic MHA execution increasing parallel work amount dy dividing Brgemm's "M" dimension to "parallel_m"- * and "kernel_m". Uses heuristics from snippets::pass::SplitDimensionM for dimension splitting.- * The optimizer performs the following steps:+ * @brief Optimizes the dynamic MHA execution increasing parallel work amount dy dividing Brgemm's "M" dimension to+ * "parallel_m" and "kernel_m". Uses heuristics from snippets::pass::SplitDimensionM for dimension splitting. The+ * optimizer performs the following steps:* - Identifies applicable Brgemm operations within the LinearIR.* - Finds parameters whose shapes and layouts need to be adjusted after the split.* - Determines loops that should be adjusted.*/class MHAParallelWAOptimizer : public lowered::pass::RuntimeOptimizer {friend class SetDynamicWAToOuterMostLoop;+public:OPENVINO_RTTI("MHAParallelWAOptimizer", "", RuntimeOptimizer)MHAParallelWAOptimizer() = default;MHAParallelWAOptimizer(const lowered::LinearIRCPtr& linear_ir, const RuntimeConfigurator* configurator);bool run(const lowered::LinearIR& linear_ir) override;- bool applicable() const override { return !m_loops_to_split.empty(); }+ bool applicable() const override {+ return !m_loops_to_split.empty();+ }private:- static std::unordered_set<lowered::ExpressionPtr> find_applicable_brgemms(- const lowered::LinearIRCPtr& linear_ir,- bool check_dynamic_wa = true);+ static std::unordered_set<lowered::ExpressionPtr> find_applicable_brgemms(const lowered::LinearIRCPtr& linear_ir,+ bool check_dynamic_wa = true);- static std::unordered_set<size_t> find_unsqueezed_params(- const lowered::LinearIRCPtr& linear_ir,- const std::unordered_set<lowered::ExpressionPtr>& brgemms);+ static std::unordered_set<size_t> find_unsqueezed_params(const lowered::LinearIRCPtr& linear_ir,+ const std::unordered_set<lowered::ExpressionPtr>& brgemms);static std::vector<lowered::ExpandedLoopInfoPtr> find_loops_to_split(const lowered::LinearIRCPtr& linear_ir,@@ -55,7 +56,7 @@ private:static const size_t m_dim_M_idx;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ov\ No newline at end of filediff --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 9cf07418a74..82e88a89c3b 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@@ -26,7 +26,7 @@ public:bool run(LinearIR& linear_ir) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 121b8302721..afdfbbb616e 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@@ -14,12 +14,11 @@ namespace pass {/*** @interface MoveScalarToConsumer* @brief As a result of loop insertion or fusion, Scalar operations might end up outside of the loop where their- * consumer is located. This transformation moves every scalar right before its consumer. This is needed to guarantee- * computation validity and also to optimize register allocation.- * Details:- * If ScalarEmitters are called outside the Loop, and only the first Loop iteration would yield correct data- * (assuming the vector reg assigned to scalar will get corrupted inside the loop body).- * To avoid such cases, we move Constants to the places in Linear IR before right Consumer to execute Scalar on each Loop iteration.+ * consumer is located. This transformation moves every scalar right before its consumer. This is needed to+ * guarantee computation validity and also to optimize register allocation. Details: If ScalarEmitters are+ * called outside the Loop, and only the first Loop iteration would yield correct data (assuming+ * the vector reg assigned to scalar will get corrupted inside the loop body). To avoid such cases, we move+ * Constants to the places in Linear IR before right Consumer to execute Scalar on each Loop iteration.* @ingroup snippets*/class MoveScalarToConsumer : public Pass {@@ -29,7 +28,7 @@ public:bool run(LinearIR& linear_ir) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 b98d7d46bfb..2a0685c8c42 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@@ -31,10 +31,12 @@ public:* @param linear_ir the target Linear IR* @return status of the pass*/- bool run(lowered::LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) override;+ bool run(lowered::LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 ca672392602..7e58843b453 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@@ -13,9 +13,9 @@ namespace pass {/*** @interface NormalizeLoopIDs- * @brief Sort loop IDs in the order of LoopEnd expressions execution and set them evenly: without missed numbers in IDs.- * Loops might have an arbitrary IDs ordering as a result of optimizations:- * IDs can be unsorted or non-consecutive (some are missing).+ * @brief Sort loop IDs in the order of LoopEnd expressions execution and set them evenly: without missed numbers in+ * IDs. Loops might have an arbitrary IDs ordering as a result of optimizations: IDs can be unsorted or non-consecutive+ * (some are missing).* For example,* [Loop -> ID -> new ID]* Loop0 -> 3 -> 0@@ -42,7 +42,7 @@ private:bool m_has_specific_loops = true;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/pass/optimize_domain.hpp b/src/common/snippets/include/snippets/lowered/pass/optimize_domain.hppindex b39707c7ca0..8a1ea53ebb0 100644--- a/src/common/snippets/include/snippets/lowered/pass/optimize_domain.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/optimize_domain.hpp@@ -18,13 +18,14 @@ namespace pass {* The pass collapses two last dimensions while none of them is broadcasted and the resulting dim size* 1. Dimension collapsing: If none of the last two dimensions are broadcasted, the last dimension's size* is less than min_kernel_work_amount and the remaining dimensions provide work amount larger than- * min_parallel_work_amount (min_kernel_work_amount and min_parallel_work_amount specified in LireanIR config),- * then these two dimensions are collapsed into one and the collapsing attempt is repeated.+ * min_parallel_work_amount (min_kernel_work_amount and min_parallel_work_amount specified in LinearIR+ * config), then these two dimensions are collapsed into one and the collapsing attempt is repeated.* 2. Tile rank increment: Tile rank is the rank of a tensor that processed during one call. If all except* for the last two dimensions provide work_amount larger than min_parallel_work_amount, then tile_rank* is incremented. This effectively increases kernel work_amount.* Examples of graphs before and after this transformations are depicted below.- * @param tile_rank (taken by reference) rank of a tensor that processed during one call. Incremented if dimensions are collapsed.+ * @param tile_rank (taken by reference) rank of a tensor that processed during one call. Incremented if dimensions are+ * collapsed.* @ingroup snippets*/// Example:@@ -62,7 +63,7 @@ private:size_t total_work_amount);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ov\ No newline at end of filediff --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 79d1fe6e489..4f0167720d2 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@@ -21,10 +21,12 @@ namespace pass {class OptimizeLoopSingleEvaluation : public RangedPass {public:OPENVINO_RTTI("OptimizeLoopSingleEvaluation", "", RangedPass);- bool run(lowered::LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) override;+ bool run(lowered::LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/pass/pass.hpp b/src/common/snippets/include/snippets/lowered/pass/pass.hppindex b9f7aaeda9d..3eb2cc30eb0 100644--- a/src/common/snippets/include/snippets/lowered/pass/pass.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/pass.hpp@@ -4,11 +4,11 @@#pragma once+#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 "openvino/core/rtti.hpp"-#include "openvino/core/type.hpp"namespace ov {namespace snippets {@@ -27,7 +27,7 @@ public:// Note that get_type_info_static and get_type_info are needed to mimic OPENVINO_RTTI interface,// so the standard OPENVINO_RTTI(...) macros could be used in derived classes._OPENVINO_HIDDEN_METHOD static const ::ov::DiscreteTypeInfo& get_type_info_static() {- static ::ov::DiscreteTypeInfo type_info_static {"snippets::lowered::pass::PassBase"};+ static ::ov::DiscreteTypeInfo type_info_static{"snippets::lowered::pass::PassBase"};type_info_static.hash();return type_info_static;}@@ -99,7 +99,9 @@ public:* @param end end of the range on which the pass is performed* @return status of the pass*/- virtual bool run(lowered::LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) = 0;+ virtual bool run(lowered::LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) = 0;};class PassPipeline {@@ -109,20 +111,29 @@ public:PassPipeline();PassPipeline(const std::shared_ptr<PassConfig>& pass_config);- const std::vector<std::shared_ptr<PassBase>>& get_passes() const { return m_passes; }- const std::shared_ptr<PassConfig>& get_pass_config() const { return m_pass_config; }- bool empty() const { return m_passes.empty(); }+ const std::vector<std::shared_ptr<PassBase>>& get_passes() const {+ return m_passes;+ }+ const std::shared_ptr<PassConfig>& get_pass_config() const {+ return m_pass_config;+ }+ bool empty() const {+ return m_passes.empty();+ }void register_pass(const snippets::pass::PassPosition& position, const std::shared_ptr<PassBase>& pass);void register_pass(const std::shared_ptr<PassBase>& pass);- template<typename T, class... Args>+ template <typename T, class... Args>void register_pass(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)...);register_pass(pass);}- template<typename T, class Pos, class... Args, std::enable_if<std::is_same<snippets::pass::PassPosition, Pos>::value, bool>() = true>+ template <typename T,+ class Pos,+ class... Args,+ std::enable_if<std::is_same<snippets::pass::PassPosition, Pos>::value, 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)...);@@ -133,14 +144,17 @@ public:void run(lowered::LinearIR& linear_ir) const;void run(const lowered::LinearIR& linear_ir) const;- void run(lowered::LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) const;+ void run(lowered::LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) const;/*** @brief Merges 2 pass pipelines into one* @param lhs first pass pipeline* @param rhs second pass pipeline* @return the merged pass pipeline- * @attention the function can not be used in case when one of the pipelines contains passes whose running order is important.+ * @attention the function can not be used in case when one of the pipelines contains passes whose running order is+ * important.*/static PassPipeline merge_pipelines(const PassPipeline& lhs, const PassPipeline& rhs);@@ -149,7 +163,7 @@ private:std::vector<std::shared_ptr<PassBase>> m_passes;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/pass/pass_config.hpp b/src/common/snippets/include/snippets/lowered/pass/pass_config.hppindex 90a45cc0eba..4feec5a2651 100644--- a/src/common/snippets/include/snippets/lowered/pass/pass_config.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/pass_config.hpp@@ -4,10 +4,9 @@#pragma once-#include "snippets/lowered/linear_ir.hpp"-#include "openvino/core/rtti.hpp"#include "openvino/core/type.hpp"+#include "snippets/lowered/linear_ir.hpp"namespace ov {namespace snippets {@@ -56,7 +55,7 @@ private:std::unordered_set<DiscreteTypeInfo> m_enabled;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 168877260c1..c892be5003c 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@@ -17,7 +17,7 @@ namespace pass {* Should be called after `SolveMemoryBuffer`.* @ingroup snippets*/-class PropagateBufferOffset: public Pass {+class PropagateBufferOffset : public Pass {public:OPENVINO_RTTI("PropagateBufferOffset", "", Pass);PropagateBufferOffset() = default;@@ -37,7 +37,7 @@ private:static void propagate(const BufferExpressionPtr& buffer_expr);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/pass/propagate_subtensors.hpp b/src/common/snippets/include/snippets/lowered/pass/propagate_subtensors.hppindex 5f8c39dd11e..f4a62ce7ca3 100644--- a/src/common/snippets/include/snippets/lowered/pass/propagate_subtensors.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/propagate_subtensors.hpp@@ -30,7 +30,7 @@ private:size_t m_tail_size;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ov\ No newline at end of filediff --git a/src/common/snippets/include/snippets/lowered/pass/reduce_decomposition.hpp b/src/common/snippets/include/snippets/lowered/pass/reduce_decomposition.hppindex c66f030e96a..0142d5d3dce 100644--- a/src/common/snippets/include/snippets/lowered/pass/reduce_decomposition.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/reduce_decomposition.hpp@@ -27,7 +27,7 @@ private:size_t m_vector_size = 0;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/pass/runtime_optimizer.hpp b/src/common/snippets/include/snippets/lowered/pass/runtime_optimizer.hppindex ec878e7a3be..9159a4baeb6 100644--- a/src/common/snippets/include/snippets/lowered/pass/runtime_optimizer.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/runtime_optimizer.hpp@@ -25,7 +25,8 @@ public:OPENVINO_ASSERT(configurator, "RuntimeConfigurator musn't be nullptr");}/**- * @brief Defines if this pass is applicable. If it is not applicable, its registration in pass pipeline can be skipped.+ * @brief Defines if this pass is applicable. If it is not applicable, its registration in pass pipeline can be+ * skipped.*/virtual bool applicable() const = 0;@@ -35,7 +36,9 @@ public:* @param pipeline The pipeline in which the pass should be registered.* @param args The arguments to be forwarded to the pass constructor.*/- template <typename OptimizerType, typename... Args, typename = std::enable_if<std::is_base_of<RuntimeOptimizer, OptimizerType>::value>>+ template <typename OptimizerType,+ typename... Args,+ typename = std::enable_if<std::is_base_of<RuntimeOptimizer, OptimizerType>::value>>static void register_if_applicable(PassPipeline& pipeline, Args&&... args) {auto pass = std::make_shared<OptimizerType>(std::forward<Args>(args)...);if (pass->applicable()) {@@ -47,7 +50,7 @@ protected:const RuntimeConfigurator* m_configurator = nullptr;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/pass/serialize_base.hpp b/src/common/snippets/include/snippets/lowered/pass/serialize_base.hppindex 2207592fbb2..f12083784d0 100644--- a/src/common/snippets/include/snippets/lowered/pass/serialize_base.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/serialize_base.hpp@@ -28,7 +28,7 @@ protected:const std::string m_bin_path;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 63ff92e88b6..354a0feeef7 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@@ -20,15 +20,16 @@ namespace pass {class SerializeControlFlow : public SerializeBase {public:OPENVINO_RTTI("SerializeControlFlow", "", SerializeBase)- SerializeControlFlow(const std::string& xml_path, bool update_dynamic_ops = false) :- SerializeBase(xml_path), m_update_dynamic_ops{update_dynamic_ops} {}+ SerializeControlFlow(const std::string& xml_path, bool update_dynamic_ops = false)+ : SerializeBase(xml_path),+ m_update_dynamic_ops{update_dynamic_ops} {}bool run(const LinearIR& linear_ir) override;private:const bool m_update_dynamic_ops = false;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 b85515916ac..75a2a42a3bb 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@@ -21,12 +21,12 @@ namespace pass {*/class SerializeDataFlow : public SerializeBase {public:- OPENVINO_RTTI("SerializeDataFlow", "", SerializeBase)+ OPENVINO_RTTI("SerializeDataFlow", "", SerializeBase)SerializeDataFlow(const std::string& xml_path) : SerializeBase(xml_path) {}bool run(const LinearIR& linear_ir) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 f59e2f77ade..555e2c7be1c 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@@ -5,7 +5,6 @@#pragma once#include "pass.hpp"-#include "snippets/lowered/loop_info.hpp"#include "snippets/utils/utils.hpp"@@ -23,13 +22,14 @@ namespace pass {* - Loops, Brgemm (the same other ops) - are "edges" between Buffers (hub of edges).* The buffers are connected to the same Loop - are adjacent in graph sense bounds.* - The vertices (buffers) are adjacent if they are connected to the same Loop and- * their data pointers cannot be proportionally incremented in Loops: different ptr increments or data sizes -- * or one of the Buffers is in some a Loop but another Buffer is not;+ * their data pointers cannot be proportionally incremented in Loops: different ptr increments or data sizes+ * - or one of the Buffers is in some a Loop but another Buffer is not;* - Firstly, create adjacency matrix using the definition above;- * - Secondly, assign the same color to non-adjacent vertices of graph (buffers), and use different colors otherwise.+ * - Secondly, assign the same color to non-adjacent vertices of graph (buffers), and use different colors+ * otherwise.* @ingroup snippets*/-class SetBufferRegGroup: public RangedPass {+class SetBufferRegGroup : public RangedPass {public:OPENVINO_RTTI("SetBufferRegGroup", "", RangedPass)SetBufferRegGroup() = default;@@ -42,12 +42,14 @@ public:bool run(LinearIR& linear_ir, LinearIR::constExprIt begin, LinearIR::constExprIt end) override;/**- * @brief Check if two Buffers can be in one register group by LoopDesc < data_size, ptr_increment, finalization_offset >+ * @brief Check if two Buffers can be in one register group by LoopDesc < data_size, ptr_increment,+ * finalization_offset >* @param lhs LoopPortInfo (Port and Data pointer shift params for first Buffer)* @param rhs LoopPortInfo (Port and Data pointer shift params for second Buffer)* @return Returns True if params are valid to reuse one register. Otherwise returns False*/- static bool can_be_in_one_reg_group(const UnifiedLoopInfo::LoopPortInfo& lhs, const UnifiedLoopInfo::LoopPortInfo& rhs);+ static bool can_be_in_one_reg_group(const UnifiedLoopInfo::LoopPortInfo& lhs,+ const UnifiedLoopInfo::LoopPortInfo& rhs);private:using BufferPool = std::vector<BufferExpressionPtr>;@@ -68,7 +70,9 @@ private:* @param pool set of Buffers from the Linear IR* @return adjacency matrix where True value means that Buffers are adjacent and cannot have the same ID*/- static std::vector<bool> create_adjacency_matrix(const LoopManagerPtr& loop_manager, LinearIR::constExprIt begin, LinearIR::constExprIt end,+ static std::vector<bool> create_adjacency_matrix(const LoopManagerPtr& loop_manager,+ LinearIR::constExprIt begin,+ LinearIR::constExprIt end,const BufferPool& pool);/*** @brief Algorithm of Graph coloring where vertices are Buffers@@ -80,15 +84,20 @@ private:/*** @brief Update the adjacency matrix:* - If Buffers are from the same Loops and connected to the same Loop and- * they have not proportionally ptr shift params for this Loop, the Buffers are adjacent - set value True in the matrix;- * - If one of Buffer inside Loop but another Buffer is connected to this Loop and this Buffer has not zero data shift params,- * the Buffers are adjacent - set value True in the matrix;- * @param lhs Pair where first value if Expression with first Buffer and second value is data pointer shift params for its- * @param rhs Pair where first value if Expression with second Buffer and second value is data pointer shift params for its+ * they have not proportionally ptr shift params for this Loop, the Buffers are adjacent - set value True+ * in the matrix;+ * - If one of Buffer inside Loop but another Buffer is connected to this Loop and this Buffer has not zero+ * data shift params, the Buffers are adjacent - set value True in the matrix;+ * @param lhs Pair where first value if Expression with first Buffer and second value is data pointer shift params+ * for its+ * @param rhs Pair where first value if Expression with second Buffer and second value is data pointer shift params+ * for its* @param buffers set of Buffers from the Linear IR* @param adj Target adjacency matrix*/- static void update_adj_matrix(const BufferMap::value_type& lhs, const BufferMap::value_type& rhs, const BufferPool& buffers,+ static void update_adj_matrix(const BufferMap::value_type& lhs,+ const BufferMap::value_type& rhs,+ const BufferPool& buffers,std::vector<bool>& adj);/**@@ -113,7 +122,7 @@ private:static BufferMap get_buffer_loop_inside(const LinearIR::constExprIt& loop_end_it);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 6daeb97ec8c..033de2358f2 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@@ -24,7 +24,7 @@ public:bool run(LinearIR& linear_ir) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 74e9d450af4..148954080a4 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@@ -6,7 +6,6 @@#include "pass.hpp"-namespace ov {namespace snippets {namespace lowered {@@ -25,7 +24,7 @@ public:bool run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 39614e71ae2..d7230eaefc4 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,9 +4,8 @@#pragma once-#include "pass.hpp"-#include "openvino/runtime/memory_solver.hpp"+#include "pass.hpp"namespace ov {namespace snippets {@@ -26,7 +25,8 @@ class SolveBufferMemory : public Pass {public:OPENVINO_RTTI("SolveBufferMemory", "", Pass);- SolveBufferMemory(size_t& static_buffer_scratchpad_size) : m_static_buffer_scratchpad_size(static_buffer_scratchpad_size) {}+ SolveBufferMemory(size_t& static_buffer_scratchpad_size)+ : m_static_buffer_scratchpad_size(static_buffer_scratchpad_size) {}/*** @brief Apply the pass to the Linear IR* @param linear_ir the target Linear IR@@ -70,7 +70,7 @@ private:size_t& m_static_buffer_scratchpad_size;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/pass/split_loops.hpp b/src/common/snippets/include/snippets/lowered/pass/split_loops.hppindex faad32e8510..6f0394284bc 100644--- a/src/common/snippets/include/snippets/lowered/pass/split_loops.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/split_loops.hpp@@ -12,6 +12,7 @@ namespace snippets {namespace lowered {namespace pass {+// clang-format off/*** @interface SplitLoops* @brief If Unified Loop `loop_1` has larger increment but the same works amount of Unified loop `loop_2`, that follows loop_1, then split loop_2@@ -28,6 +29,7 @@ namespace pass {* Split_loop_1_end (wa = 128, inc = 32)* @ingroup snippets*/+// clang-format onclass SplitLoops : public RangedPass {public:@@ -55,7 +57,7 @@ private:};};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ov\ No newline at end of filediff --git a/src/common/snippets/include/snippets/lowered/pass/validate.hpp b/src/common/snippets/include/snippets/lowered/pass/validate.hppindex c40ace1a60c..d9c1490d73f 100644--- a/src/common/snippets/include/snippets/lowered/pass/validate.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/validate.hpp@@ -27,7 +27,7 @@ private:std::unordered_map<ov::DiscreteTypeInfo, Validator> m_validation_map;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/pass/validate_buffers.hpp b/src/common/snippets/include/snippets/lowered/pass/validate_buffers.hppindex 57ebe11b219..254b4aba11a 100644--- a/src/common/snippets/include/snippets/lowered/pass/validate_buffers.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/validate_buffers.hpp@@ -23,7 +23,7 @@ public:bool run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 55338bd8200..0198a4888bd 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@@ -27,7 +27,7 @@ private:static void validate_loop_expressions(const LinearIR& linear_ir);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/pass/validate_shapes.hpp b/src/common/snippets/include/snippets/lowered/pass/validate_shapes.hppindex e1f3a90b7db..f1bf99216aa 100644--- a/src/common/snippets/include/snippets/lowered/pass/validate_shapes.hpp+++ b/src/common/snippets/include/snippets/lowered/pass/validate_shapes.hpp@@ -20,10 +20,12 @@ class ValidateShapes : public RangedPass {public:OPENVINO_RTTI("ValidateShapes", "", RangedPass)ValidateShapes() = default;- bool run(lowered::LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) override;+ bool run(lowered::LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) override;};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 0fb02e4ae13..50424c994cb 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@@ -5,10 +5,8 @@#pragma once#include "pass.hpp"-#include "snippets/lowered/loop_manager.hpp"-namespace ov {namespace snippets {namespace lowered {@@ -36,7 +34,7 @@ private:static void validate_loop_port_presence(const LinearIR& linear_ir);};-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/port_connector.hpp b/src/common/snippets/include/snippets/lowered/port_connector.hppindex 9336c032916..271778f5202 100644--- a/src/common/snippets/include/snippets/lowered/port_connector.hpp+++ b/src/common/snippets/include/snippets/lowered/port_connector.hpp@@ -7,9 +7,8 @@#include <memory>#include <vector>-#include "port_descriptor.hpp"#include "expression_port.hpp"-+#include "port_descriptor.hpp"namespace ov {namespace snippets {@@ -22,8 +21,12 @@ public:PortConnector() = default;explicit PortConnector(ExpressionPort source_descriptor, const std::set<ExpressionPort>& consumer_descriptors = {});- const ExpressionPort& get_source() const { return m_source_port; }- std::set<ExpressionPort> get_consumers() const { return m_consumer_ports; }+ const ExpressionPort& get_source() const {+ return m_source_port;+ }+ std::set<ExpressionPort> get_consumers() const {+ return m_consumer_ports;+ }void add_consumer(const ExpressionPort& consumer);void remove_consumer(const ExpressionPort& consumer);@@ -37,7 +40,6 @@ private:};using PortConnectorPtr = std::shared_ptr<PortConnector>;--} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/port_descriptor.hpp b/src/common/snippets/include/snippets/lowered/port_descriptor.hppindex fbd491b6399..1b55c5212d9 100644--- a/src/common/snippets/include/snippets/lowered/port_descriptor.hpp+++ b/src/common/snippets/include/snippets/lowered/port_descriptor.hpp@@ -4,11 +4,10 @@#pragma once-#include "openvino/core/node.hpp"#include "openvino/core/attribute_visitor.hpp"-#include "snippets/shape_types.hpp"+#include "openvino/core/node.hpp"#include "snippets/emitter.hpp"-+#include "snippets/shape_types.hpp"namespace ov {namespace snippets {@@ -19,6 +18,7 @@ class PortDescriptor;using PortDescriptorPtr = std::shared_ptr<PortDescriptor>;class PortDescriptor {friend class LinearIRBuilder;+public:explicit PortDescriptor(const ov::Input<ov::Node>& node,VectorDims subtensor_shape = {},@@ -37,9 +37,15 @@ public:PortDescriptor();const VectorDims& get_shape() const;- const VectorDims& get_subtensor() const {return m_subtensor_shape;}- const std::vector<size_t>& get_layout() const {return m_layout;}- const Reg& get_reg() const { return m_reg; }+ const VectorDims& get_subtensor() const {+ return m_subtensor_shape;+ }+ const std::vector<size_t>& get_layout() const {+ return m_layout;+ }+ const Reg& get_reg() const {+ return m_reg;+ }void set_shape(const VectorDims& tensor);void set_layout(const std::vector<size_t>& layout);@@ -51,11 +57,15 @@ public:void set_subtensor_dim(size_t idx, VectorDims::value_type value);std::string serialize() const;- bool empty() const { return m_layout.empty() && m_subtensor_shape.empty();}+ bool empty() const {+ return m_layout.empty() && m_subtensor_shape.empty();+ }PortDescriptorPtr clone() const;friend bool operator==(const PortDescriptor& lhs, const PortDescriptor& rhs);- friend bool operator!=(const PortDescriptor& lhs, const PortDescriptor& rhs) {return !(lhs == rhs);}+ friend bool operator!=(const PortDescriptor& lhs, const PortDescriptor& rhs) {+ return !(lhs == rhs);+ }private:void validate_arguments();@@ -66,12 +76,14 @@ private:/// \brief Minimal tensor size that could be processed in one callVectorDims m_subtensor_shape{};/// \brief The corresponding abstract/physical register- Reg m_reg { RegType::gpr, 0 };+ Reg m_reg{RegType::gpr, 0};/// Notes:/// - `m_tensor_shape` is dense shape which is controlled by expression outputs.- /// It means that the result of data writing of expression outputs should be read using this shape by the next expression inputs.- /// - `m_layout` is the order of data reading or writing by MemoryAccess ops. Note that only MemoryAccess ops may have `m_layout`.+ /// It means that the result of data writing of expression outputs should be read using this shape by the next+ /// expression inputs.+ /// - `m_layout` is the order of data reading or writing by MemoryAccess ops. Note that only MemoryAccess ops may+ /// have `m_layout`./// For other expressions this order parameter is simply ignored for now./// if it's input port of MemoryAccess expression:/// - `m_layout` shows how the data should be read (by which strides) using m_tensor_shape.@@ -83,8 +95,12 @@ class PortDescriptorUtils {public:static void set_port_descriptor_ptr(const ov::Input<ov::Node>& in, const PortDescriptorPtr& desc);static void set_port_descriptor_ptr(const ov::Output<ov::Node>& out, const PortDescriptorPtr& desc);- static void set_port_descriptor(const ov::Input<ov::Node>& in, std::vector<size_t> subtensor, std::vector<size_t> layout = {});- static void set_port_descriptor(const ov::Output<ov::Node>& out, std::vector<size_t> subtensor, std::vector<size_t> layout = {});+ static void set_port_descriptor(const ov::Input<ov::Node>& in,+ std::vector<size_t> subtensor,+ std::vector<size_t> layout = {});+ static void set_port_descriptor(const ov::Output<ov::Node>& out,+ std::vector<size_t> subtensor,+ std::vector<size_t> layout = {});static PortDescriptorPtr get_port_descriptor_ptr(const ov::Input<ov::Node>& in);static PortDescriptorPtr get_port_descriptor_ptr(const ov::Input<const ov::Node>& in);@@ -97,26 +113,32 @@ public:static void clean(const std::shared_ptr<ov::Node>& node);private:- static void init_default(std::vector<PortDescriptorPtr>& in_descs, std::vector<PortDescriptorPtr>& out_descs, const std::shared_ptr<ov::Node>& node);+ static void init_default(std::vector<PortDescriptorPtr>& in_descs,+ std::vector<PortDescriptorPtr>& out_descs,+ const std::shared_ptr<ov::Node>& node);};// PortDescriptorVectorAttribute is not copyable attribute!-// It's needed to avoid incorrect copies of rt info between different nodes in call copy_runtime_info() (for example, in transformations)-// The attribute must be manually copied if needed+// It's needed to avoid incorrect copies of rt info between different nodes in call copy_runtime_info() (for example, in+// transformations) The attribute must be manually copied if neededclass PortDescriptorVectorAttribute : public ov::RuntimeAttribute {public:OPENVINO_RTTI("PortDescriptorVectorAttribute", "", ov::RuntimeAttribute);PortDescriptorVectorAttribute() = default;- explicit PortDescriptorVectorAttribute(std::vector<PortDescriptorPtr> in_descs = {}, std::vector<PortDescriptorPtr> out_descs = {})- : inputs(std::move(in_descs)), outputs(std::move(out_descs)) {}+ explicit PortDescriptorVectorAttribute(std::vector<PortDescriptorPtr> in_descs = {},+ std::vector<PortDescriptorPtr> out_descs = {})+ : inputs(std::move(in_descs)),+ outputs(std::move(out_descs)) {}- bool is_copyable() const override { return false; }+ bool is_copyable() const override {+ return false;+ }std::vector<PortDescriptorPtr> inputs{};std::vector<PortDescriptorPtr> outputs{};};-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/lowered/reg_manager.hpp b/src/common/snippets/include/snippets/lowered/reg_manager.hppindex aff1a02979e..f439f0ba56e 100644--- a/src/common/snippets/include/snippets/lowered/reg_manager.hpp+++ b/src/common/snippets/include/snippets/lowered/reg_manager.hpp@@ -3,12 +3,13 @@//#pragma once+#include <type_traits>+#include "openvino/core/node.hpp"#include "snippets/emitter.hpp"-#include "snippets/lowered/expression.hpp"#include "snippets/generator.hpp"+#include "snippets/lowered/expression.hpp"#include "snippets/op/kernel.hpp"-#include <type_traits>/*** @interface RegManager@@ -27,8 +28,12 @@ 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 { return m_generator->get_op_out_reg_type(out); }- inline std::vector<Reg> get_vec_reg_pool() const { return m_generator->get_target_machine()->get_vec_reg_pool(); }+ inline 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 {+ return m_generator->get_target_machine()->get_vec_reg_pool();+ }inline 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");@@ -46,7 +51,12 @@ public:std::set<Reg> kernel_call;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) {return kernel_call.count(r) != 0; }), res.end());+ res.erase(std::remove_if(res.begin(),+ res.end(),+ [&kernel_call](const Reg& r) {+ return kernel_call.count(r) != 0;+ }),+ res.end());return res;}@@ -64,6 +74,6 @@ private:const std::shared_ptr<const Generator> m_generator;};-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 333a694277b..cd77e105a7b 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@@ -7,7 +7,6 @@#include "snippets/lowered/pass/pass.hpp"#include "snippets/lowered/specific_loop_iter_types.hpp"-namespace ov {namespace snippets {namespace lowered {@@ -62,7 +61,8 @@ public:m_last_iter_handlers.register_pass<T>(args...);}- static SpecificIterationHandlers merge_handlers(const SpecificIterationHandlers& lhs, const SpecificIterationHandlers& rhs);+ static SpecificIterationHandlers merge_handlers(const SpecificIterationHandlers& lhs,+ const SpecificIterationHandlers& rhs);private:pass::PassPipeline m_first_iter_handlers;@@ -70,6 +70,6 @@ private:pass::PassPipeline m_last_iter_handlers;};-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 dc60881b00b..10408ba0499 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@@ -8,9 +8,7 @@ namespace ov {namespace snippets {namespace lowered {-enum class SpecificLoopIterType {- FIRST_ITER, MAIN_BODY, LAST_ITER-};+enum class SpecificLoopIterType { FIRST_ITER, MAIN_BODY, LAST_ITER };inline std::ostream& operator<<(std::ostream& out, const SpecificLoopIterType& type) {switch (type) {@@ -29,6 +27,6 @@ inline std::ostream& operator<<(std::ostream& out, const SpecificLoopIterType& treturn out;}-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/brgemm.hpp b/src/common/snippets/include/snippets/op/brgemm.hppindex 4342048b7fb..aad1eeb4189 100644--- a/src/common/snippets/include/snippets/op/brgemm.hpp+++ b/src/common/snippets/include/snippets/op/brgemm.hpp@@ -4,8 +4,8 @@#pragma once-#include "openvino/op/op.hpp"#include "memory_access.hpp"+#include "openvino/op/op.hpp"#include "snippets/shape_inference/shape_inference.hpp"namespace ov {@@ -20,24 +20,42 @@ namespace op {class Brgemm : virtual public modifier::MemoryAccess, public ov::op::Op {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 = {});- 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 = {});+ 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 = {});+ 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 = {});Brgemm() = default;- size_t get_offset_a() const { return get_input_offset(0); }- size_t get_offset_b() const { return get_input_offset(1); }- size_t get_offset_c() const { return get_output_offset(0); }+ size_t get_offset_a() const {+ return get_input_offset(0);+ }+ size_t get_offset_b() const {+ return get_input_offset(1);+ }+ size_t get_offset_c() const {+ return get_output_offset(0);+ }static ov::element::Type get_output_type(const ov::element::Type& in_type0, const ov::element::Type& in_type1);void validate_and_infer_types() override;std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;- bool has_evaluate() const override { return false; }+ bool has_evaluate() const override {+ return false;+ }bool visit_attributes(AttributeVisitor& visitor) override;protected:@@ -47,9 +65,11 @@ protected: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(std::vector<size_t> layout_a,+ std::vector<size_t> layout_b,+ std::vector<size_t> layout_c);};-} // namespace op-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace op+} // namespace snippets+} // namespace ov\ No newline at end of filediff --git a/src/common/snippets/include/snippets/op/broadcastload.hpp b/src/common/snippets/include/snippets/op/broadcastload.hppindex ab7f7813967..3f09d15da16 100644--- a/src/common/snippets/include/snippets/op/broadcastload.hpp+++ b/src/common/snippets/include/snippets/op/broadcastload.hpp@@ -4,9 +4,10 @@#pragma once-#include "snippets/shape_inference/shape_infer_instances.hpp"#include <snippets/op/memory_access.hpp>+#include "openvino/op/op.hpp"+#include "snippets/shape_inference/shape_infer_instances.hpp"namespace ov {namespace snippets {@@ -14,7 +15,8 @@ namespace op {/*** @interface BroadcastLoad- * @brief Is generated for broadcasting by least varying dimension for non-blocked cases and the second varying dimension for blocked+ * @brief Is generated for broadcasting by least varying dimension for non-blocked cases and the second varying+ * dimension for blocked* @ingroup snippets*/class BroadcastLoad : public modifier::MemoryAccess, public ov::op::Op {@@ -24,13 +26,19 @@ public:BroadcastLoad(const Output<Node>& x, ov::Dimension bcast_dimension, size_t offset = 0lu);BroadcastLoad() = default;- size_t get_offset() const { return get_input_offset(0); }+ size_t get_offset() const {+ return get_input_offset(0);+ }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;- const ov::Dimension& get_bcast_dimension() {return bcast_dimension;}- void set_bcast_dimension(ov::Dimension new_dim) {bcast_dimension = std::move(new_dim);}+ const ov::Dimension& get_bcast_dimension() {+ return bcast_dimension;+ }+ void set_bcast_dimension(ov::Dimension new_dim) {+ bcast_dimension = std::move(new_dim);+ }// Note:BroadcastMove and BroadcastLoad are implemented as separate classes,// but have identical shapeInfer semantics. In order to avoid code duplication,@@ -39,10 +47,11 @@ public:struct ShapeInfer : public BroadcastShapeInfer<BroadcastLoad> {explicit ShapeInfer(const std::shared_ptr<Node>& n) : BroadcastShapeInfer<BroadcastLoad>(n) {}};+private:ov::Dimension bcast_dimension;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/broadcastmove.hpp b/src/common/snippets/include/snippets/op/broadcastmove.hppindex 1a2a0626c82..da6049f99f5 100644--- a/src/common/snippets/include/snippets/op/broadcastmove.hpp+++ b/src/common/snippets/include/snippets/op/broadcastmove.hpp@@ -28,8 +28,12 @@ public:std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;void validate_and_infer_types() override;- const ov::Dimension& get_bcast_dimension() {return bcast_dimension;}- void set_bcast_dimension(ov::Dimension new_dim) {bcast_dimension = std::move(new_dim);}+ const ov::Dimension& get_bcast_dimension() {+ return bcast_dimension;+ }+ void set_bcast_dimension(ov::Dimension new_dim) {+ bcast_dimension = std::move(new_dim);+ }// Note:BroadcastMove and BroadcastLoad are implemented as separate classes,// but have identical shapeInfer semantics. In order to avoid code duplication,// we created dummy ShapeInfer classes that are essentially instantiations@@ -42,6 +46,6 @@ protected:ov::Dimension bcast_dimension;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/buffer.hpp b/src/common/snippets/include/snippets/op/buffer.hppindex 46137d26165..db5b1dea0b8 100644--- a/src/common/snippets/include/snippets/op/buffer.hpp+++ b/src/common/snippets/include/snippets/op/buffer.hpp@@ -15,11 +15,12 @@ namespace op {/*** @interface Buffer* @brief This is a class for memory storage.- * The buffers can have source (called as "IntermediateMemory") and can be without source (called as "NewMemory").- * First one contains memory which was stored by source -> these buffers propagate output shape and element type from parents to output.- * Second one has passed `element_type` and `shape` by user - these attributes describe independent empty memory.- * The both behaviors are implemented via the corresponding classes which are derived from the class "Buffer::BaseImpl".- * It allows user to work with only the class "op::Buffer" - all needed logic is implemented in the field `m_impl`.+ * The buffers can have source (called as "IntermediateMemory") and can be without source (called as+ * "NewMemory"). First one contains memory which was stored by source -> these buffers propagate output shape and+ * element type from parents to output. Second one has passed `element_type` and `shape` by user - these attributes+ * describe independent empty memory. The both behaviors are implemented via the corresponding classes which are derived+ * from the class "Buffer::BaseImpl". It allows user to work with only the class "op::Buffer" - all needed logic is+ * implemented in the field `m_impl`.* @ingroup snippets*/class Buffer : public ov::op::Op {@@ -36,10 +37,13 @@ public:std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;- size_t get_allocation_size() const { return m_impl->get_allocation_size(); }+ size_t get_allocation_size() const {+ return m_impl->get_allocation_size();+ }class ShapeInfer : public IShapeInferSnippets {- std::shared_ptr<IShapeInferSnippets> m_impl_shape_infer {nullptr};+ std::shared_ptr<IShapeInferSnippets> m_impl_shape_infer{nullptr};+public:explicit ShapeInfer(const std::shared_ptr<ov::Node>& n);Result infer(const std::vector<VectorDimsRef>& input_shapes) override;@@ -64,11 +68,18 @@ private:public:IntermediateMemoryImpl() = default;- size_t get_allocation_size() const override { return utils::get_dynamic_value<size_t>(); }+ size_t get_allocation_size() const override {+ return utils::get_dynamic_value<size_t>();+ }std::shared_ptr<BaseImpl> clone() const override;void validate_and_infer_types(Buffer* buffer) const override;- bool visit_attributes(AttributeVisitor& visitor) override { return true; }- std::shared_ptr<IShapeInferSnippets> get_shape_infer() const override { return std::make_shared<ShapeInfer>(); }+ bool visit_attributes(AttributeVisitor& visitor) override {+ return true;+ }+ std::shared_ptr<IShapeInferSnippets> get_shape_infer() const override {+ return std::make_shared<ShapeInfer>();+ }+private:class ShapeInfer : public IShapeInferSnippets {public:@@ -86,10 +97,14 @@ private: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 { return std::make_shared<ShapeInfer>(m_shape); }+ std::shared_ptr<IShapeInferSnippets> get_shape_infer() const override {+ return std::make_shared<ShapeInfer>(m_shape);+ }+private:class ShapeInfer : public IShapeInferSnippets {ov::Shape m_shape;+public:explicit ShapeInfer(ov::Shape shape);Result infer(const std::vector<VectorDimsRef>& input_shapes) override;@@ -102,10 +117,9 @@ private:// This constructor is used only in clone_with_new_inputsBuffer(const OutputVector& arguments, std::shared_ptr<BaseImpl> impl);- const std::shared_ptr<BaseImpl> m_impl {nullptr};+ const std::shared_ptr<BaseImpl> m_impl{nullptr};};--} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/convert_saturation.hpp b/src/common/snippets/include/snippets/op/convert_saturation.hppindex 1be08a0c305..52f746b0e23 100644--- a/src/common/snippets/include/snippets/op/convert_saturation.hpp+++ b/src/common/snippets/include/snippets/op/convert_saturation.hpp@@ -5,6 +5,7 @@#pragma once#include <openvino/op/convert.hpp>+#include "openvino/op/op.hpp"namespace ov {@@ -30,9 +31,11 @@ public:std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;- bool has_evaluate() const override { return false; }+ bool has_evaluate() const override {+ return false;+ }};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/convert_truncation.hpp b/src/common/snippets/include/snippets/op/convert_truncation.hppindex 1d208582692..1cffa09b2c3 100644--- a/src/common/snippets/include/snippets/op/convert_truncation.hpp+++ b/src/common/snippets/include/snippets/op/convert_truncation.hpp@@ -5,6 +5,7 @@#pragma once#include <openvino/op/convert.hpp>+#include "openvino/op/op.hpp"namespace ov {@@ -29,9 +30,11 @@ public:std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;- bool has_evaluate() const override { return false; }+ bool has_evaluate() const override {+ return false;+ }};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/fill.hpp b/src/common/snippets/include/snippets/op/fill.hppindex a9be36a861c..82feb9f2c84 100644--- a/src/common/snippets/include/snippets/op/fill.hpp+++ b/src/common/snippets/include/snippets/op/fill.hpp@@ -27,11 +27,19 @@ public:Fill(const Output<Node>& x, const size_t offset, const uint32_t fill_value = 0x0);Fill() = default;- size_t get_offset() const { return m_offset; }- uint32_t get_fill_value() const { return m_fill_value; }-- void set_offset(const size_t offset) { m_offset = offset; }- void set_fill_value(const uint32_t fill_value) { m_fill_value = fill_value; }+ size_t get_offset() const {+ return m_offset;+ }+ uint32_t get_fill_value() const {+ return m_fill_value;+ }++ void set_offset(const size_t offset) {+ m_offset = offset;+ }+ void set_fill_value(const uint32_t fill_value) {+ m_fill_value = fill_value;+ }bool visit_attributes(AttributeVisitor& visitor) override;std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;@@ -42,6 +50,6 @@ protected:uint32_t m_fill_value = 0x0;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/horizon_max.hpp b/src/common/snippets/include/snippets/op/horizon_max.hppindex 82ad1153330..5709e5bd6b2 100644--- a/src/common/snippets/include/snippets/op/horizon_max.hpp+++ b/src/common/snippets/include/snippets/op/horizon_max.hpp@@ -22,11 +22,13 @@ public:HorizonMax(const Output<Node>& x);HorizonMax() = default;- bool visit_attributes(AttributeVisitor& visitor) override { return true;}+ 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 op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/horizon_sum.hpp b/src/common/snippets/include/snippets/op/horizon_sum.hppindex d153f4df8bf..d2d836bb284 100644--- a/src/common/snippets/include/snippets/op/horizon_sum.hpp+++ b/src/common/snippets/include/snippets/op/horizon_sum.hpp@@ -22,11 +22,13 @@ public:HorizonSum(const Output<Node>& x);HorizonSum() = default;- bool visit_attributes(AttributeVisitor& visitor) override { return true;}+ 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 op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/kernel.hpp b/src/common/snippets/include/snippets/op/kernel.hppindex af13ddca017..48f32fb8c26 100644--- a/src/common/snippets/include/snippets/op/kernel.hpp+++ b/src/common/snippets/include/snippets/op/kernel.hpp@@ -22,12 +22,12 @@ public:Kernel() = default;Kernel(lowered::LinearIR region);- template<typename ... ArgTypes>+ template <typename... ArgTypes>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;- const void *compile_params = nullptr;+ const void* compile_params = nullptr;};class KernelStatic : public Kernel {@@ -35,7 +35,9 @@ public:OPENVINO_OP("KernelStatic", "SnippetsOpset", Kernel);KernelStatic() = default;KernelStatic(lowered::LinearIR region);- size_t get_num_call_args() const override { return 2; }+ size_t get_num_call_args() const override {+ return 2;+ }std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& inputs) const override;};@@ -44,11 +46,13 @@ public:OPENVINO_OP("KernelDynamic", "SnippetsOpset", Kernel);KernelDynamic() = default;KernelDynamic(lowered::LinearIR region);- size_t get_num_call_args() const override { return 1; }+ size_t get_num_call_args() const override {+ return 1;+ }std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& inputs) const override;};-template<typename ... ArgTypes>+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)...);@@ -57,6 +61,6 @@ std::shared_ptr<Kernel> Kernel::make_kernel(bool is_dynamic, ArgTypes&&... args)}}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/load.hpp b/src/common/snippets/include/snippets/op/load.hppindex fb239aed0be..f7002566866 100644--- a/src/common/snippets/include/snippets/op/load.hpp+++ b/src/common/snippets/include/snippets/op/load.hpp@@ -14,9 +14,10 @@ namespace op {/*** @interface Load- * @brief Generated during Lowering stage (convert_to_snippets_dialect) where explicit instructions should be emitted for data loading- * where number of elements to load is determined by "count" (Default value is "1" - to load one element)- * and memory offset for loading is determined by "offset" (Default value is "0" - to load starting from the first element)+ * @brief Generated during Lowering stage (convert_to_snippets_dialect) where explicit instructions should be emitted+ * for data loading where number of elements to load is determined by "count" (Default value is "1" - to load one+ * element) and memory offset for loading is determined by "offset" (Default value is "0" - to load starting from the+ * first element)* @ingroup snippets*/class Load : public modifier::MemoryAccess, public ov::op::Op {@@ -26,11 +27,19 @@ public:Load(const Output<Node>& x, const size_t count = 1lu, const size_t offset = 0lu);Load() = default;- size_t get_offset() const { return get_input_offset(0); }- size_t get_count() const { return get_input_count(0); }+ size_t get_offset() const {+ return get_input_offset(0);+ }+ size_t get_count() const {+ return get_input_count(0);+ }- void set_offset(size_t offset) { set_input_offset(offset, 0); }- void set_count(size_t count) { set_input_count(count, 0); }+ void set_offset(size_t offset) {+ set_input_offset(offset, 0);+ }+ void set_count(size_t count) {+ set_input_count(count, 0);+ }void validate_and_infer_types() override;std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;@@ -53,8 +62,12 @@ public:LoadReorder(const Output<Node>& x, size_t count = 1lu, const size_t offset = 0lu, std::vector<size_t> order = {});LoadReorder() = default;- void set_offset(size_t offset) { set_output_offset(offset, 0); }- void set_count(size_t count) { set_output_count(count, 0); }+ void set_offset(size_t offset) {+ set_output_offset(offset, 0);+ }+ void set_count(size_t count) {+ set_output_count(count, 0);+ }bool visit_attributes(AttributeVisitor& visitor) override;std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;@@ -62,15 +75,15 @@ public:class ShapeInfer : public IShapeInferSnippets {std::vector<size_t> m_order;+public:explicit ShapeInfer(const std::shared_ptr<ov::Node>& n);Result infer(const std::vector<VectorDimsRef>& input_shapes) override;};-protected:std::vector<size_t> m_order;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/loop.hpp b/src/common/snippets/include/snippets/op/loop.hppindex b6478599715..78c8430e13a 100644--- a/src/common/snippets/include/snippets/op/loop.hpp+++ b/src/common/snippets/include/snippets/op/loop.hpp@@ -4,9 +4,8 @@#pragma once-#include "snippets/emitter.hpp"-#include "openvino/op/op.hpp"+#include "snippets/emitter.hpp"namespace ov {namespace snippets {@@ -22,13 +21,15 @@ public:OPENVINO_OP("LoopBase", "SnippetsOpset");LoopBase(const std::vector<Output<Node>>& args);LoopBase() = default;+protected:};class LoopEnd;/*** @interface LoopBegin* @brief Marks the start of the Loop region.- * Number of outputs always equals to the number of inputs (bypassed values) + 1 (edge to the corresponding LoopEnd)+ * Number of outputs always equals to the number of inputs (bypassed values) + 1 (edge to the corresponding+ * LoopEnd)* @param args - vector of input values, they are passed directly to output.* @ingroup snippets*/@@ -50,12 +51,14 @@ protected:/*** @interface LoopEnd* @brief Marks the end of the Loop region and defines the loop properties.- * Number of outputs always equals to the number of inputs (bypassed values) - 1 (edge to the corresponding LoopEnd)+ * Number of outputs always equals to the number of inputs (bypassed values) - 1 (edge to the corresponding+ * LoopEnd)* @param args vector of input values + LoopBegin, all values except for the LoopBegin are passed directly to output.* @param work_amount total number of evaluations to be processed by the loop* @param increment number of evaluations processed in one iteration of the loop.* @param is_incremented describes which data pointers attributed to the loop should be incremented on every iteration.- * @param ptr_increments specifies i/o pointer increment performed on every iteration if the following is_incremented[i] is true+ * @param ptr_increments specifies i/o pointer increment performed on every iteration if the following is_incremented[i]+ * is true* @param finalization_offsets pointer increments that are be applied to i/o pointers before exiting the loop* @param id the identifier of Loop in Loop system in LoopManager* @ingroup snippets@@ -64,9 +67,16 @@ class LoopEnd : public LoopBase {public:OPENVINO_OP("LoopEnd", "SnippetsOpset", LoopBase);LoopEnd() = default;- LoopEnd(const Output<Node>& loop_begin, size_t work_amount, size_t work_amount_increment,- std::vector<bool> is_incremented, std::vector<int64_t> ptr_increments, std::vector<int64_t> finalization_offsets,- std::vector<int64_t> element_type_sizes, size_t input_num, size_t output_num, size_t id);+ LoopEnd(const Output<Node>& loop_begin,+ size_t work_amount,+ size_t work_amount_increment,+ std::vector<bool> is_incremented,+ std::vector<int64_t> ptr_increments,+ std::vector<int64_t> finalization_offsets,+ std::vector<int64_t> element_type_sizes,+ size_t input_num,+ size_t output_num,+ size_t id);void validate_and_infer_types() override;bool visit_attributes(AttributeVisitor& visitor) override;@@ -105,9 +115,10 @@ protected:size_t m_output_num = 0;size_t m_id = 0; // the corresponding Loop identificator in LoopManager- bool m_evaluate_once = false; // true if the Loop is executed only once, used to skip setting and testing the loop counter+ // m_evaluate_once is true if the Loop is executed only once, used to skip setting and testing the loop counter+ bool m_evaluate_once = false;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/memory_access.hpp b/src/common/snippets/include/snippets/op/memory_access.hppindex 1e19b572d6c..6425a910d0d 100644--- a/src/common/snippets/include/snippets/op/memory_access.hpp+++ b/src/common/snippets/include/snippets/op/memory_access.hpp@@ -22,13 +22,13 @@ namespace modifier {class MemoryAccess {public:/**- * @interface PortDescriptor- * @brief This class describes port of MemoryAccess operation- * @param m_count - count of elements to load/store- * @param m_offset - starting index of elements to load/store- * @param m_index - port index- * @ingroup snippets- */+ * @interface PortDescriptor+ * @brief This class describes port of MemoryAccess operation+ * @param m_count - count of elements to load/store+ * @param m_offset - starting index of elements to load/store+ * @param m_index - port index+ * @ingroup snippets+ */struct PortDescriptor {PortDescriptor(size_t count, size_t offset) : count(count), offset(offset) {}PortDescriptor() = default;@@ -40,8 +40,11 @@ public:size_t index = 0lu;private:- PortDescriptor(size_t count, size_t offset, size_t stride, size_t index) :- count(count), offset(offset), stride(stride), index(index) {}+ PortDescriptor(size_t count, size_t offset, size_t stride, size_t index)+ : count(count),+ offset(offset),+ stride(stride),+ index(index) {}friend class MemoryAccess;};@@ -61,8 +64,12 @@ public:size_t get_input_stride(size_t idx = 0) const;size_t get_output_stride(size_t idx = 0) const;- PortMap get_memory_access_input_ports() const { return m_input_ports; }- PortMap get_memory_access_output_ports() const { return m_output_ports; }+ PortMap get_memory_access_input_ports() const {+ return m_input_ports;+ }+ 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;@@ -95,6 +102,6 @@ protected:PortMap m_output_ports;};-} // namespace modifier-} // namespace snippets-} // namespace ov+} // namespace modifier+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/nop.hpp b/src/common/snippets/include/snippets/op/nop.hppindex 041468ade2b..ade30b095ca 100644--- a/src/common/snippets/include/snippets/op/nop.hpp+++ b/src/common/snippets/include/snippets/op/nop.hpp@@ -27,6 +27,6 @@ public:}};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/perf_count.hpp b/src/common/snippets/include/snippets/op/perf_count.hppindex 7dd46acdbe8..eab81cf6704 100644--- a/src/common/snippets/include/snippets/op/perf_count.hpp+++ b/src/common/snippets/include/snippets/op/perf_count.hpp@@ -4,19 +4,19 @@#ifdef SNIPPETS_DEBUG_CAPS-#pragma once+# pragma once-#include <chrono>+# include <chrono>-#include "openvino/op/op.hpp"-#include "openvino/runtime/threading/thread_local.hpp"+# include "openvino/op/op.hpp"+# include "openvino/runtime/threading/thread_local.hpp"namespace ov {namespace snippets {namespace op {class PerfCountEnd;-} // namespace op+} // namespace opnamespace utils {@@ -30,8 +30,9 @@ public:Dumper() = default;virtual ~Dumper() = default;- void init(const std::string ¶ms);+ void init(const std::string& params);virtual void update(const op::PerfCountEnd* node) = 0;+protected:std::map<std::string, std::string> m_debug_params_map;std::string m_params;@@ -70,7 +71,7 @@ private:const std::string csv_path;};-} // namespace utils+} // namespace utilsnamespace op {@@ -145,11 +146,11 @@ public:void init_pc_begin();void set_accumulated_time();- const ov::threading::ThreadLocal<uint64_t> &get_accumulation() const {+ const ov::threading::ThreadLocal<uint64_t>& get_accumulation() const {return accumulation;}- const ov::threading::ThreadLocal<uint32_t> &get_iteration() const {+ const ov::threading::ThreadLocal<uint32_t>& get_iteration() const {return iteration;}@@ -161,7 +162,7 @@ private:std::shared_ptr<PerfCountBegin> m_pc_begin = nullptr;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ov#endif // SNIPPETS_DEBUG_CAPSdiff --git a/src/common/snippets/include/snippets/op/powerstatic.hpp b/src/common/snippets/include/snippets/op/powerstatic.hppindex a8333815499..26d93c19d80 100644--- a/src/common/snippets/include/snippets/op/powerstatic.hpp+++ b/src/common/snippets/include/snippets/op/powerstatic.hpp@@ -4,9 +4,10 @@#pragma once-#include "openvino/op/op.hpp"#include <snippets/snippets_isa.hpp>+#include "openvino/op/op.hpp"+namespace ov {namespace snippets {namespace op {@@ -21,23 +22,25 @@ public:OPENVINO_OP("PowerStatic", "SnippetsOpset", ov::op::util::UnaryElementwiseArithmetic);PowerStatic() = default;- PowerStatic(const Output <Node> &arg, float power) : UnaryElementwiseArithmetic(arg), power(power) {+ PowerStatic(const Output<Node>& arg, float power) : UnaryElementwiseArithmetic(arg), power(power) {constructor_validate_and_infer_types();}- std::shared_ptr<Node> clone_with_new_inputs(const OutputVector &new_args) const override {+ std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override {check_new_args_count(this, new_args);return std::make_shared<PowerStatic>(new_args.at(0), power);}- bool visit_attributes(AttributeVisitor &visitor) override {+ bool visit_attributes(AttributeVisitor& visitor) override {visitor.on_attribute("power", power);return true;}- float get_power() const { return power; }+ float get_power() const {+ return power;+ }private:float power = 0;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/rank_normalization.hpp b/src/common/snippets/include/snippets/op/rank_normalization.hppindex 63f07189d81..b978d9ec4f8 100644--- a/src/common/snippets/include/snippets/op/rank_normalization.hpp+++ b/src/common/snippets/include/snippets/op/rank_normalization.hpp@@ -13,15 +13,17 @@ namespace op {/*** @interface RankNormalization- * @brief Generated by Canonicalization for rank normalization purposes. It can prepend input shapes with seve1s only first or last dimensions.+ * @brief Generated by Canonicalization for rank normalization purposes. It can prepend input shapes with seve1s only+ * first or last dimensions.* @arg num_prepend - num `1`s that will be inserted at the beginning of the input shape. Any value is allowed.* @arg num_append - num `1`s that will be inserted at the end of the input shape. Could be either 0 (default) or 1;* @ingroup snippets*/- // Note that technically the same goal could be achieved using op::Unsqueeze operation,- // but RankNormalization has a much narrower semantics, and hence allows for an easier control and a more efficient shape infer.- //-class RankNormalization : public ShapeInferOp {+// Note that technically the same goal could be achieved using op::Unsqueeze operation,+// but RankNormalization has a much narrower semantics, and hence allows for an easier control and a more efficient+// shape infer.+//+class RankNormalization : public ShapeInferOp {public:OPENVINO_OP("RankNormalization", "SnippetsOpset", ShapeInferOp);@@ -32,16 +34,20 @@ public:bool visit_attributes(AttributeVisitor& visitor) override;std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;- size_t get_num_append() const { return m_num_append; }- size_t get_num_prepend() const { return m_num_prepend; }+ size_t get_num_append() const {+ return m_num_append;+ }+ size_t get_num_prepend() const {+ return m_num_prepend;+ }class ShapeInfer : public IShapeInferSnippets {size_t m_num_prepend = 0;size_t m_num_append = 0;+public:explicit ShapeInfer(const std::shared_ptr<ov::Node>& n);- IShapeInferSnippets::Result- infer(const std::vector<VectorDimsRef>& input_shapes) override;+ IShapeInferSnippets::Result infer(const std::vector<VectorDimsRef>& input_shapes) override;};private:@@ -49,6 +55,6 @@ private:size_t m_num_append = 0;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/reduce.hpp b/src/common/snippets/include/snippets/op/reduce.hppindex b6da17454ea..03c9cd52128 100644--- a/src/common/snippets/include/snippets/op/reduce.hpp+++ b/src/common/snippets/include/snippets/op/reduce.hpp@@ -26,7 +26,9 @@ public:bool visit_attributes(AttributeVisitor& visitor) override;void validate_and_infer_types() override;- size_t get_axis() const { return m_axis; }+ size_t get_axis() const {+ return m_axis;+ }static void compute_and_set_reduce_subtensors(const std::shared_ptr<ReduceBase>& reduce);protected:@@ -49,6 +51,6 @@ public:std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/reg_spill.hpp b/src/common/snippets/include/snippets/op/reg_spill.hppindex 62f85736067..0244a46cbd8 100644--- a/src/common/snippets/include/snippets/op/reg_spill.hpp+++ b/src/common/snippets/include/snippets/op/reg_spill.hpp@@ -6,9 +6,8 @@#include <cassert>-#include "snippets/emitter.hpp"-#include "openvino/op/op.hpp"+#include "snippets/emitter.hpp"#include "snippets/shape_inference/shape_inference.hpp"namespace ov {@@ -42,14 +41,18 @@ public:void validate_and_infer_types() override;std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& inputs) const override;std::shared_ptr<RegSpillEnd> get_reg_spill_end() const;- const std::set<Reg>& get_regs_to_spill() const override { return m_regs_to_spill; }+ const std::set<Reg>& get_regs_to_spill() const override {+ return m_regs_to_spill;+ }class ShapeInfer : public IShapeInferSnippets {size_t num_out_shapes = 0;+public:explicit ShapeInfer(const std::shared_ptr<ov::Node>& n);Result infer(const std::vector<VectorDimsRef>& input_shapes) override;};+protected:void validate_and_infer_types_except_RegSpillEnd();std::set<Reg> m_regs_to_spill = {};@@ -78,6 +81,6 @@ public:}};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/reorder.hpp b/src/common/snippets/include/snippets/op/reorder.hppindex 79b024b768a..559a40a9f79 100644--- a/src/common/snippets/include/snippets/op/reorder.hpp+++ b/src/common/snippets/include/snippets/op/reorder.hpp@@ -28,7 +28,8 @@ public: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);Result infer(const std::vector<VectorDimsRef>& input_shapes) override;@@ -38,6 +39,6 @@ private:void custom_constructor_validate_and_infer_types(std::vector<size_t> order);};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/reshape.hpp b/src/common/snippets/include/snippets/op/reshape.hppindex c86150a1479..53e5c5252b4 100644--- a/src/common/snippets/include/snippets/op/reshape.hpp+++ b/src/common/snippets/include/snippets/op/reshape.hpp@@ -32,6 +32,7 @@ public:class ShapeInfer : public IShapeInferSnippets {VectorDims target_shape;size_t target_shape_volume = 0;+public:explicit ShapeInfer(const std::shared_ptr<Node>& n);Result infer(const std::vector<VectorDimsRef>& input_shapes) override;@@ -41,6 +42,6 @@ private:ov::PartialShape m_target_shape = {};};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/scalar.hpp b/src/common/snippets/include/snippets/op/scalar.hppindex f1198dc9139..3458d7bff57 100644--- a/src/common/snippets/include/snippets/op/scalar.hpp+++ b/src/common/snippets/include/snippets/op/scalar.hpp@@ -4,8 +4,8 @@#pragma once-#include "openvino/op/op.hpp"#include "openvino/op/constant.hpp"+#include "openvino/op/op.hpp"namespace ov {namespace snippets {@@ -16,7 +16,7 @@ namespace op {* @brief Generated by Canonicalization for a scalar constant Shape() == {1}* @ingroup snippets*/-class Scalar : public ov::op::v0::Constant {+class Scalar : public ov::op::v0::Constant {public:OPENVINO_OP("Scalar", "SnippetsOpset", ov::op::v0::Constant);@@ -45,9 +45,11 @@ public:void validate_and_infer_types() override;bool visit_attributes(AttributeVisitor& visitor) override;- bool has_evaluate() const override { return false; }+ bool has_evaluate() const override {+ return false;+ }};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/serialization_node.hpp b/src/common/snippets/include/snippets/op/serialization_node.hppindex 753e4c25e31..2c36b591f09 100644--- a/src/common/snippets/include/snippets/op/serialization_node.hpp+++ b/src/common/snippets/include/snippets/op/serialization_node.hpp@@ -4,9 +4,10 @@#pragma once-#include "openvino/op/op.hpp"-#include <snippets/snippets_isa.hpp>#include <snippets/lowered/expression.hpp>+#include <snippets/snippets_isa.hpp>++#include "openvino/op/op.hpp"namespace ov {namespace snippets {@@ -28,14 +29,14 @@ public:SerializationMode mode = SerializationMode::CONTROL_FLOW);void validate_and_infer_types() override;- std::shared_ptr<Node> clone_with_new_inputs(const OutputVector &new_args) const override;- bool visit_attributes(AttributeVisitor &visitor) override;+ std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;+ bool visit_attributes(AttributeVisitor& visitor) override;private:std::shared_ptr<lowered::Expression> m_expr;SerializationMode m_mode;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/shape_infer_op.hpp b/src/common/snippets/include/snippets/op/shape_infer_op.hppindex a1462cbb426..126bf69fbcf 100644--- a/src/common/snippets/include/snippets/op/shape_infer_op.hpp+++ b/src/common/snippets/include/snippets/op/shape_infer_op.hpp@@ -22,6 +22,6 @@ public:ShapeInferOp(const OutputVector& args) : ov::op::Op(args) {}};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/store.hpp b/src/common/snippets/include/snippets/op/store.hppindex f386fa6344e..f446223ddc6 100644--- a/src/common/snippets/include/snippets/op/store.hpp+++ b/src/common/snippets/include/snippets/op/store.hpp@@ -13,9 +13,10 @@ namespace op {/*** @interface Store- * @brief Generated during Lowering stage (convert_to_snippets_dialect) where explicit instructions should be emitted for data storing- * where number of elements to store is determined by "count" (Default value is "1" - to store one element)- * and memory offset for storing is determined by "offset" (Default value is "0" - to store starting at start memory ptr)+ * @brief Generated during Lowering stage (convert_to_snippets_dialect) where explicit instructions should be emitted+ * for data storing where number of elements to store is determined by "count" (Default value is "1" - to store one+ * element) and memory offset for storing is determined by "offset" (Default value is "0" - to store starting at start+ * memory ptr)* @ingroup snippets*/class Store : public modifier::MemoryAccess, public ov::op::Op {@@ -25,17 +26,25 @@ public:Store(const Output<Node>& x, const size_t count = 1lu, const size_t offset = 0lu);Store() = default;- size_t get_offset() const { return get_output_offset(0); }- size_t get_count() const { return get_output_count(0); }+ size_t get_offset() const {+ return get_output_offset(0);+ }+ size_t get_count() const {+ return get_output_count(0);+ }- void set_offset(size_t offset) { set_output_offset(offset, 0); }- void set_count(size_t count) { set_output_count(count, 0); }+ void set_offset(size_t offset) {+ set_output_offset(offset, 0);+ }+ void set_count(size_t count) {+ set_output_count(count, 0);+ }void validate_and_infer_types() override;std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;bool visit_attributes(AttributeVisitor& visitor) override;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/op/subgraph.hpp b/src/common/snippets/include/snippets/op/subgraph.hppindex 0a5812e1aac..c81d1ff2eed 100644--- a/src/common/snippets/include/snippets/op/subgraph.hpp+++ b/src/common/snippets/include/snippets/op/subgraph.hpp@@ -11,13 +11,11 @@#include "openvino/core/rt_info.hpp"#include "openvino/op/op.hpp"#include "snippets/generator.hpp"-#include "snippets/runtime_configurator.hpp"#include "snippets/lowered/pass/pass.hpp"#include "snippets/pass/manager.hpp"-#include "snippets/shape_inference/shape_inference.hpp"-#include "snippets/lowered/pass/pass.hpp"#include "snippets/pass/positioned_pass.hpp"-+#include "snippets/runtime_configurator.hpp"+#include "snippets/shape_inference/shape_inference.hpp"namespace ov {namespace snippets {@@ -90,29 +88,49 @@ public:// we introduce this method instead of using SubGraphOp::get_function()// to align naming with other methods- const std::shared_ptr<ov::Model>& body_ptr() const { return m_bodies[0]; }- std::shared_ptr<ov::Model>& body_ptr() { return m_bodies[0]; }+ const std::shared_ptr<ov::Model>& body_ptr() const {+ return m_bodies[0];+ }+ std::shared_ptr<ov::Model>& body_ptr() {+ return m_bodies[0];+ }- const ov::Model& body() const { return *m_bodies[0]; }- ov::Model& body() { return *m_bodies[0]; }+ const ov::Model& body() const {+ return *m_bodies[0];+ }+ ov::Model& body() {+ return *m_bodies[0];+ }- const std::shared_ptr<ov::snippets::Generator>& get_generator() const { return m_generator; }- std::shared_ptr<ov::snippets::Generator>& get_generator() { return m_generator; }+ const std::shared_ptr<ov::snippets::Generator>& get_generator() const {+ return m_generator;+ }+ std::shared_ptr<ov::snippets::Generator>& get_generator() {+ return m_generator;+ }- size_t get_virtual_port_count() const { return m_virtual_port_count; }- bool is_quantized() const { return config.m_is_quantized; }+ size_t get_virtual_port_count() const {+ return m_virtual_port_count;+ }+ bool is_quantized() const {+ return config.m_is_quantized;+ }#ifdef SNIPPETS_DEBUG_CAPSDebugCapsConfig& get_debug_config() {assert(config.m_debug_config && "Debug config is not initialized");return *config.m_debug_config;}#endif // SNIPPETS_DEBUG_CAPS- bool has_domain_sensitive_ops() const { return config.m_has_domain_sensitive_ops; }+ bool has_domain_sensitive_ops() const {+ return config.m_has_domain_sensitive_ops;+ }// plugin sets generator for a snippet to some specific generator.// it's going to be replaced with Jitters table latervoid set_generator(std::shared_ptr<ov::snippets::Generator> generator);- void set_tile_rank(size_t rank) {tile_rank = rank;}+ void set_tile_rank(size_t rank) {+ tile_rank = rank;+ }void set_virtual_port_count(size_t count);void print() const;@@ -126,7 +144,8 @@ public:const std::shared_ptr<RuntimeConfig>& update_runtime_config() const;static auto wrap_node_as_subgraph(const std::shared_ptr<ov::Node>& node) -> std::shared_ptr<Subgraph>;- static void fill_empty_output_names(const Output<Node>& target_output_node, const Output<Node>& replacement_output_node);+ static void fill_empty_output_names(const Output<Node>& target_output_node,+ const Output<Node>& replacement_output_node);// Non-scalar Constants are tokenized as Parameters inside Subgraph body but some operations with constant inputs// should have explicit Constants even if they're non-scalar (Reshape, Transpose, Broadcast)@@ -143,34 +162,44 @@ public:const std::vector<ov::element::Type>& output_precisions = {},const std::vector<snippets::pass::Manager::PositionedPassBase>& = {}) const;- void control_flow_transformations(size_t min_parallel_work_amount = 8, size_t min_kernel_work_amount = 256,- const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory = std::make_shared<IShapeInferSnippetsFactory>(),- 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 = {});+ void control_flow_transformations(+ size_t min_parallel_work_amount = 8,+ size_t min_kernel_work_amount = 256,+ const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory =+ std::make_shared<IShapeInferSnippetsFactory>(),+ 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 = {});Schedule generate(const void* compile_params = nullptr) const;- Schedule generate(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::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 = {},- size_t min_parallel_work_amount = 8, size_t min_kernel_work_amount = 256,- const std::shared_ptr<IShapeInferSnippetsFactory>& factory = nullptr,- const void* compile_params = nullptr);+ Schedule generate(+ 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::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 = {},+ size_t min_parallel_work_amount = 8,+ size_t min_kernel_work_amount = 256,+ const std::shared_ptr<IShapeInferSnippetsFactory>& factory = nullptr,+ const void* compile_params = nullptr);private:- std::shared_ptr<lowered::LinearIR>- convert_body_to_linear_ir(size_t min_parallel_work_amount = 8, size_t min_kernel_work_amount = 256,- const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory = std::make_shared<IShapeInferSnippetsFactory>());+ std::shared_ptr<lowered::LinearIR> convert_body_to_linear_ir(+ size_t min_parallel_work_amount = 8,+ size_t min_kernel_work_amount = 256,+ const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory =+ std::make_shared<IShapeInferSnippetsFactory>());void init_config();// Count of Subgraph virtual ports:- // - Potential non-scalar Constants that will be created after some transformations (At the moment it's relevant only for FakeQuantize decomposition)+ // - Potential non-scalar Constants that will be created after some transformations (At the moment it's relevant+ // only for FakeQuantize decomposition)// NOTE: To avoid overheads in each calculation of this count (for example, in validate_and_type_infer()),// we should MANUALLY calculate it where it needed.size_t m_virtual_port_count = 0;- size_t tile_rank = 0; // set by plugin to specify the number of dimensions processed in a single kernel call+ size_t tile_rank = 0; // set by plugin to specify the number of dimensions processed in a single kernel callstd::shared_ptr<lowered::LinearIR> m_linear_ir = nullptr;// This LinearIR is used for ShapeInfer and based on LinearIR state after ControlFlow transformations@@ -179,10 +208,10 @@ private:std::shared_ptr<ov::snippets::Generator> m_generator = nullptr;/**- * @interface SubgraphConfig- * @brief Config to optimize IR transformation pipeline. It indicates which transformations are necessary- * so the irrelevant ones could be skipped.- */+ * @interface SubgraphConfig+ * @brief Config to optimize IR transformation pipeline. It indicates which transformations are necessary+ * so the irrelevant ones could be skipped.+ */class SubgraphConfig {public:// True if Subgraph contains FakeQuantize -> FQ decomposition should be called@@ -202,21 +231,24 @@ private:class OVShapeInfer : public ShapeInferSnippetsNode {std::shared_ptr<ov::Model> m_ov_body;+public:explicit OVShapeInfer(const std::shared_ptr<ov::Model>& body);Result infer(const std::vector<VectorDimsRef>& input_shapes) override;};};-static inline auto create_body(const std::string& name, const ov::ResultVector& results, const ov::ParameterVector& parameters) ->- std::shared_ptr<ov::Model> {+static inline auto create_body(const std::string& name,+ const ov::ResultVector& results,+ const ov::ParameterVector& parameters) -> std::shared_ptr<ov::Model> {auto body = std::make_shared<ov::Model>(results, parameters, name);return body;}-static inline auto build_subgraph(const std::shared_ptr<ov::Node>& node, const ov::OutputVector& inputs,- const std::shared_ptr<ov::Model>& body, const std::string& name = "")- -> std::shared_ptr<Subgraph>{+static inline auto build_subgraph(const std::shared_ptr<ov::Node>& node,+ const ov::OutputVector& inputs,+ const std::shared_ptr<ov::Model>& body,+ const std::string& name = "") -> std::shared_ptr<Subgraph> {auto subgraph = std::make_shared<Subgraph>(inputs, body);copy_runtime_info(node, subgraph);subgraph->set_friendly_name(name.empty() ? node->get_friendly_name() : name);@@ -232,8 +264,7 @@ auto inline update_out_tensor_name(const std::shared_ptr<ov::snippets::op::Subgrif (ov::is_type<ov::op::v0::Result>(in.get_node())) {const auto& body_result = subgraph->body_ptr()->get_output_op(i);const auto& body_result_input = body_result->get_input_source_output(0);- ov::snippets::op::Subgraph::fill_empty_output_names(- subgraph->output(i), body_result_input);+ ov::snippets::op::Subgraph::fill_empty_output_names(subgraph->output(i), body_result_input);not_set = false;break;}diff --git a/src/common/snippets/include/snippets/op/vector_buffer.hpp b/src/common/snippets/include/snippets/op/vector_buffer.hppindex 92f3a2ad5da..4ac76ec43b9 100644--- a/src/common/snippets/include/snippets/op/vector_buffer.hpp+++ b/src/common/snippets/include/snippets/op/vector_buffer.hpp@@ -30,6 +30,6 @@ private:ov::element::Type m_element_type;};-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/pass/align_element_types.hpp b/src/common/snippets/include/snippets/pass/align_element_types.hppindex fac7b1379f3..cb8698dd7f6 100644--- a/src/common/snippets/include/snippets/pass/align_element_types.hpp+++ b/src/common/snippets/include/snippets/pass/align_element_types.hpp@@ -5,8 +5,8 @@#pragma once#include "openvino/pass/pass.hpp"-#include "transformations_visibility.hpp"#include "snippets/op/subgraph.hpp"+#include "transformations_visibility.hpp"namespace ov {namespace snippets {@@ -17,7 +17,7 @@ namespace pass {* @brief Align body precision with expected input/output precision. Insert op::ConvertSaturation if necessary.* @ingroup snippets*/-class AlignElementTypes: public ov::pass::ModelPass {+class AlignElementTypes : public ov::pass::ModelPass {public:OPENVINO_MODEL_PASS_RTTI("snippets::pass::AlignElementTypes");AlignElementTypes(std::vector<ov::element::Type> input_precisions,diff --git a/src/common/snippets/include/snippets/pass/analyze_broadcastable_inputs.hpp b/src/common/snippets/include/snippets/pass/analyze_broadcastable_inputs.hppindex 9d23e462ddf..e62b9f7c1de 100644--- a/src/common/snippets/include/snippets/pass/analyze_broadcastable_inputs.hpp+++ b/src/common/snippets/include/snippets/pass/analyze_broadcastable_inputs.hpp@@ -12,9 +12,8 @@ namespace pass {/*** @interface AnalyzeBroadcastableInputs- * @brief Analyzes body parameters which affects inputs of broadcastable operations (If needed, `Broadcast` op should be inserted there).- * Also the pass initializes special map `BroadcastableInputsMap`- * Notes:+ * @brief Analyzes body parameters which affects inputs of broadcastable operations (If needed, `Broadcast` op should be+ * inserted there). Also the pass initializes special map `BroadcastableInputsMap` Notes:* - Must be called after Canonicalization pass* - Doesn't support `layouts` in PortDescriptors* @ingroup snippetsdiff --git a/src/common/snippets/include/snippets/pass/broadcast_to_movebroadcast.hpp b/src/common/snippets/include/snippets/pass/broadcast_to_movebroadcast.hppindex 8b51c1aa06b..04bcdfcd43e 100644--- a/src/common/snippets/include/snippets/pass/broadcast_to_movebroadcast.hpp+++ b/src/common/snippets/include/snippets/pass/broadcast_to_movebroadcast.hpp@@ -4,8 +4,8 @@#pragma once-#include "openvino/pass/pattern/matcher.hpp"#include "openvino/pass/matcher_pass.hpp"+#include "openvino/pass/pattern/matcher.hpp"namespace ov {namespace snippets {@@ -13,17 +13,16 @@ namespace pass {/*** @interface BroadcastToMoveBroadcast- * @brief Inserts explicit MoveBroadcast instruction if broadcasting by most varying dimension is needed instead of Broadcast.- * Otherwise the pass removes Broadcast operation.+ * @brief Inserts explicit MoveBroadcast instruction if broadcasting by most varying dimension is needed instead of+ * Broadcast. Otherwise the pass removes Broadcast operation.* @ingroup snippets*/-class BroadcastToMoveBroadcast: public ov::pass::MatcherPass {+class BroadcastToMoveBroadcast : public ov::pass::MatcherPass {public:OPENVINO_MATCHER_PASS_RTTI("snippets::pass::BroadcastToMoveBroadcast");BroadcastToMoveBroadcast();};--} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/pass/canonicalization.hpp b/src/common/snippets/include/snippets/pass/canonicalization.hppindex ac3c3017d22..beacabed1df 100644--- a/src/common/snippets/include/snippets/pass/canonicalization.hpp+++ b/src/common/snippets/include/snippets/pass/canonicalization.hpp@@ -5,9 +5,9 @@#pragma once#include "openvino/pass/pass.hpp"-#include "transformations_visibility.hpp"#include "snippets/op/subgraph.hpp"#include "snippets/shape_types.hpp"+#include "transformations_visibility.hpp"namespace ov {namespace snippets {@@ -20,7 +20,7 @@ namespace pass {* - layouts mismatch (only planar + blocked is supported), planar shapes are postpended with 1* @ingroup snippets*/-class Canonicalization: public ov::pass::ModelPass {+class Canonicalization : public ov::pass::ModelPass {public:OPENVINO_MODEL_PASS_RTTI("snippets::pass::Canonicalization");using BlockedShapeVector = op::Subgraph::BlockedShapeVector;diff --git a/src/common/snippets/include/snippets/pass/collapse_subgraph.hpp b/src/common/snippets/include/snippets/pass/collapse_subgraph.hppindex 5abad88b02a..3a6cf780a69 100644--- a/src/common/snippets/include/snippets/pass/collapse_subgraph.hpp+++ b/src/common/snippets/include/snippets/pass/collapse_subgraph.hpp@@ -16,7 +16,8 @@ namespace pass {* @brief Splits model to subgraphs if possible using rules above* This pass tokenizes topology graph into subgraphs.* Those subgraphs consists of unary or binary layout-oblivious (LO) opetations found in subset 1.- * Non-layout-oblivious (NLO) operations operations (called also support in this context) are ignored and become a fullstop in tokenization routine+ * Non-layout-oblivious (NLO) operations operations (called also support in this context) are ignored and become a+ * fullstop in tokenization routine* 1. if a considered LO operation doesn't have any unput subgraphs* -> a new single-op subgraph is introduced* 1. if a considered LO operation is a binary or an unary operation with at least one subgraph as an input@@ -24,16 +25,17 @@ namespace pass {* 1. non-subgraph inputs are wrapped into parameters* 1. all input bodies are merged and* 1. this new operation is added to a body of input subgraph- * 1. outputs are collected subgraph (outputs consumed by some other node & subgraph outputs consumed by the node to be merged)- * 1. finally current node is replaced with the new subgraph. We cannot use replace_node because multiple nodes are replaced so- * make the replacement manually by redirecting ports- * New subgraph is introduced, if there is a loop introduced- * New subgraph is introduced, if number of inputs and outputs exceeds 7 due to scheduling limitation- * New subgraph is introduced, if multiple outputs of merged nodes are not broadcastable to each other (equality of all outputs is too much on the other hand)- * Scalar constants are placed as is into subgraph due to optimization purpose+ * 1. outputs are collected subgraph (outputs consumed by some other node & subgraph outputs consumed by the node+ * to be merged)+ * 1. finally current node is replaced with the new subgraph. We cannot use replace_node because multiple nodes+ * are replaced so make the replacement manually by redirecting ports New subgraph is introduced, if+ * there is a loop introduced New subgraph is introduced, if number of inputs and outputs exceeds 7 due+ * to scheduling limitation New subgraph is introduced, if multiple outputs of merged nodes are+ * not broadcastable to each other (equality of all outputs is too much on the other hand)+ * Scalar constants are placed as is into subgraph due to optimization purpose* @ingroup snippets*/-class TokenizeSnippets: public ov::pass::MatcherPass {+class TokenizeSnippets : public ov::pass::MatcherPass {public:OPENVINO_MATCHER_PASS_RTTI("snippets::pass::TokenizeSnippets");explicit TokenizeSnippets(const SnippetsTokenization::Config& config);diff --git a/src/common/snippets/include/snippets/pass/convert_constants.hpp b/src/common/snippets/include/snippets/pass/convert_constants.hppindex cd53d6db0c8..0ad8614de29 100644--- a/src/common/snippets/include/snippets/pass/convert_constants.hpp+++ b/src/common/snippets/include/snippets/pass/convert_constants.hpp@@ -17,12 +17,12 @@ namespace pass {* Only single-value (0D) constants are currently supported.* @ingroup snippets*/-class ConvertConstantsToScalars: public ov::pass::MatcherPass {+class ConvertConstantsToScalars : public ov::pass::MatcherPass {public:OPENVINO_MATCHER_PASS_RTTI("snippets::pass::ConvertConstantsToScalars");ConvertConstantsToScalars();};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace snippets+} // namespace ovdiff --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 b3aea4b0cb9..8b3f715ba23 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@@ -15,12 +15,12 @@ namespace pass {* @brief Replace Power with a scalar input with snippets::op::PowerStatic for generation of a more optimal code.* @ingroup snippets*/-class ConvertPowerToPowerStatic: public ov::pass::MatcherPass {+class ConvertPowerToPowerStatic : public ov::pass::MatcherPass {public:OPENVINO_MATCHER_PASS_RTTI("snippets::pass::ConvertPowerToPowerStatic");ConvertPowerToPowerStatic();};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace snippets+} // namespace ovdiff --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 935b0b6b394..26108bc6265 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@@ -14,14 +14,16 @@ namespace pass {* @interface ExplicitTransposeMatMulInputs* @brief The pass extracts explicit Transpose node from MatMul with transposed_<a|b> and moves it to Parameter.* If there is another Transpose, the pass fuses extracted Transpose and existing Transpose.- * For example, At the moment Snippets supports Transpose only with order {0, 2, 3, 1}, so if there is pattern in graph:+ * For example, At the moment Snippets supports Transpose only with order {0, 2, 3, 1},+ * so if there is pattern in graph:* in0 Transpose{0, 2, 1, 3}* \ /* MatMul[false, true]- * We can set `false` in MatMul parameter `transposed_b` and change Transpose order to {0, 2, 3, 1} which is supported by Snippets+ * We can set `false` in MatMul parameter `transposed_b` and change Transpose order to {0, 2, 3, 1}+ * which is supported by Snippets* @ingroup snippets*/-class ExplicitTransposeMatMulInputs: public ov::pass::MatcherPass {+class ExplicitTransposeMatMulInputs : public ov::pass::MatcherPass {public:OPENVINO_MATCHER_PASS_RTTI("snippets::pass::ExplicitTransposeMatMulInputs");ExplicitTransposeMatMulInputs();diff --git a/src/common/snippets/include/snippets/pass/extract_constants.hpp b/src/common/snippets/include/snippets/pass/extract_constants.hppindex 3190831a9d3..e9ce0a3e77d 100644--- a/src/common/snippets/include/snippets/pass/extract_constants.hpp+++ b/src/common/snippets/include/snippets/pass/extract_constants.hpp@@ -12,10 +12,11 @@ namespace pass {/*** @interface ExtractConstants- * @brief Moves up Constants which aren't scalars outside of the Subgraph's body and replaces them with Parameters inside body+ * @brief Moves up Constants which aren't scalars outside of the Subgraph's body and replaces them with Parameters+ * inside body* @ingroup snippets*/-class ExtractConstants: public CommonOptimizations::SubgraphPass {+class ExtractConstants : public CommonOptimizations::SubgraphPass {public:OPENVINO_RTTI("ExtractConstants", "0");ExtractConstants() = default;@@ -23,7 +24,6 @@ public:bool run_on_subgraph(const std::shared_ptr<op::Subgraph>& subgraph) override;};--} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/pass/extract_unsupported_transposes.hpp b/src/common/snippets/include/snippets/pass/extract_unsupported_transposes.hppindex 833f7a6c634..7006e6868e9 100644--- a/src/common/snippets/include/snippets/pass/extract_unsupported_transposes.hpp+++ b/src/common/snippets/include/snippets/pass/extract_unsupported_transposes.hpp@@ -15,7 +15,7 @@ namespace pass {* @brief Moves up unsupported Transposes on Parameter outputs from body* @ingroup snippets*/-class ExtractUnsupportedTransposes: public CommonOptimizations::SubgraphPass {+class ExtractUnsupportedTransposes : public CommonOptimizations::SubgraphPass {public:OPENVINO_RTTI("ExtractUnsupportedTransposes", "0");ExtractUnsupportedTransposes() = default;@@ -23,7 +23,6 @@ public:bool run_on_subgraph(const std::shared_ptr<op::Subgraph>& subgraph) override;};--} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/pass/fc_tokenization.hpp b/src/common/snippets/include/snippets/pass/fc_tokenization.hppindex f106974c38c..d962371398a 100644--- a/src/common/snippets/include/snippets/pass/fc_tokenization.hpp+++ b/src/common/snippets/include/snippets/pass/fc_tokenization.hpp@@ -16,7 +16,7 @@ namespace pass {* @brief The pass tokenizes FullyConnected like (with constant path on B input) MatMuls* @ingroup snippets*/-class TokenizeFCSnippets: public ov::pass::MatcherPass {+class TokenizeFCSnippets : public ov::pass::MatcherPass {public:OPENVINO_MATCHER_PASS_RTTI("snippets::pass::TokenizeFCSnippets");TokenizeFCSnippets(const SnippetsTokenization::Config& config);diff --git a/src/common/snippets/include/snippets/pass/fq_decomposition.hpp b/src/common/snippets/include/snippets/pass/fq_decomposition.hppindex 2cf882f6f53..83945385b4e 100644--- a/src/common/snippets/include/snippets/pass/fq_decomposition.hpp+++ b/src/common/snippets/include/snippets/pass/fq_decomposition.hpp@@ -37,7 +37,8 @@ namespace pass {** Some optimizations (example for scalars):* 1. If output element type of FQ is U8 and il = 0, ish = 0, osc = 1, osh = 0, there is enough expression: x * isc- * 2. If output element type of FQ is I8 and ish ~= 128, osc = 1, osh ~= -128, il * isc ~= -128, ih * isc ~= 127 there is enough expression: x * isc+ * 2. If output element type of FQ is I8 and ish ~= 128, osc = 1, osh ~= -128, il * isc ~= -128, ih * isc ~= 127 there+ * is enough expression: x * isc* 3. If osc = 1, osh = 0, there isn't dequantization* 4. If there isn't dequantization and output element type of FQ isn't FP32, there isn't rounding*@@ -78,7 +79,7 @@ public:* 2. ConstantFolding* 3. Validate*/-class CommonFakeQuantizeDecomposition: public ov::pass::ModelPass {+class CommonFakeQuantizeDecomposition : public ov::pass::ModelPass {public:OPENVINO_MODEL_PASS_RTTI("snippets::pass::CommonFakeQuantizeDecomposition");diff --git a/src/common/snippets/include/snippets/pass/fuse_transpose_brgemm.hpp b/src/common/snippets/include/snippets/pass/fuse_transpose_brgemm.hppindex 66278afefa9..e2ff17d309a 100644--- a/src/common/snippets/include/snippets/pass/fuse_transpose_brgemm.hpp+++ b/src/common/snippets/include/snippets/pass/fuse_transpose_brgemm.hpp@@ -4,10 +4,8 @@#pragma once-#include "openvino/pass/matcher_pass.hpp"-#include "openvino/op/transpose.hpp"-+#include "openvino/pass/matcher_pass.hpp"#include "snippets/lowered/port_descriptor.hpp"namespace ov {@@ -18,10 +16,11 @@ namespace pass {* @interface FuseTransposeBrgemm* @brief Fuses Transpose with Brgemm node, fusing on both Brgemm inputs and output is supported. Applicable to* Transposes that don't change the position of the last dimension (since Brgemm supports strided rows i/o).- * Supported any Transpose order where last index is equal to [rank - 1] - it means that last dimension isn't moved.+ * Supported any Transpose order where last index is equal to [rank - 1] - it means that last dimension isn't+ * moved.* @ingroup snippets*/-class FuseTransposeBrgemm: public ov::pass::MatcherPass {+class FuseTransposeBrgemm : public ov::pass::MatcherPass {public:OPENVINO_MATCHER_PASS_RTTI("snippets::pass::FuseTransposeBrgemm");FuseTransposeBrgemm();diff --git a/src/common/snippets/include/snippets/pass/gated_mlp_tokenization.hpp b/src/common/snippets/include/snippets/pass/gated_mlp_tokenization.hppindex a27eae4630a..35e8ccb91df 100644--- a/src/common/snippets/include/snippets/pass/gated_mlp_tokenization.hpp+++ b/src/common/snippets/include/snippets/pass/gated_mlp_tokenization.hpp@@ -26,7 +26,7 @@ namespace pass {* FullyConnected* @ingroup snippets*/-class TokenizeGatedMLPSnippets: public ov::pass::MatcherPass {+class TokenizeGatedMLPSnippets : public ov::pass::MatcherPass {public:OPENVINO_MATCHER_PASS_RTTI("snippets::pass::TokenizeGatedMLPSnippets");TokenizeGatedMLPSnippets(const SnippetsTokenization::Config& config);diff --git a/src/common/snippets/include/snippets/pass/gn_decomposition.hpp b/src/common/snippets/include/snippets/pass/gn_decomposition.hppindex bd1c41c20b0..4c2145b85fd 100644--- a/src/common/snippets/include/snippets/pass/gn_decomposition.hpp+++ b/src/common/snippets/include/snippets/pass/gn_decomposition.hpp@@ -15,7 +15,7 @@ namespace pass {* @brief Decomposes GroupNormalization to a range of low-level operations* @ingroup snippets*/-class GNDecomposition: public ov::pass::MatcherPass {+class GNDecomposition : public ov::pass::MatcherPass {public:OPENVINO_MATCHER_PASS_RTTI("snippets::pass::GNDecomposition");GNDecomposition();diff --git a/src/common/snippets/include/snippets/pass/hash.hpp b/src/common/snippets/include/snippets/pass/hash.hppindex cfb2d8f4707..2c399818cec 100644--- a/src/common/snippets/include/snippets/pass/hash.hpp+++ b/src/common/snippets/include/snippets/pass/hash.hpp@@ -4,17 +4,18 @@#pragma once+#include <openvino/pass/pass.hpp>#include <string>#include "openvino/core/model.hpp"-#include <openvino/pass/pass.hpp>namespace ov {namespace snippets {namespace pass {/**- * @brief Hash transformation calculates hash value for snippets. Don't care about names as no difference from execution perspective+ * @brief Hash transformation calculates hash value for snippets. Don't care about names as no difference from execution+ * perspective*/class Hash : public ov::pass::ModelPass {public:diff --git a/src/common/snippets/include/snippets/pass/insert_movebroadcast.hpp b/src/common/snippets/include/snippets/pass/insert_movebroadcast.hppindex 118cee472ee..6794456f23c 100644--- a/src/common/snippets/include/snippets/pass/insert_movebroadcast.hpp+++ b/src/common/snippets/include/snippets/pass/insert_movebroadcast.hpp@@ -16,16 +16,16 @@ namespace pass {* The pass is used to convert model to a canonical form for code generation* @ingroup snippets*/-class InsertMoveBroadcast: public ov::pass::MatcherPass {+class InsertMoveBroadcast : public ov::pass::MatcherPass {public:OPENVINO_MATCHER_PASS_RTTI("snippets::pass::InsertMoveBroadcast");InsertMoveBroadcast();static Output<ov::Node> BroadcastNodeLastDim(const ov::Output<ov::Node>& value,- const ov::PartialShape& target_shape,- const ov::PartialShape& normalized_shape);+ const ov::PartialShape& target_shape,+ const ov::PartialShape& normalized_shape);};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/pass/manager.hpp b/src/common/snippets/include/snippets/pass/manager.hppindex abc5d9e6590..3c98e3eba25 100644--- a/src/common/snippets/include/snippets/pass/manager.hpp+++ b/src/common/snippets/include/snippets/pass/manager.hpp@@ -4,11 +4,10 @@#pragma once-#include "positioned_pass.hpp"-#include "openvino/pass/manager.hpp"#include "openvino/pass/pass.hpp"#include "openvino/pass/validate.hpp"+#include "positioned_pass.hpp"namespace ov {namespace snippets {@@ -31,7 +30,10 @@ public:std::shared_ptr<T> register_pass(Args&&... args) {return ov::pass::Manager::register_pass<T>(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<PassPosition, Pos>::value, 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");auto pass = std::make_shared<T>(std::forward<Args>(args)...);@@ -43,13 +45,14 @@ public:return rc;}- std::shared_ptr<PassBase> register_pass_instance(const PassPosition& pass_id, const std::shared_ptr<PassBase>& pass);+ std::shared_ptr<PassBase> register_pass_instance(const PassPosition& pass_id,+ const std::shared_ptr<PassBase>& pass);void register_positioned_passes(const std::vector<PositionedPassBase>& pos_passes);protected:std::shared_ptr<PassBase> insert_pass_instance(const PassPosition& position, const std::shared_ptr<PassBase>& pass);};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/pass/matmul_to_brgemm.hpp b/src/common/snippets/include/snippets/pass/matmul_to_brgemm.hppindex 939273175ec..4aabcc3491c 100644--- a/src/common/snippets/include/snippets/pass/matmul_to_brgemm.hpp+++ b/src/common/snippets/include/snippets/pass/matmul_to_brgemm.hpp@@ -5,7 +5,6 @@#pragma once#include "openvino/pass/matcher_pass.hpp"-#include "snippets/op/brgemm.hpp"namespace ov {@@ -17,13 +16,12 @@ namespace pass {* @brief Replaces ov::MatMul with snippets::op::Brgemm operation (only non-trasposing MatMuls are currently supported)* @ingroup snippets*/-class MatMulToBrgemm: public ov::pass::MatcherPass {+class MatMulToBrgemm : public ov::pass::MatcherPass {public:OPENVINO_MATCHER_PASS_RTTI("snippets::pass::MatMulToBrgemm");MatMulToBrgemm();};-} // namespace pass} // namespace snippets} // namespace ovdiff --git a/src/common/snippets/include/snippets/pass/mha_tokenization.hpp b/src/common/snippets/include/snippets/pass/mha_tokenization.hppindex 8c777ddd8a2..116f21b4909 100644--- a/src/common/snippets/include/snippets/pass/mha_tokenization.hpp+++ b/src/common/snippets/include/snippets/pass/mha_tokenization.hpp@@ -38,7 +38,7 @@ namespace pass {* * After MatMul1 may be only Transpose3 or any count of Eltwise, Select ops.* @ingroup snippets*/-class TokenizeMHASnippets: public ov::pass::MatcherPass {+class TokenizeMHASnippets : public ov::pass::MatcherPass {public:OPENVINO_MATCHER_PASS_RTTI("snippets::pass::TokenizeMHASnippets");TokenizeMHASnippets(const SnippetsTokenization::Config& config);diff --git a/src/common/snippets/include/snippets/pass/mlp_seq_tokenization.hpp b/src/common/snippets/include/snippets/pass/mlp_seq_tokenization.hppindex 16e7f18b283..87ba54106f0 100644--- a/src/common/snippets/include/snippets/pass/mlp_seq_tokenization.hpp+++ b/src/common/snippets/include/snippets/pass/mlp_seq_tokenization.hpp@@ -26,7 +26,7 @@ namespace pass {* ...* @ingroup snippets*/-class TokenizeMLPSeqSnippets: public ov::pass::MatcherPass {+class TokenizeMLPSeqSnippets : public ov::pass::MatcherPass {public:OPENVINO_MATCHER_PASS_RTTI("snippets::pass::TokenizeMLPSeqSnippets");TokenizeMLPSeqSnippets(const SnippetsTokenization::Config& config);diff --git a/src/common/snippets/include/snippets/pass/positioned_pass.hpp b/src/common/snippets/include/snippets/pass/positioned_pass.hppindex bbe04f3a560..650be587017 100644--- a/src/common/snippets/include/snippets/pass/positioned_pass.hpp+++ b/src/common/snippets/include/snippets/pass/positioned_pass.hpp@@ -4,19 +4,18 @@#pragma once+#include <typeinfo>+#include "openvino/pass/manager.hpp"#include "openvino/pass/pass.hpp"#include "openvino/pass/validate.hpp"-#include <typeinfo>--namespace ov {namespace snippets {namespace pass {/**-* @brief PassPosition describes a particular position in a transformation pipeline,+ * @brief PassPosition describes a particular position in a transformation pipeline,* where a new transformation should be inserted.* @param pass_name name of the anchor pass, the new pass will be inserted before/after it.* Empty pass_name could mean either beginning or the end of the pipeline depending on the `after` flag.@@ -26,8 +25,8 @@ namespace pass {* If `pass_name` is empty, `true` means the end, and `false` - the beginning of the pipeline.* @param pass_instance the number of the pass with matching `pass_name` to be considered as the anchor pass.* 0 (default) means the first pass with `pass_name` will be considered as the anchor pass.-* @ingroup snippets-*/+ * @ingroup snippets+ */class PassPosition {public:enum class Place { Before, After, PipelineStart, PipelineEnd };@@ -35,8 +34,9 @@ public:explicit PassPosition(Place pass_place);explicit PassPosition(Place pass_place, const DiscreteTypeInfo& pass_type_info, size_t pass_instance = 0);- template<typename PassType>- typename std::vector<std::shared_ptr<PassType>>::const_iterator get_insert_position(const std::vector<std::shared_ptr<PassType>>& pass_list) const;+ template <typename PassType>+ typename std::vector<std::shared_ptr<PassType>>::const_iterator get_insert_position(+ const std::vector<std::shared_ptr<PassType>>& pass_list) const;private:const DiscreteTypeInfo m_pass_type_info = {};@@ -44,16 +44,17 @@ private:const Place m_place{Place::Before};};-template<typename PassType>+template <typename PassType>struct PositionedPass {PositionedPass(PassPosition arg_pos, std::shared_ptr<PassType> arg_pass)- : position(arg_pos), pass(std::move(arg_pass)) {}+ : position(arg_pos),+ pass(std::move(arg_pass)) {}PassPosition position;std::shared_ptr<PassType> pass;};-template<typename PassType>+template <typename PassType>typename std::vector<std::shared_ptr<PassType>>::const_iterator PassPosition::get_insert_position(const std::vector<std::shared_ptr<PassType>>& pass_list) const {size_t pass_count = 0;@@ -66,19 +67,21 @@ typename std::vector<std::shared_ptr<PassType>>::const_iterator PassPosition::gereturn false;};switch (m_place) {- case Place::PipelineStart: return pass_list.cbegin();- case Place::PipelineEnd: return pass_list.cend();- case Place::Before:- case Place::After: {- auto insert_it = std::find_if(pass_list.cbegin(), pass_list.cend(), match);- OPENVINO_ASSERT(insert_it != pass_list.cend(), "PassPosition ", m_pass_type_info, " cannot be found");- return m_place == Place::After ? std::next(insert_it) : insert_it;- }- default:- OPENVINO_THROW("Unsupported Place type in PassPosition::get_insert_position");+ case Place::PipelineStart:+ return pass_list.cbegin();+ case Place::PipelineEnd:+ return pass_list.cend();+ case Place::Before:+ case Place::After: {+ auto insert_it = std::find_if(pass_list.cbegin(), pass_list.cend(), match);+ OPENVINO_ASSERT(insert_it != pass_list.cend(), "PassPosition ", m_pass_type_info, " cannot be found");+ return m_place == Place::After ? std::next(insert_it) : insert_it;+ }+ default:+ OPENVINO_THROW("Unsupported Place type in PassPosition::get_insert_position");}}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/pass/propagate_precision.hpp b/src/common/snippets/include/snippets/pass/propagate_precision.hppindex 9d12a524043..dbfe00567d3 100644--- a/src/common/snippets/include/snippets/pass/propagate_precision.hpp+++ b/src/common/snippets/include/snippets/pass/propagate_precision.hpp@@ -5,6 +5,7 @@#pragma once#include <memory>+#include "openvino/pass/pass.hpp"#include "snippets/generator.hpp"@@ -17,7 +18,7 @@ namespace pass {* @ingroup snippets* @brief PropagatePrecision transformation propagate precision from parameters to results.*/-class PropagatePrecision: public ov::pass::ModelPass {+class PropagatePrecision : public ov::pass::ModelPass {public:OPENVINO_MODEL_PASS_RTTI("snippets::pass::PropagatePrecision");PropagatePrecision(const std::shared_ptr<const TargetMachine>& target_machine);diff --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 170ff97bf21..15b44b8e8e9 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@@ -16,13 +16,12 @@ namespace pass {* Also checks that reduction operation is supported by snippets.* @ingroup snippets*/-class ReduceToSnippetsReduce: public ov::pass::MatcherPass {+class ReduceToSnippetsReduce : public ov::pass::MatcherPass {public:OPENVINO_MATCHER_PASS_RTTI("snippets::pass::ReduceToSnippetsReduce");ReduceToSnippetsReduce();};--} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/pass/softmax_decomposition.hpp b/src/common/snippets/include/snippets/pass/softmax_decomposition.hppindex b604b49dffe..403df8c0883 100644--- a/src/common/snippets/include/snippets/pass/softmax_decomposition.hpp+++ b/src/common/snippets/include/snippets/pass/softmax_decomposition.hpp@@ -15,7 +15,7 @@ namespace pass {* @brief Decomposes Softmax to a range of low-level operations* @ingroup snippets*/-class SoftmaxDecomposition: public ov::pass::MatcherPass {+class SoftmaxDecomposition : public ov::pass::MatcherPass {public:OPENVINO_MATCHER_PASS_RTTI("snippets::pass::SoftmaxDecomposition");SoftmaxDecomposition();diff --git a/src/common/snippets/include/snippets/pass/softmax_reshape_elimination.hpp b/src/common/snippets/include/snippets/pass/softmax_reshape_elimination.hppindex f855eaffbc2..87679554989 100644--- a/src/common/snippets/include/snippets/pass/softmax_reshape_elimination.hpp+++ b/src/common/snippets/include/snippets/pass/softmax_reshape_elimination.hpp@@ -15,13 +15,12 @@ namespace pass {* @brief The pass removes Reshape operations around Softmax if possible* @ingroup snippets*/-class SoftmaxReshapeElimination: public ov::pass::MatcherPass {+class SoftmaxReshapeElimination : public ov::pass::MatcherPass {public:OPENVINO_MATCHER_PASS_RTTI("snippets::pass::SoftmaxReshapeElimination");SoftmaxReshapeElimination();};-} // namespace pass} // namespace snippets} // namespace ovdiff --git a/src/common/snippets/include/snippets/pass/split_dimension_m.hpp b/src/common/snippets/include/snippets/pass/split_dimension_m.hppindex 8607b8e8eed..28f0ea61251 100644--- a/src/common/snippets/include/snippets/pass/split_dimension_m.hpp+++ b/src/common/snippets/include/snippets/pass/split_dimension_m.hpp@@ -19,7 +19,7 @@ namespace pass {* @todo Ticket 148805: Move static cases handling in RuntimeConfigurator as well.* @ingroup snippets*/-class SplitDimensionM: public CommonOptimizations::SubgraphPass {+class SplitDimensionM : public CommonOptimizations::SubgraphPass {public:OPENVINO_RTTI("SplitDimensionM", "0");SplitDimensionM(size_t concurrency) : m_concurrency(concurrency) {}@@ -39,7 +39,10 @@ public:* @param new_m_dim reference on new M dim after the split* @return true if split was successfull, otherwise false*/- static bool split(const ov::Shape& shape, size_t optimal_parallelism_work_amount, size_t& batch_m_dim, size_t& new_m_dim);+ static bool split(const ov::Shape& shape,+ size_t optimal_parallelism_work_amount,+ size_t& batch_m_dim,+ size_t& new_m_dim);/*** @brief Splits m dimension in order@@ -56,7 +59,10 @@ public:* @param new_m_dim new M dim after the split* @return the updated shape*/- static ov::snippets::VectorDims reshape_m_dim(ov::snippets::VectorDims shape, size_t m_index, size_t batch_m_dim, size_t new_m_dim);+ static ov::snippets::VectorDims reshape_m_dim(ov::snippets::VectorDims shape,+ size_t m_index,+ size_t batch_m_dim,+ size_t new_m_dim);/*** @brief Unsqueezes m dimension in "shape" (inserts "1" before the dimension)* @param shape Shape to split@@ -70,17 +76,28 @@ private:/*** @brief Contains splitM approaches allowing to get the batch ideally divisible by optimal_parallelism_work_amount*/- static std::pair<size_t, size_t> split_ideally(size_t batch_dim, size_t m_dim, size_t optimal_parallelism_work_amount);+ static std::pair<size_t, size_t> split_ideally(size_t batch_dim,+ size_t m_dim,+ size_t optimal_parallelism_work_amount);/**- * @brief Splits m_dim to minimize kernel_m in order to reduce waiting time for idle threads at the last parallel loop iteration.+ * @brief Splits m_dim to minimize kernel_m in order to reduce waiting time for idle threads at the last parallel+ * loop iteration.*/- static std::pair<size_t, size_t> split_minimize_kernel_wa(size_t batch_dim, size_t m_dim, size_t optimal_parallelism_work_amount);+ static std::pair<size_t, size_t> split_minimize_kernel_wa(size_t batch_dim,+ size_t m_dim,+ size_t optimal_parallelism_work_amount);/**- * @brief Splits m_dim to get the batch in (optimal_parallelism_work_amount, 2 * optimal_parallelism_work_amount) interval+ * @brief Splits m_dim to get the batch in (optimal_parallelism_work_amount, 2 * optimal_parallelism_work_amount)+ * interval*/- static std::pair<size_t, size_t> split_fallback_increase_parallel_wa(size_t batch_dim, size_t m_dim, size_t optimal_parallelism_work_amount);+ static std::pair<size_t, size_t> split_fallback_increase_parallel_wa(size_t batch_dim,+ 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);+ 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) {@@ -94,6 +111,6 @@ private:static const size_t min_kernel_m;static const size_t dim_M_index;};-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/pass/subgraph_manager.hpp b/src/common/snippets/include/snippets/pass/subgraph_manager.hppindex 4f01f6fea11..7eb152f2ff2 100644--- a/src/common/snippets/include/snippets/pass/subgraph_manager.hpp+++ b/src/common/snippets/include/snippets/pass/subgraph_manager.hpp@@ -8,10 +8,9 @@#include <typeinfo>#include <vector>+#include "snippets/op/subgraph.hpp"#include "snippets/pass/common_optimizations.hpp"-#include "snippets/pass/subgraph_pass.hpp"-#include "snippets/op/subgraph.hpp"namespace ov {namespace snippets {@@ -19,7 +18,8 @@ namespace pass {/*** @brief Manager class allows to manage transformation passes (SubgraphPasses) on Subgraph ops.* See SubgraphPasses description for more details.- * It's light version of ov::Manager implementation the purpose of which is to change only Subgraph as separate node in model.+ * It's light version of ov::Manager implementation the purpose of which is to change only Subgraph as separate+ * node in model.* @ingroup snippets*/class CommonOptimizations::SubgraphManager {diff --git a/src/common/snippets/include/snippets/pass/subgraph_pass.hpp b/src/common/snippets/include/snippets/pass/subgraph_pass.hppindex 5b9cc9e29c6..b38f54d1157 100644--- a/src/common/snippets/include/snippets/pass/subgraph_pass.hpp+++ b/src/common/snippets/include/snippets/pass/subgraph_pass.hpp@@ -8,7 +8,6 @@#include "snippets/pass/common_optimizations.hpp"-namespace ov {namespace snippets {namespace pass {@@ -29,8 +28,12 @@ public:virtual bool run_on_subgraph(const std::shared_ptr<op::Subgraph>& subgraph) = 0;- void set_name(const std::string& name) { m_name = name; }- std::string get_name() const { return m_name; }+ void set_name(const std::string& name) {+ m_name = name;+ }+ std::string get_name() const {+ return m_name;+ }using type_info_t = DiscreteTypeInfo;virtual const type_info_t& get_type_info() const = 0;@@ -39,7 +42,6 @@ private:std::string m_name;};--} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/pass/tokenization.hpp b/src/common/snippets/include/snippets/pass/tokenization.hppindex e8353a751d9..5bde74624c0 100644--- a/src/common/snippets/include/snippets/pass/tokenization.hpp+++ b/src/common/snippets/include/snippets/pass/tokenization.hpp@@ -5,7 +5,6 @@#pragma once#include "openvino/pass/matcher_pass.hpp"-#include "snippets/op/subgraph.hpp"namespace ov {@@ -14,15 +13,16 @@ namespace pass {/*NotSet - default value returned by GetSnippetsNodeType(...) if the node wasn't marked- SkippedByPlugin - indicate that snippets can't include this node in subgraph. Can be set by Plugin via SetSnippetsNodeType(...).+ SkippedByPlugin - indicate that snippets can't include this node in subgraph. Can be set by Plugin via+ SetSnippetsNodeType(...).*/-enum class SnippetsNodeType : int64_t {NotSet, SkippedByPlugin};+enum class SnippetsNodeType : int64_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};+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>&);@@ -42,7 +42,6 @@ public:bool run_on_model(const std::shared_ptr<ov::Model>&) override;};-/*** @interface SnippetsTokenization* @brief Splits model to supported subgraphs@@ -54,7 +53,8 @@ public:* - During tokenization new Subgraph op takes the name of the last tokenized op.* It's needed to save output names of model in cases when tokenized op was before model Result.* - If some transformation (for example, SplitDimensionM) insert new op after Subgraph,- * the op should be called as this Subgraph to save output name. The Subgraph name is updated using suffix "_original".+ * the op should be called as this Subgraph to save output name. The Subgraph name is updated using suffix+ * "_original".* @ingroup snippets*/class SnippetsTokenization : public ov::pass::ModelPass {@@ -138,7 +138,7 @@ public:// Set of supported Transpose shape ranks for tokenization in MHATokenization pass.// Note that in general Snippets support Transpose of any ranks.// But at the moment Transpose is used only in MHA pattern where 3D and 4D tensors are supported.- std::set<size_t> m_mha_supported_transpose_ranks = { 3, 4 };+ std::set<size_t> m_mha_supported_transpose_ranks = {3, 4};// Predicate that checks if the node can be fused as MatMul post-op.// It is currently used only in TokenizeMLPSeqSnippetsCanBeFusedAsPostOpPred m_can_be_fused_as_postop = nullptr;@@ -151,7 +151,6 @@ private:Config m_config;};-} // namespace pass} // namespace snippets} // namespace ovdiff --git a/src/common/snippets/include/snippets/pass/transform_convert.hpp b/src/common/snippets/include/snippets/pass/transform_convert.hppindex 7f2a3ac3c10..0814b231abd 100644--- a/src/common/snippets/include/snippets/pass/transform_convert.hpp+++ b/src/common/snippets/include/snippets/pass/transform_convert.hpp@@ -17,7 +17,7 @@ namespace pass {* This op is used for real Convert ops inside subgraph body in CPU Plugin* @ingroup snippets*/-class TransformConvertToConvertTruncation: public ov::pass::MatcherPass {+class TransformConvertToConvertTruncation : public ov::pass::MatcherPass {public:OPENVINO_MATCHER_PASS_RTTI("snippets::pass::TransformConvertToConvertTruncation");TransformConvertToConvertTruncation();diff --git a/src/common/snippets/include/snippets/pass/transpose_decomposition.hpp b/src/common/snippets/include/snippets/pass/transpose_decomposition.hppindex ea0305c331b..1f0a8a057ae 100644--- a/src/common/snippets/include/snippets/pass/transpose_decomposition.hpp+++ b/src/common/snippets/include/snippets/pass/transpose_decomposition.hpp@@ -15,7 +15,7 @@ namespace pass {* @brief Decompose Transpose to Load + Store wrapped in several loops.* @ingroup snippets*/-class TransposeDecomposition: public ov::pass::MatcherPass {+class TransposeDecomposition : public ov::pass::MatcherPass {public:OPENVINO_MATCHER_PASS_RTTI("snippets::pass::TransposeDecomposition");TransposeDecomposition();diff --git a/src/common/snippets/include/snippets/pass/validate.hpp b/src/common/snippets/include/snippets/pass/validate.hppindex 94998274cd0..221fa8fb03f 100644--- a/src/common/snippets/include/snippets/pass/validate.hpp+++ b/src/common/snippets/include/snippets/pass/validate.hpp@@ -15,7 +15,7 @@ namespace pass {* @brief The pass validates OV model on correctness after all common optimizations* @ingroup snippets*/-class Validate: public ov::pass::ModelPass {+class Validate : public ov::pass::ModelPass {public:OPENVINO_MODEL_PASS_RTTI("snippets::pass::Validate");Validate(const std::shared_ptr<ov::pass::PassConfig>& pass_config) : m_pass_config(pass_config) {}diff --git a/src/common/snippets/include/snippets/remarks.hpp b/src/common/snippets/include/snippets/remarks.hppindex 092731607c2..6801f0dc821 100644--- a/src/common/snippets/include/snippets/remarks.hpp+++ b/src/common/snippets/include/snippets/remarks.hpp@@ -6,9 +6,9 @@#include <iostream>// Todo: Replace remarks with DEBUG_CAPS-class logstreambuf: public std::streambuf {+class logstreambuf : public std::streambuf {public:- static const int threshold {50};+ static const int threshold{50};};template <typename T>@@ -16,5 +16,5 @@ static inline auto remark(T x) -> std::ostream& {static logstreambuf nostreambuf;static std::ostream nocout(&nostreambuf);- return ((x >= logstreambuf::threshold)? std::cout << "Remark: " : nocout);+ return ((x >= logstreambuf::threshold) ? std::cout << "Remark: " : nocout);}diff --git a/src/common/snippets/include/snippets/runtime_configurator.hpp b/src/common/snippets/include/snippets/runtime_configurator.hppindex 866e98843fc..3dfd593dffb 100644--- a/src/common/snippets/include/snippets/runtime_configurator.hpp+++ b/src/common/snippets/include/snippets/runtime_configurator.hpp@@ -24,7 +24,7 @@ public:// Note that get_type_info_static and get_type_info are needed to mimic OPENVINO_RTTI interface,// so the standard OPENVINO_RTTI(...) macros could be used in derived classes._OPENVINO_HIDDEN_METHOD static const ::ov::DiscreteTypeInfo& get_type_info_static() {- static ::ov::DiscreteTypeInfo type_info_static {"RuntimeConfig"};+ static ::ov::DiscreteTypeInfo type_info_static{"RuntimeConfig"};type_info_static.hash();return type_info_static;}@@ -50,7 +50,7 @@ public: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 = {};};@@ -74,7 +74,9 @@ public:* @brief Returns pointer to KernelExecutorTable owned by the config* @return updated KernelExecutorTable*/- const std::shared_ptr<KernelExecutorTable>& get_kernel_executor_table() const { return m_config->kernel_executor_table; }+ const std::shared_ptr<KernelExecutorTable>& get_kernel_executor_table() const {+ return m_config->kernel_executor_table;+ }/*** @brief Set new KernelExecutorTable to the config* @param table new KernelExecutorTable@@ -87,12 +89,24 @@ public:void reset_kernel_executor_table() const;// Getters for private members- std::shared_ptr<RuntimeConfig> get_config() const { return m_config; }- size_t get_io_num() const { return m_io_num; }- size_t get_in_num() const { return m_in_num; }- const std::vector<snippets::lowered::PortDescriptorPtr>& get_io_descs() const { return m_io_descs; }- 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 { return m_dynamic_buffer_clusters; }+ std::shared_ptr<RuntimeConfig> get_config() const {+ return m_config;+ }+ size_t get_io_num() const {+ return m_io_num;+ }+ size_t get_in_num() const {+ return m_in_num;+ }+ const std::vector<snippets::lowered::PortDescriptorPtr>& get_io_descs() const {+ return m_io_descs;+ }+ 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 {+ return m_dynamic_buffer_clusters;+ }/*** @brief Computes the offsets for each dimension of a tensor shape.@@ -207,5 +221,5 @@ protected:lowered::pass::PassPipeline m_final_optimizers;};-} // namespace snippets-} // namespace ov+} // namespace snippets+} // namespace ovdiff --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 f6cd6f0626f..fc4c4209f7d 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@@ -9,7 +9,9 @@namespace ov {namespace snippets {-bool broadcast_merge_into(VectorDims& dst, const VectorDims& src, const ov::op::AutoBroadcastSpec& autob = ov::op::AutoBroadcastType::NUMPY);+bool broadcast_merge_into(VectorDims& dst,+ const VectorDims& src,+ const ov::op::AutoBroadcastSpec& autob = ov::op::AutoBroadcastType::NUMPY);bool merge_into(VectorDims& dst, const VectorDims& src);@@ -18,10 +20,10 @@ public:Result infer(const std::vector<VectorDimsRef>& input_shapes) override;};--template<class BroadcastOP>+template <class BroadcastOP>class BroadcastShapeInfer : public IShapeInferSnippets {std::shared_ptr<BroadcastOP> broadcast_op;+public:explicit BroadcastShapeInfer(const std::shared_ptr<Node>& n);Result infer(const std::vector<VectorDimsRef>& input_shapes) override;@@ -51,6 +53,7 @@ public:class SelectShapeInfer : public IShapeInferSnippets {ov::op::AutoBroadcastSpec m_broadcast_spec;+public:explicit SelectShapeInfer(const std::shared_ptr<Node>& n);Result infer(const std::vector<VectorDimsRef>& input_shapes) override;@@ -63,6 +66,7 @@ public:class BrgemmShapeInfer : public IShapeInferSnippets {std::vector<std::vector<size_t>> m_io_layouts;+public:explicit BrgemmShapeInfer(const std::shared_ptr<Node>& n);Result infer(const std::vector<VectorDimsRef>& input_shapes) override;@@ -70,10 +74,11 @@ public:class ReduceShapeInfer : public IShapeInferSnippets {size_t m_axis;+public:explicit ReduceShapeInfer(const std::shared_ptr<Node>& n);Result infer(const std::vector<VectorDimsRef>& input_shapes) override;};-} // namespace snippets-} // namespace ov+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/shape_inference/shape_inference.hpp b/src/common/snippets/include/snippets/shape_inference/shape_inference.hppindex d94fd62043c..5d0b49794f0 100644--- a/src/common/snippets/include/snippets/shape_inference/shape_inference.hpp+++ b/src/common/snippets/include/snippets/shape_inference/shape_inference.hpp@@ -5,14 +5,15 @@#pragma once#include <openvino/core/core.hpp>+#include "snippets/shape_types.hpp"namespace ov {namespace snippets {enum class ShapeInferStatus {- success, ///< shapes were successfully calculated- skip ///< shape inference was skipped.+ success, ///< shapes were successfully calculated+ skip ///< shape inference was skipped.};/*** This is Snippets specific shape inference interface.@@ -31,7 +32,8 @@ public:* @brief This method actually performs all the necessary shape inference computations** @param input_shapes are the input tensors shapes- * @return Result instance that contains an array of calculated shapes (per each output port) and a status of the shape infer call+ * @return Result instance that contains an array of calculated shapes (per each output port) and a status of the+ * shape infer call*/virtual Result infer(const std::vector<VectorDimsRef>& input_shapes) = 0;};@@ -43,7 +45,10 @@ public:*/class ShapeInferSnippetsNode : public IShapeInferSnippets {public:- const Result& get_last_result() {return m_last_result; }+ const Result& get_last_result() {+ return m_last_result;+ }+protected:Result m_last_result{{}, ShapeInferStatus::success};};@@ -53,7 +58,7 @@ public:// Helper type to define specific Makers map values.using ShapeInferPtr = std::shared_ptr<IShapeInferSnippets>;// Helper type to define specific Makers map type.- using TRegistry = std::unordered_map<ov::DiscreteTypeInfo, std::function<ShapeInferPtr (std::shared_ptr<ov::Node>)>>;+ using TRegistry = std::unordered_map<ov::DiscreteTypeInfo, std::function<ShapeInferPtr(std::shared_ptr<ov::Node>)>>;/*** \brief Creates the shape inference object.@@ -72,12 +77,13 @@ private: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;+ * @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;};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 snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/shape_types.hpp b/src/common/snippets/include/snippets/shape_types.hppindex 9a3c6f9e80c..e6b4adb576d 100644--- a/src/common/snippets/include/snippets/shape_types.hpp+++ b/src/common/snippets/include/snippets/shape_types.hpp@@ -4,20 +4,21 @@#pragma once-#include <vector>#include <memory>+#include <vector>namespace ov {namespace 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,- * both PortDescriptor and IShapeInferSnippets use VectorDims, but these two classes are completely independent semantically.+ * both PortDescriptor and IShapeInferSnippets use VectorDims, but these two classes are completely independent+ * semantically.*/using VectorDims = std::vector<size_t>;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 snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/snippets_isa.hpp b/src/common/snippets/include/snippets/snippets_isa.hppindex 409da7ce46e..5028c175a60 100644--- a/src/common/snippets/include/snippets/snippets_isa.hpp+++ b/src/common/snippets/include/snippets/snippets_isa.hpp@@ -4,32 +4,31 @@#pragma once-#include "openvino/core/node.hpp"-#include "openvino/opsets/opset1.hpp"-+#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/fill.hpp"#include "op/kernel.hpp"#include "op/load.hpp"-#include "op/reshape.hpp"-#include "op/reorder.hpp"+#include "op/loop.hpp"#include "op/nop.hpp"-#include "op/scalar.hpp"+#include "op/perf_count.hpp"#include "op/powerstatic.hpp"-#include "op/store.hpp"-#include "op/loop.hpp"-#include "op/brgemm.hpp"-#include "op/vector_buffer.hpp"#include "op/rank_normalization.hpp"-#include "op/perf_count.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 {@@ -37,6 +36,6 @@ namespace isa {#define OV_OP(a, b) using b::a;#include "snippets_isa_tbl.hpp"#undef OV_OP-} // namespace isa-} // namespace snippets-} // namespace ov+} // namespace isa+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/include/snippets/snippets_isa_tbl.hpp b/src/common/snippets/include/snippets/snippets_isa_tbl.hppindex dc56c11bc0b..85d0d533bb2 100644--- a/src/common/snippets/include/snippets/snippets_isa_tbl.hpp+++ b/src/common/snippets/include/snippets/snippets_isa_tbl.hpp@@ -5,8 +5,8 @@#pragma once#ifndef OV_OP-#warning "OV_OP not defined"-#define OV_OP(x, y)+# warning "OV_OP not defined"+# define OV_OP(x, y)#endif// SnippetS dialectdiff --git a/src/common/snippets/include/snippets/target_machine.hpp b/src/common/snippets/include/snippets/target_machine.hppindex a5e95a70a2a..3d1e2424844 100644--- a/src/common/snippets/include/snippets/target_machine.hpp+++ b/src/common/snippets/include/snippets/target_machine.hpp@@ -23,13 +23,15 @@ struct CompiledSnippet {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;+ std::function<std::set<ov::element::TypeVector>(const std::shared_ptr<ov::Node>&)>>+ jitters_value;class RuntimeConfigurator;/*** @interface TargetMachine- * @brief Base class Target machine representation. Target derives from this class to provide generator information about supported emitters+ * @brief Base class Target machine representation. Target derives from this class to provide generator information+ * about supported emitters* @ingroup snippets*/class TargetMachine {@@ -70,22 +72,25 @@ public:*/virtual std::vector<snippets::Reg> get_gp_reg_pool() const = 0;/**- * @brief Get all available vector registers.+ * @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;/*** @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+ * @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;/*** @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+ * @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;+ 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@@ -110,5 +115,5 @@ protected:std::shared_ptr<RuntimeConfigurator> configurator;};-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace snippets+} // namespace ov\ No newline at end of filediff --git a/src/common/snippets/include/snippets/utils/debug_caps_config.hpp b/src/common/snippets/include/snippets/utils/debug_caps_config.hppindex a8726395d53..8c3c8ef7091 100644--- a/src/common/snippets/include/snippets/utils/debug_caps_config.hpp+++ b/src/common/snippets/include/snippets/utils/debug_caps_config.hpp@@ -3,16 +3,16 @@//#ifdef SNIPPETS_DEBUG_CAPS-#pragma once+# pragma once-#include "openvino/util/common_util.hpp"-#include "openvino/core/except.hpp"+# include <bitset>+# include <memory>+# include <unordered_map>+# include <utility>+# include <vector>-#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 {@@ -55,8 +55,11 @@ public:std::vector<PropertySetterPtr> getPropertySetters() override {return {PropertySetterPtr(new StringPropertySetter("dir", dir, "path to dumped LIRs")),format.getPropertySetter(),- PropertySetterPtr(new MultipleStringPropertySetter("passes", passes,- "indicate dump LIRs around the passes. Support multiple passes with comma separated and case insensitive. 'all' means dump all passes"))};+ PropertySetterPtr(new MultipleStringPropertySetter(+ "passes",+ passes,+ "indicate dump LIRs around the passes. Support multiple passes with comma separated and case "+ "insensitive. 'all' means dump all passes"))};}} dumpLIR;@@ -118,7 +121,9 @@ private:};struct MultipleStringPropertySetter : PropertySetter {- MultipleStringPropertySetter(const std::string& name, std::vector<std::string>& ref, const std::string&& valueDescription)+ MultipleStringPropertySetter(const std::string& name,+ std::vector<std::string>& ref,+ const std::string&& valueDescription): PropertySetter(name),propertyValues(ref),propertyValueDescription(valueDescription) {}@@ -197,4 +202,4 @@ private:} // namespace snippets} // namespace ov-#endif // SNIPPETS_DEBUG_CAPS+#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 fabd2253583..7dc9262fd5b 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@@ -5,11 +5,11 @@#pragma once#ifdef SNIPPETS_DEBUG_CAPS-#include "snippets/utils/debug_caps_config.hpp"-#include "openvino/util/file_util.hpp"-#include "snippets/lowered/linear_ir.hpp"-#include "snippets/lowered/pass/serialize_control_flow.hpp"-#include "snippets/lowered/pass/serialize_data_flow.hpp"+# include "openvino/util/file_util.hpp"+# include "snippets/lowered/linear_ir.hpp"+# include "snippets/lowered/pass/serialize_control_flow.hpp"+# include "snippets/lowered/pass/serialize_data_flow.hpp"+# include "snippets/utils/debug_caps_config.hpp"namespace ov {namespace snippets {@@ -17,7 +17,9 @@ namespace snippets {class LIRPassDump {public:explicit LIRPassDump(const lowered::LinearIR& linear_ir, std::string pass_name)- : linear_ir(linear_ir), pass_name(std::move(pass_name)), debug_config(*linear_ir.get_config().debug_config) {+ : linear_ir(linear_ir),+ pass_name(std::move(pass_name)),+ debug_config(*linear_ir.get_config().debug_config) {dump("_in");}~LIRPassDump() {@@ -32,12 +34,14 @@ private:ov::util::create_directory_recursive(debug_config.dumpLIR.dir);if (debug_config.dumpLIR.format.filter[DebugCapsConfig::LIRFormatFilter::controlFlow]) {- std::string xml_path = pathAndName + std::to_string(num) + '_' + pass_name + "_control_flow" + postfix +".xml";+ std::string xml_path =+ pathAndName + std::to_string(num) + '_' + pass_name + "_control_flow" + postfix + ".xml";lowered::pass::SerializeControlFlow SerializeLIR(xml_path);SerializeLIR.run(linear_ir);}if (debug_config.dumpLIR.format.filter[DebugCapsConfig::LIRFormatFilter::dataFlow]) {- std::string xml_path = pathAndName + std::to_string(num) + '_' + pass_name + "_data_flow" + postfix +".xml";+ std::string xml_path =+ pathAndName + std::to_string(num) + '_' + pass_name + "_data_flow" + postfix + ".xml";lowered::pass::SerializeDataFlow SerializeLIR(xml_path);SerializeLIR.run(linear_ir);}@@ -52,14 +56,15 @@ private:} // namespace snippets} // namespace ov-#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 dump_name = dumpLIR.passes; \- auto dumperPtr = ((std::find(dump_name.begin(), dump_name.end(), ov::util::to_lower(pass_name)) != dump_name.end()) || \- (std::find(dump_name.begin(), dump_name.end(), "all") != dump_name.end())) ? \- std::unique_ptr<LIRPassDump>(new LIRPassDump(_linear_ir, pass_name)) : \- nullptr+# 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 dump_name = dumpLIR.passes; \+ auto dumperPtr = \+ ((std::find(dump_name.begin(), dump_name.end(), ov::util::to_lower(pass_name)) != dump_name.end()) || \+ (std::find(dump_name.begin(), dump_name.end(), "all") != dump_name.end())) \+ ? std::unique_ptr<LIRPassDump>(new LIRPassDump(_linear_ir, pass_name)) \+ : nullptr#else-#define SNIPPETS_DEBUG_LIR_PASS_DUMP(_linear_ir, _pass)+# define SNIPPETS_DEBUG_LIR_PASS_DUMP(_linear_ir, _pass)#endif // SNIPPETS_DEBUG_CAPS\ No newline at end of filediff --git a/src/common/snippets/include/snippets/utils/loop_utils.hpp b/src/common/snippets/include/snippets/utils/loop_utils.hppindex c9f9412ff5c..111a2a4da96 100644--- a/src/common/snippets/include/snippets/utils/loop_utils.hpp+++ b/src/common/snippets/include/snippets/utils/loop_utils.hpp@@ -23,10 +23,11 @@ void update_data_pointer_shifts(const ov::snippets::lowered::UnifiedLoopInfoPtr&void update_runtime_parameters(const ov::snippets::lowered::UnifiedLoopInfoPtr& loop_info);/*** @brief Check if the passed expression port should be port of the Loop with ID `loop_id`:- * the target expression port should be connected to an expression from another Loop (missed in the loop with ID `loop_id`),+ * the target expression port should be connected to an expression from another Loop (missed in the loop with ID+ * `loop_id`),*/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 utils+} // namespace snippets+} // namespace ov\ No newline at end of filediff --git a/src/common/snippets/include/snippets/utils/reg_utils.hpp b/src/common/snippets/include/snippets/utils/reg_utils.hppindex 73b1d80d344..1edeeaeef7a 100644--- a/src/common/snippets/include/snippets/utils/reg_utils.hpp+++ b/src/common/snippets/include/snippets/utils/reg_utils.hpp@@ -9,12 +9,13 @@namespace ov {namespace snippets {namespace utils {-inline static std::vector<size_t> transform_snippets_regs_to_idxs(const std::vector<snippets::Reg>& regs, snippets::RegType expected_type) {+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;idxs.reserve(regs.size());for (const auto& reg : regs) {- OPENVINO_ASSERT(reg.type == snippets::RegType::address ||- expected_type == snippets::RegType::undefined || reg.type == expected_type,+ OPENVINO_ASSERT(reg.type == snippets::RegType::address || expected_type == snippets::RegType::undefined ||+ reg.type == expected_type,"Reg type mismatch during to_idxs conversion");idxs.emplace_back(reg.idx);}@@ -22,11 +23,12 @@ inline static std::vector<size_t> transform_snippets_regs_to_idxs(const std::vec}inline static std::vector<size_t> transform_snippets_regs_to_idxs(const std::vector<snippets::Reg>& regs) {std::vector<size_t> idxs;- std::transform(regs.begin(), regs.end(), std::back_inserter(idxs), [](const snippets::Reg& r) { return r.idx; });+ std::transform(regs.begin(), regs.end(), std::back_inserter(idxs), [](const snippets::Reg& r) {+ return r.idx;+ });return idxs;}--} // namespace utils-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace utils+} // namespace snippets+} // namespace ov\ No newline at end of filediff --git a/src/common/snippets/include/snippets/utils/tokenization_utils.hpp b/src/common/snippets/include/snippets/utils/tokenization_utils.hppindex 7702dd55e90..34d188bf07a 100644--- a/src/common/snippets/include/snippets/utils/tokenization_utils.hpp+++ b/src/common/snippets/include/snippets/utils/tokenization_utils.hpp@@ -19,10 +19,11 @@ namespace utils {* 1. The node is wrapped in a trivial Subgraph which contains only this node* 2. The node is fused in parent's Subgraphs* @param node node which should be tokenized- * @param config tokenization config which regulates+ * @param config tokenization config which regulates* @return whether the node was tokenized or not*/-bool tokenize_node(const std::shared_ptr<ov::Node>& node, const ov::snippets::pass::SnippetsTokenization::Config& config);+bool tokenize_node(const std::shared_ptr<ov::Node>& node,+ const ov::snippets::pass::SnippetsTokenization::Config& config);/*** @brief Tokenizes a list of nodes into Subgraph with the following rules:* 1. The user is responsible for valid count of parameters, results and hidden virtual ports (constants)@@ -31,6 +32,6 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const ov::snippets::pa* @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 utils+} // namespace snippets+} // namespace ov\ No newline at end of filediff --git a/src/common/snippets/include/snippets/utils/utils.hpp b/src/common/snippets/include/snippets/utils/utils.hppindex 09ef1d1ba51..3036fde135e 100644--- a/src/common/snippets/include/snippets/utils/utils.hpp+++ b/src/common/snippets/include/snippets/utils/utils.hpp@@ -8,26 +8,28 @@*/#pragma once+#include "openvino/op/constant.hpp"+#include "openvino/op/fake_quantize.hpp"#include "snippets/emitter.hpp"-#include "snippets/shape_types.hpp"#include "snippets/lowered/expression.hpp"#include "snippets/lowered/expression_port.hpp"#include "snippets/lowered/port_descriptor.hpp"--#include "openvino/op/fake_quantize.hpp"-#include "openvino/op/constant.hpp"-+#include "snippets/shape_types.hpp"namespace ov {namespace snippets {namespace 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>+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() {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>+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) {return value == get_dynamic_value<T>();}@@ -56,7 +58,8 @@ void set_full_port_desc(const T& port, size_t rank = 2) {auto get_non_scalar_constant_count_for_fq(const std::shared_ptr<ov::op::v0::FakeQuantize>& fq) -> size_t;inline auto is_scalar_constant(const std::shared_ptr<ov::Node>& source_output_node) -> bool {- return ov::is_type<ov::op::v0::Constant>(source_output_node) && ov::shape_size(source_output_node->get_shape()) == 1;+ return ov::is_type<ov::op::v0::Constant>(source_output_node) &&+ ov::shape_size(source_output_node->get_shape()) == 1;}inline auto normalize_rank(int32_t allocation_rank, const size_t shape_rank) -> int32_t {@@ -64,7 +67,9 @@ inline auto normalize_rank(int32_t allocation_rank, const size_t shape_rank) ->}template <typename T, typename P>-constexpr bool one_of(T val, P item) { return val == item; }+constexpr bool one_of(T val, P item) {+ return val == item;+}template <typename T, typename P, typename... Args>constexpr bool one_of(T val, P item, Args... item_others) {@@ -72,7 +77,9 @@ constexpr bool one_of(T val, P item, Args... item_others) {}template <typename T, typename P>-constexpr bool everyone_is(T val, P item) { return val == item; }+constexpr bool everyone_is(T val, P item) {+ return val == item;+}template <typename T, typename P, typename... Args>constexpr bool everyone_is(T val, P item, Args... item_others) {@@ -92,7 +99,7 @@ static inline auto div_up(const T lhs, const U rhs) -> decltype((lhs + rhs - 1)return (lhs + rhs - 1) / rhs;}-template<typename T, typename U>+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)) ||@@ -103,19 +110,24 @@ static inline auto rnd_up(const T lhs, const U rhs) -> decltype(div_up(lhs, 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) return false;+ if (order[i] != i)+ return false;return true;}inline bool is_dynamic_vdims(const VectorDims& shape) {- return std::any_of(shape.cbegin(), shape.cend(), [](size_t v){ return is_dynamic_value(v); });+ return std::any_of(shape.cbegin(), shape.cend(), [](size_t v) {+ return is_dynamic_value(v);+ });}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 = typename std::enable_if<(std::is_same<T, size_t>::value || std::is_same<T, int64_t>::value), bool>::type>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>();@@ -123,7 +135,9 @@ 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 = typename std::enable_if<(std::is_same<T, size_t>::value || std::is_same<T, int64_t>::value), bool>::type>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>();@@ -131,12 +145,16 @@ 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 = typename std::enable_if<(std::is_same<T, size_t>::value || std::is_same<T, int64_t>::value), bool>::type>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 = typename std::enable_if<(std::is_same<T, size_t>::value || std::is_same<T, int64_t>::value), bool>::type>std::string vector2str(const std::vector<T>& values) {std::ostringstream str;bool first = true;@@ -161,7 +179,8 @@ VectorDims pshape_to_vdims(const PartialShape&);ov::PartialShape vdims_to_pshape(const VectorDims&);inline size_t dimension_to_size_t(const ov::Dimension& dim) {- return dim.is_dynamic() ? snippets::utils::get_dynamic_value<VectorDims::value_type>() : static_cast<size_t>(dim.get_length());+ return dim.is_dynamic() ? snippets::utils::get_dynamic_value<VectorDims::value_type>()+ : static_cast<size_t>(dim.get_length());}// dim_idx starts from the layout end: dim_idx = 0 -> last element in layout (layout.back())@@ -197,26 +216,29 @@ VectorDims get_planar_layout(size_t rank);ov::PartialShape get_planar_pshape(const ov::PartialShape& shape, const std::vector<size_t>& order);/*** @brief Returns original shape before applying the order.- * It means that the shape dimensions have been already reordered in accordance with order indices to produce planar shape+ * It means that the shape dimensions have been already reordered in accordance with order indices to produce+ * planar shape* @param shape planar (ordered) partial shape* @param order order- * @return preordered partial shape: `shape[i]` = `planar_shape[order[i]]` where `shape` is shape before applying the order.- * Example, shape = [16, 2, 32, 64], order = [2, 0, 1, 3]- * planar_shape = [2, 32, 16, 64]+ * @return preordered partial shape: `shape[i]` = `planar_shape[order[i]]` where `shape` is shape before applying the+ * order. Example, shape = [16, 2, 32, 64], order = [2, 0, 1, 3] planar_shape = [2, 32, 16, 64]*/ov::PartialShape get_preordered_pshape(const ov::PartialShape& shape, const std::vector<size_t>& order);/*** @brief Returns a dense shape of node input.- * It means that the node input shape dimensions will be reordered in accordance with order indices to produce planar shape+ * It means that the node input shape dimensions will be reordered in accordance with order indices to produce+ * planar shape* @param in input of node* @return new reordered partial shape: `planar_shape[i]` = `shape[order[i]]`*/ov::PartialShape get_planar_pshape(const Input<Node>& in);/*** @brief Returns original shape of node output before applying the order.- * It means that the preordered output shape dimensions have been already reordered in accordance with order indices to produce planar shape+ * It means that the preordered output shape dimensions have been already reordered in accordance with order+ * indices to produce planar shape* @param out output of node- * @return preordered partial shape: `shape[i]` = `planar_shape[order[i]]` where `shape` is shape before applying the order.+ * @return preordered partial shape: `shape[i]` = `planar_shape[order[i]]` where `shape` is shape before applying the+ * order.*/ov::PartialShape get_preordered_pshape(const Output<Node>& out);/**@@ -231,7 +253,8 @@ ov::PartialShape get_preordered_pshape(const Output<Node>& out);VectorDims get_planar_vdims(const VectorDims& shape, const std::vector<size_t>& order);/*** @brief Returns original shape before applying the order.- * It means that the preordered shape dimensions have been already reordered in accordance with order indices to produce planar shape+ * It means that the preordered shape dimensions have been already reordered in accordance with order indices to+ * produce planar shape* @param shape planar (ordered) shape* @param order order* @return preordered shape: `shape[i]` = `planar_shape[order[i]]` where `shape` is shape before applying the order.@@ -241,14 +264,16 @@ VectorDims get_planar_vdims(const VectorDims& shape, const std::vector<size_t>&VectorDims get_preordered_vdims(const VectorDims& shape, const std::vector<size_t>& order);/*** @brief Returns a dense shape of expression input port.- * It means that the input shape dimensions will be reordered in accordance with order indices to produce planar shape+ * It means that the input shape dimensions will be reordered in accordance with order indices to produce planar+ * shape* @param expr_port input expression port* @return new reordered partial shape: `planar_shape[i]` = `shape[order[i]]`*/VectorDims get_planar_vdims(const snippets::lowered::ExpressionPort& expr_port);/*** @brief Returns original shape before applying the order of expression output port.- * It means that the preordered output shape dimensions has been already reordered in accordance with order indices to produce planar shape+ * It means that the preordered output shape dimensions has been already reordered in accordance with order+ * indices to produce planar shape* @param out input of node* @return preordered shape: `shape[i]` = `planar_shape[order[i]]` where `shape` is shape before applying the order.*/@@ -287,7 +312,8 @@ std::vector<lowered::ExpressionPtr> get_first_parent_shape_infer_expr_seq(const/*** @brief Get leaf shape infer node in first child shape infer sequence from(include) start_node.- * If start_node is a not shape infer node and start_node has no child shape infer node, function will return nullptr.+ * If start_node is a not shape infer node and start_node has no child shape infer node, function will return+ * nullptr.* @param start_node Search from start_node.* @return the leaf shape infer node of first child shape infer sequence or nullptr.*/@@ -295,7 +321,8 @@ std::shared_ptr<ov::Node> get_leaf_node_of_first_child_shape_infer_seq(const std/*** @brief Get leaf shape infer node in first parent shape infer sequence from(include) start_node.- * If start_node is a not shape infer node and start_node has no parent shape infer node, function will return nullptr.+ * If start_node is a not shape infer node and start_node has no parent shape infer node, function will return+ * nullptr.* @param start_node Search from start_node.* @return the first leaf shape infer node or nullptr.*/@@ -337,7 +364,8 @@ void init_strides(const VectorDims& shape, size_t rank, size_t data_size, size_t* Traversal direction is defined by "visit_parent_path"* @param expr The expr from which path is started.* @param visited Set of expressions which were visited.- * @param func The function which is called for each visited node. Please note: the function mustn't modify graph connectivity+ * @param func The function which is called for each visited node. Please note: the function mustn't modify graph+ * connectivity* @param visit_parent_path if true, parent nodes are visited. Otherwise, consumers are visited.*/void visit_path(const lowered::ExpressionPtr& expr,@@ -348,12 +376,12 @@ void visit_path(const lowered::ExpressionPtr& expr,/*** @brief Converts a tensor to a string representation.* Each value in the tensor is converted to a string. If the value is a full dimension, it is represented as- * "FULL_DIM". If the value is dynamic, it is represented as "?".+ * "FULL_DIM". If the value is dynamic, it is represented as "?".* @param tensor The tensor to be converted to a string.* @return A string representation of the tensor.*/std::string tensor2str(const VectorDims& tensor, const std::string& delimiter = ", ");-} // namespace utils-} // namespace snippets-} // namespace ov+} // namespace utils+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/emitter.cpp b/src/common/snippets/src/emitter.cppindex 32742fc5bb4..f0364bb2890 100644--- a/src/common/snippets/src/emitter.cpp+++ b/src/common/snippets/src/emitter.cpp@@ -14,34 +14,30 @@ bool operator!=(const Reg& lhs, const Reg& rhs) {return !(lhs == rhs);}bool operator<(const Reg& lhs, const Reg& rhs) {- return lhs.type < rhs.type ||- (lhs.type == rhs.type && lhs.idx < rhs.idx);+ return lhs.type < rhs.type || (lhs.type == rhs.type && lhs.idx < rhs.idx);}bool operator>(const Reg& lhs, const Reg& rhs) {- return lhs.type > rhs.type ||- (lhs.type == rhs.type && lhs.idx > rhs.idx);+ return lhs.type > rhs.type || (lhs.type == rhs.type && lhs.idx > rhs.idx);}std::ostream& operator<<(std::ostream& s, const Reg& r) {auto regTypeToStr = [](const RegType& type) {switch (type) {- case RegType::vec:- return "vec";- case RegType::gpr:- return "gpr";- case RegType::mask:- return "mask";- case RegType::undefined:- return "undefined";- case RegType::address:- return "address";- default:- OPENVINO_THROW("Unexpected RegType");+ case RegType::vec:+ return "vec";+ case RegType::gpr:+ return "gpr";+ case RegType::mask:+ return "mask";+ case RegType::undefined:+ return "undefined";+ case RegType::address:+ return "address";+ default:+ OPENVINO_THROW("Unexpected RegType");}};- s << regTypeToStr(r.type) << "[" <<- (r.idx == Reg::UNDEFINED_IDX ? "undefined" : std::to_string(r.idx))- << "]";+ s << regTypeToStr(r.type) << "[" << (r.idx == Reg::UNDEFINED_IDX ? "undefined" : std::to_string(r.idx)) << "]";return s;}diff --git a/src/common/snippets/src/generator.cpp b/src/common/snippets/src/generator.cppindex bb6bd636a79..9a9e11e94e3 100644--- a/src/common/snippets/src/generator.cpp+++ b/src/common/snippets/src/generator.cpp@@ -5,13 +5,13 @@#include "snippets/generator.hpp"#include "snippets/itt.hpp"-#include "snippets/runtime_configurator.hpp"-#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/expression.hpp"+#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/reg_manager.hpp"-#include "snippets/utils/reg_utils.hpp"#include "snippets/op/kernel.hpp"#include "snippets/op/memory_access.hpp"+#include "snippets/runtime_configurator.hpp"+#include "snippets/utils/reg_utils.hpp"namespace ov {namespace snippets {@@ -34,7 +34,8 @@ LoweringResult Generator::generate(const lowered::LinearIRPtr& linear_ir, constconst auto kernel_expr = linear_ir->get_expr_factory()->build(kernel_op, std::vector<lowered::PortConnectorPtr>{});const auto kernel = target->get(kernel_expr->get_node()->get_type_info())(kernel_expr);- kernel->emit_code(utils::transform_snippets_regs_to_idxs(reg_manager.get_kernel_call_regs(kernel_op)), {},+ kernel->emit_code(utils::transform_snippets_regs_to_idxs(reg_manager.get_kernel_call_regs(kernel_op)),+ {},utils::transform_snippets_regs_to_idxs(reg_manager.get_vec_reg_pool()),utils::transform_snippets_regs_to_idxs(reg_manager.get_gp_regs_except_kernel_call(kernel_op)));@@ -73,38 +74,22 @@ RegType Generator::get_op_out_reg_type(const ov::Output<Node>& out) const {if (reg_type != RegType::undefined)return reg_type;const auto op = out.get_node_shared_ptr();- if (is_type<ov::op::v0::Parameter>(op) ||- is_type<ov::op::v0::Result>(op) ||- is_type<op::LoopBegin>(op) ||- is_type<op::LoopEnd>(op) ||- is_type<op::Brgemm>(op) ||- is_type<op::Buffer>(op) ||- is_type<op::RankNormalization>(op) ||- is_type<op::Reshape>(op) ||- is_type<op::Reorder>(op) ||+ if (is_type<ov::op::v0::Parameter>(op) || is_type<ov::op::v0::Result>(op) || is_type<op::LoopBegin>(op) ||+ is_type<op::LoopEnd>(op) || is_type<op::Brgemm>(op) || is_type<op::Buffer>(op) ||+ is_type<op::RankNormalization>(op) || is_type<op::Reshape>(op) || is_type<op::Reorder>(op) ||is_type<snippets::op::Store>(op)#ifdef SNIPPETS_DEBUG_CAPS- || is_type<op::PerfCountBeginBase>(op)- || is_type<op::PerfCountEndBase>(op)+ || is_type<op::PerfCountBeginBase>(op) || is_type<op::PerfCountEndBase>(op)#endif- )+ )return RegType::gpr;- else if (is_type<snippets::op::Load>(op) ||- is_type<snippets::op::BroadcastLoad>(op) ||- 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<ov::op::v1::LogicalNot>(op) ||- is_type<ov::op::v0::PRelu>(op) ||- is_type<ov::op::v0::Convert>(op) ||- is_type<ov::op::v1::Select>(op) ||- is_type<op::VectorBuffer>(op) ||- is_type<op::BroadcastMove>(op) ||- is_type<op::Scalar>(op) ||- is_type<op::HorizonMax>(op) ||- is_type<op::HorizonSum>(op) ||- is_type<op::Fill>(op))+ else if (is_type<snippets::op::Load>(op) || is_type<snippets::op::BroadcastLoad>(op) ||+ 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<ov::op::v1::LogicalNot>(op) || is_type<ov::op::v0::PRelu>(op) ||+ is_type<ov::op::v0::Convert>(op) || is_type<ov::op::v1::Select>(op) || is_type<op::VectorBuffer>(op) ||+ is_type<op::BroadcastMove>(op) || is_type<op::Scalar>(op) || is_type<op::HorizonMax>(op) ||+ is_type<op::HorizonSum>(op) || is_type<op::Fill>(op))return RegType::vec;elseOPENVINO_THROW("Register type of the operation " + std::string(op->get_type_name()) + " isn't determined!");@@ -112,8 +97,9 @@ RegType Generator::get_op_out_reg_type(const ov::Output<Node>& out) const {}RegType Generator::get_specific_op_out_reg_type(const ov::Output<Node>& out) const {- OPENVINO_THROW("Register type of the operation " + std::string(out.get_node()->get_type_name()) + " isn't determined!");+ OPENVINO_THROW("Register type of the operation " + std::string(out.get_node()->get_type_name()) ++ " isn't determined!");}-}// namespace snippets-}// namespace ov+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/kernel_executor_table.cpp b/src/common/snippets/src/kernel_executor_table.cppindex e4d300d05c3..be406a6f9d8 100644--- a/src/common/snippets/src/kernel_executor_table.cpp+++ b/src/common/snippets/src/kernel_executor_table.cpp@@ -27,5 +27,5 @@ KernelExecutorTable::ExecTableState KernelExecutorTable::get_state() const {return result;}-}// namespace snippets-}// namespace ov+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/expression.cpp b/src/common/snippets/src/lowered/expression.cppindex 9912eda49dd..ff0da7fa73a 100644--- a/src/common/snippets/src/lowered/expression.cpp+++ b/src/common/snippets/src/lowered/expression.cpp@@ -2,23 +2,28 @@// SPDX-License-Identifier: Apache-2.0//-#include <cassert>-#include "snippets/lowered/expression.hpp"-#include "snippets/itt.hpp"-#include "snippets/utils/utils.hpp"+#include <cassert>#include "openvino/core/graph_util.hpp"#include "openvino/core/type.hpp"+#include "snippets/itt.hpp"+#include "snippets/utils/utils.hpp"namespace ov {namespace snippets {namespace 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) {+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());m_output_port_descriptors.reserve(n->get_output_size());for (const auto& input : n->inputs()) {@@ -30,27 +35,31 @@ Expression::Expression(const std::shared_ptr<Node>& n, const std::shared_ptr<ISh}const PortConnectorPtr& Expression::get_input_port_connector(size_t i) const {- assert(i < m_input_port_connectors.size() && "Failed to get input port connector: target input port must be less than input count!");+ assert(i < m_input_port_connectors.size() &&+ "Failed to get input port connector: target input port must be less than input count!");return m_input_port_connectors[i];}const PortConnectorPtr& Expression::get_output_port_connector(size_t i) const {- assert(i < m_output_port_connectors.size() && "Failed to get output port connector: target output port must be less than output count!");+ assert(i < m_output_port_connectors.size() &&+ "Failed to get output port connector: target output port must be less than output count!");return m_output_port_connectors[i];}const PortDescriptorPtr& Expression::get_input_port_descriptor(size_t i) const {- assert(i < m_input_port_descriptors.size() && "Failed to get input port descriptor: target input port must be less than input count!");+ assert(i < m_input_port_descriptors.size() &&+ "Failed to get input port descriptor: target input port must be less than input count!");return m_input_port_descriptors[i];}const PortDescriptorPtr& Expression::get_output_port_descriptor(size_t i) const {- assert(i < m_output_port_descriptors.size() && "Failed to get output port descriptor: target output port must be less than output count!");+ assert(i < m_output_port_descriptors.size() &&+ "Failed to get output port descriptor: target output port must be less than output count!");return m_output_port_descriptors[i];}std::shared_ptr<Node> Expression::get_node() const {if (!m_source_node)OPENVINO_THROW("An attempt to get uninitialized node from lowered expression");- return m_source_node;+ return m_source_node;}std::shared_ptr<Emitter> Expression::get_emitter() const {@@ -82,8 +91,7 @@ void Expression::set_reg_info(const RegInfo& rinfo) {}void Expression::validate() const {- OPENVINO_ASSERT(m_source_node != nullptr,- "The expression has null source node");+ OPENVINO_ASSERT(m_source_node != nullptr, "The expression has null source node");OPENVINO_ASSERT(m_input_port_descriptors.size() == m_input_port_connectors.size(),"The count of input ports and input port connectors must be equal");OPENVINO_ASSERT(m_output_port_descriptors.size() == m_output_port_connectors.size(),@@ -91,7 +99,8 @@ void Expression::validate() const {}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!");+ 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)return;@@ -132,7 +141,8 @@ ExpressionPtr Expression::clone_with_new_inputs(const std::shared_ptr<Node>& new// Initialize Port Attributes: PortConnectors and PortDescriptorsOPENVINO_ASSERT(new_in_descs.empty() || new_inputs.size() == new_in_descs.size(),"Can't create Expression with new inputs: invalid number of input port connectors passed");- cloned->m_input_port_descriptors = !new_in_descs.empty() ? new_in_descs : clone_ports_descriptors(m_input_port_descriptors);+ cloned->m_input_port_descriptors =+ !new_in_descs.empty() ? new_in_descs : clone_ports_descriptors(m_input_port_descriptors);cloned->m_input_port_connectors = new_inputs;for (size_t i = 0; i < cloned->m_input_port_connectors.size(); i++) {const auto& i_con = cloned->m_input_port_connectors[i];@@ -171,7 +181,7 @@ ExpressionPtr Expression::clone() const {return std::shared_ptr<Expression>(new Expression(*this));}-bool Expression::visit_attributes(AttributeVisitor &visitor) {+bool Expression::visit_attributes(AttributeVisitor& visitor) {std::ostringstream in_regs, out_regs;std::vector<std::pair<std::string, ov::PartialShape>> shapes;std::vector<std::pair<std::string, std::string>> subtensors;@@ -210,11 +220,11 @@ bool Expression::visit_attributes(AttributeVisitor &visitor) {}if (!in_regs.str().empty()) {- std::vector<std::string> tmp {in_regs.str()};+ std::vector<std::string> tmp{in_regs.str()};visitor.on_attribute("in_regs", tmp);}if (!out_regs.str().empty()) {- std::vector<std::string> tmp {out_regs.str()};+ std::vector<std::string> tmp{out_regs.str()};visitor.on_attribute("out_regs", tmp);}for (auto& s : shapes)@@ -269,17 +279,17 @@ void Expression::updateShapes() {}result = m_shapeInference->infer(input_shapes);- }- catch (const std::exception& exp) {+ } catch (const std::exception& exp) {OPENVINO_THROW("Shape inference of " + (m_source_node->get_friendly_name()) + " failed: " + exp.what());}OPENVINO_ASSERT(result.status == ShapeInferStatus::success,"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");+ 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++)m_output_port_descriptors[i]->set_shape(result.dims[i]);}-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/expression_factory.cpp b/src/common/snippets/src/lowered/expression_factory.cppindex 139abfd3cb1..db1fb715a53 100644--- a/src/common/snippets/src/lowered/expression_factory.cpp+++ b/src/common/snippets/src/lowered/expression_factory.cpp@@ -10,8 +10,9 @@ namespace ov {namespace snippets {namespace lowered {-template<>-std::shared_ptr<Expression> ExpressionFactory::build(const std::shared_ptr<Node>& n, const std::vector<PortConnectorPtr>& inputs) {+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)) {@@ -53,10 +54,9 @@ void ExpressionFactory::init_expression_inputs(const ExpressionPtr& expr, constfor (size_t i = 0; i < inputs.size(); ++i) {const auto& input = inputs[i];const auto consumers = input->get_consumers();- const auto found = std::find_if(consumers.begin(), consumers.end(),- [&](const ExpressionPort& desc) {- return desc.get_index() == i && desc.get_expr() == expr;- });+ const auto found = std::find_if(consumers.begin(), consumers.end(), [&](const ExpressionPort& desc) {+ return desc.get_index() == i && desc.get_expr() == expr;+ });if (found == consumers.end()) {input->add_consumer(expr->get_input_port(i));}@@ -64,29 +64,34 @@ void ExpressionFactory::init_expression_inputs(const ExpressionPtr& expr, constexpr->m_input_port_connectors = inputs;}-ExpressionPtr ExpressionFactory::create(const std::shared_ptr<ov::op::v0::Parameter>& par, const std::vector<PortConnectorPtr>& inputs,+ExpressionPtr ExpressionFactory::create(const std::shared_ptr<ov::op::v0::Parameter>& par,+ const std::vector<PortConnectorPtr>& inputs,const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory) {OPENVINO_ASSERT(inputs.empty(), "Parameter cannot have inputs");- // Note: ctor of shared_ptr isn't friend class for Expression -> we cannot use directly make_shared<Expression>(args)+ // Note: ctor of shared_ptr isn't friend class for Expression -> we cannot use directly+ // make_shared<Expression>(args)auto expr = std::shared_ptr<Expression>(new Expression(par, shape_infer_factory, false));create_expression_outputs(expr);expr->validate();return expr;}-ExpressionPtr ExpressionFactory::create(const std::shared_ptr<ov::op::v0::Result>& res, const std::vector<PortConnectorPtr>& inputs,+ExpressionPtr ExpressionFactory::create(const std::shared_ptr<ov::op::v0::Result>& res,+ const std::vector<PortConnectorPtr>& inputs,const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory) {- // Note: ctor of shared_ptr isn't friend class for Expression -> we cannot use directly make_shared<Expression>(args)+ // Note: ctor of shared_ptr isn't friend class for Expression -> we cannot use directly+ // make_shared<Expression>(args)auto expr = std::shared_ptr<Expression>(new Expression(res, shape_infer_factory));init_expression_inputs(expr, inputs);- // The Result node don't need output port (because of sense of the node). But each node in openvino must have one output at least.- // The port descriptors are automatically created in constructor. We manually clean output ports.+ // The Result node don't need output port (because of sense of the node). But each node in openvino must have one+ // output at least. The port descriptors are automatically created in constructor. We manually clean output ports.expr->m_output_port_descriptors.clear();expr->validate();return expr;}-ExpressionPtr ExpressionFactory::create(const std::shared_ptr<op::LoopBegin>& n, const std::vector<PortConnectorPtr>& inputs,+ExpressionPtr ExpressionFactory::create(const std::shared_ptr<op::LoopBegin>& n,+ const std::vector<PortConnectorPtr>& inputs,const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory) {OPENVINO_ASSERT(inputs.empty(), "LoopBegin cannot have inputs");auto expr = std::shared_ptr<Expression>(new Expression(n, shape_infer_factory, false));@@ -96,7 +101,8 @@ ExpressionPtr ExpressionFactory::create(const std::shared_ptr<op::LoopBegin>& n,return expr;}-ExpressionPtr ExpressionFactory::create(const std::shared_ptr<op::LoopEnd>& n, const std::vector<PortConnectorPtr>& inputs,+ExpressionPtr ExpressionFactory::create(const std::shared_ptr<op::LoopEnd>& n,+ const std::vector<PortConnectorPtr>& inputs,const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory) {auto expr = std::shared_ptr<Expression>(new Expression(n, shape_infer_factory, false));expr->m_input_port_descriptors.resize(inputs.size(), nullptr);@@ -104,17 +110,19 @@ ExpressionPtr ExpressionFactory::create(const std::shared_ptr<op::LoopEnd>& n, cexpr->m_input_port_descriptors[i] = std::make_shared<PortDescriptor>();}const auto& last_input = inputs.back()->get_source();- OPENVINO_ASSERT(ov::is_type<op::LoopBegin>(last_input.get_expr()->get_node()), "LoopEnd expression expects LoopBegin on last input");+ OPENVINO_ASSERT(ov::is_type<op::LoopBegin>(last_input.get_expr()->get_node()),+ "LoopEnd expression expects LoopBegin on last input");expr->m_input_port_descriptors[inputs.size() - 1] = last_input.get_descriptor_ptr()->clone();init_expression_inputs(expr, inputs);- // The LoopEnd node don't need output port (because of sense of the node). But each node in openvino must have one output at least.- // The port descriptors are automatically created in constructor. We manually clean output ports.+ // The LoopEnd node don't need output port (because of sense of the node). But each node in openvino must have one+ // output at least. The port descriptors are automatically created in constructor. We manually clean output ports.expr->m_output_port_descriptors.clear();expr->validate();return expr;}-ExpressionPtr ExpressionFactory::create(const std::shared_ptr<op::RegSpillBegin>& n, const std::vector<PortConnectorPtr>& inputs,+ExpressionPtr ExpressionFactory::create(const std::shared_ptr<op::RegSpillBegin>& n,+ const std::vector<PortConnectorPtr>& inputs,const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory) {auto expr = std::shared_ptr<Expression>(new Expression(n, shape_infer_factory, false));OPENVINO_ASSERT(inputs.empty(), "RegSpillBegin expression expects no inputs");@@ -131,7 +139,8 @@ ExpressionPtr ExpressionFactory::create(const std::shared_ptr<op::RegSpillBegin>return expr;}-ExpressionPtr ExpressionFactory::create(const std::shared_ptr<op::RegSpillEnd>& n, const std::vector<PortConnectorPtr>& inputs,+ExpressionPtr ExpressionFactory::create(const std::shared_ptr<op::RegSpillEnd>& n,+ const std::vector<PortConnectorPtr>& inputs,const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory) {auto expr = std::shared_ptr<Expression>(new Expression(n, shape_infer_factory, false));const auto spill_begin_node = n->get_reg_spill_begin();@@ -145,7 +154,8 @@ ExpressionPtr ExpressionFactory::create(const std::shared_ptr<op::RegSpillEnd>&}#ifdef SNIPPETS_DEBUG_CAPS-ExpressionPtr ExpressionFactory::create(const std::shared_ptr<op::PerfCountBeginBase>& n, const std::vector<PortConnectorPtr>& inputs,+ExpressionPtr ExpressionFactory::create(const std::shared_ptr<op::PerfCountBeginBase>& n,+ const std::vector<PortConnectorPtr>& inputs,const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory) {OPENVINO_ASSERT(inputs.empty(), "PerfCountBegin shape_infer_factory do not accept any input connectors");return create_without_connections(n, shape_infer_factory);@@ -158,8 +168,9 @@ ExpressionPtr ExpressionFactory::create(const std::shared_ptr<op::PerfCountEndBareturn create_without_connections(n, shape_infer_factory);}-ExpressionPtr ExpressionFactory::create_without_connections(const std::shared_ptr<ov::Node>& n,- const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory) {+ExpressionPtr ExpressionFactory::create_without_connections(+ const std::shared_ptr<ov::Node>& n,+ const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory) {auto expr = std::shared_ptr<Expression>(new Expression(n, shape_infer_factory, false));expr->m_input_port_descriptors.clear();expr->m_output_port_descriptors.clear();@@ -168,6 +179,6 @@ ExpressionPtr ExpressionFactory::create_without_connections(const std::shared_pt}#endif-}// namespace lowered-}// namespace snippets-}// namespace ov+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/expression_port.cpp b/src/common/snippets/src/lowered/expression_port.cppindex 4fbcb894051..85c08d81423 100644--- a/src/common/snippets/src/lowered/expression_port.cpp+++ b/src/common/snippets/src/lowered/expression_port.cpp@@ -2,19 +2,20 @@// SPDX-License-Identifier: Apache-2.0//-#include <cassert>-#include "snippets/lowered/expression_port.hpp"-#include "snippets/utils/utils.hpp"+#include <cassert>+#include "snippets/utils/utils.hpp"namespace ov {namespace snippets {namespace lowered {ExpressionPort::ExpressionPort(const std::shared_ptr<Expression>& expr, Type type, size_t port)- : m_expr(expr), m_type(type), m_port_index(port) {}+ : m_expr(expr),+ m_type(type),+ m_port_index(port) {}std::shared_ptr<ExpressionPort> ExpressionPort::clone_with_new_expr(const std::shared_ptr<Expression>& new_expr) const {return std::make_shared<ExpressionPort>(new_expr, m_type, m_port_index);@@ -27,22 +28,22 @@ std::shared_ptr<Expression> ExpressionPort::get_expr() const {}const PortDescriptorPtr& ExpressionPort::get_descriptor_ptr() const {- const auto& descs = m_type == Type::Input ? get_expr()->m_input_port_descriptors- : get_expr()->m_output_port_descriptors;+ const auto& descs =+ m_type == Type::Input ? get_expr()->m_input_port_descriptors : get_expr()->m_output_port_descriptors;assert(m_port_index < descs.size() && "Incorrect index of port");return descs[m_port_index];}const std::shared_ptr<PortConnector>& ExpressionPort::get_port_connector_ptr() const {- const auto& connectors = m_type == Type::Input ? get_expr()->m_input_port_connectors- : get_expr()->m_output_port_connectors;+ const auto& connectors =+ m_type == Type::Input ? get_expr()->m_input_port_connectors : get_expr()->m_output_port_connectors;assert(m_port_index < connectors.size() && "Incorrect index of port");return connectors[m_port_index];}std::set<ExpressionPort> ExpressionPort::get_connected_ports() const {if (ExpressionPort::m_type == Type::Input) {- return { get_expr()->m_input_port_connectors[m_port_index]->get_source() };+ return {get_expr()->m_input_port_connectors[m_port_index]->get_source()};}if (ExpressionPort::m_type == Type::Output) {return get_expr()->m_output_port_connectors[m_port_index]->get_consumers();@@ -66,15 +67,17 @@ bool operator!=(const ExpressionPort& lhs, const ExpressionPort& rhs) {}bool operator<(const ExpressionPort& lhs, const ExpressionPort& rhs) {OPENVINO_ASSERT(lhs.get_type() == rhs.get_type(), "Incorrect ExpressionPort comparison");- return (lhs.get_index() < rhs.get_index()) || (lhs.get_index() == rhs.get_index() && lhs.get_expr() < rhs.get_expr());+ return (lhs.get_index() < rhs.get_index()) ||+ (lhs.get_index() == rhs.get_index() && lhs.get_expr() < rhs.get_expr());}-void replace_input_port_connectors(const std::set<ExpressionPort>& consumers, const std::shared_ptr<PortConnector>& to) {+void replace_input_port_connectors(const std::set<ExpressionPort>& consumers,+ const std::shared_ptr<PortConnector>& to) {for (const auto& consumer_input : consumers) {consumer_input.replace_input_port_connector(to);}}-}// namespace lowered-}// namespace snippets-}// namespace ov+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/expressions/buffer_expression.cpp b/src/common/snippets/src/lowered/expressions/buffer_expression.cppindex 60b5dea132f..1f31fb93970 100644--- a/src/common/snippets/src/lowered/expressions/buffer_expression.cpp+++ b/src/common/snippets/src/lowered/expressions/buffer_expression.cpp@@ -2,18 +2,17 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/lowered/expressions/buffer_expression.hpp"#include "snippets/lowered/loop_manager.hpp"#include "snippets/op/buffer.hpp"-namespace ov {namespace snippets {namespace lowered {-BufferExpression::BufferExpression(const std::shared_ptr<Node>& n, const std::shared_ptr<IShapeInferSnippetsFactory>& factory)+BufferExpression::BufferExpression(const std::shared_ptr<Node>& n,+ const std::shared_ptr<IShapeInferSnippetsFactory>& factory): Expression(n, factory) {const auto& buffer = ov::as_type_ptr<op::Buffer>(get_node());OPENVINO_ASSERT(buffer, "BufferExpression expects Buffer op");@@ -24,7 +23,7 @@ ExpressionPtr BufferExpression::clone() const {return std::shared_ptr<BufferExpression>(new BufferExpression(*this));}-bool BufferExpression::visit_attributes(AttributeVisitor &visitor) {+bool BufferExpression::visit_attributes(AttributeVisitor& visitor) {Expression::visit_attributes(visitor);auto allocation_size = utils::value2str(m_allocation_size);auto offset = utils::value2str(m_offset);@@ -52,7 +51,8 @@ size_t BufferExpression::get_byte_size() const {}namespace {-std::vector<size_t> get_parent_inner_loops(const std::vector<size_t>& parent_loops, const std::vector<size_t>& current_loops) {+std::vector<size_t> get_parent_inner_loops(const std::vector<size_t>& parent_loops,+ const 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])@@ -64,8 +64,8 @@ std::vector<size_t> get_parent_inner_loops(const std::vector<size_t>& parent_loo// Ticket: 113744// TODO: This logic covers only several specific cases so it should be generalized.void BufferExpression::init_allocation_size(const std::shared_ptr<LoopManager>& loop_manager, size_t allocation_rank) {- // Note: Buffer expressions can have more than one parent after the loops splitting transformation, but only the last parent- // can be used to access valid loop ports. More info in the ticket: 146646+ // Note: Buffer expressions can have more than one parent after the loops splitting transformation, but only the+ // last parent can be used to access valid loop ports. More info in the ticket: 146646const auto buffer_in_idx = get_input_count() - 1;const auto& parent_port = get_input_port_connector(buffer_in_idx)->get_source();const auto& parent_loop_ids = get_parent_inner_loops(parent_port.get_expr()->get_loop_ids(), get_loop_ids());@@ -106,7 +106,8 @@ void BufferExpression::init_allocation_size(const std::shared_ptr<LoopManager>&// and ports are not mapped on the original ExpressionPortsif (it == output_ports.end()) {it = std::find_if(output_ports.begin(), output_ports.end(), soft_equal);- OPENVINO_ASSERT(it != output_ports.end(), "compute_allocation_shape: output port of parent loop can not be found");+ OPENVINO_ASSERT(it != output_ports.end(),+ "compute_allocation_shape: output port of parent loop can not be found");}const auto& loop_port = *it;if (!loop_port.is_processed())@@ -116,13 +117,16 @@ void BufferExpression::init_allocation_size(const std::shared_ptr<LoopManager>&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))- m_allocation_size = utils::dynamic_safe_mul(m_allocation_size, expanded_loop_info->get_unified_loop_info()->get_work_amount());+ m_allocation_size =+ utils::dynamic_safe_mul(m_allocation_size,+ expanded_loop_info->get_unified_loop_info()->get_work_amount());elseOPENVINO_THROW("Unknown LoopInfo type");processed_dim_idxs.insert(dim_idx);}}- const auto processing_rank = !processed_dim_idxs.empty() ? std::max(*processed_dim_idxs.rbegin(), subtensor.size()) : subtensor.size();+ const auto processing_rank =+ !processed_dim_idxs.empty() ? std::max(*processed_dim_idxs.rbegin(), subtensor.size()) : subtensor.size();for (size_t i = 0; i < std::min(processing_rank, rank); ++i) {if (processed_dim_idxs.count(i) == 0) {const auto multiplier = i < subtensor.size() ? *(subtensor.rbegin() + i) : *(planar_shape.rbegin() + i);@@ -138,6 +142,6 @@ void BufferExpression::init_allocation_size(const std::shared_ptr<LoopManager>&}}-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/linear_ir.cpp b/src/common/snippets/src/lowered/linear_ir.cppindex 72fc462c2b4..e3a3534e847 100644--- a/src/common/snippets/src/lowered/linear_ir.cpp+++ b/src/common/snippets/src/lowered/linear_ir.cpp@@ -4,15 +4,13 @@#include "snippets/lowered/linear_ir.hpp"-#include "snippets/itt.hpp"--#include "snippets/lowered/loop_manager.hpp"-#include "snippets/lowered/expression_factory.hpp"-#include "openvino/core/graph_util.hpp"#include "openvino/core/type.hpp"-#include "snippets/utils/utils.hpp"+#include "snippets/itt.hpp"+#include "snippets/lowered/expression_factory.hpp"+#include "snippets/lowered/loop_manager.hpp"#include "snippets/op/subgraph.hpp"+#include "snippets/utils/utils.hpp"namespace ov {namespace snippets {@@ -37,9 +35,9 @@ LinearIR::LinearIR(const std::shared_ptr<ov::Model>& model,constExprIt 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 passes.- // After these passes we must call pass MoveScalarToConsumer() to have a correct accuracy.- // For more details, please see the pass description+ // Scalar should be on the Linear IR beginning after Parameters to have valid expression order after Loop+ // passes. After these passes we must call pass MoveScalarToConsumer() to have a correct accuracy. For more+ // details, please see the pass descriptionif (const auto& scalar = as_type_ptr<op::Scalar>(n)) {insertion_pos = std::next(last_param);}@@ -85,13 +83,16 @@ void update_consumers_and_regs(const ExpressionPtr& new_expr, const std::vector<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(new_expr->get_input_port_connector(i)->get_source().get_descriptor_ptr()->get_reg());+ new_expr->get_input_port_descriptor(i)->set_reg(+ new_expr->get_input_port_connector(i)->get_source().get_descriptor_ptr()->get_reg());}}-} // namespace+} // namespace-ExpressionPtr LinearIR::create_expression(const std::shared_ptr<Node>& n, const std::vector<PortConnectorPtr>& new_inputs,- const std::vector<size_t>& loop_ids, bool update_loop_ports,+ExpressionPtr LinearIR::create_expression(const std::shared_ptr<Node>& n,+ const std::vector<PortConnectorPtr>& new_inputs,+ const std::vector<size_t>& loop_ids,+ bool update_loop_ports,const std::vector<std::set<ExpressionPort>>& consumers) {const auto new_expr = get_expr_factory()->build(n, new_inputs);update_consumers_and_regs(new_expr, consumers);@@ -108,7 +109,8 @@ ov::NodeVector LinearIR::get_ordered_ops(const std::shared_ptr<ov::Model>& m) {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 get_results()+ // are added in REVERSE order, so they will be visited in DIRECT order compared to get_parameters() and+ // get_results()NodeVector nodes;const auto& results = m->get_results();std::copy(results.rbegin(), results.rend(), std::back_inserter(nodes));@@ -137,8 +139,7 @@ void LinearIR::debug_print(bool tds_as_pointers) const {int counter = 0;for (const auto& expr : m_expressions) {const auto& node = expr->get_node();- std::cerr << counter++ << " : " <<- node->get_friendly_name() << " : ";+ 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)@@ -177,7 +178,8 @@ void LinearIR::init_emitters(const std::shared_ptr<TargetMachine>& target) {const ExpressionPtr& LinearIR::get_expr_by_node(const std::shared_ptr<Node>& n) const {auto found = m_node2expression_map.find(n);- OPENVINO_ASSERT(found != m_node2expression_map.end(), "The node " + n->get_friendly_name() + " hasn't been found in Linear IR");+ OPENVINO_ASSERT(found != m_node2expression_map.end(),+ "The node " + n->get_friendly_name() + " hasn't been found in Linear IR");return found->second;}@@ -209,7 +211,8 @@ void LinearIR::unregister_expression(const ExpressionPtr& expr) {"unregister_expression mustn't be called for parameter or result expressions");if (const auto buffer_expr = ov::as_type_ptr<BufferExpression>(expr)) {const auto& it = std::find(m_buffer_expressions.cbegin(), m_buffer_expressions.cend(), buffer_expr);- OPENVINO_ASSERT(it != m_buffer_expressions.cend(), "BufferExpression has not been found in the list of LinearIR Buffers!");+ OPENVINO_ASSERT(it != m_buffer_expressions.cend(),+ "BufferExpression has not been found in the list of LinearIR Buffers!");m_buffer_expressions.erase(it);}}@@ -233,7 +236,7 @@ LinearIR::exprIt LinearIR::insert(constExprIt pos, exprIt begin, exprIt end) {LinearIR::exprIt LinearIR::insert(constExprIt pos, constExprIt begin, constExprIt end) {// nothing to insertif (begin == end)- return m_expressions.erase(pos, pos); // to convert constExprIt to exprIt+ return m_expressions.erase(pos, pos); // to convert constExprIt to exprItconst auto count = std::distance(begin, end);auto ret = m_expressions.end();for (auto b = begin; b != end; b++) {@@ -246,7 +249,7 @@ LinearIR::exprIt LinearIR::insert(constExprIt pos, constExprIt begin, constExprILinearIR::exprIt LinearIR::insert(LinearIR::constExprIt pos, const NodeVector& nodes) {// nothing to insertif (nodes.empty())- return m_expressions.erase(pos, pos); // to convert constExprIt to exprIt+ return m_expressions.erase(pos, pos); // to convert constExprIt to exprItauto ret = m_expressions.end();for (const auto& n : nodes)ret = insert(pos, n);@@ -271,7 +274,8 @@ LinearIR::exprIt LinearIR::erase(LinearIR::constExprIt pos) {}void LinearIR::move(LinearIR::constExprIt from, LinearIR::constExprIt to) {- if (from == std::prev(to)) return;+ 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);@@ -280,19 +284,19 @@ void LinearIR::move(LinearIR::constExprIt from, LinearIR::constExprIt to) {LinearIR::constExprIt LinearIR::find(const ExpressionPtr& target) const {return find(cbegin(), cend(), target);}-template<>+template <>LinearIR::constExprIt LinearIR::find_before(LinearIR::constExprIt it, const ExpressionPtr& target) const {return find(cbegin(), it, target);}-template<>+template <>LinearIR::constExprReverseIt LinearIR::find_before(LinearIR::constExprReverseIt it, const ExpressionPtr& target) const {return find(crbegin(), it, target);}-template<>+template <>LinearIR::constExprIt LinearIR::find_after(LinearIR::constExprIt it, const ExpressionPtr& target) const {return find(it, cend(), target);}-template<>+template <>LinearIR::constExprReverseIt LinearIR::find_after(LinearIR::constExprReverseIt it, const ExpressionPtr& target) const {return find(it, crend(), target);}@@ -310,7 +314,8 @@ VectorDims LinearIR::get_master_shape() const {if (m_result_expressions.size() == 1) {const auto& out_expr = *m_result_expressions.begin();const auto& source = out_expr->get_input_port_connector(0)->get_source();- if (!m_config.m_enable_domain_optimization && ov::is_type<snippets::op::Brgemm>(source.get_expr()->get_node())) {+ if (!m_config.m_enable_domain_optimization &&+ ov::is_type<snippets::op::Brgemm>(source.get_expr()->get_node())) {master_shape = utils::get_preordered_vdims(source);} else {const auto& shape_infer_seq = utils::get_first_parent_shape_infer_expr_seq(out_expr);@@ -327,18 +332,24 @@ VectorDims LinearIR::get_master_shape() const {return master_shape;}-template<>-LinearIR::exprIt LinearIR::insert_node(const std::shared_ptr<ov::Node>& new_node, const std::vector<PortConnectorPtr>& new_inputs,- const std::vector<size_t>& loop_ids, bool update_loop_ports, const constExprIt& place,+template <>+LinearIR::exprIt LinearIR::insert_node(const std::shared_ptr<ov::Node>& new_node,+ const std::vector<PortConnectorPtr>& new_inputs,+ 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 expr_it = insert(place, new_expr);get_loop_manager()->sort_loop_ports(loop_ids);return expr_it;}-template<>-LinearIR::exprIt LinearIR::insert_node(const std::shared_ptr<ov::Node>& new_node, const std::vector<ExpressionPort>& args,- const std::vector<size_t>& loop_ids, bool update_loop_ports, const constExprIt& place,+template <>+LinearIR::exprIt LinearIR::insert_node(const std::shared_ptr<ov::Node>& new_node,+ const std::vector<ExpressionPort>& args,+ const std::vector<size_t>& loop_ids,+ bool update_loop_ports,+ const constExprIt& place,const std::vector<std::set<ExpressionPort>>& consumers) {std::vector<PortConnectorPtr> new_inputs(args.size());for (size_t i = 0; i < args.size(); ++i) {@@ -348,8 +359,11 @@ LinearIR::exprIt LinearIR::insert_node(const std::shared_ptr<ov::Node>& new_nodereturn insert_node(new_node, new_inputs, loop_ids, update_loop_ports, place, consumers);}-LinearIR::exprIt LinearIR::insert_expr(const ExpressionPtr& new_expr, const std::vector<size_t>& loop_ids,- bool update_loop_ports, const constExprIt& place, const std::vector<std::set<ExpressionPort>>& consumers) {+LinearIR::exprIt LinearIR::insert_expr(const ExpressionPtr& new_expr,+ const std::vector<size_t>& loop_ids,+ bool update_loop_ports,+ const constExprIt& place,+ const std::vector<std::set<ExpressionPort>>& consumers) {update_consumers_and_regs(new_expr, consumers);new_expr->set_loop_ids(loop_ids);@@ -360,11 +374,14 @@ LinearIR::exprIt LinearIR::insert_expr(const ExpressionPtr& new_expr, const std:return expr_it;}-LinearIR::exprIt LinearIR::replace_with_node(const std::vector<ExpressionPtr>& old_exprs, const std::shared_ptr<ov::Node>& new_node,- const std::vector<size_t>& loop_ids, const constExprIt& place) {+LinearIR::exprIt LinearIR::replace_with_node(const std::vector<ExpressionPtr>& old_exprs,+ const std::shared_ptr<ov::Node>& new_node,+ const std::vector<size_t>& loop_ids,+ const constExprIt& place) {OPENVINO_ASSERT(!old_exprs.empty(), "Failed to replace node: there are no old expressions for replacing");- OPENVINO_ASSERT(new_node->get_output_size() == old_exprs.back()->get_output_count(),- "Failed to replace node: node output port count is not equal to output count of last old expression");+ OPENVINO_ASSERT(+ new_node->get_output_size() == old_exprs.back()->get_output_count(),+ "Failed to replace node: node output port count is not equal to output count of last old expression");std::vector<PortConnectorPtr> new_inputs(new_node->get_input_size());for (size_t i = 0; i < new_node->get_input_size(); ++i) {@@ -374,25 +391,35 @@ LinearIR::exprIt LinearIR::replace_with_node(const std::vector<ExpressionPtr>& oconst 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());+ 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);}-LinearIR::exprIt LinearIR::replace_with_node(const std::vector<ExpressionPtr>& old_exprs, const std::shared_ptr<ov::Node>& new_node) {+LinearIR::exprIt LinearIR::replace_with_node(const std::vector<ExpressionPtr>& old_exprs,+ const std::shared_ptr<ov::Node>& new_node) {OPENVINO_ASSERT(!old_exprs.empty(), "Failed to replace node: there are no old expressions for replacing");const auto loop_ids = old_exprs.front()->get_loop_ids();- OPENVINO_ASSERT(std::all_of(old_exprs.cbegin(), old_exprs.cend(), [&loop_ids](const ExpressionPtr& expr) { return expr->get_loop_ids() == loop_ids; }),+ OPENVINO_ASSERT(std::all_of(old_exprs.cbegin(),+ old_exprs.cend(),+ [&loop_ids](const ExpressionPtr& expr) {+ return expr->get_loop_ids() == loop_ids;+ }),"Failed to replace node: cannot replace node to nodes with inconsistent loop ids");const auto insertion_place = std::next(find(old_exprs.back()));return replace_with_node(old_exprs, new_node, loop_ids, insertion_place);}-LinearIR::exprIt LinearIR::replace_with_expr(const std::vector<ExpressionPtr>& old_exprs, const ExpressionPtr& new_expr, const constExprIt& place) {+LinearIR::exprIt LinearIR::replace_with_expr(const std::vector<ExpressionPtr>& old_exprs,+ const ExpressionPtr& new_expr,+ const constExprIt& place) {OPENVINO_ASSERT(!old_exprs.empty(), "Failed to replace node: there are no old expressions for replacing");OPENVINO_ASSERT(new_expr->get_output_count() == old_exprs.back()->get_output_count(),- "Failed to replace expressions: new expr output port count is not equal to output count of last old expression");+ "Failed to replace expressions: new expr output port count is not equal to output count of last "+ "old expression");const auto& new_inputs = new_expr->get_input_port_connectors();@@ -400,7 +427,9 @@ LinearIR::exprIt LinearIR::replace_with_expr(const std::vector<ExpressionPtr>& oreturn std::find(old_exprs.cbegin(), old_exprs.cend(), expr) != old_exprs.cend();};auto is_input_source = [&new_inputs](const ExpressionPort& source) {- return std::any_of(new_inputs.cbegin(), new_inputs.cend(), [&source](const PortConnectorPtr& input) { return input->get_source() == source; });+ return std::any_of(new_inputs.cbegin(), new_inputs.cend(), [&source](const PortConnectorPtr& input) {+ return input->get_source() == source;+ });};// Validate removable expressions - they must be a `sequence`@@ -416,8 +445,9 @@ LinearIR::exprIt LinearIR::replace_with_expr(const std::vector<ExpressionPtr>& oconst auto old_expr_consumers = port_connector->get_consumers();if (old_expr != last_old_expr) {for (const auto& consumer : old_expr_consumers) {- OPENVINO_ASSERT(is_old_expr(consumer.get_expr()),- "Failed to replace nodes: not all input ports of existing expressions will be connected!");+ OPENVINO_ASSERT(+ is_old_expr(consumer.get_expr()),+ "Failed to replace nodes: not all input ports of existing expressions will be connected!");}} else {consumers[port_connector->get_source().get_index()] = old_expr_consumers;@@ -461,10 +491,15 @@ LinearIR::exprIt LinearIR::replace_with_expr(const std::vector<ExpressionPtr>& oreturn new_expr_it;}-LinearIR::exprIt LinearIR::replace_with_expr(const std::vector<ExpressionPtr>& old_exprs, const ExpressionPtr& new_expr) {+LinearIR::exprIt LinearIR::replace_with_expr(const std::vector<ExpressionPtr>& old_exprs,+ const ExpressionPtr& new_expr) {OPENVINO_ASSERT(!old_exprs.empty(), "Failed to replace node: there are no old expressions for replacing");const auto loop_ids = new_expr->get_loop_ids();- OPENVINO_ASSERT(std::all_of(old_exprs.cbegin(), old_exprs.cend(), [&loop_ids](const ExpressionPtr& expr) { return expr->get_loop_ids() == loop_ids; }),+ OPENVINO_ASSERT(std::all_of(old_exprs.cbegin(),+ old_exprs.cend(),+ [&loop_ids](const ExpressionPtr& expr) {+ return expr->get_loop_ids() == loop_ids;+ }),"Failed to replace node: cannot replace node to nodes with inconsistent loop ids");const auto insertion_place = std::next(find(old_exprs.back()));return replace_with_expr(old_exprs, new_expr, insertion_place);@@ -476,9 +511,11 @@ void LinearIR::enumerate_expressions() const {// - |----------|-----0-----|----------| +// Start End/*------------------------------------------*/- const double region = std::numeric_limits<double>::max() / 3; // 3 roughly equivalent working zones: before, inside, after- const double step = region / static_cast<double>(m_expressions.size()); // distribute exprs evenly over the working zone- double num = -1 * (region / 2); // main working zone is inside: [Start, End] = [-region/2, region/2]+ const double region =+ std::numeric_limits<double>::max() / 3; // 3 roughly equivalent working zones: before, inside, after+ const double step =+ region / static_cast<double>(m_expressions.size()); // distribute exprs evenly over the working zone+ double num = -1 * (region / 2); // main working zone is inside: [Start, End] = [-region/2, region/2]for (const auto& expr : m_expressions) {expr->m_exec_num = num;num += step;@@ -486,26 +523,27 @@ void LinearIR::enumerate_expressions() const {}double LinearIR::get_inserted_expr_exec_num(constExprIt insertion_pos) const {- if (empty()) return 0;+ 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 == cbegin()) { // On the list beginif (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+ } else if (right_pos == cend()) { // On the list endif (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+ } else { // In the list middleleft_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()) {+ 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();@@ -518,13 +556,16 @@ double LinearIR::get_inserted_expr_exec_num(constExprIt insertion_pos) const {LinearIR::LIRShapeInfer::LIRShapeInfer(const container& body_exprs,const std::vector<ExpressionPtr>& param_exprs,const std::vector<ExpressionPtr>& result_exprs)- : ShapeInferSnippetsNode(), m_exprs(body_exprs), m_input_exprs(param_exprs), m_output_exprs(result_exprs) {+ : ShapeInferSnippetsNode(),+ m_exprs(body_exprs),+ m_input_exprs(param_exprs),+ m_output_exprs(result_exprs) {// Note that if all output shapes are static, as in the case when the first shape infer was performed on nGraph,// we can treat them as the last resultstd::vector<VectorDims> outputDims;outputDims.reserve(m_output_exprs.size());for (const auto& expr : m_output_exprs) {- const auto &shape = expr->get_input_port_descriptor(0)->get_shape();+ const auto& shape = expr->get_input_port_descriptor(0)->get_shape();if (utils::is_dynamic_vdims(shape)) {outputDims.clear();break;@@ -535,7 +576,8 @@ LinearIR::LIRShapeInfer::LIRShapeInfer(const container& body_exprs,}IShapeInferSnippets::Result LinearIR::LIRShapeInfer::infer(const std::vector<VectorDimsRef>& input_shapes) {- OPENVINO_ASSERT(m_input_exprs.size() == input_shapes.size(), "Got invalid number of input shapes in LIR ShapeInfer");+ OPENVINO_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)expr->get_output_port_descriptor(0)->set_shape(input_shapes[input_count++]);@@ -554,6 +596,6 @@ IShapeInferSnippets::Result LinearIR::LIRShapeInfer::infer(const std::vector<Vecreturn m_last_result;}-}// namespace lowered-}// namespace snippets-}// namespace ov+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/linear_ir_builder.cpp b/src/common/snippets/src/lowered/linear_ir_builder.cppindex b4798ef1049..346a064c7a3 100644--- a/src/common/snippets/src/lowered/linear_ir_builder.cpp+++ b/src/common/snippets/src/lowered/linear_ir_builder.cpp@@ -65,7 +65,7 @@ std::vector<std::shared_ptr<ov::Node>> clone_nodes(const std::vector<std::shared}} // namespace-void LinearIRBuilder::clone(const LinearIR* src, LinearIR* dst, ExpressionMap& expression_map) const {+void LinearIRBuilder::clone(const LinearIR* src, LinearIR* dst, ExpressionMap& expression_map) const {OPENVINO_ASSERT(src && dst, "Invalid pointers were provided for LinearIRBuilder::clone");dst->m_config = src->m_config;@@ -77,12 +77,14 @@ void LinearIRBuilder::clone(const LinearIR* src, LinearIR* dst, ExpressionMap&dst->m_loop_manager = src->m_loop_manager->clone_with_new_expr(expression_map);// It's Ok to share shapeInfer factory ptr, since the factory doesn't depend on LIR in any waydst->m_shape_infer_factory = src->m_shape_infer_factory;- dst->m_shape_infer = std::make_shared<LinearIR::LIRShapeInfer>(dst->m_expressions, dst->m_parameter_expressions,+ dst->m_shape_infer = std::make_shared<LinearIR::LIRShapeInfer>(dst->m_expressions,+ dst->m_parameter_expressions,dst->m_result_expressions);dst->m_is_dynamic = src->m_is_dynamic;}-LinearIR::container LinearIRBuilder::clone_range(LinearIR::container::const_iterator begin, LinearIR::container::const_iterator end,+LinearIR::container LinearIRBuilder::clone_range(LinearIR::container::const_iterator begin,+ LinearIR::container::const_iterator end,ExpressionMap& expression_map) const {OPENVINO_ASSERT(expression_map.empty(), " LinearIRBuilder::clone_range expects empty expression_map as an input");LinearIR::container result;@@ -102,27 +104,29 @@ LinearIR::container LinearIRBuilder::clone_range(LinearIR::container::const_iterexpression_map[expr.get()] = new_expr;}- for (auto result_it = result.cbegin(), original_it = begin; result_it != result.cend(); ++result_it, ++original_it) {+ for (auto result_it = result.cbegin(), original_it = begin; result_it != result.cend();+ ++result_it, ++original_it) {const auto& result_expr = *result_it;const auto& original_expr = *original_it;// Checking that the cloning was successful: the cloned part of LinearIR is identical to the original oneOPENVINO_ASSERT(result_expr->get_node()->get_type_info() == original_expr->get_node()->get_type_info() &&- result_expr->get_input_count() == original_expr->get_input_count() &&- result_expr->get_output_count() == original_expr->get_output_count(),+ result_expr->get_input_count() == original_expr->get_input_count() &&+ result_expr->get_output_count() == original_expr->get_output_count(),"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)- result_expr->get_input_port_descriptor(i)->m_tensor_shape = original_expr->get_input_port_descriptor(i)->m_tensor_shape;+ 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)- result_expr->get_output_port_descriptor(i)->m_tensor_shape = original_expr->get_output_port_descriptor(i)->m_tensor_shape;+ 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 lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/loop_info.cpp b/src/common/snippets/src/lowered/loop_info.cppindex 765eda5796e..cd881ff2154 100644--- a/src/common/snippets/src/lowered/loop_info.cpp+++ b/src/common/snippets/src/lowered/loop_info.cpp@@ -6,16 +6,25 @@#include "snippets/utils/utils.hpp"-namespace ov {namespace snippets {namespace lowered {-LoopInfo::LoopInfo(size_t work_amount, size_t increment, const std::vector<LoopPort>& entries, const std::vector<LoopPort>& exits)- : m_work_amount(work_amount), m_increment(increment), m_input_ports(entries), m_output_ports(exits) {}--LoopInfo::LoopInfo(size_t work_amount, size_t increment, const std::vector<ExpressionPort>& entries, const std::vector<ExpressionPort>& exits)- : m_work_amount(work_amount), m_increment(increment) {+LoopInfo::LoopInfo(size_t work_amount,+ size_t increment,+ const std::vector<LoopPort>& entries,+ const std::vector<LoopPort>& exits)+ : m_work_amount(work_amount),+ m_increment(increment),+ m_input_ports(entries),+ m_output_ports(exits) {}++LoopInfo::LoopInfo(size_t work_amount,+ size_t increment,+ const std::vector<ExpressionPort>& entries,+ const std::vector<ExpressionPort>& exits)+ : m_work_amount(work_amount),+ m_increment(increment) {m_input_ports.reserve(entries.size());m_output_ports.reserve(exits.size());for (const auto& port : entries)@@ -31,7 +40,9 @@ bool LoopInfo::is_dynamic() const {size_t LoopInfo::get_dim_idx() const {OPENVINO_ASSERT(!m_input_ports.empty(), "Loop info must have at least one input port");- auto is_processed = [](const LoopPort& p) { return p.is_processed(); };+ auto is_processed = [](const LoopPort& p) {+ return p.is_processed();+ };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);@@ -40,7 +51,9 @@ size_t LoopInfo::get_dim_idx() const {}const auto dim_idx = is_processed_it->get_dim_idx();- auto equal_dim_idxes = [&](const LoopPort& p) { return !p.is_processed() || p.get_dim_idx() == dim_idx; };+ auto equal_dim_idxes = [&](const LoopPort& p) {+ return !p.is_processed() || p.get_dim_idx() == dim_idx;+ };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;@@ -68,7 +81,9 @@ size_t LoopInfo::get_increment() const {std::vector<bool> LoopInfo::get_is_incremented() const {std::vector<bool> values;values.reserve(get_input_count() + get_output_count());- iterate_through_ports([&values](const LoopPort& port) { values.push_back(port.is_incremented()); });+ iterate_through_ports([&values](const LoopPort& port) {+ values.push_back(port.is_incremented());+ });return values;}@@ -89,25 +104,30 @@ 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()) port.set_dim_idx(dim_idx); };+ auto setter = [dim_idx](LoopPort& port) {+ 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);}-template<>+template <>std::vector<LoopPort>::iterator LoopInfo::find_loop_port(const LoopPort& loop_port) {auto& ports = loop_port.get_expr_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 == loop_port; });+ const auto it = std::find_if(ports.begin(), ports.end(), [&loop_port](const LoopPort& port) {+ return port == loop_port;+ });OPENVINO_ASSERT(it != ports.end(), "Failed find_loop_port: existing loop port has not been found");return it;}-template<>+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; });+ const auto it = std::find_if(ports.begin(), ports.end(), [&expr_port](const LoopPort& port) {+ return *port.get_expr_port() == expr_port;+ });return it;}@@ -124,16 +144,20 @@ const LoopPort& LoopInfo::get_loop_port(const ExpressionPort& expr_port) {namespace {void validate_new_target_ports(const std::vector<LoopPort>& target_ports, ExpressionPort::Type target_type) {- OPENVINO_ASSERT(target_ports.empty() ||- std::all_of(target_ports.cbegin(), target_ports.cend(),- [&target_type](const LoopPort& target_port) { return target_type == target_port.get_expr_port()->get_type(); }));+ OPENVINO_ASSERT(+ target_ports.empty() ||+ std::all_of(target_ports.cbegin(), target_ports.cend(), [&target_type](const LoopPort& target_port) {+ return target_type == target_port.get_expr_port()->get_type();+ }));}void validate_new_target_ports(const std::vector<ExpressionPort>& target_ports, ExpressionPort::Type target_type) {- OPENVINO_ASSERT(target_ports.empty() ||- std::all_of(target_ports.cbegin(), target_ports.cend(),- [&target_type](const ExpressionPort& target_port) { return target_type == target_port.get_type(); }));+ OPENVINO_ASSERT(+ target_ports.empty() ||+ std::all_of(target_ports.cbegin(), target_ports.cend(), [&target_type](const ExpressionPort& target_port) {+ return target_type == target_port.get_type();+ }));}-} // namespace+} // namespacevoid LoopInfo::replace_with_new_ports(const LoopPort& actual_port, const std::vector<LoopPort>& target_ports) {const auto& actual_port_type = actual_port.get_expr_port()->get_type();@@ -145,20 +169,24 @@ void LoopInfo::replace_with_new_ports(const LoopPort& actual_port, const std::veports.insert(port_it, target_ports.cbegin(), target_ports.cend());}-void LoopInfo::replace_with_new_ports(const ExpressionPort& actual_port, const std::vector<ExpressionPort>& target_ports) {+void LoopInfo::replace_with_new_ports(const ExpressionPort& actual_port,+ const std::vector<ExpressionPort>& target_ports) {const auto& actual_port_type = actual_port.get_type();validate_new_target_ports(target_ports, actual_port_type);auto& ports = actual_port_type == ExpressionPort::Input ? m_input_ports : m_output_ports;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+ // 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 loopsif (port_it == ports.end())return;// to save other parameters except expression portstd::vector<LoopPort> target_loop_ports(target_ports.size(), *port_it);- std::transform(target_loop_ports.begin(), target_loop_ports.end(), target_ports.begin(), target_loop_ports.begin(),+ std::transform(target_loop_ports.begin(),+ target_loop_ports.end(),+ target_ports.begin(),+ target_loop_ports.begin(),[](LoopPort loop_port, const ExpressionPort& expr_port) {LoopPort copy = std::move(loop_port); // to save loop port parameterscopy.set_expr_port(std::make_shared<ExpressionPort>(expr_port));@@ -168,7 +196,8 @@ void LoopInfo::replace_with_new_ports(const ExpressionPort& actual_port, const sports.insert(port_it, target_loop_ports.cbegin(), target_loop_ports.cend());}-std::vector<LoopPort> LoopInfo::clone_loop_ports(const ExpressionMap& expr_map, const std::vector<LoopPort>& loop_ports) {+std::vector<LoopPort> LoopInfo::clone_loop_ports(const ExpressionMap& expr_map,+ const std::vector<LoopPort>& loop_ports) {std::vector<LoopPort> cloned_port_points;cloned_port_points.reserve(loop_ports.size());for (const auto& p : loop_ports) {@@ -191,43 +220,64 @@ bool UnifiedLoopInfo::LoopPortDesc::is_static() const {bool operator==(const UnifiedLoopInfo::LoopPortDesc& lhs, const UnifiedLoopInfo::LoopPortDesc& 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;+ return lhs.ptr_increment == rhs.ptr_increment && lhs.finalization_offset == rhs.finalization_offset &&+ lhs.data_size == rhs.data_size;}bool operator!=(const UnifiedLoopInfo::LoopPortDesc& lhs, const UnifiedLoopInfo::LoopPortDesc& rhs) {return !(rhs == lhs);}-UnifiedLoopInfo::UnifiedLoopInfo(size_t work_amount, size_t increment,- const std::vector<LoopPort>& entries, const std::vector<LoopPort>& exits,+UnifiedLoopInfo::UnifiedLoopInfo(size_t work_amount,+ size_t increment,+ const std::vector<LoopPort>& entries,+ const std::vector<LoopPort>& exits,const SpecificIterationHandlers& handlers)- : LoopInfo(work_amount, increment, entries, exits), m_handlers(handlers),- m_input_port_descs(std::vector<LoopPortDesc>(entries.size())), m_output_port_descs(std::vector<LoopPortDesc>(exits.size())) {+ : LoopInfo(work_amount, increment, entries, exits),+ m_handlers(handlers),+ m_input_port_descs(std::vector<LoopPortDesc>(entries.size())),+ m_output_port_descs(std::vector<LoopPortDesc>(exits.size())) {sort_ports();}-UnifiedLoopInfo::UnifiedLoopInfo(size_t work_amount, size_t increment,- const std::vector<ExpressionPort>& entries, const std::vector<ExpressionPort>& exits,+UnifiedLoopInfo::UnifiedLoopInfo(size_t work_amount,+ size_t increment,+ const std::vector<ExpressionPort>& entries,+ const std::vector<ExpressionPort>& exits,const SpecificIterationHandlers& handlers)- : LoopInfo(work_amount, increment, entries, exits), m_handlers(handlers),- m_input_port_descs(std::vector<LoopPortDesc>(entries.size())), m_output_port_descs(std::vector<LoopPortDesc>(exits.size())) {+ : LoopInfo(work_amount, increment, entries, exits),+ m_handlers(handlers),+ m_input_port_descs(std::vector<LoopPortDesc>(entries.size())),+ m_output_port_descs(std::vector<LoopPortDesc>(exits.size())) {sort_ports();}-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,+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)- : LoopInfo(work_amount, increment, entries, exits), m_handlers(handlers), m_input_port_descs(in_shifts), m_output_port_descs(out_shifts) {+ : LoopInfo(work_amount, increment, entries, exits),+ m_handlers(handlers),+ m_input_port_descs(in_shifts),+ m_output_port_descs(out_shifts) {sort_ports();}-std::shared_ptr<LoopInfo> UnifiedLoopInfo::clone_with_new_expr(const ExpressionMap& expr_map, LoopInfoMap& loop_map) const {+std::shared_ptr<LoopInfo> UnifiedLoopInfo::clone_with_new_expr(const ExpressionMap& expr_map,+ LoopInfoMap& loop_map) const {if (loop_map.count(this) == 0) {const auto& new_input_ports = clone_loop_ports(expr_map, m_input_ports);const auto& new_output_ports = clone_loop_ports(expr_map, m_output_ports);- loop_map[this] = std::make_shared<UnifiedLoopInfo>(m_work_amount, m_increment, new_input_ports, new_output_ports,- m_input_port_descs, m_output_port_descs, m_handlers);+ loop_map[this] = std::make_shared<UnifiedLoopInfo>(m_work_amount,+ m_increment,+ new_input_ports,+ new_output_ports,+ m_input_port_descs,+ m_output_port_descs,+ m_handlers);}return loop_map.at(this);}@@ -241,8 +291,14 @@ void UnifiedLoopInfo::apply(const std::function<void(const LoopInfoPtr&)>& func,bool UnifiedLoopInfo::is_dynamic() const {return LoopInfo::is_dynamic() ||- std::any_of(m_input_port_descs.cbegin(), m_input_port_descs.cend(), [](const LoopPortDesc& shift) { return shift.is_dynamic(); }) ||- std::any_of(m_output_port_descs.cbegin(), m_output_port_descs.cend(), [](const LoopPortDesc& shift) { return shift.is_dynamic(); });+ std::any_of(m_input_port_descs.cbegin(),+ m_input_port_descs.cend(),+ [](const LoopPortDesc& shift) {+ return shift.is_dynamic();+ }) ||+ std::any_of(m_output_port_descs.cbegin(), m_output_port_descs.cend(), [](const LoopPortDesc& shift) {+ return shift.is_dynamic();+ });}const SpecificIterationHandlers& UnifiedLoopInfo::get_handlers() const {@@ -252,21 +308,27 @@ const SpecificIterationHandlers& UnifiedLoopInfo::get_handlers() const {std::vector<int64_t> UnifiedLoopInfo::get_ptr_increments() const {std::vector<int64_t> values;values.reserve(get_input_count() + get_output_count());- iterate_through_descs([&values](const LoopPortDesc& shift) { values.push_back(shift.ptr_increment); });+ iterate_through_descs([&values](const LoopPortDesc& shift) {+ values.push_back(shift.ptr_increment);+ });return values;}std::vector<int64_t> UnifiedLoopInfo::get_finalization_offsets() const {std::vector<int64_t> values;values.reserve(get_input_count() + get_output_count());- iterate_through_descs([&values](const LoopPortDesc& shift) { values.push_back(shift.finalization_offset); });+ iterate_through_descs([&values](const LoopPortDesc& shift) {+ values.push_back(shift.finalization_offset);+ });return values;}std::vector<int64_t> UnifiedLoopInfo::get_data_sizes() const {std::vector<int64_t> values;values.reserve(get_input_count() + get_output_count());- iterate_through_descs([&values](const LoopPortDesc& shift) { values.push_back(shift.data_size); });+ iterate_through_descs([&values](const LoopPortDesc& shift) {+ values.push_back(shift.data_size);+ });return values;}@@ -286,7 +348,7 @@ std::vector<UnifiedLoopInfo::LoopPortInfo> UnifiedLoopInfo::get_input_ports_infoassert(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)- info[i] = { m_input_ports[i], m_input_port_descs[i] };+ info[i] = {m_input_ports[i], m_input_port_descs[i]};return info;}@@ -294,12 +356,12 @@ std::vector<UnifiedLoopInfo::LoopPortInfo> UnifiedLoopInfo::get_output_ports_infassert(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)- info[i] = { m_output_ports[i], m_output_port_descs[i] };+ info[i] = {m_output_ports[i], m_output_port_descs[i]};return info;}namespace {-template<typename T>+template <typename T>void order(const std::vector<size_t>& new_order, std::vector<T>& values) {const auto order_set = std::set<size_t>(new_order.cbegin(), new_order.cend());OPENVINO_ASSERT(new_order.size() == values.size() && order_set.size() == values.size(),@@ -315,14 +377,13 @@ void order(const std::vector<size_t>& new_order, std::vector<T>& values) {std::vector<size_t> get_port_index_order(const std::vector<LoopPort>& ports) {std::vector<size_t> new_indexes(ports.size());std::iota(new_indexes.begin(), new_indexes.end(), 0);- 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())- 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();- });+ 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())+ 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;}} // namespace@@ -347,8 +408,9 @@ UnifiedLoopInfo::LoopPortInfo UnifiedLoopInfo::get_loop_port_info(const Expressiconst auto is_input = expr_port.get_type() == ExpressionPort::Input;const auto& ports = is_input ? m_input_ports : m_output_ports;const auto& descs = is_input ? m_input_port_descs : m_output_port_descs;- const auto it = std::find_if(ports.begin(), ports.end(),- [&expr_port](const LoopPort& port) { return *port.get_expr_port() == expr_port; });+ const auto it = std::find_if(ports.begin(), ports.end(), [&expr_port](const LoopPort& port) {+ return *port.get_expr_port() == expr_port;+ });const auto index = static_cast<size_t>(std::distance(ports.cbegin(), it));OPENVINO_ASSERT(index < ports.size() && index < descs.size(), "LoopPortInfo has not been found!");return {ports[index], descs[index]};@@ -371,7 +433,8 @@ void UnifiedLoopInfo::replace_with_new_ports(const LoopPort& actual_port, constreplace_with_cloned_descs(std::distance(ports.begin(), port_it), target_ports.size(), is_input);- // Instead of call `LoopInfo::replace_with_new_ports()`, we can explicitly remove LoopPort since we already found port_it.+ // Instead of call `LoopInfo::replace_with_new_ports()`, we can explicitly remove LoopPort since we already found+ // port_it.port_it = ports.erase(port_it);ports.insert(port_it, target_ports.cbegin(), target_ports.cend());@@ -379,15 +442,16 @@ void UnifiedLoopInfo::replace_with_new_ports(const LoopPort& actual_port, constsort_ports();}-void UnifiedLoopInfo::replace_with_new_ports(const ExpressionPort& actual_port, const std::vector<ExpressionPort>& target_ports) {+void UnifiedLoopInfo::replace_with_new_ports(const ExpressionPort& actual_port,+ const std::vector<ExpressionPort>& target_ports) {const auto& actual_port_type = actual_port.get_type();validate_new_target_ports(target_ports, actual_port_type);const auto is_input = actual_port.get_type() == ExpressionPort::Input;auto& ports = is_input ? m_input_ports : m_output_ports;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+ // 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 loopsif (port_it == ports.end())return;@@ -398,28 +462,38 @@ void UnifiedLoopInfo::replace_with_new_ports(const ExpressionPort& actual_port,sort_ports();}-InnerSplittedUnifiedLoopInfo::InnerSplittedUnifiedLoopInfo(size_t increment, const std::vector<LoopPort>& entries, const std::vector<LoopPort>& exits,- const std::vector<LoopPortDesc>& in_descs, const std::vector<LoopPortDesc>& out_descs,- const SpecificIterationHandlers& handlers, LoopInfoPtr outer_splitted_loop_info)+InnerSplittedUnifiedLoopInfo::InnerSplittedUnifiedLoopInfo(size_t increment,+ const std::vector<LoopPort>& entries,+ const std::vector<LoopPort>& exits,+ const std::vector<LoopPortDesc>& in_descs,+ const std::vector<LoopPortDesc>& out_descs,+ const SpecificIterationHandlers& handlers,+ LoopInfoPtr outer_splitted_loop_info): UnifiedLoopInfo(utils::get_dynamic_value<size_t>(), increment, entries, exits, in_descs, out_descs, handlers),m_outer_splitted_loop_info(std::move(outer_splitted_loop_info)) {OPENVINO_ASSERT(m_outer_splitted_loop_info != nullptr, "Outer Splitted Loop Info is missed!");}-std::shared_ptr<LoopInfo> InnerSplittedUnifiedLoopInfo::clone_with_new_expr(const ExpressionMap& expr_map, LoopInfoMap& loop_map) const {+std::shared_ptr<LoopInfo> InnerSplittedUnifiedLoopInfo::clone_with_new_expr(const ExpressionMap& expr_map,+ LoopInfoMap& loop_map) const {if (loop_map.count(this) == 0) {auto cloned_outer_splitted_loop_info = m_outer_splitted_loop_info->clone_with_new_expr(expr_map, loop_map);const auto& new_input_ports = clone_loop_ports(expr_map, m_input_ports);const auto& new_output_ports = clone_loop_ports(expr_map, m_output_ports);- loop_map[this] = std::make_shared<InnerSplittedUnifiedLoopInfo>(m_increment, new_input_ports, new_output_ports,- m_input_port_descs, m_output_port_descs, m_handlers,+ loop_map[this] = std::make_shared<InnerSplittedUnifiedLoopInfo>(m_increment,+ new_input_ports,+ new_output_ports,+ m_input_port_descs,+ m_output_port_descs,+ m_handlers,std::move(cloned_outer_splitted_loop_info));}return loop_map.at(this);}-void InnerSplittedUnifiedLoopInfo::apply(const std::function<void(const LoopInfoPtr&)>& func, LoopInfoSet& applied_loops) {+void InnerSplittedUnifiedLoopInfo::apply(const std::function<void(const LoopInfoPtr&)>& func,+ LoopInfoSet& applied_loops) {if (applied_loops.count(this) == 0) {m_outer_splitted_loop_info->apply(func, applied_loops);func(shared_from_this());@@ -445,26 +519,45 @@ void InnerSplittedUnifiedLoopInfo::set_outer_splitted_loop_info(LoopInfoPtr outem_outer_splitted_loop_info = std::move(outer);}-ExpandedLoopInfo::ExpandedLoopInfo(size_t work_amount, size_t increment,- const std::vector<LoopPort>& entries, const std::vector<LoopPort>& exits,- std::vector<int64_t> ptr_increments, std::vector<int64_t> final_offsets, std::vector<int64_t> data_sizes,- SpecificLoopIterType type, std::shared_ptr<UnifiedLoopInfo> unified_loop_info, bool evaluate_once)+ExpandedLoopInfo::ExpandedLoopInfo(size_t work_amount,+ size_t increment,+ const std::vector<LoopPort>& entries,+ const std::vector<LoopPort>& exits,+ std::vector<int64_t> ptr_increments,+ std::vector<int64_t> final_offsets,+ std::vector<int64_t> data_sizes,+ SpecificLoopIterType type,+ std::shared_ptr<UnifiedLoopInfo> unified_loop_info,+ bool evaluate_once): LoopInfo(work_amount, increment, entries, exits),- m_ptr_increments(std::move(ptr_increments)), m_finalization_offsets(std::move(final_offsets)),- m_data_sizes(std::move(data_sizes)), m_type(type), m_unified_loop_info(std::move(unified_loop_info)), m_evaluate_once(evaluate_once) {+ m_ptr_increments(std::move(ptr_increments)),+ m_finalization_offsets(std::move(final_offsets)),+ m_data_sizes(std::move(data_sizes)),+ m_type(type),+ m_unified_loop_info(std::move(unified_loop_info)),+ m_evaluate_once(evaluate_once) {OPENVINO_ASSERT(m_unified_loop_info, "Failed to create ExpandedLoopInfo: unified loop info is nullptr!");sort_ports();}-std::shared_ptr<LoopInfo> ExpandedLoopInfo::clone_with_new_expr(const ExpressionMap& expr_map, LoopInfoMap& loop_map) const {+std::shared_ptr<LoopInfo> ExpandedLoopInfo::clone_with_new_expr(const ExpressionMap& expr_map,+ LoopInfoMap& loop_map) const {if (loop_map.count(this) == 0) {- auto cloned_unified_loop_info = ov::as_type_ptr<UnifiedLoopInfo>(m_unified_loop_info->clone_with_new_expr(expr_map, loop_map));+ auto cloned_unified_loop_info =+ ov::as_type_ptr<UnifiedLoopInfo>(m_unified_loop_info->clone_with_new_expr(expr_map, loop_map));const auto& new_input_ports = clone_loop_ports(expr_map, m_input_ports);const auto& new_output_ports = clone_loop_ports(expr_map, m_output_ports);- loop_map[this] = std::make_shared<ExpandedLoopInfo>(m_work_amount, m_increment, new_input_ports, new_output_ports,- m_ptr_increments, m_finalization_offsets, m_data_sizes, m_type,- std::move(cloned_unified_loop_info), m_evaluate_once);+ loop_map[this] = std::make_shared<ExpandedLoopInfo>(m_work_amount,+ m_increment,+ new_input_ports,+ new_output_ports,+ m_ptr_increments,+ m_finalization_offsets,+ m_data_sizes,+ m_type,+ std::move(cloned_unified_loop_info),+ m_evaluate_once);}return loop_map.at(this);}@@ -479,8 +572,14 @@ void ExpandedLoopInfo::apply(const std::function<void(const LoopInfoPtr&)>& funcbool ExpandedLoopInfo::is_dynamic() const {return LoopInfo::is_dynamic() ||- std::any_of(m_ptr_increments.cbegin(), m_ptr_increments.cend(), [](size_t v) { return utils::is_dynamic_value(v); }) ||- std::any_of(m_finalization_offsets.cbegin(), m_finalization_offsets.cend(), [](size_t v) { return utils::is_dynamic_value(v); });+ std::any_of(m_ptr_increments.cbegin(),+ m_ptr_increments.cend(),+ [](size_t v) {+ return utils::is_dynamic_value(v);+ }) ||+ std::any_of(m_finalization_offsets.cbegin(), m_finalization_offsets.cend(), [](size_t v) {+ return utils::is_dynamic_value(v);+ });}const std::shared_ptr<UnifiedLoopInfo>& ExpandedLoopInfo::get_unified_loop_info() const {@@ -494,14 +593,14 @@ SpecificLoopIterType ExpandedLoopInfo::get_type() const {const pass::PassPipeline& ExpandedLoopInfo::get_handler_passes() const {switch (m_type) {- case SpecificLoopIterType::FIRST_ITER:- return get_unified_loop_info()->get_handlers().get_passes<SpecificLoopIterType::FIRST_ITER>();- case SpecificLoopIterType::MAIN_BODY:- return get_unified_loop_info()->get_handlers().get_passes<SpecificLoopIterType::MAIN_BODY>();- case SpecificLoopIterType::LAST_ITER:- return get_unified_loop_info()->get_handlers().get_passes<SpecificLoopIterType::LAST_ITER>();- default:- OPENVINO_THROW("Unknown SpecificLoopIterType");+ case SpecificLoopIterType::FIRST_ITER:+ return get_unified_loop_info()->get_handlers().get_passes<SpecificLoopIterType::FIRST_ITER>();+ case SpecificLoopIterType::MAIN_BODY:+ return get_unified_loop_info()->get_handlers().get_passes<SpecificLoopIterType::MAIN_BODY>();+ case SpecificLoopIterType::LAST_ITER:+ return get_unified_loop_info()->get_handlers().get_passes<SpecificLoopIterType::LAST_ITER>();+ default:+ OPENVINO_THROW("Unknown SpecificLoopIterType");}}@@ -526,12 +625,14 @@ void ExpandedLoopInfo::set_evaluate_once(bool value) {}void ExpandedLoopInfo::update_ptr_increments(const std::vector<int64_t>& new_values) {- OPENVINO_ASSERT(new_values.size() == m_ptr_increments.size(), "Failed to update ptr_increments: incompatible counts");+ OPENVINO_ASSERT(new_values.size() == m_ptr_increments.size(),+ "Failed to update ptr_increments: incompatible counts");m_ptr_increments.assign(new_values.cbegin(), new_values.end());}void ExpandedLoopInfo::update_finalization_offsets(const std::vector<int64_t>& new_values) {- OPENVINO_ASSERT(new_values.size() == m_finalization_offsets.size(), "Failed to update finalization_offsets: incompatible counts");+ OPENVINO_ASSERT(new_values.size() == m_finalization_offsets.size(),+ "Failed to update finalization_offsets: incompatible counts");m_finalization_offsets.assign(new_values.cbegin(), new_values.end());}@@ -541,24 +642,29 @@ void ExpandedLoopInfo::replace_with_new_ports(const LoopPort& actual_port, constsort_ports();}-void ExpandedLoopInfo::replace_with_new_ports(const ExpressionPort& actual_port, const std::vector<ExpressionPort>& target_ports) {+void ExpandedLoopInfo::replace_with_new_ports(const ExpressionPort& actual_port,+ const std::vector<ExpressionPort>& target_ports) {OPENVINO_ASSERT(target_ports.size() == 1, "ExpandedLoopInfo supports replace one port with only one port!");LoopInfo::replace_with_new_ports(actual_port, target_ports);sort_ports();}namespace {-void order_subvector(const std::vector<size_t>& indexes, std::vector<int64_t>& original_vector, size_t count, size_t offset) {+void order_subvector(const std::vector<size_t>& indexes,+ std::vector<int64_t>& original_vector,+ size_t count,+ size_t offset) {auto subvector = std::vector<int64_t>{original_vector.cbegin() + offset, original_vector.cbegin() + offset + count};order(indexes, subvector);std::copy(subvector.begin(), subvector.end(), original_vector.begin() + offset);}-} // namespace+} // namespacevoid ExpandedLoopInfo::sort_ports() {const auto count = get_input_count() + get_output_count();- OPENVINO_ASSERT(utils::everyone_is(count, m_ptr_increments.size(), m_finalization_offsets.size(), m_data_sizes.size()),- "Incompatible data ptr shifts!");+ OPENVINO_ASSERT(+ utils::everyone_is(count, m_ptr_increments.size(), m_finalization_offsets.size(), m_data_sizes.size()),+ "Incompatible data ptr shifts!");auto reorder = [this](std::vector<LoopPort>& ports, size_t count, size_t offset) {if (!ports.empty()) {@@ -573,6 +679,6 @@ void ExpandedLoopInfo::sort_ports() {reorder(m_output_ports, get_output_count(), get_input_count());}-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/loop_manager.cpp b/src/common/snippets/src/lowered/loop_manager.cppindex b3fe1f84268..089f6c568ec 100644--- a/src/common/snippets/src/lowered/loop_manager.cpp+++ b/src/common/snippets/src/lowered/loop_manager.cpp@@ -4,16 +4,13 @@#include "snippets/lowered/loop_manager.hpp"-#include "snippets/lowered/expression.hpp"-#include "snippets/op/loop.hpp"-#include "snippets/utils/utils.hpp"-#include "openvino/core/graph_util.hpp"#include "openvino/core/type.hpp"--#include "snippets/utils/loop_utils.hpp"#include "snippets/itt.hpp"-+#include "snippets/lowered/expression.hpp"+#include "snippets/op/loop.hpp"+#include "snippets/utils/loop_utils.hpp"+#include "snippets/utils/utils.hpp"namespace ov {namespace snippets {@@ -24,7 +21,7 @@ std::shared_ptr<LoopManager> LoopManager::clone_with_new_expr(const ExpressionMa// To fully cloned all LoopInfo we have to create this map [old LoopInfo -> cloned LoopInfo],// because some LoopInfo types contains pointer to another LoopInfo// so we should recurrently make a cloning of LoopInfos'- LoopInfoMap loop_info_map; // [ old - > cloned ]+ LoopInfoMap loop_info_map; // [ old - > cloned ]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;@@ -82,14 +79,17 @@ std::vector<size_t> LoopManager::get_common_outer_loops(const std::vector<Expresreturn std::vector<size_t>(first_loop_ids.cbegin(), first_loop_ids.cbegin() + common_idx);}-std::pair<LinearIR::constExprIt, LinearIR::constExprIt> LoopManager::get_loop_bounds(const LinearIR &linear_ir, size_t loop_id) const {+std::pair<LinearIR::constExprIt, LinearIR::constExprIt> LoopManager::get_loop_bounds(const LinearIR& linear_ir,+ size_t loop_id) const {const auto loop_info = get_loop_info(loop_id);return get_loop_bounds(linear_ir, loop_id, loop_info->get_input_ports(), loop_info->get_output_ports());}-std::pair<LinearIR::constExprIt, LinearIR::constExprIt> LoopManager::get_loop_bounds(const LinearIR &linear_ir, size_t loop_id,- const std::vector<LoopPort>& entries,- const std::vector<LoopPort>& exits) {+std::pair<LinearIR::constExprIt, LinearIR::constExprIt> LoopManager::get_loop_bounds(+ const LinearIR& linear_ir,+ size_t loop_id,+ const std::vector<LoopPort>& entries,+ const std::vector<LoopPort>& exits) {OPENVINO_ASSERT(!entries.empty(), "Loop must have input ports");OPENVINO_ASSERT(!exits.empty(), "Loop must have output ports");@@ -123,7 +123,8 @@ std::pair<LinearIR::constExprIt, LinearIR::constExprIt> LoopManager::get_loop_bo}}- OPENVINO_ASSERT(loop_begin_pos != linear_ir.cend() && loop_end_pos != linear_ir.cend(), "Loop bounds haven't been found!");+ OPENVINO_ASSERT(loop_begin_pos != linear_ir.cend() && loop_end_pos != linear_ir.cend(),+ "Loop bounds haven't been found!");return std::make_pair(loop_begin_pos, loop_end_pos);}@@ -134,8 +135,8 @@ LoopPort LoopManager::get_loop_port_by_expr_port(const ExpressionPort& expr_portvoid LoopManager::get_io_loop_ports(LinearIR::constExprIt loop_begin_pos,LinearIR::constExprIt loop_end_pos,- std::vector<ExpressionPort> &entries,- std::vector<ExpressionPort> &exits) {+ std::vector<ExpressionPort>& entries,+ std::vector<ExpressionPort>& exits) {entries.clear();exits.clear();for (auto expr_it = loop_begin_pos; expr_it != loop_end_pos; ++expr_it) {@@ -164,7 +165,8 @@ void LoopManager::get_io_loop_ports(LinearIR::constExprIt loop_begin_pos,void LoopManager::mark_loop(LinearIR::constExprIt loop_begin_pos,LinearIR::constExprIt loop_end_pos,- size_t loop_depth, size_t vector_size) {+ size_t loop_depth,+ size_t vector_size) {std::vector<ExpressionPort> loop_input_ports, loop_output_ports;LoopManager::get_io_loop_ports(loop_begin_pos, loop_end_pos, loop_input_ports, loop_output_ports);@@ -202,8 +204,9 @@ void LoopManager::mark_loop(LinearIR::constExprIt loop_begin_pos,if (loop_subtensor.empty())loop_subtensor = subtensor;- OPENVINO_ASSERT(std::equal(loop_subtensor.crbegin(), loop_subtensor.crbegin() + loop_depth, subtensor.crbegin()),- "Incorrect scheduling parameters for loop");+ OPENVINO_ASSERT(+ std::equal(loop_subtensor.crbegin(), loop_subtensor.crbegin() + loop_depth, subtensor.crbegin()),+ "Incorrect scheduling parameters for loop");for (size_t dim_idx = 0; dim_idx < loop_depth; ++dim_idx) {if (!utils::is_full_dim_value(*(subtensor.rbegin() + dim_idx))) {@@ -226,15 +229,22 @@ void LoopManager::mark_loop(LinearIR::constExprIt loop_begin_pos,}}-size_t LoopManager::replace_with_new_loop(const LinearIR& linear_ir, LinearIR::constExprIt loop_begin_pos, LinearIR::constExprIt loop_end_pos,- const LoopInfoPtr& loop_info, const size_t old_id) {+size_t LoopManager::replace_with_new_loop(const LinearIR& linear_ir,+ LinearIR::constExprIt loop_begin_pos,+ LinearIR::constExprIt loop_end_pos,+ const LoopInfoPtr& loop_info,+ const size_t old_id) {const auto is_bound_explicit_loop_begin = ov::is_type<op::LoopBegin>(loop_begin_pos->get()->get_node());const auto is_bound_explicit_loop_end = ov::is_type<op::LoopEnd>(std::prev(loop_end_pos)->get()->get_node());- OPENVINO_ASSERT((is_bound_explicit_loop_begin && is_bound_explicit_loop_end) || (!is_bound_explicit_loop_begin && !is_bound_explicit_loop_end),+ OPENVINO_ASSERT((is_bound_explicit_loop_begin && is_bound_explicit_loop_end) ||+ (!is_bound_explicit_loop_begin && !is_bound_explicit_loop_end),"Incorrect LoopBounds!");const auto explicit_loop_bounds = is_bound_explicit_loop_begin && is_bound_explicit_loop_end;- OPENVINO_ASSERT(std::all_of(m_map.cbegin(), m_map.cend(),- [&loop_info](const std::pair<size_t, LoopInfoPtr>& p) { return loop_info != p.second; }),+ OPENVINO_ASSERT(std::all_of(m_map.cbegin(),+ m_map.cend(),+ [&loop_info](const std::pair<size_t, LoopInfoPtr>& p) {+ return loop_info != p.second;+ }),"Failed to replace with new Loop: this Loop already exists!");const auto old_loop_bounds = get_loop_bounds(linear_ir, old_id);@@ -254,13 +264,19 @@ size_t LoopManager::replace_with_new_loop(const LinearIR& linear_ir, LinearIR::creturn loop_id;}-void LoopManager::fuse_loops(const LinearIR& linear_ir, size_t loop_id_upper, size_t loop_id_lower, bool fuse_into_upper) {+void LoopManager::fuse_loops(const LinearIR& linear_ir,+ size_t loop_id_upper,+ size_t loop_id_lower,+ bool fuse_into_upper) {const auto loop_bounds = get_loop_bounds(linear_ir, fuse_into_upper ? loop_id_lower : loop_id_upper);fuse_loops(loop_bounds.first, loop_bounds.second, loop_id_upper, loop_id_lower, fuse_into_upper);}-void LoopManager::fuse_loops(LinearIR::constExprIt loop_begin_target, LinearIR::constExprIt loop_end_target,- size_t loop_id_upper, size_t loop_id_lower, bool fuse_into_upper) {+void LoopManager::fuse_loops(LinearIR::constExprIt loop_begin_target,+ LinearIR::constExprIt loop_end_target,+ size_t loop_id_upper,+ size_t loop_id_lower,+ bool fuse_into_upper) {const auto& loop_info_upper = get_loop_info<UnifiedLoopInfo>(loop_id_upper);const auto& loop_info_lower = get_loop_info<UnifiedLoopInfo>(loop_id_lower);@@ -277,7 +293,8 @@ void LoopManager::fuse_loops(LinearIR::constExprIt loop_begin_target, LinearIR::// maximum value is set to the fused loopconst auto work_amount = std::max(loop_info_upper->get_work_amount(), loop_info_lower->get_work_amount());const auto increment = std::max(loop_info_upper->get_increment(), loop_info_lower->get_increment());- const auto handlers = SpecificIterationHandlers::merge_handlers(loop_info_upper->get_handlers(), loop_info_lower->get_handlers());+ const auto handlers =+ SpecificIterationHandlers::merge_handlers(loop_info_upper->get_handlers(), loop_info_lower->get_handlers());auto new_entries = std::move(input_ports_upper);new_entries.insert(new_entries.end(), input_ports_lower.begin(), input_ports_lower.end());@@ -317,10 +334,10 @@ void LoopManager::fuse_loop_ports(std::vector<LoopPort>& output_ports,std::set<LoopPort> mapped_input_ports;std::set<ExpressionPtr> outside_consumers;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;- });+ 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;+ });if (input_port_it != input_ports.end()) {mapped_input_ports.insert(*input_port_it);continue;@@ -398,9 +415,13 @@ void LoopManager::sort_loop_ports(const std::vector<size_t>& loop_ids) {get_loop_info(loop_id)->sort_ports();}-void LoopManager::expression_replacement(LinearIR::constExprIt new_expr_begin, LinearIR::constExprIt new_expr_end, const ExpressionPtr& decomposed_expr,- size_t loop_id, const std::vector<ExpressionPort>& entries, const std::vector<ExpressionPort>& exits) {- for (auto it = new_expr_begin; it!= new_expr_end; ++it) {+void LoopManager::expression_replacement(LinearIR::constExprIt new_expr_begin,+ LinearIR::constExprIt new_expr_end,+ const ExpressionPtr& decomposed_expr,+ size_t loop_id,+ const std::vector<ExpressionPort>& entries,+ const std::vector<ExpressionPort>& exits) {+ for (auto it = new_expr_begin; it != new_expr_end; ++it) {insert_loop_id(*it, loop_id, true);}remove_loop_id(decomposed_expr, loop_id);@@ -421,10 +442,12 @@ void LoopManager::expression_replacement(LinearIR::constExprIt new_expr_begin, Lbool LoopManager::reorder_identifiers(const std::map<size_t, size_t>& loop_id_map) {OPENVINO_ASSERT(loop_id_map.size() == m_map.size(),- "Failed to sort reorder IDs: count of the current IDs in `loop_id_map` must be equal to count of existing loops");+ "Failed to sort reorder IDs: count of the current IDs in `loop_id_map` must be equal to count of "+ "existing loops");// If all new IDs are the same as original and they're in the `m_map` - nothing to update- if (std::all_of(loop_id_map.cbegin(), loop_id_map.cend(),- [this](const std::pair<size_t, size_t>& p) { return p.first == p.second && m_map.count(p.first) > 0; })) {+ if (std::all_of(loop_id_map.cbegin(), loop_id_map.cend(), [this](const std::pair<size_t, size_t>& p) {+ return p.first == p.second && m_map.count(p.first) > 0;+ })) {return false;}@@ -432,8 +455,13 @@ bool LoopManager::reorder_identifiers(const std::map<size_t, size_t>& loop_id_mafor (const auto& p : loop_id_map) {const auto& current_id = p.first;const auto& target_id = p.second;- OPENVINO_ASSERT(m_map.count(current_id) > 0, "Failed to reorder loop IDs: the Loop with ID ", current_id, " doesn't exist in the map");- OPENVINO_ASSERT(ordered_map.count(target_id) == 0, "Failed to reorder loop IDs: there are several Loops with the target ID ", target_id);+ OPENVINO_ASSERT(m_map.count(current_id) > 0,+ "Failed to reorder loop IDs: the Loop with ID ",+ current_id,+ " doesn't exist in the map");+ OPENVINO_ASSERT(ordered_map.count(target_id) == 0,+ "Failed to reorder loop IDs: there are several Loops with the target ID ",+ target_id);ordered_map[target_id] = get_loop_info(current_id);}m_map = std::move(ordered_map);@@ -441,7 +469,8 @@ bool LoopManager::reorder_identifiers(const std::map<size_t, size_t>& loop_id_ma}void LoopManager::insert_loop_id(const ExpressionPtr& expr, size_t new_id, bool before, size_t target_id) {- OPENVINO_ASSERT(m_map.count(new_id) == 1, "Failed marking expression by Loop ID: the Loop with this ID hasn't registered");+ OPENVINO_ASSERT(m_map.count(new_id) == 1,+ "Failed marking expression by Loop ID: the Loop with this ID hasn't registered");OPENVINO_ASSERT(!is_loop_id_found(expr, new_id), "Expression cannot have several the same Loop IDs");auto loop_ids = expr->get_loop_ids();auto insert_it = before ? loop_ids.cbegin() : loop_ids.cend();@@ -453,8 +482,15 @@ void LoopManager::insert_loop_id(const ExpressionPtr& expr, size_t new_id, boolexpr->set_loop_ids(loop_ids);}-void LoopManager::insert_loop_ids(const ExpressionPtr& expr, const std::vector<size_t>& new_ids, bool before, size_t target_id) {- OPENVINO_ASSERT(std::all_of(new_ids.cbegin(), new_ids.cend(), [this](const size_t& id) { return m_map.count(id) == 1; }),+void LoopManager::insert_loop_ids(const ExpressionPtr& expr,+ const std::vector<size_t>& new_ids,+ bool before,+ size_t target_id) {+ OPENVINO_ASSERT(std::all_of(new_ids.cbegin(),+ new_ids.cend(),+ [this](const size_t& id) {+ return m_map.count(id) == 1;+ }),"Failed marking expression by Loop ID: the Loop with this ID hasn't registered");auto loop_ids = expr->get_loop_ids();auto insert_it = before ? loop_ids.cbegin() : loop_ids.cend();@@ -469,12 +505,12 @@ void LoopManager::insert_loop_ids(const ExpressionPtr& expr, const std::vector<s}void LoopManager::replace_loop_id(const ExpressionPtr& expr, size_t prev_id, size_t new_id) {- OPENVINO_ASSERT(m_map.count(new_id), "Failed marking expression by Loop ID: the Loop with this ID hasn't registered");+ OPENVINO_ASSERT(m_map.count(new_id),+ "Failed marking expression by Loop ID: the Loop with this ID hasn't registered");OPENVINO_ASSERT(!is_loop_id_found(expr, new_id), "Expression cannot have several the same Loop IDs");auto loop_ids = expr->get_loop_ids();auto it = std::find(loop_ids.begin(), loop_ids.end(), prev_id);- OPENVINO_ASSERT(it != loop_ids.end(),- "Expression doesn't have the Loop with ID " + std::to_string(prev_id));+ OPENVINO_ASSERT(it != loop_ids.end(), "Expression doesn't have the Loop with ID " + std::to_string(prev_id));(*it) = new_id;expr->set_loop_ids(loop_ids);}@@ -492,6 +528,6 @@ 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 lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/loop_port.cpp b/src/common/snippets/src/lowered/loop_port.cppindex e6f68d48d94..9434a7fa9fa 100644--- a/src/common/snippets/src/lowered/loop_port.cpp+++ b/src/common/snippets/src/lowered/loop_port.cpp@@ -6,13 +6,13 @@#include "snippets/utils/utils.hpp"-namespace ov {namespace snippets {namespace lowered {LoopPort::LoopPort(const ExpressionPort& port, size_t dim_idx, Type type)- : m_expr_port(std::make_shared<ExpressionPort>(port)), m_type(type) {+ : m_expr_port(std::make_shared<ExpressionPort>(port)),+ m_type(type) {if (is_processed()) {set_dim_idx(dim_idx);} else {@@ -29,13 +29,13 @@ std::shared_ptr<LoopPort> LoopPort::clone_with_new_expr(const ExpressionPtr& newbool LoopPort::is_processed() const {switch (m_type) {- case Type::Incremented:- case Type::NotIncremented:- return true;- case Type::NotProcessed:- return false;- default:- OPENVINO_THROW("Unknown LoopPort type");+ case Type::Incremented:+ case Type::NotIncremented:+ return true;+ case Type::NotProcessed:+ return false;+ default:+ OPENVINO_THROW("Unknown LoopPort type");}}@@ -78,8 +78,7 @@ bool operator!=(const LoopPort& lhs, const LoopPort& rhs) {bool operator<(const LoopPort& lhs, const LoopPort& rhs) {return (*lhs.m_expr_port < *rhs.m_expr_port) ||(*lhs.m_expr_port == *rhs.m_expr_port &&- (lhs.m_type < rhs.m_type ||- (lhs.m_type == rhs.m_type && lhs.m_dim_idx < rhs.m_dim_idx)));+ (lhs.m_type < rhs.m_type || (lhs.m_type == rhs.m_type && lhs.m_dim_idx < rhs.m_dim_idx)));}std::ostream& operator<<(std::ostream& out, const LoopPort::Type& type) {@@ -99,7 +98,6 @@ std::ostream& operator<<(std::ostream& out, const LoopPort::Type& type) {return out;}--} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/allocate_buffers.cpp b/src/common/snippets/src/lowered/pass/allocate_buffers.cppindex 0269c65109b..0ada643f948 100644--- a/src/common/snippets/src/lowered/pass/allocate_buffers.cpp+++ b/src/common/snippets/src/lowered/pass/allocate_buffers.cpp@@ -2,18 +2,17 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/lowered/pass/allocate_buffers.hpp"+#include "snippets/itt.hpp"#include "snippets/lowered/pass/compute_buffer_allocation_size.hpp"-#include "snippets/lowered/pass/solve_buffer_memory.hpp"-#include "snippets/lowered/pass/init_buffers_default.hpp"-#include "snippets/lowered/pass/set_buffer_reg_group.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/propagate_buffer_offset.hpp"-#include "snippets/lowered/pass/mark_invariant_shape_path.hpp"-#include "snippets/itt.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 {@@ -23,7 +22,9 @@ namespace 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) {+bool AllocateBuffers::run(lowered::LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::AllocateBuffers");size_t buffer_scratchpad_size = 0;@@ -46,7 +47,7 @@ bool AllocateBuffers::run(lowered::LinearIR& linear_ir, lowered::LinearIR::constreturn buffer_scratchpad_size > 0;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/assign_registers.cpp b/src/common/snippets/src/lowered/pass/assign_registers.cppindex 947ce34e8ed..3fef5b61441 100644--- a/src/common/snippets/src/lowered/pass/assign_registers.cpp+++ b/src/common/snippets/src/lowered/pass/assign_registers.cpp@@ -18,7 +18,9 @@ namespace snippets {namespace lowered {namespace pass {-AssignRegisters::RegMap AssignRegisters::assign_regs_manually(const LinearIR& linear_ir, std::set<Reg>& gpr_pool, std::set<Reg>& vec_pool) {+AssignRegisters::RegMap AssignRegisters::assign_regs_manually(const LinearIR& linear_ir,+ std::set<Reg>& gpr_pool,+ std::set<Reg>& vec_pool) {RegMap manually_assigned;const auto internal_parameters = [&]() {std::vector<ExpressionPtr> internal_parameters;@@ -62,7 +64,8 @@ AssignRegisters::RegMap AssignRegisters::assign_regs_manually(const LinearIR& liOPENVINO_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.- // We should manually set the one vector register for VectorBuffer and Max/Sum output to simulate a accumulator+ // We should manually set the one vector register for VectorBuffer and Max/Sum output to simulate a+ // accumulator// TODO [96351]: We should rewrite accumulator pattern using another wayconst auto& input_tensor = expr->get_input_port_connector(0);const auto& input = input_tensor->get_source();@@ -72,9 +75,10 @@ AssignRegisters::RegMap AssignRegisters::assign_regs_manually(const LinearIR& liconst auto parent = tensor->get_source();const auto parent_expr = parent.get_expr();if (ov::is_type<op::Fill>(parent_expr->get_node())) {- if (ov::is_type<op::VectorBuffer>(parent_expr->get_input_port_connector(0)->get_source().get_expr()->get_node())) {+ if (ov::is_type<op::VectorBuffer>(+ parent_expr->get_input_port_connector(0)->get_source().get_expr()->get_node())) {manually_assigned[parent.get_descriptor_ptr()->get_reg()] =- manually_assigned[parent_expr->get_input_port_descriptor(0)->get_reg()] = assigned;+ manually_assigned[parent_expr->get_input_port_descriptor(0)->get_reg()] = assigned;}}}@@ -92,13 +96,12 @@ bool AssignRegisters::run(LinearIR& linear_ir) {const auto& exprs = linear_ir.get_ops();const auto& kernel = snippets::op::Kernel::make_kernel(linear_ir.is_dynamic());- auto vec2set = [](std::vector<Reg>&& v){+ auto vec2set = [](std::vector<Reg>&& v) {std::set<Reg> res;std::copy(v.begin(), v.end(), std::inserter(res, res.begin()));return res;};-std::set<Reg> global_regs = vec2set(m_reg_manager.get_kernel_call_regs(kernel));std::set<Reg> gpr_pool = vec2set(m_reg_manager.get_gp_regs_except_kernel_call(kernel));std::set<Reg> vec_pool = vec2set(m_reg_manager.get_vec_reg_pool());@@ -109,7 +112,7 @@ bool AssignRegisters::run(LinearIR& linear_ir) {struct by_starting {auto operator()(const LiveInterval& lhs, const LiveInterval& rhs) const -> bool {- return lhs.first < rhs.first|| (lhs.first == rhs.first && lhs.second < rhs.second);+ return lhs.first < rhs.first || (lhs.first == rhs.first && lhs.second < rhs.second);}};@@ -129,17 +132,17 @@ bool AssignRegisters::run(LinearIR& linear_ir) {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");- live_intervals_gpr[interval] = reg;- break;- case (RegType::vec):- OPENVINO_ASSERT(!live_intervals_vec.count(interval), "VEC live interval is already in the map");- live_intervals_vec[interval] = reg;- break;- case (RegType::undefined):- default:- OPENVINO_THROW("Unhandled register type");+ case (RegType::gpr):+ OPENVINO_ASSERT(!live_intervals_gpr.count(interval), "GPR live interval is already in the map");+ live_intervals_gpr[interval] = reg;+ break;+ case (RegType::vec):+ OPENVINO_ASSERT(!live_intervals_vec.count(interval), "VEC live interval is already in the map");+ live_intervals_vec[interval] = reg;+ break;+ case (RegType::undefined):+ default:+ OPENVINO_THROW("Unhandled register type");}}@@ -169,7 +172,8 @@ bool AssignRegisters::run(LinearIR& linear_ir) {bank.push(register_map[active_unique_reg]);}// allocate- OPENVINO_ASSERT(active.size() != reg_pool.size(), "Can't allocate registers for a snippet: not enough registers");+ OPENVINO_ASSERT(active.size() != reg_pool.size(),+ "Can't allocate registers for a snippet: not enough registers");register_map[unique_reg] = bank.top();bank.pop();active.insert(interval_reg);@@ -202,8 +206,7 @@ bool AssignRegisters::run(LinearIR& linear_ir) {return false;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov-+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/brgemm_blocking.cpp b/src/common/snippets/src/lowered/pass/brgemm_blocking.cppindex 19399719dbb..87208cb0164 100644--- a/src/common/snippets/src/lowered/pass/brgemm_blocking.cpp+++ b/src/common/snippets/src/lowered/pass/brgemm_blocking.cpp@@ -7,9 +7,9 @@#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/lowered/pass/iter_handler.hpp"#include "snippets/snippets_isa.hpp"#include "snippets/utils/utils.hpp"@@ -20,10 +20,12 @@ namespace pass {using namespace ov::snippets::utils;using PortType = LoopPort::Type;-lowered::SpecificIterationHandlers BrgemmBlockingBase::get_default_blocking_loop_handlers(size_t work_amount, size_t block_size) {+lowered::SpecificIterationHandlers BrgemmBlockingBase::get_default_blocking_loop_handlers(size_t work_amount,+ size_t block_size) {OPENVINO_ASSERT(block_size != 0, "block size must be non zero");SpecificIterationHandlers handlers;- const auto tail_size = utils::is_dynamic_value(work_amount) ? utils::get_dynamic_value<size_t>() : work_amount % block_size;+ const auto tail_size =+ utils::is_dynamic_value(work_amount) ? utils::get_dynamic_value<size_t>() : work_amount % block_size;if (tail_size != 0)handlers.register_pass<lowered::SpecificLoopIterType::LAST_ITER, lowered::pass::UpdateSubtensors>(tail_size);return handlers;@@ -120,7 +122,8 @@ std::tuple<size_t, size_t, size_t> BrgemmBlockingBase::get_brgemm_dimensions(conconst auto& k0 = *in_0_planar_dims.rbegin();const auto& k1 = *++in_1_planar_dims.rbegin();size_t k = 0;- OPENVINO_ASSERT(utils::merge_dynamic_dim(k, k0, k1), "Brgemm input descriptors have incompatible K dimension value.");+ OPENVINO_ASSERT(utils::merge_dynamic_dim(k, k0, k1),+ "Brgemm input descriptors have incompatible K dimension value.");return std::make_tuple(m, n, k);}@@ -155,7 +158,7 @@ bool BrgemmBlockingBase::mark_blocking_loops(LinearIR& linear_ir,}return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ov\ No newline at end of filediff --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 9090b0a0cc7..0e55cb1d5b9 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,17 +4,18 @@#include "snippets/lowered/pass/clean_repeated_ptr_shifts.hpp"+#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_manager.hpp"#include "snippets/snippets_isa.hpp"-#include "snippets/itt.hpp"namespace ov {namespace snippets {namespace lowered {namespace pass {-bool CleanRepeatedDataPointerShifts::reuse_increments(const LoopManagerPtr& loop_manager, const ExpressionPtr& loop_end_expr) {+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)return false;@@ -25,7 +26,8 @@ bool CleanRepeatedDataPointerShifts::reuse_increments(const LoopManagerPtr& loopstd::set<size_t> resetting_data_indexes;std::set<size_t> buffers_groups;- // We count expressions only on inputs of Loop because we can only read from the same data but not write to the same data.+ // We count expressions only on inputs of Loop because we can only read from the same data but not write to the same+ // data.// Parameter// | |// Load_0 Load_1@@ -63,7 +65,8 @@ bool CleanRepeatedDataPointerShifts::reuse_increments(const LoopManagerPtr& loopif (buffers_groups.count(buffer_expr->get_reg_group()) == 0) {buffers_groups.insert(buffer_expr->get_reg_group());} else {- // The Buffer with the same ID is in set - need to add this Buffer idx to set of Buffers for resetting+ // The Buffer with the same ID is in set - need to add this Buffer idx to set of Buffers for+ // resettingresetting_data_indexes.insert(input_count + i);}} else if (ov::is_type<op::LoopEnd>(consumer->get_node())) {@@ -95,19 +98,22 @@ bool CleanRepeatedDataPointerShifts::reuse_increments(const LoopManagerPtr& loopconst auto loop_info = loop_manager->get_loop_info<UnifiedLoopInfo>(loop_end->get_id());size_t loop_port_idx = 0;- loop_info->iterate_through_infos([&resetting_data_indexes, &loop_port_idx](LoopPort& loop_port, UnifiedLoopInfo::LoopPortDesc& shifts) {- if (resetting_data_indexes.count(loop_port_idx) && loop_port.is_processed()) {- shifts.ptr_increment = 0;- shifts.finalization_offset = 0;- loop_port.convert_to_type<LoopPort::Type::NotIncremented>();- }- ++loop_port_idx;- });+ loop_info->iterate_through_infos(+ [&resetting_data_indexes, &loop_port_idx](LoopPort& loop_port, UnifiedLoopInfo::LoopPortDesc& shifts) {+ if (resetting_data_indexes.count(loop_port_idx) && loop_port.is_processed()) {+ shifts.ptr_increment = 0;+ shifts.finalization_offset = 0;+ loop_port.convert_to_type<LoopPort::Type::NotIncremented>();+ }+ ++loop_port_idx;+ });return true;}-bool CleanRepeatedDataPointerShifts::run(lowered::LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) {+bool CleanRepeatedDataPointerShifts::run(lowered::LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::CleanRepeatedDataPointerShifts")bool modified = false;@@ -123,7 +129,7 @@ bool CleanRepeatedDataPointerShifts::run(lowered::LinearIR& linear_ir, lowered::return modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/cleanup_loop_offsets.cpp b/src/common/snippets/src/lowered/pass/cleanup_loop_offsets.cppindex 79dcedcc2a7..f6f5bd26213 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,19 @@#include "snippets/lowered/pass/cleanup_loop_offsets.hpp"+#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/op/loop.hpp"#include "snippets/utils/utils.hpp"-#include "snippets/itt.hpp"namespace ov {namespace snippets {namespace lowered {namespace pass {-bool CleanupLoopOffsets::run(lowered::LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) {+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")bool is_modified = false;for (auto expr_it = begin; expr_it != end; expr_it++) {@@ -52,7 +54,8 @@ bool CleanupLoopOffsets::run(lowered::LinearIR& linear_ir, lowered::LinearIR::coif (found != per_port_connector_offset.end()) {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]))+ if (utils::is_dynamic_value(outer_ptr_increments[i]) ||+ 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.@@ -61,8 +64,9 @@ bool CleanupLoopOffsets::run(lowered::LinearIR& linear_ir, lowered::LinearIR::co// Inner Loop: WA = 32, Inc = 1, ptr_increment[0] = 20, final_offset[0] = -640// Outer Loop: WA = 70, Inc = 32, ptr_increment[0] = 20, final_offset[0] = -1400// To save data ptr shift proportionality, we have to calculate so:- // outer_ptr_increment[0] = (inner_final_offset[0] + outer_ptr_increment[0] * outer_Inc) / outer_Inc- // outer_ptr_increment[0] = (-640 + 20 x 32) / 32 = 0+ // outer_ptr_increment[0] = (+ // inner_final_offset[0] + outer_ptr_increment[0] * outer_Inc) / outer_Inc+ // outer_ptr_increment[0] = (-640 + 20 x 32) / 32 = 0const auto full_outer_increment = outer_ptr_increments[i] * outer_increment;const auto new_final_outer_increment = full_outer_increment + fin_offsets[found->second];@@ -82,8 +86,7 @@ bool CleanupLoopOffsets::run(lowered::LinearIR& linear_ir, lowered::LinearIR::coreturn is_modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov-+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 c6f0b9bcb93..328a7165261 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@@ -4,17 +4,18 @@#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/itt.hpp"-namespace ov {namespace snippets {namespace lowered {namespace pass {-bool ComputeBufferAllocationSize::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) {+bool ComputeBufferAllocationSize::run(LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ 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;@@ -29,7 +30,7 @@ bool ComputeBufferAllocationSize::run(LinearIR& linear_ir, lowered::LinearIR::coreturn true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/define_buffer_clusters.cpp b/src/common/snippets/src/lowered/pass/define_buffer_clusters.cppindex a4114be74f6..a426222108b 100644--- a/src/common/snippets/src/lowered/pass/define_buffer_clusters.cpp+++ b/src/common/snippets/src/lowered/pass/define_buffer_clusters.cpp@@ -4,13 +4,12 @@#include "snippets/lowered/pass/define_buffer_clusters.hpp"+#include "snippets/itt.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/lowered/loop_manager.hpp"#include "snippets/snippets_isa.hpp"#include "snippets/utils/utils.hpp"-#include "snippets/itt.hpp"-namespace ov {namespace snippets {@@ -27,16 +26,19 @@ std::vector<size_t> get_connected_loops(const BufferExpressionPtr& buffer_expr,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");- const auto mismatched_its = std::mismatch(buffer_loops_ids.begin(), buffer_loops_ids.end(), consumer_loop_ids.begin());+ const auto mismatched_its =+ std::mismatch(buffer_loops_ids.begin(), buffer_loops_ids.end(), consumer_loop_ids.begin());return {mismatched_its.second, consumer_loop_ids.cend()};}-} // namespace+} // namespaceusing LoopPortInfo = UnifiedLoopInfo::LoopPortInfo;-DefineBufferClusters::BufferClusters::iterator DefineBufferClusters::find_cluster_by_expr(const BufferExpressionPtr& target) {- return std::find_if(m_clusters.begin(), m_clusters.end(),- [&target](const BufferCluster& cluster) { return cluster.count(target) > 0; });+DefineBufferClusters::BufferClusters::iterator DefineBufferClusters::find_cluster_by_expr(+ const BufferExpressionPtr& target) {+ return std::find_if(m_clusters.begin(), m_clusters.end(), [&target](const BufferCluster& cluster) {+ return cluster.count(target) > 0;+ });}bool DefineBufferClusters::is_direct_buffer(const BufferExpressionPtr& buffer_expr, const ExpressionPtr& target_expr) {@@ -51,10 +53,13 @@ void DefineBufferClusters::create_new_cluster(const BufferExpressionPtr& buffer_}}-void DefineBufferClusters::add_buffers_to_cluster(BufferCluster& existing_cluster, const std::set<BufferExpressionPtr>& buffers) {+void DefineBufferClusters::add_buffers_to_cluster(BufferCluster& existing_cluster,+ const std::set<BufferExpressionPtr>& buffers) {existing_cluster.insert(buffers.cbegin(), buffers.cend());// All buffers in one cluster must be only static or dynamic (no mixes).- if (std::any_of(existing_cluster.cbegin(), existing_cluster.cend(), [](const BufferExpressionPtr& buffer) { return !buffer->is_defined(); })) {+ if (std::any_of(existing_cluster.cbegin(), existing_cluster.cend(), [](const BufferExpressionPtr& buffer) {+ return !buffer->is_defined();+ })) {for (const auto& buffer : existing_cluster)buffer->set_allocation_size(utils::get_dynamic_value<size_t>());}@@ -63,24 +68,29 @@ void DefineBufferClusters::add_buffers_to_cluster(BufferCluster& existing_clustesize_t DefineBufferClusters::get_cluster_buffer_id(const BufferCluster& cluster) {assert(!cluster.empty() && "Buffer cluster is empty!");const auto id = cluster.cbegin()->get()->get_reg_group();- if (std::all_of(cluster.cbegin(), cluster.cend(), [&id](const BufferExpressionPtr& expr) { return expr->get_reg_group() == id; })) {+ if (std::all_of(cluster.cbegin(), cluster.cend(), [&id](const BufferExpressionPtr& expr) {+ return expr->get_reg_group() == id;+ })) {return id;}return SIZE_MAX;}-std::pair<DefineBufferClusters::BufferMap, DefineBufferClusters::BufferMap> DefineBufferClusters::get_direct_buffers(const UnifiedLoopInfoPtr& loop_info,- const ExpressionPtr& loop_expr) {+std::pair<DefineBufferClusters::BufferMap, DefineBufferClusters::BufferMap> DefineBufferClusters::get_direct_buffers(+ const UnifiedLoopInfoPtr& loop_info,+ const ExpressionPtr& loop_expr) {BufferMap input_buffers;const auto& loop_inputs = loop_info->get_input_ports_info();for (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());+ 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))continue;if (input_buffers.count(buffer_expr) > 0) {const auto& port_desc = port_info.desc;OPENVINO_ASSERT(input_buffers[buffer_expr].desc == port_desc,- "Invalid data pointer shifts: If Buffer has several consumers, this consumers must have the same shifts or zero");+ "Invalid data pointer shifts: If Buffer has several consumers, this consumers must have "+ "the same shifts or zero");continue;}input_buffers[buffer_expr] = port_info;@@ -130,10 +140,14 @@ void DefineBufferClusters::parse_loop(const LoopManagerPtr& loop_manager, constif ((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());- const auto out_path = MarkInvariantShapePath::getInvariantPortShapePath(*output_buffer_port_info.port.get_expr_port());- // - Memory can be reused if there are the same loop pointer increments (data size, final offsets, ptr increments).- // For that, loop ports with buffers should be on the same shape-path and have the same value of `is_incremented`.+ const auto in_path =+ MarkInvariantShapePath::getInvariantPortShapePath(*input_buffer_port_info.port.get_expr_port());+ const auto out_path =+ MarkInvariantShapePath::getInvariantPortShapePath(*output_buffer_port_info.port.get_expr_port());+ // - Memory can be reused if there are the same loop pointer increments (data size, final offsets, ptr+ // increments).+ // For that, loop ports with buffers should be on the same shape-path and have the same value of+ // `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)@@ -145,13 +159,17 @@ void DefineBufferClusters::parse_loop(const LoopManagerPtr& loop_manager, constcontinue;} 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()))+ // - 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()))continue;}const auto cluster_it = find_cluster_by_expr(input_buffer_expr);- OPENVINO_ASSERT(cluster_it != m_clusters.end(), "Buffer on inputs of Loop must be already saved in clusters");+ OPENVINO_ASSERT(cluster_it != m_clusters.end(),+ "Buffer on inputs of Loop must be already saved in clusters");// Add to the existing clusteradd_buffers_to_cluster(*cluster_it, {output_buffer_expr});// Remove input buffer because we have already use its memory@@ -168,31 +186,41 @@ void DefineBufferClusters::parse_loop(const LoopManagerPtr& loop_manager, constparse_nested_loops(loop_manager, input_buffers, output_buffers, expr_it);}-void DefineBufferClusters::parse_nested_loops(const LoopManagerPtr& loop_manager, const BufferMap& input_buffers,- const BufferMap& output_buffers, const LinearIR::constExprIt& outer_loop_end_expr_it) {+void DefineBufferClusters::parse_nested_loops(const LoopManagerPtr& loop_manager,+ const BufferMap& input_buffers,+ const BufferMap& output_buffers,+ const LinearIR::constExprIt& outer_loop_end_expr_it) {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) {+ 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))+ if (!outer_port_info.port.is_incremented() ||+ (!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!");- // we can be sure that these data pointers will be proportionally shifted if they're on the same invariant shape path+ OPENVINO_ASSERT(inner_port_info.port.get_expr_port() && outer_port_info.port.get_expr_port(),+ "Expression ports are nullptr!");+ // we can be sure that these data pointers will be proportionally shifted if they're on the same invariant shape+ // pathreturn MarkInvariantShapePath::getInvariantPortShapePath(*inner_port_info.port.get_expr_port()) ==MarkInvariantShapePath::getInvariantPortShapePath(*outer_port_info.port.get_expr_port());};- const auto outer_loop_begin = ov::as_type_ptr<op::LoopEnd>(outer_loop_end_expr_it->get()->get_node())->get_loop_begin();- for (auto it = std::reverse_iterator<LinearIR::constExprIt>(outer_loop_end_expr_it); (*it)->get_node() != outer_loop_begin; ++it) {+ const auto outer_loop_begin =+ ov::as_type_ptr<op::LoopEnd>(outer_loop_end_expr_it->get()->get_node())->get_loop_begin();+ for (auto it = std::reverse_iterator<LinearIR::constExprIt>(outer_loop_end_expr_it);+ (*it)->get_node() != outer_loop_begin;+ ++it) {const auto& inner_expr = *it;if (const auto inner_buffer_expr = ov::as_type_ptr<BufferExpression>(inner_expr)) {const 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) continue;+ 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;@@ -205,32 +233,43 @@ 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) 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()) continue;+ 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())+ 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- // - This outer Buffer should have the same Buffer ID as inner to move data ptr of inner Buffer after each outer Loop iteration.+ // - This outer Buffer should have the same Buffer ID as inner to move data ptr of inner Buffer+ // after each outer Loop iteration.// 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)) continue;+ // 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))+ continue;applied = unite_nested_clusters(loop_manager, inner_cluster_it, *cluster_it, port.first, is_input);- if (applied) break;+ if (applied)+ break;}return applied;};- if (unite(input_buffers, true)) continue;- if (unite(output_buffers, false)) continue;+ if (unite(input_buffers, true))+ continue;+ if (unite(output_buffers, false))+ continue;}}}-bool DefineBufferClusters::init_buffer_last_loop_port_info(const LoopManagerPtr& loop_manager, const BufferExpressionPtr& buffer_expr,+bool DefineBufferClusters::init_buffer_last_loop_port_info(const LoopManagerPtr& loop_manager,+ const BufferExpressionPtr& buffer_expr,UnifiedLoopInfo::LoopPortInfo& port_info) {- auto get_direct_loop_for_buffer_out = [&](const BufferExpressionPtr& buffer_expr, const ExpressionPtr& consumer_expr) -> UnifiedLoopInfoPtr {+ 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())return nullptr;@@ -244,9 +283,11 @@ bool DefineBufferClusters::init_buffer_last_loop_port_info(const LoopManagerPtr&const auto consumers = buffer_out->get_consumers();for (const auto& consumer : consumers) {if (const auto& direct_loop = get_direct_loop_for_buffer_out(buffer_expr, consumer.get_expr())) {- const auto loop_order = direct_loop->get_output_ports().back().get_expr_port()->get_expr()->get_exec_num();+ const auto loop_order =+ direct_loop->get_output_ports().back().get_expr_port()->get_expr()->get_exec_num();if (loop_order > last_loop_exec_order) {- OPENVINO_ASSERT(direct_loop->is_loop_port(consumer), "Consumer of Buffer from another loop must be loop port");+ OPENVINO_ASSERT(direct_loop->is_loop_port(consumer),+ "Consumer of Buffer from another loop must be loop port");port_info = direct_loop->get_loop_port_info(consumer);last_loop_exec_order = loop_order;found = true;@@ -257,8 +298,11 @@ bool DefineBufferClusters::init_buffer_last_loop_port_info(const LoopManagerPtr&return found;}-bool DefineBufferClusters::unite_nested_clusters(const LoopManagerPtr& loop_manager, const BufferClusters::iterator& inner_cluster_it,- BufferCluster& outer_cluster, const BufferExpressionPtr& outer_buffer, bool is_outer_up) {+bool DefineBufferClusters::unite_nested_clusters(const LoopManagerPtr& loop_manager,+ const BufferClusters::iterator& inner_cluster_it,+ BufferCluster& outer_cluster,+ const BufferExpressionPtr& outer_buffer,+ bool is_outer_up) {for (const auto& inner_buffer : *inner_cluster_it) {const auto& upper_buffer = is_outer_up ? outer_buffer : inner_buffer;const auto& lower_buffer = is_outer_up ? inner_buffer : outer_buffer;@@ -269,7 +313,8 @@ bool DefineBufferClusters::unite_nested_clusters(const LoopManagerPtr& loop_manaconst auto& connected_loops = get_connected_loops(upper_buffer, upper_buffer_consumer.get_expr());for (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))+ if (!common_loop_info->is_loop_port(lower_buffer_source) ||+ !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);@@ -306,7 +351,9 @@ void DefineBufferClusters::parse_memory_access_op(const ExpressionPtr& expr) {}}-bool DefineBufferClusters::run(lowered::LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) {+bool DefineBufferClusters::run(lowered::LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::DefineBufferClusters");m_clusters.clear();@@ -335,7 +382,7 @@ bool DefineBufferClusters::run(lowered::LinearIR& linear_ir, lowered::LinearIR::return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/extract_loop_invariants.cpp b/src/common/snippets/src/lowered/pass/extract_loop_invariants.cppindex f873a782b08..c4cbd79b7b1 100644--- a/src/common/snippets/src/lowered/pass/extract_loop_invariants.cpp+++ b/src/common/snippets/src/lowered/pass/extract_loop_invariants.cpp@@ -24,13 +24,18 @@ std::vector<size_t> get_reordered_loop_ids(const LoopManagerPtr& loop_manager) {loop_ids_need_extract.push_back(p.first);auto sorter = [&](size_t lhs, size_t rhs) {- const auto lhs_last_expr = loop_manager->get_loop_info(lhs)->get_output_ports().back().get_expr_port()->get_expr();- const auto rhs_last_expr = loop_manager->get_loop_info(rhs)->get_output_ports().back().get_expr_port()->get_expr();- // If last output loop ports are the same expressions - first executive Loop has inner ID in expression loop IDs.+ const auto lhs_last_expr =+ loop_manager->get_loop_info(lhs)->get_output_ports().back().get_expr_port()->get_expr();+ const auto rhs_last_expr =+ loop_manager->get_loop_info(rhs)->get_output_ports().back().get_expr_port()->get_expr();+ // If last output loop ports are the same expressions - first executive Loop has inner ID in expression loop+ // IDs.if (lhs_last_expr == rhs_last_expr) {for (const auto& id : lhs_last_expr->get_loop_ids()) {- if (id == lhs) return false;- if (id == rhs) return true;+ if (id == lhs)+ return false;+ if (id == rhs)+ return true;}OPENVINO_THROW("Incorrect Loop IDs");} else {@@ -79,10 +84,11 @@ bool is_extraction_applicable(const ExpressionPtr& expr, const UnifiedLoopInfoPtbool parent_scalar_with_single_consumer = ov::is_type<snippets::op::Scalar>(parent->get_node()) &&parent->get_output_port_connector(0)->get_consumers().size() == 1;const auto& is_loop_port = inner_loop_info->is_loop_port(expr_input_ports[i]);- // If expr input port is not a loop input port, then should not extract. In this case expr depend on result of another expr in inner loop,- // i.e. move expr to top(outside) of inner loop does not keep data dependency.- // If expr has parent scalar which has single consumer, expr and parent scalar could be extracted together. If parent scalar has multiple- // consumers, the scalar has chance to move with other consumers, which maybe break data dependency as well.+ // If expr input port is not a loop input port, then should not extract. In this case expr depend on result of+ // another expr in inner loop, i.e. move expr to top(outside) of inner loop does not keep data dependency. If+ // expr has parent scalar which has single consumer, expr and parent scalar could be extracted together. If+ // parent scalar has multiple consumers, the scalar has chance to move with other consumers, which maybe break+ // data dependency as well.if (!is_loop_port && !parent_scalar_with_single_consumer) {return false;}@@ -97,8 +103,10 @@ bool is_extraction_applicable(const ExpressionPtr& expr, const UnifiedLoopInfoPtreturn true;}-void extract_expr(const ExpressionPtr& expr, LinearIR& linear_ir,- LinearIR::constExprIt& inner_loop_begin_pos, const LinearIR::constExprIt& inner_loop_end_pos) {+void extract_expr(const ExpressionPtr& expr,+ LinearIR& linear_ir,+ LinearIR::constExprIt& inner_loop_begin_pos,+ const LinearIR::constExprIt& inner_loop_end_pos) {// update expr loop idremove_last_loop_id(expr);// move if it is not the first@@ -132,7 +140,8 @@ void update_loop_ports(const ExpressionPtr& expr, const LoopManagerPtr& loop_manbool inserted = false;for (const auto& port : expr->get_input_ports()) {if (inner_loop_info->is_loop_port(port)) {- inner_loop_info->replace_with_new_ports(port, (inserted ? std::vector<ExpressionPort>{} : new_loop_input_ports));+ inner_loop_info->replace_with_new_ports(port,+ (inserted ? std::vector<ExpressionPort>{} : new_loop_input_ports));inserted = true;}}@@ -172,7 +181,8 @@ bool extract_from_loop(const size_t& inner_loop_id, LinearIR& linear_ir) {if (is_extraction_applicable(port_expr, inner_loop_info, inner_loop_id)) {status = true;LinearIR::constExprIt inner_loop_begin_pos, inner_loop_end_pos;- std::tie(inner_loop_begin_pos, inner_loop_end_pos) = loop_manager->get_loop_bounds(linear_ir, inner_loop_id);+ std::tie(inner_loop_begin_pos, inner_loop_end_pos) =+ loop_manager->get_loop_bounds(linear_ir, inner_loop_id);// extract scalar on inputs if there arefor (size_t i = 0; i < port_expr->get_input_count(); ++i) {@@ -182,8 +192,8 @@ bool extract_from_loop(const size_t& inner_loop_id, LinearIR& linear_ir) {}}// Inner Loops can contain ports which are ports of outer Loops as well.- // When we move extract expressions from inner loops and move them, we can corrupt the sort of LoopPorts of outer Loops.- // Firstly, we should save outer loop ids, before extraction+ // When we move extract expressions from inner loops and move them, we can corrupt the sort of LoopPorts+ // of outer Loops. Firstly, we should save outer loop ids, before extractionconst auto outer_loop_ids = LoopManager::get_outer_expr_loops(port_expr, inner_loop_id);// Secondly, complete extraction@@ -194,7 +204,8 @@ bool extract_from_loop(const size_t& inner_loop_id, LinearIR& linear_ir) {loop_manager->sort_loop_ports(outer_loop_ids);expr_extracted = true;- break; // extracted and refreshed loop_input_ports. break potential_extractable_exprs loop, and go while() to start again.+ break; // extracted and refreshed loop_input_ports. break potential_extractable_exprs loop, and go+ // while() to start again.}}if (inner_loop_input_ports.size() == 0 && inner_loop_info->get_output_ports().size() == 0) {@@ -210,7 +221,9 @@ bool extract_from_loop(const size_t& inner_loop_id, LinearIR& linear_ir) {}} // namespace-bool ExtractLoopInvariants::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) {+bool ExtractLoopInvariants::run(LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::ExtractLoopInvariants")bool modified = false;diff --git a/src/common/snippets/src/lowered/pass/fuse_loops.cpp b/src/common/snippets/src/lowered/pass/fuse_loops.cppindex 377acd6a286..b2dab156fa0 100644--- a/src/common/snippets/src/lowered/pass/fuse_loops.cpp+++ b/src/common/snippets/src/lowered/pass/fuse_loops.cpp@@ -4,11 +4,11 @@#include "snippets/lowered/pass/fuse_loops.hpp"+#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_manager.hpp"#include "snippets/snippets_isa.hpp"#include "snippets/utils/utils.hpp"-#include "snippets/itt.hpp"namespace ov {namespace snippets {@@ -18,15 +18,15 @@ 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();}-} // namespace+} // namespaceFuseLoops::FuseLoops() : RangedPass() {}-bool FuseLoops::loop_ports_are_compatible(const LoopInfoPtr& loop_upper,- const LoopInfoPtr& loop_lower) {+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 std::find_if(loop_ports.cbegin(), loop_ports.cend(), [&target_port](const LoopPort& loop_port) {+ return *(loop_port.get_expr_port().get()) == target_port;+ });};const auto& upper_exit_ports = loop_upper->get_output_ports();const auto& lower_entry_ports = loop_lower->get_input_ports();@@ -60,33 +60,40 @@ bool FuseLoops::can_be_fused(const UnifiedLoopInfoPtr& loop_upper, const Unifiedconst auto work_amount_upper = loop_upper->get_work_amount(), work_amount_lower = loop_lower->get_work_amount();const auto increment_upper = loop_upper->get_increment(), increment_lower = loop_lower->get_increment();const bool is_dynamic_case =- (utils::is_dynamic_value(work_amount_upper) || utils::is_dynamic_value(work_amount_lower)) && increment_upper == increment_lower;- const bool equal_parameters =- (work_amount_upper == work_amount_lower) && increment_upper == increment_lower;+ (utils::is_dynamic_value(work_amount_upper) || utils::is_dynamic_value(work_amount_lower)) &&+ increment_upper == increment_lower;+ const bool equal_parameters = (work_amount_upper == work_amount_lower) && increment_upper == increment_lower;const bool bcastable_upper = work_amount_upper == 1 && increment_upper == 1;const bool bcastable_lower = work_amount_lower == 1 && increment_lower == 1;// WA: we can't fuse 2 loops if one of them has first iteration handler but second hasn't,// because in this case Main/Tail body handlers of the loop wo first iter handler must be reset with new parameters// (e.g. tail size). This logic is not implemented for now, so fusion for such loops is skipped.- const bool first_iter_handlers_match = loop_upper->get_handlers().get_passes<SpecificLoopIterType::FIRST_ITER>().empty() ==- loop_lower->get_handlers().get_passes<SpecificLoopIterType::FIRST_ITER>().empty();+ const bool first_iter_handlers_match =+ loop_upper->get_handlers().get_passes<SpecificLoopIterType::FIRST_ITER>().empty() ==+ loop_lower->get_handlers().get_passes<SpecificLoopIterType::FIRST_ITER>().empty();// InnerSplittedUnifiedLoops can be fused only if they point to the same outer loopconst auto& ispl_loop_upper = ov::as_type_ptr<InnerSplittedUnifiedLoopInfo>(loop_upper);const auto& ispl_loop_lower = ov::as_type_ptr<InnerSplittedUnifiedLoopInfo>(loop_lower);const auto& inner_splitted_loop_compatible =(!ispl_loop_upper && !ispl_loop_lower) ||- (ispl_loop_upper && ispl_loop_lower && ispl_loop_upper->get_outer_splitted_loop_info() == ispl_loop_lower->get_outer_splitted_loop_info());- return first_iter_handlers_match && inner_splitted_loop_compatible && (is_dynamic_case || equal_parameters || bcastable_upper || bcastable_lower);+ (ispl_loop_upper && ispl_loop_lower &&+ ispl_loop_upper->get_outer_splitted_loop_info() == ispl_loop_lower->get_outer_splitted_loop_info());+ return first_iter_handlers_match && inner_splitted_loop_compatible &&+ (is_dynamic_case || equal_parameters || bcastable_upper || bcastable_lower);}-void FuseLoops::move(LinearIR& linear_ir, const LoopManagerPtr& loop_manager, size_t loop_id,- LinearIR::constExprIt loop_begin_pos, LinearIR::constExprIt loop_end_pos, LinearIR::constExprIt pos) {+void FuseLoops::move(LinearIR& linear_ir,+ const LoopManagerPtr& loop_manager,+ size_t loop_id,+ LinearIR::constExprIt loop_begin_pos,+ LinearIR::constExprIt loop_end_pos,+ LinearIR::constExprIt pos) {// Inner Loops can contain ports which are ports of outer Loops as well.// When we move these inner loops, we can corrupt the sort of LoopPorts of outer Loops.// Firstly, we should get outer loop idsconst auto outer_loop_ids = LoopManager::get_outer_expr_loops(*loop_begin_pos, loop_id);- // Secondly, move expressions+ // Secondly, move expressionsfor (auto it = loop_begin_pos; it != loop_end_pos;) {auto expr_it = it;// After moving we will have `it` in new place in the current Loop,@@ -99,10 +106,13 @@ void FuseLoops::move(LinearIR& linear_ir, const LoopManagerPtr& loop_manager, siloop_manager->sort_loop_ports(outer_loop_ids);}-bool FuseLoops::fuse_upper_into_current(LinearIR& linear_ir, const LoopManagerPtr& loop_manager,+bool FuseLoops::fuse_upper_into_current(LinearIR& linear_ir,+ const LoopManagerPtr& loop_manager,const std::shared_ptr<ExpressionPort>& current_input_port,- size_t current_loop_id, size_t target_loop_id,- LinearIR::constExprIt& current_loop_begin_pos, LinearIR::constExprIt& current_loop_end_pos) {+ size_t current_loop_id,+ size_t target_loop_id,+ LinearIR::constExprIt& current_loop_begin_pos,+ 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))@@ -120,9 +130,10 @@ bool FuseLoops::fuse_upper_into_current(LinearIR& linear_ir, const LoopManagerPtcontinue;// 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 = is_loop_id_found(consumer->get_loop_ids(), target_loop_id) || // is inside target Loop- is_loop_id_found(consumer->get_loop_ids(), current_loop_id) || // is inside current Loop- consumer->get_exec_num() > (*current_loop_end_pos)->get_exec_num(); // is after current Loop+ is_fusion_allowed =+ is_loop_id_found(consumer->get_loop_ids(), target_loop_id) || // is inside target Loop+ is_loop_id_found(consumer->get_loop_ids(), current_loop_id) || // is inside current Loop+ consumer->get_exec_num() > (*current_loop_end_pos)->get_exec_num(); // is after current Loop}}@@ -143,10 +154,13 @@ bool FuseLoops::fuse_upper_into_current(LinearIR& linear_ir, const LoopManagerPtreturn true;}-bool FuseLoops::fuse_lower_into_current(LinearIR& linear_ir, const LoopManagerPtr& loop_manager,+bool FuseLoops::fuse_lower_into_current(LinearIR& linear_ir,+ const LoopManagerPtr& loop_manager,const std::shared_ptr<ExpressionPort>& current_output_port,- size_t current_loop_id, size_t target_loop_id,- LinearIR::constExprIt& current_loop_begin_pos, LinearIR::constExprIt& current_loop_end_pos) {+ size_t current_loop_id,+ size_t target_loop_id,+ LinearIR::constExprIt& current_loop_begin_pos,+ 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))@@ -159,10 +173,13 @@ bool FuseLoops::fuse_lower_into_current(LinearIR& linear_ir, const LoopManagerPtconst auto target_entry_port = loop_target->get_input_ports()[i];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())+ if (ov::is_type<ov::op::v0::Parameter>(parent_expr->get_node()) ||+ 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 Loop- parent_expr->get_exec_num() < (*current_loop_begin_pos)->get_exec_num(); // The parent is before current Loop+ is_fusion_allowed = is_loop_id_found(parent_expr->get_loop_ids(),+ current_loop_id) || // The parent expr is from the same current Loop+ parent_expr->get_exec_num() <+ (*current_loop_begin_pos)->get_exec_num(); // The parent is before current Loop}if (!is_fusion_allowed)@@ -198,7 +215,8 @@ bool FuseLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lconst auto current_loop_depth = current_expr_loops.size();for (size_t i = 0; i < current_loop_depth; ++i) {const 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 the current Loop ID is in prev fused Loops, it means that on previous step all possible fusions are+ // completedif (prev_fused_loops.count(current_loop_id) != 0)continue;@@ -209,12 +227,14 @@ bool FuseLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lwhile (need_fusion_checks) {auto current_loop_info = loop_manager->get_loop_info(current_loop_id);LinearIR::constExprIt current_loop_begin_pos, current_loop_end_pos;- std::tie(current_loop_begin_pos, current_loop_end_pos) = loop_manager->get_loop_bounds(linear_ir, current_loop_id);+ std::tie(current_loop_begin_pos, current_loop_end_pos) =+ loop_manager->get_loop_bounds(linear_ir, current_loop_id);// Loop_0 (Upper) |// | => |// Loop_1 (Current) Loop_0 + Loop_1 => new `Loop_1`- // Make a copy of `input_ports` (not ref), since current_loop_info might be changed and ref will be invalid+ // Make a copy of `input_ports` (not ref), since current_loop_info might be changed and ref will be+ // invalidconst auto input_ports = current_loop_info->get_input_ports();bool was_fusion_up = false;for (size_t in_port = 0; !was_fusion_up && in_port < input_ports.size(); ++in_port) {@@ -242,9 +262,16 @@ bool FuseLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lconst auto upper_loop_id = upper_loop_ids[loop_idx];OPENVINO_ASSERT(current_loop_id != upper_loop_id,- "Loops cannot have parents of input ports with the same identifier (", upper_loop_id, ")");- if (fuse_upper_into_current(linear_ir, loop_manager, input_port.get_expr_port(), current_loop_id, upper_loop_id,- current_loop_begin_pos, current_loop_end_pos)) {+ "Loops cannot have parents of input ports with the same identifier (",+ upper_loop_id,+ ")");+ if (fuse_upper_into_current(linear_ir,+ loop_manager,+ input_port.get_expr_port(),+ current_loop_id,+ upper_loop_id,+ current_loop_begin_pos,+ current_loop_end_pos)) {was_fusion_up = true;prev_fused_loops.insert(current_loop_id);current_loop_info = loop_manager->get_loop_info(current_loop_id);@@ -285,12 +312,18 @@ bool FuseLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lcontinue;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 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)continue;- if (fuse_lower_into_current(linear_ir, loop_manager, output_port.get_expr_port(), current_loop_id, lower_loop_id,- current_loop_begin_pos, current_loop_end_pos)) {+ if (fuse_lower_into_current(linear_ir,+ loop_manager,+ output_port.get_expr_port(),+ current_loop_id,+ lower_loop_id,+ current_loop_begin_pos,+ current_loop_end_pos)) {was_fusion_down = true;prev_fused_loops.insert(current_loop_id);current_loop_info = loop_manager->get_loop_info(current_loop_id);@@ -300,7 +333,8 @@ 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.+ // 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)need_fusion_checks = false;}@@ -310,7 +344,7 @@ bool FuseLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lreturn true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/init_buffers_default.cpp b/src/common/snippets/src/lowered/pass/init_buffers_default.cppindex 90a7ddf0b3d..0077b33416e 100644--- a/src/common/snippets/src/lowered/pass/init_buffers_default.cpp+++ b/src/common/snippets/src/lowered/pass/init_buffers_default.cpp@@ -4,16 +4,17 @@#include "snippets/lowered/pass/init_buffers_default.hpp"-#include "snippets/op/buffer.hpp"#include "snippets/itt.hpp"-+#include "snippets/op/buffer.hpp"namespace ov {namespace snippets {namespace lowered {namespace pass {-bool InitBuffersDefault::run(lowered::LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) {+bool InitBuffersDefault::run(lowered::LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::InitBuffersDefault");size_t idx = 0;@@ -35,7 +36,7 @@ bool InitBuffersDefault::run(lowered::LinearIR& linear_ir, lowered::LinearIR::coreturn m_buffer_scratchpad_size > 0;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/init_live_ranges.cpp b/src/common/snippets/src/lowered/pass/init_live_ranges.cppindex 33fd5c093fd..56906196b16 100644--- a/src/common/snippets/src/lowered/pass/init_live_ranges.cpp+++ b/src/common/snippets/src/lowered/pass/init_live_ranges.cpp@@ -23,7 +23,7 @@ inline bool pass_through_expr(const ExpressionPtr& expr) {|| ov::is_type<BufferExpression>(expr);}-} // namespace+} // namespacebool InitLiveRanges::run(LinearIR& linear_ir) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::InitLiveRanges")@@ -45,7 +45,9 @@ bool InitLiveRanges::run(LinearIR& linear_ir) {}} else {// Remove all regs that expired before start- regs_to_expire.erase(regs_to_expire.begin(), regs_to_expire.lower_bound(start)); // remove all elements lower than start (not equal)+ 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)live_regs.insert(time_reg.second.begin(), time_reg.second.end());expr->set_live_regs(std::move(live_regs));@@ -88,8 +90,7 @@ bool InitLiveRanges::run(LinearIR& linear_ir) {return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov-+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/init_loops.cpp b/src/common/snippets/src/lowered/pass/init_loops.cppindex 07143ec8b59..c77541cb870 100644--- a/src/common/snippets/src/lowered/pass/init_loops.cpp+++ b/src/common/snippets/src/lowered/pass/init_loops.cpp@@ -26,9 +26,11 @@ inline void init_is_incremented(LoopPort& port) {inline int64_t get_data_size(const LoopPort& loop_port) {const auto& expr_port = loop_port.get_expr_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());+ 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) {- return static_cast<int64_t>(expr_port->get_expr()->get_node()->get_output_element_type(expr_port->get_index()).size());+ 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!");}@@ -37,11 +39,10 @@ inline int64_t get_data_size(const LoopPort& loop_port) {void InitLoops::update_compile_parameters(const UnifiedLoopInfoPtr& loop_info) {OPENVINO_ASSERT(loop_info != nullptr, "UnifiedLoopInfo is nullptr, nothing to update");- loop_info->iterate_through_infos(- [](LoopPort& loop_port, UnifiedLoopInfo::LoopPortDesc& ptr_shifts_params) {- init_is_incremented(loop_port);- ptr_shifts_params.data_size = get_data_size(loop_port);- });+ loop_info->iterate_through_infos([](LoopPort& loop_port, UnifiedLoopInfo::LoopPortDesc& ptr_shifts_params) {+ init_is_incremented(loop_port);+ ptr_shifts_params.data_size = get_data_size(loop_port);+ });}bool InitLoops::run(LinearIR& linear_ir) {@@ -59,7 +60,7 @@ bool InitLoops::run(LinearIR& linear_ir) {return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/init_registers.cpp b/src/common/snippets/src/lowered/pass/init_registers.cppindex 9c069b3165e..1d4c1bc8b13 100644--- a/src/common/snippets/src/lowered/pass/init_registers.cpp+++ b/src/common/snippets/src/lowered/pass/init_registers.cpp@@ -3,10 +3,11 @@//#include "snippets/lowered/pass/init_registers.hpp"-#include "snippets/lowered/pass/init_live_ranges.hpp"++#include "snippets/itt.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/itt.hpp"namespace ov {namespace snippets {@@ -14,9 +15,10 @@ namespace lowered {namespace pass {InitRegisters::InitRegisters(const std::shared_ptr<const Generator>& generator,- const std::shared_ptr<PassConfig>& pass_config) :- Pass(), m_reg_manager(generator), m_pass_config(pass_config) {-}+ const std::shared_ptr<PassConfig>& pass_config)+ : Pass(),+ m_reg_manager(generator),+ m_pass_config(pass_config) {}bool InitRegisters::run(LinearIR& linear_ir) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::InitRegisters");@@ -28,8 +30,7 @@ bool InitRegisters::run(LinearIR& linear_ir) {return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov-+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/insert_broadcastmove.cpp b/src/common/snippets/src/lowered/pass/insert_broadcastmove.cppindex 4130eac1db1..399965c72a4 100644--- a/src/common/snippets/src/lowered/pass/insert_broadcastmove.cpp+++ b/src/common/snippets/src/lowered/pass/insert_broadcastmove.cpp@@ -3,11 +3,12 @@//#include "snippets/lowered/pass/insert_broadcastmove.hpp"-#include "snippets/utils/utils.hpp"++#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_manager.hpp"#include "snippets/snippets_isa.hpp"-#include "snippets/itt.hpp"+#include "snippets/utils/utils.hpp"namespace ov {namespace snippets {@@ -16,9 +17,8 @@ namespace pass {bool InsertBroadcastMove::is_broadcasting_supported(const std::shared_ptr<ov::Node>& n) {return !std::dynamic_pointer_cast<modifier::MemoryAccess>(n) &&- (ov::op::util::supports_auto_broadcast(n) ||- n->get_autob().m_type == ov::op::AutoBroadcastType::NUMPY ||- is_type<ov::op::v0::PRelu>(n));+ (ov::op::util::supports_auto_broadcast(n) || n->get_autob().m_type == ov::op::AutoBroadcastType::NUMPY ||+ is_type<ov::op::v0::PRelu>(n));}bool InsertBroadcastMove::is_broadcasting_needed(const std::shared_ptr<ov::Node>& n) {@@ -33,9 +33,12 @@ bool InsertBroadcastMove::is_broadcasting_needed(const std::shared_ptr<ov::Node>std::vector<size_t> InsertBroadcastMove::get_last_dims(const ExpressionPtr& expr) {const auto& descriptors = expr->get_input_port_descriptors();std::vector<size_t> last_dims(descriptors.size());- std::transform(descriptors.begin(), descriptors.end(), last_dims.begin(),- [](const std::shared_ptr<PortDescriptor>& d){- return d->get_shape().size() > 0 ? d->get_shape().back() : 1; });+ std::transform(descriptors.begin(),+ descriptors.end(),+ last_dims.begin(),+ [](const std::shared_ptr<PortDescriptor>& d) {+ return d->get_shape().size() > 0 ? d->get_shape().back() : 1;+ });return last_dims;}@@ -49,7 +52,9 @@ size_t InsertBroadcastMove::get_max_dim(const std::vector<size_t>& last_dims) {return broadcast_dim;}-bool InsertBroadcastMove::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) {+bool InsertBroadcastMove::run(LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::InsertBroadcastMove")bool modified = false;@@ -68,18 +73,29 @@ bool InsertBroadcastMove::run(LinearIR& linear_ir, lowered::LinearIR::constExprIconst auto& input = expr->get_input_port_connector(i);const auto& parent_port = input->get_source();- if (!utils::is_dynamic_value(last_dims[i]) && last_dims[i] != broadcasted_dim && is_broadcasting_needed(parent_port.get_expr()->get_node())) {+ if (!utils::is_dynamic_value(last_dims[i]) && last_dims[i] != broadcasted_dim &&+ is_broadcasting_needed(parent_port.get_expr()->get_node())) {OPENVINO_ASSERT(last_dims[i] == 1,- "Attempt to broadcast non-1 dimension. Target dim: ", broadcasted_dim, " This dim: ", last_dims[i]);- const auto broadcast = std::make_shared<op::BroadcastMove>(node->get_input_source_output(i), broadcasted_dim);- const auto broadcast_expr = *linear_ir.insert_node(broadcast, std::vector<PortConnectorPtr>{ input },- expr->get_loop_ids(), true, expr_it, { expr->get_input_port(i) });- // Note: We have to set live regs manually, since this transformation is applied after all register-related passes.- // Since BroadcastMove sets in_regs the same as out_regs, live regs are the same as for the child.+ "Attempt to broadcast non-1 dimension. Target dim: ",+ broadcasted_dim,+ " This dim: ",+ last_dims[i]);+ const auto broadcast =+ std::make_shared<op::BroadcastMove>(node->get_input_source_output(i), broadcasted_dim);+ const auto broadcast_expr = *linear_ir.insert_node(broadcast,+ std::vector<PortConnectorPtr>{input},+ expr->get_loop_ids(),+ true,+ expr_it,+ {expr->get_input_port(i)});+ // Note: We have to set live regs manually, since this transformation is applied after all+ // register-related passes. Since BroadcastMove sets in_regs the same as out_regs, live regs are the+ // same as for the child.broadcast_expr->set_live_regs(expr->get_live_regs());// Note that BroadcastMove modified the next expr input shape, so we need to set update// expr's input port descriptor to reflect the changes- expr->get_input_port_descriptor(i)->set_shape(broadcast_expr->get_output_port_descriptor(0)->get_shape());+ expr->get_input_port_descriptor(i)->set_shape(+ broadcast_expr->get_output_port_descriptor(0)->get_shape());modified = true;}@@ -88,8 +104,7 @@ bool InsertBroadcastMove::run(LinearIR& linear_ir, lowered::LinearIR::constExprIreturn modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov-+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/insert_buffers.cpp b/src/common/snippets/src/lowered/pass/insert_buffers.cppindex 203f9374ef4..df28e9afadb 100644--- a/src/common/snippets/src/lowered/pass/insert_buffers.cpp+++ b/src/common/snippets/src/lowered/pass/insert_buffers.cpp@@ -9,13 +9,14 @@#include "snippets/snippets_isa.hpp"#include "snippets/utils/utils.hpp"-namespace ov {namespace snippets {namespace lowered {namespace pass {namespace {-std::vector<size_t> get_buffer_loop_ids(const std::vector<size_t>& lhs, const std::vector<size_t>& rhs, bool& is_buffer_needed) {+std::vector<size_t> get_buffer_loop_ids(const std::vector<size_t>& lhs,+ const std::vector<size_t>& rhs,+ bool& is_buffer_needed) {std::vector<size_t> buffer_loop_ids;const auto lhs_num = lhs.size();const auto rhs_num = rhs.size();@@ -31,8 +32,10 @@ std::vector<size_t> get_buffer_loop_ids(const std::vector<size_t>& lhs, const st}} // namespace-LinearIR::constExprIt InsertBuffers::insertion_position(const LinearIR& linear_ir, const LoopManagerPtr& loop_manager,- const ExpressionPtr& up_expr, const ExpressionPtr& down_expr) {+LinearIR::constExprIt InsertBuffers::insertion_position(const LinearIR& linear_ir,+ const LoopManagerPtr& loop_manager,+ const ExpressionPtr& up_expr,+ const ExpressionPtr& down_expr) {const auto& up_loops = up_expr->get_loop_ids();const auto& down_loops = down_expr->get_loop_ids();// If upper expression is out of Loop, we can insert Buffer implicitly after him@@ -115,8 +118,13 @@ void InsertBuffers::insertion(LinearIR& linear_ir,// Need to insert between 2nd and 4th Loops - after 2nd Loopconst auto pos = insertion_position(linear_ir, loop_manager, parent_expr, expr);const auto buffer = std::make_shared<op::Buffer>(parent->output(parent_port));- const auto buffer_consumer = has_shape_infer_parent ? top_shape_infer_expr->get_input_port(0) : entry_port;- linear_ir.insert_node(buffer, std::vector<ExpressionPort>{ parent_expr_output }, buffer_loop_ids, false, pos, { buffer_consumer });+ const auto buffer_consumer = has_shape_infer_parent ? top_shape_infer_expr->get_input_port(0) : entry_port;+ linear_ir.insert_node(buffer,+ std::vector<ExpressionPort>{parent_expr_output},+ buffer_loop_ids,+ false,+ pos,+ {buffer_consumer});}}@@ -131,12 +139,13 @@ void InsertBuffers::insertion(LinearIR& linear_ir,std::set<ExpressionPort> potential_consumers;std::set<ExpressionPtr> buffers;std::vector<size_t> buffer_loop_ids;- auto update_buffer_loop_ids = [&buffer_loop_ids, &potential_consumers, &buffers](const std::vector<size_t>& local_ids) {- if (buffers.empty() && potential_consumers.empty()) {- buffer_loop_ids = local_ids;- }- OPENVINO_ASSERT(local_ids == buffer_loop_ids, "Incorrect loop configuration for Buffers");- };+ auto update_buffer_loop_ids =+ [&buffer_loop_ids, &potential_consumers, &buffers](const std::vector<size_t>& local_ids) {+ if (buffers.empty() && potential_consumers.empty()) {+ buffer_loop_ids = local_ids;+ }+ OPENVINO_ASSERT(local_ids == buffer_loop_ids, "Incorrect loop configuration for Buffers");+ };for (const auto& child_expr_input : child_exprs_inputs) {const auto& child_expr = child_expr_input.get_expr();const auto child_port = child_expr_input.get_index();@@ -153,7 +162,8 @@ void InsertBuffers::insertion(LinearIR& linear_ir,const auto node_ma = std::dynamic_pointer_cast<modifier::MemoryAccess>(node);bool is_buffer_needed = (child_ma && child_ma->is_memory_access_input_port(child_port)) ||(node_ma && node_ma->is_memory_access_output_port(port_idx));- const auto local_buffer_loop_ids = get_buffer_loop_ids(current_loops, child_expr->get_loop_ids(), is_buffer_needed);+ const auto local_buffer_loop_ids =+ get_buffer_loop_ids(current_loops, child_expr->get_loop_ids(), is_buffer_needed);if (is_buffer_needed) {update_buffer_loop_ids(local_buffer_loop_ids);@@ -177,16 +187,20 @@ void InsertBuffers::insertion(LinearIR& linear_ir,// potential_consumers is unsorted by linear IR set.// We have to find first expr in Linear IR from the set to insert Buffer before *all* consumersOPENVINO_ASSERT(!potential_consumers.empty(), "Buffer should have one consumer at least");- const auto& consumer_expr = std::min_element(potential_consumers.begin(), potential_consumers.end(),- [](const ExpressionPort& l, const ExpressionPort& r) {- return l.get_expr()->get_exec_num() < r.get_expr()->get_exec_num();- })->get_expr();+ const auto& consumer_expr =+ std::min_element(potential_consumers.begin(),+ potential_consumers.end(),+ [](const ExpressionPort& l, const ExpressionPort& r) {+ return l.get_expr()->get_exec_num() < r.get_expr()->get_exec_num();+ })+ ->get_expr();// We should insert Buffer between first different Loops.// Example: Current expr Loop identifies: 3, 2, 1// Target consumers Loop identifies: 3, 4, 6// Need to insert after 2nd Loops- // Note: All potential consumers must have the same count of first equal Loop identifies and the same count of different last identifies+ // Note: All potential consumers must have the same count of first equal Loop identifies and the same count+ // of different last identifiesconst auto pos = insertion_position(linear_ir, loop_manager, expr, consumer_expr);auto buffer = std::make_shared<op::Buffer>(node->output(port_idx));@@ -198,7 +212,12 @@ void InsertBuffers::insertion(LinearIR& linear_ir,// | <- It should be new PortConnector// Relu// Output port connector is automatically filled from PortDescriptor- linear_ir.insert_node(buffer, std::vector<ExpressionPort>{ exit_port }, buffer_loop_ids, false, pos, { potential_consumers });+ linear_ir.insert_node(buffer,+ std::vector<ExpressionPort>{exit_port},+ buffer_loop_ids,+ false,+ pos,+ {potential_consumers});}}}@@ -214,8 +233,9 @@ bool InsertBuffers::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begiauto cvt_to_expr_ports = [](const std::vector<LoopPort>& loop_ports) {std::vector<ExpressionPort> expr_ports(loop_ports.size());- std::transform(loop_ports.cbegin(), loop_ports.cend(), expr_ports.begin(),- [](const LoopPort& loop_port) { return *loop_port.get_expr_port(); });+ std::transform(loop_ports.cbegin(), loop_ports.cend(), expr_ports.begin(), [](const LoopPort& loop_port) {+ return *loop_port.get_expr_port();+ });return expr_ports;};// using begin() as expr_it because we work with LoopInfo, not expressions in Linear IR@@ -245,7 +265,7 @@ bool InsertBuffers::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begireturn true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/insert_load_store.cpp b/src/common/snippets/src/lowered/pass/insert_load_store.cppindex a83df82202a..84d194a0f9f 100644--- a/src/common/snippets/src/lowered/pass/insert_load_store.cpp+++ b/src/common/snippets/src/lowered/pass/insert_load_store.cpp@@ -3,12 +3,13 @@//#include "snippets/lowered/pass/insert_load_store.hpp"-#include "snippets/op/rank_normalization.hpp"++#include "snippets/itt.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/utils/utils.hpp"-#include "snippets/itt.hpp"namespace ov {namespace snippets {@@ -36,8 +37,12 @@ bool InsertLoadStore::insert_load(LinearIR& linear_ir, const LinearIR::constExprcontinue;const auto load = std::make_shared<op::Load>(data_ngraph_output, get_count(data_expr->get_output_port(0)));- linear_ir.insert_node(load, std::vector<PortConnectorPtr>{ data_out }, consumer_expr->get_loop_ids(),- true, linear_ir.find_after(data_expr_it, consumer_expr), { consumer_input });+ linear_ir.insert_node(load,+ std::vector<PortConnectorPtr>{data_out},+ consumer_expr->get_loop_ids(),+ true,+ linear_ir.find_after(data_expr_it, consumer_expr),+ {consumer_input});was_inserted = true;}@@ -61,11 +66,18 @@ bool InsertLoadStore::insert_store(LinearIR& linear_ir, const LinearIR::constExpconst auto insertion_it =linear_ir.find_after(std::reverse_iterator<LinearIR::constExprIt>(data_expr_it), parent_expr);const auto& insertion_pos = insertion_it.base();- linear_ir.insert_node(store, std::vector<ExpressionPort>{ parent_output }, loop_ids, true, insertion_pos, { data_expr->get_input_port(0) });+ linear_ir.insert_node(store,+ std::vector<ExpressionPort>{parent_output},+ loop_ids,+ true,+ insertion_pos,+ {data_expr->get_input_port(0)});return true;}-bool InsertLoadStore::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) {+bool InsertLoadStore::run(LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::InsertLoadStore")bool modified = false;@@ -85,7 +97,7 @@ bool InsertLoadStore::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt bereturn modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/insert_loops.cpp b/src/common/snippets/src/lowered/pass/insert_loops.cppindex d88bf7a1980..5a4739dc856 100644--- a/src/common/snippets/src/lowered/pass/insert_loops.cpp+++ b/src/common/snippets/src/lowered/pass/insert_loops.cpp@@ -4,11 +4,11 @@#include "snippets/lowered/pass/insert_loops.hpp"+#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_manager.hpp"#include "snippets/snippets_isa.hpp"#include "snippets/utils/utils.hpp"-#include "snippets/itt.hpp"namespace ov {namespace snippets {@@ -34,13 +34,22 @@ void InsertLoops::insertion(LinearIR& linear_ir, const LoopManagerPtr& loop_manaconst auto io_data_sizes = loop_info->get_data_sizes();const auto loop_begin = std::make_shared<op::LoopBegin>();- const auto loop_end = std::make_shared<op::LoopEnd>(loop_begin, work_amount, work_amount_increment, is_incremented, ptr_increments,- finalization_offsets, io_data_sizes, in_num, out_num, loop_id);+ const auto loop_end = std::make_shared<op::LoopEnd>(loop_begin,+ work_amount,+ work_amount_increment,+ is_incremented,+ ptr_increments,+ finalization_offsets,+ io_data_sizes,+ in_num,+ out_num,+ loop_id);const auto loop_bounds = loop_manager->get_loop_bounds(linear_ir, loop_id);const auto outer_loop_ids = loop_manager->get_outer_expr_loops(*loop_bounds.first, loop_id);- const auto loop_begin_expr = *linear_ir.insert_node(loop_begin, std::vector<PortConnectorPtr>{}, outer_loop_ids, false, loop_bounds.first);+ const auto loop_begin_expr =+ *linear_ir.insert_node(loop_begin, std::vector<PortConnectorPtr>{}, outer_loop_ids, false, loop_bounds.first);// Add LoopBegin port connectorloop_end_inputs.push_back(loop_begin_expr->get_output_port_connector(0));linear_ir.insert_node(loop_end, loop_end_inputs, outer_loop_ids, false, loop_bounds.second);@@ -72,7 +81,7 @@ bool InsertLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin,return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/insert_perf_count.cpp b/src/common/snippets/src/lowered/pass/insert_perf_count.cppindex 67fb9c52268..f71332410f3 100644--- a/src/common/snippets/src/lowered/pass/insert_perf_count.cpp+++ b/src/common/snippets/src/lowered/pass/insert_perf_count.cpp@@ -3,9 +3,10 @@//#ifdef SNIPPETS_DEBUG_CAPS-#include "snippets/lowered/pass/insert_perf_count.hpp"-#include "snippets/lowered/linear_ir.hpp"-#include "snippets/itt.hpp"+# include "snippets/lowered/pass/insert_perf_count.hpp"++# include "snippets/itt.hpp"+# include "snippets/lowered/linear_ir.hpp"namespace ov {namespace snippets {@@ -13,10 +14,12 @@ namespace lowered {namespace pass {InsertPerfCount::InsertPerfCount(std::map<std::string, std::string> boundary_op_names)- : RangedPass(), m_boundary_op_names(std::move(boundary_op_names)) {-}+ : RangedPass(),+ m_boundary_op_names(std::move(boundary_op_names)) {}-bool InsertPerfCount::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) {+bool InsertPerfCount::run(LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::InsertPerfCount")if (m_boundary_op_names.empty()) {const auto& first_op_name = linear_ir.begin()->get()->get_node()->get_friendly_name();@@ -35,28 +38,38 @@ bool InsertPerfCount::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt beperf_count_end_pos != linear_ir.cend()) {perf_count_end_pos++;}- OPENVINO_ASSERT(perf_count_end_pos != linear_ir.cend(), "Failed to find requested op name to insert PerfCountEnd");+ OPENVINO_ASSERT(perf_count_end_pos != linear_ir.cend(),+ "Failed to find requested op name to insert PerfCountEnd");const auto& perf_count_begin = std::make_shared<snippets::op::PerfCountBegin>();perf_count_begin->set_friendly_name(std::string("PerfCount_Begin_") + std::to_string(seq_number));const auto empty_inputs = std::vector<PortConnectorPtr>{};- linear_ir.insert_node(perf_count_begin, empty_inputs, perf_count_begin_pos->get()->get_loop_ids(), false, perf_count_begin_pos);+ linear_ir.insert_node(perf_count_begin,+ empty_inputs,+ perf_count_begin_pos->get()->get_loop_ids(),+ false,+ perf_count_begin_pos);// Unique ConsoleDumper for each PerfCounter pairstd::vector<std::shared_ptr<snippets::utils::Dumper>> dumpers;dumpers.push_back(std::make_shared<snippets::utils::ConsoleDumper>());- const auto& perf_count_end = std::make_shared<snippets::op::PerfCountEnd>(perf_count_begin->output(0), dumpers);+ const auto& perf_count_end =+ std::make_shared<snippets::op::PerfCountEnd>(perf_count_begin->output(0), dumpers);perf_count_end->set_friendly_name(std::string("PerfCount_End_") + std::to_string(seq_number));// linear_ir.insert has insert before behavior, need to increment perf_count_end_pos- linear_ir.insert_node(perf_count_end, empty_inputs, perf_count_end_pos->get()->get_loop_ids(), false, next(perf_count_end_pos));+ linear_ir.insert_node(perf_count_end,+ empty_inputs,+ perf_count_end_pos->get()->get_loop_ids(),+ false,+ next(perf_count_end_pos));seq_number++;}}return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ov#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 e58a4b40de4..edaae22691a 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@@ -3,16 +3,16 @@//#ifdef SNIPPETS_DEBUG_CAPS-#include "snippets/lowered/pass/insert_perf_count_verbose.hpp"+# 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/pass.hpp"-#include "snippets/lowered/pass/propagate_subtensors.hpp"-#include "snippets/lowered/pass/iter_handler.hpp"-#include "snippets/snippets_isa.hpp"-#include "snippets/utils/utils.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/utils/utils.hpp"namespace ov {namespace snippets {@@ -48,7 +48,8 @@ bool InsertPerfCountVerbose::run(snippets::lowered::LinearIR& linear_ir,const auto empty_inputs = std::vector<PortConnectorPtr>{};linear_ir.insert_node(perf_count_begin, empty_inputs, expr_it->get()->get_loop_ids(), false, expr_it);- const auto& perf_count_end = std::make_shared<snippets::op::PerfCountEnd>(perf_count_begin->output(0), dumpers, params);+ const auto& perf_count_end =+ std::make_shared<snippets::op::PerfCountEnd>(perf_count_begin->output(0), dumpers, params);perf_count_end->set_friendly_name(std::string("PerfCountVerbose_End_") + std::to_string(seq_number));linear_ir.insert_node(perf_count_end, empty_inputs, expr_it->get()->get_loop_ids(), false, next(expr_it));@@ -149,9 +150,9 @@ std::string InsertPerfCountVerbose::collect_params(const ov::snippets::lowered::return ss.str();}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ov-#endif // SNIPPETS_DEBUG_CAPS+#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 f1c55de3b2f..9103ddeaf82 100644--- a/src/common/snippets/src/lowered/pass/insert_reg_spills.cpp+++ b/src/common/snippets/src/lowered/pass/insert_reg_spills.cpp@@ -4,13 +4,12 @@#include "snippets/lowered/pass/insert_reg_spills.hpp"+#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"-#include "snippets/op/reg_spill.hpp"#include "snippets/op/brgemm.hpp"-#include "snippets/itt.hpp"+#include "snippets/op/reg_spill.hpp"#include "snippets/utils/utils.hpp"-namespace ov {namespace snippets {namespace lowered {@@ -40,11 +39,15 @@ bool InsertRegSpills::run(LinearIR& linear_ir) {used.insert(reg_info.second.begin(), reg_info.second.end());// Note: before the loop, we need to spill all live regs except for the ones used by the target expressionstd::set<Reg> regs_to_spill;- std::set_difference(loop_begin_live.begin(), loop_begin_live.end(),- used.begin(), used.end(),+ std::set_difference(loop_begin_live.begin(),+ loop_begin_live.end(),+ used.begin(),+ used.end(),std::inserter(regs_to_spill, regs_to_spill.begin()));- // 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())))+ // 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())))regs_to_spill.erase(r);if (regs_to_spill.empty())continue;@@ -53,8 +56,10 @@ bool InsertRegSpills::run(LinearIR& linear_ir) {const auto& affected_expr = *affected_it;const auto& live_old = affected_expr->get_live_regs();std::set<Reg> live_new;- std::set_difference(live_old.begin(), live_old.end(),- regs_to_spill.begin(), regs_to_spill.end(),+ std::set_difference(live_old.begin(),+ live_old.end(),+ regs_to_spill.begin(),+ regs_to_spill.end(),std::inserter(live_new, live_new.begin()));affected_expr->set_live_regs(live_new);}@@ -62,18 +67,28 @@ bool InsertRegSpills::run(LinearIR& linear_ir) {const auto begin = std::make_shared<op::RegSpillBegin>(regs_to_spill);const auto end = std::make_shared<op::RegSpillEnd>(begin);const auto loop_ids = start_it->get()->get_loop_ids();- OPENVINO_ASSERT(loop_ids == std::prev(stop_it)->get()->get_loop_ids(), "Inconsistent loop ids for RegSpill expressions");- const auto spill_begin_it = linear_ir.insert_node(begin, std::vector<PortConnectorPtr>{}, loop_ids,- false, start_it, std::vector<std::set<ExpressionPort>>{});+ OPENVINO_ASSERT(loop_ids == std::prev(stop_it)->get()->get_loop_ids(),+ "Inconsistent loop ids for RegSpill expressions");+ const auto spill_begin_it = linear_ir.insert_node(begin,+ std::vector<PortConnectorPtr>{},+ loop_ids,+ false,+ start_it,+ std::vector<std::set<ExpressionPort>>{});std::vector<Reg> vregs{regs_to_spill.begin(), regs_to_spill.end()};spill_begin_it->get()->set_reg_info({{}, vregs});// Note: spill_begin and spill_end do not use any registers, so:- // - the regs that are live on entry of spill_begin are the same as for its predecessor (since no regs consumed)+ // - the regs that are live on entry of spill_begin are the same as for its predecessor (since no regs+ // consumed)// - similarly, live regs for spill_end are the same as for its successor (since no regs produced)spill_begin_it->get()->set_live_regs(std::prev(spill_begin_it)->get()->get_live_regs());- const auto spill_end_it = linear_ir.insert_node(end, spill_begin_it->get()->get_output_port_connectors(), loop_ids,- false, stop_it, std::vector<std::set<ExpressionPort>>{});+ const auto spill_end_it = linear_ir.insert_node(end,+ spill_begin_it->get()->get_output_port_connectors(),+ loop_ids,+ false,+ stop_it,+ std::vector<std::set<ExpressionPort>>{});spill_end_it->get()->set_reg_info({vregs, {}});spill_end_it->get()->set_live_regs(std::next(spill_end_it)->get()->get_live_regs());modified = true;@@ -81,8 +96,7 @@ bool InsertRegSpills::run(LinearIR& linear_ir) {return modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov-+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/insert_specific_iterations.cpp b/src/common/snippets/src/lowered/pass/insert_specific_iterations.cppindex 570e878fd87..8eeeb9343d3 100644--- a/src/common/snippets/src/lowered/pass/insert_specific_iterations.cpp+++ b/src/common/snippets/src/lowered/pass/insert_specific_iterations.cpp@@ -4,15 +4,15 @@#include "snippets/lowered/pass/insert_specific_iterations.hpp"+#include <array>++#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/linear_ir_builder.hpp"#include "snippets/lowered/specific_loop_iter_types.hpp"-#include "snippets/op/memory_access.hpp"#include "snippets/op/buffer.hpp"+#include "snippets/op/memory_access.hpp"#include "snippets/utils/utils.hpp"-#include "snippets/itt.hpp"--#include <array>namespace ov {namespace snippets {@@ -20,8 +20,10 @@ namespace lowered {namespace pass {namespace {-void connect_cloned_body_with_buffers_outside(LinearIR::constExprIt cur_begin, LinearIR::constExprIt cur_end,- LinearIR::constExprIt res_begin, LinearIR::constExprIt res_end,+void connect_cloned_body_with_buffers_outside(LinearIR::constExprIt cur_begin,+ LinearIR::constExprIt cur_end,+ LinearIR::constExprIt res_begin,+ LinearIR::constExprIt res_end,LinearIR& linear_ir) {for (auto result_it = res_begin, original_it = cur_begin; result_it != res_end; ++result_it, ++original_it) {const auto& result_expr = *result_it;@@ -34,7 +36,8 @@ void connect_cloned_body_with_buffers_outside(LinearIR::constExprIt cur_begin, Lconst auto consumer_expr = consumer.get_expr();const auto buffer_expr = ov::as_type_ptr<BufferExpression>(consumer_expr);if (buffer_expr && std::find(cur_begin, cur_end, consumer.get_expr()) == cur_end) {- std::vector<PortDescriptorPtr> new_descs = {buffer_expr->get_input_port_descriptor(consumer.get_index())->clone()};+ std::vector<PortDescriptorPtr> new_descs = {+ buffer_expr->get_input_port_descriptor(consumer.get_index())->clone()};std::vector<PortConnectorPtr> new_inputs = {result_expr->get_output_port_connector(i)};OutputVector new_op_inputs = {result_expr->get_node()->output(i)};for (size_t j = 0; j < buffer_expr->get_input_count(); ++j) {@@ -44,7 +47,9 @@ void connect_cloned_body_with_buffers_outside(LinearIR::constExprIt cur_begin, Lnew_inputs.push_back(buffer_expr->get_input_port_connector(j));}const auto new_buffer_op = buffer_expr->get_node()->clone_with_new_inputs(new_op_inputs);- linear_ir.replace_with_expr({consumer_expr}, buffer_expr->clone_with_new_inputs(new_buffer_op, new_inputs, new_descs));+ linear_ir.replace_with_expr(+ {consumer_expr},+ buffer_expr->clone_with_new_inputs(new_buffer_op, new_inputs, new_descs));break;}}@@ -54,7 +59,8 @@ void connect_cloned_body_with_buffers_outside(LinearIR::constExprIt cur_begin, L}} // namespace-bool InsertSpecificIterations::is_decomposed_loop_needed(const UnifiedLoopInfoPtr& unified_loop_info, SpecificLoopIterType type,+bool InsertSpecificIterations::is_decomposed_loop_needed(const UnifiedLoopInfoPtr& unified_loop_info,+ SpecificLoopIterType type,size_t remaining_work_amount) {OPENVINO_ASSERT(unified_loop_info, "UnifiedLoopInfo is missed!");const auto increment = unified_loop_info->get_increment();@@ -62,57 +68,65 @@ bool InsertSpecificIterations::is_decomposed_loop_needed(const UnifiedLoopInfoPtconst auto is_dynamic = utils::is_dynamic_value(remaining_work_amount);switch (type) {- case (SpecificLoopIterType::FIRST_ITER):- return !unified_loop_info->get_handlers().get_passes<SpecificLoopIterType::FIRST_ITER>().empty() &&- (is_dynamic || remaining_work_amount >= increment);- case (SpecificLoopIterType::MAIN_BODY):- return is_dynamic || remaining_work_amount >= increment;- case (SpecificLoopIterType::LAST_ITER):- return (is_dynamic && increment > 1) || (!is_dynamic && remaining_work_amount > 0);- default:- OPENVINO_THROW("Unknown SpecificLoopIterType!");+ case (SpecificLoopIterType::FIRST_ITER):+ return !unified_loop_info->get_handlers().get_passes<SpecificLoopIterType::FIRST_ITER>().empty() &&+ (is_dynamic || remaining_work_amount >= increment);+ case (SpecificLoopIterType::MAIN_BODY):+ return is_dynamic || remaining_work_amount >= increment;+ case (SpecificLoopIterType::LAST_ITER):+ return (is_dynamic && increment > 1) || (!is_dynamic && remaining_work_amount > 0);+ default:+ OPENVINO_THROW("Unknown SpecificLoopIterType!");}}-size_t InsertSpecificIterations::get_decomposed_loop_work_amount(const UnifiedLoopInfoPtr& unified_loop_info, SpecificLoopIterType type,+size_t InsertSpecificIterations::get_decomposed_loop_work_amount(const UnifiedLoopInfoPtr& unified_loop_info,+ SpecificLoopIterType type,size_t remaining_work_amount) {OPENVINO_ASSERT(unified_loop_info, "UnifiedLoopInfo is missed!");const auto increment = unified_loop_info->get_increment();const auto is_dynamic = utils::is_dynamic_value(remaining_work_amount);switch (type) {- case (SpecificLoopIterType::FIRST_ITER):- // We don't set always `increment` for first iterations since in dynamic `work_amount` can be less than `increment`- return is_dynamic ? remaining_work_amount : increment;- case (SpecificLoopIterType::MAIN_BODY):- return is_dynamic ? remaining_work_amount : (remaining_work_amount / increment) * increment;- case (SpecificLoopIterType::LAST_ITER): {- OPENVINO_ASSERT(is_dynamic || remaining_work_amount < unified_loop_info->get_increment(),- "Last iter work amount (", remaining_work_amount,- ") must be less than the UnifiedLoopInfo's increment: ", unified_loop_info->get_increment());- return remaining_work_amount;- }- default:- OPENVINO_THROW("Unknown SpecificLoopIterType!");+ case (SpecificLoopIterType::FIRST_ITER):+ // We don't set always `increment` for first iterations since in dynamic `work_amount` can be less than+ // `increment`+ return is_dynamic ? remaining_work_amount : increment;+ case (SpecificLoopIterType::MAIN_BODY):+ return is_dynamic ? remaining_work_amount : (remaining_work_amount / increment) * increment;+ case (SpecificLoopIterType::LAST_ITER): {+ OPENVINO_ASSERT(is_dynamic || remaining_work_amount < unified_loop_info->get_increment(),+ "Last iter work amount (",+ remaining_work_amount,+ ") must be less than the UnifiedLoopInfo's increment: ",+ unified_loop_info->get_increment());+ return remaining_work_amount;+ }+ default:+ OPENVINO_THROW("Unknown SpecificLoopIterType!");}}-size_t InsertSpecificIterations::get_decomposed_loop_increment(const UnifiedLoopInfoPtr& unified_loop_info, SpecificLoopIterType type,+size_t InsertSpecificIterations::get_decomposed_loop_increment(const UnifiedLoopInfoPtr& unified_loop_info,+ SpecificLoopIterType type,size_t remaining_work_amount) {OPENVINO_ASSERT(unified_loop_info, "UnifiedLoopInfo is missed!");const auto increment = unified_loop_info->get_increment();switch (type) {- case (SpecificLoopIterType::FIRST_ITER):- case (SpecificLoopIterType::MAIN_BODY):- return increment;- case(SpecificLoopIterType::LAST_ITER):- return remaining_work_amount;- default:- OPENVINO_THROW("Unknown SpecificLoopIterType!");+ case (SpecificLoopIterType::FIRST_ITER):+ case (SpecificLoopIterType::MAIN_BODY):+ return increment;+ case (SpecificLoopIterType::LAST_ITER):+ return remaining_work_amount;+ default:+ OPENVINO_THROW("Unknown SpecificLoopIterType!");}}-LoopManager::LoopBounds InsertSpecificIterations::insert_copy_loop(LinearIR& linear_ir, const size_t loop_id, const LinearIR::constExprIt& insert_pos,- std::vector<LoopPort>& new_entry_ports, std::vector<LoopPort>& new_exit_ports) {+LoopManager::LoopBounds InsertSpecificIterations::insert_copy_loop(LinearIR& linear_ir,+ const size_t loop_id,+ const LinearIR::constExprIt& insert_pos,+ std::vector<LoopPort>& new_entry_ports,+ std::vector<LoopPort>& new_exit_ports) {const auto& loop_manager = linear_ir.get_loop_manager();const auto loop_bounds = loop_manager->get_loop_bounds(linear_ir, loop_id);const auto loop_begin_pos = loop_bounds.first;@@ -120,12 +134,18 @@ LoopManager::LoopBounds InsertSpecificIterations::insert_copy_loop(LinearIR& linExpressionMap expression_map;const auto& cloning_config = LinearIRBuilder::Config(false);- const auto& loop_copy_range = LinearIRBuilder(cloning_config).clone_range(loop_begin_pos, std::next(loop_end_pos), expression_map);+ const auto& loop_copy_range =+ LinearIRBuilder(cloning_config).clone_range(loop_begin_pos, std::next(loop_end_pos), expression_map);const auto new_loop_begin_pos = linear_ir.insert(insert_pos, loop_copy_range.begin(), loop_copy_range.end());const auto new_loop_end_pos = std::prev(insert_pos);- // Add connections between output of cloned bodies and Buffers from the current LinearIR (Buffers are connections between Loops)- connect_cloned_body_with_buffers_outside(loop_begin_pos, loop_end_pos, new_loop_begin_pos, new_loop_end_pos, linear_ir);+ // Add connections between output of cloned bodies and Buffers from the current LinearIR (Buffers are connections+ // between Loops)+ connect_cloned_body_with_buffers_outside(loop_begin_pos,+ loop_end_pos,+ new_loop_begin_pos,+ new_loop_end_pos,+ linear_ir);auto clone_ports = [&expression_map](const std::vector<LoopPort>& ports, std::vector<LoopPort>& new_ports) {new_ports.resize(ports.size());@@ -138,14 +158,18 @@ LoopManager::LoopBounds InsertSpecificIterations::insert_copy_loop(LinearIR& linclone_ports(original_loop_info->get_input_ports(), new_entry_ports);clone_ports(original_loop_info->get_output_ports(), new_exit_ports);- return { new_loop_begin_pos, new_loop_end_pos };+ return {new_loop_begin_pos, new_loop_end_pos};}-void InsertSpecificIterations::init_decomposed_loop(LinearIR& linear_ir, LinearIR::constExprIt begin, LinearIR::constExprIt end,- const ExpandedLoopInfoPtr& decomposed_loop_info, size_t unified_loop_id,+void InsertSpecificIterations::init_decomposed_loop(LinearIR& linear_ir,+ LinearIR::constExprIt begin,+ LinearIR::constExprIt end,+ const ExpandedLoopInfoPtr& decomposed_loop_info,+ size_t unified_loop_id,const std::shared_ptr<op::LoopEnd>& decomposed_loop_end) {const auto& loop_manager = linear_ir.get_loop_manager();- const auto new_id = loop_manager->replace_with_new_loop(linear_ir, begin, std::next(end), decomposed_loop_info, unified_loop_id);+ const auto new_id =+ loop_manager->replace_with_new_loop(linear_ir, begin, std::next(end), decomposed_loop_info, unified_loop_id);decomposed_loop_end->set_id(new_id);decomposed_loop_end->set_work_amount(decomposed_loop_info->get_work_amount());decomposed_loop_end->set_increment(decomposed_loop_info->get_increment());@@ -156,7 +180,9 @@ void InsertSpecificIterations::init_decomposed_loop(LinearIR& linear_ir, LinearIhandlers.run(linear_ir, std::next(begin), end);}-bool InsertSpecificIterations::decompose(LinearIR& linear_ir, LinearIR::constExprIt begin, LinearIR::constExprIt end,+bool InsertSpecificIterations::decompose(LinearIR& linear_ir,+ LinearIR::constExprIt begin,+ LinearIR::constExprIt end,const std::shared_ptr<op::LoopEnd>& loop_end) {const auto loop_id = loop_end->get_id();const auto& loop_manager = linear_ir.get_loop_manager();@@ -165,14 +191,15 @@ bool InsertSpecificIterations::decompose(LinearIR& linear_ir, LinearIR::constExpauto remaining_work_amount = unified_loop_info->get_work_amount();const auto is_wa_dynamic = utils::is_dynamic_value(remaining_work_amount);- static constexpr std::array<SpecificLoopIterType, 3> loop_iterations = {- SpecificLoopIterType::FIRST_ITER, SpecificLoopIterType::MAIN_BODY, SpecificLoopIterType::LAST_ITER- };+ static constexpr std::array<SpecificLoopIterType, 3> loop_iterations = {SpecificLoopIterType::FIRST_ITER,+ SpecificLoopIterType::MAIN_BODY,+ SpecificLoopIterType::LAST_ITER};auto decomposed = false;for (const auto& iter_type : loop_iterations) {if (is_decomposed_loop_needed(unified_loop_info, iter_type, remaining_work_amount)) {- const auto work_amount = get_decomposed_loop_work_amount(unified_loop_info, iter_type, remaining_work_amount);+ const auto work_amount =+ get_decomposed_loop_work_amount(unified_loop_info, iter_type, remaining_work_amount);const auto increment = get_decomposed_loop_increment(unified_loop_info, iter_type, remaining_work_amount);// Update remaining Loop work amount// Note: if work_amount is unknown and increment = 1, it means that a loop will iterate by whole work_amount@@ -191,23 +218,39 @@ bool InsertSpecificIterations::decompose(LinearIR& linear_ir, LinearIR::constExp// Otherwise we should update the current bodyif (remaining_work_amount > 0) {std::tie(decomposed_loop_begin_it, decomposed_loop_end_it) =- insert_copy_loop(linear_ir, loop_id, begin, decomposed_loop_entry_ports, decomposed_loop_exit_ports);+ insert_copy_loop(linear_ir,+ loop_id,+ begin,+ decomposed_loop_entry_ports,+ decomposed_loop_exit_ports);decomposed_loop_end = ov::as_type_ptr<op::LoopEnd>(decomposed_loop_end_it->get()->get_node());OPENVINO_ASSERT(decomposed_loop_end, "Cloned Loop does not contain LoopEnd op at the expected place.");// Only latest loop iterations must have summarized finalization offsets!// Since we inserted copy before the latest iterations, these copies should have reseted offsets- std::for_each(decomposed_finalization_offsets.begin(), decomposed_finalization_offsets.end(), [](int64_t& offset) {- if (!utils::is_dynamic_value(offset))- offset = 0;- });+ std::for_each(decomposed_finalization_offsets.begin(),+ decomposed_finalization_offsets.end(),+ [](int64_t& offset) {+ if (!utils::is_dynamic_value(offset))+ offset = 0;+ });}- const auto decomposed_loop_info = std::make_shared<ExpandedLoopInfo>(work_amount, increment,- decomposed_loop_entry_ports, decomposed_loop_exit_ports,- decomposed_ptr_increments, decomposed_finalization_offsets,- decomposed_data_sizes, iter_type, unified_loop_info);- init_decomposed_loop(linear_ir, decomposed_loop_begin_it, decomposed_loop_end_it, decomposed_loop_info, loop_id, decomposed_loop_end);+ const auto decomposed_loop_info = std::make_shared<ExpandedLoopInfo>(work_amount,+ increment,+ decomposed_loop_entry_ports,+ decomposed_loop_exit_ports,+ decomposed_ptr_increments,+ decomposed_finalization_offsets,+ decomposed_data_sizes,+ iter_type,+ unified_loop_info);+ init_decomposed_loop(linear_ir,+ decomposed_loop_begin_it,+ decomposed_loop_end_it,+ decomposed_loop_info,+ loop_id,+ decomposed_loop_end);decomposed = true;}@@ -216,15 +259,21 @@ bool InsertSpecificIterations::decompose(LinearIR& linear_ir, LinearIR::constExpreturn decomposed;}-bool InsertSpecificIterations::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) {+bool InsertSpecificIterations::run(LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::InsertSpecificIterations")bool modified = false;for (auto expr_it = begin; expr_it != end; ++expr_it) {if (const auto loop_end = ov::as_type_ptr<op::LoopEnd>(expr_it->get()->get_node())) {- const auto begin_it = linear_ir.find_before(expr_it, linear_ir.get_expr_by_node(loop_end->get_loop_begin()));+ const auto begin_it =+ linear_ir.find_before(expr_it, linear_ir.get_expr_by_node(loop_end->get_loop_begin()));const auto end_it = expr_it;- OPENVINO_ASSERT(decompose(linear_ir, begin_it, end_it, loop_end), "Loop with ID ", loop_end->get_id(), " has not been decomposed!");+ OPENVINO_ASSERT(decompose(linear_ir, begin_it, end_it, loop_end),+ "Loop with ID ",+ loop_end->get_id(),+ " has not been decomposed!");modified = true;}}@@ -232,7 +281,7 @@ bool InsertSpecificIterations::run(LinearIR& linear_ir, lowered::LinearIR::constreturn modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/iter_handler.cpp b/src/common/snippets/src/lowered/pass/iter_handler.cppindex 9c9ab69351c..34faa41658b 100644--- a/src/common/snippets/src/lowered/pass/iter_handler.cpp+++ b/src/common/snippets/src/lowered/pass/iter_handler.cpp@@ -83,18 +83,19 @@ std::shared_ptr<pass::PassBase> SetFillOffset::merge(const std::shared_ptr<pass:bool SetLoopIncrementOne::run(LinearIR& linear_ir, 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 = linear_ir.get_loop_manager()->get_loop_info<ov::snippets::lowered::ExpandedLoopInfo>(loop_end->get_id());+ const auto& loop_info =+ linear_ir.get_loop_manager()->get_loop_info<ov::snippets::lowered::ExpandedLoopInfo>(loop_end->get_id());loop_info->set_increment(1);loop_end->set_increment(1);return true;}-std::shared_ptr<snippets::lowered::pass::PassBase> SetLoopIncrementOne::merge(const std::shared_ptr<snippets::lowered::pass::PassBase>& other) {+std::shared_ptr<snippets::lowered::pass::PassBase> SetLoopIncrementOne::merge(+ const std::shared_ptr<snippets::lowered::pass::PassBase>& other) {return !other || ov::is_type<SetLoopIncrementOne>(other) ? std::make_shared<SetLoopIncrementOne>() : nullptr;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov-+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 741ab936055..87c3e27a6f4 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,17 +4,19 @@#include "snippets/lowered/pass/load_movebroadcast_to_broadcastload.hpp"+#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_manager.hpp"#include "snippets/snippets_isa.hpp"-#include "snippets/itt.hpp"namespace ov {namespace snippets {namespace lowered {namespace pass {-bool LoadMoveBroadcastToBroadcastLoad::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) {+bool LoadMoveBroadcastToBroadcastLoad::run(LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::LoadMoveBroadcastToBroadcastLoad")bool modified = false;@@ -26,10 +28,10 @@ bool LoadMoveBroadcastToBroadcastLoad::run(LinearIR& linear_ir, lowered::LinearIconst auto& interm_connector = expr->get_input_port_connector(0);const auto load_expr = interm_connector->get_source().get_expr();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())- continue;+ 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())+ continue;// Cannot rewrite Broadcast + Load if load has more than 1 user// or more than one input, or if Broadcast has several inputs@@ -46,10 +48,15 @@ bool LoadMoveBroadcastToBroadcastLoad::run(LinearIR& linear_ir, lowered::LinearIconst 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);- const auto broadcastload = std::make_shared<snippets::op::BroadcastLoad>(load_parent_node, *outshape.rbegin(), load->get_offset());+ const auto broadcastload =+ std::make_shared<snippets::op::BroadcastLoad>(load_parent_node, *outshape.rbegin(), load->get_offset());auto live_regs = load_expr->get_live_regs();- expr_it = linear_ir.replace_with_node({ load_expr, expr }, broadcastload, load_expr->get_loop_ids(), linear_ir.find(load_expr));- // Note: We have to set live regs manually, since this transformation is applied after all register-related passes.+ expr_it = linear_ir.replace_with_node({load_expr, expr},+ broadcastload,+ load_expr->get_loop_ids(),+ linear_ir.find(load_expr));+ // Note: We have to set live regs manually, since this transformation is applied after all register-related+ // passes.expr_it->get()->set_live_regs(std::move(live_regs));modified |= true;}@@ -57,7 +64,7 @@ bool LoadMoveBroadcastToBroadcastLoad::run(LinearIR& linear_ir, lowered::LinearIreturn modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 3cb055ddc4c..2991b814a6f 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@@ -2,14 +2,13 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/lowered/pass/mark_invariant_shape_path.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/utils/utils.hpp"-#include "snippets/itt.hpp"namespace ov {namespace snippets {@@ -51,20 +50,24 @@ size_t MarkInvariantShapePath::getInvariantPortShapePath(const ExpressionPort& p}void MarkInvariantShapePath::SetInvariantPortShapePath(const ExpressionPort& port, size_t value) {- OPENVINO_ASSERT(port.get_type() == ExpressionPort::Output, "SetInvariantPortShapePath can be used only for output port");+ OPENVINO_ASSERT(port.get_type() == ExpressionPort::Output,+ "SetInvariantPortShapePath can be used only for output port");auto& rt = get_rt_info(port);rt["InvariantShapePath"] = value;}ov::RTMap& MarkInvariantShapePath::get_rt_info(const ExpressionPort& port) {- const auto& source_port = port.get_type() == ExpressionPort::Input ? port.get_port_connector_ptr()->get_source() : port;+ const auto& source_port =+ port.get_type() == ExpressionPort::Input ? port.get_port_connector_ptr()->get_source() : port;const auto& node = source_port.get_expr()->get_node();const auto port_idx = source_port.get_index();assert(port_idx < node->get_output_size() && "Node has incompatible port count with the expression");return node->output(port_idx).get_rt_info();}-bool MarkInvariantShapePath::run(lowered::LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) {+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");bool modified = false;@@ -75,8 +78,10 @@ bool MarkInvariantShapePath::run(lowered::LinearIR& linear_ir, lowered::LinearIRsize_t color_path = 0;auto merge_paths = [&color_path](size_t lhs, size_t rhs) {- if (lhs == rhs || rhs == NOT_AFFECTING_PATH) return lhs;- if (lhs == NOT_AFFECTING_PATH) return rhs;+ if (lhs == rhs || rhs == NOT_AFFECTING_PATH)+ return lhs;+ if (lhs == NOT_AFFECTING_PATH)+ return rhs;return ++color_path;};@@ -104,8 +109,8 @@ bool MarkInvariantShapePath::run(lowered::LinearIR& linear_ir, lowered::LinearIRcurrent_color_path = merge_paths(current_color_path, input_path);}} else {- current_color_path = expr->get_input_count() > 0 ? getInvariantPortShapePath(expr->get_input_port(0))- : ++color_path;+ current_color_path =+ expr->get_input_count() > 0 ? getInvariantPortShapePath(expr->get_input_port(0)) : ++color_path;}if (!utils::is_dynamic_vdims(out_shape))@@ -120,7 +125,7 @@ bool MarkInvariantShapePath::run(lowered::LinearIR& linear_ir, lowered::LinearIRreturn modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/mark_loops.cpp b/src/common/snippets/src/lowered/pass/mark_loops.cppindex bdca317edce..43d5efb8ba5 100644--- a/src/common/snippets/src/lowered/pass/mark_loops.cpp+++ b/src/common/snippets/src/lowered/pass/mark_loops.cpp@@ -4,10 +4,10 @@#include "snippets/lowered/pass/mark_loops.hpp"+#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_manager.hpp"#include "snippets/snippets_isa.hpp"-#include "snippets/itt.hpp"namespace ov {namespace snippets {@@ -86,7 +86,7 @@ bool MarkLoops::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lreturn true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 bb01346f4ef..2d38c590ff8 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@@ -19,7 +19,8 @@ using namespace ov::snippets::pass;const size_t MHAParallelWAOptimizer::m_dim_M_idx = 1;-MHAParallelWAOptimizer::MHAParallelWAOptimizer(const lowered::LinearIRCPtr& linear_ir, const RuntimeConfigurator* configurator)+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())return;@@ -77,9 +78,10 @@ bool MHAParallelWAOptimizer::run(const lowered::LinearIR& linear_ir) {}for (size_t i = 0; i < m_configurator->get_io_num(); ++i) {- config->io_shapes[i] = m_unsqueezed_params.count(i)- ? SplitDimensionM::unsqueeze_m_dim(config->io_shapes[i], m_dim_M_idces[i])- : SplitDimensionM::reshape_m_dim(config->io_shapes[i], m_dim_M_idces[i], new_batch_dim, new_kernel_dim);+ config->io_shapes[i] =+ m_unsqueezed_params.count(i)+ ? SplitDimensionM::unsqueeze_m_dim(config->io_shapes[i], m_dim_M_idces[i])+ : SplitDimensionM::reshape_m_dim(config->io_shapes[i], m_dim_M_idces[i], new_batch_dim, new_kernel_dim);}config->io_layouts = m_optimized_layouts;return true;@@ -112,7 +114,9 @@ std::unordered_set<lowered::ExpressionPtr> MHAParallelWAOptimizer::find_applicab});return loop_by_m;};- return std::all_of(brgemms.begin(), brgemms.end(), applicable_brgemm) ? brgemms : std::unordered_set<lowered::ExpressionPtr>{};+ return std::all_of(brgemms.begin(), brgemms.end(), applicable_brgemm)+ ? brgemms+ : std::unordered_set<lowered::ExpressionPtr>{};}std::unordered_set<size_t> MHAParallelWAOptimizer::find_unsqueezed_params(@@ -171,7 +175,7 @@ std::vector<lowered::ExpandedLoopInfoPtr> MHAParallelWAOptimizer::find_loops_to_return loops_to_split;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ov\ No newline at end of filediff --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 a413c570a39..5c8872f0c54 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,10 +4,10 @@#include "snippets/lowered/pass/move_result_out_of_loop.hpp"+#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_manager.hpp"#include "snippets/snippets_isa.hpp"-#include "snippets/itt.hpp"namespace ov {namespace snippets {@@ -66,7 +66,7 @@ bool MoveResultOutOfLoop::run(LinearIR& linear_ir) {return modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 6fac8eaaced..8a149be360c 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,10 +4,10 @@#include "snippets/lowered/pass/move_scalar_to_consumer.hpp"+#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_manager.hpp"#include "snippets/snippets_isa.hpp"-#include "snippets/itt.hpp"namespace ov {namespace snippets {@@ -56,7 +56,7 @@ bool MoveScalarToConsumer::run(LinearIR& linear_ir) {return modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 3431a198f90..7e9eb7c171a 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,16 +4,17 @@#include "snippets/lowered/pass/normalize_buffer_reg_groups.hpp"-#include "snippets/op/buffer.hpp"#include "snippets/itt.hpp"-+#include "snippets/op/buffer.hpp"namespace ov {namespace snippets {namespace lowered {namespace pass {-bool NormalizeBufferRegisterGroups::run(lowered::LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) {+bool NormalizeBufferRegisterGroups::run(lowered::LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::NormalizeBufferRegisterGroups");// [ original Buffer reg group -> normalized ]@@ -29,7 +30,7 @@ bool NormalizeBufferRegisterGroups::run(lowered::LinearIR& linear_ir, lowered::Lreturn buffer_reg_groups.size();}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/normalize_loop_ids.cpp b/src/common/snippets/src/lowered/pass/normalize_loop_ids.cppindex c995e0ee047..249c83aaa77 100644--- a/src/common/snippets/src/lowered/pass/normalize_loop_ids.cpp+++ b/src/common/snippets/src/lowered/pass/normalize_loop_ids.cpp@@ -4,10 +4,9 @@#include "snippets/lowered/pass/normalize_loop_ids.hpp"+#include "snippets/itt.hpp"#include "snippets/lowered/loop_manager.hpp"#include "snippets/op/loop.hpp"-#include "snippets/itt.hpp"-namespace ov {namespace snippets {@@ -33,7 +32,8 @@ void NormalizeLoopIDs::update_linear_ir(lowered::LinearIR& linear_ir, const IDMaprevious_loop_ids.first = expr_loop_ids;std::for_each(expr_loop_ids.begin(), expr_loop_ids.end(), [&loop_id_map](size_t& id) {- OPENVINO_ASSERT(loop_id_map.count(id) > 0, "Expression is marked by LoopID that has not been found in the map!");+ OPENVINO_ASSERT(loop_id_map.count(id) > 0,+ "Expression is marked by LoopID that has not been found in the map!");id = loop_id_map.at(id);});expr->set_loop_ids(expr_loop_ids);@@ -55,7 +55,8 @@ bool NormalizeLoopIDs::run(lowered::LinearIR& linear_ir) {loop_id_map[old_id] = new_id;continue;}- OPENVINO_ASSERT(m_has_specific_loops, "NormalizeLoopIDs failed: LinearIR contains unified loops with the same IDs!");+ OPENVINO_ASSERT(m_has_specific_loops,+ "NormalizeLoopIDs failed: LinearIR contains unified loops with the same IDs!");}}@@ -70,7 +71,7 @@ bool NormalizeLoopIDs::run(lowered::LinearIR& linear_ir) {return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/optimize_domain.cpp b/src/common/snippets/src/lowered/pass/optimize_domain.cppindex 890e5878b2a..39064249573 100644--- a/src/common/snippets/src/lowered/pass/optimize_domain.cpp+++ b/src/common/snippets/src/lowered/pass/optimize_domain.cpp@@ -6,23 +6,21 @@#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"-#include "snippets/snippets_isa.hpp"#include "snippets/shape_inference/shape_inference.hpp"+#include "snippets/snippets_isa.hpp"#include "snippets/utils/utils.hpp"-namespace ov {namespace snippets {namespace lowered {namespace pass {-OptimizeDomain::OptimizeDomain(size_t& tile_rank) : Pass(), m_tile_rank(tile_rank) {-}+OptimizeDomain::OptimizeDomain(size_t& tile_rank) : Pass(), m_tile_rank(tile_rank) {}size_t OptimizeDomain::optimize(std::vector<VectorDims>& input_shapes,- VectorDims& master_shape,- const size_t total_work_amount,- const size_t min_parallel_work_amount,- const size_t min_jit_work_amount) {+ VectorDims& master_shape,+ 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;@@ -34,15 +32,13 @@ size_t OptimizeDomain::optimize(std::vector<VectorDims>& input_shapes,dims[0] = 1;};// Check that neither of the two last dims is broadcasted, so they can be collapsed- auto LastDimsNotBroadcasted = [] (const std::vector<VectorDims>& input_shapes, const VectorDims& master_shape) {+ auto LastDimsNotBroadcasted = [](const std::vector<VectorDims>& input_shapes, const VectorDims& master_shape) {const auto master_last = *master_shape.rbegin();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;- });+ 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;+ });};// Index of InputShape with the minimal rank@@ -54,11 +50,10 @@ size_t OptimizeDomain::optimize(std::vector<VectorDims>& input_shapes,size_t jit_work_amount = master_shape.back();size_t num_dims_collapsed = 0;- while (jit_work_amount < min_jit_work_amount &&- (num_dims_collapsed + 1) < input_shapes[min_rank_idx].size() &&+ 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);@@ -73,8 +68,8 @@ inline bool OptimizeDomain::can_increase_jit_work_amount(const VectorDims& masteconst size_t min_parallel_work_amount,const size_t total_work_amount) {return master_shape.size() > 2 &&- master_shape[master_shape.size() - 1] * master_shape[master_shape.size() - 2] *- min_parallel_work_amount <= total_work_amount;+ master_shape[master_shape.size() - 1] * master_shape[master_shape.size() - 2] * min_parallel_work_amount <=+ total_work_amount;}bool OptimizeDomain::run(snippets::lowered::LinearIR& linear_ir) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::OptimizeDomain")@@ -98,7 +93,8 @@ bool OptimizeDomain::run(snippets::lowered::LinearIR& linear_ir) {return false;}- OPENVINO_ASSERT(config.m_min_parallel_work_amount != 0, "OptimizeDomain: Min parallel work amount can't equal to zero");+ OPENVINO_ASSERT(config.m_min_parallel_work_amount != 0,+ "OptimizeDomain: Min parallel work amount can't equal to zero");std::vector<VectorDims> input_shapes;bool blocked_input_shapes = false;for (const auto& param : linear_ir.get_parameters()) {@@ -112,26 +108,24 @@ bool OptimizeDomain::run(snippets::lowered::LinearIR& linear_ir) {// If RankNormalization prepends dims, then the dims should be ignored during domain optimization// to avoid passing already incremented shapes to linear_ir.shape_infer()}- const ExpressionPtr& shape_producing_expr = blocked_input_shapes ?- first_consumer :- param;+ const ExpressionPtr& shape_producing_expr = blocked_input_shapes ? first_consumer : param;const auto& shape = utils::get_preordered_vdims(shape_producing_expr->get_output_port(0));- OPENVINO_ASSERT(std::none_of(shape.begin(), shape.end(),- [](size_t d) { return utils::is_dynamic_value(d); }),+ OPENVINO_ASSERT(std::none_of(shape.begin(),+ shape.end(),+ [](size_t d) {+ return utils::is_dynamic_value(d);+ }),"OptimizeDomain pass does not support dynamic shapes");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>());- const auto num_dims_collapsed = blocked_input_shapes ?- 0 :- optimize(input_shapes,- master_shape,- total_work_amount,- config.m_min_parallel_work_amount,- config.m_min_kernel_work_amount);+ const auto total_work_amount =+ std::accumulate(master_shape.begin(), master_shape.end(), (size_t)1, std::multiplies<size_t>());+ const auto num_dims_collapsed = blocked_input_shapes ? 0+ : optimize(input_shapes,+ master_shape,+ total_work_amount,+ config.m_min_parallel_work_amount,+ config.m_min_kernel_work_amount);if (num_dims_collapsed > 0) {std::vector<VectorDimsRef> infer_shapes;infer_shapes.reserve(input_shapes.size());@@ -147,7 +141,7 @@ bool OptimizeDomain::run(snippets::lowered::LinearIR& linear_ir) {return num_dims_collapsed > 0;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ov\ No newline at end of filediff --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 24ba946c923..05cdb9f48db 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,18 +4,20 @@#include "snippets/lowered/pass/optimize_loop_single_evaluation.hpp"-#include "snippets/lowered/loop_manager.hpp"+#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"+#include "snippets/lowered/loop_manager.hpp"#include "snippets/op/loop.hpp"#include "snippets/utils/utils.hpp"-#include "snippets/itt.hpp"namespace ov {namespace snippets {namespace lowered {namespace pass {-bool OptimizeLoopSingleEvaluation::run(lowered::LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) {+bool OptimizeLoopSingleEvaluation::run(lowered::LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::OptimizeLoopSingleEvaluation")const auto& loop_manager = linear_ir.get_loop_manager();@@ -48,8 +50,7 @@ bool OptimizeLoopSingleEvaluation::run(lowered::LinearIR& linear_ir, lowered::Lireturn is_modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov-+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/pass.cpp b/src/common/snippets/src/lowered/pass/pass.cppindex 3ea83d43b5b..a181e2eaa12 100644--- a/src/common/snippets/src/lowered/pass/pass.cpp+++ b/src/common/snippets/src/lowered/pass/pass.cpp@@ -3,8 +3,8 @@//#include "snippets/lowered/pass/pass.hpp"-#include "snippets/utils/linear_ir_pass_dumper.hpp"+#include "snippets/utils/linear_ir_pass_dumper.hpp"#include "snippets/utils/utils.hpp"namespace ov {@@ -74,13 +74,15 @@ void PassPipeline::register_positioned_passes(const std::vector<PositionedPassLo}PassPipeline PassPipeline::merge_pipelines(const PassPipeline& lhs, const PassPipeline& rhs) {- OPENVINO_ASSERT(*lhs.get_pass_config() == *rhs.get_pass_config(), "2 passes with different PassConfigs can't be merged.");+ OPENVINO_ASSERT(*lhs.get_pass_config() == *rhs.get_pass_config(),+ "2 passes with different PassConfigs can't be merged.");const auto& lhs_passes = lhs.get_passes();std::unordered_map<ov::DiscreteTypeInfo, std::shared_ptr<lowered::pass::PassBase>> lhs_passes_map;for (const auto& pass : lhs_passes) {lhs_passes_map[pass->get_type_info()] = pass;}- OPENVINO_ASSERT(lhs_passes_map.size() == lhs_passes.size(), "The pass pipeline must not contain several passes with equal type info");+ OPENVINO_ASSERT(lhs_passes_map.size() == lhs_passes.size(),+ "The pass pipeline must not contain several passes with equal type info");PassPipeline merged_pipeline;for (const auto& rhs_pass : rhs.get_passes()) {@@ -96,7 +98,7 @@ PassPipeline PassPipeline::merge_pipelines(const PassPipeline& lhs, const PassPireturn merged_pipeline;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/pass_config.cpp b/src/common/snippets/src/lowered/pass/pass_config.cppindex 6d4888e81c7..cb0528f34b0 100644--- a/src/common/snippets/src/lowered/pass/pass_config.cpp+++ b/src/common/snippets/src/lowered/pass/pass_config.cpp@@ -4,7 +4,6 @@#include "snippets/lowered/pass/pass_config.hpp"-namespace ov {namespace snippets {namespace lowered {@@ -36,7 +35,7 @@ bool operator!=(const PassConfig& lhs, const PassConfig& rhs) {return !(lhs == rhs);}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/propagate_buffer_offset.cpp b/src/common/snippets/src/lowered/pass/propagate_buffer_offset.cppindex 4e7d17cf284..7c7f72140ab 100644--- a/src/common/snippets/src/lowered/pass/propagate_buffer_offset.cpp+++ b/src/common/snippets/src/lowered/pass/propagate_buffer_offset.cpp@@ -2,21 +2,19 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/lowered/pass/propagate_buffer_offset.hpp"-#include "snippets/op/memory_access.hpp"-#include "snippets/op/loop.hpp"+#include "snippets/itt.hpp"#include "snippets/op/buffer.hpp"+#include "snippets/op/loop.hpp"+#include "snippets/op/memory_access.hpp"#include "snippets/utils/utils.hpp"-#include "snippets/itt.hpp"namespace ov {namespace snippets {namespace lowered {namespace pass {-void PropagateBufferOffset::propagate(const BufferExpressionPtr& buffer_expr) {// If Buffer has offset We set this offset in the connected MemoryAccess ops// to correctly read and write data because all Buffers have the common data pointer on buffer scratchpad@@ -34,7 +32,7 @@ void PropagateBufferOffset::propagate(const BufferExpressionPtr& buffer_expr) {memory_access->set_output_offset(offset, port);} else {OPENVINO_THROW(- "PropagateBufferOffset didn't find the connected MemoryAccess op to Buffer for offset propagation");+ "PropagateBufferOffset didn't find the connected MemoryAccess op to Buffer for offset propagation");}}// Propagate to down: in Load. Buffer can have several Load@@ -52,8 +50,8 @@ void PropagateBufferOffset::propagate(const BufferExpressionPtr& buffer_expr) {// After Loop initialization, Buffer can be connected to LoopEnd - it's okcontinue;} else {- OPENVINO_THROW(- "PropagateBufferOffset didn't find the connected MemoryAccess op to Buffer for offset propagation for offset propagation");+ OPENVINO_THROW("PropagateBufferOffset didn't find the connected MemoryAccess op to Buffer for offset "+ "propagation for offset propagation");}}}@@ -67,7 +65,7 @@ bool PropagateBufferOffset::run(lowered::LinearIR& linear_ir) {return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/propagate_subtensors.cpp b/src/common/snippets/src/lowered/pass/propagate_subtensors.cppindex 08997d08cc3..2f08f13f964 100644--- a/src/common/snippets/src/lowered/pass/propagate_subtensors.cpp+++ b/src/common/snippets/src/lowered/pass/propagate_subtensors.cpp@@ -4,11 +4,11 @@#include "snippets/lowered/pass/propagate_subtensors.hpp"+#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_manager.hpp"#include "snippets/snippets_isa.hpp"#include "snippets/utils/utils.hpp"-#include "snippets/itt.hpp"namespace ov {namespace snippets {@@ -38,7 +38,7 @@ namespace {// new subtensor [32, FULL_DIM] - has not been changed! But should be [?, FULL_DIM]// Conclusion: we have to distinguish forced dynamic value with existing dynamic values in shape and subtensor-constexpr size_t NEW_DEFAULT_VALUE = SIZE_MAX - 2;+constexpr size_t NEW_DEFAULT_VALUE = SIZE_MAX - 2;constexpr size_t FORCED_DYNAMIC_VALUE = SIZE_MAX - 3;void propagate_updated_subtensor_through_loop(const LinearIR& linear_ir,@@ -50,7 +50,8 @@ void propagate_updated_subtensor_through_loop(const LinearIR& linear_ir,// Marks the forced dynamic valuenew_dim_value = utils::is_dynamic_value(new_dim_value) ? FORCED_DYNAMIC_VALUE : new_dim_value;OPENVINO_ASSERT(snippets::utils::implication(most_outer_loop, new_dim_value != NEW_DEFAULT_VALUE),- "if the updated subtensor propagation was called for the outer loop, new_dim_value must not be equal to default value");+ "if the updated subtensor propagation was called for the outer loop, new_dim_value must not be "+ "equal to default value");std::map<lowered::PortDescriptorPtr, snippets::VectorDims> original_shapes;// First step: set new dim value to the corresponding input_ports' dimensions@@ -63,7 +64,9 @@ void propagate_updated_subtensor_through_loop(const LinearIR& linear_ir,desc->set_subtensor_dim(port.get_dim_idx(), new_dim_value);}- const auto parent_desc = expr->get_input_port_connector(port.get_expr_port()->get_index())->get_source().get_descriptor_ptr();+ const auto parent_desc = expr->get_input_port_connector(port.get_expr_port()->get_index())+ ->get_source()+ .get_descriptor_ptr();const auto& parent_shape = parent_desc->get_shape();if (original_shapes.find(parent_desc) == original_shapes.end()) {original_shapes[parent_desc] = parent_shape;@@ -79,7 +82,8 @@ void propagate_updated_subtensor_through_loop(const LinearIR& linear_ir,if (port.is_processed()) {const auto desc = port.get_expr_port()->get_descriptor_ptr();const auto expr = port.get_expr_port()->get_expr();- const auto parent_desc = expr->get_input_port_connector(port.get_expr_port()->get_index())->get_source().get_descriptor_ptr();+ const auto parent_desc =+ expr->get_input_port_connector(port.get_expr_port()->get_index())->get_source().get_descriptor_ptr();const auto& parent_shape = parent_desc->get_shape();const auto& desc_subtensor = desc->get_subtensor();@@ -88,7 +92,8 @@ void propagate_updated_subtensor_through_loop(const LinearIR& linear_ir,original_shapes[parent_desc] = parent_shape;}auto new_shape = parent_shape;- new_shape[*(desc->get_layout().rbegin() + port.get_dim_idx())] = *(desc_subtensor.rbegin() + port.get_dim_idx());+ new_shape[*(desc->get_layout().rbegin() + port.get_dim_idx())] =+ *(desc_subtensor.rbegin() + port.get_dim_idx());parent_desc->set_shape(new_shape);}}@@ -98,14 +103,18 @@ void propagate_updated_subtensor_through_loop(const LinearIR& linear_ir,for (const auto& desc : descs) {const auto& subtensor = desc->get_subtensor();if (!subtensor.empty()) {- auto planar_dims = is_input ? snippets::utils::get_planar_vdims(desc->get_shape(), desc->get_layout())- : snippets::utils::get_preordered_vdims(desc->get_shape(), desc->get_layout());+ auto planar_dims = is_input+ ? snippets::utils::get_planar_vdims(desc->get_shape(), desc->get_layout())+ : snippets::utils::get_preordered_vdims(desc->get_shape(), desc->get_layout());const size_t subtensor_start = planar_dims.size() - subtensor.size();VectorDims new_subtensor(planar_dims.begin() + subtensor_start, planar_dims.end());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]);+ // 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]);}desc->set_subtensor(new_subtensor);}@@ -185,8 +194,7 @@ std::shared_ptr<pass::PassBase> UpdateSubtensors::merge(const std::shared_ptr<pareturn std::make_shared<UpdateSubtensors>(merged_size);}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov-+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/reduce_decomposition.cpp b/src/common/snippets/src/lowered/pass/reduce_decomposition.cppindex 5a7a84a4dd8..01a0edf3b93 100644--- a/src/common/snippets/src/lowered/pass/reduce_decomposition.cpp+++ b/src/common/snippets/src/lowered/pass/reduce_decomposition.cpp@@ -4,12 +4,12 @@#include "snippets/lowered/pass/reduce_decomposition.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/snippets_isa.hpp"#include "snippets/utils/utils.hpp"-#include "snippets/itt.hpp"namespace ov {namespace snippets {@@ -30,10 +30,12 @@ bool ReduceDecomposition::run(LinearIR& linear_ir, LinearIR::constExprIt begin,return reduce_initial_values.at(type_info);};- auto insert_accumulation_node = [&linear_ir](const LinearIR::constExprIt& expr_it,- const ov::Output<ov::Node>& input0,- const ov::Output<ov::Node>& input1,- const ov::DiscreteTypeInfo& type_info) -> std::pair<LinearIR::constExprIt, std::shared_ptr<ov::Node>> {+ auto insert_accumulation_node =+ [&linear_ir](+ const LinearIR::constExprIt& expr_it,+ const ov::Output<ov::Node>& input0,+ const ov::Output<ov::Node>& input1,+ 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()) {@@ -43,9 +45,11 @@ bool ReduceDecomposition::run(LinearIR& linear_ir, LinearIR::constExprIt begin,}};- auto insert_horizon_node = [&linear_ir](const LinearIR::constExprIt& expr_it,- const ov::Output<ov::Node>& input,- const ov::DiscreteTypeInfo& type_info) -> std::pair<LinearIR::constExprIt, std::shared_ptr<ov::Node>> {+ auto insert_horizon_node =+ [&linear_ir](+ const LinearIR::constExprIt& expr_it,+ const ov::Output<ov::Node>& input,+ 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()) {@@ -66,8 +70,10 @@ bool ReduceDecomposition::run(LinearIR& linear_ir, LinearIR::constExprIt begin,const auto& reduce_type_info = reduce->get_type_info();const auto& input_shape = reduce_expr->get_input_port_descriptor(0)->get_shape();const auto work_amount = *(input_shape.rbegin());- const auto increment = utils::is_dynamic_value(work_amount) || m_vector_size <= work_amount ? m_vector_size : work_amount;- OPENVINO_ASSERT(reduce->get_axis() == input_shape.size() - 1, "ReduceDecomposition supports only Reduce by last dimension.");+ const auto increment =+ utils::is_dynamic_value(work_amount) || m_vector_size <= work_amount ? m_vector_size : work_amount;+ OPENVINO_ASSERT(reduce->get_axis() == input_shape.size() - 1,+ "ReduceDecomposition supports only Reduce by last dimension.");// Float constant values in byte representationconst auto fill_value = get_initial_value(reduce_type_info);@@ -77,7 +83,8 @@ bool ReduceDecomposition::run(LinearIR& linear_ir, LinearIR::constExprIt begin,const auto initial_fill = linear_ir.insert_node<op::Fill>(expr_it, vector_buffer.second, 0, fill_value);// Reduce loop- const auto fill = linear_ir.insert_node<op::Fill>(expr_it, reduce->get_input_source_output(0), increment, fill_value);+ const auto fill =+ linear_ir.insert_node<op::Fill>(expr_it, reduce->get_input_source_output(0), increment, fill_value);const auto accumulation = insert_accumulation_node(expr_it, fill.second, initial_fill.second, reduce_type_info);const auto reduce_loop_id = loop_manager->mark_loop(@@ -97,7 +104,8 @@ bool ReduceDecomposition::run(LinearIR& linear_ir, LinearIR::constExprIt begin,// Transfer original ExpressionPortsreplace_input_port_connectors({fill.first->get()->get_input_port(0)}, reduce_expr->get_input_port_connector(0));- replace_input_port_connectors(reduce_expr->get_output_port_connector(0)->get_consumers(), horizon.first->get()->get_output_port_connector(0));+ replace_input_port_connectors(reduce_expr->get_output_port_connector(0)->get_consumers(),+ horizon.first->get()->get_output_port_connector(0));// Update input shapes of consumersconst auto reduce_consumers = horizon.first->get()->get_output_port_connector(0)->get_consumers();@@ -109,12 +117,8 @@ bool ReduceDecomposition::run(LinearIR& linear_ir, LinearIR::constExprIt begin,const std::vector<ExpressionPort> input_ports{(*fill.first)->get_input_port(0)};const std::vector<ExpressionPort> output_ports{(*horizon.first)->get_output_port(0)};for (auto loop_id : reduce_expr->get_loop_ids()) {- loop_manager->expression_replacement(vector_buffer.first,- expr_it,- reduce_expr,- loop_id,- input_ports,- output_ports);+ loop_manager+ ->expression_replacement(vector_buffer.first, expr_it, reduce_expr, loop_id, input_ports, output_ports);}expr_it = linear_ir.erase(expr_it);@@ -123,7 +127,7 @@ bool ReduceDecomposition::run(LinearIR& linear_ir, LinearIR::constExprIt begin,return modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/serialize_base.cpp b/src/common/snippets/src/lowered/pass/serialize_base.cppindex 1535497c90a..9c69ee655bd 100644--- a/src/common/snippets/src/lowered/pass/serialize_base.cpp+++ b/src/common/snippets/src/lowered/pass/serialize_base.cpp@@ -23,7 +23,7 @@ std::string SerializeBase::get_bin_path_from_xml(const std::string& xml_path) {#endif}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/serialize_control_flow.cpp b/src/common/snippets/src/lowered/pass/serialize_control_flow.cppindex 1901753d299..ccc9835c06f 100644--- a/src/common/snippets/src/lowered/pass/serialize_control_flow.cpp+++ b/src/common/snippets/src/lowered/pass/serialize_control_flow.cpp@@ -7,10 +7,10 @@#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_manager.hpp"#include "snippets/op/serialization_node.hpp"#include "snippets/snippets_isa.hpp"-#include "snippets/lowered/loop_manager.hpp"-#include "snippets/lowered/linear_ir_builder.hpp"namespace ov {namespace snippets {@@ -57,7 +57,9 @@ bool SerializeControlFlow::run(const LinearIR& original_linear_ir) {OPENVINO_THROW("Unknown LoopInfo type");}}- serialization_node = std::make_shared<op::SerializationNode>(ov::OutputVector{serialization_node, loop_begin_serialization_node}, expr);+ serialization_node = std::make_shared<op::SerializationNode>(+ ov::OutputVector{serialization_node, loop_begin_serialization_node},+ expr);} else {serialization_node = std::make_shared<op::SerializationNode>(ov::OutputVector{serialization_node}, expr);if (auto loop_begin = ov::as_type_ptr<snippets::op::LoopBegin>(node)) {@@ -67,11 +69,12 @@ bool SerializeControlFlow::run(const LinearIR& original_linear_ir) {}auto last_node = std::make_shared<ov::op::v0::Result>(serialization_node);last_node->set_friendly_name("End");- const auto model = std::make_shared<ov::Model>(ResultVector{last_node}, ParameterVector{first_node}, "Lowered_IR_Control_Flow");+ const auto model =+ std::make_shared<ov::Model>(ResultVector{last_node}, ParameterVector{first_node}, "Lowered_IR_Control_Flow");return ov::pass::Serialize(m_xml_path, m_bin_path).run_on_model(model);}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/serialize_data_flow.cpp b/src/common/snippets/src/lowered/pass/serialize_data_flow.cppindex 4136c637a03..5ba2ebb9b86 100644--- a/src/common/snippets/src/lowered/pass/serialize_data_flow.cpp+++ b/src/common/snippets/src/lowered/pass/serialize_data_flow.cpp@@ -50,7 +50,7 @@ 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 pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 8f9f672cb3f..adb0875e292 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,11 +4,11 @@#include "snippets/lowered/pass/set_buffer_reg_group.hpp"-#include "snippets/lowered/pass/mark_invariant_shape_path.hpp"+#include "snippets/itt.hpp"+#include "snippets/lowered/expressions/buffer_expression.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/loop_manager.hpp"-#include "snippets/lowered/expressions/buffer_expression.hpp"-#include "snippets/itt.hpp"+#include "snippets/lowered/pass/mark_invariant_shape_path.hpp"namespace ov {namespace snippets {@@ -19,7 +19,7 @@ namespace {inline size_t index(size_t col_num, size_t row, size_t col) {return row * col_num + col;}-} // namespace+} // namespacesize_t SetBufferRegGroup::get_buffer_idx(const BufferExpressionPtr& target, const BufferPool& pool) {const auto iter = std::find(pool.cbegin(), pool.cend(), target);@@ -38,7 +38,8 @@ bool SetBufferRegGroup::can_be_in_one_reg_group(const UnifiedLoopInfo::LoopPortIconst auto rhs_is_incremented = rhs_info.port.is_incremented();const auto equal_is_incremented = lhs_is_incremented == rhs_is_incremented;return equal_invariant_shape_paths && equal_is_incremented &&- (equal_element_type_sizes || !lhs_is_incremented || (lhs_info.desc.ptr_increment == 0 && lhs_info.desc.finalization_offset == 0));+ (equal_element_type_sizes || !lhs_is_incremented ||+ (lhs_info.desc.ptr_increment == 0 && lhs_info.desc.finalization_offset == 0));}bool SetBufferRegGroup::are_adjacent(const BufferMap::value_type& lhs, const BufferMap::value_type& rhs) {@@ -49,18 +50,23 @@ bool SetBufferRegGroup::are_adjacent(const BufferMap::value_type& lhs, const Bufreturn !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 (lhs_ids.size() == rhs_ids.size()) // If the count of outer Loops are equal, it means that outer loops are already different+ // 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() &&+ 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;+ 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, const BufferMap::value_type& rhs, const BufferPool& buffers,+void SetBufferRegGroup::update_adj_matrix(const BufferMap::value_type& lhs,+ const BufferMap::value_type& rhs,+ const BufferPool& buffers,std::vector<bool>& adj) {const auto size = buffers.size();const auto lhs_idx = get_buffer_idx(lhs.first, buffers);@@ -74,7 +80,9 @@ void SetBufferRegGroup::update_adj_matrix(const BufferMap::value_type& lhs, cons}}-std::vector<bool> SetBufferRegGroup::create_adjacency_matrix(const LoopManagerPtr& loop_manager, LinearIR::constExprIt begin, LinearIR::constExprIt end,+std::vector<bool> SetBufferRegGroup::create_adjacency_matrix(const LoopManagerPtr& loop_manager,+ LinearIR::constExprIt begin,+ LinearIR::constExprIt end,const BufferPool& pool) {// The sync point to check for adjacency is Loop because only in Loop we increment pointers.// So if some Buffers in the one Loop have conflict (cannot be inplace: the different ptr increment and data sizes)@@ -85,7 +93,7 @@ std::vector<bool> SetBufferRegGroup::create_adjacency_matrix(const LoopManagerPtadj[index(size, i, i)] = true;for (auto expr_it = begin; expr_it != end; expr_it++) {- const auto &expr = *expr_it;+ const auto& expr = *expr_it;const auto& loop_end = ov::as_type_ptr<op::LoopEnd>(expr->get_node());if (!loop_end)continue;@@ -93,14 +101,18 @@ std::vector<bool> SetBufferRegGroup::create_adjacency_matrix(const LoopManagerPtconst auto& loop_info = loop_manager->get_loop_info<UnifiedLoopInfo>(loop_end->get_id());const auto buffer_loop_neighbours = get_buffer_loop_neighbours(loop_info);const auto buffers_loop_inside = get_buffer_loop_inside(expr_it);- for (auto buffer_it = buffer_loop_neighbours.cbegin(); buffer_it != buffer_loop_neighbours.cend(); ++buffer_it) {- // If Buffers, that are connected to the same Loop, have not proportionally ptr shift params for this Loop - these Buffers are adjacent- for (auto neighbour_it = std::next(buffer_it); neighbour_it != buffer_loop_neighbours.cend(); ++neighbour_it) {+ for (auto buffer_it = buffer_loop_neighbours.cbegin(); buffer_it != buffer_loop_neighbours.cend();+ ++buffer_it) {+ // If Buffers, that are connected to the same Loop, have not proportionally ptr shift params for this Loop -+ // these Buffers are adjacent+ for (auto neighbour_it = std::next(buffer_it); neighbour_it != buffer_loop_neighbours.cend();+ ++neighbour_it) {update_adj_matrix(*buffer_it, *neighbour_it, pool, adj);}- // Buffers which are connected to the current Loop with zero ptr shifts and Buffers which are inside this 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.+ // Buffers which are connected to the current Loop with zero ptr shifts and Buffers which are inside this+ // 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);}@@ -120,7 +132,8 @@ SetBufferRegGroup::BufferMap SetBufferRegGroup::get_buffer_loop_neighbours(constif (buffer_neighbours.count(buffer_expr) > 0) {const auto& port_desc = port_info.desc;OPENVINO_ASSERT(buffer_neighbours[buffer_expr].desc == port_desc,- "Invalid data pointer shifts: If Buffer has several consumers, this consumers must have the same shifts or zero");+ "Invalid data pointer shifts: If Buffer has several consumers, this consumers must "+ "have the same shifts or zero");continue;}buffer_neighbours[buffer_expr] = port_info;@@ -165,11 +178,12 @@ auto SetBufferRegGroup::coloring(BufferPool& buffers, std::vector<bool>& adj) ->continue;const auto& buffer = buffers[i];- color_groups[color].push_back(buffer); // Add to Color Group- buffers[i] = nullptr; // Remove from graph vertices+ color_groups[color].push_back(buffer); // Add to Color Group+ buffers[i] = nullptr; // Remove from graph vertices// 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>())) {+ while ((i + 1 < size) &&+ !std::accumulate(adj.begin() + i * size, adj.begin() + (i + 1) * size, true, std::logical_and<bool>())) {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) {@@ -183,15 +197,18 @@ auto SetBufferRegGroup::coloring(BufferPool& buffers, std::vector<bool>& adj) ->break;const auto& neighbour_buffer = buffers[j];- color_groups[color].push_back(neighbour_buffer); // Add to Color Group- buffers[j] = nullptr; // Remove from graph vertices+ color_groups[color].push_back(neighbour_buffer); // Add to Color Group+ buffers[j] = nullptr; // Remove from graph vertices// Unite adjacency links:- // All the neighbors of Buffer `j` are added to the neighbors of Buffer `i` (the `vertices` are pulled together).- // The result is an updated i-th row of the adjacency matrix,- // in which 0 are only in columns with `vertex` numbers that are not adjacent to either the i-th or j-th `vertices`.- // Mathematically, this can be replaced by the operation of OR of Boolean vectors representing strings i and j.- std::transform(adj.begin() + i * size, adj.begin() + (i + 1) * size, adj.begin() + j * size,- adj.begin() + i * size, std::logical_or<bool>());+ // All the neighbors of Buffer `j` are added to the neighbors of Buffer `i` (the `vertices` are pulled+ // together). The result is an updated i-th row of the adjacency matrix, in which 0 are only in columns+ // with `vertex` numbers that are not adjacent to either the i-th or j-th `vertices`. Mathematically,+ // this can be replaced by the operation of OR of Boolean vectors representing strings i and j.+ std::transform(adj.begin() + i * size,+ adj.begin() + (i + 1) * size,+ adj.begin() + j * size,+ adj.begin() + i * size,+ std::logical_or<bool>());}color++;@@ -200,14 +217,19 @@ auto SetBufferRegGroup::coloring(BufferPool& buffers, std::vector<bool>& adj) ->return color_groups;}-bool SetBufferRegGroup::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) {+bool SetBufferRegGroup::run(LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::SetBufferRegGroup")// Identify Buffers using Graph coloring algorithm.BufferPool buffer_pool = linear_ir.get_buffers();// For the better coloring Buffers should be stored in the order of execution numbers- std::sort(buffer_pool.begin(), buffer_pool.end(),- [](const BufferExpressionPtr& lhs, const BufferExpressionPtr& rhs) { return lhs->get_exec_num() < rhs->get_exec_num(); });+ std::sort(buffer_pool.begin(),+ buffer_pool.end(),+ [](const BufferExpressionPtr& lhs, const BufferExpressionPtr& rhs) {+ return lhs->get_exec_num() < rhs->get_exec_num();+ });// Creation of Adj matrixauto adj = create_adjacency_matrix(linear_ir.get_loop_manager(), begin, end, buffer_pool);@@ -225,7 +247,7 @@ bool SetBufferRegGroup::run(LinearIR& linear_ir, lowered::LinearIR::constExprItreturn true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --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 8a5db80f577..8f653de5b8e 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,10 +4,10 @@#include "snippets/lowered/pass/set_dynamic_wa_to_outermost_loop.hpp"-#include "snippets/lowered/pass/mha_parallel_wa_optimizer.hpp"#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.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"@@ -29,7 +29,6 @@ bool SetDynamicWAToOuterMostLoop::run(LinearIR& linear_ir) {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");-const auto& loop_manager = linear_ir_ptr->get_loop_manager();std::unordered_set<lowered::UnifiedLoopInfoPtr> affected_loops;size_t prev_loop_id = std::numeric_limits<size_t>::max();@@ -67,7 +66,7 @@ bool SetDynamicWAToOuterMostLoop::run(LinearIR& linear_ir) {return modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ov\ No newline at end of filediff --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 633d24e93d2..ef46d6e052f 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,21 @@#include "snippets/lowered/pass/set_load_store_scalar.hpp"-#include "snippets/lowered/pass/insert_load_store.hpp"+#include "snippets/itt.hpp"#include "snippets/lowered/loop_manager.hpp"+#include "snippets/lowered/pass/insert_load_store.hpp"#include "snippets/op/load.hpp"#include "snippets/op/store.hpp"#include "snippets/utils/utils.hpp"-#include "snippets/itt.hpp"namespace ov {namespace snippets {namespace lowered {namespace pass {-bool SetLoadStoreScalar::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) {+bool SetLoadStoreScalar::run(LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::SetLoadStoreScalar")bool modified = false;for (auto expr_it = begin; expr_it != end; ++expr_it) {@@ -42,7 +44,7 @@ bool SetLoadStoreScalar::run(LinearIR& linear_ir, lowered::LinearIR::constExprItreturn modified;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/solve_buffer_memory.cpp b/src/common/snippets/src/lowered/pass/solve_buffer_memory.cppindex ec7ab6c95eb..68c91767186 100644--- a/src/common/snippets/src/lowered/pass/solve_buffer_memory.cpp+++ b/src/common/snippets/src/lowered/pass/solve_buffer_memory.cpp@@ -4,12 +4,11 @@#include "snippets/lowered/pass/solve_buffer_memory.hpp"+#include "snippets/itt.hpp"#include "snippets/lowered/pass/allocate_buffers.hpp"#include "snippets/op/buffer.hpp"#include "snippets/op/loop.hpp"#include "snippets/utils/utils.hpp"-#include "snippets/itt.hpp"-namespace ov {namespace snippets {@@ -28,7 +27,8 @@ std::map<double, int> create_execution_number_mapping(const LinearIR& linear_ir)}} // namespace-std::pair<SolveBufferMemory::Buffers, SolveBufferMemory::Buffers> SolveBufferMemory::extract_static_and_dynamic_buffers(const Buffers& buffer_expressions) {+std::pair<SolveBufferMemory::Buffers, SolveBufferMemory::Buffers> SolveBufferMemory::extract_static_and_dynamic_buffers(+ const Buffers& buffer_expressions) {Buffers static_buffer_exprs, dynamic_buffer_exprs;for (const auto& buffer_expr : buffer_expressions) {auto& clusters = buffer_expr->is_defined() ? static_buffer_exprs : dynamic_buffer_exprs;@@ -38,21 +38,26 @@ std::pair<SolveBufferMemory::Buffers, SolveBufferMemory::Buffers> SolveBufferMem// Validation check that buffer cluster has only static or dynamic buffers.for (const auto& static_buffer : static_buffer_exprs) {const auto static_cluster_id = static_buffer->get_cluster_id();- auto is_cluster_ids_the_same = [&static_cluster_id](const BufferExpressionPtr& expr) { return static_cluster_id == expr->get_cluster_id(); };- OPENVINO_ASSERT(std::none_of(dynamic_buffer_exprs.cbegin(), dynamic_buffer_exprs.cend(), is_cluster_ids_the_same),- "There is Buffer cluster with buffers which has defined and undefined allocation sizes");+ auto is_cluster_ids_the_same = [&static_cluster_id](const BufferExpressionPtr& expr) {+ return static_cluster_id == expr->get_cluster_id();+ };+ OPENVINO_ASSERT(+ std::none_of(dynamic_buffer_exprs.cbegin(), dynamic_buffer_exprs.cend(), is_cluster_ids_the_same),+ "There is Buffer cluster with buffers which has defined and undefined allocation sizes");}- return { static_buffer_exprs, dynamic_buffer_exprs };+ return {static_buffer_exprs, dynamic_buffer_exprs};}-std::vector<ov::MemorySolver::Box> SolveBufferMemory::init_boxes(const Buffers& buffer_expressions, const LinearIR& linear_ir) {+std::vector<ov::MemorySolver::Box> SolveBufferMemory::init_boxes(const Buffers& buffer_expressions,+ const LinearIR& linear_ir) {// ov::MemorySolver interface requires integer execution numbers (lifetime must be integer).// To align with ov::MemorySolver interface, we create the map [double -> integer]const auto int_execution_numbers = create_execution_number_mapping(linear_ir);auto casted_execution_number = [&](const ExpressionPtr& expr) {const auto double_execution_number = expr->get_exec_num();- OPENVINO_ASSERT(int_execution_numbers.count(double_execution_number) != 0, "Expression execution number has not been found!");+ OPENVINO_ASSERT(int_execution_numbers.count(double_execution_number) != 0,+ "Expression execution number has not been found!");return int_execution_numbers.at(double_execution_number);};@@ -61,7 +66,7 @@ std::vector<ov::MemorySolver::Box> SolveBufferMemory::init_boxes(const Buffers&auto cluster_id = static_cast<int>(buffer_expr->get_cluster_id());if (map_boxes.count(cluster_id) == 0) {- map_boxes[cluster_id] = { std::numeric_limits<int>::max(), 0, 0, cluster_id };+ map_boxes[cluster_id] = {std::numeric_limits<int>::max(), 0, 0, cluster_id};}auto& box = map_boxes.at(cluster_id);@@ -111,7 +116,8 @@ std::vector<ov::MemorySolver::Box> SolveBufferMemory::init_boxes(const Buffers&return boxes;}-void SolveBufferMemory::solve_static_buffer_memory(const Buffers& static_buffer_expressions, const LinearIR& linear_ir) {+void SolveBufferMemory::solve_static_buffer_memory(const Buffers& static_buffer_expressions,+ const LinearIR& linear_ir) {const auto boxes = init_boxes(static_buffer_expressions, linear_ir);ov::MemorySolver memSolver(boxes);@@ -127,8 +133,8 @@ 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>();- // 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 = 0+ // 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)@@ -160,7 +166,7 @@ bool SolveBufferMemory::run(LinearIR& linear_ir) {return !static_buffer_exprs.empty() && !dynamic_buffer_exprs.empty();}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/split_loops.cpp b/src/common/snippets/src/lowered/pass/split_loops.cppindex a663cc1ed56..4b2170d249f 100644--- a/src/common/snippets/src/lowered/pass/split_loops.cpp+++ b/src/common/snippets/src/lowered/pass/split_loops.cpp@@ -86,20 +86,33 @@ void SplitLoops::split(LinearIR& linear_ir, size_t loop_to_split_id, size_t outeconst auto& loop_manager = linear_ir.get_loop_manager();const auto& inner_loop_info = loop_manager->get_loop_info<UnifiedLoopInfo>(loop_to_split_id);- const auto loop_bounds = LoopManager::get_loop_bounds(linear_ir, loop_to_split_id,+ const auto loop_bounds = LoopManager::get_loop_bounds(linear_ir,+ loop_to_split_id,inner_loop_info->get_input_ports(),inner_loop_info->get_output_ports());- const auto outer_loop_id = loop_manager->mark_loop(loop_bounds.first, loop_bounds.second, inner_loop_info->get_work_amount(),- outer_increment, inner_loop_info->get_dim_idx(),- inner_loop_info->get_input_ports(), inner_loop_info->get_output_ports(), false);+ const auto outer_loop_id = loop_manager->mark_loop(loop_bounds.first,+ loop_bounds.second,+ inner_loop_info->get_work_amount(),+ outer_increment,+ inner_loop_info->get_dim_idx(),+ inner_loop_info->get_input_ports(),+ inner_loop_info->get_output_ports(),+ false);const auto& outer_loop_info = loop_manager->get_loop_info<UnifiedLoopInfo>(outer_loop_id);const auto& inner_splitted_loop_info =- std::make_shared<InnerSplittedUnifiedLoopInfo>(inner_loop_info->get_increment(), inner_loop_info->get_input_ports(),- inner_loop_info->get_output_ports(), inner_loop_info->get_input_port_descs(),- inner_loop_info->get_output_port_descs(), inner_loop_info->get_handlers(),+ std::make_shared<InnerSplittedUnifiedLoopInfo>(inner_loop_info->get_increment(),+ inner_loop_info->get_input_ports(),+ inner_loop_info->get_output_ports(),+ inner_loop_info->get_input_port_descs(),+ inner_loop_info->get_output_port_descs(),+ inner_loop_info->get_handlers(),outer_loop_info);- loop_manager->replace_with_new_loop(linear_ir, loop_bounds.first, loop_bounds.second, inner_splitted_loop_info, loop_to_split_id);+ loop_manager->replace_with_new_loop(linear_ir,+ loop_bounds.first,+ loop_bounds.second,+ inner_splitted_loop_info,+ loop_to_split_id);if (!outer_loop_info->get_handlers().get_passes<SpecificLoopIterType::FIRST_ITER>().empty()) {outer_loop_info->register_pass_to_handler<SpecificLoopIterType::FIRST_ITER, TransformInnerSplitLoop>();@@ -109,29 +122,39 @@ void SplitLoops::split(LinearIR& linear_ir, size_t loop_to_split_id, size_t oute}namespace {-InnerSplittedUnifiedLoopInfoPtr make_own_inner_splitted_unified_loop_info(const ExpandedLoopInfoPtr& inner_expanded,- const ExpandedLoopInfoPtr& outer_expanded,- const InnerSplittedUnifiedLoopInfoPtr& existing_inner_unified) {+InnerSplittedUnifiedLoopInfoPtr make_own_inner_splitted_unified_loop_info(+ const ExpandedLoopInfoPtr& inner_expanded,+ const ExpandedLoopInfoPtr& outer_expanded,+ const InnerSplittedUnifiedLoopInfoPtr& existing_inner_unified) {const auto loop_info =- std::make_shared<InnerSplittedUnifiedLoopInfo>(inner_expanded->get_increment(), inner_expanded->get_input_ports(),- inner_expanded->get_output_ports(), existing_inner_unified->get_input_port_descs(),- existing_inner_unified->get_output_port_descs(), existing_inner_unified->get_handlers(),+ std::make_shared<InnerSplittedUnifiedLoopInfo>(inner_expanded->get_increment(),+ inner_expanded->get_input_ports(),+ inner_expanded->get_output_ports(),+ existing_inner_unified->get_input_port_descs(),+ existing_inner_unified->get_output_port_descs(),+ existing_inner_unified->get_handlers(),outer_expanded);ov::snippets::utils::update_runtime_parameters(loop_info);return loop_info;}ExpandedLoopInfoPtr make_own_inner_splitted_expanded_loop_info(const ExpandedLoopInfoPtr& inner_expanded,const InnerSplittedUnifiedLoopInfoPtr& inner_unified) {- return std::make_shared<ExpandedLoopInfo>(inner_unified->get_work_amount(), inner_unified->get_increment(),- inner_unified->get_input_ports(), inner_unified->get_output_ports(),+ return std::make_shared<ExpandedLoopInfo>(inner_unified->get_work_amount(),+ inner_unified->get_increment(),+ inner_unified->get_input_ports(),+ inner_unified->get_output_ports(),inner_unified->get_ptr_increments(),inner_unified->get_finalization_offsets(),- inner_unified->get_data_sizes(), inner_expanded->get_type(),- inner_unified, inner_expanded->is_evaluate_once());+ inner_unified->get_data_sizes(),+ inner_expanded->get_type(),+ inner_unified,+ inner_expanded->is_evaluate_once());}} // namespace-bool SplitLoops::TransformInnerSplitLoop::run(LinearIR& linear_ir, LinearIR::constExprIt begin, LinearIR::constExprIt end) {+bool SplitLoops::TransformInnerSplitLoop::run(LinearIR& linear_ir,+ LinearIR::constExprIt begin,+ LinearIR::constExprIt end) {OPENVINO_ASSERT(end != linear_ir.cend(), "Incorrect LinearIR range for processing");const auto& expr = *end;const auto node = expr->get_node();@@ -153,22 +176,35 @@ bool SplitLoops::TransformInnerSplitLoop::run(LinearIR& linear_ir, LinearIR::con// 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())+ 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())continue;- OPENVINO_ASSERT(current_dim_idx == inner_unified_loop_info->get_dim_idx(), "Incorrect processing dim index of splitted loops");- OPENVINO_ASSERT(inner_expanded_loop_info->get_type() == SpecificLoopIterType::MAIN_BODY, "InnerSplittedLoop must be Main Body of loop");+ OPENVINO_ASSERT(current_dim_idx == inner_unified_loop_info->get_dim_idx(),+ "Incorrect processing dim index of splitted loops");+ OPENVINO_ASSERT(inner_expanded_loop_info->get_type() == SpecificLoopIterType::MAIN_BODY,+ "InnerSplittedLoop must be Main Body of loop");- // We have to make a new UnifiedLoopInfo to distinguish it from other unified loops in other specific iterations of outer loop.- const auto inner_splitted_unified_loop_info = make_own_inner_splitted_unified_loop_info(inner_expanded_loop_info, outer_loop_info,- inner_unified_loop_info);+ // We have to make a new UnifiedLoopInfo to distinguish it from other unified loops in other specific iterations+ // of outer loop.+ const auto inner_splitted_unified_loop_info =+ make_own_inner_splitted_unified_loop_info(inner_expanded_loop_info,+ outer_loop_info,+ inner_unified_loop_info);// We have to replace existing ExpandedLoopInfo with new one to have the own InnerSplittedUnifiedLoopInfo and// distinguish it from other expanded loops in other specific iterations of outer loop.- const auto new_expanded_inner_loop_info = make_own_inner_splitted_expanded_loop_info(inner_expanded_loop_info, inner_splitted_unified_loop_info);- const auto inner_begin = linear_ir.find_before(it, linear_ir.get_expr_by_node(inner_loop_end->get_loop_begin()));- const auto new_id = loop_manager->replace_with_new_loop(linear_ir, inner_begin, std::next(it), new_expanded_inner_loop_info, inner_loop_end->get_id());+ const auto new_expanded_inner_loop_info =+ make_own_inner_splitted_expanded_loop_info(inner_expanded_loop_info, inner_splitted_unified_loop_info);+ const auto inner_begin =+ linear_ir.find_before(it, linear_ir.get_expr_by_node(inner_loop_end->get_loop_begin()));+ const auto new_id = loop_manager->replace_with_new_loop(linear_ir,+ inner_begin,+ std::next(it),+ new_expanded_inner_loop_info,+ inner_loop_end->get_id());// [147894] : Update inner LoopEnd expressioninner_loop_end->set_id(new_id);@@ -179,11 +215,13 @@ bool SplitLoops::TransformInnerSplitLoop::run(LinearIR& linear_ir, LinearIR::conreturn modified;}-std::shared_ptr<pass::PassBase> SplitLoops::TransformInnerSplitLoop::merge(const std::shared_ptr<pass::PassBase>& other) {- return !other || ov::is_type<TransformInnerSplitLoop>(other) ? std::make_shared<TransformInnerSplitLoop>() : nullptr;+std::shared_ptr<pass::PassBase> SplitLoops::TransformInnerSplitLoop::merge(+ const std::shared_ptr<pass::PassBase>& other) {+ return !other || ov::is_type<TransformInnerSplitLoop>(other) ? std::make_shared<TransformInnerSplitLoop>()+ : nullptr;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ov\ No newline at end of filediff --git a/src/common/snippets/src/lowered/pass/validate.cpp b/src/common/snippets/src/lowered/pass/validate.cppindex 6db5589e933..7a305ea9252 100644--- a/src/common/snippets/src/lowered/pass/validate.cpp+++ b/src/common/snippets/src/lowered/pass/validate.cpp@@ -4,10 +4,10 @@#include "snippets/lowered/pass/validate.hpp"+#include "snippets/itt.hpp"#include "snippets/lowered/loop_manager.hpp"#include "snippets/snippets_isa.hpp"#include "snippets/utils/utils.hpp"-#include "snippets/itt.hpp"namespace ov {namespace snippets {@@ -31,8 +31,7 @@ void validate_ports(const ExpressionPtr& expr) {}void validate_parameter(const ExpressionPtr& expr, const LinearIR& linear_ir) {- OPENVINO_ASSERT(ov::is_type<ov::op::v0::Parameter>(expr->get_node()),- "Parameter validation expects Parameter op");+ 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();auto consumer_inputs = expr_val->get_output_port_connector(0)->get_consumers();@@ -44,33 +43,30 @@ void validate_parameter(const ExpressionPtr& expr, const LinearIR& linear_ir) {"Parameter expects MemoryAccess on output");layouts.insert(consumer_input.get_descriptor_ptr()->get_layout());} else {- OPENVINO_ASSERT(ov::is_type<op::LoopEnd>(node), "Parameter must be connected to MemoryAccess op or LoopEnd");+ OPENVINO_ASSERT(ov::is_type<op::LoopEnd>(node),+ "Parameter must be connected to MemoryAccess op or LoopEnd");}}OPENVINO_ASSERT(layouts.size() == 1, "All consumers of Parameter must have the same layout");}void validate_result(const ExpressionPtr& expr, const LinearIR& linear_ir) {- OPENVINO_ASSERT(ov::is_type<ov::op::v0::Result>(expr->get_node()),- "Result validation expects Result op");+ 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();const auto source = expr_val->get_input_port_connector(0)->get_source();const auto ma = std::dynamic_pointer_cast<snippets::modifier::MemoryAccess>(source.get_expr()->get_node());- OPENVINO_ASSERT(ma && ma->is_memory_access_output_port(source.get_index()),- "Result expects MemoryAccess parent");+ 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) {- 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");+ 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()) {const auto& source = input->get_source();const auto ma = std::dynamic_pointer_cast<snippets::modifier::MemoryAccess>(source.get_expr()->get_node());OPENVINO_ASSERT(ma && ma->is_memory_access_output_port(source.get_index()),- "Buffer expects MemoryAccess parent");+ "Buffer expects MemoryAccess parent");const auto buffer_siblings = input->get_consumers();for (const auto& buffer_sibling : buffer_siblings) {const auto& buffer_sibling_expr = buffer_sibling.get_expr();@@ -98,8 +94,7 @@ void validate_loop_end(const ExpressionPtr& expr, const LinearIR& linear_ir) {const auto loop_end = ov::as_type_ptr<op::LoopEnd>(expr->get_node());OPENVINO_ASSERT(loop_end, "LoopEnd validation expects LoopEnd op");const auto& loop_begin = loop_end->get_loop_begin();- OPENVINO_ASSERT(loop_begin != nullptr,- "LoopEnd must be connected to the LoopBegin");+ OPENVINO_ASSERT(loop_begin != nullptr, "LoopEnd must be connected to the LoopBegin");const auto num_inputs = expr->get_input_count();OPENVINO_ASSERT(num_inputs >= 1, "LoopEnd expression must have at least 1 input");OPENVINO_ASSERT(expr->get_input_port_connector(num_inputs - 1)->get_source().get_expr()->get_node() == loop_begin,@@ -108,30 +103,31 @@ void validate_loop_end(const ExpressionPtr& expr, const LinearIR& linear_ir) {const auto& loop_manager = linear_ir.get_loop_manager();const auto& loop_info = loop_manager->get_loop_info<UnifiedLoopInfo>(loop_end->get_id());OPENVINO_ASSERT(loop_info->get_work_amount() == loop_end->get_work_amount() &&- loop_info->get_increment() == loop_end->get_increment(),+ loop_info->get_increment() == loop_end->get_increment(),"Incompatible LoopEnd and the corresponding LoopInfo");const auto input_port_infos = loop_info->get_input_ports_info();const auto output_port_infos = loop_info->get_output_ports_info();- OPENVINO_ASSERT(input_port_infos.size() == loop_end->get_input_num() &&- output_port_infos.size() == loop_end->get_output_num(),- "Incompatible LoopEnd and the corresponding LoopInfo");+ OPENVINO_ASSERT(+ input_port_infos.size() == loop_end->get_input_num() && output_port_infos.size() == loop_end->get_output_num(),+ "Incompatible LoopEnd and the corresponding LoopInfo");const auto& is_incremented = loop_end->get_is_incremented();const auto& ptr_increments = loop_end->get_ptr_increments();const auto& final_offsets = loop_end->get_finalization_offsets();- auto validate_loop_ports = [&](const std::vector<UnifiedLoopInfo::LoopPortInfo>& loop_port_infos, size_t shift = 0) {+ auto validate_loop_ports = [&](const std::vector<UnifiedLoopInfo::LoopPortInfo>& loop_port_infos,+ size_t shift = 0) {for (size_t i = 0; i < loop_port_infos.size(); ++i) {OPENVINO_ASSERT(is_incremented[i + shift] == loop_port_infos[i].port.is_incremented() &&- ptr_increments[i + shift] == loop_port_infos[i].desc.ptr_increment &&- final_offsets[i + shift] == loop_port_infos[i].desc.finalization_offset,+ ptr_increments[i + shift] == loop_port_infos[i].desc.ptr_increment &&+ final_offsets[i + shift] == loop_port_infos[i].desc.finalization_offset,"Incompatible data ptr shifts in LoopEnd and the corresponding LoopInfo");}};validate_loop_ports(input_port_infos);validate_loop_ports(output_port_infos, loop_end->get_input_num());}-} // namespace+} // namespaceValidate::Validate() {m_validation_map = {@@ -173,7 +169,7 @@ bool Validate::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, loreturn false;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/validate_buffers.cpp b/src/common/snippets/src/lowered/pass/validate_buffers.cppindex e955f10ca09..50092ac29ca 100644--- a/src/common/snippets/src/lowered/pass/validate_buffers.cpp+++ b/src/common/snippets/src/lowered/pass/validate_buffers.cpp@@ -4,15 +4,17 @@#include "snippets/lowered/pass/validate_buffers.hpp"-#include "snippets/utils/utils.hpp"#include "snippets/itt.hpp"+#include "snippets/utils/utils.hpp"namespace ov {namespace snippets {namespace lowered {namespace pass {-bool ValidateBuffers::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) {+bool ValidateBuffers::run(LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::ValidateBuffers")const auto& lir_buffers = linear_ir.get_buffers();@@ -28,7 +30,8 @@ bool ValidateBuffers::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt bestd::set<size_t> cluster_ids;std::map<size_t, std::set<lowered::BufferExpressionPtr>> dynamic_buffer_clusters, static_buffer_clusters;for (const auto& buffer_expr : lir_buffers) {- // TODO [143395] : MemoryManager should provide exact containers with needed buffers (static or dynamic) without any `is_defined()`+ // TODO [143395] : MemoryManager should provide exact containers with needed buffers (static or dynamic) without+ // any `is_defined()`auto& clusters = buffer_expr->is_defined() ? static_buffer_clusters : dynamic_buffer_clusters;clusters[buffer_expr->get_cluster_id()].insert(buffer_expr);cluster_ids.insert(buffer_expr->get_cluster_id());@@ -36,26 +39,30 @@ bool ValidateBuffers::run(LinearIR& linear_ir, lowered::LinearIR::constExprIt bebuffer_expr->validate();}- OPENVINO_ASSERT(cluster_ids.size() == dynamic_buffer_clusters.size() + static_buffer_clusters.size(), "Incorrect count of Buffer clusters");- OPENVINO_ASSERT(cluster_ids.empty() || (*cluster_ids.cbegin() == 0 && *cluster_ids.crbegin() == (cluster_ids.size() - 1)),- "Incorrect indetifiers of Buffer clusters");+ OPENVINO_ASSERT(cluster_ids.size() == dynamic_buffer_clusters.size() + static_buffer_clusters.size(),+ "Incorrect count of Buffer clusters");+ OPENVINO_ASSERT(+ cluster_ids.empty() || (*cluster_ids.cbegin() == 0 && *cluster_ids.crbegin() == (cluster_ids.size() - 1)),+ "Incorrect indetifiers of Buffer clusters");for (const auto& p : static_buffer_clusters) {const auto& cluster_id = p.first;const auto& cluster = p.second;- OPENVINO_ASSERT(dynamic_buffer_clusters.count(cluster_id) == 0, "Buffers from the same cluster must be only static or dynamic");+ 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");size_t cluster_offset = (*cluster.cbegin())->get_offset();for (const auto& buffer_expr : cluster) {- OPENVINO_ASSERT(cluster_offset == buffer_expr->get_offset(), "Static Buffers from the same cluster must have the same offset!");+ OPENVINO_ASSERT(cluster_offset == buffer_expr->get_offset(),+ "Static Buffers from the same cluster must have the same offset!");}}return !lir_buffers.empty();}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/validate_expanded_loops.cpp b/src/common/snippets/src/lowered/pass/validate_expanded_loops.cppindex ec77d75fe3f..9f322a5f5ce 100644--- a/src/common/snippets/src/lowered/pass/validate_expanded_loops.cpp+++ b/src/common/snippets/src/lowered/pass/validate_expanded_loops.cpp@@ -4,18 +4,17 @@#include "snippets/lowered/pass/validate_expanded_loops.hpp"+#include "snippets/itt.hpp"#include "snippets/lowered/loop_manager.hpp"#include "snippets/op/loop.hpp"#include "snippets/utils/utils.hpp"-#include "snippets/itt.hpp"namespace ov {namespace snippets {namespace lowered {namespace pass {-#define INFORMATIVE_ASSERT(cond, ...) \- OPENVINO_ASSERT((cond), "Failed to validate ExpandedLoops: ", __VA_ARGS__)+#define INFORMATIVE_ASSERT(cond, ...) OPENVINO_ASSERT((cond), "Failed to validate ExpandedLoops: ", __VA_ARGS__)namespace {bool is_inner_splitted_tail(const ExpressionPtr& loop_expr, const LoopManagerPtr& loop_manager) {@@ -37,7 +36,7 @@ bool is_inner_splitted_tail(const ExpressionPtr& loop_expr, const LoopManagerPtrexpanded_loop_info->get_dim_idx() == outer_expanded_loop_info->get_dim_idx();}-} // namespace+} // namespacevoid ValidateExpandedLoops::validate_loop_information(const LinearIR& linear_ir) {const auto& loop_manager = linear_ir.get_loop_manager();@@ -60,16 +59,18 @@ void ValidateExpandedLoops::validate_loop_information(const LinearIR& linear_ir)INFORMATIVE_ASSERT(current_unified_loop_info, "expects non nullptr UnifiedLoopInfo in ExpandedLoopInfo");auto& current_info = initializated_info_map[current_unified_loop_info];- if (current_info.num_ports == 0) { // the info was just default constructed- current_info.num_ports = current_unified_loop_info->get_input_count() + current_unified_loop_info->get_output_count();+ if (current_info.num_ports == 0) { // the info was just default constructed+ current_info.num_ports =+ current_unified_loop_info->get_input_count() + current_unified_loop_info->get_output_count();current_info.finalization_offsets.resize(current_info.num_ports, 0);}INFORMATIVE_ASSERT(current_unified_loop_info->get_input_count() == expanded_loop_info->get_input_count() &&- current_unified_loop_info->get_output_count() == expanded_loop_info->get_output_count(),+ current_unified_loop_info->get_output_count() == expanded_loop_info->get_output_count(),"incompatible loop ports with UnifiedLoopInfo");- current_info.work_amount = utils::dynamic_safe_add(current_info.work_amount, expanded_loop_info->get_work_amount());+ current_info.work_amount =+ utils::dynamic_safe_add(current_info.work_amount, expanded_loop_info->get_work_amount());INFORMATIVE_ASSERT(current_unified_loop_info->get_ptr_increments() == expanded_loop_info->get_ptr_increments(),"incompatible pointer increments with UnifiedLoopInfo");@@ -77,17 +78,22 @@ void ValidateExpandedLoops::validate_loop_information(const LinearIR& linear_ir)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)- current_info.finalization_offsets[i] = utils::dynamic_safe_add(current_info.finalization_offsets[i], finalization_offsets[i]);+ current_info.finalization_offsets[i] =+ utils::dynamic_safe_add(current_info.finalization_offsets[i], finalization_offsets[i]);}// Validation of total informationfor (const auto& p : initializated_info_map) {const auto loop_info = p.first;const auto total_info = p.second;- INFORMATIVE_ASSERT(total_info.work_amount == loop_info->get_work_amount(),- "total work amount of expanded loops is not equal to work amount of undefined loop with ID: " + std::to_string(total_info.id));- INFORMATIVE_ASSERT(total_info.finalization_offsets == loop_info->get_finalization_offsets(),- "total finalization offsets are not equal to finalization offsets of undefined loop with ID: " + std::to_string(total_info.id));+ INFORMATIVE_ASSERT(+ total_info.work_amount == loop_info->get_work_amount(),+ "total work amount of expanded loops is not equal to work amount of undefined loop with ID: " ++ std::to_string(total_info.id));+ INFORMATIVE_ASSERT(+ total_info.finalization_offsets == loop_info->get_finalization_offsets(),+ "total finalization offsets are not equal to finalization offsets of undefined loop with ID: " ++ std::to_string(total_info.id));}}@@ -121,7 +127,7 @@ void ValidateExpandedLoops::validate_loop_expressions(const LinearIR& linear_ir)}}INFORMATIVE_ASSERT(unique_loop_ids.size() == loop_manager->get_map().size(),- "incompatible loopIDs of inserted LoopEnd expressions and LoopInfo in LoopManager");+ "incompatible loopIDs of inserted LoopEnd expressions and LoopInfo in LoopManager");}bool ValidateExpandedLoops::run(LinearIR& linear_ir) {@@ -137,7 +143,7 @@ bool ValidateExpandedLoops::run(LinearIR& linear_ir) {#undef INFORMATIVE_ASSERT-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/validate_shapes.cpp b/src/common/snippets/src/lowered/pass/validate_shapes.cppindex 6558c3e1553..1a16ece6d54 100644--- a/src/common/snippets/src/lowered/pass/validate_shapes.cpp+++ b/src/common/snippets/src/lowered/pass/validate_shapes.cpp@@ -4,17 +4,19 @@#include "snippets/lowered/pass/validate_shapes.hpp"+#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/op/loop.hpp"#include "snippets/shape_inference/shape_inference.hpp"-#include "snippets/itt.hpp"namespace ov {namespace snippets {namespace lowered {namespace pass {-bool ValidateShapes::run(lowered::LinearIR& linear_ir, lowered::LinearIR::constExprIt begin, lowered::LinearIR::constExprIt end) {+bool ValidateShapes::run(lowered::LinearIR& linear_ir,+ lowered::LinearIR::constExprIt begin,+ lowered::LinearIR::constExprIt end) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::ValidateShapes")for (auto expr_it = begin; expr_it != end; ++expr_it) {@@ -31,18 +33,22 @@ bool ValidateShapes::run(lowered::LinearIR& linear_ir, lowered::LinearIR::constEconst auto& layout = descr->get_layout();const auto& shape = descr->get_shape();const auto& n = expr->get_node();- OPENVINO_ASSERT(layout.size() == shape.size(), "Layout and shape sizes must match. ",- "Check the expr for node ", n->get_friendly_name());+ OPENVINO_ASSERT(layout.size() == shape.size(),+ "Layout and shape sizes must match. ",+ "Check the expr for node ",+ n->get_friendly_name());const auto& parent_desc = port_connectors[i]->get_source().get_descriptor_ptr();const auto& parent_shape = parent_desc->get_shape();- OPENVINO_ASSERT(parent_shape == shape, "Parent shape must be equal to the expression shape. ",- "Check the expr for node ", n->get_friendly_name());+ OPENVINO_ASSERT(parent_shape == shape,+ "Parent shape must be equal to the expression shape. ",+ "Check the expr for node ",+ n->get_friendly_name());}}return false;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/pass/validate_unified_loops.cpp b/src/common/snippets/src/lowered/pass/validate_unified_loops.cppindex e127aaea0c1..012102aa481 100644--- a/src/common/snippets/src/lowered/pass/validate_unified_loops.cpp+++ b/src/common/snippets/src/lowered/pass/validate_unified_loops.cpp@@ -31,34 +31,39 @@ void ValidateUnifiedLoops::validate_loop_infos(const LoopManagerPtr& loop_managestd::vector<size_t> dim_indexes;- auto validate_loop_port = [&loop_manager, &dim_indexes, &validated_nested_loops, &is_already_verified](const LoopPort& loop_port) {- const 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))- return;-- dim_indexes.clear();- dim_indexes.reserve(loop_ids.size());- // Outer Loop -> Inner Loop- for (size_t i = 0; i < loop_ids.size(); ++i) {- const auto id = loop_ids[i];- const 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)- continue;- if (i > 0) {- if (std::find(dim_indexes.cbegin(), dim_indexes.cend(), dim_idx) != dim_indexes.cend()) {+ auto validate_loop_port =+ [&loop_manager, &dim_indexes, &validated_nested_loops, &is_already_verified](const LoopPort& loop_port) {+ const 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))+ return;++ dim_indexes.clear();+ dim_indexes.reserve(loop_ids.size());+ // Outer Loop -> Inner Loop+ for (size_t i = 0; i < loop_ids.size(); ++i) {+ const auto id = loop_ids[i];+ const 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)+ 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,- "Incorrect Loop ID configuration: the Loops with splitted dimension should be successively nested");- OPENVINO_ASSERT(loop_manager->get_loop_info(loop_ids[i - 1])->get_increment() == loop_manager->get_loop_info(id)->get_work_amount(),- "Incorrect Loop ID configuration: the Loops with splitted dimension should be successively nested");+ "Incorrect Loop ID configuration: the Loops with splitted dimension should be "+ "successively nested");+ OPENVINO_ASSERT(loop_manager->get_loop_info(loop_ids[i - 1])->get_increment() ==+ loop_manager->get_loop_info(id)->get_work_amount(),+ "Incorrect Loop ID configuration: the Loops with splitted dimension should be "+ "successively nested");+ }}+ dim_indexes.push_back(dim_idx);}- dim_indexes.push_back(dim_idx);- }- validated_nested_loops.insert(loop_ids);- };+ validated_nested_loops.insert(loop_ids);+ };for (const auto& pair : loop_manager->get_map()) {const auto& loop_info = ov::as_type_ptr<UnifiedLoopInfo>(pair.second);@@ -70,8 +75,9 @@ void ValidateUnifiedLoops::validate_loop_infos(const LoopManagerPtr& loop_manageloop_info->iterate_through_ports([&unique_dimensions](const LoopPort& loop_port) {if (loop_port.is_processed()) {const auto is_input = loop_port.get_expr_port()->get_type() == ExpressionPort::Input;- const auto planar_shape = is_input ? ov::snippets::utils::get_planar_vdims(*loop_port.get_expr_port())- : ov::snippets::utils::get_preordered_vdims(*loop_port.get_expr_port());+ const auto planar_shape = is_input+ ? ov::snippets::utils::get_planar_vdims(*loop_port.get_expr_port())+ : 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 dimsif (!utils::is_dynamic_value(dim) && dim != 1)@@ -87,12 +93,18 @@ void ValidateUnifiedLoops::validate_loop_port_presence(const LinearIR& linear_irauto validate_loop_port = [](const ExpressionPort& expr_port, const LoopInfoPtr& loop_info, size_t loop_id) {if (utils::should_be_loop_port(expr_port, loop_id)) {OPENVINO_ASSERT(loop_info->is_loop_port(expr_port),- "Expression port with idx ", expr_port.get_index(), " with node ",- expr_port.get_expr()->get_node()->get_friendly_name(), " is not Loop port but should be!");+ "Expression port with idx ",+ expr_port.get_index(),+ " with node ",+ expr_port.get_expr()->get_node()->get_friendly_name(),+ " is not Loop port but should be!");} else {OPENVINO_ASSERT(!loop_info->is_loop_port(expr_port),- "Expression port with idx ", expr_port.get_index(), " with node ",- expr_port.get_expr()->get_node()->get_friendly_name(), " is Loop port but should not be!");+ "Expression port with idx ",+ expr_port.get_index(),+ " with node ",+ expr_port.get_expr()->get_node()->get_friendly_name(),+ " is Loop port but should not be!");}};@@ -125,7 +137,7 @@ bool ValidateUnifiedLoops::run(LinearIR& linear_ir) {return true;}-} // namespace pass-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/port_connector.cpp b/src/common/snippets/src/lowered/port_connector.cppindex 11e7652721d..0aba531e341 100644--- a/src/common/snippets/src/lowered/port_connector.cpp+++ b/src/common/snippets/src/lowered/port_connector.cpp@@ -7,28 +7,26 @@#include "snippets/itt.hpp"#include "snippets/utils/utils.hpp"-namespace ov {namespace snippets {namespace lowered {PortConnector::PortConnector(ExpressionPort source_descriptor, const std::set<ExpressionPort>& consumer_descriptors)- : m_source_port(std::move(source_descriptor)), m_consumer_ports(consumer_descriptors) {}+ : m_source_port(std::move(source_descriptor)),+ m_consumer_ports(consumer_descriptors) {}std::set<ExpressionPort>::const_iterator PortConnector::find_consumer(const ExpressionPort& consumer) const {// Note: Find by shared ptr and index port is enough since these parameters must be unique- return std::find_if(m_consumer_ports.cbegin(), m_consumer_ports.cend(),- [&consumer](const ExpressionPort& td) {- return consumer.get_expr() == td.get_expr() && consumer.get_index() == td.get_index();- });+ return std::find_if(m_consumer_ports.cbegin(), m_consumer_ports.cend(), [&consumer](const ExpressionPort& td) {+ return consumer.get_expr() == td.get_expr() && consumer.get_index() == td.get_index();+ });}std::set<ExpressionPort>::iterator PortConnector::find_consumer(const ExpressionPort& consumer) {// Note: Find by shared ptr and index port is enough since these parameters must be unique- return std::find_if(m_consumer_ports.begin(), m_consumer_ports.end(),- [&consumer](const ExpressionPort& td) {- return consumer.get_expr() == td.get_expr() && consumer.get_index() == td.get_index();- });+ return std::find_if(m_consumer_ports.begin(), m_consumer_ports.end(), [&consumer](const ExpressionPort& td) {+ return consumer.get_expr() == td.get_expr() && consumer.get_index() == td.get_index();+ });}bool PortConnector::found_consumer(const ExpressionPort& consumer) const {@@ -47,6 +45,6 @@ void PortConnector::remove_consumer(const ExpressionPort& consumer) {m_consumer_ports.erase(found);}-}// namespace lowered-}// namespace snippets-}// namespace ov+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/port_descriptor.cpp b/src/common/snippets/src/lowered/port_descriptor.cppindex 311612348de..11d36b81c33 100644--- a/src/common/snippets/src/lowered/port_descriptor.cpp+++ b/src/common/snippets/src/lowered/port_descriptor.cpp@@ -2,9 +2,9 @@// SPDX-License-Identifier: Apache-2.0//-#include <cassert>-#include "snippets/lowered/port_descriptor.hpp"++#include <cassert>#include <snippets/utils/utils.hpp>namespace ov {@@ -12,26 +12,40 @@ namespace snippets {namespace 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()), std::move(subtensor_shape), std::move(layout)) {}+ : PortDescriptor(ov::Input<const Node>(in.get_node(), in.get_index()),+ std::move(subtensor_shape),+ std::move(layout)) {}-PortDescriptor::PortDescriptor(const ov::Input<const ov::Node>& in, std::vector<size_t> subtensor_shape, std::vector<size_t> layout)- : PortDescriptor(utils::pshape_to_vdims(in.get_partial_shape()), std::move(subtensor_shape), std::move(layout)) {}+PortDescriptor::PortDescriptor(const ov::Input<const ov::Node>& in,+ std::vector<size_t> subtensor_shape,+ std::vector<size_t> layout)+ : PortDescriptor(utils::pshape_to_vdims(in.get_partial_shape()), std::move(subtensor_shape), std::move(layout)) {}PortDescriptor::PortDescriptor(const ov::Output<ov::Node>& out, VectorDims subtensor_shape, std::vector<size_t> layout)- : PortDescriptor(ov::Output<const Node>(out.get_node(), out.get_index()), std::move(subtensor_shape), std::move(layout)) {}+ : PortDescriptor(ov::Output<const Node>(out.get_node(), out.get_index()),+ std::move(subtensor_shape),+ std::move(layout)) {}-PortDescriptor::PortDescriptor(const ov::Output<const ov::Node>& out, std::vector<size_t> subtensor_shape, std::vector<size_t> layout)- : PortDescriptor(utils::pshape_to_vdims(out.get_partial_shape()), std::move(subtensor_shape), std::move(layout)) {}+PortDescriptor::PortDescriptor(const ov::Output<const ov::Node>& out,+ std::vector<size_t> subtensor_shape,+ std::vector<size_t> layout)+ : PortDescriptor(utils::pshape_to_vdims(out.get_partial_shape()), std::move(subtensor_shape), std::move(layout)) {}PortDescriptor::PortDescriptor(VectorDims shape, VectorDims subtensor_shape, std::vector<size_t> layout, Reg reg)- : PortDescriptor(std::make_shared<VectorDims>(std::move(shape)), std::move(subtensor_shape), std::move(layout), std::move(reg)) {}+ : PortDescriptor(std::make_shared<VectorDims>(std::move(shape)),+ std::move(subtensor_shape),+ std::move(layout),+ std::move(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_tensor_shape(std::move(shape)),+ m_layout(std::move(layout)),+ m_subtensor_shape(std::move(subtensor_shape)),+ m_reg(std::move(reg)) {validate_arguments();}-PortDescriptor::PortDescriptor() : PortDescriptor(VectorDims(), {}, {}) {} // to avoid tensor_shape = nullptr+PortDescriptor::PortDescriptor() : PortDescriptor(VectorDims(), {}, {}) {} // to avoid tensor_shape = nullptrvoid PortDescriptor::validate_arguments() {OPENVINO_ASSERT(m_tensor_shape, "Tensor Shape is nullptr");@@ -40,7 +54,8 @@ void PortDescriptor::validate_arguments() {}OPENVINO_ASSERT(m_subtensor_shape.size() <= m_tensor_shape->size(),"Snippets tensor descriptor: Subtensor shape must be less than or equal to tensor shape");- OPENVINO_ASSERT(m_layout.size() == m_tensor_shape->size(), "Snippets tensor descriptor: Layout size must be equal to the shape size");+ OPENVINO_ASSERT(m_layout.size() == m_tensor_shape->size(),+ "Snippets tensor descriptor: Layout size must be equal to the shape size");}const VectorDims& PortDescriptor::get_shape() const {@@ -103,10 +118,8 @@ std::string PortDescriptor::serialize() const {return ss.str();}bool operator==(const PortDescriptor& lhs, const PortDescriptor& rhs) {- return lhs.m_tensor_shape == rhs.m_tensor_shape &&- lhs.m_layout == rhs.m_layout &&- lhs.m_subtensor_shape == rhs.m_subtensor_shape &&- lhs.m_reg == rhs.m_reg;+ return lhs.m_tensor_shape == rhs.m_tensor_shape && lhs.m_layout == rhs.m_layout &&+ lhs.m_subtensor_shape == rhs.m_subtensor_shape && lhs.m_reg == rhs.m_reg;}void PortDescriptorUtils::init_default(std::vector<PortDescriptorPtr>& in_descs,@@ -159,7 +172,7 @@ void PortDescriptorUtils::set_port_descriptor_ptr(const ov::Output<ov::Node>& ou}namespace {-template<typename T>+template <typename T>void set_port_desc(const T& port, std::vector<size_t> subtensor, std::vector<size_t> layout) {const auto& shape = utils::pshape_to_vdims(port.get_partial_shape());for (size_t i = 1; i <= std::min(subtensor.size(), shape.size()); i++) {@@ -171,10 +184,14 @@ void set_port_desc(const T& port, std::vector<size_t> subtensor, std::vector<siz}} // namespace-void PortDescriptorUtils::set_port_descriptor(const ov::Input<ov::Node>& in, std::vector<size_t> subtensor, std::vector<size_t> layout) {+void PortDescriptorUtils::set_port_descriptor(const ov::Input<ov::Node>& in,+ std::vector<size_t> subtensor,+ std::vector<size_t> layout) {set_port_desc(in, std::move(subtensor), std::move(layout));}-void PortDescriptorUtils::set_port_descriptor(const ov::Output<ov::Node>& out, std::vector<size_t> subtensor, std::vector<size_t> layout) {+void PortDescriptorUtils::set_port_descriptor(const ov::Output<ov::Node>& out,+ std::vector<size_t> subtensor,+ std::vector<size_t> layout) {set_port_desc(out, std::move(subtensor), std::move(layout));}@@ -228,6 +245,6 @@ 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 lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/specific_loop_iter_handlers.cpp b/src/common/snippets/src/lowered/specific_loop_iter_handlers.cppindex 41c63d98b2f..e92348484e7 100644--- a/src/common/snippets/src/lowered/specific_loop_iter_handlers.cpp+++ b/src/common/snippets/src/lowered/specific_loop_iter_handlers.cpp@@ -8,19 +8,21 @@#include "snippets/lowered/pass/propagate_subtensors.hpp"#include "snippets/utils/utils.hpp"-namespace ov {namespace snippets {namespace lowered {-SpecificIterationHandlers::SpecificIterationHandlers(size_t loop_work_amount, size_t loop_increment, size_t processing_dim_idx) {+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>();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) {- // [149935] : Last Iterations of Loop processed last dimensions with Eltwise nodes inside should have increment = 1+ // [149935] : Last Iterations of Loop processed last dimensions with Eltwise nodes inside should have+ // increment = 1last_iter_increment = 1;}if (last_iter_increment != 0) {@@ -40,15 +42,14 @@ SpecificIterationHandlers::SpecificIterationHandlers(lowered::pass::PassPipelinem_main_body_handlers(std::move(main_body_handlers)),m_last_iter_handlers(std::move(last_iter_handlers)) {}-SpecificIterationHandlers SpecificIterationHandlers::merge_handlers(- const SpecificIterationHandlers& lhs,- const SpecificIterationHandlers& rhs) {+SpecificIterationHandlers 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));}-} // namespace lowered-} // namespace snippets-} // namespace ov+} // namespace lowered+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/lowered/target_machine.cpp b/src/common/snippets/src/lowered/target_machine.cppindex 4536c3d6d62..b6db7cdcaad 100644--- a/src/common/snippets/src/lowered/target_machine.cpp+++ b/src/common/snippets/src/lowered/target_machine.cpp@@ -7,7 +7,8 @@#include "snippets/runtime_configurator.hpp"using namespace ov::snippets;-std::function<std::shared_ptr<Emitter>(const lowered::ExpressionPtr&)> TargetMachine::get(const ov::DiscreteTypeInfo& type) const {+std::function<std::shared_ptr<Emitter>(const lowered::ExpressionPtr&)> TargetMachine::get(+ const ov::DiscreteTypeInfo& type) const {auto jitter = jitters.find(type);OPENVINO_ASSERT(jitter != jitters.end(), "Target code emitter is not available for ", type.name, " operation.");return jitter->second.first;@@ -16,7 +17,10 @@ std::function<std::shared_ptr<Emitter>(const lowered::ExpressionPtr&)> TargetMacstd::function<std::set<ov::element::TypeVector>(const std::shared_ptr<ov::Node>&)>TargetMachine::get_supported_precisions(const ov::DiscreteTypeInfo& type) const {auto jitter = jitters.find(type);- OPENVINO_ASSERT(jitter != jitters.end(), "Supported precisions set is not available for ", type.name, " operation.");+ OPENVINO_ASSERT(jitter != jitters.end(),+ "Supported precisions set is not available for ",+ type.name,+ " operation.");return jitter->second.second;}diff --git a/src/common/snippets/src/op/brgemm.cpp b/src/common/snippets/src/op/brgemm.cppindex 6c8c46fde5e..7fe89a0e013 100644--- a/src/common/snippets/src/op/brgemm.cpp+++ b/src/common/snippets/src/op/brgemm.cpp@@ -2,14 +2,13 @@// SPDX-License-Identifier: Apache-2.0//-#include <cassert>-#include "snippets/op/brgemm.hpp"-#include "snippets/itt.hpp"-#include "snippets/utils/utils.hpp"+#include <cassert>#include "openvino/core/rt_info.hpp"+#include "snippets/itt.hpp"+#include "snippets/utils/utils.hpp"namespace ov {namespace snippets {@@ -30,12 +29,18 @@ std::vector<size_t> get_output_layout(const std::shared_ptr<const ov::Node>& n)return {};}-} // namespace--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)- : MemoryAccess(std::set<size_t>{0, 1}, std::set<size_t>{0}), Op({A, B}) {+} // namespace++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)+ : 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);@@ -43,22 +48,30 @@ Brgemm::Brgemm(const Output<Node>& A, const Output<Node>& B,custom_constructor_validate_and_infer_types(std::move(layout_a), std::move(layout_b), std::move(layout_c));}-Brgemm::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)- : MemoryAccess(PortMap{{0, desc_a}, {1, desc_b}}, PortMap{{0, desc_c}}), Op({A, B}) {+Brgemm::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)+ : 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));}-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(std::vector<size_t> layout_a,+ std::vector<size_t> layout_b,+ 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.// So we use explicit layouts from parametersconst auto planar_input_shapes =- std::vector<ov::PartialShape>{ ov::snippets::utils::get_planar_pshape(get_input_partial_shape(0), layout_a),- ov::snippets::utils::get_planar_pshape(get_input_partial_shape(1), layout_b) };+ std::vector<ov::PartialShape>{ov::snippets::utils::get_planar_pshape(get_input_partial_shape(0), layout_a),+ ov::snippets::utils::get_planar_pshape(get_input_partial_shape(1), layout_b)};auto output_shape = infer_output_partial_shape(planar_input_shapes);set_output_type(0, get_output_type(), ov::snippets::utils::get_planar_pshape(output_shape, layout_c));}@@ -74,8 +87,11 @@ void Brgemm::validate_and_infer_types() {std::shared_ptr<Node> Brgemm::clone_with_new_inputs(const OutputVector& new_args) const {INTERNAL_OP_SCOPE(Brgemm_clone_with_new_inputs);check_new_args_count(this, new_args);- return std::make_shared<Brgemm>(new_args.at(0), new_args.at(1),- get_input_port_descriptor(0), get_input_port_descriptor(1), get_output_port_descriptor(0),+ return std::make_shared<Brgemm>(new_args.at(0),+ new_args.at(1),+ get_input_port_descriptor(0),+ get_input_port_descriptor(1),+ get_output_port_descriptor(0),lowered::PortDescriptorUtils::get_port_descriptor_ptr(input(0))->get_layout(),lowered::PortDescriptorUtils::get_port_descriptor_ptr(input(1))->get_layout(),lowered::PortDescriptorUtils::get_port_descriptor_ptr(output(0))->get_layout());@@ -103,9 +119,7 @@ ov::element::Type Brgemm::get_output_type() const {auto output_type = get_output_type(get_input_element_type(0), get_input_element_type(1));if (output_type == element::dynamic) {OPENVINO_THROW("BrgemmCPU node has incompatible input element types: " +- get_input_element_type(0).get_type_name() +- " and " +- get_input_element_type(1).get_type_name());+ get_input_element_type(0).get_type_name() + " and " + get_input_element_type(1).get_type_name());}return output_type;@@ -113,12 +127,12 @@ ov::element::Type Brgemm::get_output_type() const {std::vector<ov::PartialShape> Brgemm::get_planar_input_shapes(const std::vector<ov::Input<ov::Node>>& inputs) const {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]) };+ return {utils::get_planar_pshape(inputs[0]), utils::get_planar_pshape(inputs[1])};}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 creation- const auto& out_layout = get_output_layout(shared_from_this());+ const auto& out_layout = get_output_layout(shared_from_this());if (!out_layout.empty())return utils::get_planar_pshape(output_shape, out_layout);@@ -158,8 +172,12 @@ ov::PartialShape Brgemm::infer_output_partial_shape(const std::vector<ov::Partiaauto merged_dimension = DimType();auto arg0_col_dim = arg0_shape_tmp[arg0_rank - 1];auto arg1_row_dim = arg1_shape_tmp[arg1_rank - 2];- OPENVINO_ASSERT(DimType::merge(merged_dimension, arg0_col_dim, arg1_row_dim) || arg0_col_dim.is_dynamic() || arg1_row_dim.is_dynamic(),- "Incompatible Brgemm matrix dimension. arg0_col_dim = ", arg0_col_dim, ", arg1_row_dim = ", arg1_row_dim);+ OPENVINO_ASSERT(DimType::merge(merged_dimension, arg0_col_dim, arg1_row_dim) || arg0_col_dim.is_dynamic() ||+ arg1_row_dim.is_dynamic(),+ "Incompatible Brgemm matrix dimension. arg0_col_dim = ",+ arg0_col_dim,+ ", arg1_row_dim = ",+ arg1_row_dim);// add 1 to begin to align shape ranks if neededif (arg0_rank < arg1_rank)@@ -170,9 +188,8 @@ ov::PartialShape Brgemm::infer_output_partial_shape(const std::vector<ov::Partiasize_t max_rank = arg0_shape_tmp.size();std::vector<DimType> output_shape(max_rank);for (size_t i = 0; i < max_rank - 2; ++i) {- OPENVINO_ASSERT(DimType::broadcast_merge(output_shape[i], arg0_shape_tmp[i], arg1_shape_tmp[i]) ||- arg0_shape_tmp[i].is_dynamic() ||- arg1_shape_tmp[i].is_dynamic(),+ OPENVINO_ASSERT(DimType::broadcast_merge(output_shape[i], arg0_shape_tmp[i], arg1_shape_tmp[i]) ||+ arg0_shape_tmp[i].is_dynamic() || arg1_shape_tmp[i].is_dynamic(),"Incompatible Brgemm batch dimension");}output_shape[output_shape.size() - 2] = arg0_shape_tmp[arg0_shape_tmp.size() - 2]; // M@@ -187,6 +204,6 @@ ov::PartialShape Brgemm::infer_output_partial_shape(const std::vector<ov::Partia}return output_shape;}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/op/broadcastload.cpp b/src/common/snippets/src/op/broadcastload.cppindex 6c02b7e63ff..33b09228f4f 100644--- a/src/common/snippets/src/op/broadcastload.cpp+++ b/src/common/snippets/src/op/broadcastload.cpp@@ -12,7 +12,9 @@ namespace snippets {namespace op {BroadcastLoad::BroadcastLoad(const Output<Node>& x, ov::Dimension bcast_dimension, size_t offset)- : MemoryAccess(std::set<size_t>{0}, std::set<size_t>{}), Op({x}), bcast_dimension(std::move(bcast_dimension)) {+ : MemoryAccess(std::set<size_t>{0}, std::set<size_t>{}),+ Op({x}),+ bcast_dimension(std::move(bcast_dimension)) {set_input_port_descriptor({1, offset}, 0);constructor_validate_and_infer_types();}@@ -32,7 +34,8 @@ void BroadcastLoad::validate_and_infer_types() {// BroadcastLoad has memory access port only on inputconst 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() == 1 && is_memory_access_input_port(0), "BroadcastLoad node must have memory access input port");+ 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");auto broadcasted_shape = get_input_partial_shape(0);if (broadcasted_shape.size() == 0)@@ -41,6 +44,6 @@ void BroadcastLoad::validate_and_infer_types() {set_output_type(0, get_input_element_type(0), broadcasted_shape);}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/op/broadcastmove.cpp b/src/common/snippets/src/op/broadcastmove.cppindex c504db9a523..d48c1bc46a4 100644--- a/src/common/snippets/src/op/broadcastmove.cpp+++ b/src/common/snippets/src/op/broadcastmove.cpp@@ -2,16 +2,17 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/itt.hpp"-#include "snippets/op/broadcastmove.hpp"+#include "snippets/itt.hpp"namespace ov {namespace snippets {namespace op {-BroadcastMove::BroadcastMove(const Output<Node>& x, ov::Dimension bcast_dimension) : Op({x}), bcast_dimension(std::move(bcast_dimension)) {+BroadcastMove::BroadcastMove(const Output<Node>& x, ov::Dimension bcast_dimension)+ : Op({x}),+ bcast_dimension(std::move(bcast_dimension)) {constructor_validate_and_infer_types();}@@ -34,6 +35,6 @@ void BroadcastMove::validate_and_infer_types() {set_output_type(0, get_input_element_type(0), broadcasted_shape);}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/op/buffer.cpp b/src/common/snippets/src/op/buffer.cppindex 69ca1de8f4e..2ce520dfbdc 100644--- a/src/common/snippets/src/op/buffer.cpp+++ b/src/common/snippets/src/op/buffer.cpp@@ -2,13 +2,11 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/op/buffer.hpp"#include "snippets/itt.hpp"#include "snippets/utils/utils.hpp"-namespace ov {namespace snippets {namespace op {@@ -18,7 +16,9 @@ Buffer::Buffer(const ov::Output<ov::Node>& arg) : Buffer(ov::OutputVector{arg})Buffer::Buffer(const OutputVector& arguments) : Op(arguments), m_impl(std::make_shared<IntermediateMemoryImpl>()) {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)) {+Buffer::Buffer(const ov::Shape& shape, ov::element::Type element_type)+ : Op(),+ 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)) {@@ -61,19 +61,24 @@ void Buffer::IntermediateMemoryImpl::validate_and_infer_types(Buffer* buffer) coconst auto inputs = buffer->input_values();const auto& inshape = buffer->get_input_partial_shape(0);const auto& intype = buffer->get_input_element_type(0);- OPENVINO_ASSERT(std::all_of(inputs.cbegin() + 1, inputs.cend(),- [&](const ov::Output<ov::Node>& in) { return in.get_partial_shape() == inshape && in.get_element_type() == intype; }),+ OPENVINO_ASSERT(std::all_of(inputs.cbegin() + 1,+ inputs.cend(),+ [&](const ov::Output<ov::Node>& in) {+ return in.get_partial_shape() == inshape && in.get_element_type() == intype;+ }),"All inputs of Buffers must have the same shape and element type");buffer->set_output_type(0, intype, inshape);}-Buffer::IntermediateMemoryImpl::ShapeInfer::Result Buffer::IntermediateMemoryImpl::ShapeInfer::infer(const std::vector<VectorDimsRef>& input_shapes) {+Buffer::IntermediateMemoryImpl::ShapeInfer::Result Buffer::IntermediateMemoryImpl::ShapeInfer::infer(+ const std::vector<VectorDimsRef>& input_shapes) {OPENVINO_ASSERT(!input_shapes.empty(), "IntermediateMemoryBuffer shape inference must have input shapes");return {{input_shapes[0].get()}, ShapeInferStatus::success};}Buffer::NewMemoryImpl::NewMemoryImpl(const ov::Shape& shape, ov::element::Type element_type)- : m_shape(shape), m_element_type(element_type) {}+ : m_shape(shape),+ m_element_type(element_type) {}size_t Buffer::NewMemoryImpl::get_allocation_size() const {return ov::shape_size(m_shape);@@ -97,11 +102,12 @@ bool Buffer::NewMemoryImpl::visit_attributes(AttributeVisitor& visitor) {Buffer::NewMemoryImpl::ShapeInfer::ShapeInfer(ov::Shape shape) : m_shape(std::move(shape)) {}-Buffer::NewMemoryImpl::ShapeInfer::Result Buffer::NewMemoryImpl::ShapeInfer::infer(const std::vector<VectorDimsRef>& input_shapes) {+Buffer::NewMemoryImpl::ShapeInfer::Result Buffer::NewMemoryImpl::ShapeInfer::infer(+ const std::vector<VectorDimsRef>& input_shapes) {OPENVINO_ASSERT(input_shapes.empty(), "NewMemoryBuffer shape inference must have input shapes");return {{m_shape}, ShapeInferStatus::success};}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/op/convert_saturation.cpp b/src/common/snippets/src/op/convert_saturation.cppindex 14f2a722754..b913e27110e 100644--- a/src/common/snippets/src/op/convert_saturation.cpp+++ b/src/common/snippets/src/op/convert_saturation.cpp@@ -2,15 +2,15 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/itt.hpp"-#include "snippets/op/convert_saturation.hpp"+#include "snippets/itt.hpp"+ov::snippets::op::ConvertSaturation::ConvertSaturation(const Output<Node>& x, const ov::element::Type& destination_type)- : ov::op::v0::Convert({x}, destination_type) {-}+ : ov::op::v0::Convert({x}, destination_type) {}-std::shared_ptr<ov::Node> ov::snippets::op::ConvertSaturation::clone_with_new_inputs(const OutputVector& new_args) const {+std::shared_ptr<ov::Node> ov::snippets::op::ConvertSaturation::clone_with_new_inputs(+ const OutputVector& new_args) const {INTERNAL_OP_SCOPE(ConvertSaturation_clone_with_new_inputs);check_new_args_count(this, new_args);return std::make_shared<ConvertSaturation>(new_args.at(0), m_destination_type);diff --git a/src/common/snippets/src/op/convert_truncation.cpp b/src/common/snippets/src/op/convert_truncation.cppindex 58e725f63d9..24321b4bce4 100644--- a/src/common/snippets/src/op/convert_truncation.cpp+++ b/src/common/snippets/src/op/convert_truncation.cpp@@ -2,15 +2,15 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/itt.hpp"-#include "snippets/op/convert_truncation.hpp"+#include "snippets/itt.hpp"+ov::snippets::op::ConvertTruncation::ConvertTruncation(const Output<Node>& x, const ov::element::Type& destination_type)- : ov::op::v0::Convert({x}, destination_type) {-}+ : ov::op::v0::Convert({x}, destination_type) {}-std::shared_ptr<ov::Node> ov::snippets::op::ConvertTruncation::clone_with_new_inputs(const OutputVector& new_args) const {+std::shared_ptr<ov::Node> ov::snippets::op::ConvertTruncation::clone_with_new_inputs(+ const OutputVector& new_args) const {INTERNAL_OP_SCOPE(ConvertTruncation_clone_with_new_inputs);check_new_args_count(this, new_args);return std::make_shared<ConvertTruncation>(new_args.at(0), m_destination_type);diff --git a/src/common/snippets/src/op/fill.cpp b/src/common/snippets/src/op/fill.cppindex b49873a59e6..bd76ec26411 100644--- a/src/common/snippets/src/op/fill.cpp+++ b/src/common/snippets/src/op/fill.cpp@@ -2,17 +2,18 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/itt.hpp"-#include "snippets/op/fill.hpp"+#include "snippets/itt.hpp"namespace ov {namespace snippets {namespace op {Fill::Fill(const Output<Node>& x, const size_t offset, const uint32_t fill_value)- : Op({x}), m_offset(offset), m_fill_value(fill_value) {+ : Op({x}),+ m_offset(offset),+ m_fill_value(fill_value) {constructor_validate_and_infer_types();}@@ -32,11 +33,12 @@ std::shared_ptr<Node> Fill::clone_with_new_inputs(const OutputVector& new_args)void Fill::validate_and_infer_types() {INTERNAL_OP_SCOPE(Fill_validate_and_infer_types);const auto in_type = get_input_element_type(0);- OPENVINO_ASSERT(in_type.size() == 4, "Fill operation supports only element types with 4 byte size but got:" + std::to_string(in_type.size()));+ OPENVINO_ASSERT(+ in_type.size() == 4,+ "Fill operation supports only element types with 4 byte size but got:" + std::to_string(in_type.size()));set_output_type(0, get_input_element_type(0), get_input_partial_shape(0));}-} // namespace op-} // namespace snippets-} // namespace ov-+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/op/horizon_max.cpp b/src/common/snippets/src/op/horizon_max.cppindex 31b1e28d7ba..7f4911ccf43 100644--- a/src/common/snippets/src/op/horizon_max.cpp+++ b/src/common/snippets/src/op/horizon_max.cpp@@ -2,9 +2,10 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/itt.hpp"#include "snippets/op/horizon_max.hpp"+#include "snippets/itt.hpp"+namespace ov {namespace snippets {namespace op {@@ -28,6 +29,6 @@ void HorizonMax::validate_and_infer_types() {set_output_type(0, get_input_element_type(0), new_shape);}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/op/horizon_sum.cpp b/src/common/snippets/src/op/horizon_sum.cppindex f8ff2c550cd..7c8594d5a6a 100644--- a/src/common/snippets/src/op/horizon_sum.cpp+++ b/src/common/snippets/src/op/horizon_sum.cpp@@ -2,9 +2,10 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/itt.hpp"#include "snippets/op/horizon_sum.hpp"+#include "snippets/itt.hpp"+namespace ov {namespace snippets {namespace op {@@ -28,6 +29,6 @@ void HorizonSum::validate_and_infer_types() {set_output_type(0, get_input_element_type(0), new_shape);}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/op/kernel.cpp b/src/common/snippets/src/op/kernel.cppindex 51d4848a31c..ac983407c48 100644--- a/src/common/snippets/src/op/kernel.cpp+++ b/src/common/snippets/src/op/kernel.cpp@@ -24,6 +24,6 @@ std::shared_ptr<Node> KernelDynamic::clone_with_new_inputs(const OutputVector& ireturn std::make_shared<KernelDynamic>(*region.get());}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/op/load.cpp b/src/common/snippets/src/op/load.cppindex ee6405606fe..2aacd94fc78 100644--- a/src/common/snippets/src/op/load.cpp+++ b/src/common/snippets/src/op/load.cpp@@ -2,18 +2,18 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/itt.hpp"-#include "snippets/op/load.hpp"-#include "snippets/utils/utils.hpp"+#include "snippets/itt.hpp"+#include "snippets/utils/utils.hpp"namespace ov {namespace snippets {namespace 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>{}), Op({x}) {+ : MemoryAccess(std::set<size_t>{0}, std::set<size_t>{}),+ Op({x}) {set_input_port_descriptor({count, offset}, 0);constructor_validate_and_infer_types();}@@ -22,7 +22,8 @@ void Load::validate_memory_access_params() const {// Load 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() == 1 && is_memory_access_input_port(0), "Load node must have memory access input port");+ 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");}@@ -42,12 +43,14 @@ std::shared_ptr<Node> Load::clone_with_new_inputs(const OutputVector& new_args)}LoadReorder::LoadReorder(const Output<ov::Node>& x, const size_t count, const size_t offset, std::vector<size_t> order)- : Load(x, count, offset), m_order(std::move(order)) {+ : Load(x, count, offset),+ m_order(std::move(order)) {const auto& in_shape = x.get_partial_shape();const auto in_shape_size = in_shape.size();OPENVINO_ASSERT(m_order.size() == in_shape_size, "LoadReorder got new_order of invalid size");OPENVINO_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");+ *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");constructor_validate_and_infer_types();@@ -82,6 +85,6 @@ 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 op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/op/loop.cpp b/src/common/snippets/src/op/loop.cppindex dca4cf2132b..7958ae0b74d 100644--- a/src/common/snippets/src/op/loop.cpp+++ b/src/common/snippets/src/op/loop.cpp@@ -2,17 +2,17 @@// SPDX-License-Identifier: Apache-2.0//-#include <cassert>-#include "snippets/op/loop.hpp"+#include <cassert>+#include "snippets/utils/utils.hpp"namespace ov {namespace snippets {namespace op {-LoopBase::LoopBase(const std::vector<Output<Node>> &args) : Op(args) {}+LoopBase::LoopBase(const std::vector<Output<Node>>& args) : Op(args) {}LoopBegin::LoopBegin() : LoopBase() {validate_and_infer_types_except_LoopEnd();@@ -27,7 +27,8 @@ void LoopBegin::validate_and_infer_types() {validate_and_infer_types_except_LoopEnd();OPENVINO_ASSERT(get_output_size() == 1, "LoopBegin must have only one output");const auto& last_output_inputs = get_output_target_inputs(0);- OPENVINO_ASSERT(last_output_inputs.size() == 1, "LoopBegin must have exactly one input attached to the last output");+ OPENVINO_ASSERT(last_output_inputs.size() == 1,+ "LoopBegin must have exactly one input attached to the last output");OPENVINO_ASSERT(ov::is_type<LoopEnd>(last_output_inputs.begin()->get_node()),"LoopBegin must have LoopEnd connected to its last output");}@@ -45,20 +46,27 @@ std::shared_ptr<LoopEnd> LoopBegin::get_loop_end() const {return loop_end;}-LoopEnd::LoopEnd(const Output<Node>& loop_begin, size_t work_amount, size_t work_amount_increment,- std::vector<bool> is_incremented, std::vector<int64_t> ptr_increments, std::vector<int64_t> finalization_offsets,- std::vector<int64_t> element_type_sizes, size_t input_num, size_t output_num, size_t id)- : LoopBase({loop_begin}),- m_is_incremented(std::move(is_incremented)),- m_ptr_increments(std::move(ptr_increments)),- m_finalization_offsets(std::move(finalization_offsets)),- m_element_type_sizes(std::move(element_type_sizes)),- m_work_amount(work_amount),- m_work_amount_increment(work_amount_increment),- m_input_num(input_num),- m_output_num(output_num),- m_id(id),- m_evaluate_once(false) {+LoopEnd::LoopEnd(const Output<Node>& loop_begin,+ size_t work_amount,+ size_t work_amount_increment,+ std::vector<bool> is_incremented,+ std::vector<int64_t> ptr_increments,+ std::vector<int64_t> finalization_offsets,+ std::vector<int64_t> element_type_sizes,+ size_t input_num,+ size_t output_num,+ size_t id)+ : LoopBase({loop_begin}),+ m_is_incremented(std::move(is_incremented)),+ m_ptr_increments(std::move(ptr_increments)),+ m_finalization_offsets(std::move(finalization_offsets)),+ m_element_type_sizes(std::move(element_type_sizes)),+ m_work_amount(work_amount),+ m_work_amount_increment(work_amount_increment),+ m_input_num(input_num),+ m_output_num(output_num),+ m_id(id),+ m_evaluate_once(false) {constructor_validate_and_infer_types();}@@ -68,11 +76,15 @@ void LoopEnd::validate_and_infer_types() {const auto io_size = m_input_num + m_output_num;NODE_VALIDATION_CHECK(this, loop_begin != nullptr, "LoopEnd must have LoopBegin as the last argument");-#define VALIDATE_VALUES(values, name, default_value) \- NODE_VALIDATION_CHECK(this, 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()) \+#define VALIDATE_VALUES(values, name, default_value) \+ NODE_VALIDATION_CHECK(this, \+ 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);VALIDATE_VALUES(m_is_incremented, "is_incremented", true)@@ -84,7 +96,7 @@ void LoopEnd::validate_and_infer_types() {set_output_type(0, element::f32, ov::PartialShape{});}-bool LoopEnd::visit_attributes(AttributeVisitor &visitor) {+bool LoopEnd::visit_attributes(AttributeVisitor& visitor) {std::vector<int> int_incremented(m_is_incremented.cbegin(), m_is_incremented.cend());auto work_amount = utils::value2str(m_work_amount);auto ptr_increments = utils::vector2str(m_ptr_increments);@@ -104,14 +116,23 @@ bool LoopEnd::visit_attributes(AttributeVisitor &visitor) {std::shared_ptr<Node> LoopEnd::clone_with_new_inputs(const OutputVector& inputs) const {check_new_args_count(this, inputs);- const auto loop_end = std::make_shared<LoopEnd>(inputs.at(0), m_work_amount, m_work_amount_increment, m_is_incremented, m_ptr_increments,- m_finalization_offsets, m_element_type_sizes, m_input_num, m_output_num, m_id);+ const auto loop_end = std::make_shared<LoopEnd>(inputs.at(0),+ m_work_amount,+ m_work_amount_increment,+ m_is_incremented,+ m_ptr_increments,+ m_finalization_offsets,+ m_element_type_sizes,+ m_input_num,+ m_output_num,+ m_id);loop_end->m_evaluate_once = m_evaluate_once;return loop_end;}std::shared_ptr<LoopBegin> LoopEnd::get_loop_begin() {- const auto& loop_begin = ov::as_type_ptr<LoopBegin>(get_input_source_output(get_input_size() - 1).get_node_shared_ptr());+ const auto& loop_begin =+ ov::as_type_ptr<LoopBegin>(get_input_source_output(get_input_size() - 1).get_node_shared_ptr());assert(loop_begin != nullptr && "LoopEnd last input is not connected to LoopBegin");return loop_begin;}@@ -160,7 +181,8 @@ bool LoopEnd::has_dynamic_params() const {auto is_vector_dynamic = [](const std::vector<int64_t>& values) {return std::any_of(values.cbegin(), values.cend(), utils::is_dynamic_value<int64_t>);};- return utils::is_dynamic_value(m_work_amount) || is_vector_dynamic(m_ptr_increments) || is_vector_dynamic(m_finalization_offsets);+ return utils::is_dynamic_value(m_work_amount) || is_vector_dynamic(m_ptr_increments) ||+ is_vector_dynamic(m_finalization_offsets);}void LoopEnd::set_is_incremented(std::vector<bool> is_incremented) {@@ -197,6 +219,6 @@ void LoopEnd::set_id(size_t id) {m_id = id;}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/op/memory_access.cpp b/src/common/snippets/src/op/memory_access.cppindex 31bc4e5afc1..faad24dc3fc 100644--- a/src/common/snippets/src/op/memory_access.cpp+++ b/src/common/snippets/src/op/memory_access.cpp@@ -2,11 +2,12 @@// SPDX-License-Identifier: Apache-2.0//+#include "snippets/op/memory_access.hpp"+#include <cassert>-#include "snippets/op/memory_access.hpp"-#include "snippets/utils/utils.hpp"#include "snippets/itt.hpp"+#include "snippets/utils/utils.hpp"namespace ov {namespace snippets {@@ -28,7 +29,8 @@ MemoryAccess::MemoryAccess(const std::set<size_t>& input_ports, const std::set<s}MemoryAccess::MemoryAccess(const PortMap& input_ports, const PortMap& output_ports)- : m_input_ports(input_ports), m_output_ports(output_ports) {}+ : m_input_ports(input_ports),+ m_output_ports(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) {@@ -62,7 +64,8 @@ bool MemoryAccess::visit_attributes(AttributeVisitor& visitor) {visitor.on_attribute("count_in_" + std::to_string(idx), count);visitor.on_attribute("offset_in_" + std::to_string(idx), offset);visitor.on_attribute("stride_in_" + std::to_string(idx), stride);- is_dynamic |= utils::is_dynamic_value(port.count) || utils::is_dynamic_value(port.offset) || utils::is_dynamic_value(port.stride);+ is_dynamic |= utils::is_dynamic_value(port.count) || utils::is_dynamic_value(port.offset) ||+ utils::is_dynamic_value(port.stride);}for (const auto& p : m_output_ports) {auto idx = p.first;@@ -73,7 +76,8 @@ bool MemoryAccess::visit_attributes(AttributeVisitor& visitor) {visitor.on_attribute("count_out_" + std::to_string(idx), count);visitor.on_attribute("offset_out_" + std::to_string(idx), offset);visitor.on_attribute("stride_out_" + std::to_string(idx), stride);- is_dynamic |= utils::is_dynamic_value(port.count) || utils::is_dynamic_value(port.offset) || utils::is_dynamic_value(port.stride);+ is_dynamic |= utils::is_dynamic_value(port.count) || utils::is_dynamic_value(port.offset) ||+ utils::is_dynamic_value(port.stride);}std::string dynamic_status = is_dynamic ? "DYNAMIC" : "STATIC";@@ -91,54 +95,60 @@ bool MemoryAccess::is_memory_access_output_port(size_t idx) const {void MemoryAccess::set_input_port_descriptor(const PortDescriptor& desc, const size_t i) {const auto it = m_input_ports.find(i);- OPENVINO_ASSERT(it != m_input_ports.end(), "Index of input port descriptor should be less than count of input ports");+ OPENVINO_ASSERT(it != m_input_ports.end(),+ "Index of input port descriptor should be less than count of input ports");it->second = desc;it->second.index = i;}void MemoryAccess::set_output_port_descriptor(const PortDescriptor& desc, const size_t i) {const auto it = m_output_ports.find(i);- OPENVINO_ASSERT(it != m_output_ports.end(), "Index of output port descriptor should be less than count of output ports");+ OPENVINO_ASSERT(it != m_output_ports.end(),+ "Index of output port descriptor should be less than count of output ports");it->second = desc;it->second.index = i;}const MemoryAccess::PortDescriptor& MemoryAccess::get_input_port_descriptor(const size_t i) const {const auto it = m_input_ports.find(i);- OPENVINO_ASSERT(it != m_input_ports.end(), "Index of input port descriptor should be less than count of input ports");+ OPENVINO_ASSERT(it != m_input_ports.end(),+ "Index of input port descriptor should be less than count of input ports");return it->second;}MemoryAccess::PortDescriptor& MemoryAccess::get_input_port_descriptor(const size_t i) {- return const_cast<MemoryAccess::PortDescriptor&>(const_cast<const MemoryAccess*>(this)->get_input_port_descriptor(i));+ return const_cast<MemoryAccess::PortDescriptor&>(+ const_cast<const MemoryAccess*>(this)->get_input_port_descriptor(i));}const MemoryAccess::PortDescriptor& MemoryAccess::get_output_port_descriptor(const size_t i) const {const auto it = m_output_ports.find(i);- OPENVINO_ASSERT(it != m_output_ports.end(), "Index of output port descriptor should be less than count of output ports");+ OPENVINO_ASSERT(it != m_output_ports.end(),+ "Index of output port descriptor should be less than count of output ports");return it->second;}MemoryAccess::PortDescriptor& MemoryAccess::get_output_port_descriptor(const size_t i) {- return const_cast<MemoryAccess::PortDescriptor&>(const_cast<const MemoryAccess*>(this)->get_output_port_descriptor(i));+ return const_cast<MemoryAccess::PortDescriptor&>(+ const_cast<const MemoryAccess*>(this)->get_output_port_descriptor(i));}-void MemoryAccess::set_input_count(size_t count, size_t idx) {+void MemoryAccess::set_input_count(size_t count, size_t idx) {get_input_port_descriptor(idx).count = count;}void MemoryAccess::set_output_count(size_t count, size_t idx) {get_output_port_descriptor(idx).count = count;}-void MemoryAccess::set_input_offset(size_t offset, size_t idx) {+void MemoryAccess::set_input_offset(size_t offset, size_t idx) {get_input_port_descriptor(idx).offset = offset;}void MemoryAccess::set_output_offset(size_t offset, size_t idx) {get_output_port_descriptor(idx).offset = offset;}-void MemoryAccess::set_input_stride(size_t stride, size_t idx) {+void MemoryAccess::set_input_stride(size_t stride, size_t idx) {get_input_port_descriptor(idx).stride = stride;}-void MemoryAccess::set_output_stride(size_t stride, size_t idx) {+void MemoryAccess::set_output_stride(size_t stride, size_t idx) {get_output_port_descriptor(idx).stride = stride;}size_t MemoryAccess::get_input_count(size_t idx) const {@@ -160,6 +170,6 @@ size_t MemoryAccess::get_output_stride(size_t idx) const {return get_output_port_descriptor(idx).stride;}-} // namespace modifier-} // namespace snippets-} // namespace ov+} // namespace modifier+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/op/nop.cpp b/src/common/snippets/src/op/nop.cppindex 75c29cdeb7a..dd9f4270737 100644--- a/src/common/snippets/src/op/nop.cpp+++ b/src/common/snippets/src/op/nop.cpp@@ -4,12 +4,10 @@#include "snippets/op/nop.hpp"-ov::snippets::op::Nop::Nop(const OutputVector& arguments, const OutputVector& results): Op([arguments, results]() -> OutputVector {- OutputVector x;- x.insert(x.end(), arguments.begin(), arguments.end());- x.insert(x.end(), results.begin(), results.end());- return x;- }()) {-}+ OutputVector x;+ x.insert(x.end(), arguments.begin(), arguments.end());+ x.insert(x.end(), results.begin(), results.end());+ return x;+ }()) {}diff --git a/src/common/snippets/src/op/perf_count.cpp b/src/common/snippets/src/op/perf_count.cppindex 0d07d888ae6..d2c25dff2af 100644--- a/src/common/snippets/src/op/perf_count.cpp+++ b/src/common/snippets/src/op/perf_count.cpp@@ -3,9 +3,9 @@//#ifdef SNIPPETS_DEBUG_CAPS-#include <fstream>+# include "snippets/op/perf_count.hpp"-#include "snippets/op/perf_count.hpp"+# include <fstream>namespace ov {namespace snippets {@@ -16,7 +16,7 @@ namespace utils {//////////////////utils::Dumper///////////////-void Dumper::init(const std::string ¶ms) {+void Dumper::init(const std::string& params) {m_params = params;}@@ -85,7 +85,8 @@ CSVDumper::~CSVDumper() {void CSVDumper::update(const op::PerfCountEnd* node) {auto accumulation = node->get_accumulation();auto iteration = node->get_iteration();- OPENVINO_ASSERT(accumulation.size() == iteration.size(), "accumulation size should be the same as iteration size in perf_count_end node.");+ OPENVINO_ASSERT(accumulation.size() == iteration.size(),+ "accumulation size should be the same as iteration size in perf_count_end node.");auto iterator_iter = iteration.begin();auto iterator_acc = accumulation.begin();uint64_t avg_max = 0;@@ -119,12 +120,13 @@ void PerfCountBeginBase::validate_and_infer_types() {validate_and_infer_types_except_PerfCountEnd();OPENVINO_ASSERT(get_output_size() == 1, "PerfCountBegin must have only one output");const auto& last_output_inputs = get_output_target_inputs(0);- OPENVINO_ASSERT(last_output_inputs.size() == 1, "PerfCountBegin must have exactly one input attached to the last output");+ OPENVINO_ASSERT(last_output_inputs.size() == 1,+ "PerfCountBegin must have exactly one input attached to the last output");const auto& pc_end = ov::as_type_ptr<PerfCountEndBase>(last_output_inputs.begin()->get_node()->shared_from_this());OPENVINO_ASSERT(pc_end != nullptr, "PerfCountBegin must have PerfCountEnd connected to its last output");}-bool PerfCountBeginBase::visit_attributes(AttributeVisitor &visitor) {+bool PerfCountBeginBase::visit_attributes(AttributeVisitor& visitor) {return true;}@@ -134,16 +136,18 @@ void PerfCountBeginBase::validate_and_infer_types_except_PerfCountEnd() {}//////////////////PerfCountEndBase/////////////////-PerfCountEndBase::PerfCountEndBase(const std::vector<Output<Node>> &args) : Op(args) {}+PerfCountEndBase::PerfCountEndBase(const std::vector<Output<Node>>& args) : Op(args) {}void PerfCountEndBase::validate_and_infer_types() {NODE_VALIDATION_CHECK(this, get_input_size() == 1, "PerfCountEndBase must have one input");const auto& pc_begin = ov::as_type_ptr<PerfCountBeginBase>(get_input_node_shared_ptr(0));- NODE_VALIDATION_CHECK(this, pc_begin != nullptr, "PerfCountEndBase must have PerfCountBeginBase as the last argument");+ NODE_VALIDATION_CHECK(this,+ pc_begin != nullptr,+ "PerfCountEndBase must have PerfCountBeginBase as the last argument");set_output_type(0, element::f32, {});}-bool PerfCountEndBase::visit_attributes(AttributeVisitor &visitor) {+bool PerfCountEndBase::visit_attributes(AttributeVisitor& visitor) {return true;}@@ -204,7 +208,7 @@ void PerfCountEnd::init_pc_begin() {NODE_VALIDATION_CHECK(this, m_pc_begin != nullptr, "PerfCountEnd last input is not connected to PerfCountBegin");}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ov#endif // SNIPPETS_DEBUG_CAPSdiff --git a/src/common/snippets/src/op/rank_normalization.cpp b/src/common/snippets/src/op/rank_normalization.cppindex d93bbedc069..d781bd458b7 100644--- a/src/common/snippets/src/op/rank_normalization.cpp+++ b/src/common/snippets/src/op/rank_normalization.cpp@@ -3,14 +3,17 @@//#include "snippets/op/rank_normalization.hpp"+#include "snippets/utils/utils.hpp"namespace ov {namespace snippets {namespace op {-RankNormalization::RankNormalization(const Output<Node>& data, size_t num_prepend, size_t num_append) :- ShapeInferOp({data}), m_num_prepend(num_prepend), m_num_append(num_append) {+RankNormalization::RankNormalization(const Output<Node>& data, size_t num_prepend, size_t num_append)+ : ShapeInferOp({data}),+ m_num_prepend(num_prepend),+ m_num_append(num_append) {constructor_validate_and_infer_types();}@@ -22,7 +25,8 @@ std::shared_ptr<ov::Node> RankNormalization::clone_with_new_inputs(const OutputVvoid RankNormalization::validate_and_infer_types() {auto new_shape = get_input_partial_shape(0);// Note: other values are not allowed, only planar + blocked layout combination can be normalized.- NODE_VALIDATION_CHECK(this, utils::one_of(m_num_append, 0lu, 1lu),+ NODE_VALIDATION_CHECK(this,+ utils::one_of(m_num_append, 0lu, 1lu),"num_append could be only 0 or 1, other values are not allowed.");new_shape.insert(new_shape.begin(), m_num_prepend, Dimension(1));new_shape.insert(new_shape.end(), m_num_append, Dimension(1));@@ -42,15 +46,15 @@ RankNormalization::ShapeInfer::ShapeInfer(const std::shared_ptr<ov::Node>& n) {m_num_prepend = rank_norm->m_num_prepend;}-IShapeInferSnippets::Result-RankNormalization::ShapeInfer::infer(const std::vector<VectorDimsRef>& input_shapes) {- OPENVINO_ASSERT(input_shapes.size() == 1, "Invalid number of input shapes passed to RankNormalization::ShapeInfer::infer");+IShapeInferSnippets::Result RankNormalization::ShapeInfer::infer(const std::vector<VectorDimsRef>& input_shapes) {+ OPENVINO_ASSERT(input_shapes.size() == 1,+ "Invalid number of input shapes passed to RankNormalization::ShapeInfer::infer");VectorDims out_shape = input_shapes[0].get();out_shape.insert(out_shape.begin(), m_num_prepend, 1);out_shape.insert(out_shape.end(), m_num_append, 1);return {{out_shape}, ShapeInferStatus::success};}-} // namespace op-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace op+} // namespace snippets+} // namespace ov\ No newline at end of filediff --git a/src/common/snippets/src/op/reduce.cpp b/src/common/snippets/src/op/reduce.cppindex 50b3c38516e..7388134dc22 100644--- a/src/common/snippets/src/op/reduce.cpp+++ b/src/common/snippets/src/op/reduce.cpp@@ -5,8 +5,8 @@#include "snippets/op/reduce.hpp"#include "snippets/itt.hpp"-#include "snippets/utils/utils.hpp"#include "snippets/lowered/port_descriptor.hpp"+#include "snippets/utils/utils.hpp"namespace ov {namespace snippets {@@ -35,8 +35,12 @@ void ReduceBase::compute_and_set_reduce_subtensors(const std::shared_ptr<ReduceBstd::vector<size_t> subtensor(reduce_rank, 1);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));- lowered::PortDescriptorUtils::set_port_descriptor_ptr(reduce->output(0), std::make_shared<lowered::PortDescriptor>(reduce->output(0), subtensor));+ lowered::PortDescriptorUtils::set_port_descriptor_ptr(+ reduce->input(0),+ std::make_shared<lowered::PortDescriptor>(reduce->input(0), subtensor));+ lowered::PortDescriptorUtils::set_port_descriptor_ptr(+ reduce->output(0),+ std::make_shared<lowered::PortDescriptor>(reduce->output(0), subtensor));}std::shared_ptr<Node> ReduceSum::clone_with_new_inputs(const OutputVector& new_args) const {@@ -51,6 +55,6 @@ 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 op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/op/reg_spill.cpp b/src/common/snippets/src/op/reg_spill.cppindex 7f9b8cff0ba..b380bb90314 100644--- a/src/common/snippets/src/op/reg_spill.cpp+++ b/src/common/snippets/src/op/reg_spill.cpp@@ -10,9 +10,9 @@ namespace ov {namespace snippets {namespace op {-RegSpillBase::RegSpillBase(const std::vector<Output<Node>> &args) : Op(args) {}+RegSpillBase::RegSpillBase(const std::vector<Output<Node>>& args) : Op(args) {}-bool RegSpillBase::visit_attributes(AttributeVisitor &visitor) {+bool RegSpillBase::visit_attributes(AttributeVisitor& visitor) {std::stringstream ss;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++) {@@ -38,7 +38,8 @@ void RegSpillBegin::validate_and_infer_types() {validate_and_infer_types_except_RegSpillEnd();OPENVINO_ASSERT(get_output_size() == 1, "RegSpillBegin must have only one output");const auto& last_output_inputs = get_output_target_inputs(0);- OPENVINO_ASSERT(last_output_inputs.size() == 1, "RegSpillBegin must have exactly one input attached to the last output");+ OPENVINO_ASSERT(last_output_inputs.size() == 1,+ "RegSpillBegin must have exactly one input attached to the last output");OPENVINO_ASSERT(ov::is_type<RegSpillEnd>(last_output_inputs.begin()->get_node()),"RegSpillBegin must have RegSpillEnd connected to its last output");}@@ -71,8 +72,9 @@ RegSpillEnd::RegSpillEnd(const Output<Node>& reg_spill_begin) : RegSpillBase({re}void RegSpillEnd::validate_and_infer_types() {- NODE_VALIDATION_CHECK(this, get_input_size() == 1 && ov::is_type<RegSpillBegin>(get_input_node_shared_ptr(0)),- "RegSpillEnd must have one input of RegSPillBegin type");+ NODE_VALIDATION_CHECK(this,+ get_input_size() == 1 && ov::is_type<RegSpillBegin>(get_input_node_shared_ptr(0)),+ "RegSpillEnd must have one input of RegSPillBegin type");set_output_type(0, element::f32, ov::PartialShape{});}@@ -81,7 +83,6 @@ 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 op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/op/reorder.cpp b/src/common/snippets/src/op/reorder.cppindex 43d8387a8cb..c39549f3dca 100644--- a/src/common/snippets/src/op/reorder.cpp+++ b/src/common/snippets/src/op/reorder.cpp@@ -2,18 +2,16 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/itt.hpp"-#include "snippets/op/reorder.hpp"-#include "snippets/utils/utils.hpp"+#include "snippets/itt.hpp"+#include "snippets/utils/utils.hpp"namespace ov {namespace snippets {namespace op {-Reorder::Reorder(const Output<Node>& arg, std::vector<size_t> order)- : ShapeInferOp({arg}) {+Reorder::Reorder(const Output<Node>& arg, std::vector<size_t> order) : ShapeInferOp({arg}) {custom_constructor_validate_and_infer_types(std::move(order));}@@ -22,7 +20,7 @@ void Reorder::custom_constructor_validate_and_infer_types(std::vector<size_t> orconst auto& input_pshape = get_input_partial_shape(0);OPENVINO_ASSERT(input_pshape.rank().is_static() && input_pshape.size() == order.size(),- "Incompatible shape and order sizes");+ "Incompatible shape and order sizes");// During ctor call, Reorder doesn't know his port descriptors.// So we use explicit layouts from parameters@@ -62,6 +60,6 @@ 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 op+} // namespace snippets+} // namespace ov\ No newline at end of filediff --git a/src/common/snippets/src/op/reshape.cpp b/src/common/snippets/src/op/reshape.cppindex 9b46ea73247..1fdecdb0ae6 100644--- a/src/common/snippets/src/op/reshape.cpp+++ b/src/common/snippets/src/op/reshape.cpp@@ -2,18 +2,18 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/itt.hpp"-#include "snippets/op/reshape.hpp"-#include "snippets/utils/utils.hpp"+#include "snippets/itt.hpp"+#include "snippets/utils/utils.hpp"namespace ov {namespace snippets {namespace op {Reshape::Reshape(const Output<Node>& arg, ov::PartialShape target_shape)- : ShapeInferOp({arg}), m_target_shape(std::move(target_shape)) {+ : ShapeInferOp({arg}),+ m_target_shape(std::move(target_shape)) {constructor_validate_and_infer_types();}@@ -52,11 +52,12 @@ Reshape::ShapeInfer::ShapeInfer(const std::shared_ptr<Node>& n) {IShapeInferSnippets::Result Reshape::ShapeInfer::infer(const std::vector<VectorDimsRef>& input_shapes) {OPENVINO_ASSERT(input_shapes.size() == 1, "Invalid number of shapes is passed in ReshapeShapeInfer");const auto input_shape_volume = utils::get_shape_size(input_shapes[0].get());- OPENVINO_ASSERT(input_shape_volume == target_shape_volume, "Tensor volume should be the same after reshape in ReshapeShapeInfer");+ OPENVINO_ASSERT(input_shape_volume == target_shape_volume,+ "Tensor volume should be the same after reshape in ReshapeShapeInfer");return {{target_shape}, ShapeInferStatus::success};}-}// namespace op-}// namespace snippets-}// namespace ov\ No newline at end of file+} // namespace op+} // namespace snippets+} // namespace ov\ No newline at end of filediff --git a/src/common/snippets/src/op/scalar.cpp b/src/common/snippets/src/op/scalar.cppindex 528bf1c904e..16266a7b241 100644--- a/src/common/snippets/src/op/scalar.cpp+++ b/src/common/snippets/src/op/scalar.cpp@@ -18,9 +18,11 @@ void Scalar::validate_and_infer_types() {Constant::validate_and_infer_types();auto out_pshape = get_output_partial_shape(0);NODE_VALIDATION_CHECK(this, out_pshape.is_static(), "Scalar supports only static input shapes");- NODE_VALIDATION_CHECK(this, out_pshape.get_shape().empty() || ov::shape_size(out_pshape.get_shape()) == 1,- "Scalar supports only one-element constants, got ", out_pshape.get_shape(),- " shape");+ NODE_VALIDATION_CHECK(this,+ out_pshape.get_shape().empty() || ov::shape_size(out_pshape.get_shape()) == 1,+ "Scalar supports only one-element constants, got ",+ out_pshape.get_shape(),+ " shape");}bool Scalar::visit_attributes(AttributeVisitor& visitor) {@@ -33,6 +35,6 @@ bool Scalar::visit_attributes(AttributeVisitor& visitor) {return true;}-} // namespace op-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace op+} // namespace snippets+} // namespace ov\ No newline at end of filediff --git a/src/common/snippets/src/op/serialization_node.cpp b/src/common/snippets/src/op/serialization_node.cppindex 8162aebe397..bef13704e7f 100644--- a/src/common/snippets/src/op/serialization_node.cpp+++ b/src/common/snippets/src/op/serialization_node.cpp@@ -4,7 +4,6 @@#include "snippets/op/serialization_node.hpp"-namespace ov {namespace snippets {namespace op {@@ -15,7 +14,8 @@ SerializationNode::SerializationNode(const ov::OutputVector& args,: Op(args),m_expr(expr),m_mode(mode) {- OPENVINO_ASSERT(m_expr && m_expr->get_node(), "SerializationNode requires a valid expression with non-null node pointer");+ OPENVINO_ASSERT(m_expr && m_expr->get_node(),+ "SerializationNode requires a valid expression with non-null node pointer");const auto& node = expr->get_node();set_friendly_name(node->get_friendly_name());std::string type = node->get_type_name();@@ -34,15 +34,15 @@ void SerializationNode::validate_and_infer_types() {}}-std::shared_ptr<Node> SerializationNode::clone_with_new_inputs(const OutputVector &new_args) const {+std::shared_ptr<Node> SerializationNode::clone_with_new_inputs(const OutputVector& new_args) const {check_new_args_count(this, new_args);return std::make_shared<SerializationNode>(new_args, m_expr, m_mode);}-bool SerializationNode::visit_attributes(AttributeVisitor &visitor) {+bool SerializationNode::visit_attributes(AttributeVisitor& visitor) {return m_expr->visit_attributes(visitor);}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/op/store.cpp b/src/common/snippets/src/op/store.cppindex 2b95c1e4568..ea3256b1514 100644--- a/src/common/snippets/src/op/store.cpp+++ b/src/common/snippets/src/op/store.cpp@@ -2,17 +2,17 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/itt.hpp"-#include "snippets/op/store.hpp"+#include "snippets/itt.hpp"namespace ov {namespace snippets {namespace 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}), Op({x}) {+ : MemoryAccess(std::set<size_t>{}, std::set<size_t>{0}),+ Op({x}) {set_output_port_descriptor({count, offset}, 0);constructor_validate_and_infer_types();}@@ -22,7 +22,8 @@ void snippets::op::Store::validate_and_infer_types() {const 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(output_ma_ports.size() == 1 && is_memory_access_output_port(0), "Store node must have memory access output 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));}@@ -34,6 +35,6 @@ 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 op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/op/subgraph.cpp b/src/common/snippets/src/op/subgraph.cppindex 8c41f787bb8..2c795d771a9 100644--- a/src/common/snippets/src/op/subgraph.cpp+++ b/src/common/snippets/src/op/subgraph.cpp@@ -2,71 +2,65 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/itt.hpp"-#include "snippets/remarks.hpp"-#include "snippets/op/subgraph.hpp"-#include "snippets/pass/broadcast_to_movebroadcast.hpp"-#include "snippets/pass/propagate_precision.hpp"-#include "snippets/pass/convert_constants.hpp"-#include "snippets/pass/convert_power_to_powerstatic.hpp"-#include "snippets/pass/transpose_decomposition.hpp"-#include "snippets/pass/softmax_decomposition.hpp"-#include "snippets/pass/matmul_to_brgemm.hpp"-#include "snippets/pass/fuse_transpose_brgemm.hpp"-#include "snippets/pass/canonicalization.hpp"-#include "snippets/pass/align_element_types.hpp"-#include "snippets/pass/reduce_to_snippets_reduce.hpp"-#include "snippets/pass/gn_decomposition.hpp"--#include "snippets/runtime_configurator.hpp"-#include "snippets/utils/utils.hpp"+#include <algorithm>+#include <array>+#include <memory>-#include "snippets/lowered/port_descriptor.hpp"+#include "openvino/pass/constant_folding.hpp"+#include "ov_ops/type_relaxed.hpp"+#include "snippets/itt.hpp"#include "snippets/lowered/linear_ir.hpp"#include "snippets/lowered/linear_ir_builder.hpp"-#include "snippets/lowered/pass/mark_loops.hpp"-#include "snippets/lowered/pass/split_loops.hpp"+#include "snippets/lowered/pass/allocate_buffers.hpp"+#include "snippets/lowered/pass/clean_repeated_ptr_shifts.hpp"+#include "snippets/lowered/pass/cleanup_loop_offsets.hpp"+#include "snippets/lowered/pass/extract_loop_invariants.hpp"#include "snippets/lowered/pass/fuse_loops.hpp"#include "snippets/lowered/pass/init_loops.hpp"+#include "snippets/lowered/pass/init_registers.hpp"+#include "snippets/lowered/pass/insert_broadcastmove.hpp"#include "snippets/lowered/pass/insert_buffers.hpp"#include "snippets/lowered/pass/insert_load_store.hpp"-#include "snippets/lowered/pass/insert_broadcastmove.hpp"+#include "snippets/lowered/pass/insert_loops.hpp"+#include "snippets/lowered/pass/insert_perf_count.hpp"+#include "snippets/lowered/pass/insert_specific_iterations.hpp"#include "snippets/lowered/pass/load_movebroadcast_to_broadcastload.hpp"-#include "snippets/lowered/pass/allocate_buffers.hpp"-#include "snippets/lowered/pass/move_scalar_to_consumer.hpp"+#include "snippets/lowered/pass/mark_loops.hpp"#include "snippets/lowered/pass/move_result_out_of_loop.hpp"-#include "snippets/lowered/pass/clean_repeated_ptr_shifts.hpp"-#include "snippets/lowered/pass/validate_unified_loops.hpp"-#include "snippets/lowered/pass/insert_loops.hpp"+#include "snippets/lowered/pass/move_scalar_to_consumer.hpp"+#include "snippets/lowered/pass/normalize_loop_ids.hpp"#include "snippets/lowered/pass/optimize_domain.hpp"-#include "snippets/lowered/pass/insert_perf_count.hpp"-#include "snippets/lowered/pass/validate_shapes.hpp"-#include "snippets/lowered/pass/validate_buffers.hpp"-#include "snippets/lowered/pass/validate.hpp"+#include "snippets/lowered/pass/optimize_loop_single_evaluation.hpp"#include "snippets/lowered/pass/pass_config.hpp"#include "snippets/lowered/pass/reduce_decomposition.hpp"-#include "snippets/lowered/pass/cleanup_loop_offsets.hpp"-#include "snippets/lowered/pass/insert_specific_iterations.hpp"-#include "snippets/lowered/pass/optimize_loop_single_evaluation.hpp"-#include "snippets/lowered/pass/normalize_loop_ids.hpp"-#include "snippets/lowered/pass/validate_expanded_loops.hpp"-#include "snippets/lowered/pass/set_load_store_scalar.hpp"-#include "snippets/lowered/pass/extract_loop_invariants.hpp"#include "snippets/lowered/pass/set_dynamic_wa_to_outermost_loop.hpp"--#include "snippets/lowered/pass/init_registers.hpp"--#include "transformations/utils/utils.hpp"-+#include "snippets/lowered/pass/set_load_store_scalar.hpp"+#include "snippets/lowered/pass/split_loops.hpp"+#include "snippets/lowered/pass/validate.hpp"+#include "snippets/lowered/pass/validate_buffers.hpp"+#include "snippets/lowered/pass/validate_expanded_loops.hpp"+#include "snippets/lowered/pass/validate_shapes.hpp"+#include "snippets/lowered/pass/validate_unified_loops.hpp"+#include "snippets/lowered/port_descriptor.hpp"+#include "snippets/pass/align_element_types.hpp"+#include "snippets/pass/broadcast_to_movebroadcast.hpp"+#include "snippets/pass/canonicalization.hpp"+#include "snippets/pass/convert_constants.hpp"+#include "snippets/pass/convert_power_to_powerstatic.hpp"+#include "snippets/pass/fuse_transpose_brgemm.hpp"+#include "snippets/pass/gn_decomposition.hpp"#include "snippets/pass/manager.hpp"-#include "openvino/pass/constant_folding.hpp"-#include "ov_ops/type_relaxed.hpp"--#include <algorithm>-#include <memory>-#include <array>+#include "snippets/pass/matmul_to_brgemm.hpp"+#include "snippets/pass/propagate_precision.hpp"+#include "snippets/pass/reduce_to_snippets_reduce.hpp"+#include "snippets/pass/softmax_decomposition.hpp"+#include "snippets/pass/transpose_decomposition.hpp"+#include "snippets/remarks.hpp"+#include "snippets/runtime_configurator.hpp"+#include "snippets/utils/utils.hpp"+#include "transformations/utils/utils.hpp"using namespace std;using namespace ov::op::util;@@ -101,12 +95,15 @@ auto Subgraph::is_shape_infer_op(const std::shared_ptr<ov::Node>& op) -> bool {}void Subgraph::init_config() {- auto update = [](bool& flag, bool status) { flag = flag || status; };+ auto update = [](bool& flag, bool status) {+ flag = flag || status;+ };const auto ops = body_ptr()->get_ops();for (const auto& op : ops) {update(config.m_is_quantized, ov::is_type<ov::op::v0::FakeQuantize>(op));update(config.m_has_domain_sensitive_ops, is_domain_sensitive_op(op));- update(config.m_has_broadcast_sensitive_ops, ov::is_type_any_of<ov::op::v12::GroupNormalization, op::Reshape>(op));+ update(config.m_has_broadcast_sensitive_ops,+ ov::is_type_any_of<ov::op::v12::GroupNormalization, op::Reshape>(op));}}@@ -114,11 +111,12 @@ auto Subgraph::get_estimated_buffer_count(const ov::NodeVector& ops) -> size_t {// The count of potential unique Buffers - it's hidden virtual ports as well// We should go through Subgraph and calculate potential non-inplace Buffers count.// These Buffers can be in 2 cases:- // 1. Around Loops: we should check for element type size of nodes which use Buffer to get rating from above for unique Buffer count.- // 2. Around MatMul: all buffers around Matmul must not be inplace because MatMul blocking implementation changes registers during computations.- // The count is estimated because when we calculate this number, we have only original graph representation- // and where will be Loops - we can just predict.- // Note: The ops that create Buffers: MatMul, Transpose and Softmax (always FP32)+ // 1. Around Loops: we should check for element type size of nodes which use Buffer to get rating from above for+ // unique Buffer count.+ // 2. Around MatMul: all buffers around Matmul must not be inplace because MatMul blocking implementation changes+ // registers during computations. The count is estimated because when we calculate this number, we have only+ // original graph representation and where will be Loops - we can just predict. Note: The ops that create Buffers:+ // MatMul, Transpose and Softmax (always FP32)std::vector<size_t> used_precision_size;auto push_prc_size = [&used_precision_size](size_t precision_size) {@@ -134,11 +132,13 @@ auto Subgraph::get_estimated_buffer_count(const ov::NodeVector& ops) -> size_t {const auto consumers = transpose->get_output_target_inputs(0);// If after Transpose there is Result it means that there won't be Buffer after Transpose.// The same case is for Parameter before Transpose- const auto are_prev_or_next_ops = std::none_of(consumers.begin(), consumers.end(),- [](const ov::Input<ov::Node>& in) {- return ov::is_type<ov::op::v0::Result>(in.get_node());- }) ||- !ov::is_type<ov::op::v0::Parameter>(transpose->get_input_node_shared_ptr(0));+ const auto are_prev_or_next_ops =+ std::none_of(consumers.begin(),+ consumers.end(),+ [](const ov::Input<ov::Node>& in) {+ return ov::is_type<ov::op::v0::Result>(in.get_node());+ }) ||+ !ov::is_type<ov::op::v0::Parameter>(transpose->get_input_node_shared_ptr(0));if (are_prev_or_next_ops) {push_prc_size(transpose->get_element_type().size());}@@ -147,17 +147,17 @@ auto Subgraph::get_estimated_buffer_count(const ov::NodeVector& ops) -> size_t {// They are inplace and the same, so we can push precision size only oncepush_prc_size(ov::element::f32.size());} 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+ // Since all buffers around Matmul must be unique, we explicitely add values to the vector without any+ // checksif (!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)))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) {- return ov::is_type<ov::op::v0::Result>(in.get_node());- })) {+ if (std::none_of(consumers.begin(), consumers.end(), [](const ov::Input<ov::Node>& in) {+ return ov::is_type<ov::op::v0::Result>(in.get_node());+ })) {used_precision_size.push_back(matmul->get_element_type().size());}}@@ -167,7 +167,8 @@ auto Subgraph::get_estimated_buffer_count(const ov::NodeVector& ops) -> size_t {}Subgraph::Subgraph(const OutputVector& args, const std::shared_ptr<ov::Model>& body)- : SubGraphOp(args), m_generator(nullptr) {+ : SubGraphOp(args),+ m_generator(nullptr) {SubGraphOp::set_function(body);init_config();constructor_validate_and_infer_types();@@ -180,7 +181,7 @@ Subgraph::Subgraph(const OutputVector& args, const std::shared_ptr<ov::Model>& b}Subgraph::Subgraph(const NodeVector& args, const std::shared_ptr<ov::Model>& body)- : Subgraph(as_output_vector(args), body) {}+ : Subgraph(as_output_vector(args), body) {}std::shared_ptr<Node> Subgraph::clone_with_new_inputs(const OutputVector& inputs) const {INTERNAL_OP_SCOPE(Subgraph);@@ -196,7 +197,9 @@ void Subgraph::validate_and_infer_types() {}for (size_t i = 0; i < get_input_size(); ++i) {- body_ptr()->replace_parameter(i, std::make_shared<ov::op::v0::Parameter>(get_input_element_type(i), get_input_partial_shape(i)));+ body_ptr()->replace_parameter(+ i,+ std::make_shared<ov::op::v0::Parameter>(get_input_element_type(i), get_input_partial_shape(i)));}body_ptr()->validate_nodes_and_infer_types();@@ -228,12 +231,12 @@ auto Subgraph::wrap_node_as_subgraph(const std::shared_ptr<ov::Node>& node) -> sfor (const auto& input : node->input_values()) {if (ov::is_type<ov::opset1::Constant>(input.get_node_shared_ptr()) &&- (ov::shape_size(input.get_shape()) == 1 ||- ov::is_type<ov::op::v0::FakeQuantize>(node) ||+ (ov::shape_size(input.get_shape()) == 1 || ov::is_type<ov::op::v0::FakeQuantize>(node) ||constant_input_should_be_inside_body(node))) {body_inputs.push_back(input);} else {- auto parameter = std::make_shared<ov::opset1::Parameter>(input.get_element_type(), input.get_partial_shape());+ auto parameter =+ std::make_shared<ov::opset1::Parameter>(input.get_element_type(), input.get_partial_shape());body_parameters.push_back(parameter);body_parameters.back()->set_friendly_name(input.get_node()->get_friendly_name());body_inputs.push_back(parameter->output(0));@@ -277,7 +280,8 @@ auto Subgraph::wrap_node_as_subgraph(const std::shared_ptr<ov::Node>& node) -> sreturn subgraph;}-void Subgraph::fill_empty_output_names(const Output<Node>& target_output_node, const Output<Node>& replacement_output_node) {+void Subgraph::fill_empty_output_names(const Output<Node>& target_output_node,+ const Output<Node>& replacement_output_node) {auto& out_tensor = target_output_node.get_tensor();if (!replacement_output_node.get_names().empty()) {out_tensor.set_names(replacement_output_node.get_names());@@ -291,10 +295,9 @@ auto Subgraph::constant_input_should_be_inside_body(const std::shared_ptr<ov::Nobool Subgraph::check_broadcast(const std::shared_ptr<const ov::Node>& node) {const auto elementwise = ov::as_type_ptr<const ov::op::util::BinaryElementwiseArithmetic>(node);- return- (elementwise == nullptr) ||- (elementwise->get_input_partial_shape(0).size() == elementwise->get_input_partial_shape(1).size()) ||- (elementwise->get_autob().m_type != ov::op::AutoBroadcastType::PDPD);+ return (elementwise == nullptr) ||+ (elementwise->get_input_partial_shape(0).size() == elementwise->get_input_partial_shape(1).size()) ||+ (elementwise->get_autob().m_type != ov::op::AutoBroadcastType::PDPD);}IShapeInferSnippets::Result Subgraph::shape_infer(const std::vector<VectorDimsRef>& input_shapes) {@@ -302,15 +305,15 @@ IShapeInferSnippets::Result Subgraph::shape_infer(const std::vector<VectorDimsRereturn m_shape_infer->infer(input_shapes);}-Subgraph::OVShapeInfer::OVShapeInfer(const std::shared_ptr<ov::Model>& body) :- m_ov_body(body) {+Subgraph::OVShapeInfer::OVShapeInfer(const std::shared_ptr<ov::Model>& body) : m_ov_body(body) {OPENVINO_ASSERT(m_ov_body, "Can't initialize shape infer with empty body");}IShapeInferSnippets::Result Subgraph::OVShapeInfer::infer(const std::vector<VectorDimsRef>& input_shapes) {const ParameterVector& parameters = m_ov_body->get_parameters();const ResultVector& results = m_ov_body->get_results();- OPENVINO_ASSERT(parameters.size() == input_shapes.size(), "Got invalid number of input shapes to reshape subgraph body");+ 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)parameters[i]->set_partial_shape(utils::vdims_to_pshape(input_shapes[i].get()));m_ov_body->validate_nodes_and_infer_types();@@ -354,9 +357,10 @@ VectorDims Subgraph::infer_master_shape() {return default_broadcasting->infer(inputs).dims.front();}-std::shared_ptr<lowered::LinearIR>-Subgraph::convert_body_to_linear_ir(size_t min_parallel_work_amount, size_t min_kernel_work_amount,- const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory) {+std::shared_ptr<lowered::LinearIR> Subgraph::convert_body_to_linear_ir(+ size_t min_parallel_work_amount,+ size_t min_kernel_work_amount,+ const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory) {lowered::Config lowering_config;lowering_config.m_need_fill_tail_register = config.m_has_domain_sensitive_ops;lowering_config.m_loop_depth = tile_rank;@@ -375,7 +379,7 @@ Subgraph::convert_body_to_linear_ir(size_t min_parallel_work_amount, size_t min_std::shared_ptr<Subgraph> Subgraph::clone() const {ov::OutputVector subgraph_node_inputs;- for (const auto &input : input_values()) {+ 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);}@@ -395,16 +399,18 @@ std::shared_ptr<Subgraph> Subgraph::clone() const {return result;}-void Subgraph::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 Subgraph::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 {INTERNAL_OP_SCOPE(Subgraph);OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::op::data_flow_transformations")std::shared_ptr<ov::pass::PassConfig> pass_config = std::make_shared<ov::pass::PassConfig>();- // 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 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)pass_config->disable<snippets::pass::Canonicalization>();if (input_precisions.empty() || output_precisions.empty())@@ -434,14 +440,19 @@ void Subgraph::data_flow_transformations(const BlockedShapeVector& blocked_inputmanager.run_passes(body_ptr());}-void Subgraph::control_flow_transformations(size_t min_parallel_work_amount, size_t min_kernel_work_amount,- const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory,- const std::shared_ptr<lowered::pass::PassConfig>& lowered_pass_config,- const std::vector<lowered::pass::PassPipeline::PositionedPassLowered>& lowered_backend_passes) {+void Subgraph::control_flow_transformations(+ size_t min_parallel_work_amount,+ size_t min_kernel_work_amount,+ const std::shared_ptr<IShapeInferSnippetsFactory>& shape_infer_factory,+ const std::shared_ptr<lowered::pass::PassConfig>& lowered_pass_config,+ const std::vector<lowered::pass::PassPipeline::PositionedPassLowered>& lowered_backend_passes) {INTERNAL_OP_SCOPE(Subgraph);OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::op::control_flow_transformations")- OV_ITT_TASK_CHAIN(CONTROL_FLOW, ov::pass::itt::domains::SnippetsTransform, "Snippets::op::control_flow_transformations", "::convert_body_to_linear_ir")+ OV_ITT_TASK_CHAIN(CONTROL_FLOW,+ ov::pass::itt::domains::SnippetsTransform,+ "Snippets::op::control_flow_transformations",+ "::convert_body_to_linear_ir")convert_body_to_linear_ir(min_parallel_work_amount, min_kernel_work_amount, shape_infer_factory);OPENVINO_ASSERT(m_linear_ir, "LinearIR has not been inited for control flow transformations!");@@ -494,7 +505,8 @@ void Subgraph::control_flow_transformations(size_t min_parallel_work_amount, sizOV_ITT_TASK_NEXT(CONTROL_FLOW, "::init_shape_infer_linear_ir")- // After ControlFlow transformations we should to create LinearIR for ShapeInference - clone state of LinearIR before loop decomposition.+ // After ControlFlow transformations we should to create LinearIR for ShapeInference - clone state of LinearIR+ // before loop decomposition.const auto& cloning_config = lowered::LinearIRBuilder::Config(false);m_shape_infer_linear_ir = lowered::LinearIRBuilder(cloning_config).clone(m_linear_ir);OPENVINO_ASSERT(m_shape_infer_linear_ir, "LinearIR has not been successfully cloned!");@@ -505,9 +517,11 @@ void Subgraph::control_flow_transformations(size_t min_parallel_work_amount, sizlowered::pass::PassPipeline gen_pipeline(lowered_pass_config);// Note: the order of all passes in this pipeline must not be changed since they have hard dependencies- // 1. InsertSpecificIterations must be called after AssignRegisters since tail loop expressions must have the same+ // 1. InsertSpecificIterations must be called after AssignRegisters since tail loop expressions must have the+ // same// assigned registers as the corresponding ops in the main body.- // 2. CleanupLoopOffsets must be called after InsertSpecificIterations to avoid violating the proportionality of the pointer increments+ // 2. CleanupLoopOffsets must be called after InsertSpecificIterations to avoid violating the proportionality of+ // the pointer increments// (this might happen if tail loop and main loop have different increments)// 3. OptimizeLoopSingleEvaluation must be called after CleanupLoopOffsets// since CleanupLoopOffsets can't handle loops with evaluate_once = true@@ -521,17 +535,23 @@ void Subgraph::control_flow_transformations(size_t min_parallel_work_amount, sizgen_pipeline.run(*m_linear_ir);}-snippets::Schedule Subgraph::generate(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_backend_passes,- const std::shared_ptr<lowered::pass::PassConfig>& lowered_pass_config,- const std::vector<snippets::lowered::pass::PassPipeline::PositionedPassLowered>& lowered_backend_passes,- size_t min_parallel_work_amount, size_t min_kernel_work_amount,- const std::shared_ptr<IShapeInferSnippetsFactory>& factory,- const void* compile_params) {+snippets::Schedule Subgraph::generate(+ 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_backend_passes,+ const std::shared_ptr<lowered::pass::PassConfig>& lowered_pass_config,+ const std::vector<snippets::lowered::pass::PassPipeline::PositionedPassLowered>& lowered_backend_passes,+ size_t min_parallel_work_amount,+ size_t min_kernel_work_amount,+ const std::shared_ptr<IShapeInferSnippetsFactory>& factory,+ const void* compile_params) {data_flow_transformations(blocked_input_shapes, input_precisions, output_precisions, data_flow_backend_passes);- control_flow_transformations(min_parallel_work_amount, min_kernel_work_amount, factory, lowered_pass_config, lowered_backend_passes);+ control_flow_transformations(min_parallel_work_amount,+ min_kernel_work_amount,+ factory,+ lowered_pass_config,+ lowered_backend_passes);return generate(compile_params);}@@ -570,9 +590,8 @@ 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;+ remark(13) << "subgraph " << this->get_friendly_name() << " " << this->get_type_name() << " which contains "+ << body_ptr()->get_ops().size() << " nodes" << std::endl;int qqq = 0;for (const auto& op : body_ptr()->get_ordered_ops()) {@@ -593,6 +612,6 @@ void Subgraph::print() const {}}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/op/vector_buffer.cpp b/src/common/snippets/src/op/vector_buffer.cppindex cc4b4556356..296ade7fab9 100644--- a/src/common/snippets/src/op/vector_buffer.cpp+++ b/src/common/snippets/src/op/vector_buffer.cpp@@ -2,16 +2,15 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/itt.hpp"-#include "snippets/op/vector_buffer.hpp"+#include "snippets/itt.hpp"+namespace ov {namespace snippets {namespace 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) : Op(), m_element_type(std::move(element_type)) {constructor_validate_and_infer_types();}@@ -32,6 +31,6 @@ bool VectorBuffer::visit_attributes(AttributeVisitor& visitor) {return true;}-} // namespace op-} // namespace snippets-} // namespace ov+} // namespace op+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/pass/align_element_types.cpp b/src/common/snippets/src/pass/align_element_types.cppindex 820d31c1599..79c6dba6431 100644--- a/src/common/snippets/src/pass/align_element_types.cpp+++ b/src/common/snippets/src/pass/align_element_types.cpp@@ -4,18 +4,17 @@#include "snippets/pass/align_element_types.hpp"-#include "snippets/pass/propagate_precision.hpp"#include "snippets/itt.hpp"+#include "snippets/pass/propagate_precision.hpp"#include "snippets/utils/utils.hpp"namespace ov {namespace snippets {pass::AlignElementTypes::AlignElementTypes(std::vector<ov::element::Type> input_precisions,- std::vector<ov::element::Type> output_precisions) :- m_input_precisions(std::move(input_precisions)),- m_output_precisions(std::move(output_precisions)) {-}+ std::vector<ov::element::Type> output_precisions)+ : m_input_precisions(std::move(input_precisions)),+ m_output_precisions(std::move(output_precisions)) {}bool pass::AlignElementTypes::run_on_model(const std::shared_ptr<ov::Model>& m) {RUN_ON_MODEL_SCOPE(AlignElementTypes);@@ -38,19 +37,24 @@ bool pass::AlignElementTypes::run_on_model(const std::shared_ptr<ov::Model>& m)// So we have to insert Convert before Transpose (if there is) on Subgraph outputsconst auto transpose = ov::as_type_ptr<ov::op::v1::Transpose>(parent_output.get_node_shared_ptr());if (transpose) {- OPENVINO_ASSERT(parent_output.get_target_inputs().size() == 1,- "If Result has Transpose on input, this Result must be single consumer of the Transpose");+ OPENVINO_ASSERT(+ parent_output.get_target_inputs().size() == 1,+ "If Result has Transpose on input, this Result must be single consumer of the Transpose");parent_output = transpose->get_input_source_output(0);consumer = transpose;}- // If there is already Convert[needed_in_type->original_type] and this node has only one consumer, we can remove the Convert,- // since the sequence existing Convert[needed_in_type->original_type] -> new Convert[original_type->needed_in_type] is redundant- if (const auto existing_convert = ov::as_type_ptr<ov::snippets::op::ConvertSaturation>(parent_output.get_node_shared_ptr())) {+ // If there is already Convert[needed_in_type->original_type] and this node has only one consumer, we can+ // remove the Convert, since the sequence existing Convert[needed_in_type->original_type] -> new+ // Convert[original_type->needed_in_type] is redundant+ if (const auto existing_convert =+ ov::as_type_ptr<ov::snippets::op::ConvertSaturation>(parent_output.get_node_shared_ptr())) {const auto actual_before = existing_convert->get_input_element_type(0);const auto actual_after = existing_convert->get_output_element_type(0);const auto required_after = needed_out_type;- if (ov::snippets::pass::PropagatePrecision::can_be_removed(actual_before, actual_after, required_after) &&+ if (ov::snippets::pass::PropagatePrecision::can_be_removed(actual_before,+ actual_after,+ required_after) &&parent_output.get_target_inputs().size() == 1) {// remove existing convertexisting_convert->output(0).replace(existing_convert->input_value(0));@@ -87,10 +91,12 @@ bool pass::AlignElementTypes::run_on_model(const std::shared_ptr<ov::Model>& m)// Snippets supports Transpose only after Parameter or before Result nodes// So we have to insert Convert after Transpose (if there is) on Subgraph inputs- if (std::any_of(consumer_inputs.cbegin(), consumer_inputs.cend(),- [](const ov::Input<ov::Node>& input) { return ov::is_type<ov::op::v1::Transpose>(input.get_node()); })) {- OPENVINO_ASSERT(consumer_inputs.size() == 1,- "If Parameter has Transpose on output, this Transpose must be single consumer of the Parameter");+ if (std::any_of(consumer_inputs.cbegin(), consumer_inputs.cend(), [](const ov::Input<ov::Node>& input) {+ return ov::is_type<ov::op::v1::Transpose>(input.get_node());+ })) {+ OPENVINO_ASSERT(+ consumer_inputs.size() == 1,+ "If Parameter has Transpose on output, this Transpose must be single consumer of the Parameter");const auto transpose = consumer_inputs.begin()->get_node()->shared_from_this();transpose->validate_and_infer_types();@@ -98,13 +104,17 @@ bool pass::AlignElementTypes::run_on_model(const std::shared_ptr<ov::Model>& m)consumer_inputs = parent_output.get_target_inputs();}- // If there is already Convert[original_type->needed_in_type] and this node is alone consumer, we can remove the Convert,- // since the sequence new Convert[needed_in_type->original_type] -> existing Convert[original_type->needed_in_type] is redundant- if (const auto existing_convert = ov::as_type_ptr<ov::snippets::op::ConvertSaturation>(consumer_inputs.cbegin()->get_node()->shared_from_this())) {+ // If there is already Convert[original_type->needed_in_type] and this node is alone consumer, we can remove+ // the Convert, since the sequence new Convert[needed_in_type->original_type] -> existing+ // Convert[original_type->needed_in_type] is redundant+ if (const auto existing_convert = ov::as_type_ptr<ov::snippets::op::ConvertSaturation>(+ consumer_inputs.cbegin()->get_node()->shared_from_this())) {const auto actual_before = needed_in_type;const auto actual_after = original_type;const auto required_after = existing_convert->get_element_type();- if (ov::snippets::pass::PropagatePrecision::can_be_removed(actual_before, actual_after, required_after) &&+ if (ov::snippets::pass::PropagatePrecision::can_be_removed(actual_before,+ actual_after,+ required_after) &&consumer_inputs.size() == 1) {// remove existing convertexisting_convert->output(0).replace(parent_output);@@ -130,5 +140,5 @@ 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 snippets+} // namespace ov\ No newline at end of filediff --git a/src/common/snippets/src/pass/analyze_broadcastable_inputs.cpp b/src/common/snippets/src/pass/analyze_broadcastable_inputs.cppindex 4d78b6b78c2..cf71201cefa 100644--- a/src/common/snippets/src/pass/analyze_broadcastable_inputs.cpp+++ b/src/common/snippets/src/pass/analyze_broadcastable_inputs.cpp@@ -4,9 +4,9 @@#include "snippets/pass/analyze_broadcastable_inputs.hpp"+#include "snippets/itt.hpp"#include "snippets/lowered/pass/insert_broadcastmove.hpp"#include "snippets/utils/utils.hpp"-#include "snippets/itt.hpp"namespace ov {namespace snippets {@@ -23,9 +23,10 @@ bool pass::AnalyzeBroadcastableInputs::run_on_model(const std::shared_ptr<ov::Mo// Binary Elementwise ops (+ Select) requires explicit Broadcast op// on inputs if broadcasting of latest dimensions is needed.// These ops will be start points of DFS - need to go to Parameters and update `broadcastable_inputs_map`.- // We iterates through all ops by execution order. So if we already analyzied some op in the input branch - skip this branch.- // However, there some ops which can change `processing_dim_idx`:- // - Transpose has order which changes `processing_dim_idx`. But Transpose can be only after Parameters and before Results.+ // We iterates through all ops by execution order. So if we already analyzied some op in the input branch - skip+ // this branch. However, there some ops which can change `processing_dim_idx`:+ // - Transpose has order which changes `processing_dim_idx`. But Transpose can be only after Parameters and before+ // Results.// - MatMul's first input doesn't affect output latest dimension - skip this branch.// Also MatMul has `transposed_b` which changes `processing_dim_idx`m_broadcastable_inputs.clear();@@ -51,19 +52,22 @@ bool pass::AnalyzeBroadcastableInputs::run_on_model(const std::shared_ptr<ov::Moif (const auto& param = ov::as_type_ptr<ov::op::v0::Parameter>(current_node)) {const auto consumers = param->get_output_target_inputs(0);- if (std::any_of(consumers.cbegin(), consumers.cend(),- [](const ov::Input<ov::Node>& in) { return ov::is_type<ov::op::v1::Transpose>(in.get_node()); })) {+ if (std::any_of(consumers.cbegin(), consumers.cend(), [](const ov::Input<ov::Node>& in) {+ return 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();std::vector<size_t> order;- const auto& constant = ov::as_type_ptr<const opset1::Constant>(transpose->get_input_node_shared_ptr(1));+ const auto& constant =+ ov::as_type_ptr<const opset1::Constant>(transpose->get_input_node_shared_ptr(1));OPENVINO_ASSERT(constant, "Unsupported order node of Transpose");order = constant->cast_vector<size_t>();if (order.empty()) {order = utils::get_planar_layout(transpose->get_output_partial_shape(0).size());}// `processing_dim_idx` starts from the end- processing_dim_idx = order.size() - 1 - ov::snippets::utils::get_input_dim_idx(order, processing_dim_idx);+ processing_dim_idx =+ order.size() - 1 - ov::snippets::utils::get_input_dim_idx(order, processing_dim_idx);}const auto param_idx = body->get_parameter_index(param);if (m_broadcastable_inputs.count(param_idx) == 0) {@@ -81,7 +85,7 @@ bool pass::AnalyzeBroadcastableInputs::run_on_model(const std::shared_ptr<ov::Moov::OutputVector inputs = current_node->input_values();if (const auto mm = ov::as_type_ptr<ov::op::v0::MatMul>(current_node)) {- inputs = { current_node->input_value(1) };+ inputs = {current_node->input_value(1)};processing_dim_idx = static_cast<size_t>(mm->get_transpose_b());}@@ -100,6 +104,6 @@ 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 pass+} // namespace snippets+} // namespace ov\ No newline at end of filediff --git a/src/common/snippets/src/pass/broadcast_to_movebroadcast.cpp b/src/common/snippets/src/pass/broadcast_to_movebroadcast.cppindex 2077925cc90..4f49c347eb3 100644--- a/src/common/snippets/src/pass/broadcast_to_movebroadcast.cpp+++ b/src/common/snippets/src/pass/broadcast_to_movebroadcast.cpp@@ -2,22 +2,20 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/itt.hpp"-#include "snippets/pass/broadcast_to_movebroadcast.hpp"-#include "snippets/op/broadcastmove.hpp"-#include "openvino/pass/pattern/op/wrap_type.hpp"-#include "openvino/opsets/opset1.hpp"#include "openvino/core/rt_info.hpp"-+#include "openvino/opsets/opset1.hpp"+#include "openvino/pass/pattern/op/wrap_type.hpp"+#include "snippets/itt.hpp"+#include "snippets/op/broadcastmove.hpp"ov::snippets::pass::BroadcastToMoveBroadcast::BroadcastToMoveBroadcast() {MATCHER_SCOPE(BroadcastToMoveBroadcast);auto m_broadcast = ov::pass::pattern::wrap_type<ov::op::v1::Broadcast, ov::op::v3::Broadcast>();- auto callback = [](ov::pass::pattern::Matcher &m) {+ auto callback = [](ov::pass::pattern::Matcher& m) {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)) {@@ -30,9 +28,11 @@ ov::snippets::pass::BroadcastToMoveBroadcast::BroadcastToMoveBroadcast() {const auto target_shape = root->get_output_partial_shape(0);const auto value_shape = root->get_input_partial_shape(0);- OPENVINO_ASSERT(target_shape.is_static() && value_shape.rank().is_static(), "Broadcast with dynamic target shape is not supported in Snippets");+ OPENVINO_ASSERT(target_shape.is_static() && value_shape.rank().is_static(),+ "Broadcast with dynamic target shape is not supported in Snippets");// Insert BroadcastMove only if the last dimension needs to be broadcasted. Higher-level dims broadcasting- // will be handled by pointer arithmetics. Note that this behavior should be changed in case of full op::Boradcast support.+ // will be handled by pointer arithmetics. Note that this behavior should be changed in case of full+ // op::Boradcast support.Output<ov::Node> in_value = root->input_value(0);if (*target_shape.rbegin() != *value_shape.rbegin()) {auto broadcasted_dim = ov::Dimension(*target_shape.rbegin());diff --git a/src/common/snippets/src/pass/canonicalization.cpp b/src/common/snippets/src/pass/canonicalization.cppindex cda37a9ad14..df459bb89f1 100644--- a/src/common/snippets/src/pass/canonicalization.cpp+++ b/src/common/snippets/src/pass/canonicalization.cpp@@ -3,10 +3,11 @@//#include "snippets/pass/canonicalization.hpp"-#include "snippets/op/rank_normalization.hpp"+#include "snippets/itt.hpp"-#include "snippets/utils/utils.hpp"#include "snippets/lowered/port_descriptor.hpp"+#include "snippets/op/rank_normalization.hpp"+#include "snippets/utils/utils.hpp"namespace ov {namespace snippets {@@ -19,7 +20,8 @@ pass::Canonicalization::Canonicalization(const BlockedShapeVector& blocked_inputm_in_shapes.emplace_back(bs.first);m_in_layouts.emplace_back(bs.second);// Note: Blocking (if any) must be accounted for in input shapes- OPENVINO_ASSERT(m_in_shapes.back().size() == m_in_layouts.back().size(), "Input shapes and layouts must have the same rank");+ OPENVINO_ASSERT(m_in_shapes.back().size() == m_in_layouts.back().size(),+ "Input shapes and layouts must have the same rank");}}@@ -30,7 +32,11 @@ bool pass::Canonicalization::run_on_model(const std::shared_ptr<ov::Model>& m) {const ParameterVector& params = m->get_parameters();OPENVINO_ASSERT(m_in_shapes.size() == params.size(),"Number of parameters for snippet doesn't match passed to the Canonicalization pass. ",- "Expected: ", m_in_shapes.size(), " Got: ", params.size(), ".");+ "Expected: ",+ m_in_shapes.size(),+ " Got: ",+ params.size(),+ ".");// Note that shape rank also incorporates layout, so NCHW16c would have shape rank 5auto is_blocked_layout = [](const Layout& l) {@@ -58,12 +64,14 @@ bool pass::Canonicalization::run_on_model(const std::shared_ptr<ov::Model>& m) {// then insert RankNormalization op after this input. This is needed, so all shapes inside the body have// similar ranks.if (i_is_blocked) {- OPENVINO_ASSERT(base_is_blocked && i_rank == max_rank, "If this shape is blocked, base must also be blocked");+ OPENVINO_ASSERT(base_is_blocked && i_rank == max_rank,+ "If this shape is blocked, base must also be blocked");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;- OPENVINO_ASSERT(max_rank >= i_rank + num_append, "Unsupported blocked shapes combination in canonicalization");+ 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();@@ -73,12 +81,13 @@ bool pass::Canonicalization::run_on_model(const std::shared_ptr<ov::Model>& m) {is_modified = true;} else {// todo: 4d blocked + 5d planar layouts are not supported: <N, C, H, W, c> + <N, C, D, H, W>- OPENVINO_ASSERT(equal(base_layout.begin(), base_layout.end(), i_layout.begin()),- "Canonicalization got input shapes of equal ranks but different layouts, which is not supported");+ OPENVINO_ASSERT(+ equal(base_layout.begin(), base_layout.end(), i_layout.begin()),+ "Canonicalization got input shapes of equal ranks but different layouts, which is not supported");}}return is_modified;}-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace snippets+} // namespace ov\ No newline at end of filediff --git a/src/common/snippets/src/pass/collapse_subgraph.cpp b/src/common/snippets/src/pass/collapse_subgraph.cppindex 2ac74481268..aef075c00ac 100644--- a/src/common/snippets/src/pass/collapse_subgraph.cpp+++ b/src/common/snippets/src/pass/collapse_subgraph.cpp@@ -2,6 +2,8 @@// SPDX-License-Identifier: Apache-2.0//+#include "snippets/pass/collapse_subgraph.hpp"+#include <cassert>#include <climits>#include <memory>@@ -15,23 +17,21 @@#include "openvino/opsets/opset1.hpp"#include "snippets/itt.hpp"#include "snippets/op/subgraph.hpp"-#include "snippets/pass/collapse_subgraph.hpp"#include "snippets/pass/fq_decomposition.hpp"#include "snippets/pass/fuse_transpose_brgemm.hpp"#include "snippets/pass/tokenization.hpp"#include "snippets/pass/transpose_decomposition.hpp"#include "snippets/remarks.hpp"-#include "snippets/utils/utils.hpp"#include "snippets/utils/tokenization_utils.hpp"+#include "snippets/utils/utils.hpp"#include "transformations/utils/utils.hpp"namespace ov {namespace snippets {namespace pass {-namespace {-auto is_supported_op(const std::shared_ptr<const Node> &n) -> bool {+auto is_supported_op(const std::shared_ptr<const Node>& n) -> bool {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::is_supported_op")auto is_supported_matmul = [](const std::shared_ptr<const Node>& n) -> bool {const auto& matmul = ov::as_type_ptr<const opset1::MatMul>(n);@@ -58,7 +58,8 @@ auto is_supported_op(const std::shared_ptr<const Node> &n) -> bool {// Transpose decomposition is supported only for Transpose nodes right after Subgraph's parametersdecomposition_case = false;const auto body = subgraph->body_ptr();- const auto subgraph_output = body->get_results()[transpose->input_value(0).get_index()]->get_input_node_shared_ptr(0);+ const auto subgraph_output =+ body->get_results()[transpose->input_value(0).get_index()]->get_input_node_shared_ptr(0);is_brgemm_case = is_brgemm_case || ov::is_type<opset1::MatMul>(subgraph_output);}}@@ -77,7 +78,7 @@ auto is_supported_op(const std::shared_ptr<const Node> &n) -> bool {return CommonFakeQuantizeDecomposition::is_supported_fq(ov::as_type_ptr<const opset1::FakeQuantize>(n));};- auto is_supported_ternary_eltwise_op = [](const std::shared_ptr<const Node> &n) -> bool {+ auto is_supported_ternary_eltwise_op = [](const std::shared_ptr<const Node>& n) -> bool {return ov::is_type<ov::op::v1::Select>(n);};@@ -128,7 +129,7 @@ auto is_supported_op(const std::shared_ptr<const Node> &n) -> bool {ov::op::v4::HSwish>(n);};- auto is_supported_softmax = [](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())return false;int64_t axis = -1;@@ -145,7 +146,7 @@ auto is_supported_op(const std::shared_ptr<const Node> &n) -> bool {return axis >= 0 && axis == (rank.get_length() - 1);};- auto is_supported_broadcast_op = [](const std::shared_ptr<const Node> &n) -> bool {+ auto is_supported_broadcast_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;@@ -155,12 +156,13 @@ auto is_supported_op(const std::shared_ptr<const Node> &n) -> bool {return false;};- auto is_supported_reduce_op = [](const std::shared_ptr<const Node> &n) -> bool {+ auto is_supported_reduce_op = [](const std::shared_ptr<const Node>& n) -> bool {if (ov::is_type_any_of<const ov::op::v1::ReduceMax, const ov::op::v1::ReduceSum>(n)) {const auto& reduce_base = ov::as_type_ptr<const ov::op::util::ArithmeticReductionKeepDims>(n);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)+ if (rank.is_dynamic() || !reduce_base->get_keep_dims() || !axis_constant ||+ shape_size(axis_constant->get_shape()) != 1)return false;const auto axis_value = axis_constant->cast_vector<int32_t>(1)[0];@@ -171,24 +173,18 @@ auto is_supported_op(const std::shared_ptr<const Node> &n) -> bool {return false;};- return is_supported_fq_op(n) ||- is_supported_unary_eltwise_op(n) ||- is_supported_binary_eltwise_op(n) ||- is_supported_ternary_eltwise_op(n) ||- is_supported_transpose(n) ||- is_supported_softmax(n) ||- is_supported_matmul(n) ||- is_supported_broadcast_op(n) ||- is_supported_reduce_op(n);+ return is_supported_fq_op(n) || is_supported_unary_eltwise_op(n) || is_supported_binary_eltwise_op(n) ||+ is_supported_ternary_eltwise_op(n) || is_supported_transpose(n) || is_supported_softmax(n) ||+ is_supported_matmul(n) || is_supported_broadcast_op(n) || is_supported_reduce_op(n);}-auto has_supported_in_out(const std::shared_ptr<const Node> &n) -> bool {+auto has_supported_in_out(const std::shared_ptr<const Node>& n) -> bool {auto supported = [](descriptor::Tensor& t) -> bool {// TODO [122585] Need to add dynamic rank supportreturn t.get_partial_shape().rank().is_static();};- const auto& inputs = n->inputs();- const auto& outputs = n->outputs();+ const auto& inputs = n->inputs();+ const auto& outputs = n->outputs();// todo: Is this check necessary? Remove if notfor (const auto& out : outputs) {for (const auto& in_out : out.get_target_inputs()) {@@ -197,10 +193,16 @@ auto has_supported_in_out(const std::shared_ptr<const Node> &n) -> bool {}}}- return std::all_of(inputs.begin(), inputs.end(), [&](const Input<const Node>& in) {return supported(in.get_tensor());}) &&- std::all_of(outputs.begin(), outputs.end(), [&](const Output<const Node>& out) {return supported(out.get_tensor());});+ return std::all_of(inputs.begin(),+ inputs.end(),+ [&](const Input<const Node>& in) {+ return supported(in.get_tensor());+ }) &&+ std::all_of(outputs.begin(), outputs.end(), [&](const Output<const Node>& out) {+ return supported(out.get_tensor());+ });}-} // namespace+} // namespaceconst std::set<ov::element::Type>& ov::snippets::pass::TokenizeSnippets::get_supported_element_types() {static const std::set<ov::element::Type> supported_element_types = {ov::element::f32,@@ -211,28 +213,24 @@ const std::set<ov::element::Type>& ov::snippets::pass::TokenizeSnippets::get_supreturn supported_element_types;}-bool TokenizeSnippets::AppropriateForSubgraph(const std::shared_ptr<const Node> &node) {- return- is_supported_op(node) &&- has_supported_in_out(node) &&- node->get_control_dependencies().empty() &&- snippets::op::Subgraph::check_broadcast(node);+bool TokenizeSnippets::AppropriateForSubgraph(const std::shared_ptr<const Node>& node) {+ return is_supported_op(node) && has_supported_in_out(node) && node->get_control_dependencies().empty() &&+ snippets::op::Subgraph::check_broadcast(node);}TokenizeSnippets::TokenizeSnippets(const SnippetsTokenization::Config& config) {MATCHER_SCOPE(TokenizeSnippets);- auto label = ov::pass::pattern::any_input(- [](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- // or align this with the custom MHA tokenization pass.- return (GetSnippetsNodeType(n) != SnippetsNodeType::SkippedByPlugin ||- ov::is_type_any_of<ov::op::v0::MatMul, ov::op::v1::Transpose>(n)) &&- AppropriateForSubgraph(n);- });- ov::graph_rewrite_callback callback = [OV_CAPTURE_CPY_AND_THIS](ov::pass::pattern::Matcher &m) -> bool {+ auto label = ov::pass::pattern::any_input([](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+ // or align this with the custom MHA tokenization pass.+ return (GetSnippetsNodeType(n) != SnippetsNodeType::SkippedByPlugin ||+ ov::is_type_any_of<ov::op::v0::MatMul, ov::op::v1::Transpose>(n)) &&+ AppropriateForSubgraph(n);+ });+ ov::graph_rewrite_callback callback = [OV_CAPTURE_CPY_AND_THIS](ov::pass::pattern::Matcher& m) -> bool {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::CreateSubgraph_callback")auto node = m.get_match_root();if (transformation_callback(node)) {@@ -244,6 +242,6 @@ TokenizeSnippets::TokenizeSnippets(const SnippetsTokenization::Config& config) {auto matcher = std::make_shared<ov::pass::pattern::Matcher>(label, matcher_name);register_matcher(matcher, callback);}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/pass/common_optimizations.cpp b/src/common/snippets/src/pass/common_optimizations.cppindex d9cc6f7f819..cae092f63ad 100644--- a/src/common/snippets/src/pass/common_optimizations.cpp+++ b/src/common/snippets/src/pass/common_optimizations.cpp@@ -4,21 +4,20 @@#include "snippets/pass/common_optimizations.hpp"-#include "snippets/pass/fq_decomposition.hpp"-#include "snippets/pass/softmax_reshape_elimination.hpp"+#include "openvino/pass/pattern/op/wrap_type.hpp"+#include "snippets/itt.hpp"+#include "snippets/op/subgraph.hpp"#include "snippets/pass/explicit_transpose_matmul_inputs.hpp"-#include "snippets/pass/transpose_decomposition.hpp"-#include "snippets/pass/fuse_transpose_brgemm.hpp"-#include "snippets/pass/transform_convert.hpp"-#include "snippets/pass/validate.hpp"-#include "snippets/pass/split_dimension_m.hpp"#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/op/subgraph.hpp"-#include "snippets/itt.hpp"--#include "openvino/pass/pattern/op/wrap_type.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 {@@ -26,7 +25,7 @@ namespace snippets {namespace pass {#define REGISTER_SNIPPETS_PASS(manager, pass, enabled, ...) \- if (enabled) \+ if (enabled) \manager.register_pass<pass>(__VA_ARGS__);CommonOptimizations::CommonOptimizations(const SnippetsTokenization::Config& config) {@@ -43,8 +42,8 @@ CommonOptimizations::CommonOptimizations(const SnippetsTokenization::Config& conconst auto is_quantized = subgraph->is_quantized();const auto is_domain_sensitive = subgraph->has_domain_sensitive_ops();- // Firstly, we should transform all original Converts inside body to ConvertTruncation to save original behavior.- // Then if Subgraph contains FakeQuantize we enable specific transformation for quantized subgraphs.+ // Firstly, we should transform all original Converts inside body to ConvertTruncation to save original+ // behavior. Then if Subgraph contains FakeQuantize we enable specific transformation for quantized subgraphs.ov::pass::Manager manager(get_pass_config(), "Snippets:CommonOptimizations");REGISTER_SNIPPETS_PASS(manager, ov::snippets::pass::TransformConvertToConvertTruncation, true);REGISTER_SNIPPETS_PASS(manager, ov::snippets::pass::ExplicitTransposeMatMulInputs, is_domain_sensitive);@@ -57,7 +56,9 @@ CommonOptimizations::CommonOptimizations(const SnippetsTokenization::Config& con// so we can enable ExtractConstants pass for quantized modelsREGISTER_SNIPPETS_PASS(subgraph_manager, ov::snippets::pass::ExtractConstants, is_quantized);REGISTER_SNIPPETS_PASS(subgraph_manager, ov::snippets::pass::ExtractUnsupportedTransposes, is_domain_sensitive);- REGISTER_SNIPPETS_PASS(subgraph_manager, ov::snippets::pass::SplitDimensionM, is_domain_sensitive && config.get_split_m_dimension(),+ REGISTER_SNIPPETS_PASS(subgraph_manager,+ ov::snippets::pass::SplitDimensionM,+ is_domain_sensitive && config.get_split_m_dimension(),config.get_concurrency());subgraph_manager.run_passes(subgraph);@@ -67,10 +68,11 @@ CommonOptimizations::CommonOptimizations(const SnippetsTokenization::Config& conreturn true;};- auto m = std::make_shared<ov::pass::pattern::Matcher>(ov::pass::pattern::wrap_type<ov::snippets::op::Subgraph>(), matcher_name);+ auto m = std::make_shared<ov::pass::pattern::Matcher>(ov::pass::pattern::wrap_type<ov::snippets::op::Subgraph>(),+ matcher_name);this->register_matcher(m, callback);}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/pass/convert_constants.cpp b/src/common/snippets/src/pass/convert_constants.cppindex c374ee010d3..95c3e8f4435 100644--- a/src/common/snippets/src/pass/convert_constants.cpp+++ b/src/common/snippets/src/pass/convert_constants.cpp@@ -2,21 +2,20 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/itt.hpp"-#include "openvino/core/rt_info.hpp"-#include "snippets/pass/convert_constants.hpp"-#include "snippets/op/subgraph.hpp"-#include "snippets/op/scalar.hpp"+#include "openvino/core/rt_info.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);- });- ov::graph_rewrite_callback callback = [](ov::pass::pattern::Matcher &m) {+ 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);+ });+ 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)diff --git a/src/common/snippets/src/pass/convert_power_to_powerstatic.cpp b/src/common/snippets/src/pass/convert_power_to_powerstatic.cppindex 57fd9bee9d0..4bffc9add19 100644--- a/src/common/snippets/src/pass/convert_power_to_powerstatic.cpp+++ b/src/common/snippets/src/pass/convert_power_to_powerstatic.cpp@@ -2,20 +2,19 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/itt.hpp"-#include "snippets/snippets_isa.hpp"#include "snippets/pass/convert_power_to_powerstatic.hpp"-#include "openvino/core/rt_info.hpp"+#include "openvino/core/rt_info.hpp"+#include "snippets/itt.hpp"+#include "snippets/snippets_isa.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) {- 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) {+ auto scalarPower =+ std::make_shared<ov::pass::pattern::op::Label>(ov::pass::pattern::any_input(), [](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) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::op::ConvertPowerToPowerStatic")auto power = ov::as_type_ptr<ov::op::v1::Power>(m.get_match_root());auto scalar = ov::as_type_ptr<snippets::op::Scalar>(power->get_input_node_shared_ptr(1));diff --git a/src/common/snippets/src/pass/explicit_transpose_matmul_inputs.cpp b/src/common/snippets/src/pass/explicit_transpose_matmul_inputs.cppindex 15291b2528c..7a551655041 100644--- a/src/common/snippets/src/pass/explicit_transpose_matmul_inputs.cpp+++ b/src/common/snippets/src/pass/explicit_transpose_matmul_inputs.cpp@@ -12,17 +12,17 @@bool ov::snippets::pass::ExplicitTransposeMatMulInputs::are_weights_scalar(const std::shared_ptr<ov::Node>& node) {const auto inputs = node->inputs();- return std::all_of(inputs.begin() + 1, inputs.end(),- [](const ov::Input<ov::Node>& in) {- return in.get_partial_shape().is_static() && ov::shape_size(in.get_shape()) == 1;- });+ return std::all_of(inputs.begin() + 1, inputs.end(), [](const ov::Input<ov::Node>& in) {+ return in.get_partial_shape().is_static() && ov::shape_size(in.get_shape()) == 1;+ });}void ov::snippets::pass::ExplicitTransposeMatMulInputs::extract(const ov::Input<ov::Node>& input) {auto parent = input.get_source_output().get_node_shared_ptr();auto transpose = ov::as_type_ptr<ov::op::v1::Transpose>(parent);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+ // We can set supported order and transposed_<a|b>=false only if ops have scalar shapes to avoid shape+ // mismatchingif (!are_weights_scalar(parent))break;@@ -50,13 +50,16 @@ void ov::snippets::pass::ExplicitTransposeMatMulInputs::extract(const ov::Input<}// Create new Transpose before Parameter- OPENVINO_ASSERT(ov::is_type<opset1::Parameter>(parent),- "ExplicitTransposeMatMulInputs expects Parameter in cases when there isn't existing Transpose on input");+ OPENVINO_ASSERT(+ ov::is_type<opset1::Parameter>(parent),+ "ExplicitTransposeMatMulInputs expects Parameter in cases when there isn't existing Transpose on input");const auto& consumers = parent->get_output_target_inputs(0);OPENVINO_ASSERT(consumers.size() == 1,- "ExplicitTransposeMatMulInputs expects Parameter with one consumer in cases when there isn't existing Transpose on input");+ "ExplicitTransposeMatMulInputs expects Parameter with one consumer in cases when there isn't "+ "existing Transpose on input");// Extract Transpose from MatMul- OPENVINO_ASSERT(input.get_partial_shape().rank().is_static(), "ExplicitTransposeMatMulInputs supports only static ranks of shapes");+ OPENVINO_ASSERT(input.get_partial_shape().rank().is_static(),+ "ExplicitTransposeMatMulInputs supports only static ranks of shapes");const auto rank = input.get_partial_shape().size();std::vector<size_t> transpose_order(rank, 0);@@ -64,7 +67,7 @@ void ov::snippets::pass::ExplicitTransposeMatMulInputs::extract(const ov::Input<std::swap(transpose_order[rank - 1], transpose_order[rank - 2]);const auto constant_order = std::make_shared<opset1::Constant>(ov::element::i32, ov::Shape{rank}, transpose_order);- const auto new_transpose = std::make_shared<opset1::Transpose>(parent, constant_order); // parent is Parameter+ const auto new_transpose = std::make_shared<opset1::Transpose>(parent, constant_order); // parent is Parameterconst auto consumer_input = *(consumers.begin());consumer_input.replace_source_output(new_transpose);}@@ -72,30 +75,32 @@ void ov::snippets::pass::ExplicitTransposeMatMulInputs::extract(const ov::Input<ov::snippets::pass::ExplicitTransposeMatMulInputs::ExplicitTransposeMatMulInputs() {MATCHER_SCOPE(ExplicitTransposeMatMulInputs);- auto m_matmul0 = std::make_shared<ov::op::v0::MatMul>(ov::pass::pattern::any_input(), ov::pass::pattern::any_input());+ auto m_matmul0 =+ std::make_shared<ov::op::v0::MatMul>(ov::pass::pattern::any_input(), ov::pass::pattern::any_input());register_matcher(std::make_shared<ov::pass::pattern::Matcher>(m_matmul0, matcher_name),- [OV_CAPTURE_CPY_AND_THIS](ov::pass::pattern::Matcher &m) {- OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::op::ExplicitTransposeMatMulInputs")- auto root = m.get_match_root();- bool rewritten = false;-- auto matmul = ov::as_type_ptr<ov::op::v0::MatMul>(root);- if (!matmul)- return false;-- if (matmul->get_transpose_a()) {- extract(matmul->input(0));- matmul->set_transpose_a(false);- rewritten |= true;- }-- if (matmul->get_transpose_b() && !transformation_callback(matmul)) {- extract(matmul->input(1));- matmul->set_transpose_b(false);- rewritten |= true;- }-- return rewritten;- });+ [OV_CAPTURE_CPY_AND_THIS](ov::pass::pattern::Matcher& m) {+ OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform,+ "Snippets::op::ExplicitTransposeMatMulInputs")+ auto root = m.get_match_root();+ bool rewritten = false;++ auto matmul = ov::as_type_ptr<ov::op::v0::MatMul>(root);+ if (!matmul)+ return false;++ if (matmul->get_transpose_a()) {+ extract(matmul->input(0));+ matmul->set_transpose_a(false);+ rewritten |= true;+ }++ if (matmul->get_transpose_b() && !transformation_callback(matmul)) {+ extract(matmul->input(1));+ matmul->set_transpose_b(false);+ rewritten |= true;+ }++ return rewritten;+ });}diff --git a/src/common/snippets/src/pass/extract_constants.cpp b/src/common/snippets/src/pass/extract_constants.cppindex ddbd07db434..3e3e9ae0f6a 100644--- a/src/common/snippets/src/pass/extract_constants.cpp+++ b/src/common/snippets/src/pass/extract_constants.cpp@@ -7,7 +7,6 @@#include "openvino/opsets/opset1.hpp"#include "snippets/itt.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");auto body = subgraph->body_ptr();diff --git a/src/common/snippets/src/pass/extract_reshapes_from_mha.cpp b/src/common/snippets/src/pass/extract_reshapes_from_mha.cppindex 45330517eb2..3c21f92efbb 100644--- a/src/common/snippets/src/pass/extract_reshapes_from_mha.cpp+++ b/src/common/snippets/src/pass/extract_reshapes_from_mha.cpp@@ -22,19 +22,22 @@ ov::snippets::pass::ExtractPairsAfterMatmul::ExtractPairsAfterMatmul() {return pattern::has_static_shape()(out) && pattern::consumers_count(1)(out);};auto matmul_m = pattern::wrap_type<opset1::MatMul>(static_shape_single_consumer);- auto reshape_1_m = pattern::wrap_type<opset1::Reshape>({matmul_m, pattern::wrap_type<opset1::Constant>()}, static_shape_single_consumer);+ auto reshape_1_m = pattern::wrap_type<opset1::Reshape>({matmul_m, pattern::wrap_type<opset1::Constant>()},+ static_shape_single_consumer);auto sparse_input_1_m = pattern::any_input(pattern::has_static_shape());auto sparse_input_2_m = pattern::any_input(pattern::has_static_shape());auto add_1_m = pattern::wrap_type<opset1::Add>({reshape_1_m, sparse_input_1_m}, static_shape_single_consumer);auto add_2_m = pattern::wrap_type<opset1::Add>({add_1_m, sparse_input_2_m}, static_shape_single_consumer);- auto reshape_2_m = pattern::wrap_type<opset1::Reshape>({add_2_m, pattern::wrap_type<opset1::Constant>()}, pattern::has_static_shape());+ auto reshape_2_m = pattern::wrap_type<opset1::Reshape>({add_2_m, pattern::wrap_type<opset1::Constant>()},+ pattern::has_static_shape());matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](pattern::Matcher& m) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::op::ExtractPairsAfterMatmul")const auto& pattern_map = m.get_pattern_value_map();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))+ if (!ov::snippets::pass::TokenizeMHASnippets::is_matmul0_supported(matmul_node) ||+ transformation_callback(matmul_node))return false;const auto& reshape_2 = pattern_map.at(reshape_2_m);diff --git a/src/common/snippets/src/pass/extract_unsupported_transposes.cpp b/src/common/snippets/src/pass/extract_unsupported_transposes.cppindex ca26128afc6..b298d31f2fe 100644--- a/src/common/snippets/src/pass/extract_unsupported_transposes.cpp+++ b/src/common/snippets/src/pass/extract_unsupported_transposes.cpp@@ -5,16 +5,16 @@#include "snippets/pass/extract_unsupported_transposes.hpp"#include "openvino/opsets/opset1.hpp"-#include "snippets/pass/mha_tokenization.hpp"#include "snippets/itt.hpp"-+#include "snippets/pass/mha_tokenization.hpp"bool ov::snippets::pass::ExtractUnsupportedTransposes::run_on_subgraph(const std::shared_ptr<op::Subgraph>& subgraph) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::ExtractUnsupportedTransposes");const auto& body = subgraph->body_ptr();const auto parameters = body->get_parameters();// [107806]: If count of Parameters isn't equal to Subgraph inputs,- // we cannot guarantee correct extraction since we don't have correct connections between body I/O and Subgraph I/O.+ // we cannot guarantee correct extraction since we don't have correct connections between body I/O and+ // Subgraph I/O.OPENVINO_ASSERT(parameters.size() == subgraph->input_values().size(),"Failed to extract unsupported transposes: the count of Parameters isn't equal to Subgraph inputs");diff --git a/src/common/snippets/src/pass/fc_tokenization.cpp b/src/common/snippets/src/pass/fc_tokenization.cppindex a75bf0a4fed..a0c6f41a4c2 100644--- a/src/common/snippets/src/pass/fc_tokenization.cpp+++ b/src/common/snippets/src/pass/fc_tokenization.cpp@@ -15,7 +15,7 @@ ov::snippets::pass::TokenizeFCSnippets::TokenizeFCSnippets(const SnippetsTokenizauto constant = ov::pass::pattern::wrap_type<ov::op::v0::Constant>();auto m_matmul = ov::pass::pattern::wrap_type<ov::opset1::MatMul>({ov::pass::pattern::any_input(), constant});- auto callback = [OV_CAPTURE_CPY_AND_THIS](ov::pass::pattern::Matcher &m) {+ auto callback = [OV_CAPTURE_CPY_AND_THIS](ov::pass::pattern::Matcher& m) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::op::TokenizeFCSnippets")const auto matmul = m.get_match_root();if (transformation_callback(matmul)) {diff --git a/src/common/snippets/src/pass/fq_decomposition.cpp b/src/common/snippets/src/pass/fq_decomposition.cppindex b75f3137e10..eb87baab88e 100644--- a/src/common/snippets/src/pass/fq_decomposition.cpp+++ b/src/common/snippets/src/pass/fq_decomposition.cpp@@ -12,38 +12,36 @@#include "openvino/pass/manager.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"#include "openvino/pass/validate.hpp"-#include "transformations/utils/utils.hpp"-#include "openvino/reference/autobroadcast_binop.hpp"#include "openvino/reference/broadcast.hpp"-#include "snippets/itt.hpp"-#include "snippets/utils/utils.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);auto fake_quantize = ov::pass::pattern::wrap_type<ov::op::v0::FakeQuantize>(- OutputVector{ov::pass::pattern::any_input(),- ov::pass::pattern::wrap_type<ov::op::v0::Constant>(),- ov::pass::pattern::wrap_type<ov::op::v0::Constant>(),- ov::pass::pattern::wrap_type<ov::op::v0::Constant>(),- ov::pass::pattern::wrap_type<ov::op::v0::Constant>()});+ OutputVector{ov::pass::pattern::any_input(),+ ov::pass::pattern::wrap_type<ov::op::v0::Constant>(),+ ov::pass::pattern::wrap_type<ov::op::v0::Constant>(),+ ov::pass::pattern::wrap_type<ov::op::v0::Constant>(),+ ov::pass::pattern::wrap_type<ov::op::v0::Constant>()});ov::matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](ov::pass::pattern::Matcher& m) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::op::FakeQuantizeDecomposition")auto& pattern_to_output = m.get_pattern_value_map();- const auto fake_quantize_node = ov::as_type_ptr<ov::op::v0::FakeQuantize>(- pattern_to_output.at(fake_quantize).get_node_shared_ptr());+ const auto fake_quantize_node =+ ov::as_type_ptr<ov::op::v0::FakeQuantize>(pattern_to_output.at(fake_quantize).get_node_shared_ptr());if (!fake_quantize_node || transformation_callback(fake_quantize_node)) {return false;}- OPENVINO_ASSERT(CommonFakeQuantizeDecomposition::is_supported_fq(fake_quantize_node),- "FQ Decomposition got invalid FakeQuantize node with the name " + fake_quantize_node->get_friendly_name());+ OPENVINO_ASSERT(+ CommonFakeQuantizeDecomposition::is_supported_fq(fake_quantize_node),+ "FQ Decomposition got invalid FakeQuantize node with the name " + fake_quantize_node->get_friendly_name());Output<Node> data{fake_quantize_node->input_value(0)};const Output<Node> input_low{fake_quantize_node->input_value(1)};@@ -90,9 +88,7 @@ ov::snippets::pass::FakeQuantizeDecomposition::FakeQuantizeDecomposition() {std::shared_ptr<ov::Node> result = nullptr;if (out_scales.size() != 0) {PartialShape scale_shape = input_low.get_partial_shape();- ov::PartialShape::broadcast_merge_into(scale_shape,- input_high.get_partial_shape(),- broadcast_type);+ 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(),scale_shape.get_shape(),out_scales);@@ -153,7 +149,8 @@ ov::snippets::pass::FakeQuantizeDecomposition::FakeQuantizeDecomposition() {}if (result->get_output_element_type(0) != fake_quantize_node->get_output_element_type(0)) {- result = std::make_shared<snippets::op::ConvertSaturation>(result, fake_quantize_node->get_output_element_type(0));+ result = std::make_shared<snippets::op::ConvertSaturation>(result,+ fake_quantize_node->get_output_element_type(0));decomp_ops.push_back(result);}@@ -241,8 +238,11 @@ bool ov::snippets::pass::FakeQuantizeDecomposition::getScalesAndShifts([](float x, float y) -> float {return -x * y;});- auto broadcast = [](const std::vector<float>& original_data, std::vector<float>& out_data,- const ov::Shape& original_shape, const ov::Shape& out_shape, size_t size) -> void {+ auto broadcast = [](const std::vector<float>& original_data,+ std::vector<float>& out_data,+ const ov::Shape& original_shape,+ const ov::Shape& out_shape,+ size_t size) -> void {out_data.resize(size, 0);std::vector<size_t> broadcast_axes(out_shape.size() - original_shape.size());std::iota(broadcast_axes.begin(), broadcast_axes.end(), 0);@@ -260,7 +260,8 @@ bool ov::snippets::pass::FakeQuantizeDecomposition::getScalesAndShifts(// Calculations of output scales and shift:// - osc := (oh - ol) / (levels-1)// - osh := ol- if (output_low_shape == output_high_shape || shape_size(output_low_shape) == 1 || shape_size(output_high_shape) == 1) {+ if (output_low_shape == output_high_shape || shape_size(output_low_shape) == 1 ||+ shape_size(output_high_shape) == 1) {const auto output_size = std::max(output_low.size(), output_high.size());osc.resize(output_size, 0);osh.resize(output_size, 0);@@ -273,7 +274,9 @@ bool ov::snippets::pass::FakeQuantizeDecomposition::getScalesAndShifts(}} else { // general broadcastingPartialShape scale_pshape = output_low_constant->get_output_partial_shape(0);- PartialShape::broadcast_merge_into(scale_pshape, output_high_constant->get_output_partial_shape(0), broadcast_type);+ PartialShape::broadcast_merge_into(scale_pshape,+ output_high_constant->get_output_partial_shape(0),+ broadcast_type);const auto output_size = ov::shape_size(scale_pshape.get_shape());osc.resize(output_size, 0);ov::reference::autobroadcast_binop(output_high.data(),@@ -323,9 +326,19 @@ std::vector<float> ov::snippets::pass::FakeQuantizeDecomposition::calculateScalestatic const float thr = 0.0001f;if (out_type == ov::element::i8 &&- std::all_of(ish.cbegin(), ish.cend(), [](float val) { return std::abs(val - 128.f) < thr; }) &&- std::all_of(osc.cbegin(), osc.cend(), [](float val) { return val == 1.f; }) &&- std::all_of(osh.cbegin(), osh.cend(), [](float val) { return std::abs(val + 128.f) < thr; })) {+ std::all_of(ish.cbegin(),+ ish.cend(),+ [](float val) {+ return std::abs(val - 128.f) < thr;+ }) &&+ std::all_of(osc.cbegin(),+ osc.cend(),+ [](float val) {+ return val == 1.f;+ }) &&+ std::all_of(osh.cbegin(), osh.cend(), [](float val) {+ return std::abs(val + 128.f) < thr;+ })) {bool is_crop_aligned = true;for (size_t i = 0; i < std::max(cl.size(), isc.size()); i++) {if (std::abs(cl[cl.size() == 1 ? 0 : i] * isc[isc.size() == 1 ? 0 : i] + 128.f) > thr) {@@ -347,7 +360,8 @@ std::vector<float> ov::snippets::pass::FakeQuantizeDecomposition::calculateScalereturn out_scales;}-bool ov::snippets::pass::CommonFakeQuantizeDecomposition::is_supported_fq(const std::shared_ptr<const ov::op::v0::FakeQuantize>& fq) {+bool ov::snippets::pass::CommonFakeQuantizeDecomposition::is_supported_fq(+ const std::shared_ptr<const ov::op::v0::FakeQuantize>& fq) {// TODO [92179]: Add support of FakeQuantize with non-constants inputs and with binarization algorithm.auto is_valid_range_values = [](const std::shared_ptr<const ov::op::v0::FakeQuantize>& fq) {const auto il = fq->input_value(1);@@ -364,8 +378,7 @@ bool ov::snippets::pass::CommonFakeQuantizeDecomposition::is_supported_fq(constreturn value;});};- return fq && fq->get_levels() != 2 &&- ov::is_type<ov::op::v0::Constant>(fq->get_input_node_shared_ptr(1)) &&+ return fq && fq->get_levels() != 2 && ov::is_type<ov::op::v0::Constant>(fq->get_input_node_shared_ptr(1)) &&ov::is_type<ov::op::v0::Constant>(fq->get_input_node_shared_ptr(2)) &&ov::is_type<ov::op::v0::Constant>(fq->get_input_node_shared_ptr(3)) &&ov::is_type<ov::op::v0::Constant>(fq->get_input_node_shared_ptr(4)) &&diff --git a/src/common/snippets/src/pass/fuse_transpose_brgemm.cpp b/src/common/snippets/src/pass/fuse_transpose_brgemm.cppindex fa2072804cb..5990aa29b26 100644--- a/src/common/snippets/src/pass/fuse_transpose_brgemm.cpp+++ b/src/common/snippets/src/pass/fuse_transpose_brgemm.cpp@@ -2,16 +2,14 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/itt.hpp"-#include "snippets/pass/fuse_transpose_brgemm.hpp"-#include "snippets/snippets_isa.hpp"--#include "snippets/utils/utils.hpp"#include "openvino/core/rt_info.hpp"-#include "openvino/pass/pattern/op/wrap_type.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/utils/utils.hpp"namespace ov {namespace snippets {@@ -35,7 +33,8 @@ bool FuseTransposeBrgemm::is_supported_transpose_order(const std::vector<int32_tFuseTransposeBrgemm::FuseTransposeBrgemm() {MATCHER_SCOPE(FuseTransposeBrgemm);auto constant = ov::pass::pattern::wrap_type<ov::op::v0::Constant>();- auto transpose = ov::pass::pattern::wrap_type<ov::op::v1::Transpose>({ov::pass::pattern::any_input(), constant}, is_supported_transpose);+ auto transpose = ov::pass::pattern::wrap_type<ov::op::v1::Transpose>({ov::pass::pattern::any_input(), constant},+ is_supported_transpose);auto transpose_matcher = std::make_shared<ov::pass::pattern::Matcher>(transpose);// Pattern 0: Transpose on 0-th input of MatMul@@ -45,10 +44,13 @@ FuseTransposeBrgemm::FuseTransposeBrgemm() {auto brgemm_in1 = ov::pass::pattern::wrap_type<op::Brgemm>({ov::pass::pattern::any_input(), transpose});// Pattern 2: Transpose on output of MatMul- auto brgemm_out = ov::pass::pattern::wrap_type<op::Brgemm>({ov::pass::pattern::any_input(), ov::pass::pattern::any_input()});- auto transpose2 = ov::pass::pattern::wrap_type<ov::op::v1::Transpose>({brgemm_out, constant}, is_supported_transpose);+ auto brgemm_out =+ ov::pass::pattern::wrap_type<op::Brgemm>({ov::pass::pattern::any_input(), ov::pass::pattern::any_input()});+ auto transpose2 =+ ov::pass::pattern::wrap_type<ov::op::v1::Transpose>({brgemm_out, constant}, is_supported_transpose);- auto brgemm_or_transpose = std::make_shared<ov::pass::pattern::op::Or>(OutputVector{brgemm_in0, brgemm_in1, transpose2});+ auto brgemm_or_transpose =+ std::make_shared<ov::pass::pattern::op::Or>(OutputVector{brgemm_in0, brgemm_in1, transpose2});auto callback = [=](ov::pass::pattern::Matcher& m) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "FuseTransposeBrgemm")@@ -73,7 +75,8 @@ FuseTransposeBrgemm::FuseTransposeBrgemm() {brgemm = ov::as_type_ptr<op::Brgemm>(m.get_match_root()->get_input_node_shared_ptr(0));const auto& brgemm_out = brgemm->output(0);const auto& transpose_out = m.get_match_value();- const auto& const_order = ov::as_type_ptr<ov::op::v0::Constant>(transpose_out.get_node_shared_ptr()->get_input_node_shared_ptr(1));+ const auto& const_order = ov::as_type_ptr<ov::op::v0::Constant>(+ transpose_out.get_node_shared_ptr()->get_input_node_shared_ptr(1));const auto& original_port = ov::snippets::lowered::PortDescriptorUtils::get_port_descriptor_ptr(brgemm_out);original_port->set_shape(utils::pshape_to_vdims(transpose_out.get_partial_shape()));const auto& out_layout = original_port->get_layout();@@ -88,7 +91,8 @@ FuseTransposeBrgemm::FuseTransposeBrgemm() {const auto& in_value = in.get_source_output();if (transpose_matcher->match(in_value)) {const auto& transpose = as_type_ptr<ov::op::v1::Transpose>(in_value.get_node_shared_ptr());- const auto& const_order = ov::as_type_ptr<ov::op::v0::Constant>(transpose->get_input_node_shared_ptr(1));+ const auto& const_order =+ ov::as_type_ptr<ov::op::v0::Constant>(transpose->get_input_node_shared_ptr(1));brgemm->set_argument(i, transpose->input_value(0));const auto& original_port = ov::snippets::lowered::PortDescriptorUtils::get_port_descriptor_ptr(in);const auto& in_layout = original_port->get_layout();diff --git a/src/common/snippets/src/pass/gated_mlp_tokenization.cpp b/src/common/snippets/src/pass/gated_mlp_tokenization.cppindex 98b819b67c6..b3388c9cafa 100644--- a/src/common/snippets/src/pass/gated_mlp_tokenization.cpp+++ b/src/common/snippets/src/pass/gated_mlp_tokenization.cpp@@ -4,17 +4,16 @@#include "snippets/pass/gated_mlp_tokenization.hpp"+#include "openvino/core/rt_info.hpp"+#include "openvino/core/validation_util.hpp"+#include "openvino/pass/pattern/op/or.hpp"+#include "openvino/pass/pattern/op/wrap_type.hpp"#include "snippets/itt.hpp"#include "snippets/op/brgemm.hpp"#include "snippets/op/subgraph.hpp"#include "snippets/pass/collapse_subgraph.hpp"-#include "snippets/utils/utils.hpp"#include "snippets/utils/tokenization_utils.hpp"--#include "openvino/core/rt_info.hpp"-#include "openvino/core/validation_util.hpp"-#include "openvino/pass/pattern/op/or.hpp"-#include "openvino/pass/pattern/op/wrap_type.hpp"+#include "snippets/utils/utils.hpp"#include "transformations/utils/utils.hpp"namespace ov {@@ -27,7 +26,8 @@ namespace {ov::pass::pattern::op::Predicate act_predicate() {return ov::pass::pattern::op::Predicate([](const Output<Node>& output) -> bool {- return consumers_count(1)(output) && ov::snippets::pass::TokenizeSnippets::AppropriateForSubgraph(output.get_node_shared_ptr());+ return consumers_count(1)(output) &&+ ov::snippets::pass::TokenizeSnippets::AppropriateForSubgraph(output.get_node_shared_ptr());},"act_predicate");}@@ -45,7 +45,8 @@ ov::pass::pattern::op::Predicate fc_predicate(bool is_down) {[=](const Output<Node>& output) -> bool {const auto node = output.get_node_shared_ptr();return ov::is_type<ov::op::v0::MatMul>(node) && ((!is_down && consumers_count(1)(output)) || is_down) &&- (op::Brgemm::get_output_type(node->get_input_element_type(0), node->get_input_element_type(1)) != element::dynamic);+ (op::Brgemm::get_output_type(node->get_input_element_type(0), node->get_input_element_type(1)) !=+ element::dynamic);},"fc_predicate");}@@ -55,7 +56,7 @@ ov::pass::pattern::op::Predicate fc_predicate(bool is_down) {TokenizeGatedMLPSnippets::TokenizeGatedMLPSnippets(const SnippetsTokenization::Config& config) {MATCHER_SCOPE(TokenizeGatedMLPSnippets);- auto make_weights = [](){+ auto make_weights = []() {// TODO: Add decompressed weightsreturn wrap_type<ov::op::v0::Constant>();};@@ -64,46 +65,51 @@ TokenizeGatedMLPSnippets::TokenizeGatedMLPSnippets(const SnippetsTokenization::Cauto m_fc_gate = wrap_type<ov::opset1::MatMul>({m_input, make_weights()}, fc_predicate(false));auto m_fc_up = wrap_type<ov::opset1::MatMul>({m_input, make_weights()}, fc_predicate(false));- auto m_act_unary = wrap_type<ov::op::util::UnaryElementwiseArithmetic, ov::op::v0::HardSigmoid>({m_fc_gate}, act_predicate());+ auto m_act_unary =+ wrap_type<ov::op::util::UnaryElementwiseArithmetic, ov::op::v0::HardSigmoid>({m_fc_gate}, act_predicate());auto m_act_binary_scalar = wrap_type<ov::op::v0::Constant>(scalar_predicate());- auto m_act_binary =- wrap_type<ov::op::util::BinaryElementwiseArithmetic, ov::op::v4::Swish, ov::op::v0::PRelu>({m_fc_gate, m_act_binary_scalar}, act_predicate());+ auto m_act_binary = wrap_type<ov::op::util::BinaryElementwiseArithmetic, ov::op::v4::Swish, ov::op::v0::PRelu>(+ {m_fc_gate, m_act_binary_scalar},+ act_predicate());auto m_act = std::make_shared<ov::pass::pattern::op::Or>(ov::OutputVector{m_act_unary, m_act_binary});auto m_mul = wrap_type<ov::opset1::Multiply>({m_act, m_fc_up}, consumers_count(1));auto m_fc_down = wrap_type<ov::opset1::MatMul>({m_mul, make_weights()}, fc_predicate(true));- register_matcher(std::make_shared<ov::pass::pattern::Matcher>(m_fc_down, matcher_name),- [OV_CAPTURE_CPY_AND_THIS](ov::pass::pattern::Matcher &m) {- OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::op::TokenizeGatedMLPSnippets")- auto& pattern_map = m.get_pattern_value_map();-- const auto fc_gate = pattern_map.at(m_fc_gate).get_node_shared_ptr();- const auto fc_up = pattern_map.at(m_fc_up).get_node_shared_ptr();- const auto act = pattern_map.at(m_act).get_node_shared_ptr();- const auto mul = pattern_map.at(m_mul).get_node_shared_ptr();- const auto fc_down = pattern_map.at(m_fc_down).get_node_shared_ptr();-- if (transformation_callback(fc_gate) || transformation_callback(fc_up) || transformation_callback(fc_down)) {- return false;- }-- static const auto body_params_count = 5; // 2xinput + 3x fc- static const auto body_result_count = 1; // one output- static const auto reg_group_count = 5; // upper-bound of possible buffer count-- // TODO [75567]: move this plugin-specific constraint to the plugin callback- if (body_params_count + body_result_count + reg_group_count > config.get_data_ptr_gpr_count()) {- return false;- }-- const auto ordered_ops = ov::NodeVector{fc_gate, fc_up, act, mul, fc_down};- const auto subgraph = ov::snippets::utils::tokenize_ordered_nodes(ordered_ops);-- // mark the Subgraph as Completed to not allow Snippets to include any nodes into this Subgraph in common Tokenization- SetSnippetsSubgraphType(subgraph, SnippetsSubgraphType::Completed);- return true;- });+ register_matcher(+ std::make_shared<ov::pass::pattern::Matcher>(m_fc_down, matcher_name),+ [OV_CAPTURE_CPY_AND_THIS](ov::pass::pattern::Matcher& m) {+ OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::op::TokenizeGatedMLPSnippets")+ auto& pattern_map = m.get_pattern_value_map();++ const auto fc_gate = pattern_map.at(m_fc_gate).get_node_shared_ptr();+ const auto fc_up = pattern_map.at(m_fc_up).get_node_shared_ptr();+ const auto act = pattern_map.at(m_act).get_node_shared_ptr();+ const auto mul = pattern_map.at(m_mul).get_node_shared_ptr();+ const auto fc_down = pattern_map.at(m_fc_down).get_node_shared_ptr();++ if (transformation_callback(fc_gate) || transformation_callback(fc_up) ||+ transformation_callback(fc_down)) {+ return false;+ }++ static const auto body_params_count = 5; // 2xinput + 3x fc+ static const auto body_result_count = 1; // one output+ static const auto reg_group_count = 5; // upper-bound of possible buffer count++ // TODO [75567]: move this plugin-specific constraint to the plugin callback+ if (body_params_count + body_result_count + reg_group_count > config.get_data_ptr_gpr_count()) {+ return false;+ }++ const auto ordered_ops = ov::NodeVector{fc_gate, fc_up, act, mul, fc_down};+ const auto subgraph = ov::snippets::utils::tokenize_ordered_nodes(ordered_ops);++ // mark the Subgraph as Completed to not allow Snippets to include any nodes into this Subgraph in common+ // Tokenization+ SetSnippetsSubgraphType(subgraph, SnippetsSubgraphType::Completed);+ return true;+ });}} // namespace passdiff --git a/src/common/snippets/src/pass/gn_decomposition.cpp b/src/common/snippets/src/pass/gn_decomposition.cppindex 1bb82421abe..dacf3b315b8 100644--- a/src/common/snippets/src/pass/gn_decomposition.cpp+++ b/src/common/snippets/src/pass/gn_decomposition.cpp@@ -4,11 +4,11 @@#include "snippets/pass/gn_decomposition.hpp"+#include "openvino/core/rt_info.hpp"#include "openvino/op/group_normalization.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"#include "snippets/itt.hpp"#include "snippets/snippets_isa.hpp"-#include "openvino/core/rt_info.hpp"namespace ov {namespace snippets {@@ -25,7 +25,8 @@ GNDecomposition::GNDecomposition() {ov::matcher_pass_callback callback = [=](ov::pass::pattern::Matcher& m) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::pass::GNDecomposition")auto group_norm_node = ov::as_type_ptr<ov::op::v12::GroupNormalization>(m.get_match_root());- OPENVINO_ASSERT(!group_norm_node->is_dynamic(), "GroupNormalization decomposition in snippets only support static node.");+ OPENVINO_ASSERT(!group_norm_node->is_dynamic(),+ "GroupNormalization decomposition in snippets only support static node.");const auto data = group_norm_node->input_value(0);const auto scale = group_norm_node->input_value(1);@@ -58,7 +59,8 @@ GNDecomposition::GNDecomposition() {// reduceMeanfloat group_size_inv = 1.0f / static_cast<float>(group_shape[3]);- const auto group_size_inv_node = std::make_shared<ov::op::v0::Constant>(element::f32, Shape{}, std::vector<float>{group_size_inv});+ const auto group_size_inv_node =+ std::make_shared<ov::op::v0::Constant>(element::f32, Shape{}, std::vector<float>{group_size_inv});const auto reduce_mean = std::make_shared<ov::op::v1::Multiply>(reduce_sum, group_size_inv_node);// x - mean@@ -74,7 +76,8 @@ GNDecomposition::GNDecomposition() {auto sqr_reduce_sum = std::make_shared<ov::snippets::op::ReduceSum>(sqr, group_rank - 1);op::ReduceBase::compute_and_set_reduce_subtensors(sqr_reduce_sum);// reduceMean((x - mean) ^ 2)- const auto group_size_inv_node_aux = std::make_shared<ov::op::v0::Constant>(element::f32, Shape{}, std::vector<float>{group_size_inv});+ const auto group_size_inv_node_aux =+ std::make_shared<ov::op::v0::Constant>(element::f32, Shape{}, std::vector<float>{group_size_inv});auto sqr_mean = std::make_shared<ov::op::v1::Multiply>(sqr_reduce_sum, group_size_inv_node_aux);// reduceMean((x - mean) ^ 2) + epsauto eps_node = std::make_shared<ov::op::v0::Constant>(element::f32, Shape{1}, std::vector<float>{eps});diff --git a/src/common/snippets/src/pass/gn_tokenization.cpp b/src/common/snippets/src/pass/gn_tokenization.cppindex 6cb1997ecf2..75352e9d3a4 100644--- a/src/common/snippets/src/pass/gn_tokenization.cpp+++ b/src/common/snippets/src/pass/gn_tokenization.cpp@@ -3,15 +3,14 @@//#include "snippets/pass/gn_tokenization.hpp"-#include "snippets/pass/collapse_subgraph.hpp"+#include "openvino/core/rt_info.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 "openvino/core/rt_info.hpp"-#include "openvino/pass/pattern/op/wrap_type.hpp"-ov::snippets::pass::TokenizeGNSnippets::TokenizeGNSnippets() {MATCHER_SCOPE(TokenizeGNSnippets);@@ -29,9 +28,10 @@ ov::snippets::pass::TokenizeGNSnippets::TokenizeGNSnippets() {ov::replace_node(group_norm_node, subgraph);op::update_out_tensor_name(subgraph);- // Mark the Subgraph as Completed to not allow Snippets to include any nodes into the GN Subgraph in common Tokenization.- // This is because GN has specific parallel domain(bacth * group_num), which maybe suboptimal to other part if tokenized as a big subgraph,- // as there is a unified paralell domain for the whole subgraph. Ticket 137310 is to relax and track this.+ // Mark the Subgraph as Completed to not allow Snippets to include any nodes into the GN Subgraph in common+ // Tokenization. This is because GN has specific parallel domain(bacth * group_num), which maybe suboptimal to+ // other part if tokenized as a big subgraph, as there is a unified paralell domain for the whole subgraph.+ // Ticket 137310 is to relax and track this.SetSnippetsSubgraphType(subgraph, SnippetsSubgraphType::Completed);return true;diff --git a/src/common/snippets/src/pass/hash.cpp b/src/common/snippets/src/pass/hash.cppindex 442fa569b12..9a2d7745b7c 100644--- a/src/common/snippets/src/pass/hash.cpp+++ b/src/common/snippets/src/pass/hash.cpp@@ -42,17 +42,40 @@ struct Edge {int to_port = 0;};-enum class AttrType {layers, layer, id, type, data, rt_info, attribute, name, version, input, port, precision, dimension, output, value,- edges, edge, from_layer, from_port, to_layer, to_port, constant, size};+enum class AttrType {+ layers,+ layer,+ id,+ type,+ data,+ rt_info,+ attribute,+ name,+ version,+ input,+ port,+ precision,+ dimension,+ output,+ value,+ edges,+ edge,+ from_layer,+ from_port,+ to_layer,+ to_port,+ constant,+ 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, typename std::enable_if<!std::is_enum<T>::value, int>::type = 0>+static uint64_t hash_combine(uint64_t seed, const T& v) {// Hash combine formula from boost- return seed ^= std::hash<T> {}(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);+ return 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) {+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;return hash_combine(seed, static_cast<underlying_t>(v));}@@ -146,7 +169,7 @@ public:}};-} // namespace rt_info+} // namespace rt_infovoid ovfunction_2_hash(uint64_t& hash, const ov::Model& model);@@ -160,16 +183,14 @@ class SnippetsHasher : public ov::AttributeVisitor {}public:- SnippetsHasher(uint64_t& hash,- const std::string& node_type_name)+ SnippetsHasher(uint64_t& hash, const std::string& node_type_name): m_hash(hash),m_node_type_name(node_type_name) {}void on_adapter(const std::string& name, ov::ValueAccessor<void>& adapter) override {if (const auto& a = ov::as_type<ov::AttributeAdapter<std::shared_ptr<ov::op::util::Variable>>>(&adapter)) {m_hash = hash_combine(hash_combine(m_hash, name), a->get()->get_info().variable_id);- } else if (const auto& a =- ov::as_type<ov::AttributeAdapter<std::shared_ptr<ov::AlignedBuffer>>>(&adapter)) {+ } else if (const auto& a = ov::as_type<ov::AttributeAdapter<std::shared_ptr<ov::AlignedBuffer>>>(&adapter)) {if (name == "value" && m_node_type_name == "Constant") {m_hash = hash_combine(m_hash, AttrType::constant);const int64_t size = a->get()->size();@@ -244,8 +265,7 @@ std::unordered_map<ov::Node*, int> create_layer_ids(const ov::Model& model) {return layer_ids;}-std::vector<Edge> create_edge_mapping(const std::unordered_map<ov::Node*, int>& layer_ids,- const ov::Model& model) {+std::vector<Edge> create_edge_mapping(const std::unordered_map<ov::Node*, int>& layer_ids, const ov::Model& model) {std::vector<Edge> edges;for (const auto& node : model.get_ordered_ops()) {if (ov::op::util::is_parameter(node)) {@@ -293,8 +313,7 @@ void hash_rt_info(uint64_t& hash, const std::string& name, const ov::Any& data)}}-void ovfunction_2_hash(uint64_t& hash,- const ov::Model& model) {+void ovfunction_2_hash(uint64_t& hash, const ov::Model& model) {hash = hash_combine(hash, AttrType::layers);const std::unordered_map<ov::Node*, int> layer_ids = create_layer_ids(model);@@ -319,7 +338,8 @@ void ovfunction_2_hash(uint64_t& hash,hash = hash_combine(hash, AttrType::rt_info);for (const auto& [name, attribute] : attributes) {if (attribute.is<ov::RuntimeAttribute>()) {- if (const auto& rt_attribute = attribute.as<ov::RuntimeAttribute>(); rt_attribute.is_deterministic()) {+ if (const auto& rt_attribute = attribute.as<ov::RuntimeAttribute>();+ rt_attribute.is_deterministic()) {const auto& type_info = rt_attribute.get_type_info();hash = hash_combine(hash, AttrType::attribute);hash = hash_combine(hash_combine(hash, AttrType::name), type_info.name);diff --git a/src/common/snippets/src/pass/insert_movebroadcast.cpp b/src/common/snippets/src/pass/insert_movebroadcast.cppindex 00c1622e108..3c6c5f0ee3a 100644--- a/src/common/snippets/src/pass/insert_movebroadcast.cpp+++ b/src/common/snippets/src/pass/insert_movebroadcast.cpp@@ -2,22 +2,22 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/itt.hpp"-#include "snippets/pass/insert_movebroadcast.hpp"-#include "snippets/snippets_isa.hpp"-#include "snippets/utils/utils.hpp"--#include "openvino/opsets/opset1.hpp"-#include "openvino/op/util/op_types.hpp"-#include "openvino/core/rt_info.hpp"#include <numeric>+#include "openvino/core/rt_info.hpp"+#include "openvino/op/util/op_types.hpp"+#include "openvino/opsets/opset1.hpp"+#include "snippets/itt.hpp"+#include "snippets/snippets_isa.hpp"+#include "snippets/utils/utils.hpp"+namespace {-std::pair<ov::PartialShape, std::vector<ov::PartialShape>> get_numpy_broadcast_partial_shapes(const std::vector<ov::PartialShape>& input_shapes) {- ov::PartialShape target_shape = input_shapes.front();+std::pair<ov::PartialShape, std::vector<ov::PartialShape>> get_numpy_broadcast_partial_shapes(+ const 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))OPENVINO_THROW("InsertMoveBroadcast: Failed broadcast-merge input shapes");@@ -32,10 +32,12 @@ std::pair<ov::PartialShape, std::vector<ov::PartialShape>> get_numpy_broadcast_preturn {target_shape, normalized_shapes};}-} // namespace+} // namespaceov::Output<ov::Node> ov::snippets::pass::InsertMoveBroadcast::BroadcastNodeLastDim(- const ov::Output<ov::Node>& value, const ov::PartialShape& target_shape, const ov::PartialShape& normalized_shape) {+ const ov::Output<ov::Node>& value,+ const ov::PartialShape& target_shape,+ const ov::PartialShape& normalized_shape) {if (target_shape == value.get_partial_shape()) {return value;}@@ -55,7 +57,7 @@ ov::Output<ov::Node> ov::snippets::pass::InsertMoveBroadcast::BroadcastNodeLastDov::snippets::pass::InsertMoveBroadcast::InsertMoveBroadcast() {MATCHER_SCOPE(InsertMoveBroadcast);- ov::graph_rewrite_callback callback = [](ov::pass::pattern::Matcher &m) {+ ov::graph_rewrite_callback callback = [](ov::pass::pattern::Matcher& m) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::op::InsertMoveBroadcast")auto root = m.get_match_root();const auto& values = root->input_values();@@ -63,7 +65,7 @@ ov::snippets::pass::InsertMoveBroadcast::InsertMoveBroadcast() {return false;}- auto is_ignored_node = [](const ov::Output<ov::Node>& v){+ auto is_ignored_node = [](const ov::Output<ov::Node>& v) {// We don't need to insert BroadcastMove after the following operations:// - Scalar has emitter with explicit broadcasting// - VectorBuffer has scalar output shape to avoid broadcast conflicts and manually shape insertion.@@ -82,7 +84,8 @@ ov::snippets::pass::InsertMoveBroadcast::InsertMoveBroadcast() {return false;}- // find the output tensor's shape, then broadcast all inputs so that they are compatible with respect to the last dim+ // find the output tensor's shape, then broadcast all inputs so that they are compatible with respect to the+ // last dimauto bcast_shapes = get_numpy_broadcast_partial_shapes(input_shapes);ov::OutputVector broadcasted_inputs;@@ -103,11 +106,15 @@ ov::snippets::pass::InsertMoveBroadcast::InsertMoveBroadcast() {};// only numpy broadcast type is supported currently- auto any = std::make_shared<ov::pass::pattern::op::Label>(ov::pass::pattern::any_input(),+ auto any = std::make_shared<ov::pass::pattern::op::Label>(+ ov::pass::pattern::any_input(),[](const std::shared_ptr<Node>& n) {// should add supports_auto_broadcast to SquaredDifference- return ((ov::op::util::supports_auto_broadcast(n) || is_type<ov::op::v0::SquaredDifference>(n) || is_type<ov::op::v1::Mod>(n)) &&- n->get_autob().m_type == ov::op::AutoBroadcastType::NUMPY) || is_type<ov::op::v0::PRelu>(n); });+ return ((ov::op::util::supports_auto_broadcast(n) || is_type<ov::op::v0::SquaredDifference>(n) ||+ is_type<ov::op::v1::Mod>(n)) &&+ n->get_autob().m_type == ov::op::AutoBroadcastType::NUMPY) ||+ is_type<ov::op::v0::PRelu>(n);+ });register_matcher(std::make_shared<ov::pass::pattern::Matcher>(any, matcher_name), callback);}diff --git a/src/common/snippets/src/pass/manager.cpp b/src/common/snippets/src/pass/manager.cppindex 37d236583f8..9e5719da31e 100644--- a/src/common/snippets/src/pass/manager.cpp+++ b/src/common/snippets/src/pass/manager.cpp@@ -4,7 +4,6 @@#include "snippets/pass/manager.hpp"-namespace ov {namespace snippets {namespace pass {@@ -35,6 +34,6 @@ std::shared_ptr<Manager::PassBase> Manager::insert_pass_instance(const PassPositreturn pass;}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/pass/matmul_to_brgemm.cpp b/src/common/snippets/src/pass/matmul_to_brgemm.cppindex 81941923b05..015e93828b4 100644--- a/src/common/snippets/src/pass/matmul_to_brgemm.cpp+++ b/src/common/snippets/src/pass/matmul_to_brgemm.cpp@@ -4,13 +4,12 @@#include "snippets/pass/matmul_to_brgemm.hpp"+#include "openvino/core/rt_info.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/utils/utils.hpp"-#include "snippets/lowered/port_descriptor.hpp"--#include "openvino/core/rt_info.hpp"-#include "openvino/pass/pattern/op/wrap_type.hpp"#include "transformations/utils/utils.hpp"namespace ov {@@ -21,7 +20,8 @@ using namespace lowered;MatMulToBrgemm::MatMulToBrgemm() {MATCHER_SCOPE(MatMulToBrgemm);- auto matmul_pattern = ov::pass::pattern::wrap_type<ov::opset1::MatMul>({ov::pass::pattern::any_input(), ov::pass::pattern::any_input()});+ auto matmul_pattern = ov::pass::pattern::wrap_type<ov::opset1::MatMul>(+ {ov::pass::pattern::any_input(), ov::pass::pattern::any_input()});auto callback = [matmul_pattern](ov::pass::pattern::Matcher& m) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "ov::intel_cpu::pass::MatMulToBrgemm")@@ -40,14 +40,15 @@ MatMulToBrgemm::MatMulToBrgemm() {const auto layout_a = generate_layout(matmul->get_input_partial_shape(0), matmul->get_transpose_a());const auto layout_b = generate_layout(matmul->get_input_partial_shape(1), matmul->get_transpose_b());- const auto brgemm = std::make_shared<op::Brgemm>(matmul->input_value(0), matmul->input_value(1), 0, 0, 0, layout_a, layout_b);+ const auto brgemm =+ std::make_shared<op::Brgemm>(matmul->input_value(0), matmul->input_value(1), 0, 0, 0, layout_a, layout_b);static const std::vector<size_t> subtensor{utils::get_full_dim_value(), utils::get_full_dim_value()};PortDescriptorUtils::set_port_descriptor(brgemm->input(0), subtensor, layout_a);PortDescriptorUtils::set_port_descriptor(brgemm->input(1), subtensor, layout_b);PortDescriptorUtils::set_port_descriptor(brgemm->output(0), subtensor);- ov::NodeVector nodes = { brgemm };+ ov::NodeVector nodes = {brgemm};if (brgemm->get_output_element_type(0) != matmul->get_output_element_type(0)) {nodes.emplace_back(std::make_shared<op::ConvertSaturation>(brgemm, matmul->get_output_element_type(0)));}diff --git a/src/common/snippets/src/pass/mha_tokenization.cpp b/src/common/snippets/src/pass/mha_tokenization.cppindex c98aac2461a..2a7b2e87f84 100644--- a/src/common/snippets/src/pass/mha_tokenization.cpp+++ b/src/common/snippets/src/pass/mha_tokenization.cpp@@ -2,6 +2,8 @@// SPDX-License-Identifier: Apache-2.0//+#include "snippets/pass/mha_tokenization.hpp"+#include "openvino/core/rt_info.hpp"#include "openvino/core/validation_util.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"@@ -10,14 +12,14 @@#include "snippets/op/subgraph.hpp"#include "snippets/pass/collapse_subgraph.hpp"#include "snippets/pass/explicit_transpose_matmul_inputs.hpp"-#include "snippets/pass/mha_tokenization.hpp"-#include "snippets/utils/utils.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) {- return t.get_partial_shape().rank().is_static() && ov::snippets::utils::one_of(t.get_partial_shape().size(), 2lu, 3lu, 4lu);+ return t.get_partial_shape().rank().is_static() &&+ ov::snippets::utils::one_of(t.get_partial_shape().size(), 2lu, 3lu, 4lu);}bool is_supported_intermediate_op(const std::shared_ptr<ov::Node>& node) {@@ -30,7 +32,9 @@ bool is_supported_intermediate_op(const std::shared_ptr<ov::Node>& node) {return is_intermediate_op(node) && ov::snippets::pass::TokenizeSnippets::AppropriateForSubgraph(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) {+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) {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)@@ -39,18 +43,19 @@ bool is_valid_transpose(const std::shared_ptr<ov::opset1::Transpose>& node, consreturn existing_order == expected_order && supported_ranks.count(existing_order.size()) != 0;};auto is_supported_transpose_tensor = [](const ov::descriptor::Tensor& t) {- return is_supported_tensor(t) && ov::snippets::pass::TokenizeSnippets::get_supported_element_types().count(t.get_element_type()) != 0;+ return is_supported_tensor(t) &&+ ov::snippets::pass::TokenizeSnippets::get_supported_element_types().count(t.get_element_type()) != 0;};- return node && node->get_output_target_inputs(0).size() == 1 && is_valid_transpose_order(node->get_input_node_shared_ptr(1)) &&+ return node && node->get_output_target_inputs(0).size() == 1 &&+ is_valid_transpose_order(node->get_input_node_shared_ptr(1)) &&is_supported_transpose_tensor(node->get_input_tensor(0));}void tokenize_broadcast(const std::shared_ptr<ov::Node>& interm_op, ov::NodeVector& ordered_ops) {- // We can tokenize Broadcast op only when output shape of child doesn't depend on Broadcast shape without last dimension.- // Snippets remove Broadcast op and insert BroadcastMove if last dimensions before and after Broadcast are different.- // Otherwise, we can lose original shape.- // Example:+ // We can tokenize Broadcast op only when output shape of child doesn't depend on Broadcast shape without last+ // dimension. Snippets remove Broadcast op and insert BroadcastMove if last dimensions before and after Broadcast+ // are different. Otherwise, we can lose original shape. Example:// in0 [1, 1, 1] in0 [1, 1, 1] in0 [1, 1, 1] in0 [1, 1, 1]// Broadcast [1, 10, 1] / \ /// \ / --->>> Add@@ -98,7 +103,9 @@ void tokenize_broadcast(const std::shared_ptr<ov::Node>& interm_op, ov::NodeVect}}-bool tokenize_reshape_around_softmax(std::shared_ptr<ov::Node>& interm_op, std::shared_ptr<ov::opset1::Reshape>& reshape, ov::NodeVector& ordered_ops) {+bool tokenize_reshape_around_softmax(std::shared_ptr<ov::Node>& interm_op,+ std::shared_ptr<ov::opset1::Reshape>& reshape,+ ov::NodeVector& ordered_ops) {reshape = ov::as_type_ptr<ov::opset1::Reshape>(interm_op);if (reshape) {// TODO: Add support of Reshape with ShapeOf subgraph on second input@@ -109,7 +116,8 @@ bool tokenize_reshape_around_softmax(std::shared_ptr<ov::Node>& interm_op, std::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)+ 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)return false;ordered_ops.push_back(reshape);@@ -124,8 +132,7 @@ size_t get_potential_body_params(const std::shared_ptr<ov::Node>& op) {const auto input = op->input_value(i);const auto parent = input.get_node_shared_ptr();const auto constant = ov::as_type_ptr<ov::op::v0::Constant>(parent);- if (!(constant && (ov::shape_size(input.get_shape()) == 1 ||- ov::is_type<ov::op::v0::FakeQuantize>(op)||+ if (!(constant && (ov::shape_size(input.get_shape()) == 1 || ov::is_type<ov::op::v0::FakeQuantize>(op) ||ov::snippets::op::Subgraph::constant_input_should_be_inside_body(op)))) {count++;}@@ -133,8 +140,10 @@ size_t get_potential_body_params(const std::shared_ptr<ov::Node>& op) {return count;}-bool update_intermediate_supported_ops(std::shared_ptr<ov::Node>& interm_op, ov::NodeVector& ordered_ops,- size_t& hidden_virtual_ports_count, size_t& potential_body_params_count) {+bool update_intermediate_supported_ops(std::shared_ptr<ov::Node>& interm_op,+ ov::NodeVector& ordered_ops,+ size_t& hidden_virtual_ports_count,+ size_t& potential_body_params_count) {while (is_supported_intermediate_op(interm_op)) {// All supported intermediate ops have only one output portif (interm_op->get_output_target_inputs(0).size() != 1)@@ -144,15 +153,17 @@ bool update_intermediate_supported_ops(std::shared_ptr<ov::Node>& interm_op, ov:if (interm_op->get_input_size() > 1) {tokenize_broadcast(interm_op, ordered_ops);- // 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 FakeQuantize that will be moved up from body.+ // 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+ // FakeQuantize that will be moved up from body.if (const auto fq_node = ov::as_type_ptr<ov::op::v0::FakeQuantize>(interm_op)) {hidden_virtual_ports_count += ov::snippets::utils::get_non_scalar_constant_count_for_fq(fq_node);}auto is_supported_branch_op = [&ordered_ops](const std::shared_ptr<ov::Node>& op) {return is_supported_intermediate_op(op) &&- ov::snippets::pass::GetSnippetsNodeType(op) != ov::snippets::pass::SnippetsNodeType::SkippedByPlugin &&+ ov::snippets::pass::GetSnippetsNodeType(op) !=+ ov::snippets::pass::SnippetsNodeType::SkippedByPlugin &&std::find(ordered_ops.begin(), ordered_ops.end(), op) == ordered_ops.end();};@@ -170,7 +181,8 @@ bool update_intermediate_supported_ops(std::shared_ptr<ov::Node>& interm_op, ov: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?+ // 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)parent = parent->get_input_node_shared_ptr(0);}@@ -209,260 +221,294 @@ bool ov::snippets::pass::TokenizeMHASnippets::is_matmul0_supported(const std::sh!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));+ const auto matmul_prc =+ op::Brgemm::get_output_type(matmul->get_input_element_type(0), matmul->get_input_element_type(1));return matmul_prc != element::dynamic;}ov::snippets::pass::TokenizeMHASnippets::TokenizeMHASnippets(const SnippetsTokenization::Config& config) {MATCHER_SCOPE(TokenizeMHASnippets);- auto m_matmul0 = std::make_shared<ov::opset1::MatMul>(ov::pass::pattern::any_input(), ov::pass::pattern::any_input());-- register_matcher(std::make_shared<ov::pass::pattern::Matcher>(m_matmul0, matcher_name),- [OV_CAPTURE_CPY_AND_THIS](ov::pass::pattern::Matcher &m) {- OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::op::TokenizeMHASnippets")- auto& pattern_to_output = m.get_pattern_value_map();-- // Queries + Key + Values = 3 standard inputs of MHA- size_t potential_body_params_count = 3;- // After some transformations, a different number of Constants for some operations may be created- // than the actual number of Constants during tokenization.- // To avoid unsupported number of non-scalar Constants in the future (plugin specific limitation)- // we should calculate potential number of non-scalar Constants that will be moved up from body.- size_t hidden_virtual_ports_count = 0;- // The count of potential unique Buffers - it's hidden virtual ports as well- // We should go through Subgraph and calculate potential non-inplace Buffers count.- // Example:- // Buffer - i32 [32, 128] -> ~ Loop ~ -> Buffer - i8 [32, 128]- // After each Loop iteration we should increment pointers of Buffers: accordingly on 4 byte and 1 byte for scalar case.- // It means that these increments are not proportional => Each Buffer should have the own register- // For that we can just check the following "branches":- // - Between MatMul0 and MatMul1 - Softmax is sync point. The operations between MatMul0 -> Softmax and Softmax -> MatMul1- // will be fused into one loop after conversion to snippet dialect (Because it's just FQ, Eltwise nodes)- // - Between MatMul0 and Transpose1 - At the moment operations after Transpose1 cannot be fused in inner Transpose Loop- // (to avoid performance regressions due to scalar calculations).- // 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 ========== */-- /****** Skeleton ******/- /* Skeleton on MHA-pattern is:- * \ /- * MatMul0- * |- * Eltwise/Select/Reshape/FakeQuantize- * |- * Softmax- * |- * Eltwise/Select/Reshape/FakeQuantize- * \ /- * MatMul1- */- 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))- return false;+ auto m_matmul0 =+ std::make_shared<ov::opset1::MatMul>(ov::pass::pattern::any_input(), ov::pass::pattern::any_input());++ register_matcher(+ std::make_shared<ov::pass::pattern::Matcher>(m_matmul0, matcher_name),+ [OV_CAPTURE_CPY_AND_THIS](ov::pass::pattern::Matcher& m) {+ OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::op::TokenizeMHASnippets")+ auto& pattern_to_output = m.get_pattern_value_map();++ // Queries + Key + Values = 3 standard inputs of MHA+ size_t potential_body_params_count = 3;+ // After some transformations, a different number of Constants for some operations may be created+ // than the actual number of Constants during tokenization.+ // To avoid unsupported number of non-scalar Constants in the future (plugin specific limitation)+ // we should calculate potential number of non-scalar Constants that will be moved up from body.+ size_t hidden_virtual_ports_count = 0;+ // The count of potential unique Buffers - it's hidden virtual ports as well+ // We should go through Subgraph and calculate potential non-inplace Buffers count.+ // Example:+ // Buffer - i32 [32, 128] -> ~ Loop ~ -> Buffer - i8 [32, 128]+ // After each Loop iteration we should increment pointers of Buffers: accordingly on 4 byte and 1 byte+ // for scalar case. It means that these increments are not proportional => Each Buffer should have the+ // own register+ // For that we can just check the following "branches":+ // - Between MatMul0 and MatMul1:+ // Softmax is sync point. The operations between MatMul0 -> Softmax and Softmax -> MatMul1+ // will be fused into one loop after conversion to snippet dialect (Because it's just FQ, Eltwise+ // nodes)+ // - Between MatMul0 and Transpose1:+ // At the moment operations after Transpose1 cannot be fused in inner Transpose Loop+ // (to avoid performance regressions due to scalar calculations).+ // 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 ========== */++ /****** Skeleton ******/+ /* Skeleton on MHA-pattern is:+ * \ /+ * MatMul0+ * |+ * Eltwise/Select/Reshape/FakeQuantize+ * |+ * Softmax+ * |+ * Eltwise/Select/Reshape/FakeQuantize+ * \ /+ * MatMul1+ */+ 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))+ return false;- ordered_ops.push_back(matmul0);+ ordered_ops.push_back(matmul0);- const auto pattern_rank = matmul0->get_output_partial_shape(0).size();+ const auto pattern_rank = matmul0->get_output_partial_shape(0).size();- auto interm_op = matmul0->get_output_target_inputs(0).begin()->get_node()->shared_from_this();- // Add supported operations which are between MatMul0 and Softmax to ordered_ops- if (!update_intermediate_supported_ops(interm_op, ordered_ops, hidden_virtual_ports_count, potential_body_params_count))- return false;+ auto interm_op = matmul0->get_output_target_inputs(0).begin()->get_node()->shared_from_this();+ // Add supported operations which are between MatMul0 and Softmax to ordered_ops+ if (!update_intermediate_supported_ops(interm_op,+ ordered_ops,+ hidden_virtual_ports_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))- return false;+ std::shared_ptr<ov::opset1::Reshape> reshape0 = nullptr;+ 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();- if (const auto softmax_v8 = ov::as_type_ptr<ov::op::v8::Softmax>(interm_op)) {- axis = ov::util::try_normalize_axis(softmax_v8->get_axis(), rank, *interm_op);- } else if (const auto softmax_v1 = ov::as_type_ptr<ov::op::v1::Softmax>(interm_op)) {- axis = softmax_v1->get_axis();- } else {- return false;- }+ int64_t axis = 0;+ const auto rank = interm_op->get_input_partial_shape(0).rank();+ if (const auto softmax_v8 = ov::as_type_ptr<ov::op::v8::Softmax>(interm_op)) {+ axis = ov::util::try_normalize_axis(softmax_v8->get_axis(), rank, *interm_op);+ } else if (const auto softmax_v1 = ov::as_type_ptr<ov::op::v1::Softmax>(interm_op)) {+ axis = softmax_v1->get_axis();+ } else {+ return false;+ }- if (axis != rank.get_length() - 1 || interm_op->get_output_target_inputs(0).size() != 1)- return false;+ if (axis != rank.get_length() - 1 || interm_op->get_output_target_inputs(0).size() != 1)+ return false;- ordered_ops.push_back(interm_op);+ 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))- return false;+ 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))+ return false;- if (((reshape0 == nullptr) != (reshape1 == nullptr)) ||- (reshape0 && reshape1 && (reshape0->get_input_partial_shape(0) != reshape1->get_output_partial_shape(0))))- return false;+ if (((reshape0 == nullptr) != (reshape1 == nullptr)) ||+ (reshape0 && reshape1 &&+ (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_ops- if (!update_intermediate_supported_ops(interm_op, ordered_ops, hidden_virtual_ports_count, potential_body_params_count))- return false;+ // Add supported operations which are between Softmax and MatMul1 to ordered_ops+ if (!update_intermediate_supported_ops(interm_op,+ ordered_ops,+ hidden_virtual_ports_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())- return false;+ const auto matmul1 = ov::as_type_ptr<ov::opset1::MatMul>(interm_op);+ 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)))- 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)))+ return false;- if (transformation_callback(matmul0)) {- return false;- }+ if (transformation_callback(matmul0)) {+ return false;+ }- // Between Softmax and MatMul1 will be the one Loop because of LoopFusing optimization.- // The Loop will have one Buffer with the same shape both on input and output.- // Need to check for precision to get if we need one more register for Buffer- const auto matmul0_prc = op::Brgemm::get_output_type(matmul0->get_input_element_type(0), matmul0->get_input_element_type(1));- if (matmul1->get_input_element_type(0).size() != matmul0_prc.size()) {- uniqie_buffer_reg_group_count++;- }+ // Between Softmax and MatMul1 will be the one Loop because of LoopFusing optimization.+ // The Loop will have one Buffer with the same shape both on input and output.+ // Need to check for precision to get if we need one more register for Buffer+ const auto matmul0_prc =+ op::Brgemm::get_output_type(matmul0->get_input_element_type(0), matmul0->get_input_element_type(1));+ if (matmul1->get_input_element_type(0).size() != matmul0_prc.size()) {+ uniqie_buffer_reg_group_count++;+ }- /***********************/-- /***** Transposes *****/- /* There may be Transpose and Reshape ops on inputs and outputs of MHA-pattern skeleton- * We can add them into Subgraph body- * Transpose0 Transpose1- * \ /- * MatMul0- * |- * [...] Transpose2- * \ /- * MatMul1- * |- * Transpose3- */-- auto tokenize_transpose = [&](const std::shared_ptr<ov::opset1::Transpose>& transpose,- bool is_input_transposed, size_t rank,- const ov::NodeVector::const_iterator& pos) {- // Transpose is redundant for 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);- if (!is_input_transposed) {+ /***********************/++ /***** Transposes *****/+ /* There may be Transpose and Reshape ops on inputs and outputs of MHA-pattern skeleton+ * We can add them into Subgraph body+ * Transpose0 Transpose1+ * \ /+ * MatMul0+ * |+ * [...] Transpose2+ * \ /+ * MatMul1+ * |+ * Transpose3+ */++ auto tokenize_transpose = [&](const std::shared_ptr<ov::opset1::Transpose>& transpose,+ bool is_input_transposed,+ size_t rank,+ const ov::NodeVector::const_iterator& pos) {+ // Transpose is redundant for 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);+ if (!is_input_transposed) {+ if (is_valid_transpose(transpose, config.get_mha_supported_transpose_ranks(), order)) {+ ordered_ops.insert(pos, transpose);+ }+ return;+ }+ std::swap(order[rank - 1], order[rank - 2]);if (is_valid_transpose(transpose, config.get_mha_supported_transpose_ranks(), order)) {ordered_ops.insert(pos, transpose);}- return;- }- std::swap(order[rank - 1], order[rank - 2]);- if (is_valid_transpose(transpose, config.get_mha_supported_transpose_ranks(), order)) {- ordered_ops.insert(pos, transpose);+ };++ // [160177]: Due to performance problems, if operations on 2nd input of MatMuls should be explicitly+ // executed+ // (in other words, if the Buffer should be inserted between Brgemm and this op sequence),+ // we don't tokenize such operations into Subgraph. The details are described in the ticket 160177.+ // Please, return the tokenization of these ops when parallel loops are implemented.+ const auto transpose0 = ov::as_type_ptr<ov::opset1::Transpose>(matmul0->get_input_node_shared_ptr(0));+ const auto transpose1 = ov::as_type_ptr<ov::opset1::Transpose>(matmul0->get_input_node_shared_ptr(1));+ const auto transpose2 = ov::as_type_ptr<ov::opset1::Transpose>(matmul1->get_input_node_shared_ptr(1));+ tokenize_transpose(transpose0, matmul0->get_transpose_a(), pattern_rank, ordered_ops.begin());+ tokenize_transpose(transpose1, matmul0->get_transpose_b(), pattern_rank, ordered_ops.begin());+ tokenize_transpose(transpose2, matmul1->get_transpose_b(), pattern_rank, ordered_ops.end());+ ordered_ops.push_back(matmul1);++ bool are_ops_after_matmul1 = false;+ auto child = matmul1->get_output_target_inputs(0).begin()->get_node()->shared_from_this();+ const auto can_be_ops_after_matmul1_tokenized = matmul1->get_output_target_inputs(0).size() == 1;+ bool has_matmul1_has_ops_on_output = false;+ while (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)+ 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+ // FakeQuantize that will be moved up from body.+ if (const auto fq_node = ov::as_type_ptr<ov::op::v0::FakeQuantize>(child)) {+ hidden_virtual_ports_count += ov::snippets::utils::get_non_scalar_constant_count_for_fq(fq_node);+ }+ potential_body_params_count += get_potential_body_params(child);++ // TODO [75567]: move this plugin-specific constraint to the plugin callback+ // We cannot collapse op to Subgraph if count of potential Parameter and Result count is+ // higher 12+ if (potential_body_params_count + child->get_output_target_inputs(0).size() ++ hidden_virtual_ports_count + uniqie_buffer_reg_group_count >+ 12) {+ break;+ }++ ordered_ops.push_back(child);+ child = child->get_output_target_inputs(0).begin()->get_node()->shared_from_this();+ has_matmul1_has_ops_on_output = true;}- };-- // [160177]: Due to performance problems, if operations on 2nd input of MatMuls should be explicitly executed- // (in other words, if the Buffer should be inserted between Brgemm and this op sequence),- // we don't tokenize such operations into Subgraph. The details are described in the ticket 160177.- // Please, return the tokenization of these ops when parallel loops are implemented.- const auto transpose0 = ov::as_type_ptr<ov::opset1::Transpose>(matmul0->get_input_node_shared_ptr(0));- const auto transpose1 = ov::as_type_ptr<ov::opset1::Transpose>(matmul0->get_input_node_shared_ptr(1));- const auto transpose2 = ov::as_type_ptr<ov::opset1::Transpose>(matmul1->get_input_node_shared_ptr(1));- tokenize_transpose(transpose0, matmul0->get_transpose_a(), pattern_rank, ordered_ops.begin());- tokenize_transpose(transpose1, matmul0->get_transpose_b(), pattern_rank, ordered_ops.begin());- tokenize_transpose(transpose2, matmul1->get_transpose_b(), pattern_rank, ordered_ops.end());- ordered_ops.push_back(matmul1);-- bool are_ops_after_matmul1 = false;- auto child = matmul1->get_output_target_inputs(0).begin()->get_node()->shared_from_this();- const auto can_be_ops_after_matmul1_tokenized = matmul1->get_output_target_inputs(0).size() == 1;- bool has_matmul1_has_ops_on_output = false;- while (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)- 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 FakeQuantize that will be moved up from body.- if (const auto fq_node = ov::as_type_ptr<ov::op::v0::FakeQuantize>(child)) {- hidden_virtual_ports_count += ov::snippets::utils::get_non_scalar_constant_count_for_fq(fq_node);+ if (has_matmul1_has_ops_on_output) {+ uniqie_buffer_reg_group_count++;}- potential_body_params_count += get_potential_body_params(child);- // TODO [75567]: move this plugin-specific constraint to the plugin callback- // We cannot collapse op to Subgraph if count of potential Parameter and Result count is higher 12- if (potential_body_params_count + child->get_output_target_inputs(0).size() + hidden_virtual_ports_count + uniqie_buffer_reg_group_count > 12) {- break;+ // At the moment Snippets don't support nodes between MatMul1 and Transpose3 due to Loop and strided+ // calculations limitations+ // MatMul1+ // <Supported ops>+ // Transpose3+ if (can_be_ops_after_matmul1_tokenized && !are_ops_after_matmul1 && pattern_rank > 2) {+ auto transpose3 = config.get_mha_token_enable_transpose_on_output()+ ? ov::as_type_ptr<ov::opset1::Transpose>(child)+ : nullptr;+ if (is_valid_transpose(transpose3,+ config.get_mha_supported_transpose_ranks(),+ get_fusion_transpose_order(pattern_rank)) &&+ transpose3->get_input_element_type(0) ==+ matmul1_out_type) { // To avoid Convert between MatMul1 and Transpose3+ ordered_ops.push_back(transpose3);+ }}- ordered_ops.push_back(child);- child = child->get_output_target_inputs(0).begin()->get_node()->shared_from_this();- has_matmul1_has_ops_on_output = true;- }- if (has_matmul1_has_ops_on_output) {- uniqie_buffer_reg_group_count++;- }+ /**********************/- // At the moment Snippets don't support nodes between MatMul1 and Transpose3 due to Loop and strided calculations limitations- // MatMul1- // <Supported ops>- // Transpose3- if (can_be_ops_after_matmul1_tokenized && !are_ops_after_matmul1 && pattern_rank > 2) {- auto transpose3 = config.get_mha_token_enable_transpose_on_output() ? ov::as_type_ptr<ov::opset1::Transpose>(child) : nullptr;- if (is_valid_transpose(transpose3, config.get_mha_supported_transpose_ranks(), get_fusion_transpose_order(pattern_rank)) &&- transpose3->get_input_element_type(0) == matmul1_out_type) { // To avoid Convert between MatMul1 and Transpose3- ordered_ops.push_back(transpose3);- }- }+ /* ================================ */- /**********************/-- /* ================================ */-- /* ======= Support checks ========= */-- // TODO [75567]: move this plugin-specific constraint to the plugin callback- const auto last_node = ordered_ops.back();- const auto io_count = potential_body_params_count + last_node->get_output_size() + hidden_virtual_ports_count;- const auto data_count = io_count + uniqie_buffer_reg_group_count;- auto available_regs = config.get_data_ptr_gpr_count();- // [150148, 150149] Currently Snippets don't have mechanism of spilling registers on stack.- // Due to this limitation we have to skip tokenization of some subgraphs- // if we need more registers than we have on the target machine.- // `config.get_data_ptr_gpr_count()` provides available data registers count (including parameters, results and buffers)- // after excluding 2 registers for work amounts.- // However, MHA Subgraph has `SplitLoops` optimization which adds outermost blocked Loop by M. This Loop requires- // the separate own register for `work_amount` also. Thus, we have to decrement `available_regs` count in MHA case.- // Need to notice that in general we have enough count of available registers.- // But in rare cases (when there are a lot of 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)- available_regs--;-- if (data_count > available_regs)- return false;+ /* ======= Support checks ========= */- // If backend doesn't enable dynamic MHA tokenization, return false- if (!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(); }))+ // TODO [75567]: move this plugin-specific constraint to the plugin callback+ const auto last_node = ordered_ops.back();+ const auto io_count =+ potential_body_params_count + last_node->get_output_size() + hidden_virtual_ports_count;+ const auto data_count = io_count + uniqie_buffer_reg_group_count;+ auto available_regs = config.get_data_ptr_gpr_count();+ // [150148, 150149] Currently Snippets don't have mechanism of spilling registers on stack.+ // Due to this limitation we have to skip tokenization of some subgraphs+ // if we need more registers than we have on the target machine.+ // `config.get_data_ptr_gpr_count()` provides available data registers count (including+ // parameters, results and buffers) after excluding 2 registers for work amounts. However,+ // MHA Subgraph has `SplitLoops` optimization which adds outermost blocked Loop by M. This+ // Loop requires the separate own register for `work_amount` also. Thus, we have to+ // decrement `available_regs` count in MHA case. Need to notice that in general we have+ // enough count of available registers. But in rare cases (when there are a lot of+ // 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)+ available_regs--;++ if (data_count > available_regs)return false;- }- /* ================================ */+ // If backend doesn't enable dynamic MHA tokenization, return false+ if (!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;+ }++ /* ================================ */- const auto subgraph = ov::snippets::utils::tokenize_ordered_nodes(ordered_ops);+ const auto subgraph = ov::snippets::utils::tokenize_ordered_nodes(ordered_ops);- // mark the Subgraph as Completed to not allow Snippets to include any nodes into the MHA Subgraph in common Tokenization- SetSnippetsSubgraphType(subgraph, SnippetsSubgraphType::Completed);+ // mark the Subgraph as Completed to not allow Snippets to include any nodes into the MHA Subgraph in common+ // Tokenization+ SetSnippetsSubgraphType(subgraph, SnippetsSubgraphType::Completed);- return true;+ return true;- /* ================================ */- });+ /* ================================ */+ });}diff --git a/src/common/snippets/src/pass/mlp_seq_tokenization.cpp b/src/common/snippets/src/pass/mlp_seq_tokenization.cppindex 955e0ec7923..28ef75a5a70 100644--- a/src/common/snippets/src/pass/mlp_seq_tokenization.cpp+++ b/src/common/snippets/src/pass/mlp_seq_tokenization.cpp@@ -4,16 +4,15 @@#include "snippets/pass/mlp_seq_tokenization.hpp"+#include "openvino/core/rt_info.hpp"+#include "openvino/core/validation_util.hpp"+#include "openvino/pass/pattern/op/wrap_type.hpp"#include "snippets/itt.hpp"#include "snippets/op/brgemm.hpp"#include "snippets/op/subgraph.hpp"#include "snippets/pass/collapse_subgraph.hpp"-#include "snippets/utils/utils.hpp"#include "snippets/utils/tokenization_utils.hpp"--#include "openvino/core/rt_info.hpp"-#include "openvino/core/validation_util.hpp"-#include "openvino/pass/pattern/op/wrap_type.hpp"+#include "snippets/utils/utils.hpp"#include "transformations/utils/utils.hpp"namespace ov {@@ -36,7 +35,8 @@ size_t get_potential_body_params(const std::shared_ptr<ov::Node>& op) {const auto parent = input.get_node_shared_ptr();const auto constant = ov::as_type_ptr<ov::op::v0::Constant>(parent);const auto is_scalar = constant && (ov::shape_size(input.get_shape()) == 1);- const auto should_be_inside_body = constant && ov::snippets::op::Subgraph::constant_input_should_be_inside_body(op);+ const auto should_be_inside_body =+ constant && ov::snippets::op::Subgraph::constant_input_should_be_inside_body(op);if (!(is_scalar || should_be_inside_body)) {count++;}@@ -44,7 +44,7 @@ size_t get_potential_body_params(const std::shared_ptr<ov::Node>& op) {return count;}-} // namespace+} // namespaceconst size_t TokenizeMLPSeqSnippets::m_rank = 2;@@ -81,10 +81,9 @@ bool TokenizeMLPSeqSnippets::is_supported_intermediate_op(const std::shared_ptr<if (!ov::snippets::pass::TokenizeSnippets::AppropriateForSubgraph(node)) {return false;}- return is_supported_softmax(node) ||- ov::is_type_any_of<ov::op::util::UnaryElementwiseArithmetic,- ov::op::util::BinaryElementwiseArithmetic,- ov::op::v0::FakeQuantize>(node);+ return is_supported_softmax(node) || ov::is_type_any_of<ov::op::util::UnaryElementwiseArithmetic,+ ov::op::util::BinaryElementwiseArithmetic,+ ov::op::v0::FakeQuantize>(node);}TokenizeMLPSeqSnippets::TokenizeMLPSeqSnippets(const SnippetsTokenization::Config& config) {@@ -93,116 +92,120 @@ TokenizeMLPSeqSnippets::TokenizeMLPSeqSnippets(const SnippetsTokenization::Confiauto constant = ov::pass::pattern::wrap_type<ov::op::v0::Constant>();auto m_matmul0 = ov::pass::pattern::wrap_type<ov::opset1::MatMul>({ov::pass::pattern::any_input(), constant});- register_matcher(std::make_shared<ov::pass::pattern::Matcher>(m_matmul0, matcher_name),- [OV_CAPTURE_CPY_AND_THIS](ov::pass::pattern::Matcher &m) {- OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::op::TokenizeMLPSeqSnippets")- auto& pattern_to_output = m.get_pattern_value_map();-- // Two inputs of first MatMul- size_t potential_body_params_count = 2;- // After some transformations, a different number of Constants for some operations may be created- // than the actual number of Constants during tokenization.- // To avoid unsupported number of non-scalar Constants in the future (plugin specific limitation)- // we should calculate potential number of non-scalar Constants that will be moved up from body.- // Heuiristic count of possible buffers - upper-bound value- const size_t unique_buffer_reg_group_count = 2;- std::string fused_names;- ov::NodeVector ordered_ops;-- /* ======== Matcher Pass ========== */-- /****** Skeleton ******/- /* Skeleton on MLPSeq sequence-pattern is:- * MatMul0- * |- * Eltwise/FakeQuantize (1 or more)- * |- * MatMul1- * |- * Eltwise/FakeQuantize (1 or more)- * |- * MatMul2- * |- * ...- */-- const auto matmul0 = ov::as_type_ptr<ov::opset1::MatMul>(pattern_to_output.at(m_matmul0).get_node_shared_ptr());- if (!is_matmul_supported(matmul0) || !has_one_consumer(matmul0)) {- return false;- }-- if (transformation_callback(matmul0)) {- return false;- }+ register_matcher(+ std::make_shared<ov::pass::pattern::Matcher>(m_matmul0, matcher_name),+ [OV_CAPTURE_CPY_AND_THIS](ov::pass::pattern::Matcher& m) {+ OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::op::TokenizeMLPSeqSnippets")+ auto& pattern_to_output = m.get_pattern_value_map();++ // Two inputs of first MatMul+ size_t potential_body_params_count = 2;+ // After some transformations, a different number of Constants for some operations may be created+ // than the actual number of Constants during tokenization.+ // To avoid unsupported number of non-scalar Constants in the future (plugin specific limitation)+ // we should calculate potential number of non-scalar Constants that will be moved up from body.+ // Heuiristic count of possible buffers - upper-bound value+ const size_t unique_buffer_reg_group_count = 2;+ std::string fused_names;+ ov::NodeVector ordered_ops;++ /* ======== Matcher Pass ========== */++ /****** Skeleton ******/+ /* Skeleton on MLPSeq sequence-pattern is:+ * MatMul0+ * |+ * Eltwise/FakeQuantize (1 or more)+ * |+ * MatMul1+ * |+ * Eltwise/FakeQuantize (1 or more)+ * |+ * MatMul2+ * |+ * ...+ */++ const auto matmul0 =+ ov::as_type_ptr<ov::opset1::MatMul>(pattern_to_output.at(m_matmul0).get_node_shared_ptr());+ if (!is_matmul_supported(matmul0) || !has_one_consumer(matmul0)) {+ return false;+ }- // Add possible FQ before matmul0- if (const auto fq = ov::as_type_ptr<ov::op::v0::FakeQuantize>(matmul0->input_value(0).get_node_shared_ptr())) {- if (has_one_consumer(fq)) {- potential_body_params_count += ov::snippets::utils::get_non_scalar_constant_count_for_fq(fq);- ordered_ops.push_back(fq);+ if (transformation_callback(matmul0)) {+ return false;}- }- ordered_ops.push_back(matmul0);-- // Tokenize Sequence while we can do it- std::shared_ptr<ov::Node> prev_op = matmul0;- auto interm_op = prev_op->get_output_target_inputs(0).begin()->get_node()->shared_from_this();- auto available_regs = config.get_data_ptr_gpr_count();-- bool postops_fusion_possible = true;- std::shared_ptr<ov::op::v0::MatMul> cur_matmul = matmul0;- while (has_one_consumer(prev_op)) {- auto current_potential_body_params_count = potential_body_params_count;-- if (is_matmul_supported(interm_op) && !transformation_callback(interm_op)) {- // +1 for weights- current_potential_body_params_count++;- // If MatMul is the first in the sequence, postops fusion status is reset- postops_fusion_possible = true;- cur_matmul = ov::as_type_ptr<ov::op::v0::MatMul>(interm_op);- OPENVINO_ASSERT(cur_matmul, "MatMul is expected");- } else if (is_supported_intermediate_op(interm_op)) {- // Intermediate op contributes to the body params count only if can't be fused as post-op- // or if a previous node between MatMul and this op is not supported by post-op fusion- if (!postops_fusion_possible || config.get_can_be_fused_as_postop() == nullptr ||- !config.get_can_be_fused_as_postop()(cur_matmul, interm_op)) {- postops_fusion_possible = false;- current_potential_body_params_count += get_potential_body_params(interm_op);++ // Add possible FQ before matmul0+ if (const auto fq =+ ov::as_type_ptr<ov::op::v0::FakeQuantize>(matmul0->input_value(0).get_node_shared_ptr())) {+ if (has_one_consumer(fq)) {+ potential_body_params_count += ov::snippets::utils::get_non_scalar_constant_count_for_fq(fq);+ ordered_ops.push_back(fq);}- } else {- // Unsupported op- break;}+ ordered_ops.push_back(matmul0);++ // Tokenize Sequence while we can do it+ std::shared_ptr<ov::Node> prev_op = matmul0;+ auto interm_op = prev_op->get_output_target_inputs(0).begin()->get_node()->shared_from_this();+ auto available_regs = config.get_data_ptr_gpr_count();++ bool postops_fusion_possible = true;+ std::shared_ptr<ov::op::v0::MatMul> cur_matmul = matmul0;+ while (has_one_consumer(prev_op)) {+ auto current_potential_body_params_count = potential_body_params_count;++ if (is_matmul_supported(interm_op) && !transformation_callback(interm_op)) {+ // +1 for weights+ current_potential_body_params_count++;+ // If MatMul is the first in the sequence, postops fusion status is reset+ postops_fusion_possible = true;+ cur_matmul = ov::as_type_ptr<ov::op::v0::MatMul>(interm_op);+ OPENVINO_ASSERT(cur_matmul, "MatMul is expected");+ } else if (is_supported_intermediate_op(interm_op)) {+ // Intermediate op contributes to the body params count only if can't be fused as post-op+ // or if a previous node between MatMul and this op is not supported by post-op fusion+ if (!postops_fusion_possible || config.get_can_be_fused_as_postop() == nullptr ||+ !config.get_can_be_fused_as_postop()(cur_matmul, interm_op)) {+ postops_fusion_possible = false;+ current_potential_body_params_count += get_potential_body_params(interm_op);+ }+ } else {+ // Unsupported op+ break;+ }- // 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)- break;+ // 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)+ break;- ordered_ops.push_back(interm_op);- prev_op = interm_op;- interm_op = prev_op->get_output_target_inputs(0).begin()->get_node()->shared_from_this();+ ordered_ops.push_back(interm_op);+ prev_op = interm_op;+ interm_op = prev_op->get_output_target_inputs(0).begin()->get_node()->shared_from_this();- // Move counts- potential_body_params_count = current_potential_body_params_count;- }+ // Move counts+ potential_body_params_count = current_potential_body_params_count;+ }- // Currently, sequence of MLP should contain 2 MatMuls at least- size_t mm_count = 0;- for (const auto& op : ordered_ops) {- mm_count += (ov::is_type<ov::op::v0::MatMul>(op));- }- if (mm_count < 2)- return false;+ // Currently, sequence of MLP should contain 2 MatMuls at least+ size_t mm_count = 0;+ for (const auto& op : ordered_ops) {+ mm_count += (ov::is_type<ov::op::v0::MatMul>(op));+ }+ if (mm_count < 2)+ return false;- /* ====== Subgraph creation ======= */+ /* ====== Subgraph creation ======= */- const auto subgraph = ov::snippets::utils::tokenize_ordered_nodes(ordered_ops);+ const auto subgraph = ov::snippets::utils::tokenize_ordered_nodes(ordered_ops);- // mark the Subgraph as Completed to not allow Snippets to include any nodes into this Subgraph in common Tokenization- SetSnippetsSubgraphType(subgraph, SnippetsSubgraphType::Completed);- return true;- });+ // mark the Subgraph as Completed to not allow Snippets to include any nodes into this Subgraph in common+ // Tokenization+ SetSnippetsSubgraphType(subgraph, SnippetsSubgraphType::Completed);+ return true;+ });}} // namespace passdiff --git a/src/common/snippets/src/pass/positioned_pass.cpp b/src/common/snippets/src/pass/positioned_pass.cppindex f48a795e584..c8c038993b3 100644--- a/src/common/snippets/src/pass/positioned_pass.cpp+++ b/src/common/snippets/src/pass/positioned_pass.cpp@@ -4,22 +4,25 @@#include "snippets/pass/positioned_pass.hpp"-namespace ov {namespace snippets {namespace pass {PassPosition::PassPosition(Place pass_place) : m_place(pass_place) {OPENVINO_ASSERT(m_place == Place::PipelineStart || m_place == Place::PipelineEnd,- "Invalid arg: pass_type_info and pass_instance args could be omitted only for Place::PipelineStart/Place::PipelineEnd");+ "Invalid arg: pass_type_info and pass_instance args could be omitted only for "+ "Place::PipelineStart/Place::PipelineEnd");}PassPosition::PassPosition(Place pass_place, const DiscreteTypeInfo& pass_type_info, size_t pass_instance)-: m_pass_type_info(pass_type_info), m_pass_instance(pass_instance), m_place(pass_place) {- OPENVINO_ASSERT((m_place == Place::Before || m_place == Place::After) && m_pass_type_info != DiscreteTypeInfo(),- "Invalid args combination: pass_place must be Place::Before/Place::After and pass_type_info must be non-empty");+ : m_pass_type_info(pass_type_info),+ m_pass_instance(pass_instance),+ m_place(pass_place) {+ OPENVINO_ASSERT(+ (m_place == Place::Before || m_place == Place::After) && m_pass_type_info != DiscreteTypeInfo(),+ "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 pass+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/pass/propagate_precision.cpp b/src/common/snippets/src/pass/propagate_precision.cppindex dc144e43c27..8ba2cf57a62 100644--- a/src/common/snippets/src/pass/propagate_precision.cpp+++ b/src/common/snippets/src/pass/propagate_precision.cpp@@ -4,18 +4,16 @@#include "snippets/pass/propagate_precision.hpp"+#include <memory>++#include "openvino/core/rt_info.hpp"#include "ov_ops/type_relaxed.hpp"#include "snippets/itt.hpp"#include "snippets/utils/utils.hpp"-#include "openvino/core/rt_info.hpp"#include "transformations/utils/utils.hpp"-#include <memory>---ov::snippets::pass::PropagatePrecision::PropagatePrecision(- const std::shared_ptr<const TargetMachine>& target_machine) : target_machine(target_machine) {-}+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) {RUN_ON_MODEL_SCOPE(PropagatePrecision);@@ -74,21 +72,18 @@ bool ov::snippets::pass::PropagatePrecision::run_on_model(const std::shared_ptr<// update input precisions// if possible then convert precisions to supportedif (!supported_precisions.empty() &&- std::all_of(- supported_precisions.begin(),- supported_precisions.end(),- [&input_precisions](const std::vector<element::Type>& precisions) {- return precisions != input_precisions;- })) {- auto precisions = get_precisions(input_precisions,- supported_precisions);- OPENVINO_ASSERT(- !precisions.empty(),- "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,- const ov::element::Type convert_type) -> snippets::op::ConvertSaturation* {+ std::all_of(supported_precisions.begin(),+ supported_precisions.end(),+ [&input_precisions](const std::vector<element::Type>& precisions) {+ return precisions != input_precisions;+ })) {+ auto precisions = get_precisions(input_precisions, supported_precisions);+ OPENVINO_ASSERT(!precisions.empty(),+ "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,+ 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());if ((child != nullptr) && (child->get_output_element_type(0) == convert_type)) {@@ -105,8 +100,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);@@ -119,9 +113,8 @@ bool ov::snippets::pass::PropagatePrecision::run_on_model(const std::shared_ptr<if (existing_convert == nullptr) {// create new Convert- auto convert = std::make_shared<ov::snippets::op::ConvertSaturation>(- parent_output,- required_after);+ auto convert =+ std::make_shared<ov::snippets::op::ConvertSaturation>(parent_output, required_after);copy_runtime_info(parent_output.get_node_shared_ptr(), convert);op->set_argument(op_input.get_index(), convert);continue;@@ -147,9 +140,8 @@ bool ov::snippets::pass::PropagatePrecision::run_on_model(const std::shared_ptr<}// create new convert- auto convert = std::make_shared<ov::snippets::op::ConvertSaturation>(- existing_convert->output(0),- required_after);+ auto convert = std::make_shared<ov::snippets::op::ConvertSaturation>(existing_convert->output(0),+ required_after);copy_runtime_info(existing_convert->output(0).get_node()->shared_from_this(), convert);op->set_argument(op_input.get_index(), convert);}@@ -169,9 +161,7 @@ bool ov::snippets::pass::PropagatePrecision::run_on_model(const std::shared_ptr<const auto expected_type = it->second;if (actual_type != it->second) {was_updated = true;- auto convert = std::make_shared<ov::snippets::op::ConvertSaturation>(- result->input_value(0),- expected_type);+ 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);result->set_argument(0, convert);}@@ -180,7 +170,8 @@ bool ov::snippets::pass::PropagatePrecision::run_on_model(const std::shared_ptr<return was_updated;}-bool ov::snippets::pass::PropagatePrecision::validate_and_infer_types_and_restore_outputs(const std::shared_ptr<ov::Node>& op) {+bool ov::snippets::pass::PropagatePrecision::validate_and_infer_types_and_restore_outputs(+ const std::shared_ptr<ov::Node>& op) {bool was_updated = false;// update output precision@@ -212,9 +203,7 @@ bool ov::snippets::pass::PropagatePrecision::validate_and_infer_types_and_restorif (output.get_element_type() != op_output_types[i]) {was_updated = true;- auto convert = std::make_shared<ov::snippets::op::ConvertSaturation>(- output,- op_output_types[i]);+ auto 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()) {@@ -225,7 +214,6 @@ bool ov::snippets::pass::PropagatePrecision::validate_and_infer_types_and_restorinput.replace_source_output(convert->output(0));-if (ov::is_type<ov::op::v0::Result>(input.get_node())) {// Result input tensor name was changed, the name has to be restored// task #107826@@ -269,10 +257,8 @@ bool ov::snippets::pass::PropagatePrecision::can_be_fused(const element::Type& a}// general conditions: any new added precision will support- return- (actual.is_signed() == required.is_signed()) &&- (actual.is_real() == required.is_real()) &&- (actual.bitwidth() > required.bitwidth());+ return (actual.is_signed() == required.is_signed()) && (actual.is_real() == required.is_real()) &&+ (actual.bitwidth() > required.bitwidth());}std::vector<ov::element::Type> ov::snippets::pass::PropagatePrecision::get_precisions(diff --git a/src/common/snippets/src/pass/reduce_to_snippets_reduce.cpp b/src/common/snippets/src/pass/reduce_to_snippets_reduce.cppindex 17e09c87cd6..dff653b2a69 100644--- a/src/common/snippets/src/pass/reduce_to_snippets_reduce.cpp+++ b/src/common/snippets/src/pass/reduce_to_snippets_reduce.cpp@@ -5,13 +5,13 @@#include "snippets/pass/reduce_to_snippets_reduce.hpp"#include "openvino/core/rt_info.hpp"+#include "openvino/core/validation_util.hpp"#include "openvino/op/reduce_max.hpp"#include "openvino/op/reduce_sum.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"#include "snippets/itt.hpp"#include "snippets/lowered/port_descriptor.hpp"#include "snippets/op/reduce.hpp"-#include "openvino/core/validation_util.hpp"namespace ov {namespace snippets {@@ -21,13 +21,14 @@ snippets::pass::ReduceToSnippetsReduce::ReduceToSnippetsReduce() {MATCHER_SCOPE(ReduceToSnippetsReduce);auto reduce_pattern = ov::pass::pattern::wrap_type<ov::op::v1::ReduceSum, ov::op::v1::ReduceMax>();- auto callback = [](ov::pass::pattern::Matcher &m) {+ auto callback = [](ov::pass::pattern::Matcher& m) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::op::ReduceToSnippetsReduce")auto reduce = m.get_match_root();const auto& reduce_base = ov::as_type_ptr<ov::op::util::ArithmeticReductionKeepDims>(reduce);OPENVINO_ASSERT(reduce_base, "Failed to cast Reduce operation to ArithmeticReductionKeepDims");const auto& axis_constant = ov::as_type_ptr<ov::op::v0::Constant>(reduce->get_input_node_shared_ptr(1));- // Note: we do not check the Constant value here. If the Reduce was tokenized, then we assume that it is supported+ // Note: we do not check the Constant value here. If the Reduce was tokenized, then we assume that it is+ // supportedOPENVINO_ASSERT(reduce_base->get_keep_dims() && axis_constant, "Unspported Reduce was tokenized by Snippets");const auto& data_input = reduce->get_input_source_output(0);@@ -54,6 +55,6 @@ snippets::pass::ReduceToSnippetsReduce::ReduceToSnippetsReduce() {register_matcher(m, callback);}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/pass/softmax_decomposition.cpp b/src/common/snippets/src/pass/softmax_decomposition.cppindex 5f00c770f4d..76ec53d7d91 100644--- a/src/common/snippets/src/pass/softmax_decomposition.cpp+++ b/src/common/snippets/src/pass/softmax_decomposition.cpp@@ -4,6 +4,7 @@#include "snippets/pass/softmax_decomposition.hpp"+#include "openvino/core/validation_util.hpp"#include "openvino/op/softmax.hpp"#include "openvino/pass/pattern/op/or.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"@@ -11,7 +12,6 @@#include "snippets/lowered/port_descriptor.hpp"#include "snippets/op/reduce.hpp"#include "snippets/snippets_isa.hpp"-#include "openvino/core/validation_util.hpp"namespace ov {namespace snippets {diff --git a/src/common/snippets/src/pass/softmax_reshape_elimination.cpp b/src/common/snippets/src/pass/softmax_reshape_elimination.cppindex 80b580a2996..a8b6b07adce 100644--- a/src/common/snippets/src/pass/softmax_reshape_elimination.cpp+++ b/src/common/snippets/src/pass/softmax_reshape_elimination.cpp@@ -2,24 +2,29 @@// SPDX-License-Identifier: Apache-2.0//+#include "snippets/pass/softmax_reshape_elimination.hpp"+#include "openvino/core/rt_info.hpp"#include "openvino/core/validation_util.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"#include "snippets/itt.hpp"-#include "snippets/pass/softmax_reshape_elimination.hpp"#include "snippets/remarks.hpp"#include "snippets/snippets_isa.hpp"ov::snippets::pass::SoftmaxReshapeElimination::SoftmaxReshapeElimination() {MATCHER_SCOPE(SoftmaxReshapeElimination);- const auto m_reshape0 = ov::pass::pattern::wrap_type<ov::op::v1::Reshape>({ov::pass::pattern::any_input(),- ov::pass::pattern::wrap_type<ov::op::v0::Constant>()},+ const auto m_reshape0 = ov::pass::pattern::wrap_type<ov::op::v1::Reshape>(+ {ov::pass::pattern::any_input(), ov::pass::pattern::wrap_type<ov::op::v0::Constant>()},+ ov::pass::pattern::consumers_count(1));+ const auto m_softmax =+ ov::pass::pattern::wrap_type<ov::op::v1::Softmax, ov::op::v8::Softmax>({m_reshape0},ov::pass::pattern::consumers_count(1));- const auto m_softmax = ov::pass::pattern::wrap_type<ov::op::v1::Softmax, ov::op::v8::Softmax>({m_reshape0}, ov::pass::pattern::consumers_count(1));- const auto m_reshape1 = ov::pass::pattern::wrap_type<ov::op::v1::Reshape>({m_softmax, ov::pass::pattern::wrap_type<ov::op::v0::Constant>()});+ const auto m_reshape1 = ov::pass::pattern::wrap_type<ov::op::v1::Reshape>(+ {m_softmax, ov::pass::pattern::wrap_type<ov::op::v0::Constant>()});- register_matcher(std::make_shared<ov::pass::pattern::Matcher>(m_reshape1, matcher_name),- [=](ov::pass::pattern::Matcher &m) {+ register_matcher(+ std::make_shared<ov::pass::pattern::Matcher>(m_reshape1, matcher_name),+ [=](ov::pass::pattern::Matcher& m) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::op::SoftmaxReshapeElimination")auto& pattern_to_output = m.get_pattern_value_map();auto reshape0 = pattern_to_output[m_reshape0].get_node_shared_ptr();@@ -56,7 +61,8 @@ ov::snippets::pass::SoftmaxReshapeElimination::SoftmaxReshapeElimination() {// Eliminate Reshape before Softmaxreshape0->output(0).replace(reshape0->input_value(0));- copy_runtime_info({reshape0->input_value(0).get_node_shared_ptr(), reshape0->output(0).get_node_shared_ptr()},+ copy_runtime_info(+ {reshape0->input_value(0).get_node_shared_ptr(), reshape0->output(0).get_node_shared_ptr()},reshape0->input_value(0).get_node_shared_ptr());// Eliminate Reshape after Softmax with name savingdiff --git a/src/common/snippets/src/pass/split_dimension_m.cpp b/src/common/snippets/src/pass/split_dimension_m.cppindex 8e9b8454c70..e143782631b 100644--- a/src/common/snippets/src/pass/split_dimension_m.cpp+++ b/src/common/snippets/src/pass/split_dimension_m.cpp@@ -9,8 +9,10 @@namespace {bool is_prime_number(size_t value) {- if (ov::snippets::utils::one_of(value, 2lu, 3lu)) return true;- if (value == 1 || value % 2 == 0 || value % 3 == 0) return false;+ if (ov::snippets::utils::one_of(value, 2lu, 3lu))+ return true;+ 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))@@ -32,9 +34,11 @@ bool SplitDimensionM::is_supported_matmul(const std::shared_ptr<const ov::Node>&return matmul && !matmul->get_transpose_a() && !matmul->is_dynamic();}-std::pair<size_t, size_t> SplitDimensionM::split_ideally(size_t batch_dim, size_t m_dim, size_t optimal_parallelism_work_amount) {- // 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 once+std::pair<size_t, size_t> SplitDimensionM::split_ideally(size_t batch_dim,+ size_t m_dim,+ size_t optimal_parallelism_work_amount) {+ // 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)return std::make_pair(lower_bound, m_dim / lower_bound);@@ -50,20 +54,26 @@ std::pair<size_t, size_t> SplitDimensionM::split_ideally(size_t batch_dim, size_return std::make_pair(1, m_dim);}-std::pair<size_t, size_t> SplitDimensionM::split_fallback_increase_parallel_wa(size_t batch_dim, size_t m_dim, size_t optimal_parallelism_work_amount) {- std::pair<size_t, size_t> splited = { 1, m_dim };+std::pair<size_t, size_t> SplitDimensionM::split_fallback_increase_parallel_wa(size_t batch_dim,+ size_t m_dim,+ size_t optimal_parallelism_work_amount) {+ std::pair<size_t, size_t> splited = {1, m_dim};const 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)- return divisor_0 * batch_dim >= optimal_parallelism_work_amount ? std::make_pair(divisor_0, divisor_1) : splited;+ return divisor_0 * batch_dim >= optimal_parallelism_work_amount ? std::make_pair(divisor_0, divisor_1)+ : splited;}return splited;}-std::pair<size_t, size_t> SplitDimensionM::split_minimize_kernel_wa(size_t batch_dim, size_t m_dim, size_t optimal_parallelism_work_amount) {+std::pair<size_t, size_t> SplitDimensionM::split_minimize_kernel_wa(size_t batch_dim,+ size_t m_dim,+ size_t optimal_parallelism_work_amount) {// This heuristic minimizes 'm_kernel' (=> maximizes 'm_batch') with a limitation that 'm_kernel >= min_kernel_m'.- // In other words, it tries to find 'm_kernel' bigger than 'min_kernel_m' and at the same time as close as possible to this value.+ // In other words, it tries to find 'm_kernel' bigger than 'min_kernel_m' and at the same time as close as possible+ // 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)@@ -74,8 +84,8 @@ std::pair<size_t, size_t> SplitDimensionM::split_minimize_kernel_wa(size_t batchreturn 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 divisors can be more optimal.- // So in this case the best result is remembered+ // However, it is not guaranteed that the current 'm_kernel = m_dim / divisor' is minimized, as one of the next+ // divisors can be more optimal. So in this case the best result is rememberedconst size_t m_kernel = m_dim / divisor;if (m_kernel >= min_kernel_m) {best_result.first = divisor;@@ -110,7 +120,10 @@ std::vector<size_t> SplitDimensionM::get_updated_order(const std::vector<size_t>return new_order;}-ov::snippets::VectorDims SplitDimensionM::reshape_m_dim(ov::snippets::VectorDims shape, size_t m_index, size_t batch_m_dim, size_t new_m_dim) {+ov::snippets::VectorDims SplitDimensionM::reshape_m_dim(ov::snippets::VectorDims shape,+ size_t m_index,+ size_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)return unsqueeze_m_dim(std::move(shape), m_index);@@ -128,14 +141,16 @@ std::shared_ptr<ov::op::v0::MatMul> SplitDimensionM::get_matmul(const std::shareconst auto& body = subgraph->body_ptr();const auto& parameters = body->get_parameters();// [107806]: If count of Parameters isn't equal to Subgraph inputs (it's possible case in general),- // we cannot garantee correct extraction since we don't have correct connections between body I/O and Subgraph I/O.+ // we cannot garantee correct extraction since we don't have correct connections between body I/O and+ // Subgraph I/O.OPENVINO_ASSERT(parameters.size() == subgraph->input_values().size(),"Failed to extract unsupported transposes: the count of Parameters isn't equal to Subgraph inputs");// Need to find MatMul0 and check output shapeconst auto& ops = body->get_ordered_ops();- const 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); });+ const 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())return nullptr;@@ -143,7 +158,10 @@ std::shared_ptr<ov::op::v0::MatMul> SplitDimensionM::get_matmul(const std::sharereturn is_supported_matmul(matmul0) ? ov::as_type_ptr<ov::op::v0::MatMul>(matmul0) : nullptr;}-bool SplitDimensionM::split(const ov::Shape& shape, size_t optimal_parallelism_work_amount, size_t& batch_m_dim, size_t& new_m_dim) {+bool SplitDimensionM::split(const ov::Shape& shape,+ size_t optimal_parallelism_work_amount,+ size_t& batch_m_dim,+ size_t& new_m_dim) {size_t batch_dim = 1;if (shape.size() > 2) {batch_dim = std::accumulate(shape.rbegin() + 2, shape.rend(), batch_dim, std::multiplies<>()); // B (batch)@@ -169,11 +187,15 @@ bool SplitDimensionM::split(const ov::Shape& shape, size_t optimal_parallelism_wreturn true;// If all the previous heuristics failed, fallback heuristic is used, which reflects the old splitting behaviorif (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);+ 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();}-void SplitDimensionM::reshape_subgraph(const std::shared_ptr<op::Subgraph>& subgraph, const ov::Shape& shape, size_t batch_m_dim, size_t new_m_dim) {+void SplitDimensionM::reshape_subgraph(const std::shared_ptr<op::Subgraph>& subgraph,+ const ov::Shape& shape,+ size_t batch_m_dim,+ size_t new_m_dim) {const auto& body = subgraph->body_ptr();const auto& parameters = body->get_parameters();const auto& results = body->get_results();@@ -188,7 +210,8 @@ void SplitDimensionM::reshape_subgraph(const std::shared_ptr<op::Subgraph>& subgauto insert_reshape = [&](const std::shared_ptr<ov::op::v0::Parameter>& param, const ov::Shape& new_shape) {const auto index = std::distance(parameters.begin(), std::find(parameters.begin(), parameters.end(), param));- const auto shape_const = std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{new_shape.size()}, new_shape);+ const auto shape_const =+ std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{new_shape.size()}, new_shape);const auto reshape = std::make_shared<ov::op::v1::Reshape>(subgraph->input_value(index), shape_const, false);subgraph->input(index).replace_source_output(reshape);param->set_partial_shape(new_shape);@@ -199,7 +222,8 @@ void SplitDimensionM::reshape_subgraph(const std::shared_ptr<op::Subgraph>& subgOPENVINO_ASSERT(m_index < shape.size(), "Dimension index must be less than shape rank");const auto current_m_dim = shape[m_index];OPENVINO_ASSERT(!split_m_dim || current_m_dim == 1 || current_m_dim == m_dim, "Incorrect shape for splitting!");- const auto new_shape = split_m_dim ? reshape_m_dim(shape, m_index, batch_m_dim, new_m_dim) : unsqueeze_m_dim(shape, m_index);+ const auto new_shape =+ split_m_dim ? reshape_m_dim(shape, m_index, batch_m_dim, new_m_dim) : unsqueeze_m_dim(shape, m_index);OPENVINO_ASSERT(ov::shape_size(new_shape) == ov::shape_size(shape), "Incorrect shape splitting!");return new_shape;};@@ -209,9 +233,13 @@ void SplitDimensionM::reshape_subgraph(const std::shared_ptr<op::Subgraph>& subgOPENVINO_ASSERT(order_constant != nullptr, "Transpose must have Constant order");const auto order = order_constant->cast_vector<size_t>();const auto forward_index = order.size() - 1 - dim_M_index;- const auto m_index = is_input ? order[forward_index] : forward_index; // Index of M dimension in the previous order+ const auto m_index =+ is_input ? order[forward_index] : forward_index; // Index of M dimension in the previous orderconst auto new_order = get_updated_order(order, m_index);- transpose->set_argument(1, std::make_shared<ov::op::v0::Constant>(order_constant->get_element_type(), ov::Shape{new_order.size()}, new_order));+ transpose->set_argument(1,+ std::make_shared<ov::op::v0::Constant>(order_constant->get_element_type(),+ ov::Shape{new_order.size()},+ new_order));return m_index;};@@ -256,14 +284,18 @@ void SplitDimensionM::reshape_subgraph(const std::shared_ptr<op::Subgraph>& subg} else if (const auto softmax_v8 = ov::as_type_ptr<ov::op::v8::Softmax>(op)) {softmax_v8->set_axis(-1);} else if (const auto softmax_v1 = ov::as_type_ptr<ov::op::v1::Softmax>(op)) {- softmax_v1->set_axis(softmax_v1->get_output_partial_shape(0).size()); // since new_shape.size() = old_shape.size() + 1+ softmax_v1->set_axis(+ softmax_v1->get_output_partial_shape(0).size()); // since new_shape.size() = old_shape.size() + 1} else if (const auto broadcast = ov::as_type_ptr<ov::op::v1::Broadcast>(op)) {// Broadcast is tokenized only between MatMuls -> Split M dimensionconst auto shape_const = ov::as_type_ptr<ov::op::v0::Constant>(broadcast->get_input_node_shared_ptr(1));OPENVINO_ASSERT(shape_const, "SplitDimensionM expects Broadcast with Constant output shape");const auto m_dim_idx = broadcast->get_output_partial_shape(0).size() - 2;const auto new_shape = get_updated_shape(shape_const->cast_vector<size_t>(), m_dim_idx, true);- broadcast->set_argument(1, std::make_shared<ov::op::v0::Constant>(shape_const->get_element_type(), ov::Shape{new_shape.size()}, new_shape));+ broadcast->set_argument(1,+ std::make_shared<ov::op::v0::Constant>(shape_const->get_element_type(),+ ov::Shape{new_shape.size()},+ new_shape));}}@@ -288,7 +320,8 @@ void SplitDimensionM::reshape_subgraph(const std::shared_ptr<op::Subgraph>& subgcontinue;const auto& target_inputs = subgraph->get_output_target_inputs(i);- const auto shape_const = std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{output_shape.size()}, output_shape);+ const auto shape_const =+ std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{output_shape.size()}, output_shape);const auto reshape = std::make_shared<ov::op::v1::Reshape>(subgraph->output(i), shape_const, false);// Save output nameconst auto original_output = body->get_results()[i]->get_input_node_shared_ptr(0);@@ -323,7 +356,9 @@ bool SplitDimensionM::run_on_subgraph(const std::shared_ptr<op::Subgraph>& subgr// 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(); };+ 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))return false;@@ -338,6 +373,6 @@ bool SplitDimensionM::run_on_subgraph(const std::shared_ptr<op::Subgraph>& subgr}return false;}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/pass/subgraph_manager.cpp b/src/common/snippets/src/pass/subgraph_manager.cppindex 860a2b15c35..8a31a117c76 100644--- a/src/common/snippets/src/pass/subgraph_manager.cpp+++ b/src/common/snippets/src/pass/subgraph_manager.cpp@@ -16,6 +16,6 @@ bool CommonOptimizations::SubgraphManager::run_passes(std::shared_ptr<ov::snippereturn updated;}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/pass/tokenization.cpp b/src/common/snippets/src/pass/tokenization.cppindex d3412ae9082..0643939ea00 100644--- a/src/common/snippets/src/pass/tokenization.cpp+++ b/src/common/snippets/src/pass/tokenization.cpp@@ -20,19 +20,19 @@ namespace ov {namespace snippets {namespace pass {-void SetSnippetsNodeType(const std::shared_ptr<Node> &node, SnippetsNodeType nodeType) {+void SetSnippetsNodeType(const std::shared_ptr<Node>& node, SnippetsNodeType nodeType) {auto& rt = node->get_rt_info();rt["SnippetsNodeType"] = nodeType;}-void SetSnippetsSubgraphType(const std::shared_ptr<op::Subgraph> &node, SnippetsSubgraphType nodeType) {+void SetSnippetsSubgraphType(const std::shared_ptr<op::Subgraph>& node, SnippetsSubgraphType nodeType) {if (node) {- auto &rt = node->get_rt_info();+ auto& rt = node->get_rt_info();rt["SnippetsSubgraphType"] = nodeType;}}-SnippetsNodeType GetSnippetsNodeType(const std::shared_ptr<const Node> &node) {+SnippetsNodeType 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 rinfo = rt.find("SnippetsNodeType");@@ -41,24 +41,24 @@ SnippetsNodeType GetSnippetsNodeType(const std::shared_ptr<const Node> &node) {return rinfo->second.as<SnippetsNodeType>();}-SnippetsSubgraphType GetSnippetsSubgraphType(const std::shared_ptr<const op::Subgraph> &node) {+SnippetsSubgraphType GetSnippetsSubgraphType(const std::shared_ptr<const op::Subgraph>& node) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::GetSnippetsSubgraphType")if (!node)return SnippetsSubgraphType::NotSet;- auto &rt = node->get_rt_info();+ auto& rt = node->get_rt_info();const auto rinfo = rt.find("SnippetsSubgraphType");if (rinfo == rt.end())return SnippetsSubgraphType::NotSet;return rinfo->second.as<SnippetsSubgraphType>();}-void SetTopologicalOrder(const std::shared_ptr<Node> &node, int64_t order) {+void SetTopologicalOrder(const std::shared_ptr<Node>& node, int64_t order) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::SetTopologicalOrder")auto& rt = node->get_rt_info();rt["TopologicalOrder"] = order;}-int64_t GetTopologicalOrder(const std::shared_ptr<const Node> &node) {+int64_t GetTopologicalOrder(const std::shared_ptr<const Node>& node) {auto& rt = node->get_rt_info();const auto rinfo = rt.find("TopologicalOrder");if (rinfo == rt.end())@@ -66,7 +66,7 @@ int64_t GetTopologicalOrder(const std::shared_ptr<const Node> &node) {return rinfo->second.as<int64_t>();}-bool EnumerateNodes::run_on_model(const std::shared_ptr<ov::Model> &m) {+bool EnumerateNodes::run_on_model(const std::shared_ptr<ov::Model>& m) {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::EnumerateNodes")int64_t order = 0;// Todo: We don't really have to set order for every node, just for subgraph parents and children would be enough@@ -76,7 +76,6 @@ bool EnumerateNodes::run_on_model(const std::shared_ptr<ov::Model> &m) {return true;}-bool SnippetsTokenization::run_on_model(const std::shared_ptr<ov::Model>& m) {RUN_ON_FUNCTION_SCOPE(SnippetsTokenization);ov::pass::Manager manager(get_pass_config(), "Snippets:Tokenization");@@ -104,6 +103,6 @@ bool SnippetsTokenization::run_on_model(const std::shared_ptr<ov::Model>& m) {return false;}-} // namespace pass-} // namespace snippets-} // namespace ov+} // namespace pass+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/pass/transform_convert.cpp b/src/common/snippets/src/pass/transform_convert.cppindex 6756d85ded2..7ddbb0158e3 100644--- a/src/common/snippets/src/pass/transform_convert.cpp+++ b/src/common/snippets/src/pass/transform_convert.cpp@@ -2,13 +2,12 @@// SPDX-License-Identifier: Apache-2.0//-#include "snippets/itt.hpp"-#include "snippets/pass/transform_convert.hpp"-#include "snippets/snippets_isa.hpp"#include "openvino/core/rt_info.hpp"#include "openvino/pass/pattern/op/wrap_type.hpp"+#include "snippets/itt.hpp"+#include "snippets/snippets_isa.hpp"ov::snippets::pass::TransformConvertToConvertTruncation::TransformConvertToConvertTruncation() {MATCHER_SCOPE(TransformConvertToConvertTruncation);@@ -19,9 +18,11 @@ ov::snippets::pass::TransformConvertToConvertTruncation::TransformConvertToConve!ov::is_type_any_of<op::ConvertTruncation, op::ConvertSaturation>(n);});- register_matcher(std::make_shared<ov::pass::pattern::Matcher>(- ov::pass::pattern::wrap_type<ov::opset1::Convert>(), matcher_name), [](ov::pass::pattern::Matcher &m) {- OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::op::TransformConvertToConvertTruncation")+ register_matcher(+ std::make_shared<ov::pass::pattern::Matcher>(ov::pass::pattern::wrap_type<ov::opset1::Convert>(), matcher_name),+ [](ov::pass::pattern::Matcher& m) {+ OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform,+ "Snippets::op::TransformConvertToConvertTruncation")const auto root = m.get_match_root();const auto convert = ov::as_type_ptr<ov::opset1::Convert>(root);OPENVINO_ASSERT(convert, "Convert op is invalid");diff --git a/src/common/snippets/src/pass/transpose_decomposition.cpp b/src/common/snippets/src/pass/transpose_decomposition.cppindex ebee1177065..4fb9af61bd6 100644--- a/src/common/snippets/src/pass/transpose_decomposition.cpp+++ b/src/common/snippets/src/pass/transpose_decomposition.cpp@@ -4,10 +4,10 @@#include "snippets/pass/transpose_decomposition.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 "openvino/pass/pattern/op/wrap_type.hpp"+#include "snippets/snippets_isa.hpp"#include "transformations/utils/utils.hpp"namespace ov {@@ -36,8 +36,8 @@ TransposeDecomposition::TransposeDecomposition() {MATCHER_SCOPE(TransposeDecomposition);// Todo: we need a special transformation that detects and propagates data access pattern to Parameters and Results// this is needed to communicate access pattern to the plugin node and op::Kernel- // This is the reason we match only to Parameter, this limitation could be relaxed if we propagate access pattern- // to the appropriate parameter+ // This is the reason we match only to Parameter, this limitation could be relaxed if we propagate access+ // pattern to the appropriate parameterauto match_data = ov::pass::pattern::wrap_type<ov::op::v0::Parameter>();auto match_order = ov::pass::pattern::wrap_type<ov::op::v0::Constant>();auto match_transpose = ov::pass::pattern::wrap_type<ov::opset1::Transpose>({match_data, match_order});@@ -46,9 +46,11 @@ TransposeDecomposition::TransposeDecomposition() {OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::op::TransposeDecomposition")auto& pattern_to_output = m.get_pattern_value_map();const auto& data_input = pattern_to_output.at(match_data);- const auto transpose = ov::as_type_ptr<ov::opset1::Transpose>(pattern_to_output.at(match_transpose).get_node_shared_ptr());+ const auto transpose =+ ov::as_type_ptr<ov::opset1::Transpose>(pattern_to_output.at(match_transpose).get_node_shared_ptr());- const auto order = ov::as_type_ptr<ov::op::v0::Constant>(pattern_to_output.at(match_order).get_node_shared_ptr());+ 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))return false;@@ -56,7 +58,8 @@ TransposeDecomposition::TransposeDecomposition() {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+ // number of elements that can be processed on every iteration. For 0,1,2,3 -> 0,2,3,1 we can guarantee only+ // scalar accessconst auto subtensor = std::vector<size_t>{1};const auto& layout = order->cast_vector<size_t>();diff --git a/src/common/snippets/src/pass/validate.cpp b/src/common/snippets/src/pass/validate.cppindex 7f325c9343e..65489c41f38 100644--- a/src/common/snippets/src/pass/validate.cpp+++ b/src/common/snippets/src/pass/validate.cpp@@ -2,6 +2,8 @@// SPDX-License-Identifier: Apache-2.0//+#include "snippets/pass/validate.hpp"+#include "openvino/core/validation_util.hpp"#include "openvino/op/broadcast.hpp"#include "openvino/op/fake_quantize.hpp"@@ -14,7 +16,6 @@#include "snippets/op/convert_truncation.hpp"#include "snippets/pass/explicit_transpose_matmul_inputs.hpp"#include "snippets/pass/fq_decomposition.hpp"-#include "snippets/pass/validate.hpp"#include "snippets/utils/utils.hpp"namespace ov {@@ -22,13 +23,14 @@ namespace snippets {namespace 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+} // namespacebool Validate::is_supported_constant(const std::shared_ptr<const ov::Node>& op) {const auto constant = ov::as_type_ptr<const ov::op::v0::Constant>(op);diff --git a/src/common/snippets/src/runtime_configurator.cpp b/src/common/snippets/src/runtime_configurator.cppindex 139f4e40358..f6ced32c674 100644--- a/src/common/snippets/src/runtime_configurator.cpp+++ b/src/common/snippets/src/runtime_configurator.cpp@@ -24,23 +24,25 @@ using namespace ov::snippets::lowered::pass;#ifdef SNIPPETS_DEBUG_CAPSstd::string RuntimeConfig::to_string() const {std::stringstream out;- out << " ========== RuntimeConfig state ==========\n" <<- "tensor_rank: " << tensor_rank << "\n" <<- "tile_rank: " << tile_rank << "\n" <<- "master_shape: " << ov::Shape(master_shape) << "\n";- out << "io_data_offsets: " << "\n";+ out << " ========== RuntimeConfig state ==========\n"+ << "tensor_rank: " << tensor_rank << "\n"+ << "tile_rank: " << tile_rank << "\n"+ << "master_shape: " << ov::Shape(master_shape) << "\n";+ out << "io_data_offsets: "+ << "\n";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";+ out << "buffer_cluster_offsets: "+ << "\n";for (size_t i = 0; i < buffer_cluster_offsets.size(); ++i)- out << "\t[" << i << "]" << buffer_cluster_offsets[i] << "\n";+ out << "buffer_cluster_offsets: "+ << "\n";return out.str();}#endif-RuntimeConfigurator::RuntimeConfigurator(std::shared_ptr<RuntimeConfig> c)- : m_config(std::move(c)) {+RuntimeConfigurator::RuntimeConfigurator(std::shared_ptr<RuntimeConfig> c) : m_config(std::move(c)) {OPENVINO_ASSERT(m_config, "Runtime config is nullptr!");}@@ -120,14 +122,15 @@ void RuntimeConfigurator::init_data_info(const lowered::LinearIRCPtr& linear_ir)const auto& shape_infer_seq = utils::get_first_child_shape_infer_expr_seq(param);ExpressionPtr mem_desc_expr = param;if (!shape_infer_seq.empty()) {- // [160048] Reorder, as any another ShapeInferOp, should just propagate input shape to output using target order+ // [160048] Reorder, as any another ShapeInferOp, should just propagate input shape to output using target+ // order// without data movement. However, currently we have to save desc of input of the Reorder// to support correct input data offsets calculations and MHAParallelWAOptimizer pass work.// Please, remove this code part when the mentioned ticket is completed.- const auto& reorder_it = std::find_if(shape_infer_seq.cbegin(), shape_infer_seq.cend(),- [](const ExpressionPtr& expr) {- return ov::is_type<op::Reorder>(expr->get_node());- });+ const auto& reorder_it =+ std::find_if(shape_infer_seq.cbegin(), shape_infer_seq.cend(), [](const ExpressionPtr& expr) {+ return ov::is_type<op::Reorder>(expr->get_node());+ });if (reorder_it != shape_infer_seq.cend()) {const auto& reorder = *reorder_it;const auto& etype = reorder->get_node()->get_output_element_type(0);@@ -140,7 +143,8 @@ void RuntimeConfigurator::init_data_info(const lowered::LinearIRCPtr& linear_ir)auto consumer_inputs = mem_desc_expr->get_output_port_connector(0)->get_consumers();for (const auto& child_input : consumer_inputs) {- const auto ma = std::dynamic_pointer_cast<snippets::modifier::MemoryAccess>(child_input.get_expr()->get_node());+ const auto ma =+ std::dynamic_pointer_cast<snippets::modifier::MemoryAccess>(child_input.get_expr()->get_node());if (ma && ma->is_memory_access_input_port(child_input.get_index())) {desc = child_input.get_descriptor_ptr();break;@@ -166,7 +170,8 @@ void RuntimeConfigurator::init_buffer_info(const lowered::LinearIRCPtr& linear_i// All needed checks are in Validate passconst auto& buffer_expressions = linear_ir->get_buffers();for (const auto& buffer_expr : buffer_expressions) {- // TODO [143395] : MemoryManager should provide exact containers with needed buffers (static or dynamic) without any `is_defined()`+ // TODO [143395] : MemoryManager should provide exact containers with needed buffers (static or dynamic) without+ // any `is_defined()`auto& clusters = buffer_expr->is_defined() ? static_buffer_clusters : dynamic_buffer_clusters;clusters[buffer_expr->get_cluster_id()].insert(buffer_expr);}@@ -191,7 +196,8 @@ void RuntimeConfigurator::update_expanded_loop_info(const lowered::ExpandedLoopILoopInfoRuntimeParamsMap& initialized_info) {const auto& current_unified_loop_info = expanded_loop_info->get_unified_loop_info();- OPENVINO_ASSERT(initialized_info.count(current_unified_loop_info) > 0, "UnifiedLoopInfo must be updated before ExpandedLoopInfo");+ OPENVINO_ASSERT(initialized_info.count(current_unified_loop_info) > 0,+ "UnifiedLoopInfo must be updated before ExpandedLoopInfo");auto& cur_initialized_info = initialized_info.at(current_unified_loop_info);auto& current_work_amount = cur_initialized_info.work_amount;const auto& ptr_increments = cur_initialized_info.ptr_increments;@@ -200,7 +206,9 @@ void RuntimeConfigurator::update_expanded_loop_info(const lowered::ExpandedLoopIconst auto& decomposed_loop_type = expanded_loop_info->get_type();// If the specific iteration is not needed, we skip loop evaluation - set zero as work amount is enough- if (!lowered::pass::InsertSpecificIterations::is_decomposed_loop_needed(current_unified_loop_info, decomposed_loop_type, current_work_amount)) {+ if (!lowered::pass::InsertSpecificIterations::is_decomposed_loop_needed(current_unified_loop_info,+ decomposed_loop_type,+ current_work_amount)) {expanded_loop_info->set_work_amount(0);if (expanded_loop_info->is_evaluate_once())expanded_loop_info->set_increment(0);@@ -208,13 +216,16 @@ void RuntimeConfigurator::update_expanded_loop_info(const lowered::ExpandedLoopI}const auto work_amount =- lowered::pass::InsertSpecificIterations::get_decomposed_loop_work_amount(current_unified_loop_info, decomposed_loop_type, current_work_amount);+ lowered::pass::InsertSpecificIterations::get_decomposed_loop_work_amount(current_unified_loop_info,+ decomposed_loop_type,+ current_work_amount);expanded_loop_info->set_work_amount(work_amount);// Update remaining Loop work amountcurrent_work_amount -= work_amount;// Update only `finalization offsets`. `Ptr increments` are always zeroed in this case- auto updated_finalization_offsets = current_work_amount > 0 ? std::vector<int64_t>(finalization_offsets.size(), 0) : finalization_offsets;+ auto updated_finalization_offsets =+ current_work_amount > 0 ? std::vector<int64_t>(finalization_offsets.size(), 0) : finalization_offsets;if (expanded_loop_info->is_evaluate_once()) {expanded_loop_info->set_increment(work_amount);// work_amount is equal to increment in cases with `evaluate_once`@@ -251,12 +262,14 @@ void RuntimeConfigurator::update_loop_info(const lowered::LinearIRCPtr& linear_ivoid RuntimeConfigurator::update_buffer_scratchpad_size(const lowered::LinearIRCPtr& linear_ir) const {const auto& loop_manager = linear_ir->get_loop_manager();// Align initial buffer scratchpad size with cache line size- m_config->buffer_scratchpad_size = utils::rnd_up(linear_ir->get_static_buffer_scratchpad_size(), lowered::pass::SolveBufferMemory::byte_alignment);+ m_config->buffer_scratchpad_size =+ utils::rnd_up(linear_ir->get_static_buffer_scratchpad_size(), lowered::pass::SolveBufferMemory::byte_alignment);auto is_not_executed = [&loop_manager](const lowered::ExpressionPtr& buffer_expr) {const auto& loop_ids = buffer_expr->get_loop_ids();- return std::any_of(loop_ids.cbegin(), loop_ids.cend(),- [&loop_manager](size_t loop_id) { return loop_manager->get_loop_info(loop_id)->get_work_amount() == 0; });+ return std::any_of(loop_ids.cbegin(), loop_ids.cend(), [&loop_manager](size_t loop_id) {+ return loop_manager->get_loop_info(loop_id)->get_work_amount() == 0;+ });};for (const auto& p : m_dynamic_buffer_clusters) {@@ -268,13 +281,15 @@ void RuntimeConfigurator::update_buffer_scratchpad_size(const lowered::LinearIRCsize_t additional_size = 0;for (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+ // No need to calculate allocation size of Buffers which are in Loops with `work_amount = 0` - they won't be+ // executedif (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!");- additional_size = std::max(allocation_size * buffer_expr->get_node()->get_element_type().size(), additional_size);+ additional_size =+ std::max(allocation_size * buffer_expr->get_node()->get_element_type().size(), additional_size);}// Align with cache line size. The experiments shows that it affects performance.@@ -285,7 +300,8 @@ void RuntimeConfigurator::update_buffer_scratchpad_size(const lowered::LinearIRCm_config->buffer_scratchpad_size += additional_size;}- OPENVINO_ASSERT(!utils::is_dynamic_value(m_config->buffer_scratchpad_size), "Buffer scratchpad size must be defined!");+ OPENVINO_ASSERT(!utils::is_dynamic_value(m_config->buffer_scratchpad_size),+ "Buffer scratchpad size must be defined!");}void RuntimeConfigurator::update_data_offsets() const {@@ -350,7 +366,8 @@ void RuntimeConfigurator::set_kernel_executor_table(std::shared_ptr<KernelExecutm_config->kernel_executor_table = std::move(table);}-RuntimeConfigurator::UnifiedLoopInfoRtParams RuntimeConfigurator::get_loop_runtime_params(const lowered::UnifiedLoopInfoPtr& loop_info) {+RuntimeConfigurator::UnifiedLoopInfoRtParams RuntimeConfigurator::get_loop_runtime_params(+ const lowered::UnifiedLoopInfoPtr& loop_info) {RuntimeConfigurator::UnifiedLoopInfoRtParams rt_params;rt_params.work_amount = loop_info->get_work_amount();const auto count = loop_info->get_input_count() + loop_info->get_output_count();@@ -358,13 +375,12 @@ RuntimeConfigurator::UnifiedLoopInfoRtParams RuntimeConfigurator::get_loop_runtirt_params.finalization_offsets.resize(count);size_t idx = 0;- loop_info->iterate_through_descs(- [&rt_params, &idx](const lowered::UnifiedLoopInfo::LoopPortDesc& desc) {- rt_params.ptr_increments[idx] = desc.ptr_increment;- rt_params.finalization_offsets[idx] = desc.finalization_offset;- ++idx;- });+ loop_info->iterate_through_descs([&rt_params, &idx](const lowered::UnifiedLoopInfo::LoopPortDesc& desc) {+ rt_params.ptr_increments[idx] = desc.ptr_increment;+ rt_params.finalization_offsets[idx] = desc.finalization_offset;+ ++idx;+ });return rt_params;}-} // namespace snippets-} // namespace ov+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/shape_inference/shape_infer_instances.cpp b/src/common/snippets/src/shape_inference/shape_infer_instances.cppindex 5249d64e0da..a52ba87b887 100644--- a/src/common/snippets/src/shape_inference/shape_infer_instances.cpp+++ b/src/common/snippets/src/shape_inference/shape_infer_instances.cpp@@ -2,9 +2,10 @@// SPDX-License-Identifier: Apache-2.0//#include "snippets/shape_inference/shape_infer_instances.hpp"++#include "openvino/op/select.hpp"#include "snippets/snippets_isa.hpp"#include "snippets/utils/utils.hpp"-#include "openvino/op/select.hpp"namespace ov {namespace snippets {using Result = IShapeInferSnippets::Result;@@ -16,41 +17,41 @@ bool broadcast_merge_into(VectorDims& dst, const VectorDims& src, const ov::op::const auto dst_rank = static_cast<int64_t>(dst.size());const auto src_rank = static_cast<int64_t>(src.size());switch (autob.m_type) {- case ov::op::AutoBroadcastType::NONE:- return true;- case ov::op::AutoBroadcastType::NUMPY: {- const auto new_rank = std::max(dst_rank, src_rank);- VectorDims dims(new_rank);- bool success = true;- for (int64_t i = 0; i < new_rank; i++) {- auto dsti = i < (new_rank - dst_rank) ? 1 : dst[i - (new_rank - dst_rank)];- auto srci = i < (new_rank - src_rank) ? 1 : src[i - (new_rank - src_rank)];- success &= utils::broadcast_merge_dim(dims[i], dsti, srci);- }- dst = std::move(dims);- return success;+ case ov::op::AutoBroadcastType::NONE:+ return true;+ case ov::op::AutoBroadcastType::NUMPY: {+ const auto new_rank = std::max(dst_rank, src_rank);+ VectorDims dims(new_rank);+ bool success = true;+ for (int64_t i = 0; i < new_rank; i++) {+ auto dsti = i < (new_rank - dst_rank) ? 1 : dst[i - (new_rank - dst_rank)];+ auto srci = i < (new_rank - src_rank) ? 1 : src[i - (new_rank - src_rank)];+ success &= utils::broadcast_merge_dim(dims[i], dsti, srci);}- case ov::op::AutoBroadcastType::PDPD: {- int64_t axis = autob.m_axis;- if (src_rank > dst_rank || axis < -1)- return false;-- axis = (axis == -1) ? (dst_rank - src_rank) : axis;- 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])- return false;- }- success &= utils::broadcast_merge_dim(dst[axis + i], dst[axis + i], src[i]);+ dst = std::move(dims);+ return success;+ }+ case ov::op::AutoBroadcastType::PDPD: {+ int64_t axis = autob.m_axis;+ if (src_rank > dst_rank || axis < -1)+ return false;++ axis = (axis == -1) ? (dst_rank - src_rank) : axis;+ 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])+ return false;}- return success;+ success &= utils::broadcast_merge_dim(dst[axis + i], dst[axis + i], src[i]);}- default:- OPENVINO_THROW("Unsupported auto broadcast type: ", autob.m_type);+ return success;+ }+ default:+ OPENVINO_THROW("Unsupported auto broadcast type: ", autob.m_type);}return false;}@@ -78,26 +79,30 @@ bool merge_into(VectorDims& dst, const VectorDims& src) {}Result NumpyBroadcastShapeInfer::infer(const std::vector<VectorDimsRef>& input_shapes) {- OPENVINO_ASSERT(!input_shapes.empty(), "No input shapes were provided for NumpyBroadcastShapeInfer");- auto output_shape = input_shapes[0].get();- for (size_t i = 1; i < input_shapes.size(); i++) {- OPENVINO_ASSERT(broadcast_merge_into(output_shape, input_shapes[i], ov::op::AutoBroadcastType::NUMPY),- "Failed to broadcast-merge input shapes in NumpyBroadcastShapeInfer");- }- return {{std::move(output_shape)}, ShapeInferStatus::success};+ OPENVINO_ASSERT(!input_shapes.empty(), "No input shapes were provided for NumpyBroadcastShapeInfer");+ auto output_shape = input_shapes[0].get();+ for (size_t i = 1; i < input_shapes.size(); i++) {+ OPENVINO_ASSERT(broadcast_merge_into(output_shape, input_shapes[i], ov::op::AutoBroadcastType::NUMPY),+ "Failed to broadcast-merge input shapes in NumpyBroadcastShapeInfer");+ }+ return {{std::move(output_shape)}, ShapeInferStatus::success};}-template<class BroadcastOP>+template <class BroadcastOP>BroadcastShapeInfer<BroadcastOP>::BroadcastShapeInfer(const std::shared_ptr<Node>& n) {- static_assert(std::is_base_of<snippets::op::BroadcastMove, BroadcastOP>() ||+ 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 ", typeid(BroadcastOP).name(), "got ", n->get_type_name());+ "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 ",+ typeid(BroadcastOP).name(),+ "got ",+ n->get_type_name());}-template<class BroadcastOP>+template <class BroadcastOP>Result BroadcastShapeInfer<BroadcastOP>::infer(const std::vector<VectorDimsRef>& input_shapes) {auto out_shape = input_shapes[0].get();const auto& bcasted_dim = broadcast_op->get_bcast_dimension();@@ -200,8 +205,12 @@ Result BrgemmShapeInfer::infer(const std::vector<VectorDimsRef>& input_shapes) {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]))- OPENVINO_THROW("Incompatible MatMul batch dimension. Can't merge dim ", arg0_shape_tmp[i],- " with dim ", arg1_shape_tmp[i], " at index=", 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@@ -230,5 +239,5 @@ Result ReduceShapeInfer::infer(const std::vector<VectorDimsRef>& input_shapes) {return {{result_shape}, ShapeInferStatus::success};}-} // namespace snippets-} // namespace ov+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/shape_inference/shape_inference.cpp b/src/common/snippets/src/shape_inference/shape_inference.cppindex 0ed5d094a6f..b0c2e5382ca 100644--- a/src/common/snippets/src/shape_inference/shape_inference.cpp+++ b/src/common/snippets/src/shape_inference/shape_inference.cpp@@ -2,15 +2,17 @@// SPDX-License-Identifier: Apache-2.0//#include "snippets/shape_inference/shape_inference.hpp"-#include "snippets/shape_inference/shape_infer_instances.hpp"-#include <openvino/op/util/unary_elementwise_arithmetic.hpp>++#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/parameter.hpp>-#include <openvino/op/result.hpp>+#include <openvino/op/util/unary_elementwise_arithmetic.hpp>#include <snippets/snippets_isa.hpp>+#include "snippets/shape_inference/shape_infer_instances.hpp"+namespace ov {namespace snippets {using ShapeInferPtr = IShapeInferSnippetsFactory::ShapeInferPtr;@@ -27,52 +29,64 @@ ShapeInferPtr IShapeInferSnippetsFactory::get_specific_op_shape_infer(const ov::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_OP_SPECIFIC(OP) \- { OP::get_type_info_static(), [](const std::shared_ptr<ov::Node>& n) { return std::make_shared<OP::ShapeInfer>(n);} }-#define SHAPE_INFER_OP_SPECIFIC_EXTERNAL(OP, InferType) \- { OP::get_type_info_static(), [](const std::shared_ptr<ov::Node>& n) { return std::make_shared<InferType>(n);} }+#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_OP_SPECIFIC(OP) \+ { \+ OP::get_type_info_static(), [](const std::shared_ptr<ov::Node>& n) { \+ return std::make_shared<OP::ShapeInfer>(n); \+ } \+ }+#define SHAPE_INFER_OP_SPECIFIC_EXTERNAL(OP, InferType) \+ { \+ OP::get_type_info_static(), [](const std::shared_ptr<ov::Node>& n) { \+ return std::make_shared<InferType>(n); \+ } \+ }-const IShapeInferSnippetsFactory::TRegistry IShapeInferSnippetsFactory::registry {- SHAPE_INFER_PREDEFINED(op::ConvertTruncation, PassThroughShapeInfer),- SHAPE_INFER_PREDEFINED(op::ConvertSaturation, PassThroughShapeInfer),- SHAPE_INFER_PREDEFINED(op::Load, PassThroughShapeInfer),- SHAPE_INFER_PREDEFINED(op::Store, PassThroughShapeInfer),- SHAPE_INFER_PREDEFINED(op::Fill, PassThroughShapeInfer),- SHAPE_INFER_PREDEFINED(ov::op::v0::Parameter, PassThroughShapeInfer),- SHAPE_INFER_PREDEFINED(ov::op::v1::LogicalNot, PassThroughShapeInfer),- SHAPE_INFER_PREDEFINED(ov::op::v0::PRelu, PassThroughShapeInfer),- SHAPE_INFER_PREDEFINED(op::HorizonMax, HorizonOpShapeInfer),- SHAPE_INFER_PREDEFINED(op::HorizonSum, HorizonOpShapeInfer),- //- SHAPE_INFER_PREDEFINED(op::Scalar, SingleElementShapeInfer),- SHAPE_INFER_PREDEFINED(op::VectorBuffer, SingleElementShapeInfer),- SHAPE_INFER_PREDEFINED(op::LoopBegin, SingleElementShapeInfer),- SHAPE_INFER_PREDEFINED(op::LoopEnd, EmptyShapeInfer),- SHAPE_INFER_OP_SPECIFIC(op::RegSpillBegin),- SHAPE_INFER_PREDEFINED(op::RegSpillEnd, EmptyShapeInfer),+const IShapeInferSnippetsFactory::TRegistry IShapeInferSnippetsFactory::registry{+ SHAPE_INFER_PREDEFINED(op::ConvertTruncation, PassThroughShapeInfer),+ SHAPE_INFER_PREDEFINED(op::ConvertSaturation, PassThroughShapeInfer),+ SHAPE_INFER_PREDEFINED(op::Load, PassThroughShapeInfer),+ SHAPE_INFER_PREDEFINED(op::Store, PassThroughShapeInfer),+ SHAPE_INFER_PREDEFINED(op::Fill, PassThroughShapeInfer),+ SHAPE_INFER_PREDEFINED(ov::op::v0::Parameter, PassThroughShapeInfer),+ SHAPE_INFER_PREDEFINED(ov::op::v1::LogicalNot, PassThroughShapeInfer),+ SHAPE_INFER_PREDEFINED(ov::op::v0::PRelu, PassThroughShapeInfer),+ SHAPE_INFER_PREDEFINED(op::HorizonMax, HorizonOpShapeInfer),+ SHAPE_INFER_PREDEFINED(op::HorizonSum, HorizonOpShapeInfer),+ //+ SHAPE_INFER_PREDEFINED(op::Scalar, SingleElementShapeInfer),+ SHAPE_INFER_PREDEFINED(op::VectorBuffer, SingleElementShapeInfer),+ SHAPE_INFER_PREDEFINED(op::LoopBegin, SingleElementShapeInfer),+ SHAPE_INFER_PREDEFINED(op::LoopEnd, EmptyShapeInfer),+ SHAPE_INFER_OP_SPECIFIC(op::RegSpillBegin),+ SHAPE_INFER_PREDEFINED(op::RegSpillEnd, EmptyShapeInfer),#ifdef SNIPPETS_DEBUG_CAPS- SHAPE_INFER_PREDEFINED(op::PerfCountBegin, EmptyShapeInfer),- SHAPE_INFER_PREDEFINED(op::PerfCountEnd, EmptyShapeInfer),+ SHAPE_INFER_PREDEFINED(op::PerfCountBegin, EmptyShapeInfer),+ SHAPE_INFER_PREDEFINED(op::PerfCountEnd, EmptyShapeInfer),#endif- SHAPE_INFER_PREDEFINED(op::KernelStatic, EmptyShapeInfer),- SHAPE_INFER_PREDEFINED(op::KernelDynamic, EmptyShapeInfer),- SHAPE_INFER_PREDEFINED(op::Nop, EmptyShapeInfer),- SHAPE_INFER_OP_SPECIFIC_EXTERNAL(opset1::Select, SelectShapeInfer),- SHAPE_INFER_OP_SPECIFIC_EXTERNAL(op::Brgemm, BrgemmShapeInfer),- SHAPE_INFER_OP_SPECIFIC_EXTERNAL(op::ReduceMax, ReduceShapeInfer),- SHAPE_INFER_OP_SPECIFIC_EXTERNAL(op::ReduceSum, ReduceShapeInfer),- // Note that Result has no output PortConnectors, so the shape must be empty- SHAPE_INFER_PREDEFINED(ov::op::v0::Result, EmptyShapeInfer),- //- SHAPE_INFER_OP_SPECIFIC(op::LoadReorder),- SHAPE_INFER_OP_SPECIFIC(op::Reshape),- SHAPE_INFER_OP_SPECIFIC(op::Reorder),- SHAPE_INFER_OP_SPECIFIC(op::RankNormalization),- SHAPE_INFER_OP_SPECIFIC(op::BroadcastLoad),- SHAPE_INFER_OP_SPECIFIC(op::BroadcastMove),- SHAPE_INFER_OP_SPECIFIC(op::Buffer),+ SHAPE_INFER_PREDEFINED(op::KernelStatic, EmptyShapeInfer),+ SHAPE_INFER_PREDEFINED(op::KernelDynamic, EmptyShapeInfer),+ SHAPE_INFER_PREDEFINED(op::Nop, EmptyShapeInfer),+ SHAPE_INFER_OP_SPECIFIC_EXTERNAL(opset1::Select, SelectShapeInfer),+ SHAPE_INFER_OP_SPECIFIC_EXTERNAL(op::Brgemm, BrgemmShapeInfer),+ SHAPE_INFER_OP_SPECIFIC_EXTERNAL(op::ReduceMax, ReduceShapeInfer),+ SHAPE_INFER_OP_SPECIFIC_EXTERNAL(op::ReduceSum, ReduceShapeInfer),+ // Note that Result has no output PortConnectors, so the shape must be empty+ SHAPE_INFER_PREDEFINED(ov::op::v0::Result, EmptyShapeInfer),+ //+ SHAPE_INFER_OP_SPECIFIC(op::LoadReorder),+ SHAPE_INFER_OP_SPECIFIC(op::Reshape),+ SHAPE_INFER_OP_SPECIFIC(op::Reorder),+ SHAPE_INFER_OP_SPECIFIC(op::RankNormalization),+ SHAPE_INFER_OP_SPECIFIC(op::BroadcastLoad),+ SHAPE_INFER_OP_SPECIFIC(op::BroadcastMove),+ SHAPE_INFER_OP_SPECIFIC(op::Buffer),};#undef SHAPE_INFER_OP_SPECIFIC_EXTERNAL#undef SHAPE_INFER_OP_SPECIFIC@@ -91,9 +105,10 @@ std::shared_ptr<IShapeInferSnippets> make_shape_inference(const std::shared_ptr<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 snippets+} // namespace ovdiff --git a/src/common/snippets/src/utils/debug_caps_config.cpp b/src/common/snippets/src/utils/debug_caps_config.cppindex e354c362a51..da4ae4238a5 100644--- a/src/common/snippets/src/utils/debug_caps_config.cpp+++ b/src/common/snippets/src/utils/debug_caps_config.cpp@@ -3,7 +3,7 @@//#ifdef SNIPPETS_DEBUG_CAPS-#include "snippets/utils/debug_caps_config.hpp"+# include "snippets/utils/debug_caps_config.hpp"namespace ov {namespace snippets {@@ -73,4 +73,4 @@ void DebugCapsConfig::PropertyGroup::parseAndSet(const std::string& str) {} // namespace snippets} // namespace ov-#endif // SNIPPETS_DEBUG_CAPS+#endif // SNIPPETS_DEBUG_CAPSdiff --git a/src/common/snippets/src/utils/loop_utils.cpp b/src/common/snippets/src/utils/loop_utils.cppindex 92e82930c0b..9f1159be246 100644--- a/src/common/snippets/src/utils/loop_utils.cpp+++ b/src/common/snippets/src/utils/loop_utils.cpp@@ -52,7 +52,8 @@ inline void init_work_amount(const LoopInfoPtr& loop_info) {const auto& shape = desc->get_shape();const auto& layout = desc->get_layout();const auto is_input = loop_port.get_expr_port()->get_type() == ExpressionPort::Input;- const auto dim_idx = is_input ? get_input_dim_idx(layout, loop_port.get_dim_idx()) : get_output_dim_idx(layout, loop_port.get_dim_idx());+ const auto dim_idx = is_input ? get_input_dim_idx(layout, loop_port.get_dim_idx())+ : get_output_dim_idx(layout, loop_port.get_dim_idx());OPENVINO_ASSERT(broadcast_merge_dim(work_amount, work_amount, shape[dim_idx]),"Failed to broadcast work_amount");}@@ -67,9 +68,12 @@ void update_data_pointer_shifts(const UnifiedLoopInfoPtr& loop_info) {const auto input_count = loop_info->get_input_count();const auto output_count = loop_info->get_output_count();- auto update_shifts = [&work_amount, &input_count, &output_count](LoopPort& loop_port, UnifiedLoopInfo::LoopPortDesc& ptr_shifts_params) {- ptr_shifts_params.ptr_increment = get_ptr_increment(loop_port, work_amount,- loop_port.get_expr_port()->get_type() == ExpressionPort::Input ? input_count : output_count);+ auto update_shifts = [&work_amount, &input_count, &output_count](LoopPort& loop_port,+ UnifiedLoopInfo::LoopPortDesc& ptr_shifts_params) {+ ptr_shifts_params.ptr_increment = get_ptr_increment(+ loop_port,+ work_amount,+ loop_port.get_expr_port()->get_type() == ExpressionPort::Input ? input_count : output_count);ptr_shifts_params.finalization_offset = get_finalization_offset(work_amount, ptr_shifts_params.ptr_increment);};loop_info->iterate_through_infos(update_shifts);@@ -84,13 +88,12 @@ void update_runtime_parameters(const UnifiedLoopInfoPtr& loop_info) {bool should_be_loop_port(const ov::snippets::lowered::ExpressionPort& port, size_t loop_id) {const auto& connected_ports = port.get_connected_ports();- return std::any_of(connected_ports.cbegin(), connected_ports.cend(),- [&](const ExpressionPort& connected_port) {- const auto& loops = connected_port.get_expr()->get_loop_ids();- return std::find(loops.cbegin(), loops.cend(), loop_id) == loops.cend();- });+ return std::any_of(connected_ports.cbegin(), connected_ports.cend(), [&](const ExpressionPort& connected_port) {+ const auto& loops = connected_port.get_expr()->get_loop_ids();+ return std::find(loops.cbegin(), loops.cend(), loop_id) == loops.cend();+ });}-} // namespace utils-} // namespace snippets-} // namespace ov\ No newline at end of file+} // namespace utils+} // namespace snippets+} // namespace ov\ No newline at end of filediff --git a/src/common/snippets/src/utils/tokenization_utils.cpp b/src/common/snippets/src/utils/tokenization_utils.cppindex 037c954d356..9e5ace1730d 100644--- a/src/common/snippets/src/utils/tokenization_utils.cpp+++ b/src/common/snippets/src/utils/tokenization_utils.cpp@@ -2,10 +2,11 @@// SPDX-License-Identifier: Apache-2.0//+#include "snippets/utils/tokenization_utils.hpp"+#include <cassert>#include <climits>-#include "snippets/utils/tokenization_utils.hpp"#include "snippets/remarks.hpp"namespace ov {@@ -16,7 +17,7 @@ using namespace ov::snippets::op;using namespace ov::snippets::pass;namespace {-auto has_result_child(const std::shared_ptr<const Node> &node) -> bool {+auto has_result_child(const std::shared_ptr<const Node>& node) -> bool {for (const auto& child : node->get_users()) {if (ov::is_type<ov::opset1::Result>(child)) {return true;@@ -25,7 +26,7 @@ auto has_result_child(const std::shared_ptr<const Node> &node) -> bool {return false;}-auto get_num_result_children(const std::shared_ptr<const Node> &node) -> size_t {+auto get_num_result_children(const std::shared_ptr<const Node>& node) -> size_t {size_t result = 0;for (const auto& child : node->get_users()) {if (ov::is_type<ov::opset1::Result>(child)) {@@ -42,7 +43,9 @@ auto outputs_are_not_broadcastable(const std::shared_ptr<const Node>& node) -> bov::PartialShape ref_shape = outputs.front().get_partial_shape();bool success = true;for (size_t i = 1; i < outputs.size() && success; i++) {- success &= ov::PartialShape::broadcast_merge_into(ref_shape, outputs[i].get_partial_shape(), ov::op::AutoBroadcastType::NUMPY);+ success &= ov::PartialShape::broadcast_merge_into(ref_shape,+ outputs[i].get_partial_shape(),+ ov::op::AutoBroadcastType::NUMPY);}return !success;}@@ -58,7 +61,7 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokenizareturn "";};- auto create_single_node_subgraph = [&](const std::shared_ptr<Node> &node) {+ auto create_single_node_subgraph = [&](const std::shared_ptr<Node>& node) {auto subgraph = op::Subgraph::wrap_node_as_subgraph(node);subgraph->get_rt_info()["originalLayersNames"] = getFusedNames(node) + node->get_friendly_name();ov::replace_node(node, subgraph);@@ -85,22 +88,25 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokenizaauto input_values = node->input_values();/*- * Called with subgraph->input_value(i) arg and used to- * Check that the attached node input subgraph has the same input as the node itself.- * If true, then ternary merge is initiated.- * input- * / \- * subgraph--node- */+ * Called with subgraph->input_value(i) arg and used to+ * Check that the attached node input subgraph has the same input as the node itself.+ * If true, then ternary merge is initiated.+ * input+ * / \+ * subgraph--node+ */auto is_recurrent = [&input_values](const ov::Output<ov::Node>& to_find) -> bool {- return std::any_of(input_values.begin(), input_values.end(),- [&](const ov::Output<ov::Node> &in) {return in == to_find;});+ return std::any_of(input_values.begin(), input_values.end(), [&](const ov::Output<ov::Node>& in) {+ return in == to_find;+ });};/*- * Checks if the passed node introduces loop dependency for given topological bounds (pair of maxParentOrder, minChildOrder).- * The bounds are presumed to be without dependency. The bounds are updated if no dependency is introduced by the node.- */- const auto cyclicDependencyIsIntoduced = [&node](const std::shared_ptr<Node>& nodeToExamine, std::pair<int64_t, int64_t>& currentBounds) -> bool {+ * Checks if the passed node introduces loop dependency for given topological bounds (pair of maxParentOrder,+ * minChildOrder). The bounds are presumed to be without dependency. The bounds are updated if no dependency is+ * introduced by the node.+ */+ const auto cyclicDependencyIsIntoduced = [&node](const std::shared_ptr<Node>& nodeToExamine,+ std::pair<int64_t, int64_t>& currentBounds) -> bool {assert(currentBounds.first < currentBounds.second && "Invalid currentBounds passed");const auto& parentNodes = ov::as_node_vector(nodeToExamine->input_values());const int64_t maxParentOrder =@@ -114,12 +120,14 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokeniza});const auto& childNodes = nodeToExamine->get_users();// Skip the node being attached, since it will be a part of subgraph and can't introduce loop dependency- const 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)- return minOrder;- return std::min(minOrder, GetTopologicalOrder(n));- });+ const 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)+ return minOrder;+ return std::min(minOrder, GetTopologicalOrder(n));+ });if (maxParentOrder < minChildOrder) {currentBounds = std::pair<int64_t, int64_t>(maxParentOrder, minChildOrder);return false;@@ -139,21 +147,20 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokeniza// If there are no input subgraphs no need to go further, just create a new one.if (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;+ remark(1) << "Starting subgraph at: " << node->get_friendly_name() << " with " << node->inputs().size()+ << " inputs and " << node->outputs().size() << " outputs" << std::endl;return true;}std::string subgraph_name = node->get_friendly_name();std::string fusedNames{};size_t num_result_children = 0;- std::pair<int64_t, int64_t> currentTopoBounds {-1, LONG_MAX};+ std::pair<int64_t, int64_t> currentTopoBounds{-1, LONG_MAX};cyclicDependencyIsIntoduced(node, currentTopoBounds);- assert(!cyclicDependencyIsIntoduced(node, currentTopoBounds) && "Cyclic dependency is introduced by the node itself");+ assert(!cyclicDependencyIsIntoduced(node, currentTopoBounds) &&+ "Cyclic dependency is introduced by the node itself");for (const auto& input_value : input_values) {auto input_node = input_value.get_node_shared_ptr();- if (ov::is_type<op::Subgraph>(input_node) &&- !cyclicDependencyIsIntoduced(input_node, currentTopoBounds)) {+ if (ov::is_type<op::Subgraph>(input_node) && !cyclicDependencyIsIntoduced(input_node, currentTopoBounds)) {auto subgraph = std::static_pointer_cast<op::Subgraph>(input_node);if (!input_subgraphs.count(input_node)) {input_subgraphs.insert(input_node);@@ -170,15 +177,15 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokenizaauto f = clones[input_node];const auto& input_body_parameters = f->get_parameters();// Todo:- // Some of the input subgraphs might have common parents, so some of the input_parameters might already be- // in external_inputs and hence in body_parameters. Here we handle this case and remove repeated body_parameters.- // Would it be better to incorporate all inputs first and then remove repeated params.+ // Some of the input subgraphs might have common parents, so some of the input_parameters might already+ // be in external_inputs and hence in body_parameters. Here we handle this case and remove repeated+ // body_parameters. Would it be better to incorporate all inputs first and then remove repeated params.for (size_t i = 0; i < input_body_parameters.size(); ++i) {auto found = std::find(external_inputs.begin(), external_inputs.end(), subgraph->input_value(i));if (found != external_inputs.end()) {// Todo: here we rely on friendly_name uniqueness. Propose a different algorithm.size_t current_input_index = body_parameters.size();- for (size_t p_ind = 0; p_ind < body_parameters.size(); p_ind++) {+ for (size_t p_ind = 0; p_ind < body_parameters.size(); p_ind++) {const auto& p = body_parameters[p_ind];// unite two body parameters from two input subgraphs only if:// 1. two input subgraphs are connected to the same parent node/subgraph,@@ -192,31 +199,36 @@ 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] << std::endl;f->replace_parameter(i, body_parameters[current_input_index]);} else {external_inputs.push_back(subgraph->input_value(i));body_parameters.push_back(input_body_parameters[i]);}} else if (is_recurrent(subgraph->input_value(i))) {- remark(13) << "ternary merge is conducted " << subgraph->input_value(i).get_node_shared_ptr() << std::endl;+ remark(13) << "ternary merge is conducted " << subgraph->input_value(i).get_node_shared_ptr()+ << std::endl;auto internal = input_body_parameters[i];auto internal_consumers = internal->outputs();- if (auto to_replace_with = ov::as_type_ptr<op::Subgraph>(subgraph->get_input_node_shared_ptr(i))) {- // todo: In principle, we can still attach the node to the subgraph if cyclic dependency is introduced during ternary merge.+ if (auto to_replace_with =+ ov::as_type_ptr<op::Subgraph>(subgraph->get_input_node_shared_ptr(i))) {+ // 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))- return abort("Attempt to perform recurrent merge for cyclic-dependent subgraphs. Aborting.");+ 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)];- auto other_body_result = other_body->get_results()[consumer.get_source_output().get_index()];- auto result_producer = other_body_result->input(0).get_source_output();+ for (auto consumer : output.get_target_inputs()) {+ auto other_body = clones[subgraph->get_input_node_shared_ptr(i)];+ auto other_body_result =+ other_body->get_results()[consumer.get_source_output().get_index()];+ auto result_producer = other_body_result->input(0).get_source_output();- consumer.replace_source_output(result_producer.get_node_shared_ptr());- }+ consumer.replace_source_output(result_producer.get_node_shared_ptr());}+ }} else {external_inputs.push_back(subgraph->input_value(i));body_parameters.push_back(input_body_parameters[i]);@@ -228,8 +240,8 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokeniza}}- // this is there stitching happens, get result of a copy of a body of currently processed input and put it to the new inputs- // internal output index == external output index+ // this is there stitching happens, get result of a copy of a body of currently processed input and put it+ // to the new inputs internal output index == external output indexconst auto& input_body = clones[input_node];const size_t source_output_index = input_value.get_index();const auto& source_result = input_body->get_results()[source_output_index];@@ -237,17 +249,19 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokeniza} else {// We need some non-scalar constants inside Subgraph in the following cases:// [*] We have to save explicitly FQ Constants to call ConstantFolding after Tokenization.- // After ConstantFolding we will move remaining non-scalar Constants from body using ConvertConstantsToParameters pass- // [*] We support Transpose with second Constant input (represents order). This Constant will not be scheduled+ // After ConstantFolding we will move remaining non-scalar Constants from body using+ // ConvertConstantsToParameters pass+ // [*] We support Transpose with second Constant input (represents order). This Constant will not be+ // scheduled// and will only be used to decompose Transpose into a proper Load, Store and Loop combination.if (ov::is_type<ov::opset1::Constant>(input_node) &&- (ov::shape_size(input_value.get_shape()) == 1 ||- ov::is_type<ov::op::v0::FakeQuantize>(node) ||- op::Subgraph::constant_input_should_be_inside_body(node))) {+ (ov::shape_size(input_value.get_shape()) == 1 || ov::is_type<ov::op::v0::FakeQuantize>(node) ||+ op::Subgraph::constant_input_should_be_inside_body(node))) {internal_inputs.push_back(input_node->output(0));} else {external_inputs.push_back(input_value);- auto new_parameter = std::make_shared<ov::op::v0::Parameter>(input_value.get_element_type(), input_value.get_partial_shape());+ auto new_parameter = std::make_shared<ov::op::v0::Parameter>(input_value.get_element_type(),+ input_value.get_partial_shape());new_parameter->set_friendly_name(input_node->get_friendly_name());body_parameters.push_back(new_parameter);internal_inputs.push_back(new_parameter->output(0));@@ -263,7 +277,7 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokenizabody_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() << std::endl;if (node->get_output_size() != body_node->get_output_size()) {OPENVINO_THROW("original node outputs size and extracted node outputs size doesn't much");@@ -309,7 +323,7 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokenizaif (first_side_consumer) {auto& 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)));+ input_subgraph_body->get_results()[output.get_index()]->input_value(0)));subgraph_result_inputs.push_back({});first_side_consumer = false;@@ -338,17 +352,18 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokenizaOPENVINO_THROW("body results and node results size mismatch during subgraph collaps");}- // The each data node (Parameter (and non-Scalar Constants), Result, Buffers with the same ID) requires the own unique GPR.- // At the moment, CPU Plugin has limitation for GPR registers: there are 12 available GPRs,- // and one of them must be reserved for runtime parameters, so only 11 can be used during kernel execution.- // This limitation will be resolved once generator supports gprs spills [75622].+ // The each data node (Parameter (and non-Scalar Constants), Result, Buffers with the same ID) requires the own+ // unique GPR. At the moment, CPU Plugin has limitation for GPR registers: there are 12 available GPRs, and one of+ // them must be reserved for runtime parameters, so only 11 can be used during kernel execution. This limitation+ // will be resolved once generator supports gprs spills [75622].// TODO [75567]: move this plugin-specific constraint to the plugin callbackconst auto unique_buffer_count = op::Subgraph::get_estimated_buffer_count(ops_for_buffer_count);const size_t max_data_ptr_count = config.get_data_ptr_gpr_count();if (body_parameters.size() + body_results.size() + hidden_data_count + unique_buffer_count > max_data_ptr_count) {- const std::string message_reset = "new subgraph is created. Impossible to schedule subgraph with " +- std::to_string(body_parameters.size()) + " inputs, " + std::to_string(body_results.size()) + " outputs and " +- std::to_string(hidden_data_count) + " non-scalar constants and " + std::to_string(unique_buffer_count) + "buffers.";+ const std::string message_reset =+ "new subgraph is created. Impossible to schedule subgraph with " + std::to_string(body_parameters.size()) ++ " inputs, " + std::to_string(body_results.size()) + " outputs and " + std::to_string(hidden_data_count) ++ " non-scalar constants and " + std::to_string(unique_buffer_count) + "buffers.";return abort(message_reset);}@@ -386,11 +401,9 @@ bool tokenize_node(const std::shared_ptr<ov::Node>& node, const SnippetsTokenizasubgraph->get_rt_info()["originalLayersNames"] = fusedNames;subgraph->set_virtual_port_count(hidden_data_count);- remark(1) << "Replacement (merge) done for: "- << subgraph->get_friendly_name()- << " with " << subgraph->inputs().size()- << " inputs and " << subgraph->outputs().size()- << " outputs and " << subgraph->body_ptr()->get_ops().size() << " ops total\n";+ remark(1) << "Replacement (merge) done for: " << subgraph->get_friendly_name() << " with "+ << subgraph->inputs().size() << " inputs and " << subgraph->outputs().size() << " outputs and "+ << subgraph->body_ptr()->get_ops().size() << " ops total\n";return true;}@@ -408,24 +421,26 @@ std::shared_ptr<ov::snippets::op::Subgraph> tokenize_ordered_nodes(const ov::Nodconst auto input = node->input(i);const auto parent = input.get_source_output().get_node_shared_ptr();const auto constant = ov::as_type_ptr<ov::op::v0::Constant>(parent);- if (constant && (ov::shape_size(input.get_shape()) == 1 ||- ov::is_type<ov::op::v0::FakeQuantize>(node) ||+ if (constant && (ov::shape_size(input.get_shape()) == 1 || ov::is_type<ov::op::v0::FakeQuantize>(node) ||op::Subgraph::constant_input_should_be_inside_body(node))) {// If Constant has one consumer - target node, we add Constant to body_inputs// If Constant has several consumers, we should check that all these consumers are inside Subgraph body- // and if all of them are inside body, we can explicitly add Constant to the body_inputs, otherwise we should- // make a copy and add copy of Constant to body_inputs- // For example, this case is especially valid for Transposes nodes- // (several Transposes have the same order so there can be the common Constant with this order)+ // and if all of them are inside body, we can explicitly add Constant to the body_inputs, otherwise we+ // should make a copy and add copy of Constant to body_inputs For example, this case is especially valid+ // for Transposes nodes+ // (several Transposes have the same order so there can be the common Constant with this order)if (constant->get_output_target_inputs(0).size() == 1) {body_inputs.push_back(input.get_source_output());} else {const auto constant_consumers = constant->get_output_target_inputs(0);- bool all_consumers_are_inside = std::all_of(constant_consumers.begin(), constant_consumers.end(),- [&ordered_ops](const ov::Input<ov::Node>& input) {- return std::find(ordered_ops.begin(), ordered_ops.end(),- input.get_node()->shared_from_this()) != ordered_ops.end();- });+ bool all_consumers_are_inside =+ std::all_of(constant_consumers.begin(),+ constant_consumers.end(),+ [&ordered_ops](const ov::Input<ov::Node>& input) {+ return std::find(ordered_ops.begin(),+ ordered_ops.end(),+ input.get_node()->shared_from_this()) != ordered_ops.end();+ });if (all_consumers_are_inside) {body_inputs.push_back(input.get_source_output());} else {@@ -435,7 +450,8 @@ std::shared_ptr<ov::snippets::op::Subgraph> tokenize_ordered_nodes(const ov::Nod}}} else if (std::find(ordered_ops.begin(), ordered_ops.end(), parent) == ordered_ops.end()) {- auto parameter = std::make_shared<ov::opset1::Parameter>(input.get_element_type(), input.get_partial_shape());+ auto parameter =+ std::make_shared<ov::opset1::Parameter>(input.get_element_type(), input.get_partial_shape());body_parameters.push_back(parameter);body_parameters.back()->set_friendly_name(input.get_node()->get_friendly_name());body_inputs.push_back(parameter->output(0));@@ -497,6 +513,6 @@ std::shared_ptr<ov::snippets::op::Subgraph> tokenize_ordered_nodes(const ov::Nodreturn subgraph;}-} // namespace utils-} // namespace snippets-} // namespace ov+} // namespace utils+} // namespace snippets+} // namespace ovdiff --git a/src/common/snippets/src/utils/utils.cpp b/src/common/snippets/src/utils/utils.cppindex e79fffe3542..938098c5317 100644--- a/src/common/snippets/src/utils/utils.cpp+++ b/src/common/snippets/src/utils/utils.cpp@@ -4,17 +4,16 @@#include "snippets/utils/utils.hpp"-#include "snippets/pass/fq_decomposition.hpp"#include "openvino/core/rt_info.hpp"#include "snippets/op/subgraph.hpp"-+#include "snippets/pass/fq_decomposition.hpp"namespace ov {namespace snippets {namespace utils {namespace {-template<typename Shape>+template <typename Shape>void ordered_shape(const Shape& shape, const std::vector<size_t>& layout, bool is_forward, Shape& reordered_shape) {for (size_t i = 0; i < layout.size(); i++) {OPENVINO_ASSERT(layout[i] < shape.size(), "layout index is greater than the shape size");@@ -37,7 +36,9 @@ ov::PartialShape get_pshape(const ov::PartialShape& shape, const std::vector<sizif (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 purposes- if (std::any_of(layout.begin(), layout.end(), [=](size_t x) {return x >= rank;}))+ if (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;@@ -46,18 +47,30 @@ ov::PartialShape get_pshape(const ov::PartialShape& shape, const std::vector<sizauto get_non_scalar_constant_count_for_fq(const std::shared_ptr<ov::op::v0::FakeQuantize>& fq) -> size_t {std::vector<float> cl, ch, isc, ish, osc, osh;- const bool status = ov::snippets::pass::FakeQuantizeDecomposition::getScalesAndShifts(fq, cl, ch, isc, ish, osc, osh);+ const bool status =+ ov::snippets::pass::FakeQuantizeDecomposition::getScalesAndShifts(fq, cl, ch, isc, ish, osc, osh);bool is_optimized = false; // The case when we can calculate only scalesif (status) {- const auto out_scales = ov::snippets::pass::FakeQuantizeDecomposition::calculateScales(fq->get_output_element_type(0), cl, ch, isc, ish, osc, osh);+ const auto out_scales =+ ov::snippets::pass::FakeQuantizeDecomposition::calculateScales(fq->get_output_element_type(0),+ cl,+ ch,+ isc,+ ish,+ osc,+ osh);is_optimized = out_scales.size() != 0;}const bool only_quantized = is_optimized || (status &&- std::all_of(osc.cbegin(), osc.cend(),- [](float val) { return val == 1.f; }) &&- std::all_of(osh.cbegin(), osh.cend(),- [](float val) { return val == 0.f; }));+ std::all_of(osc.cbegin(),+ osc.cend(),+ [](float val) {+ return val == 1.f;+ }) &&+ std::all_of(osh.cbegin(), osh.cend(), [](float val) {+ return val == 0.f;+ }));const bool il = ov::shape_size(fq->input(1).get_shape()) != 1lu;const bool ih = ov::shape_size(fq->input(2).get_shape()) != 1lu;const bool ol = !only_quantized && ov::shape_size(fq->input(3).get_shape()) != 1lu;@@ -129,16 +142,16 @@ VectorDims pshape_to_vdims(const PartialShape& pshape) {result.reserve(pshape.size());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 Snippets- return result.empty() ? VectorDims {1} : result;+ // Note: PartialShape could be empty which designates scalar value. However, Scalars are represented as {1} in+ // Snippets+ return result.empty() ? VectorDims{1} : result;}ov::PartialShape vdims_to_pshape(const VectorDims& vdims) {ov::PartialShape result;result.reserve(vdims.size());for (const auto& v : vdims)- result.push_back(!is_dynamic_value(v) ? Dimension(static_cast<Dimension::value_type>(v))- : Dimension());+ result.push_back(!is_dynamic_value(v) ? Dimension(static_cast<Dimension::value_type>(v)) : Dimension());return result;}@@ -199,19 +212,22 @@ VectorDims get_preordered_vdims(const VectorDims& shape, const std::vector<size_}VectorDims get_planar_vdims(const snippets::lowered::ExpressionPort& expr_port) {- OPENVINO_ASSERT(expr_port.get_type() == snippets::lowered::ExpressionPort::Type::Input, "get_planar_vdims expects Expression Input port");+ OPENVINO_ASSERT(expr_port.get_type() == snippets::lowered::ExpressionPort::Type::Input,+ "get_planar_vdims expects Expression Input port");return get_planar_vdims(expr_port.get_descriptor_ptr()->get_shape(), expr_port.get_descriptor_ptr()->get_layout());}VectorDims get_preordered_vdims(const snippets::lowered::ExpressionPort& expr_port) {- OPENVINO_ASSERT(expr_port.get_type() == snippets::lowered::ExpressionPort::Type::Output, "get_preordered_vdims expects Expression Output port");- return get_preordered_vdims(expr_port.get_descriptor_ptr()->get_shape(), expr_port.get_descriptor_ptr()->get_layout());+ OPENVINO_ASSERT(expr_port.get_type() == snippets::lowered::ExpressionPort::Type::Output,+ "get_preordered_vdims expects Expression Output port");+ return get_preordered_vdims(expr_port.get_descriptor_ptr()->get_shape(),+ expr_port.get_descriptor_ptr()->get_layout());}VectorDims get_projected_subtensor(const snippets::lowered::ExpressionPort& expr_port) {const auto& desc = expr_port.get_descriptor_ptr();const auto& shape = expr_port.get_type() == snippets::lowered::ExpressionPort::Type::Input- ? get_planar_vdims(expr_port)- : get_preordered_vdims(expr_port);+ ? get_planar_vdims(expr_port)+ : get_preordered_vdims(expr_port);auto subtensor = desc->get_subtensor();for (size_t i = 1; i <= std::min(subtensor.size(), shape.size()); i++) {if (auto& dim = subtensor[subtensor.size() - i]; utils::is_full_dim_value(dim)) {@@ -233,7 +249,8 @@ std::vector<lowered::ExpressionPtr> get_first_child_shape_infer_expr_seq(const l};std::vector<lowered::ExpressionPtr> shape_infer_exprs;if (op::Subgraph::is_shape_infer_op(start_expr->get_node())) {- OPENVINO_ASSERT(start_expr->get_input_port_connector(0)->get_consumers().size() == 1, "Shape infer ops are supposed to be the only consumer.");+ OPENVINO_ASSERT(start_expr->get_input_port_connector(0)->get_consumers().size() == 1,+ "Shape infer ops are supposed to be the only consumer.");shape_infer_exprs.push_back(start_expr);}if (start_expr->get_output_count() == 0)@@ -253,7 +270,8 @@ std::vector<lowered::ExpressionPtr> get_first_parent_shape_infer_expr_seq(conststd::vector<lowered::ExpressionPtr> shape_infer_exprs;auto current_exp = start_expr;if (op::Subgraph::is_shape_infer_op(current_exp->get_node())) {- OPENVINO_ASSERT(current_exp->get_input_port_connector(0)->get_consumers().size() == 1, "Shape infer ops are supposed to be the only consumer.");+ OPENVINO_ASSERT(current_exp->get_input_port_connector(0)->get_consumers().size() == 1,+ "Shape infer ops are supposed to be the only consumer.");shape_infer_exprs.push_back(current_exp);}if (current_exp->get_input_count() == 0)@@ -269,13 +287,14 @@ std::vector<lowered::ExpressionPtr> get_first_parent_shape_infer_expr_seq(constfirst_parent = input->get_source().get_expr();if (!ov::is_type<snippets::op::Store>(first_parent->get_node())) {// there are maybe some loopEnd consumers of store as well for loop code gen purpose- OPENVINO_ASSERT(input->get_consumers().size() == 1, "Shape infer ops are supposed to be the only consumer if it doesn't consume a store ops.");+ OPENVINO_ASSERT(input->get_consumers().size() == 1,+ "Shape infer ops are supposed to be the only consumer if it doesn't consume a store ops.");}}return shape_infer_exprs;}-std::shared_ptr<ov::Node> get_leaf_node_of_first_child_shape_infer_seq(const std::shared_ptr<ov::Node>& start_node) {+std::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();@@ -287,7 +306,8 @@ std::shared_ptr<ov::Node> get_leaf_node_of_first_child_shape_infer_seq(const std};std::shared_ptr<ov::Node> leaf_node = nullptr;if (op::Subgraph::is_shape_infer_op(start_node)) {- OPENVINO_ASSERT(start_node->input(0).get_source_output().get_target_inputs().size() == 1, "Shape infer ops are supposed to be the only consumer.");+ OPENVINO_ASSERT(start_node->input(0).get_source_output().get_target_inputs().size() == 1,+ "Shape infer ops are supposed to be the only consumer.");leaf_node = start_node;}if (start_node->get_output_size() == 0)@@ -306,14 +326,16 @@ std::shared_ptr<ov::Node> get_leaf_node_of_first_child_shape_infer_seq(const stdstd::shared_ptr<ov::Node> get_leaf_node_of_first_parent_shape_infer_seq(const std::shared_ptr<ov::Node>& start_node) {std::shared_ptr<ov::Node> leaf_node = nullptr;if (op::Subgraph::is_shape_infer_op(start_node)) {- OPENVINO_ASSERT(start_node->input(0).get_source_output().get_target_inputs().size() == 1, "Shape infer ops are supposed to be the only consumer.");+ OPENVINO_ASSERT(start_node->input(0).get_source_output().get_target_inputs().size() == 1,+ "Shape infer ops are supposed to be the only consumer.");leaf_node = start_node;}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.");+ 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)break;@@ -326,8 +348,10 @@ int64_t get_dim_stride(const lowered::ExpressionPort& expr_port, size_t idx) {const auto& shape = expr_port.get_descriptor_ptr()->get_shape();const auto& layout = expr_port.get_descriptor_ptr()->get_layout();switch (expr_port.get_type()) {- case lowered::ExpressionPort::Input: return get_dim_in_stride(shape, layout, idx);- case lowered::ExpressionPort::Output: return get_dim_out_stride(shape, layout, idx);+ case lowered::ExpressionPort::Input:+ return get_dim_in_stride(shape, layout, idx);+ case lowered::ExpressionPort::Output:+ return get_dim_out_stride(shape, layout, idx);}OPENVINO_THROW("Unsupported expression port type!");}@@ -404,6 +428,6 @@ std::string tensor2str(const VectorDims& tensor, const std::string& delimiter) {return ss.str();}-} // namespace utils-} // namespace snippets-} // namespace ov+} // namespace utils+} // namespace snippets+} // namespace ov