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

PassManager refactoring and new debug caps #25637

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 @@ -20,7 +20,7 @@ ov::pass::low_precision::AlignQuantizationIntervals::AlignQuantizationIntervals(

bool ov::pass::low_precision::AlignQuantizationIntervals::run_on_model(const std::shared_ptr<ov::Model>& f) {
RUN_ON_FUNCTION_SCOPE(AlignQuantizationIntervals);
ov::pass::Manager manager;
ov::pass::Manager manager("LPT:AlignQuantizationIntervals");
manager.set_per_pass_validation(false);
std::shared_ptr<ov::pass::GraphRewrite> intervalsAlignment = manager.register_pass<ov::pass::GraphRewrite>();
intervalsAlignment->add_matcher<low_precision::CreateAttribute<IntervalsAlignmentAttribute, opset1::FakeQuantize>>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ov::pass::low_precision::AlignQuantizationParameters::AlignQuantizationParameter

bool ov::pass::low_precision::AlignQuantizationParameters::run_on_model(const std::shared_ptr<ov::Model>& f) {
RUN_ON_FUNCTION_SCOPE(AlignQuantizationParameters);
ov::pass::Manager manager;
ov::pass::Manager manager("LPT:AlignQuantizationParameters");
manager.set_per_pass_validation(false);
std::shared_ptr<ov::pass::GraphRewrite> propagation = manager.register_pass<ov::pass::GraphRewrite>();
propagation->add_matcher<low_precision::CreateAttribute<QuantizationAlignmentAttribute>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ MarkupOptimizations::MarkupOptimizations(

bool ov::pass::low_precision::MarkupOptimizations::run_on_model(const std::shared_ptr<ov::Model>& f) {
RUN_ON_FUNCTION_SCOPE(MarkupOptimizations);
ov::pass::Manager markup(get_pass_config());
ov::pass::Manager markup(get_pass_config(), "LPT:MarkupOptimizations");
markup.set_per_pass_validation(false);
markup.register_pass<low_precision::MarkupCanBeQuantized>(params.defaultPrecisions);
if (!precisionRestrictions.empty()) {
Expand All @@ -216,7 +216,7 @@ bool ov::pass::low_precision::LowPrecision::run_on_model(const std::shared_ptr<o
OV_ITT_SCOPE(FIRST_INFERENCE, itt::domains::LPT_LT, "LowPrecision");

auto passConfig = get_pass_config();
ov::pass::Manager manager(passConfig);
ov::pass::Manager manager(passConfig, "LowPrecision");

auto prerequisites = manager.register_pass<ov::pass::GraphRewrite>();
const std::vector<ov::element::Type> supportedTypes = {ov::element::i8, ov::element::u8};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ov::pass::low_precision::MarkupAvgPoolPrecisionPreserved::MarkupAvgPoolPrecision

bool ov::pass::low_precision::MarkupAvgPoolPrecisionPreserved::run_on_model(const std::shared_ptr<ov::Model>& f) {
RUN_ON_FUNCTION_SCOPE(MarkupAvgPoolPrecisionPreserved);
ov::pass::Manager manager;
ov::pass::Manager manager("LPT:MarkupAvgPoolPrecisionPreserved");
manager.set_per_pass_validation(false);
std::shared_ptr<ov::pass::GraphRewrite> markupAvgPoolPrecision = manager.register_pass<ov::pass::GraphRewrite>();
markupAvgPoolPrecision->add_matcher<low_precision::CreatePrecisionsDependentAttribute<AvgPoolPrecisionPreservedAttribute, opset1::AvgPool>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ov::pass::low_precision::PropagatePrecisions::PropagatePrecisions(const Attribut

bool ov::pass::low_precision::PropagatePrecisions::run_on_model(const std::shared_ptr<ov::Model>& f) {
RUN_ON_FUNCTION_SCOPE(PropagatePrecisions);
ov::pass::Manager manager;
ov::pass::Manager manager("LPT:PropagatePrecisions");
manager.set_per_pass_validation(false);
std::shared_ptr<ov::pass::GraphRewrite> precisionsPropagation = manager.register_pass<ov::pass::GraphRewrite>();
precisionsPropagation->add_matcher<low_precision::CreateAttribute<PrecisionsAttribute, opset1::FakeQuantize>>(params, AttributeSource::OutputPort);
Expand Down
2 changes: 1 addition & 1 deletion src/common/snippets/src/pass/common_optimizations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ CommonOptimizations::CommonOptimizations(const SnippetsTokenization::Config& con

// Firstly, we should transform all original Converts inside body to ConvertTruncation to save original behavior.
// Then if Subgraph contains FakeQuantize we enable specific transformation for quantized subgraphs.
ov::pass::Manager manager(get_pass_config());
ov::pass::Manager manager(get_pass_config(), "Snippets:CommonOptimizations");
REGISTER_SNIPPETS_PASS(manager, ov::snippets::pass::TransformConvertToConvertTruncation, true);
REGISTER_SNIPPETS_PASS(manager, ov::snippets::pass::ExplicitTransposeMatMulInputs, is_domain_sensitive);
REGISTER_SNIPPETS_PASS(manager, ov::snippets::pass::CommonFakeQuantizeDecomposition, is_quantized);
Expand Down
2 changes: 1 addition & 1 deletion src/common/snippets/src/pass/fq_decomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ bool ov::snippets::pass::CommonFakeQuantizeDecomposition::is_supported_fq(const

bool ov::snippets::pass::CommonFakeQuantizeDecomposition::run_on_model(const std::shared_ptr<ov::Model>& f) {
RUN_ON_FUNCTION_SCOPE(CommonFakeQuantizeDecomposition);
ov::pass::Manager manager;
ov::pass::Manager manager("Snippets:CommonFakeQuantizeDecomposition");
manager.set_per_pass_validation(false);
manager.register_pass<ov::snippets::pass::FakeQuantizeDecomposition>();
manager.register_pass<ov::pass::ConstantFolding>();
Expand Down
2 changes: 1 addition & 1 deletion src/common/snippets/src/pass/tokenization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ bool EnumerateNodes::run_on_model(const std::shared_ptr<ov::Model> &m) {

bool SnippetsTokenization::run_on_model(const std::shared_ptr<ov::Model>& m) {
RUN_ON_FUNCTION_SCOPE(SnippetsTokenization);
ov::pass::Manager manager(get_pass_config());
ov::pass::Manager manager(get_pass_config(), "Snippets:Tokenization");
manager.set_per_pass_validation(false);

manager.register_pass<EnumerateNodes>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@

bool ov::pass::CommonOptimizations::run_on_model(const std::shared_ptr<ov::Model>& f) {
RUN_ON_FUNCTION_SCOPE(CommonOptimizations);
ov::pass::Manager manager(get_pass_config());
ov::pass::Manager manager(get_pass_config(), "CommonOptimizations");
manager.set_per_pass_validation(false);

using namespace ov::pass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class PropagateNMSPath : public pass::MatcherPass {

for (size_t body_idx = 0; body_idx < models.size(); ++body_idx) {
handle_params(multi_subgraph_op, models[body_idx], static_cast<int>(body_idx));
ov::pass::Manager manager;
ov::pass::Manager manager("PropagateNMSPath");
manager.register_pass<ov::pass::PropagateNMSPath>();
manager.run_passes(models[body_idx]);
handle_results(multi_subgraph_op, models[body_idx], static_cast<int>(body_idx));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

bool ov::pass::MOCLegacyTransformations::run_on_model(const std::shared_ptr<ov::Model>& f) {
RUN_ON_MODEL_SCOPE(MOCLegacyTransformations);
ov::pass::Manager manager(get_pass_config());
ov::pass::Manager manager(get_pass_config(), "MOCLegacyTransformations");
using namespace ov::pass;
REGISTER_PASS(manager, ChangePlaceholderTypes, m_params_with_custom_types)
manager.run_passes(f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ bool ov::pass::MOCTransformations::run_on_model(const std::shared_ptr<ov::Model>
f->validate_nodes_and_infer_types();
}

ov::pass::Manager manager(get_pass_config());
ov::pass::Manager manager(get_pass_config(), "MOC");
manager.set_per_pass_validation(false);
using namespace ov::pass;
REGISTER_PASS(manager, InitNodeInfo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ ov::pass::StridedSliceOptimization::StridedSliceOptimization(bool use_shapes) {

bool ov::pass::StridedSliceOptimization::run_on_model(const std::shared_ptr<ov::Model>& f) {
RUN_ON_FUNCTION_SCOPE(StridedSliceOptimization);
ov::pass::Manager manager;
ov::pass::Manager manager("StridedSliceOptimization");
manager.set_per_pass_validation(false);
if (m_use_shapes) {
manager.register_pass<UselessSliceEraser>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ bool ov::pass::ReverseInputChannelsFusion::run_on_model(const std::shared_ptr<ov
// First we need to initialize and propagate RIC attributes through entire graph
{
using namespace init;
Manager m;
Manager m("ReverseInputChannelsFusion");
m.set_per_pass_validation(false);
auto ric_init = m.register_pass<GraphRewrite>();
ADD_MATCHER(ric_init, SplitConcat, nodes_to_fuse)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ pass::SimplifySecondInputOfReshape::SimplifySecondInputOfReshape() {

bool pass::SimplifyShapeOfSubGraph::run_on_model(const std::shared_ptr<Model>& f) {
RUN_ON_FUNCTION_SCOPE(SimplifyShapeOfSubGraph);
Manager manager(get_pass_config());
Manager manager(get_pass_config(), "SimplifyShapeOfSubGraph");
manager.set_per_pass_validation(false);

REGISTER_PASS(manager, PrepareShapeOpsForEliminationAroundBE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ bool ov::pass::ConvertPrecision::run_on_model(const std::shared_ptr<ov::Model>&
bool has_fp16_compression = m_precisions.count(element::f32) > 0 && m_precisions[element::f32] == element::f16;

if (m_keep_precision_sensitive_in_fp32 && has_fp16_compression) {
pass::Manager manager(get_pass_config());
pass::Manager manager(get_pass_config(), "KeepPrecisionSensitiveInFP32");
// Mark subgraphs with disable_fp16_compression to keep them in FP32
manager.register_pass<pass::MarkSugraphsToKeepInMixedPrecision>();
manager.register_pass<pass::AlignMixedFP32FP16Types>();
Expand Down Expand Up @@ -494,7 +494,7 @@ bool ov::pass::ConvertPrecision::run_on_model(const std::shared_ptr<ov::Model>&

// to remove extra converts
if (m_keep_precision_sensitive_in_fp32) {
pass::Manager manager(get_pass_config());
pass::Manager manager(get_pass_config(), "KeepPrecisionSensitiveInFP32:RemoveConverts");
manager.register_pass<pass::EnableDecompressionConvertConstantFolding>();
manager.register_pass<pass::ConstantFolding>();
manager.run_passes(f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ using namespace ov;
bool ov::pass::ConvertCompressedOnlyToLegacy::run_on_model(const std::shared_ptr<ov::Model>& f) {
RUN_ON_MODEL_SCOPE(ConvertCompressedOnlyToLegacy);
if (ov::op::util::has_decompression_converts(f)) {
Manager manager(get_pass_config());
Manager manager(get_pass_config(), "ConvertCompressedOnlyToLegacy");

const precisions_map convert_precision_map{{ov::element::f32, ov::element::f16}};
manager.register_pass<ConvertPrecision>(convert_precision_map);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ class PropagateDownDisableSensitivityForQuantized : public pass::MatcherPass {
bool MarkSugraphsToKeepInMixedPrecision::run_on_model(const shared_ptr<ov::Model>& m) {
RUN_ON_MODEL_SCOPE(MarkSugraphsToKeepInMixedPrecision);

Manager manager(get_pass_config());
Manager manager(get_pass_config(), "MarkSugraphsToKeepInMixedPrecision");
// Mark root of Division with eps pattern to keep in FP32
REGISTER_PASS(manager, MarkDivWithEps)
REGISTER_PASS(manager, MarkExpInReduceOpPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

bool ov::pass::ConvertOpSet2ToOpSet1::run_on_model(const std::shared_ptr<ov::Model>& f) {
RUN_ON_FUNCTION_SCOPE(ConvertOpSet2ToOpSet1);
ov::pass::Manager manager(get_pass_config());
ov::pass::Manager manager(get_pass_config(), "ConvertOpSet2ToOpSet1");
manager.set_per_pass_validation(false);

manager.register_pass<ov::pass::ConvertSpaceToBatch>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

bool ov::pass::ConvertOpSet3ToOpSet2::run_on_model(const std::shared_ptr<ov::Model>& f) {
RUN_ON_FUNCTION_SCOPE(ConvertOpSet3ToOpSet2);
ov::pass::Manager manager(get_pass_config());
ov::pass::Manager manager(get_pass_config(), "ConvertOpSet3ToOpSet2");
manager.set_per_pass_validation(false);

manager.register_pass<ov::pass::ConvertBroadcast3>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

bool ov::pass::SmartReshape::run_on_model(const std::shared_ptr<ov::Model>& f) {
RUN_ON_FUNCTION_SCOPE(SmartReshape);
ov::pass::Manager static_manager;
ov::pass::Manager static_manager("SmartReshape:static");
// This pass must be called first in pipeline
static_manager.register_pass<ov::pass::InitNodeInfo>();
static_manager.register_pass<ov::pass::ReshapeTo1D>();
Expand All @@ -37,7 +37,7 @@ bool ov::pass::SmartReshape::run_on_model(const std::shared_ptr<ov::Model>& f) {
static_manager.register_pass<ov::pass::ReshapeSinkingMatMul>();
static_manager.run_passes(f);

ov::pass::Manager dynamic_manager;
ov::pass::Manager dynamic_manager("SmartReshape:dynamic");
// function revalidation will cause "fake" dynamism due to ShapeOf ops insertions
// we turn it off to have access to originally static shapes
dynamic_manager.set_per_pass_validation(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ ov::pass::LabelResolvingThroughSelect::LabelResolvingThroughSelect() {
}

ov::pass::SymbolicOptimizations::SymbolicOptimizations(bool full_run) {
m_manager = std::make_shared<pass::Manager>();
m_manager = std::make_shared<pass::Manager>("Symbolic");
m_manager->set_per_pass_validation(false);

#define REGISTER_SYMBOLIC(region, ...) m_manager->register_pass<region>(__VA_ARGS__);
Expand Down
15 changes: 9 additions & 6 deletions src/core/include/openvino/pass/manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ class OPENVINO_API Manager {
Manager();
virtual ~Manager();

//// \brief Construct Manager with a provided name.
explicit Manager(std::string name);
Copy link
Contributor

Choose a reason for hiding this comment

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

why "UnnamedManager" is not used here as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

We want to collect information about managers/transformations execution time in a separate job. We need this name parameter here to identify manager in debug log

Copy link
Contributor

Choose a reason for hiding this comment

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

Added another PR #25842 to fix it


//// \brief Construct Manager with shared PassConfig instance
explicit Manager(std::shared_ptr<PassConfig> pass_config);
explicit Manager(std::shared_ptr<PassConfig> pass_config, std::string name = "UnnamedManager");

/// \brief Register given transformation class type to execution list
/// Example below show the basic usage of pass::Manager
Expand Down Expand Up @@ -66,11 +69,8 @@ class OPENVINO_API Manager {
///
/// \return Returns true if the model was changed by transformations,
/// false otherwise.
bool run_passes(std::shared_ptr<Model> model);
bool run_passes(const std::shared_ptr<Model>& model);
praasz marked this conversation as resolved.
Show resolved Hide resolved

void set_pass_visualization(bool new_state) {
m_visualize = new_state;
}
/// \brief Set flag to enable/disable running Validate pass after executing
/// each registered pass
/// \param new_state Value "true" enables Validate pass run; "false", otherwise
Expand All @@ -97,8 +97,11 @@ class OPENVINO_API Manager {

std::shared_ptr<PassConfig> m_pass_config;
std::vector<std::shared_ptr<PassBase>> m_pass_list;
bool m_visualize = false;
bool m_per_pass_validation = true;
std::string m_name = "UnnamedManager";

private:
bool run_pass(const std::shared_ptr<PassBase>& pass, const std::shared_ptr<Model>& model, bool needs_validate);
};
} // namespace pass
} // namespace ov
4 changes: 2 additions & 2 deletions src/core/src/graph_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ void serialize(const std::shared_ptr<const ov::Model>& m,
const std::string& xml_path,
const std::string& bin_path,
ov::pass::Serialize::Version version) {
ov::pass::Manager manager;
ov::pass::Manager manager("Serialize");
manager.register_pass<ov::pass::Serialize>(xml_path, bin_path, version);
manager.run_passes(std::const_pointer_cast<ov::Model>(m));
}
Expand All @@ -339,7 +339,7 @@ void save_model(const std::shared_ptr<const ov::Model>& m, const std::string& ou
ov::pass::compress_model_to_f16(cloned, postponed);
}

ov::pass::Manager manager;
ov::pass::Manager manager("SaveModel");
manager.register_pass<ov::pass::FusedNamesCleanup>();
manager.register_pass<ov::pass::Serialize>(output_model, "");
manager.run_passes(std::move(cloned));
Expand Down
2 changes: 1 addition & 1 deletion src/core/src/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ void ov::Model::reshape(const std::map<ov::Output<ov::Node>, ov::PartialShape>&
};

try {
ov::pass::Manager ssr_manager;
ov::pass::Manager ssr_manager("SmartReshape");
ssr_manager.register_pass<ov::pass::SmartReshape>();
ssr_manager.run_passes(shared_from_this());

Expand Down
2 changes: 1 addition & 1 deletion src/core/src/pass/convert_fp32_to_fp16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

bool ov::pass::ConvertFP32ToFP16::run_on_model(const std::shared_ptr<ov::Model>& f) {
RUN_ON_MODEL_SCOPE(ConvertFP32ToFP16);
ov::pass::Manager m(get_pass_config());
ov::pass::Manager m(get_pass_config(), "ConvertFP32ToFP16");
m.register_pass<ov::pass::ConvertPrecision>(precisions_map{{ov::element::f32, ov::element::f16}});
m.run_passes(f);
return false;
Expand Down
Loading
Loading