OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[Snippets][CPU] Enable verbose perf count insertion pass conditionally (#28846)
Arseniy Obolenskiy38791c628345
diff --git a/src/common/snippets/include/snippets/lowered/linear_ir.hpp b/src/common/snippets/include/snippets/lowered/linear_ir.hppindex 7f9436bb6ac..acc1024e875 100644--- a/src/common/snippets/include/snippets/lowered/linear_ir.hpp+++ b/src/common/snippets/include/snippets/lowered/linear_ir.hpp@@ -40,7 +40,7 @@ public:// False if LIR can be built from ov::Model only. Prevents adding I/O expressionsbool m_manual_build_support = false;#ifdef SNIPPETS_DEBUG_CAPS- DebugCapsConfig debug_config;+ std::shared_ptr<DebugCapsConfig> debug_config = std::make_shared<DebugCapsConfig>();#endif};@@ -69,7 +69,12 @@ public: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 { return m_config; }+ const Config& get_config() const {+#ifdef SNIPPETS_DEBUG_CAPS+ OPENVINO_ASSERT(m_config.debug_config, "Debug config is not initialized");+#endif // SNIPPETS_DEBUG_CAPS+ return m_config;+ }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; }diff --git a/src/common/snippets/include/snippets/op/subgraph.hpp b/src/common/snippets/include/snippets/op/subgraph.hppindex 9e9c1a9b546..b904ec57818 100644--- a/src/common/snippets/include/snippets/op/subgraph.hpp+++ b/src/common/snippets/include/snippets/op/subgraph.hpp@@ -101,6 +101,12 @@ public:size_t get_virtual_port_count() const { return m_virtual_port_count; }bool is_quantized() const { return config.m_is_quantized; }+#ifdef SNIPPETS_DEBUG_CAPS+ DebugCapsConfig& get_debug_config() {+ OPENVINO_ASSERT(config.m_debug_config, "Debug config is not initialized");+ return *config.m_debug_config;+ }+#endif // SNIPPETS_DEBUG_CAPSbool has_domain_sensitive_ops() const { return config.m_has_domain_sensitive_ops; }// plugin sets generator for a snippet to some specific generator.@@ -187,6 +193,9 @@ private:// True if Subgraph contains ops that are not applicable to auto broadcast rule.// (e.g. GroupNormalization, reshape)bool m_has_broadcast_sensitive_ops = false;+#ifdef SNIPPETS_DEBUG_CAPS+ std::shared_ptr<DebugCapsConfig> m_debug_config = std::make_shared<DebugCapsConfig>();+#endif} config;std::shared_ptr<ShapeInferSnippetsNode> m_shape_infer = nullptr;diff --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 c8c145d7eac..fabd2253583 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@@ -17,7 +17,7 @@ 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() {@@ -53,7 +53,7 @@ private:} // namespace ov#define SNIPPETS_DEBUG_LIR_PASS_DUMP(_linear_ir, _pass) \- auto dumpLIR = _linear_ir.get_config().debug_config.dumpLIR; \+ auto dumpLIR = _linear_ir.get_config().debug_config->dumpLIR; \auto pass_name = std::string(_pass->get_type_name()); \auto dump_name = dumpLIR.passes; \auto dumperPtr = ((std::find(dump_name.begin(), dump_name.end(), ov::util::to_lower(pass_name)) != dump_name.end()) || \diff --git a/src/common/snippets/src/lowered/pass/insert_perf_count_verbose.cpp b/src/common/snippets/src/lowered/pass/insert_perf_count_verbose.cppindex 969dd6242f4..e58a4b40de4 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@@ -26,12 +26,12 @@ bool InsertPerfCountVerbose::run(snippets::lowered::LinearIR& linear_ir,static size_t seq_number = 0;bool modified = false;- auto csv_path = linear_ir.get_config().debug_config.dumpParams.csv_path;+ auto csv_path = linear_ir.get_config().debug_config->dumpParams.csv_path;std::vector<std::shared_ptr<snippets::utils::Dumper>> dumpers;dumpers.push_back(std::make_shared<snippets::utils::ConsoleDumper>());// Add CSV dumper if path is provided- if (!linear_ir.get_config().debug_config.dumpParams.csv_path.empty()) {+ if (!linear_ir.get_config().debug_config->dumpParams.csv_path.empty()) {dumpers.push_back(std::make_shared<snippets::utils::CSVDumper>(csv_path));}diff --git a/src/common/snippets/src/op/subgraph.cpp b/src/common/snippets/src/op/subgraph.cppindex 42820889e2f..7d94015079c 100644--- a/src/common/snippets/src/op/subgraph.cpp+++ b/src/common/snippets/src/op/subgraph.cpp@@ -363,6 +363,10 @@ Subgraph::convert_body_to_linear_ir(size_t min_parallel_work_amount, size_t min_lowering_config.m_enable_domain_optimization = !config.m_has_domain_sensitive_ops;lowering_config.m_min_parallel_work_amount = min_parallel_work_amount;lowering_config.m_min_kernel_work_amount = min_kernel_work_amount;+#ifdef SNIPPETS_DEBUG_CAPS+ lowering_config.debug_config = config.m_debug_config;+ OPENVINO_ASSERT(lowering_config.debug_config, "Debug config is not initialized");+#endif // SNIPPETS_DEBUG_CAPSm_linear_ir = std::make_shared<lowered::LinearIR>(body_ptr(), shape_infer_factory, lowering_config);m_shape_infer = m_linear_ir->get_shape_infer_instance();@@ -481,7 +485,7 @@ void Subgraph::control_flow_transformations(size_t min_parallel_work_amount, sizvalidation_pipeline.run(*m_linear_ir);#ifdef SNIPPETS_DEBUG_CAPS- if (m_linear_ir->get_config().debug_config.perf_count_mode != DebugCapsConfig::PerfCountMode::Disabled) {+ if (m_linear_ir->get_config().debug_config->perf_count_mode != DebugCapsConfig::PerfCountMode::Disabled) {lowered::pass::InsertPerfCount perf_count_pass({});perf_count_pass.run(*m_linear_ir, m_linear_ir->cbegin(), m_linear_ir->cend());}diff --git a/src/plugins/intel_cpu/src/nodes/subgraph.cpp b/src/plugins/intel_cpu/src/nodes/subgraph.cppindex 9726f15c93a..b055bb4ff72 100644--- a/src/plugins/intel_cpu/src/nodes/subgraph.cpp+++ b/src/plugins/intel_cpu/src/nodes/subgraph.cpp@@ -543,10 +543,13 @@ Subgraph::ControlFlowPasses Subgraph::getControlFlowPasses() const {ov::intel_cpu::pass::BrgemmCPUBlocking);#ifdef SNIPPETS_DEBUG_CAPS- SNIPPETS_REGISTER_PASS_RELATIVE(Place::After,- ov::intel_cpu::pass::BrgemmCPUBlocking,- ov::snippets::lowered::pass::InsertPerfCountVerbose,- getName());+ const auto& debug_config = subgraph_attrs->snippet->get_debug_config();+ if (debug_config.perf_count_mode != snippets::DebugCapsConfig::PerfCountMode::Disabled) {+ SNIPPETS_REGISTER_PASS_RELATIVE(Place::After,+ ov::intel_cpu::pass::BrgemmCPUBlocking,+ ov::snippets::lowered::pass::InsertPerfCountVerbose,+ getName());+ }#endif // SNIPPETS_DEBUG_CAPSSNIPPETS_REGISTER_PASS_RELATIVE(Place::After,