Skip to content

Commit 52abb9b

Browse files
committed
Address review comments
1 parent 6e3ab61 commit 52abb9b

File tree

4 files changed

+40
-17
lines changed

4 files changed

+40
-17
lines changed

src/common/snippets/docs/debug_capabilities/linear_ir_passes_serialization.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,25 @@ Examples:
1717
OV_SNIPPETS_DUMP_LIR="passes=all dir=path/dumpdir formats=control_flow" binary ...
1818
OV_SNIPPETS_DUMP_LIR="passes=FuseLoops,InsertLoops,InsertLoadStore formats=data_flow" binary ...
1919
OV_SNIPPETS_DUMP_LIR="passes=final formats=control_flow name_modifier=subgraph_name" binary ...
20+
OV_SNIPPETS_DUMP_LIR="passes=all dir=path/dumpdir name_modifier=branchA" binary ...
2021
```
2122

23+
Dumped files have below names:
24+
- Regular passes: `lir_<index>_<pass>_(control_flow|data_flow)_(in|out).xml` (creates both input and output files)
25+
- Final dump: `lir_<index>_Final_(control_flow|data_flow).xml` (creates single file only)
26+
27+
When `name_modifier` is provided, it is prepended to file names as a prefix:
28+
- `name_modifier=subgraph_name` prepends the Snippets Subgraph friendly name where available (e.g., final dump).
29+
- any other non-empty value prepends that literal value (e.g., `branchA_lir_...`).
30+
2231
Option names are case insensitive, the following options are supported:
2332
- `passes` : Dump LIR around the passes if passes name are specified.
2433
It support multiple comma separated pass names. The names are case insensitive.
2534
This option is a must have, should not be omitted.
26-
Special values: 'all' - dump all passes (includes 'final'), 'final' - dump final LIR snapshot right before code generation.
35+
Special values: 'all' - dump all passes (includes 'final'), 'final' - dump final LIR snapshot right before code generation (single file, no _in/_out suffix).
2736
- `dir` : Path to dumped LIR files.
2837
If omitted, it defaults to snippets_LIR_dump.
2938
If specified path doesn't exist, the directory will be created automatically.
3039
- `formats` : Support values are control_flow, data_flow and all.
3140
If omitted, it defaults to control_flow.
32-
- `name_modifier` : Optional naming modifier for dump files. Supported value is `subgraph_name`, which prepends the Snippets Subgraph friendly name to dumped files. If omitted, no name modification is performed. Note: when using `subgraph_name`, characters '/' and ':' in the subgraph name are replaced with '_' for filesystem compatibility.
33-
34-
Notes:
35-
- File names follow the same `OV_SNIPPETS_DUMP_LIR` convention: `lir_<index>_<pass>_(control_flow|data_flow)_(in|out).xml`. When `name_modifier=subgraph_name` is set, it is prepended to the file name.
41+
- `name_modifier` : Optional file-name prefix. Special value `subgraph_name` prepends the Snippets Subgraph friendly name to dumped files (where available). Any other non-empty value is used as a literal prefix. If omitted, no name modification is performed. Note: when using `subgraph_name`, characters '/' and ':' in the subgraph name are replaced with '_' for filesystem compatibility.

src/common/snippets/include/snippets/utils/debug_caps_config.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class DebugCapsConfig {
5151
std::string dir = "snippets_LIR_dump";
5252
LIRFormatFilter format = {1 << LIRFormatFilter::controlFlow};
5353
std::vector<std::string> passes;
54-
bool use_subgraph_name = false;
5554
std::string name_modifier;
5655

5756
std::vector<PropertySetterPtr> getPropertySetters() override {
@@ -63,9 +62,11 @@ class DebugCapsConfig {
6362
"indicate dump LIRs around the passes. Support multiple passes with comma separated and case "
6463
"insensitive. Special values: 'all' - dump all passes (includes 'final'), 'final' - dump final "
6564
"LIR")),
66-
PropertySetterPtr(new StringPropertySetter("name_modifier",
67-
name_modifier,
68-
"optional name modifier, supported: subgraph_name"))};
65+
PropertySetterPtr(new StringPropertySetter(
66+
"name_modifier",
67+
name_modifier,
68+
"optional file-name prefix; special value 'subgraph_name' uses the Subgraph friendly name; any "
69+
"other non-empty value is used as a literal prefix"))};
6970
}
7071
} dumpLIR;
7172

src/common/snippets/include/snippets/utils/linear_ir_pass_dumper.hpp

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,40 @@ namespace ov::snippets {
1818

1919
class LIRPassDump {
2020
public:
21-
explicit LIRPassDump(const lowered::LinearIR& linear_ir, std::string pass_name, std::string name_prefix = "")
21+
enum class DumpMode : uint8_t { Both, SingleDump };
22+
23+
explicit LIRPassDump(const lowered::LinearIR& linear_ir,
24+
std::string pass_name,
25+
std::string name_prefix = "",
26+
DumpMode mode = DumpMode::Both)
2227
: linear_ir(linear_ir),
2328
pass_name(std::move(pass_name)),
2429
name_prefix(std::move(name_prefix)),
30+
dump_mode(mode),
2531
debug_config(*linear_ir.get_config().debug_config) {
26-
dump("_in");
32+
if (dump_mode == DumpMode::Both) {
33+
dump("_in");
34+
} else {
35+
dump("");
36+
}
2737
}
2838
~LIRPassDump() {
29-
dump("_out");
39+
if (dump_mode == DumpMode::Both) {
40+
dump("_out");
41+
}
3042
}
3143

3244
private:
3345
void dump(const std::string&& postfix) const {
3446
static int num = 0; // just to keep dumped IRs ordered in filesystem
3547
auto pathAndName = debug_config.dumpLIR.dir + "/";
36-
const bool use_subgraph_prefix =
37-
ov::util::to_lower(debug_config.dumpLIR.name_modifier) == std::string("subgraph_name");
38-
if (use_subgraph_prefix && !name_prefix.empty()) {
39-
pathAndName += name_prefix + "_";
48+
const auto nm_lower = ov::util::to_lower(debug_config.dumpLIR.name_modifier);
49+
if (nm_lower == std::string("subgraph_name")) {
50+
if (!name_prefix.empty()) {
51+
pathAndName += name_prefix + "_";
52+
}
53+
} else if (!debug_config.dumpLIR.name_modifier.empty()) {
54+
pathAndName += debug_config.dumpLIR.name_modifier + "_";
4055
}
4156
pathAndName += "lir_";
4257

@@ -60,6 +75,7 @@ class LIRPassDump {
6075
const lowered::LinearIR& linear_ir;
6176
const std::string pass_name;
6277
const std::string name_prefix;
78+
const DumpMode dump_mode;
6379
const DebugCapsConfig& debug_config;
6480
};
6581

src/common/snippets/src/op/subgraph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ snippets::Schedule Subgraph::generate(const void* compile_params) const {
637637
std::replace(name_prefix.begin(), name_prefix.end(), '/', '_');
638638
std::replace(name_prefix.begin(), name_prefix.end(), ':', '_');
639639
}
640-
LIRPassDump final_dump(*linear_ir, std::string("Final"), name_prefix);
640+
LIRPassDump final_dump(*linear_ir, std::string("Final"), name_prefix, LIRPassDump::DumpMode::SingleDump);
641641
}
642642
#endif
643643

0 commit comments

Comments
 (0)