Skip to content

Commit 7090848

Browse files
author
Gleb Kazantaev
authored
Remove deprecated classes from openvino headers (openvinotoolkit#10371)
* Remove deprecated classes from openvino headers * Fix tests
1 parent 0b27fb8 commit 7090848

File tree

8 files changed

+91
-85
lines changed

8 files changed

+91
-85
lines changed

src/core/include/ngraph/pass/graph_rewrite.hpp

+65-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <functional>
88
#include <memory>
9+
#include <ngraph/log.hpp>
910
#include <set>
1011

1112
#include "ngraph/pass/pass.hpp"
@@ -21,6 +22,69 @@ namespace pass {
2122
using ov::pass::BackwardGraphRewrite;
2223
using ov::pass::GraphRewrite;
2324
using ov::pass::MatcherPass;
24-
using ov::pass::RecurrentGraphRewrite;
25+
26+
class NGRAPH_DEPRECATED("Use MatcherPass or FunctionPass instead.") NGRAPH_API RecurrentGraphRewrite
27+
: public FunctionPass {
28+
public:
29+
RecurrentGraphRewrite(size_t num_iters = 10) : ModelPass(), m_num_iters(num_iters) {}
30+
31+
void add_matcher(const std::shared_ptr<pattern::RecurrentMatcher>& m,
32+
const ov::recurrent_graph_rewrite_callback& callback,
33+
const PassPropertyMask& property) {
34+
NGRAPH_SUPPRESS_DEPRECATED_START
35+
m_matchers.push_back(std::make_shared<MatcherPass>(
36+
"Recurrent matcher",
37+
nullptr,
38+
[m, callback](const std::shared_ptr<Node>& node) {
39+
NGRAPH_DEBUG << "Running recurrent matcher on " << node;
40+
if (m->match(node->output(0))) {
41+
NGRAPH_DEBUG << "Recurrent matcher matched " << m.get();
42+
return callback(*m.get());
43+
}
44+
return false;
45+
},
46+
property));
47+
NGRAPH_SUPPRESS_DEPRECATED_END
48+
}
49+
50+
// TODO: This interface may deprecate after all passes are refactored.
51+
void add_matcher(const std::shared_ptr<pattern::RecurrentMatcher>& m,
52+
const ov::recurrent_graph_rewrite_callback& callback) {
53+
NGRAPH_SUPPRESS_DEPRECATED_START
54+
// TODO: before deprecate this function, by default expect the
55+
// callback require static shape.
56+
add_matcher(m, callback, {PassProperty::REQUIRE_STATIC_SHAPE});
57+
NGRAPH_SUPPRESS_DEPRECATED_END
58+
}
59+
60+
bool run_on_model(const std::shared_ptr<ov::Model>& m) override {
61+
NGRAPH_SUPPRESS_DEPRECATED_START
62+
bool changed = false;
63+
size_t i = 0;
64+
65+
auto run_matchers = [&]() -> bool {
66+
for (const auto& node : m->get_ops()) {
67+
for (auto& m_pass : m_matchers) {
68+
if (m_pass->apply(node)) {
69+
return true;
70+
}
71+
}
72+
}
73+
return false;
74+
};
75+
76+
do {
77+
changed = run_matchers();
78+
i++;
79+
} while (changed && i < m_num_iters);
80+
return changed;
81+
NGRAPH_SUPPRESS_DEPRECATED_END
82+
}
83+
84+
private:
85+
size_t m_num_iters;
86+
87+
std::vector<std::shared_ptr<ov::pass::MatcherPass>> m_matchers;
88+
};
2589
} // namespace pass
2690
} // namespace ngraph

src/core/include/ngraph/pass/pass.hpp

+15-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ class Manager;
2525
namespace ngraph {
2626
namespace pass {
2727
using FunctionPass = ov::pass::ModelPass;
28-
using ov::pass::FusionType;
29-
using ov::pass::FusionTypeMask;
3028
using ov::pass::Manager;
3129
using ov::pass::PassBase;
3230
using ov::pass::PassProperty;
@@ -40,5 +38,20 @@ class NGRAPH_DEPRECATED("Use MatcherPass or FunctionPass instead.") NGRAPH_API N
4038
~NodePass() override;
4139
virtual bool run_on_node(std::shared_ptr<ngraph::Node>) = 0;
4240
};
41+
42+
enum class NGRAPH_DEPRECATED("FusionType is no longer used anywhere. Please do no use it.") FusionType : uint32_t {
43+
//`DIFFERENTIABLE_FUSIONS` produce ops that support autodiff
44+
// i.e. implement `generate_adjoints`
45+
DIFFERENTIABLE_FUSIONS = 0x1,
46+
REGULAR_FUSIONS = 0x2,
47+
//`FOP_FUSIONS` produce ops in the FusedOps category that might
48+
// not be supported by all backends
49+
FOP_FUSIONS = 0x4,
50+
ALL_FUSIONS = 0xFFFFFFFF
51+
};
52+
53+
NGRAPH_SUPPRESS_DEPRECATED_START
54+
using FusionTypeMask = ov::EnumMask<FusionType>;
55+
NGRAPH_SUPPRESS_DEPRECATED_END
4356
} // namespace pass
4457
} // namespace ngraph

src/core/include/openvino/pass/graph_rewrite.hpp

-20
Original file line numberDiff line numberDiff line change
@@ -225,25 +225,5 @@ class OPENVINO_API BackwardGraphRewrite : public GraphRewrite {
225225

226226
bool run_on_model(const std::shared_ptr<ov::Model>& m) override;
227227
};
228-
229-
class OPENVINO_API RecurrentGraphRewrite : public ModelPass {
230-
public:
231-
RecurrentGraphRewrite(size_t num_iters = 10) : ModelPass(), m_num_iters(num_iters) {}
232-
233-
void add_matcher(const std::shared_ptr<pattern::RecurrentMatcher>& m,
234-
const ov::recurrent_graph_rewrite_callback& callback,
235-
const PassPropertyMask& property);
236-
237-
// TODO: This interface may deprecate after all passes are refactored.
238-
void add_matcher(const std::shared_ptr<pattern::RecurrentMatcher>& m,
239-
const ov::recurrent_graph_rewrite_callback& callback);
240-
241-
bool run_on_model(const std::shared_ptr<ov::Model>& m) override;
242-
243-
private:
244-
size_t m_num_iters;
245-
246-
std::vector<std::shared_ptr<ov::pass::MatcherPass>> m_matchers;
247-
};
248228
} // namespace pass
249229
} // namespace ov

src/core/include/openvino/pass/pass.hpp

-12
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,5 @@ class OPENVINO_API ModelPass : public PassBase {
100100
bool call_on_model{false};
101101
};
102102

103-
class Manager;
104-
enum class FusionType : uint32_t {
105-
//`DIFFERENTIABLE_FUSIONS` produce ops that support autodiff
106-
// i.e. implement `generate_adjoints`
107-
DIFFERENTIABLE_FUSIONS = 0x1,
108-
REGULAR_FUSIONS = 0x2,
109-
//`FOP_FUSIONS` produce ops in the FusedOps category that might
110-
// not be supported by all backends
111-
FOP_FUSIONS = 0x4,
112-
ALL_FUSIONS = 0xFFFFFFFF
113-
};
114-
using FusionTypeMask = ov::EnumMask<FusionType>;
115103
} // namespace pass
116104
} // namespace ov

src/core/src/pass/graph_rewrite.cpp

-46
Original file line numberDiff line numberDiff line change
@@ -288,52 +288,6 @@ void ov::pass::GraphRewrite::set_pass_config(const std::shared_ptr<PassConfig>&
288288
}
289289
}
290290

291-
void ov::pass::RecurrentGraphRewrite::add_matcher(const std::shared_ptr<pattern::RecurrentMatcher>& m,
292-
const ov::recurrent_graph_rewrite_callback& callback,
293-
const PassPropertyMask& property) {
294-
m_matchers.push_back(std::make_shared<MatcherPass>(
295-
"Recurrent matcher",
296-
nullptr,
297-
[m, callback](const std::shared_ptr<Node>& node) {
298-
NGRAPH_DEBUG << "Running recurrent matcher on " << node;
299-
if (m->match(node->output(0))) {
300-
NGRAPH_DEBUG << "Recurrent matcher matched " << m.get();
301-
return callback(*m.get());
302-
}
303-
return false;
304-
},
305-
property));
306-
}
307-
308-
void ov::pass::RecurrentGraphRewrite::add_matcher(const std::shared_ptr<pattern::RecurrentMatcher>& m,
309-
const ov::recurrent_graph_rewrite_callback& callback) {
310-
// TODO: before deprecate this function, by default expect the
311-
// callback require static shape.
312-
add_matcher(m, callback, {PassProperty::REQUIRE_STATIC_SHAPE});
313-
}
314-
315-
bool ov::pass::RecurrentGraphRewrite::run_on_model(const std::shared_ptr<Model>& f) {
316-
bool changed = false;
317-
size_t i = 0;
318-
319-
auto run_matchers = [&]() -> bool {
320-
for (const auto& node : f->get_ops()) {
321-
for (auto& m_pass : m_matchers) {
322-
if (m_pass->apply(node)) {
323-
return true;
324-
}
325-
}
326-
}
327-
return false;
328-
};
329-
330-
do {
331-
changed = run_matchers();
332-
i++;
333-
} while (changed && i < m_num_iters);
334-
return changed;
335-
}
336-
337291
void ov::pass::MatcherPass::register_matcher(const std::shared_ptr<ov::pass::pattern::Matcher>& m,
338292
const ov::graph_rewrite_callback& callback,
339293
const PassPropertyMask& property) {

src/core/tests/models/ir/conv_with_rt_info.xml

+6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33
<layers>
44
<layer id="0" name="Parameter_69" type="Parameter" version="opset1">
55
<data shape="490, 608, 1, 1" element_type="f32" />
6+
<rt_info>
7+
<attribute name="custom_attr" version="0"/>
8+
</rt_info>
69
<output>
710
<port id="0" precision="FP32">
11+
<rt_info>
12+
<attribute name="another_custom_attr" version="0"/>
13+
</rt_info>
814
<dim>490</dim>
915
<dim>608</dim>
1016
<dim>1</dim>

src/frontends/ir/src/ir_deserializer.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,8 @@ std::shared_ptr<ngraph::Node> XmlDeserializer::createNode(
755755
IE_THROW() << "Attribute: " << item.name() << " is not recognized as runtime attribute";
756756
}
757757
} else {
758-
IE_THROW() << "Attribute: " << item.name() << " is not recognized";
758+
// As runtime attributes are optional, so we skip attribute if it is unknown to avoid exception
759+
// when loading new IR with new attribute in old IE version.
759760
}
760761
}
761762
};

src/tests/functional/inference_engine/ir_serialization/rt_info_deserialization.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -802,8 +802,8 @@ TEST_F(RTInfoDeserialization, NodeV11MultipleRTKeys) {
802802
<layer name="in1" type="Parameter" id="0" version="opset8">
803803
<data element_type="f32" shape="1,22,22,3"/>
804804
<rt_info>
805-
<attribute name="old_api_map" version="0" order="0,2,3,1" element_type="f16"/>
806-
<attribute name="old_api_map" version="0" order="0,1,2,3" element_type="f32"/>
805+
<attribute name="old_api_map_order" version="0" value="0,2,3,1"/>
806+
<attribute name="old_api_map_order" version="0" value="0,1,2,3"/>
807807
<attribute name="fused_names" version="0" value="in1"/>
808808
</rt_info>
809809
<output>
@@ -843,7 +843,7 @@ TEST_F(RTInfoDeserialization, NodeV11MultipleRTKeys) {
843843
</layer>
844844
<layer name="output" type="Result" id="2" version="opset8">
845845
<rt_info>
846-
<attribute name="old_api_map" version="0" order="0,3,1,2" element_type="f16"/>
846+
<attribute name="old_api_map_order" version="0" value="0,3,1,2"/>
847847
</rt_info>
848848
<input>
849849
<port id="0" precision="FP32">

0 commit comments

Comments
 (0)