Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Snippets][CPU] Enable verbose perf count insertion pass conditionally #28846

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Config {
// False if LIR can be built from ov::Model only. Prevents adding I/O expressions
bool m_manual_build_support = false;
#ifdef SNIPPETS_DEBUG_CAPS
DebugCapsConfig debug_config;
std::shared_ptr<DebugCapsConfig> debug_config = std::make_shared<DebugCapsConfig>();
#endif
};

Expand Down
6 changes: 6 additions & 0 deletions src/common/snippets/include/snippets/op/subgraph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class Subgraph : public ov::op::util::SubGraphOp {

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() { return *config.m_debug_config; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor:
Can we add assert to check that ptr is not null? I see that the m_debug_config is defined in public section as non-const and can be nullified/changed in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

#endif // SNIPPETS_DEBUG_CAPS
bool has_domain_sensitive_ops() const { return config.m_has_domain_sensitive_ops; }

// plugin sets generator for a snippet to some specific generator.
Expand Down Expand Up @@ -187,6 +190,9 @@ class Subgraph : public ov::op::util::SubGraphOp {
// 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -53,7 +53,7 @@ class LIRPassDump {
} // 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()) || \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
6 changes: 5 additions & 1 deletion src/common/snippets/src/op/subgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_CAPS

m_linear_ir = std::make_shared<lowered::LinearIR>(body_ptr(), shape_infer_factory, lowering_config);
m_shape_infer = m_linear_ir->get_shape_infer_instance();
Expand Down Expand Up @@ -481,7 +485,7 @@ void Subgraph::control_flow_transformations(size_t min_parallel_work_amount, siz
validation_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());
}
Expand Down
11 changes: 7 additions & 4 deletions src/plugins/intel_cpu/src/nodes/subgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_CAPS

SNIPPETS_REGISTER_PASS_RELATIVE(Place::After,
Expand Down
Loading