From d253f4fd89c1a77a68cac0fa3d97e627a8ed4467 Mon Sep 17 00:00:00 2001 From: Ivan Tikhonov Date: Tue, 30 Jul 2024 14:52:55 +0400 Subject: [PATCH] PassManager refactoring and new debug caps (#25637) ### Details: - Simplified run_passes logic in pass::Manager class - Moved debugging logic to a separate Profiler class - Added a name for pass::Manager - Extended debug caps: added serialization by env variable, added filtring and collection perf statistics in a file New debug output format: ![image_2024-07-25_17-26-54](https://github.com/user-attachments/assets/2504fa83-3496-47e7-89a3-27c66b3e97b1) ### Tickets: - *CVS-147285* --- .../src/align_quantization_intervals.cpp | 2 +- .../src/align_quantization_parameters.cpp | 2 +- .../src/low_precision.cpp | 4 +- .../markup_avg_pool_precision_preserved.cpp | 2 +- .../src/propagate_precisions.cpp | 2 +- .../src/pass/common_optimizations.cpp | 2 +- .../snippets/src/pass/fq_decomposition.cpp | 2 +- src/common/snippets/src/pass/tokenization.cpp | 2 +- .../common_optimizations.cpp | 2 +- .../convert_nms_gather_path_to_unsigned.cpp | 2 +- .../moc_legacy_transformations.cpp | 2 +- .../moc_transformations.cpp | 2 +- .../optimize_strided_slice.cpp | 2 +- .../common_optimizations/ric_fusion.cpp | 2 +- .../simplify_shape_of_sub_graph.cpp | 2 +- .../src/transformations/convert_precision.cpp | 4 +- .../convert_compression_only_to_legacy.cpp | 2 +- ...k_subgraphs_to_keep_in_mixed_precision.cpp | 2 +- .../convert_opset2_to_opset1.cpp | 2 +- .../convert_opset3_to_opset2.cpp | 2 +- .../smart_reshape/smart_reshape.cpp | 4 +- .../symbolic_optimizations.cpp | 2 +- src/core/include/openvino/pass/manager.hpp | 15 +- src/core/src/graph_util.cpp | 4 +- src/core/src/model.cpp | 2 +- src/core/src/pass/convert_fp32_to_fp16.cpp | 2 +- src/core/src/pass/manager.cpp | 300 +++++++++++++----- src/core/src/pass/sdpa_to_paged_attention.cpp | 2 +- src/frontends/ir/src/frontend.cpp | 2 +- src/frontends/onnx/frontend/src/frontend.cpp | 6 +- src/frontends/paddle/src/frontend.cpp | 8 +- src/frontends/pytorch/src/frontend.cpp | 2 +- src/frontends/tensorflow/src/frontend.cpp | 4 +- .../tensorflow_lite/src/frontend.cpp | 6 +- .../tflite_quantize_resolver.cpp | 2 +- src/plugins/auto_batch/src/plugin.cpp | 2 +- .../convert_to_cpu_specific_opset.hpp | 2 +- .../transformation_pipeline.cpp | 12 +- .../transformations/convert_convolution.cpp | 2 +- .../src/plugin/transformations_pipeline.cpp | 8 +- .../compiler/src/graph_transformations.cpp | 2 +- src/plugins/template/src/plugin.cpp | 2 +- 42 files changed, 287 insertions(+), 148 deletions(-) diff --git a/src/common/low_precision_transformations/src/align_quantization_intervals.cpp b/src/common/low_precision_transformations/src/align_quantization_intervals.cpp index e8f8bb0250d8af..2d28adfe7f8570 100644 --- a/src/common/low_precision_transformations/src/align_quantization_intervals.cpp +++ b/src/common/low_precision_transformations/src/align_quantization_intervals.cpp @@ -20,7 +20,7 @@ ov::pass::low_precision::AlignQuantizationIntervals::AlignQuantizationIntervals( bool ov::pass::low_precision::AlignQuantizationIntervals::run_on_model(const std::shared_ptr& 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 intervalsAlignment = manager.register_pass(); intervalsAlignment->add_matcher>( diff --git a/src/common/low_precision_transformations/src/align_quantization_parameters.cpp b/src/common/low_precision_transformations/src/align_quantization_parameters.cpp index 236cc802d4f9a3..88729c63a6faf7 100644 --- a/src/common/low_precision_transformations/src/align_quantization_parameters.cpp +++ b/src/common/low_precision_transformations/src/align_quantization_parameters.cpp @@ -21,7 +21,7 @@ ov::pass::low_precision::AlignQuantizationParameters::AlignQuantizationParameter bool ov::pass::low_precision::AlignQuantizationParameters::run_on_model(const std::shared_ptr& 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 propagation = manager.register_pass(); propagation->add_matcher>(); diff --git a/src/common/low_precision_transformations/src/low_precision.cpp b/src/common/low_precision_transformations/src/low_precision.cpp index 6435f47d12ffec..e58374ed3e2b1a 100644 --- a/src/common/low_precision_transformations/src/low_precision.cpp +++ b/src/common/low_precision_transformations/src/low_precision.cpp @@ -190,7 +190,7 @@ MarkupOptimizations::MarkupOptimizations( bool ov::pass::low_precision::MarkupOptimizations::run_on_model(const std::shared_ptr& 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(params.defaultPrecisions); if (!precisionRestrictions.empty()) { @@ -217,7 +217,7 @@ bool ov::pass::low_precision::LowPrecision::run_on_model(const std::shared_ptr(); const std::vector supportedTypes = {ov::element::i8, ov::element::u8}; diff --git a/src/common/low_precision_transformations/src/markup_avg_pool_precision_preserved.cpp b/src/common/low_precision_transformations/src/markup_avg_pool_precision_preserved.cpp index ef5675bd764b5f..9dfe0c39caa419 100644 --- a/src/common/low_precision_transformations/src/markup_avg_pool_precision_preserved.cpp +++ b/src/common/low_precision_transformations/src/markup_avg_pool_precision_preserved.cpp @@ -19,7 +19,7 @@ ov::pass::low_precision::MarkupAvgPoolPrecisionPreserved::MarkupAvgPoolPrecision bool ov::pass::low_precision::MarkupAvgPoolPrecisionPreserved::run_on_model(const std::shared_ptr& 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 markupAvgPoolPrecision = manager.register_pass(); markupAvgPoolPrecision->add_matcher>(); diff --git a/src/common/low_precision_transformations/src/propagate_precisions.cpp b/src/common/low_precision_transformations/src/propagate_precisions.cpp index f849dbfe55263c..a899b6939a6039 100644 --- a/src/common/low_precision_transformations/src/propagate_precisions.cpp +++ b/src/common/low_precision_transformations/src/propagate_precisions.cpp @@ -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& 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 precisionsPropagation = manager.register_pass(); precisionsPropagation->add_matcher>(params, AttributeSource::OutputPort); diff --git a/src/common/snippets/src/pass/common_optimizations.cpp b/src/common/snippets/src/pass/common_optimizations.cpp index 516737f621051c..d9cc6f7f819201 100644 --- a/src/common/snippets/src/pass/common_optimizations.cpp +++ b/src/common/snippets/src/pass/common_optimizations.cpp @@ -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); diff --git a/src/common/snippets/src/pass/fq_decomposition.cpp b/src/common/snippets/src/pass/fq_decomposition.cpp index 2328e7f12c1681..fe5e98e8a8a4c9 100644 --- a/src/common/snippets/src/pass/fq_decomposition.cpp +++ b/src/common/snippets/src/pass/fq_decomposition.cpp @@ -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& 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(); manager.register_pass(); diff --git a/src/common/snippets/src/pass/tokenization.cpp b/src/common/snippets/src/pass/tokenization.cpp index 643f169f8b8416..43733fc196ee83 100644 --- a/src/common/snippets/src/pass/tokenization.cpp +++ b/src/common/snippets/src/pass/tokenization.cpp @@ -76,7 +76,7 @@ bool EnumerateNodes::run_on_model(const std::shared_ptr &m) { bool SnippetsTokenization::run_on_model(const std::shared_ptr& 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(); diff --git a/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp b/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp index 9da4340c2423f4..d7ca44e7ddad34 100644 --- a/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp @@ -121,7 +121,7 @@ bool ov::pass::CommonOptimizations::run_on_model(const std::shared_ptr& 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; diff --git a/src/common/transformations/src/transformations/common_optimizations/convert_nms_gather_path_to_unsigned.cpp b/src/common/transformations/src/transformations/common_optimizations/convert_nms_gather_path_to_unsigned.cpp index 3252882472ffec..7c22dbdfeac53d 100644 --- a/src/common/transformations/src/transformations/common_optimizations/convert_nms_gather_path_to_unsigned.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/convert_nms_gather_path_to_unsigned.cpp @@ -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(body_idx)); - ov::pass::Manager manager; + ov::pass::Manager manager("PropagateNMSPath"); manager.register_pass(); manager.run_passes(models[body_idx]); handle_results(multi_subgraph_op, models[body_idx], static_cast(body_idx)); diff --git a/src/common/transformations/src/transformations/common_optimizations/moc_legacy_transformations.cpp b/src/common/transformations/src/transformations/common_optimizations/moc_legacy_transformations.cpp index 83cf163555c327..7c21f98439d9a4 100644 --- a/src/common/transformations/src/transformations/common_optimizations/moc_legacy_transformations.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/moc_legacy_transformations.cpp @@ -12,7 +12,7 @@ bool ov::pass::MOCLegacyTransformations::run_on_model(const std::shared_ptr& 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); diff --git a/src/common/transformations/src/transformations/common_optimizations/moc_transformations.cpp b/src/common/transformations/src/transformations/common_optimizations/moc_transformations.cpp index 44c227623f444d..3cf542377d5adc 100644 --- a/src/common/transformations/src/transformations/common_optimizations/moc_transformations.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/moc_transformations.cpp @@ -125,7 +125,7 @@ bool ov::pass::MOCTransformations::run_on_model(const std::shared_ptr 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) diff --git a/src/common/transformations/src/transformations/common_optimizations/optimize_strided_slice.cpp b/src/common/transformations/src/transformations/common_optimizations/optimize_strided_slice.cpp index ace7e544bc994c..8d093878ff0b93 100644 --- a/src/common/transformations/src/transformations/common_optimizations/optimize_strided_slice.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/optimize_strided_slice.cpp @@ -425,7 +425,7 @@ ov::pass::StridedSliceOptimization::StridedSliceOptimization(bool use_shapes) { bool ov::pass::StridedSliceOptimization::run_on_model(const std::shared_ptr& 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(); diff --git a/src/common/transformations/src/transformations/common_optimizations/ric_fusion.cpp b/src/common/transformations/src/transformations/common_optimizations/ric_fusion.cpp index 7c095fbe89fe1f..6e44692b5f169c 100644 --- a/src/common/transformations/src/transformations/common_optimizations/ric_fusion.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/ric_fusion.cpp @@ -844,7 +844,7 @@ bool ov::pass::ReverseInputChannelsFusion::run_on_model(const std::shared_ptr(); ADD_MATCHER(ric_init, SplitConcat, nodes_to_fuse) diff --git a/src/common/transformations/src/transformations/common_optimizations/simplify_shape_of_sub_graph.cpp b/src/common/transformations/src/transformations/common_optimizations/simplify_shape_of_sub_graph.cpp index d4bb02227c56ac..a225f0655f98ee 100644 --- a/src/common/transformations/src/transformations/common_optimizations/simplify_shape_of_sub_graph.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/simplify_shape_of_sub_graph.cpp @@ -353,7 +353,7 @@ pass::SimplifySecondInputOfReshape::SimplifySecondInputOfReshape() { bool pass::SimplifyShapeOfSubGraph::run_on_model(const std::shared_ptr& 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) diff --git a/src/common/transformations/src/transformations/convert_precision.cpp b/src/common/transformations/src/transformations/convert_precision.cpp index 6d9d11ff52bcba..3c819d481bacee 100644 --- a/src/common/transformations/src/transformations/convert_precision.cpp +++ b/src/common/transformations/src/transformations/convert_precision.cpp @@ -413,7 +413,7 @@ bool ov::pass::ConvertPrecision::run_on_model(const std::shared_ptr& 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(); manager.register_pass(); @@ -494,7 +494,7 @@ bool ov::pass::ConvertPrecision::run_on_model(const std::shared_ptr& // 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(); manager.register_pass(); manager.run_passes(f); diff --git a/src/common/transformations/src/transformations/fp16_compression/convert_compression_only_to_legacy.cpp b/src/common/transformations/src/transformations/fp16_compression/convert_compression_only_to_legacy.cpp index ebeb900a31f2b8..b471424aeb9e65 100644 --- a/src/common/transformations/src/transformations/fp16_compression/convert_compression_only_to_legacy.cpp +++ b/src/common/transformations/src/transformations/fp16_compression/convert_compression_only_to_legacy.cpp @@ -17,7 +17,7 @@ using namespace ov; bool ov::pass::ConvertCompressedOnlyToLegacy::run_on_model(const std::shared_ptr& 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(convert_precision_map); diff --git a/src/common/transformations/src/transformations/fp16_compression/mark_subgraphs_to_keep_in_mixed_precision.cpp b/src/common/transformations/src/transformations/fp16_compression/mark_subgraphs_to_keep_in_mixed_precision.cpp index c5e768fa687bc2..45c455fd61e87c 100644 --- a/src/common/transformations/src/transformations/fp16_compression/mark_subgraphs_to_keep_in_mixed_precision.cpp +++ b/src/common/transformations/src/transformations/fp16_compression/mark_subgraphs_to_keep_in_mixed_precision.cpp @@ -423,7 +423,7 @@ class PropagateDownDisableSensitivityForQuantized : public pass::MatcherPass { bool MarkSugraphsToKeepInMixedPrecision::run_on_model(const shared_ptr& 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) diff --git a/src/common/transformations/src/transformations/opset_conversions/convert_opset2_to_opset1.cpp b/src/common/transformations/src/transformations/opset_conversions/convert_opset2_to_opset1.cpp index ab042a4cbdaaf4..3279fcb3e6cb55 100644 --- a/src/common/transformations/src/transformations/opset_conversions/convert_opset2_to_opset1.cpp +++ b/src/common/transformations/src/transformations/opset_conversions/convert_opset2_to_opset1.cpp @@ -14,7 +14,7 @@ bool ov::pass::ConvertOpSet2ToOpSet1::run_on_model(const std::shared_ptr& 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(); diff --git a/src/common/transformations/src/transformations/opset_conversions/convert_opset3_to_opset2.cpp b/src/common/transformations/src/transformations/opset_conversions/convert_opset3_to_opset2.cpp index 4c9ef1950ace84..045ad23a506220 100644 --- a/src/common/transformations/src/transformations/opset_conversions/convert_opset3_to_opset2.cpp +++ b/src/common/transformations/src/transformations/opset_conversions/convert_opset3_to_opset2.cpp @@ -17,7 +17,7 @@ bool ov::pass::ConvertOpSet3ToOpSet2::run_on_model(const std::shared_ptr& 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(); diff --git a/src/common/transformations/src/transformations/smart_reshape/smart_reshape.cpp b/src/common/transformations/src/transformations/smart_reshape/smart_reshape.cpp index 67e7084380375e..e1ddcdc3540e56 100644 --- a/src/common/transformations/src/transformations/smart_reshape/smart_reshape.cpp +++ b/src/common/transformations/src/transformations/smart_reshape/smart_reshape.cpp @@ -21,7 +21,7 @@ bool ov::pass::SmartReshape::run_on_model(const std::shared_ptr& 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(); static_manager.register_pass(); @@ -37,7 +37,7 @@ bool ov::pass::SmartReshape::run_on_model(const std::shared_ptr& f) { static_manager.register_pass(); 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); diff --git a/src/common/transformations/src/transformations/symbolic_transformations/symbolic_optimizations.cpp b/src/common/transformations/src/transformations/symbolic_transformations/symbolic_optimizations.cpp index 197644ffca6d84..d6629f326a2a70 100644 --- a/src/common/transformations/src/transformations/symbolic_transformations/symbolic_optimizations.cpp +++ b/src/common/transformations/src/transformations/symbolic_transformations/symbolic_optimizations.cpp @@ -172,7 +172,7 @@ ov::pass::LabelResolvingThroughSelect::LabelResolvingThroughSelect() { } ov::pass::SymbolicOptimizations::SymbolicOptimizations(bool full_run) { - m_manager = std::make_shared(); + m_manager = std::make_shared("Symbolic"); m_manager->set_per_pass_validation(false); #define REGISTER_SYMBOLIC(region, ...) m_manager->register_pass(__VA_ARGS__); diff --git a/src/core/include/openvino/pass/manager.hpp b/src/core/include/openvino/pass/manager.hpp index 8ca9ce354eeb5c..a026957697f2db 100644 --- a/src/core/include/openvino/pass/manager.hpp +++ b/src/core/include/openvino/pass/manager.hpp @@ -23,8 +23,11 @@ class OPENVINO_API Manager { Manager(); virtual ~Manager(); + //// \brief Construct Manager with a provided name. + explicit Manager(std::string name); + //// \brief Construct Manager with shared PassConfig instance - explicit Manager(std::shared_ptr pass_config); + explicit Manager(std::shared_ptr pass_config, std::string name = "UnnamedManager"); /// \brief Register given transformation class type to execution list /// Example below show the basic usage of pass::Manager @@ -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); + bool run_passes(const std::shared_ptr& model); - 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 @@ -97,8 +97,11 @@ class OPENVINO_API Manager { std::shared_ptr m_pass_config; std::vector> 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& pass, const std::shared_ptr& model, bool needs_validate); }; } // namespace pass } // namespace ov diff --git a/src/core/src/graph_util.cpp b/src/core/src/graph_util.cpp index fa36c61cb38d84..17780f7751d52e 100644 --- a/src/core/src/graph_util.cpp +++ b/src/core/src/graph_util.cpp @@ -326,7 +326,7 @@ void serialize(const std::shared_ptr& 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(xml_path, bin_path, version); manager.run_passes(std::const_pointer_cast(m)); } @@ -339,7 +339,7 @@ void save_model(const std::shared_ptr& 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(); manager.register_pass(output_model, ""); manager.run_passes(std::move(cloned)); diff --git a/src/core/src/model.cpp b/src/core/src/model.cpp index 88609222885f05..1493d950cd78ef 100644 --- a/src/core/src/model.cpp +++ b/src/core/src/model.cpp @@ -870,7 +870,7 @@ void ov::Model::reshape(const std::map, ov::PartialShape>& }; try { - ov::pass::Manager ssr_manager; + ov::pass::Manager ssr_manager("SmartReshape"); ssr_manager.register_pass(); ssr_manager.run_passes(shared_from_this()); diff --git a/src/core/src/pass/convert_fp32_to_fp16.cpp b/src/core/src/pass/convert_fp32_to_fp16.cpp index 4ccd024e1cf830..aab1180ff47dfb 100644 --- a/src/core/src/pass/convert_fp32_to_fp16.cpp +++ b/src/core/src/pass/convert_fp32_to_fp16.cpp @@ -10,7 +10,7 @@ bool ov::pass::ConvertFP32ToFP16::run_on_model(const std::shared_ptr& f) { RUN_ON_MODEL_SCOPE(ConvertFP32ToFP16); - ov::pass::Manager m(get_pass_config()); + ov::pass::Manager m(get_pass_config(), "ConvertFP32ToFP16"); m.register_pass(precisions_map{{ov::element::f32, ov::element::f16}}); m.run_passes(f); return false; diff --git a/src/core/src/pass/manager.cpp b/src/core/src/pass/manager.cpp index 13404562a4318d..4b01c09a077bde 100644 --- a/src/core/src/pass/manager.cpp +++ b/src/core/src/pass/manager.cpp @@ -5,15 +5,18 @@ #include "openvino/pass/manager.hpp" #include +#include #include #include #include #include #include +#include #include "itt.hpp" #include "openvino/pass/graph_rewrite.hpp" #include "openvino/pass/visualize_tree.hpp" +#include "openvino/util/common_util.hpp" #include "openvino/util/env_util.hpp" #include "openvino/util/log.hpp" #include "perf_counters.hpp" @@ -36,35 +39,73 @@ PerfCounters& perf_counters() { #endif // ENABLE_PROFILING_ITT namespace { -bool getenv_visualize_tracing() { - return ov::util::getenv_bool("OV_ENABLE_VISUALIZE_TRACING"); -} -} // namespace -ov::pass::Manager::Manager() : m_pass_config(std::make_shared()), m_visualize(getenv_visualize_tracing()) {} +/** + * @brief EnvVar gets the environment variable value by name. + * It tries to interpret the value as boolean, if it fails then + * the original string value is stored. This behavior helps us to reduce the number + * of the additional env variables. + * + * Example of usage: + * if OV_ENABLE_PROFILE_PASS is true, it enables console output. + * if OV_ENABLE_PROFILE_PASS contains a path to file (string), the out logs + * will be re-directed to the file. + */ +class EnvVar { +public: + explicit EnvVar(const std::string& var) { + const auto& val = ov::util::getenv_string(var.c_str()); + std::set off = {"0", "false", "off"}; + std::set on = {"1", "true", "on"}; -ov::pass::Manager::~Manager() = default; + const auto& val_lower = ov::util::to_lower(var); + if (off.count(val_lower)) { + m_is_bool = true; + } else if (on.count(val_lower)) { + m_is_bool = true; + b_value = true; + } else { + s_value = val; + } + } -ov::pass::Manager::Manager(std::shared_ptr pass_config) - : m_pass_config(std::move(pass_config)), - m_visualize(getenv_visualize_tracing()) {} + /** + * @brief This ctor helps to activate/deactivate EnvVar from the code. + */ + explicit EnvVar(const std::string& var, bool activate) { + m_is_bool = true; + b_value = activate; + } -void ov::pass::Manager::set_per_pass_validation(bool new_state) { - m_per_pass_validation = new_state; -} + bool is_enabled() const { + return b_value || !s_value.empty(); + } + + bool is_bool() const { + return m_is_bool; + } + + const std::string& get_str() const { + return s_value; + } + +private: + bool m_is_bool = false; + bool b_value = false; + std::string s_value; +}; -namespace { class stopwatch { public: void start() { - if (m_active == false) { + if (!m_active) { m_active = true; m_start_time = m_clock.now(); } } void stop() { - if (m_active == true) { + if (m_active) { auto end_time = m_clock.now(); m_last_time = end_time - m_start_time; m_active = false; @@ -89,89 +130,184 @@ class stopwatch { bool m_active = false; std::chrono::nanoseconds m_last_time = std::chrono::high_resolution_clock::duration::zero(); }; -} // namespace -bool ov::pass::Manager::run_passes(shared_ptr func) { - OV_ITT_SCOPED_TASK(ov::itt::domains::core, "pass::Manager::run_passes"); - - static bool profile_enabled = ov::util::getenv_bool("OV_PROFILE_PASS_ENABLE"); - - size_t index = 0; - stopwatch pass_timer; - stopwatch overall_timer; - overall_timer.start(); - bool pass_applied = false; - bool function_changed = false; - bool needs_validate = false; - for (auto& pass : m_pass_list) { - if (m_pass_config->is_disabled(pass->get_type_info())) { - OPENVINO_DEBUG("Pass ", pass->get_name(), " is disabled"); - continue; +class Profiler { +public: + explicit Profiler(std::string manager_name) + : m_visualize("OV_ENABLE_VISUALIZE_TRACING"), + m_serialize("OV_ENABLE_SERIALIZE_TRACING"), + m_profile_pass("OV_ENABLE_PROFILE_PASS"), + m_manager_name(std::move(manager_name)) { + if (m_profile_pass.is_enabled() && !m_profile_pass.is_bool()) { + m_file.open(m_profile_pass.get_str(), std::ios_base::app); } + } - OV_ITT_SCOPE(FIRST_INFERENCE, ov::itt::domains::ov_pass, ov::pass::perf_counters()[pass->get_type_info()]); + ~Profiler() { + if (m_file.is_open()) { + m_file.close(); + } + } - pass_timer.start(); + void start_timer(const std::string& name) { + if (m_profile_pass.is_enabled()) { + stopwatches[name] = stopwatch(); + stopwatches[name].start(); - if (auto matcher_pass = dynamic_pointer_cast(pass)) { - // This checks is to skip the graph transformation when the graph pass relies on - // static shape but the function state is dynamic. - if (matcher_pass->get_property(PassProperty::REQUIRE_STATIC_SHAPE) && func->is_dynamic()) { - OPENVINO_DEBUG("Pass ", - pass->get_name(), - " requires static shape but the " - "model is dynamic. Skipping this transformation"); - continue; - } - // GraphRewrite is a temporary container for MatcherPass to make execution - // on on entire ov::Model - pass_applied = GraphRewrite(matcher_pass).run_on_model(func); - } else if (auto function_pass = dynamic_pointer_cast(pass)) { - // This checks is to skip the graph transformation when the graph pass relies on - // static shape but the function state is dynamic. - if (function_pass->get_property(PassProperty::REQUIRE_STATIC_SHAPE) && func->is_dynamic()) { - OPENVINO_DEBUG("Pass ", - pass->get_name(), - " requires static shape but the " - "model is dynamic. Skipping this transformation"); - continue; + bool is_pass_manager = name == m_manager_name; + if (is_pass_manager) { + std::cout << std::setw(25) << left; + std::cout << "PassManager started: " << m_manager_name << std::endl; } + } + } + + void stop_timer(const std::string& name, bool applied) { + if (m_profile_pass.is_enabled()) { + auto& stopwatch = stopwatches.at(name); + stopwatch.stop(); - if (dynamic_pointer_cast(pass)) { - if (needs_validate) { - function_pass->run_on_model(func); - needs_validate = false; + bool is_pass_manager = name == m_manager_name; + if (m_profile_pass.is_bool()) { + std::cout << std::setw(25) << left; + if (is_pass_manager) { + std::cout << "PassManager finished: "; + } else { + std::cout << " "; + } + std::cout << std::setw(60) << left << name; + std::cout << std::setw(5) << right << stopwatch.get_milliseconds() << "ms " << (applied ? "+" : "-") + << std::endl; + } else if (m_file.is_open()) { + if (is_pass_manager) { + m_file << "m;" << name << ";" << stopwatch.get_timer_value().count() << ";" << (applied ? "1" : "0") + << std::endl; + } else { + m_file << "t;" << name << ";" << m_manager_name << ";" << stopwatch.get_timer_value().count() << ";" + << (applied ? "1" : "0") << std::endl; } } else { - pass_applied = function_pass->run_on_model(func); + OPENVINO_THROW("The output file for logging transformation statistics is closed. " + "Recording of statistics is not possible."); } } + } - if (m_visualize) { - // visualizations and serializations will be named after the outermost function - const size_t num_digits_in_pass_index = 3; - std::string index_str = std::to_string(index); - index_str = std::string(num_digits_in_pass_index - index_str.length(), '0') + index_str; - auto base_filename = func->get_name() + std::string("_") + index_str + std::string("_") + pass->get_name(); - - if (m_visualize) { - auto file_ext = "svg"; - pass::VisualizeTree vt(base_filename + std::string(".") + file_ext); - vt.run_on_model(func); + void visualize(const shared_ptr& model, const std::string& pass_name) const { + static size_t viz_index = 0; + if (m_visualize.is_enabled()) { + const auto& filter = m_visualize.get_str(); + if (m_visualize.is_bool() || (pass_name.find(filter) != std::string::npos)) { + const auto& file_name = gen_file_name(model->get_name(), pass_name, viz_index++); + ov::pass::VisualizeTree vt(file_name + ".svg"); + vt.run_on_model(model); } } - index++; - pass_timer.stop(); - if (profile_enabled) { - cout << setw(7) << pass_timer.get_milliseconds() << "ms" << (pass_applied ? " + " : " ") - << pass->get_name() << "\n"; + } + + void serialize(const shared_ptr& model, const std::string& pass_name) const { + static size_t serialize_index = 0; + if (m_serialize.is_enabled()) { + const auto& filter = m_serialize.get_str(); + if (m_serialize.is_bool() || (pass_name.find(filter) != std::string::npos)) { + const auto& file_name = gen_file_name(model->get_name(), pass_name, serialize_index++); + ov::pass::Serialize serialize(file_name + ".xml", file_name + ".bin"); + serialize.run_on_model(model); + } } - function_changed = function_changed || pass_applied; - needs_validate = pass_applied; } - if (profile_enabled) { - cout << "passes done in " << overall_timer.get_milliseconds() << "ms\n"; + +private: + static std::string gen_file_name(const std::string& model_name, const std::string& pass_name, const size_t idx) { + std::stringstream name; + // visualizations and serializations will be named after the outermost function + const size_t num_digits_in_pass_index = 3; + std::string index_str = std::to_string(idx); + index_str = std::string(num_digits_in_pass_index - index_str.length(), '0') + index_str; + + name << model_name << std::string("_") << index_str << std::string("_") << pass_name; + return name.str(); } - return function_changed; + std::unordered_map stopwatches; + + EnvVar m_visualize; + EnvVar m_serialize; + EnvVar m_profile_pass; + + std::string m_manager_name; + std::fstream m_file; +}; + +} // namespace + +ov::pass::Manager::Manager() : m_pass_config(std::make_shared()) {} + +ov::pass::Manager::~Manager() = default; + +ov::pass::Manager::Manager(std::string name) : m_pass_config(std::make_shared()), m_name(std::move(name)) {} + +ov::pass::Manager::Manager(std::shared_ptr pass_config, std::string name) + : m_pass_config(std::move(pass_config)), + m_name(std::move(name)) {} + +void ov::pass::Manager::set_per_pass_validation(bool new_state) { + m_per_pass_validation = new_state; +} + +bool ov::pass::Manager::run_passes(const shared_ptr& model) { + OV_ITT_SCOPED_TASK(ov::itt::domains::core, "pass::Manager::run_passes"); + Profiler profiler(m_name); + + bool model_changed = false; + bool pass_changed_model = false; + + profiler.start_timer(m_name); + for (const auto& pass : m_pass_list) { + const auto& pass_name = pass->get_name(); + + profiler.start_timer(pass_name); + pass_changed_model = run_pass(pass, model, pass_changed_model); + profiler.stop_timer(pass_name, pass_changed_model); + + model_changed = model_changed || pass_changed_model; + + profiler.visualize(model, pass_name); + profiler.serialize(model, pass_name); + } + profiler.stop_timer(m_name, model_changed); + + return model_changed; +} + +bool ov::pass::Manager::run_pass(const std::shared_ptr& pass, + const std::shared_ptr& model, + bool needs_validate) { + if (m_pass_config->is_disabled(pass->get_type_info())) { + OPENVINO_DEBUG("Pass ", pass->get_name(), " is disabled."); + return false; + } + + // This checks if we need to skip the graph transformation when the graph pass relies on + // static shape but the model state is dynamic. + if (pass->get_property(PassProperty::REQUIRE_STATIC_SHAPE) && model->is_dynamic()) { + OPENVINO_DEBUG("Pass ", + pass->get_name(), + " requires static shape but the ", + "model is dynamic. Skipping this transformation."); + return false; + } + + OV_ITT_SCOPE(FIRST_INFERENCE, ov::itt::domains::ov_pass, ov::pass::perf_counters()[pass->get_type_info()]); + + if (auto matcher_pass = dynamic_pointer_cast(pass)) { + // GraphRewrite is a temporary container for MatcherPass to make execution on entire ov::Model + return GraphRewrite(matcher_pass).run_on_model(model); + } else if (auto model_pass = dynamic_pointer_cast(pass)) { + if (dynamic_pointer_cast(model_pass) && !needs_validate) { + return false; + } + return model_pass->run_on_model(model); + } + return false; } diff --git a/src/core/src/pass/sdpa_to_paged_attention.cpp b/src/core/src/pass/sdpa_to_paged_attention.cpp index 8630fbefe728ec..8b19b07f2f5d76 100644 --- a/src/core/src/pass/sdpa_to_paged_attention.cpp +++ b/src/core/src/pass/sdpa_to_paged_attention.cpp @@ -101,7 +101,7 @@ bool ov::pass::SDPAToPagedAttention::run_on_model(const std::shared_ptr(position_ids); // it is not always required, so will be disposed if not needed - ov::pass::Manager manager; + ov::pass::Manager manager("SDPA to PA"); manager.set_per_pass_validation(false); manager.register_pass(kv_parameters, model_remaining_params, diff --git a/src/frontends/ir/src/frontend.cpp b/src/frontends/ir/src/frontend.cpp index 74553520410cda..b8e92e8b37b291 100644 --- a/src/frontends/ir/src/frontend.cpp +++ b/src/frontends/ir/src/frontend.cpp @@ -252,7 +252,7 @@ std::string FrontEnd::get_name() const { } void FrontEnd::normalize(const std::shared_ptr& model) const { - ov::pass::Manager manager; + ov::pass::Manager manager("Frontend:IR:normalize"); manager.register_pass(); manager.run_passes(model); } diff --git a/src/frontends/onnx/frontend/src/frontend.cpp b/src/frontends/onnx/frontend/src/frontend.cpp index 529869a7d936d0..d4b83fee20db82 100644 --- a/src/frontends/onnx/frontend/src/frontend.cpp +++ b/src/frontends/onnx/frontend/src/frontend.cpp @@ -93,7 +93,7 @@ std::shared_ptr FrontEnd::convert_partially(const InputModel::Ptr& in if (!m_transformation_extensions.empty()) { auto model = decode(input_model); - ov::pass::Manager manager; + ov::pass::Manager manager("Frontend:ONNX:convert_partially"); for (const auto& transformation : m_transformation_extensions) { transformation->register_pass(manager); } @@ -113,7 +113,7 @@ std::shared_ptr FrontEnd::convert_partially(const InputModel::Ptr& in void FrontEnd::normalize(const std::shared_ptr& model) const { // Here, you can register transformations as a second step of importing process // In particular, you can operate on not supported ops (it allows to N:N ONNX->OV mapping). - ov::pass::Manager manager; + ov::pass::Manager manager("Frontend:ONNX:normalize"); manager.register_pass(true); manager.run_passes(model); } @@ -125,7 +125,7 @@ std::shared_ptr FrontEnd::convert(const InputModel::Ptr& input_model) if (!m_transformation_extensions.empty()) { auto model = decode(input_model); - ov::pass::Manager manager; + ov::pass::Manager manager("Frontend:ONNX:convert"); for (const auto& transformation : m_transformation_extensions) { transformation->register_pass(manager); } diff --git a/src/frontends/paddle/src/frontend.cpp b/src/frontends/paddle/src/frontend.cpp index 0b6ab0d4eef331..c6febe08437b5d 100644 --- a/src/frontends/paddle/src/frontend.cpp +++ b/src/frontends/paddle/src/frontend.cpp @@ -343,7 +343,7 @@ std::map> FrontEnd::convert_each_node_recurs void FrontEnd::try_remove_internal_ops(const std::vector>& models) const { for (auto& model : models) { - ov::pass::Manager manager; + ov::pass::Manager manager("Frontend:Paddle:try_remove_internal_ops"); manager.register_pass(models); manager.register_pass(models); manager.register_pass(models); @@ -357,7 +357,7 @@ void FrontEnd::try_remove_internal_ops(const std::vector> void FrontEnd::fuse_fakequantize_ops(const std::vector>& models) const { for (auto& model : models) { - ov::pass::Manager manager; + ov::pass::Manager manager("Frontend:Paddle:fuse_fakequantize_ops"); manager.register_pass(); manager.run_passes(model); } @@ -506,7 +506,7 @@ std::shared_ptr FrontEnd::convert_partially(const InputModel::Ptr& mo if (!m_transformation_extensions.empty()) { auto function = decode(model); - ov::pass::Manager manager; + ov::pass::Manager manager("Frontend:Paddle:convert_partially"); for (const auto& transformation : m_transformation_extensions) { transformation->register_pass(manager); } @@ -572,7 +572,7 @@ void FrontEnd::add_extension(const std::shared_ptr& extension) { } void FrontEnd::normalize(const std::shared_ptr& model) const { - ov::pass::Manager manager; + ov::pass::Manager manager("Frontend:Paddle:normalize"); manager.register_pass(true); manager.run_passes(model); } diff --git a/src/frontends/pytorch/src/frontend.cpp b/src/frontends/pytorch/src/frontend.cpp index 7e63f3c4aeb456..2cbb5c4d6bc96e 100644 --- a/src/frontends/pytorch/src/frontend.cpp +++ b/src/frontends/pytorch/src/frontend.cpp @@ -240,7 +240,7 @@ std::shared_ptr FrontEnd::decode(const InputModel::Ptr& model) const { } void FrontEnd::normalize(const std::shared_ptr& model) const { - ov::pass::Manager manager; + ov::pass::Manager manager("Frontend:Pytorch:normalize"); // GPTQ transformations need to be executed before other passes // Once the GPTQ patterns are modified by other transformations, diff --git a/src/frontends/tensorflow/src/frontend.cpp b/src/frontends/tensorflow/src/frontend.cpp index e2e49355e914f0..aac5811223e135 100644 --- a/src/frontends/tensorflow/src/frontend.cpp +++ b/src/frontends/tensorflow/src/frontend.cpp @@ -488,7 +488,7 @@ std::shared_ptr FrontEnd::convert_partially(const ov::frontend::Input if (!m_transformation_extensions.empty()) { auto function = decode(model); - ov::pass::Manager manager; + ov::pass::Manager manager("Frontend:TF:convert_partially"); for (const auto& transformation : m_transformation_extensions) { transformation->register_pass(manager); } @@ -557,7 +557,7 @@ void FrontEnd::convert(const std::shared_ptr& partiallyConverted) con } void FrontEnd::normalize(const std::shared_ptr& model) const { - ov::pass::Manager manager; + ov::pass::Manager manager("Frontend:TF:normalize"); // Mark quantized and f16/bf16 compressed constants to prevent CF for them, // so that not extra memory is used for intermediate decompressed constants. diff --git a/src/frontends/tensorflow_lite/src/frontend.cpp b/src/frontends/tensorflow_lite/src/frontend.cpp index 62d75d9c2513c6..15e89301983811 100644 --- a/src/frontends/tensorflow_lite/src/frontend.cpp +++ b/src/frontends/tensorflow_lite/src/frontend.cpp @@ -111,7 +111,7 @@ std::shared_ptr FrontEnd::convert(const ov::frontend::InputModel::Ptr if (!m_transformation_extensions.empty()) { auto ov_model = decode(model); - ov::pass::Manager manager; + ov::pass::Manager manager("Frontend:TFLite:convert"); for (const auto& transformation : m_transformation_extensions) { transformation->register_pass(manager); } @@ -153,7 +153,7 @@ void FrontEnd::convert(const std::shared_ptr& partiallyConverted) con std::shared_ptr FrontEnd::convert_partially(const ov::frontend::InputModel::Ptr& model) const { if (!m_transformation_extensions.empty()) { auto function = decode(model); - ov::pass::Manager manager; + ov::pass::Manager manager("Frontend:TFLite:convert_partially"); for (const auto& transformation : m_transformation_extensions) { transformation->register_pass(manager); } @@ -293,7 +293,7 @@ std::shared_ptr FrontEnd::decode(const InputModel::Ptr& model) const } void FrontEnd::normalize(const std::shared_ptr& function) const { - ov::pass::Manager manager; + ov::pass::Manager manager("Frontend:TFLite:normalize"); // Mark quantized and f16/bf16 compressed constants to prevent CF for them, // so that not extra memory is used for intermediate decompressed constants. manager.register_pass(); diff --git a/src/frontends/tensorflow_lite/src/tflite_transformations/tflite_quantize_resolver.cpp b/src/frontends/tensorflow_lite/src/tflite_transformations/tflite_quantize_resolver.cpp index aa38ed72d839e5..ffa8438817bb77 100644 --- a/src/frontends/tensorflow_lite/src/tflite_transformations/tflite_quantize_resolver.cpp +++ b/src/frontends/tensorflow_lite/src/tflite_transformations/tflite_quantize_resolver.cpp @@ -198,7 +198,7 @@ pass::TFLQuantizeReplacer::TFLQuantizeReplacer() { } bool pass::TFLQuantizeResolver::run_on_model(const std::shared_ptr& m) { - ov::pass::Manager manager; + ov::pass::Manager manager("Frontend:TFLite:TFLQuantizeResolver"); manager.register_pass(); manager.register_pass(); manager.run_passes(m); diff --git a/src/plugins/auto_batch/src/plugin.cpp b/src/plugins/auto_batch/src/plugin.cpp index d97987bea6f39a..2e3e17cd43086d 100644 --- a/src/plugins/auto_batch/src/plugin.cpp +++ b/src/plugins/auto_batch/src/plugin.cpp @@ -162,7 +162,7 @@ std::shared_ptr Plugin::compile_model(const std::shared_ptr< const bool check_dims = (enable_tput_plugin || enable_tput_cfg); // find the batch dim auto cloned_model = model->clone(); - ov::pass::Manager pass_manager; + ov::pass::Manager pass_manager("Plugin:AutoBatch"); pass_manager.register_pass(); pass_manager.register_pass(false, check_dims); pass_manager.run_passes(cloned_model); diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/convert_to_cpu_specific_opset.hpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/convert_to_cpu_specific_opset.hpp index 934a86bbc8b30e..8667f85e380449 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/convert_to_cpu_specific_opset.hpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/convert_to_cpu_specific_opset.hpp @@ -29,7 +29,7 @@ namespace intel_cpu { inline void ConvertToCPUSpecificOpset(std::shared_ptr &nGraphFunc, int subStreamNum) { RUN_ON_FUNCTION_SCOPE(ConvertToCPUSpecificOpset); - ov::pass::Manager manager; + ov::pass::Manager manager("CPU:ConvertToCPUSpecificOpset"); manager.set_per_pass_validation(false); CPU_REGISTER_PASS_COMMON(manager, ConvertMatMulToFC); CPU_REGISTER_PASS_X64(manager, MoveFCReshapeToWeights); diff --git a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp index e8ac0bbd9748ad..cd8ce3062c815b 100644 --- a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp +++ b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp @@ -307,7 +307,7 @@ void Transformations::PreLpt(const std::vector& defaultPrecis // Decompression handling related transformations must be run separately from common preLPT pipeline // since there is used the same transformations as in LPT related transformations, but with the specific settings. // This must be done in order to keep compressed MatMul weights with decompression operations as is - ov::pass::Manager decompression_handling_manager; + ov::pass::Manager decompression_handling_manager("CPU:DecompressionHandling"); decompression_handling_manager.set_per_pass_validation(false); CPU_REGISTER_PASS_COMMON(decompression_handling_manager, ov::pass::InitNodeInfo); const bool useLpt = !defaultPrecisions.empty(); @@ -346,7 +346,7 @@ void Transformations::PreLpt(const std::vector& defaultPrecis ov::pass::ConvertGatherToGatherCompressed); decompression_handling_manager.run_passes(model); - ov::pass::Manager manager; + ov::pass::Manager manager("Plugin:CPU"); manager.set_per_pass_validation(false); if (useLpt) CPU_REGISTER_PASS_COMMON(manager, ov::pass::MarkDequantizationSubgraph, defaultPrecisions); @@ -732,7 +732,7 @@ void Transformations::Lpt(const std::vector& defaultPrecision QuantizationGranularityRestriction::create({0}) }); - ov::pass::Manager lptManager; + ov::pass::Manager lptManager("CPU:LPT"); CPU_REGISTER_PASS_COMMON(lptManager, LowPrecision, supportedPrecisions, quantizationRestrictions, @@ -781,7 +781,7 @@ void Transformations::Lpt(const std::vector& defaultPrecision void Transformations::PostLpt() { CPU_DEBUG_CAP_TRANSFORMATION_SCOPE(this, PostLpt); - ov::pass::Manager postLPTPassManager; + ov::pass::Manager postLPTPassManager("CPU:PostLPT"); postLPTPassManager.set_per_pass_validation(false); CPU_REGISTER_PASS_COMMON(postLPTPassManager, ov::pass::UnrollTensorIterator); CPU_REGISTER_PASS_COMMON(postLPTPassManager, ov::pass::ReshapePRelu); @@ -904,7 +904,7 @@ void Transformations::MainSnippets(void) { mha_token_enable_transpose_on_output, is_dynamic_mha_token_enabled, mha_supported_transpose_ranks); - ov::pass::Manager snippetsManager; + ov::pass::Manager snippetsManager("CPU:Snippets"); snippetsManager.set_per_pass_validation(false); if (!ignoreCallback) { #if defined(OPENVINO_ARCH_ARM64) @@ -1106,7 +1106,7 @@ void Transformations::MainSnippets(void) { } void Transformations::PostSnippets(void) { - ov::pass::Manager postSnippetsManager; + ov::pass::Manager postSnippetsManager("CPU:PostSnippets"); postSnippetsManager.set_per_pass_validation(false); CPU_REGISTER_PASS_COMMON(postSnippetsManager, ov::pass::FakeQuantizeDecomposition); CPU_SET_CALLBACK_COMMON(postSnippetsManager, diff --git a/src/plugins/intel_gpu/src/plugin/transformations/convert_convolution.cpp b/src/plugins/intel_gpu/src/plugin/transformations/convert_convolution.cpp index 6a61eae3ed4996..656b4c6fd99c20 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/convert_convolution.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/convert_convolution.cpp @@ -227,7 +227,7 @@ ConvolutionMatcher::ConvolutionMatcher() { } bool ConvertConvolutionToInternal::run_on_model(const std::shared_ptr& m) { - ov::pass::Manager manager; + ov::pass::Manager manager("ConvertConvolutionToInternal"); auto pass_config = manager.get_pass_config(); manager.set_per_pass_validation(false); manager.register_pass(); diff --git a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp index dbe7e858c1e6fe..e99d3851974629 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp @@ -208,7 +208,7 @@ void TransformationsPipeline::apply(std::shared_ptr func) { bool enableInt8; bool unroll_loop = config.get_property(ov::intel_gpu::enable_loop_unrolling); { - ov::pass::Manager manager; + ov::pass::Manager manager("Plugin:GPU"); auto pass_config = manager.get_pass_config(); manager.set_per_pass_validation(false); @@ -667,7 +667,7 @@ void TransformationsPipeline::apply(std::shared_ptr func) { QuantizationGranularityRestriction::create({0}), }); - ov::pass::Manager lptManager; + ov::pass::Manager lptManager("GPU:LPT"); auto lptPassConfig = lptManager.get_pass_config(); // quantized LSTMSequence / GPUSequence are not supported yet. Avoid extra transformation @@ -756,7 +756,7 @@ void TransformationsPipeline::apply(std::shared_ptr func) { { OV_ITT_SCOPED_TASK(itt::domains::intel_gpu_plugin, "TransformationsPipeline::apply::run_passes"); - ov::pass::Manager manager; + ov::pass::Manager manager("GPU:UnrollTensorIterator"); // This ConstantFolding pass is added to fold reshapes added for constant inputs on NMS internal operation which prevents upper-bound calculation // TODO: check why we have these reshapes manager.register_pass(); @@ -776,7 +776,7 @@ void TransformationsPipeline::apply(std::shared_ptr func) { } { - ov::pass::Manager manager; + ov::pass::Manager manager("GPU:PostLPT"); // Other ops support eltwise fusions const std::vector allowed_data_movement_ops = { diff --git a/src/plugins/intel_npu/src/compiler/src/graph_transformations.cpp b/src/plugins/intel_npu/src/compiler/src/graph_transformations.cpp index c0881d75cd7be9..cc9655a38dd3ff 100644 --- a/src/plugins/intel_npu/src/compiler/src/graph_transformations.cpp +++ b/src/plugins/intel_npu/src/compiler/src/graph_transformations.cpp @@ -33,7 +33,7 @@ IRSerializer::IRSerializer(const std::shared_ptr& origModel, co void IRSerializer::serializeModelToStream(std::ostream& xml, std::ostream& weights) { _logger.debug("serializeModelToStream"); const auto passConfig = std::make_shared(); - ov::pass::Manager manager(passConfig); + ov::pass::Manager manager(passConfig, "NPU:serializeModelToStream"); if (_supportedOpset < 11) { // Downgrade to opset10 diff --git a/src/plugins/template/src/plugin.cpp b/src/plugins/template/src/plugin.cpp index b0abb1c232e52b..ee885f67e188b5 100644 --- a/src/plugins/template/src/plugin.cpp +++ b/src/plugins/template/src/plugin.cpp @@ -64,7 +64,7 @@ ov::SoPtr ov::template_plugin::Plugin::get_default_context( // ! [plugin:transform_model] void transform_model(const std::shared_ptr& model) { // Perform common optimizations and device-specific transformations - ov::pass::Manager passManager; + ov::pass::Manager passManager("Plugin:Template"); // Example: register CommonOptimizations transformation from transformations library passManager.register_pass(); // Disable some transformations