forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
encapulate LIR dumper for Vladislav comments
- Loading branch information
1 parent
19a4833
commit 16d4d24
Showing
8 changed files
with
203 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
#ifdef SNIPPETS_DEBUG_CAPS | ||
|
||
#include "snippets/debug_caps.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" | ||
|
||
namespace ov { | ||
namespace snippets { | ||
|
||
class LIRPassDump { | ||
public: | ||
explicit LIRPassDump(lowered::LinearIR& linear_ir, std::string pass_name) | ||
: linear_ir(linear_ir), pass_name(pass_name), debug_config(linear_ir.get_config().debug_config) { | ||
dump("_in"); | ||
} | ||
~LIRPassDump() { | ||
dump("_out"); | ||
} | ||
|
||
private: | ||
void dump(const std::string&& postfix) const { | ||
static int num = 0; // just to keep dumped IRs ordered in filesystem | ||
const auto pathAndName = debug_config.dumpLIR.dir + "/lir_"; | ||
|
||
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"; | ||
lowered::pass::SerializeControlFlow SerializeLIR(xml_path); | ||
SerializeLIR.run(linear_ir); | ||
num++; | ||
} | ||
if (debug_config.dumpLIR.format.filter[DebugCapsConfig::LIRFormatFilter::dataFlow]) { | ||
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); | ||
num++; | ||
} | ||
} | ||
|
||
lowered::LinearIR& linear_ir; | ||
const std::string pass_name; | ||
const DebugCapsConfig& debug_config; | ||
}; | ||
|
||
} // 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 dumperPtr = (dumpLIR.passes == "all" || (pass_name.find(dumpLIR.passes) != std::string::npos)) ? \ | ||
std::unique_ptr<LIRPassDump>(new LIRPassDump(_linear_ir, pass_name)) : \ | ||
nullptr | ||
#else | ||
#define SNIPPETS_DEBUG_LIR_PASS_DUMP(_linear_ir, _pass) | ||
#endif // SNIPPETS_DEBUG_CAPS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.