diff --git a/src/core/include/ngraph/pass/graph_rewrite.hpp b/src/core/include/ngraph/pass/graph_rewrite.hpp index 7e614214791..2ad255a3f39 100644 --- a/src/core/include/ngraph/pass/graph_rewrite.hpp +++ b/src/core/include/ngraph/pass/graph_rewrite.hpp @@ -6,6 +6,7 @@ #include #include +#include #include #include "ngraph/pass/pass.hpp" @@ -21,6 +22,69 @@ namespace pass { using ov::pass::BackwardGraphRewrite; using ov::pass::GraphRewrite; using ov::pass::MatcherPass; -using ov::pass::RecurrentGraphRewrite; + +class NGRAPH_DEPRECATED("Use MatcherPass or FunctionPass instead.") NGRAPH_API RecurrentGraphRewrite + : public FunctionPass { +public: + RecurrentGraphRewrite(size_t num_iters = 10) : ModelPass(), m_num_iters(num_iters) {} + + void add_matcher(const std::shared_ptr& m, + const ov::recurrent_graph_rewrite_callback& callback, + const PassPropertyMask& property) { + NGRAPH_SUPPRESS_DEPRECATED_START + m_matchers.push_back(std::make_shared( + "Recurrent matcher", + nullptr, + [m, callback](const std::shared_ptr& node) { + NGRAPH_DEBUG << "Running recurrent matcher on " << node; + if (m->match(node->output(0))) { + NGRAPH_DEBUG << "Recurrent matcher matched " << m.get(); + return callback(*m.get()); + } + return false; + }, + property)); + NGRAPH_SUPPRESS_DEPRECATED_END + } + + // TODO: This interface may deprecate after all passes are refactored. + void add_matcher(const std::shared_ptr& m, + const ov::recurrent_graph_rewrite_callback& callback) { + NGRAPH_SUPPRESS_DEPRECATED_START + // TODO: before deprecate this function, by default expect the + // callback require static shape. + add_matcher(m, callback, {PassProperty::REQUIRE_STATIC_SHAPE}); + NGRAPH_SUPPRESS_DEPRECATED_END + } + + bool run_on_model(const std::shared_ptr& m) override { + NGRAPH_SUPPRESS_DEPRECATED_START + bool changed = false; + size_t i = 0; + + auto run_matchers = [&]() -> bool { + for (const auto& node : m->get_ops()) { + for (auto& m_pass : m_matchers) { + if (m_pass->apply(node)) { + return true; + } + } + } + return false; + }; + + do { + changed = run_matchers(); + i++; + } while (changed && i < m_num_iters); + return changed; + NGRAPH_SUPPRESS_DEPRECATED_END + } + +private: + size_t m_num_iters; + + std::vector> m_matchers; +}; } // namespace pass } // namespace ngraph diff --git a/src/core/include/ngraph/pass/pass.hpp b/src/core/include/ngraph/pass/pass.hpp index 614a1b38a7e..7b122e61f38 100644 --- a/src/core/include/ngraph/pass/pass.hpp +++ b/src/core/include/ngraph/pass/pass.hpp @@ -25,8 +25,6 @@ class Manager; namespace ngraph { namespace pass { using FunctionPass = ov::pass::ModelPass; -using ov::pass::FusionType; -using ov::pass::FusionTypeMask; using ov::pass::Manager; using ov::pass::PassBase; using ov::pass::PassProperty; @@ -40,5 +38,20 @@ public: ~NodePass() override; virtual bool run_on_node(std::shared_ptr) = 0; }; + +enum class NGRAPH_DEPRECATED("FusionType is no longer used anywhere. Please do no use it.") FusionType : uint32_t { + //`DIFFERENTIABLE_FUSIONS` produce ops that support autodiff + // i.e. implement `generate_adjoints` + DIFFERENTIABLE_FUSIONS = 0x1, + REGULAR_FUSIONS = 0x2, + //`FOP_FUSIONS` produce ops in the FusedOps category that might + // not be supported by all backends + FOP_FUSIONS = 0x4, + ALL_FUSIONS = 0xFFFFFFFF +}; + +NGRAPH_SUPPRESS_DEPRECATED_START +using FusionTypeMask = ov::EnumMask; +NGRAPH_SUPPRESS_DEPRECATED_END } // namespace pass } // namespace ngraph diff --git a/src/core/include/openvino/pass/graph_rewrite.hpp b/src/core/include/openvino/pass/graph_rewrite.hpp index c5781b68d38..a070504ef4d 100644 --- a/src/core/include/openvino/pass/graph_rewrite.hpp +++ b/src/core/include/openvino/pass/graph_rewrite.hpp @@ -225,25 +225,5 @@ public: bool run_on_model(const std::shared_ptr& m) override; }; - -class OPENVINO_API RecurrentGraphRewrite : public ModelPass { -public: - RecurrentGraphRewrite(size_t num_iters = 10) : ModelPass(), m_num_iters(num_iters) {} - - void add_matcher(const std::shared_ptr& m, - const ov::recurrent_graph_rewrite_callback& callback, - const PassPropertyMask& property); - - // TODO: This interface may deprecate after all passes are refactored. - void add_matcher(const std::shared_ptr& m, - const ov::recurrent_graph_rewrite_callback& callback); - - bool run_on_model(const std::shared_ptr& m) override; - -private: - size_t m_num_iters; - - std::vector> m_matchers; -}; } // namespace pass } // namespace ov diff --git a/src/core/include/openvino/pass/pass.hpp b/src/core/include/openvino/pass/pass.hpp index e1ace55fa96..c7028419511 100644 --- a/src/core/include/openvino/pass/pass.hpp +++ b/src/core/include/openvino/pass/pass.hpp @@ -100,17 +100,5 @@ private: bool call_on_model{false}; }; -class Manager; -enum class FusionType : uint32_t { - //`DIFFERENTIABLE_FUSIONS` produce ops that support autodiff - // i.e. implement `generate_adjoints` - DIFFERENTIABLE_FUSIONS = 0x1, - REGULAR_FUSIONS = 0x2, - //`FOP_FUSIONS` produce ops in the FusedOps category that might - // not be supported by all backends - FOP_FUSIONS = 0x4, - ALL_FUSIONS = 0xFFFFFFFF -}; -using FusionTypeMask = ov::EnumMask; } // namespace pass } // namespace ov diff --git a/src/core/src/pass/graph_rewrite.cpp b/src/core/src/pass/graph_rewrite.cpp index 6527cd260bc..8898f8e3da6 100644 --- a/src/core/src/pass/graph_rewrite.cpp +++ b/src/core/src/pass/graph_rewrite.cpp @@ -288,52 +288,6 @@ void ov::pass::GraphRewrite::set_pass_config(const std::shared_ptr& } } -void ov::pass::RecurrentGraphRewrite::add_matcher(const std::shared_ptr& m, - const ov::recurrent_graph_rewrite_callback& callback, - const PassPropertyMask& property) { - m_matchers.push_back(std::make_shared( - "Recurrent matcher", - nullptr, - [m, callback](const std::shared_ptr& node) { - NGRAPH_DEBUG << "Running recurrent matcher on " << node; - if (m->match(node->output(0))) { - NGRAPH_DEBUG << "Recurrent matcher matched " << m.get(); - return callback(*m.get()); - } - return false; - }, - property)); -} - -void ov::pass::RecurrentGraphRewrite::add_matcher(const std::shared_ptr& m, - const ov::recurrent_graph_rewrite_callback& callback) { - // TODO: before deprecate this function, by default expect the - // callback require static shape. - add_matcher(m, callback, {PassProperty::REQUIRE_STATIC_SHAPE}); -} - -bool ov::pass::RecurrentGraphRewrite::run_on_model(const std::shared_ptr& f) { - bool changed = false; - size_t i = 0; - - auto run_matchers = [&]() -> bool { - for (const auto& node : f->get_ops()) { - for (auto& m_pass : m_matchers) { - if (m_pass->apply(node)) { - return true; - } - } - } - return false; - }; - - do { - changed = run_matchers(); - i++; - } while (changed && i < m_num_iters); - return changed; -} - void ov::pass::MatcherPass::register_matcher(const std::shared_ptr& m, const ov::graph_rewrite_callback& callback, const PassPropertyMask& property) { diff --git a/src/core/tests/models/ir/conv_with_rt_info.xml b/src/core/tests/models/ir/conv_with_rt_info.xml index eeda7abb2bf..8b8933f6c99 100644 --- a/src/core/tests/models/ir/conv_with_rt_info.xml +++ b/src/core/tests/models/ir/conv_with_rt_info.xml @@ -3,8 +3,14 @@ + + + + + + 490 608 1 diff --git a/src/frontends/ir/src/ir_deserializer.cpp b/src/frontends/ir/src/ir_deserializer.cpp index 5e082470a42..4cd2a74701d 100644 --- a/src/frontends/ir/src/ir_deserializer.cpp +++ b/src/frontends/ir/src/ir_deserializer.cpp @@ -755,7 +755,8 @@ std::shared_ptr XmlDeserializer::createNode( IE_THROW() << "Attribute: " << item.name() << " is not recognized as runtime attribute"; } } else { - IE_THROW() << "Attribute: " << item.name() << " is not recognized"; + // As runtime attributes are optional, so we skip attribute if it is unknown to avoid exception + // when loading new IR with new attribute in old IE version. } } }; diff --git a/src/tests/functional/inference_engine/ir_serialization/rt_info_deserialization.cpp b/src/tests/functional/inference_engine/ir_serialization/rt_info_deserialization.cpp index f6269a4d7f2..0f614ae60e7 100644 --- a/src/tests/functional/inference_engine/ir_serialization/rt_info_deserialization.cpp +++ b/src/tests/functional/inference_engine/ir_serialization/rt_info_deserialization.cpp @@ -802,8 +802,8 @@ TEST_F(RTInfoDeserialization, NodeV11MultipleRTKeys) { - - + + @@ -843,7 +843,7 @@ TEST_F(RTInfoDeserialization, NodeV11MultipleRTKeys) { - +