From 869c004b23f9862ac4d5485f87f3f425fa22f94a Mon Sep 17 00:00:00 2001 From: Arseniy Obolenskiy Date: Mon, 20 Jan 2025 21:09:06 +0100 Subject: [PATCH] debug caps --- .../snippets/src/utils/debug_caps_config.cpp | 3 +- .../plugin/x64/debug_capabilities.cpp | 6 +- .../snippets/cpu_runtime_configurator.cpp | 6 +- .../snippets/utils/debug_caps_config.cpp | 3 +- .../snippets/x64/jit_debug_emitter.cpp | 6 +- .../snippets/x64/kernel_executors/brgemm.cpp | 3 +- .../src/emitters/snippets/x64/verbose.cpp | 12 ++- src/plugins/intel_cpu/src/graph.cpp | 3 +- src/plugins/intel_cpu/src/graph_dumper.cpp | 43 +++++++---- .../src/nodes/executors/x64/subgraph.cpp | 3 +- .../intel_cpu/src/onednn/iml_type_mapper.cpp | 9 ++- .../transformation_pipeline.cpp | 3 +- .../src/utils/debug_capabilities.cpp | 76 ++++++++++++------- .../intel_cpu/src/utils/debug_caps_config.cpp | 45 +++++++---- .../intel_cpu/src/utils/node_dumper.cpp | 42 ++++++---- src/plugins/intel_cpu/src/utils/verbose.cpp | 15 ++-- 16 files changed, 183 insertions(+), 95 deletions(-) diff --git a/src/common/snippets/src/utils/debug_caps_config.cpp b/src/common/snippets/src/utils/debug_caps_config.cpp index 4f29b109b5fb98..e108db2c633153 100644 --- a/src/common/snippets/src/utils/debug_caps_config.cpp +++ b/src/common/snippets/src/utils/debug_caps_config.cpp @@ -11,8 +11,9 @@ namespace snippets { void DebugCapsConfig::readProperties() { auto readEnv = [](const char* envVar) { const char* env = std::getenv(envVar); - if (env && *env) + if (env && *env) { return env; + } return static_cast(nullptr); }; diff --git a/src/plugins/intel_cpu/src/emitters/plugin/x64/debug_capabilities.cpp b/src/plugins/intel_cpu/src/emitters/plugin/x64/debug_capabilities.cpp index daf4f62bdaf70e..322d33df04e739 100644 --- a/src/plugins/intel_cpu/src/emitters/plugin/x64/debug_capabilities.cpp +++ b/src/plugins/intel_cpu/src/emitters/plugin/x64/debug_capabilities.cpp @@ -33,8 +33,9 @@ template void RegPrinter::print(jit_generator& h, Reg8 reg, template void RegPrinter::print_reg_prc(const char* name, const char* ori_name, T* ptr) { std::stringstream ss; - if (name) + if (name) { ss << name << " | "; + } ss << ori_name << ": "; if (std::is_floating_point::value) { ss << *ptr; @@ -52,8 +53,9 @@ void RegPrinter::print_reg_prc(const char* name, const char* ori_name, T* ptr) { template void RegPrinter::print_vmm_prc(const char* name, const char* ori_name, PRC_T* ptr) { std::stringstream ss; - if (name) + if (name) { ss << name << " | "; + } ss << ori_name << ": {" << ptr[0]; for (size_t i = 1; i < vlen / sizeof(float); i++) { ss << ", " << ptr[i]; diff --git a/src/plugins/intel_cpu/src/emitters/snippets/cpu_runtime_configurator.cpp b/src/plugins/intel_cpu/src/emitters/snippets/cpu_runtime_configurator.cpp index 639b54d8ade4c3..3a823ea43797ab 100644 --- a/src/plugins/intel_cpu/src/emitters/snippets/cpu_runtime_configurator.cpp +++ b/src/plugins/intel_cpu/src/emitters/snippets/cpu_runtime_configurator.cpp @@ -27,12 +27,14 @@ std::string CPURuntimeConfig::to_string() const { const auto& loop = loop_args[i]; out << "\t[" << i << "] WA: " << loop.m_work_amount << "\n"; out << "\tPointer Increments: "; - for (int64_t j = 0; j < loop.m_num_data_ptrs; ++j) + for (int64_t j = 0; j < loop.m_num_data_ptrs; ++j) { out << loop.m_ptr_increments[j] << " "; + } out << "\n"; out << "\tFinalization offsets: "; - for (int64_t j = 0; j < loop.m_num_data_ptrs; ++j) + for (int64_t j = 0; j < loop.m_num_data_ptrs; ++j) { out << loop.m_finalization_offsets[j] << " "; + } out << "\n"; } return out.str(); diff --git a/src/plugins/intel_cpu/src/emitters/snippets/utils/debug_caps_config.cpp b/src/plugins/intel_cpu/src/emitters/snippets/utils/debug_caps_config.cpp index 8350de5f56840f..13c68f4494c796 100644 --- a/src/plugins/intel_cpu/src/emitters/snippets/utils/debug_caps_config.cpp +++ b/src/plugins/intel_cpu/src/emitters/snippets/utils/debug_caps_config.cpp @@ -11,8 +11,9 @@ namespace intel_cpu { void SnippetsDebugCapsConfig::readProperties() { auto readEnv = [](const char* envVar) { const char* env = std::getenv(envVar); - if (env && *env) + if (env && *env) { return env; + } return static_cast(nullptr); }; diff --git a/src/plugins/intel_cpu/src/emitters/snippets/x64/jit_debug_emitter.cpp b/src/plugins/intel_cpu/src/emitters/snippets/x64/jit_debug_emitter.cpp index 9cdc806255c933..9a30c39ccf18f1 100644 --- a/src/plugins/intel_cpu/src/emitters/snippets/x64/jit_debug_emitter.cpp +++ b/src/plugins/intel_cpu/src/emitters/snippets/x64/jit_debug_emitter.cpp @@ -64,13 +64,15 @@ void jit_debug_emitter::emit_code(const std::vector& in_idxs, const std::vector& out_idxs, const std::vector& pool_vec_idxs, const std::vector& pool_gpr_idxs) const { - if (m_decorator_emit_loc == EmissionLocation::preamble || m_decorator_emit_loc == EmissionLocation::both) + if (m_decorator_emit_loc == EmissionLocation::preamble || m_decorator_emit_loc == EmissionLocation::both) { m_decorator_emitter->emit_code(in_idxs, out_idxs, pool_vec_idxs, pool_gpr_idxs); + } m_target_emitter->emit_code(in_idxs, out_idxs, pool_vec_idxs, pool_gpr_idxs); - if (m_decorator_emit_loc == EmissionLocation::postamble || m_decorator_emit_loc == EmissionLocation::both) + if (m_decorator_emit_loc == EmissionLocation::postamble || m_decorator_emit_loc == EmissionLocation::both) { m_decorator_emitter->emit_code(in_idxs, out_idxs, pool_vec_idxs, pool_gpr_idxs); + } } } // namespace intel_cpu diff --git a/src/plugins/intel_cpu/src/emitters/snippets/x64/kernel_executors/brgemm.cpp b/src/plugins/intel_cpu/src/emitters/snippets/x64/kernel_executors/brgemm.cpp index 7dd2573c32b113..3cf6c27689119f 100644 --- a/src/plugins/intel_cpu/src/emitters/snippets/x64/kernel_executors/brgemm.cpp +++ b/src/plugins/intel_cpu/src/emitters/snippets/x64/kernel_executors/brgemm.cpp @@ -118,8 +118,9 @@ void brgemm_ref_kernel::operator()(dnnl::impl::cpu::x64::brgemm_kernel_params_t* for (dnnl_dim_t m = 0; m < m_config.get_M(); m++) { for (dnnl_dim_t n = 0; n < m_config.get_N(); n++, B++) { C[n] = 0; - for (dnnl_dim_t k = 0; k < m_config.get_K(); k++) + for (dnnl_dim_t k = 0; k < m_config.get_K(); k++) { C[n] += A[k] * B[k * m_config.get_LDB()]; + } } B -= m_config.get_N(); A += m_config.get_LDA(); diff --git a/src/plugins/intel_cpu/src/emitters/snippets/x64/verbose.cpp b/src/plugins/intel_cpu/src/emitters/snippets/x64/verbose.cpp index 4338000d6982fa..c6e156265445f5 100644 --- a/src/plugins/intel_cpu/src/emitters/snippets/x64/verbose.cpp +++ b/src/plugins/intel_cpu/src/emitters/snippets/x64/verbose.cpp @@ -84,10 +84,12 @@ static std::string init_info_jit_store_memory_emitter(const jit_store_memory_emi std::string init_info_jit_brgemm_emitter(const jit_brgemm_emitter* emitter) { std::stringstream ss; ss << "Emitter_type_name:jit_brgemm_emitter"; - if (const auto& common = std::dynamic_pointer_cast(emitter->m_kernel_executor)) + if (const auto& common = std::dynamic_pointer_cast(emitter->m_kernel_executor)) { ss << common->to_string(); - if (const auto& amx = std::dynamic_pointer_cast(emitter->m_kernel_executor)) + } + if (const auto& amx = std::dynamic_pointer_cast(emitter->m_kernel_executor)) { ss << amx->to_string(); + } ss << " m_memory_offset:" << vector_to_string(emitter->m_memory_offsets) << " m_buffer_ids:" << vector_to_string(emitter->m_buffer_ids); @@ -110,8 +112,9 @@ std::string init_info_jit_kernel_static_emitter(const jit_kernel_static_emitter* << " master_shape:" << vector_to_string(emitter->master_shape) << " num_inputs:" << emitter->num_inputs << " num_outputs:" << emitter->num_outputs << " num_unique_buffers:" << emitter->num_unique_buffers << " data_ptr_regs_idx:" << vector_to_string(emitter->data_ptr_regs_idx); - for (size_t i = 0; i < emitter->data_offsets.size(); ++i) + for (size_t i = 0; i < emitter->data_offsets.size(); ++i) { ss << " data_offsets for " << i << " is:" << vector_to_string(emitter->data_offsets[i]); + } return ss.str(); } @@ -146,8 +149,9 @@ static std::string init_info_jit_emitter_general(const jit_emitter* emitter) { } void jit_emitter_info_t::init(const jit_emitter* emitter) { - if (is_initialized_) + if (is_initialized_) { return; + } if (auto e_type = dynamic_cast(emitter)) { str_ = init_info_jit_load_memory_emitter(e_type); } else if (auto e_type = dynamic_cast(emitter)) { diff --git a/src/plugins/intel_cpu/src/graph.cpp b/src/plugins/intel_cpu/src/graph.cpp index 02e05156883534..3d83d644185e67 100644 --- a/src/plugins/intel_cpu/src/graph.cpp +++ b/src/plugins/intel_cpu/src/graph.cpp @@ -1904,8 +1904,9 @@ void Graph::EnforceInferencePrecision() { continue; } #ifdef CPU_DEBUG_CAPS - if (!inferPrecDebug.enabled(NameFromType(node->getType()), node->getName(), node->getOriginalLayers())) + if (!inferPrecDebug.enabled(NameFromType(node->getType()), node->getName(), node->getOriginalLayers())) { continue; + } #endif for (size_t i = 0; i < node->getOriginalInputsNumber(); i++) { diff --git a/src/plugins/intel_cpu/src/graph_dumper.cpp b/src/plugins/intel_cpu/src/graph_dumper.cpp index ede91d4d659477..880800587c0ad7 100644 --- a/src/plugins/intel_cpu/src/graph_dumper.cpp +++ b/src/plugins/intel_cpu/src/graph_dumper.cpp @@ -225,8 +225,9 @@ std::shared_ptr dump_graph_as_ie_ngraph_net(const Graph& graph) { void serialize(const Graph& graph) { const std::string& path = graph.getConfig().debugCaps.execGraphPath; - if (path.empty()) + if (path.empty()) { return; + } if (path == "cout") { serializeToCout(graph); @@ -240,8 +241,9 @@ void serialize(const Graph& graph) { } void serializeToXML(const Graph& graph, const std::string& path) { - if (path.empty()) + if (path.empty()) { return; + } std::string binPath; ov::pass::Manager manager; @@ -275,8 +277,9 @@ void summary_perf(const Graph& graph) { } const std::string& summaryPerf = graph.getConfig().debugCaps.summaryPerf; - if (summaryPerf.empty() || !std::stoi(summaryPerf)) + if (summaryPerf.empty() || !std::stoi(summaryPerf)) { return; + } std::map perf_by_type; std::map perf_by_node; @@ -290,19 +293,22 @@ void summary_perf(const Graph& graph) { total += node->PerfCounter().count() * avg; total_avg += avg; - if (perf_by_type.count(type)) + if (perf_by_type.count(type)) { perf_by_type[type] += avg; - else + } else { perf_by_type[type] = avg; + } - if (perf_by_node.count(node)) + if (perf_by_node.count(node)) { perf_by_node[node] += avg; - else + } else { perf_by_node[node] = avg; + } } - if (total_avg < 1) + if (total_avg < 1) { return; + } std::cout << "======= ENABLE_DEBUG_CAPS:OV_CPU_SUMMARY_PERF ======" << std::endl; std::cout << "Summary of " << graph.GetName() << " @" << std::hash{}(reinterpret_cast(&graph)) @@ -313,8 +319,9 @@ void summary_perf(const Graph& graph) { std::cout << " perf_by_type:" << std::endl; std::vector> A; A.reserve(perf_by_type.size()); - for (auto& it : perf_by_type) + for (auto& it : perf_by_type) { A.push_back(it); + } sort(A.begin(), A.end(), [](std::pair& a, std::pair& b) { return a.second > b.second; }); @@ -322,8 +329,9 @@ void summary_perf(const Graph& graph) { for (auto& it : A) { std::stringstream ss; int percentage = static_cast(it.second * 100 / total_avg); - if (percentage == 0) + if (percentage == 0) { break; + } ss << std::setw(10) << std::right << percentage << " % : " << std::setw(8) << std::right << it.second << "(us) " << it.first << std::endl; std::cout << ss.str(); @@ -333,8 +341,9 @@ void summary_perf(const Graph& graph) { std::cout << " perf_by_node:" << std::endl; std::vector> A; A.reserve(perf_by_node.size()); - for (auto& it : perf_by_node) + for (auto& it : perf_by_node) { A.push_back(it); + } sort(A.begin(), A.end(), [](std::pair& a, std::pair& b) { return a.second > b.second; }); @@ -343,10 +352,12 @@ void summary_perf(const Graph& graph) { std::stringstream ss; auto percentage = it.second * 100 / total_avg; auto node = it.first; - if (node->PerfCounter().count() == 0) + if (node->PerfCounter().count() == 0) { continue; - if (node->PerfCounter().avg() < 1) + } + if (node->PerfCounter().avg() < 1) { continue; + } ss << std::setw(10) << std::right << std::fixed << std::setprecision(2) << percentage << " % " << std::setw(8) << std::right << node->PerfCounter().avg() << "(us)x" << node->PerfCounter().count() << " #" << node->getExecIndex() << " " << node->getName() << " " @@ -371,8 +382,9 @@ void average_counters(const Graph& graph) { const std::string& path = graph.getConfig().debugCaps.averageCountersPath; - if (path.empty()) + if (path.empty()) { return; + } static int graphIndex = 0; std::string fileName = path + "_" + std::to_string(graphIndex++) + ".csv"; @@ -404,8 +416,9 @@ void average_counters(const Graph& graph) { }; for (auto& node : graph.GetNodes()) { - if (node->isConstant()) + if (node->isConstant()) { continue; + } total += printAverageCounter(node); } diff --git a/src/plugins/intel_cpu/src/nodes/executors/x64/subgraph.cpp b/src/plugins/intel_cpu/src/nodes/executors/x64/subgraph.cpp index 1b2bcf217f7f64..5c7a9f87864ecc 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/x64/subgraph.cpp +++ b/src/plugins/intel_cpu/src/nodes/executors/x64/subgraph.cpp @@ -130,8 +130,9 @@ void SubgraphExecutor::segfault_detector() { if (enabled_segfault_detector) { __sighandler_t signal_handler = [](int signal) { std::lock_guard guard(err_print_lock); - if (auto segfault_detector_emitter = ov::intel_cpu::g_custom_segfault_handler->local()) + if (auto segfault_detector_emitter = ov::intel_cpu::g_custom_segfault_handler->local()) { std::cout << segfault_detector_emitter->info() << std::endl; + } auto tid = parallel_get_thread_num(); OPENVINO_THROW("Segfault was caught by the signal handler in subgraph node execution on thread " + std::to_string(tid)); diff --git a/src/plugins/intel_cpu/src/onednn/iml_type_mapper.cpp b/src/plugins/intel_cpu/src/onednn/iml_type_mapper.cpp index eb6fabe65a03b2..388618f7b93682 100644 --- a/src/plugins/intel_cpu/src/onednn/iml_type_mapper.cpp +++ b/src/plugins/intel_cpu/src/onednn/iml_type_mapper.cpp @@ -41,8 +41,9 @@ impl_desc_type parse_impl_name(std::string impl_desc_name) { SEARCH_WORD(jit); SEARCH_WORD(brgconv); SEARCH_WORD(brgemm); - if ((res & impl_desc_type::brgemm) != impl_desc_type::brgemm) + if ((res & impl_desc_type::brgemm) != impl_desc_type::brgemm) { SEARCH_WORD(gemm); + } SEARCH_WORD(blas); SEARCH_WORD(mlas); SEARCH_WORD(sse42); @@ -60,12 +61,14 @@ impl_desc_type parse_impl_name(std::string impl_desc_name) { SEARCH_WORD(shl); SEARCH_WORD(asimd); if ((res & impl_desc_type::avx2) != impl_desc_type::avx2 && - (res & impl_desc_type::avx512) != impl_desc_type::avx512) + (res & impl_desc_type::avx512) != impl_desc_type::avx512) { SEARCH_WORD(avx); + } if ((res & impl_desc_type::sse42) != impl_desc_type::sse42 && (res & impl_desc_type::avx) != impl_desc_type::avx && (res & impl_desc_type::avx2) != impl_desc_type::avx2 && - (res & impl_desc_type::avx512) != impl_desc_type::avx512) + (res & impl_desc_type::avx512) != impl_desc_type::avx512) { SEARCH_WORD(uni); + } SEARCH_WORD_2(nchw, ref); SEARCH_WORD_2(ncdhw, ref); diff --git a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp index 18bc8dd5a61ec1..882e0f3c7e74b8 100644 --- a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp +++ b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp @@ -388,8 +388,9 @@ void Transformations::PreLpt(const std::vector& defaultPrecis ov::pass::Manager manager("Plugin:CPU"); manager.set_per_pass_validation(false); - if (useLpt) + if (useLpt) { CPU_REGISTER_PASS_COMMON(manager, ov::pass::MarkDequantization, defaultPrecisions); + } auto get_convert_precisions = [&]() { precisions_map map = {{ov::element::i64, ov::element::i32}, diff --git a/src/plugins/intel_cpu/src/utils/debug_capabilities.cpp b/src/plugins/intel_cpu/src/utils/debug_capabilities.cpp index 722230484b6c13..d9ed66672e532f 100644 --- a/src/plugins/intel_cpu/src/utils/debug_capabilities.cpp +++ b/src/plugins/intel_cpu/src/utils/debug_capabilities.cpp @@ -55,10 +55,12 @@ DebugLogEnabled::DebugLogEnabled(const char* file, const char* func, int line, c std::string file_path(file); std::string file_name(file); auto last_sep = file_path.find_last_of('/'); - if (last_sep == std::string::npos) + if (last_sep == std::string::npos) { last_sep = file_path.find_last_of('\\'); - if (last_sep != std::string::npos) + } + if (last_sep != std::string::npos) { file_name = file_path.substr(last_sep + 1); + } std::string file_name_with_line = file_name + ":" + std::to_string(line); tag = file_name_with_line + " " + func + "()"; @@ -79,8 +81,9 @@ DebugLogEnabled::DebugLogEnabled(const char* file, const char* func, int line, c const char* p1 = p0; while (*p0 != 0) { p1 = p0; - while (*p1 != ';' && *p1 != 0) + while (*p1 != ';' && *p1 != 0) { ++p1; + } std::string pattern(p0, p1 - p0); if (pattern == file_name || pattern == func || pattern == tag || pattern == file_name_with_line || (name != nullptr && pattern == name)) { @@ -88,14 +91,16 @@ DebugLogEnabled::DebugLogEnabled(const char* file, const char* func, int line, c break; } p0 = p1; - if (*p0 == ';') + if (*p0 == ';') { ++p0; + } } - if (match) + if (match) { enabled = filter_match_action; - else + } else { enabled = !filter_match_action; + } } void DebugLogEnabled::break_at(const std::string& log) { @@ -137,11 +142,13 @@ std::ostream& operator<<(std::ostream& os, const PortConfig& config) { std::ostream& operator<<(std::ostream& os, const NodeConfig& config) { os << "("; - for (auto& conf : config.inConfs) + for (auto& conf : config.inConfs) { os << conf; + } os << ") -> ("; - for (auto& conf : config.outConfs) + for (auto& conf : config.outConfs) { os << conf; + } os << ")" << '\n'; return os; } @@ -158,17 +165,20 @@ std::ostream& operator<<(std::ostream& os, const Node& c_node) { const char* comma = ""; auto node_id = [](Node& node) { auto id = node.getName(); - if (id.size() > 50) + if (id.size() > 50) { return node.getTypeStr() + "_" + std::to_string(node.getExecIndex()); + } return id; }; auto is_single_output_port = [](Node& node) { for (auto& e : node.getChildEdges()) { auto edge = e.lock(); - if (!edge) + if (!edge) { continue; - if (edge->getInputNum() != 0) + } + if (edge->getInputNum() != 0) { return false; + } } return true; }; @@ -179,8 +189,9 @@ std::ostream& operator<<(std::ostream& os, const Node& c_node) { int num_output_port = 0; for (const auto& wptr : node.getChildEdges()) { auto edge = wptr.lock(); - if (num_output_port < edge->getInputNum() + 1) + if (num_output_port < edge->getInputNum() + 1) { num_output_port = edge->getInputNum() + 1; + } } auto getData = [](const MemoryPtr& ptr) { @@ -196,8 +207,9 @@ std::ostream& operator<<(std::ostream& os, const Node& c_node) { }; if (num_output_port) { - if (num_output_port > 1) + if (num_output_port > 1) { leftside << "("; + } comma = ""; for (int i = 0; i < num_output_port; i++) { bool b_ouputed = false; @@ -229,8 +241,9 @@ std::ostream& operator<<(std::ostream& os, const Node& c_node) { } comma = ","; } - if (num_output_port > 1) + if (num_output_port > 1) { leftside << ")"; + } } else if (nodeDesc) { // output Desc is enough since input is always in consistent // with output. @@ -249,8 +262,9 @@ std::ostream& operator<<(std::ostream& os, const Node& c_node) { auto& outConfs = nodeDesc->getConfig().outConfs; if (!outConfs.empty()) { - if (outConfs.size() > 1) + if (outConfs.size() > 1) { leftside << "("; + } comma = ""; for (auto& c : outConfs) { auto shape_str = c.getMemDesc()->getShape().toString(); @@ -259,8 +273,9 @@ std::ostream& operator<<(std::ostream& os, const Node& c_node) { << c.getMemDesc()->serializeFormat() << "_" << shape_str; comma = ","; } - if (outConfs.size() > 1) + if (outConfs.size() > 1) { leftside << ")"; + } } } else { // no SPD yet, use orginal shapes @@ -278,8 +293,9 @@ std::ostream& operator<<(std::ostream& os, const Node& c_node) { leftside << " " << node_id(node) << " = "; os << "#" << node.getExecIndex() << " :" << std::right << std::setw(align_col) << leftside.str(); os << std::left << node.getTypeStr(); - if (node.getAlgorithm() != Algorithm::Default) + if (node.getAlgorithm() != Algorithm::Default) { os << "." << algToString(node.getAlgorithm()); + } os << " ("; comma = ""; @@ -289,10 +305,12 @@ std::ostream& operator<<(std::ostream& os, const Node& c_node) { const char* sep2 = ""; for (const auto& e : node.getParentEdges()) { auto edge = e.lock(); - if (!edge) + if (!edge) { continue; - if (edge->getOutputNum() != static_cast(port)) + } + if (edge->getOutputNum() != static_cast(port)) { continue; + } auto n = edge->getParent(); os << sep2; os << node_id(*edge->getParent()); @@ -300,8 +318,9 @@ std::ostream& operator<<(std::ostream& os, const Node& c_node) { if (ptr) { os << "&" << getData(ptr); } - if (!is_single_output_port(*n)) + if (!is_single_output_port(*n)) { os << "[" << edge->getInputNum() << "]"; + } sep2 = "|"; // show all edges at single port(usually indicating bugs) } comma = ","; @@ -489,15 +508,17 @@ std::ostream& operator<<(std::ostream& os, const PrintableModel& model) { auto type = op->get_type_name(); auto name = op->get_friendly_name(); os << prefix << "\t"; - if (op->get_output_size() > 1) + if (op->get_output_size() > 1) { os << "("; + } sep = ""; for (size_t i = 0; i < op->get_output_size(); i++) { os << sep << op->get_output_element_type(i) << "_" << op->get_output_partial_shape(i); sep = ","; } - if (op->get_output_size() > 1) + if (op->get_output_size() > 1) { os << ")"; + } os << " " << tag << name << " = " << type << "("; sep = ""; for (size_t i = 0; i < op->get_input_size(); i++) { @@ -549,8 +570,9 @@ std::ostream& operator<<(std::ostream& os, const PrintableModel& model) { os << prefix << "}\n"; os << prefix << "fp16_compress disabled Ngraph nodes:\n"; for (const auto& op : f.get_ordered_ops()) { - if (ov::fp16_compression_is_disabled(op) && !ov::as_type_ptr(op)) + if (ov::fp16_compression_is_disabled(op) && !ov::as_type_ptr(op)) { os << "\t" << tag << op->get_friendly_name() << "\n"; + } } return os; } @@ -638,16 +660,18 @@ template std::string to_string(const T* values, size_t N, size_t maxsize) { std::stringstream ss; for (size_t i = 0; i < N; i++) { - if (i > 0) + if (i > 0) { ss << ","; + } if (ss.tellp() > static_cast(maxsize)) { ss << "..." << N << "in total"; break; } - if (std::is_same::value || std::is_same::value) + if (std::is_same::value || std::is_same::value) { ss << static_cast(values[i]); - else + } else { ss << values[i]; + } } return ss.str(); } diff --git a/src/plugins/intel_cpu/src/utils/debug_caps_config.cpp b/src/plugins/intel_cpu/src/utils/debug_caps_config.cpp index 79031ac0dcb44f..85afa984045fe0 100644 --- a/src/plugins/intel_cpu/src/utils/debug_caps_config.cpp +++ b/src/plugins/intel_cpu/src/utils/debug_caps_config.cpp @@ -13,59 +13,72 @@ namespace intel_cpu { void DebugCapsConfig::readProperties() { auto readEnv = [](const char* envVar) { const char* env = std::getenv(envVar); - if (env && *env) // set and non-empty + if (env && *env) { // set and non-empty return env; + } - return (const char*)nullptr; + return static_cast(nullptr); }; auto parseDumpFormat = [](const std::string& format) { - if (format == "BIN") + if (format == "BIN") { return FORMAT::BIN; - else if (format == "TEXT") + } else if (format == "TEXT") { return FORMAT::TEXT; - else + } else { OPENVINO_THROW("readDebugCapsProperties: Unknown dump format"); + } }; const char* envVarValue = nullptr; - if ((envVarValue = readEnv("OV_CPU_EXEC_GRAPH_PATH"))) + if ((envVarValue = readEnv("OV_CPU_EXEC_GRAPH_PATH"))) { execGraphPath = envVarValue; + } - if ((envVarValue = readEnv("OV_CPU_VERBOSE"))) + if ((envVarValue = readEnv("OV_CPU_VERBOSE"))) { verbose = envVarValue; + } - if ((envVarValue = readEnv("OV_CPU_BLOB_DUMP_DIR"))) + if ((envVarValue = readEnv("OV_CPU_BLOB_DUMP_DIR"))) { blobDumpDir = envVarValue; + } - if ((envVarValue = readEnv("OV_CPU_BLOB_DUMP_FORMAT"))) + if ((envVarValue = readEnv("OV_CPU_BLOB_DUMP_FORMAT"))) { blobDumpFormat = parseDumpFormat(envVarValue); + } - if ((envVarValue = readEnv("OV_CPU_BLOB_DUMP_NODE_EXEC_ID"))) + if ((envVarValue = readEnv("OV_CPU_BLOB_DUMP_NODE_EXEC_ID"))) { blobDumpFilters[FILTER::BY_EXEC_ID] = envVarValue; + } - if ((envVarValue = readEnv("OV_CPU_BLOB_DUMP_NODE_PORTS"))) + if ((envVarValue = readEnv("OV_CPU_BLOB_DUMP_NODE_PORTS"))) { blobDumpFilters[FILTER::BY_PORTS] = envVarValue; + } - if ((envVarValue = readEnv("OV_CPU_BLOB_DUMP_NODE_TYPE"))) + if ((envVarValue = readEnv("OV_CPU_BLOB_DUMP_NODE_TYPE"))) { blobDumpFilters[FILTER::BY_TYPE] = envVarValue; + } - if ((envVarValue = readEnv("OV_CPU_BLOB_DUMP_NODE_NAME"))) + if ((envVarValue = readEnv("OV_CPU_BLOB_DUMP_NODE_NAME"))) { blobDumpFilters[FILTER::BY_NAME] = envVarValue; + } - if ((envVarValue = readEnv("OV_CPU_DISABLE"))) + if ((envVarValue = readEnv("OV_CPU_DISABLE"))) { disable.parseAndSet(envVarValue); + } - if ((envVarValue = readEnv("OV_CPU_DUMP_IR"))) + if ((envVarValue = readEnv("OV_CPU_DUMP_IR"))) { dumpIR.parseAndSet(envVarValue); + } if ((envVarValue = readEnv("OV_CPU_SUMMARY_PERF"))) { summaryPerf = envVarValue; } - if ((envVarValue = readEnv("OV_CPU_AVERAGE_COUNTERS"))) + if ((envVarValue = readEnv("OV_CPU_AVERAGE_COUNTERS"))) { averageCountersPath = envVarValue; + } } } // namespace intel_cpu diff --git a/src/plugins/intel_cpu/src/utils/node_dumper.cpp b/src/plugins/intel_cpu/src/utils/node_dumper.cpp index e5c2326ff95c76..26416652d4f1d2 100644 --- a/src/plugins/intel_cpu/src/utils/node_dumper.cpp +++ b/src/plugins/intel_cpu/src/utils/node_dumper.cpp @@ -27,13 +27,15 @@ static void formatNodeName(std::string& name) { static bool shouldBeDumped(const NodePtr& node, const DebugCapsConfig& config, const std::string& portsKind) { const auto& dumpFilters = config.blobDumpFilters; - if (dumpFilters.empty()) + if (dumpFilters.empty()) { return false; + } if (dumpFilters.count(DebugCapsConfig::FILTER::BY_PORTS)) { // filter by ports configured if (dumpFilters.at(DebugCapsConfig::FILTER::BY_PORTS) != "ALL" && - portsKind != dumpFilters.at(DebugCapsConfig::FILTER::BY_PORTS)) + portsKind != dumpFilters.at(DebugCapsConfig::FILTER::BY_PORTS)) { return false; + } } if (dumpFilters.count(DebugCapsConfig::FILTER::BY_EXEC_ID)) { // filter by exec id configured @@ -48,8 +50,9 @@ static bool shouldBeDumped(const NodePtr& node, const DebugCapsConfig& config, c } } - if (!matched) + if (!matched) { return false; + } } if (dumpFilters.count(DebugCapsConfig::FILTER::BY_TYPE)) { // filter by type configured @@ -64,16 +67,18 @@ static bool shouldBeDumped(const NodePtr& node, const DebugCapsConfig& config, c } } - if (!matched) + if (!matched) { return false; + } } if (dumpFilters.count(DebugCapsConfig::FILTER::BY_NAME)) { // filter by name configured if (dumpFilters.at(DebugCapsConfig::FILTER::BY_NAME) != "*" && // to have 'single char' option for matching all the names !std::regex_match(node->getName(), - std::regex(dumpFilters.at(DebugCapsConfig::FILTER::BY_NAME)))) // name does not match + std::regex(dumpFilters.at(DebugCapsConfig::FILTER::BY_NAME)))) { // name does not match return false; + } } return true; @@ -105,8 +110,9 @@ static void dumpInternalBlobs(const NodePtr& node, const DebugCapsConfig& config std::string file_name = NameFromType(node->getType()) + "_" + nodeName + "_blb" + std::to_string(i) + ".ieb"; auto dump_file = config.blobDumpDir + "/#" + std::to_string(node->getExecIndex()) + "_" + file_name; - if (blb->getDesc().getPrecision() == ov::element::u1) + if (blb->getDesc().getPrecision() == ov::element::u1) { continue; + } BlobDumper dumper(blb); dump(dumper, dump_file, config); @@ -124,8 +130,9 @@ static std::string createDumpFilePath(const std::string& blobDumpDir, const std: } void dumpInputBlobs(const NodePtr& node, const DebugCapsConfig& config, int count) { - if (!shouldBeDumped(node, config, "IN")) + if (!shouldBeDumped(node, config, "IN")) { return; + } std::string nodeName = node->getName(); formatNodeName(nodeName); @@ -136,19 +143,22 @@ void dumpInputBlobs(const NodePtr& node, const DebugCapsConfig& config, int coun auto pr = prEdge->getParent(); std::string file_name = NameFromType(node->getType()) + "_" + nodeName; - if (count != -1) + if (count != -1) { file_name += "_iter" + std::to_string(count); + } file_name += "_in" + std::to_string(i) + ".ieb"; - if (file_name.size() > 240) + if (file_name.size() > 240) { file_name = file_name.substr(file_name.size() - 240); + } std::string dump_file = createDumpFilePath(config.blobDumpDir, file_name, node->getExecIndex()); std::cout << "Dump inputs: " << dump_file << std::endl; auto& desc = prEdge->getMemory().getDesc(); - if (desc.getPrecision() == ov::element::u1) + if (desc.getPrecision() == ov::element::u1) { continue; + } BlobDumper dumper(prEdge->getMemoryPtr()); dump(dumper, dump_file, config); @@ -158,8 +168,9 @@ void dumpInputBlobs(const NodePtr& node, const DebugCapsConfig& config, int coun } void dumpOutputBlobs(const NodePtr& node, const DebugCapsConfig& config, int count) { - if (!shouldBeDumped(node, config, "OUT")) + if (!shouldBeDumped(node, config, "OUT")) { return; + } std::string nodeName = node->getName(); formatNodeName(nodeName); @@ -169,19 +180,22 @@ void dumpOutputBlobs(const NodePtr& node, const DebugCapsConfig& config, int cou auto childEdge = node->getChildEdgeAt(i); std::string file_name = NameFromType(node->getType()) + "_" + nodeName; - if (count != -1) + if (count != -1) { file_name += "_iter" + std::to_string(count); + } file_name += "_out" + std::to_string(i) + ".ieb"; - if (file_name.size() > 240) + if (file_name.size() > 240) { file_name = file_name.substr(file_name.size() - 240); + } std::string dump_file = createDumpFilePath(config.blobDumpDir, file_name, node->getExecIndex()); std::cout << "Dump outputs: " << dump_file << std::endl; auto& desc = childEdge->getMemory().getDesc(); - if (desc.getPrecision() == ov::element::u1) + if (desc.getPrecision() == ov::element::u1) { continue; + } BlobDumper dumper(childEdge->getMemoryPtr()); dump(dumper, dump_file, config); diff --git a/src/plugins/intel_cpu/src/utils/verbose.cpp b/src/plugins/intel_cpu/src/utils/verbose.cpp index d0ed7e2bd82097..53779ce516e580 100644 --- a/src/plugins/intel_cpu/src/utils/verbose.cpp +++ b/src/plugins/intel_cpu/src/utils/verbose.cpp @@ -23,14 +23,17 @@ namespace ov { namespace intel_cpu { bool Verbose::shouldBePrinted() const { - if (lvl < 1) + if (lvl < 1) { return false; + } - if (lvl < 2 && one_of(node->getType(), Type::Input, Type::Output)) + if (lvl < 2 && one_of(node->getType(), Type::Input, Type::Output)) { return false; + } - if (lvl < 3 && node->isConstant()) + if (lvl < 3 && node->isConstant()) { return false; + } return true; } @@ -45,8 +48,9 @@ void Verbose::printInfo() { enum Color { RED, GREEN, YELLOW, BLUE, PURPLE, CYAN }; auto colorize = [&](const Color color, const std::string& str) { - if (!colorUp) + if (!colorUp) { return str; + } const std::string red("\033[1;31m"); const std::string green("\033[1;32m"); @@ -148,8 +152,9 @@ void Verbose::printInfo() { } std::string nodeImplementer = "cpu"; - if (node->getType() == Type::Reference) + if (node->getType() == Type::Reference) { nodeImplementer = "ngraph_ref"; // ngraph reference + } const std::string& nodeName = colorize(GREEN, node->getName()); const std::string& nodeType = colorize(CYAN, NameFromType(node->getType()));