Skip to content

Commit

Permalink
Serialization passes updated
Browse files Browse the repository at this point in the history
  • Loading branch information
v-Golubev committed Nov 13, 2024
1 parent 938892e commit c0d352f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ namespace pass {
* @brief Base class for LinearIR serialization passes
* @ingroup snippets
*/
class SerializeBase : public Pass {
class SerializeBase : public ConstPass {
public:
OPENVINO_RTTI("SerializeBase", "Pass")
OPENVINO_RTTI("SerializeBase", "ConstPass")
SerializeBase(const std::string& xml_path);

protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ class SerializeControlFlow : public SerializeBase {
OPENVINO_RTTI("SerializeControlFlow", "Pass", SerializeBase)
SerializeControlFlow(const std::string& xml_path, bool update_dynamic_ops = false) :
SerializeBase(xml_path), m_update_dynamic_ops{update_dynamic_ops} {}

bool run(LinearIR& linear_ir) override {
return run(const_cast<const LinearIR&>(linear_ir));
}
// We need a const method to run from functions that can't change LIR
bool run(const LinearIR& linear_ir);
bool run(const LinearIR& linear_ir) override;

private:
const bool m_update_dynamic_ops = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ class SerializeDataFlow : public SerializeBase {
public:
OPENVINO_RTTI("SerializeDataFlow", "Pass", SerializeBase)
SerializeDataFlow(const std::string& xml_path) : SerializeBase(xml_path) {}

bool run(LinearIR& linear_ir) override {
return run(const_cast<const LinearIR&>(linear_ir));
}
// We need a const method to run from functions that can't change LIR
bool run(const LinearIR& linear_ir);
bool run(const LinearIR& linear_ir) override;
};

} // namespace pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace snippets {

class LIRPassDump {
public:
explicit LIRPassDump(lowered::LinearIR& linear_ir, std::string pass_name)
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) {
dump("_in");
}
Expand Down Expand Up @@ -44,7 +44,7 @@ class LIRPassDump {
num++;
}

lowered::LinearIR& linear_ir;
const lowered::LinearIR& linear_ir;
const std::string pass_name;
const DebugCapsConfig& debug_config;
};
Expand Down
9 changes: 7 additions & 2 deletions src/common/snippets/src/lowered/pass/pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ void PassPipeline::register_pass(const std::shared_ptr<PassBase>& pass) {
void PassPipeline::run(const lowered::LinearIR& linear_ir) const {
for (const auto& pass : m_passes) {
OPENVINO_ASSERT(pass != nullptr, "PassPipeline has empty pass!");
// SNIPPETS_DEBUG_LIR_PASS_DUMP(linear_ir, pass);
SNIPPETS_DEBUG_LIR_PASS_DUMP(linear_ir, pass);

if (m_pass_config->is_disabled(pass->get_type_info())) {
continue;
}
const auto const_pass = std::dynamic_pointer_cast<ConstPass>(pass);
OPENVINO_ASSERT(const_pass != nullptr, "Unexpected pass (", pass->get_type_info(), ") is registered in PassPipeline");
OPENVINO_ASSERT(const_pass != nullptr,
"Unexpected pass (",
pass->get_type_info(),
") is registered in PassPipeline. Only ConstPass is allowed.");
const_pass->run(linear_ir);
}
}
Expand All @@ -55,6 +58,8 @@ void PassPipeline::run(LinearIR& linear_ir, LinearIR::constExprIt begin, LinearI
}
if (auto lir_pass = std::dynamic_pointer_cast<Pass>(pass)) {
lir_pass->run(linear_ir);
} else if (auto const_pass = std::dynamic_pointer_cast<ConstPass>(pass)) {
const_pass->run(linear_ir);
} else if (auto ranged_pass = std::dynamic_pointer_cast<RangedPass>(pass)) {
ranged_pass->run(linear_ir, begin, end);
} else {
Expand Down

0 comments on commit c0d352f

Please sign in to comment.