Skip to content

Commit 0a177ff

Browse files
authored
[core] Deprecate ov::Model constructor from ov::NodeVector (#30158)
### Details: - Deprecate `ov::Model` ctor using ov::NodeVector` as model outputs - Use only `ov::ResultVector` or `ov::OutputVector` as model outputs ### Tickets: - CVS-72662 --------- Signed-off-by: Raasz, Pawel <[email protected]>
1 parent 935ac43 commit 0a177ff

File tree

395 files changed

+2627
-2595
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

395 files changed

+2627
-2595
lines changed

src/bindings/python/src/pyopenvino/graph/model.cpp

+25-8
Original file line numberDiff line numberDiff line change
@@ -185,24 +185,41 @@ void regclass_graph_Model(py::module m) {
185185
:type name: str
186186
)");
187187

188-
model.def(py::init([](const std::vector<std::shared_ptr<ov::Node>>& results,
189-
const ov::ParameterVector& parameters,
190-
const std::string& name) {
191-
return make_model_with_tensor_names(results, parameters, name);
188+
model.def(py::init([](const ov::ResultVector& results, const ov::ParameterVector& params, const std::string& name) {
189+
auto model = make_model_with_tensor_names(results, params, name);
190+
return model;
192191
}),
193192
py::arg("results"),
194193
py::arg("parameters"),
195194
py::arg("name") = "",
196195
R"(
197196
Create user-defined Model which is a representation of a model.
198197
199-
:param results: List of Nodes to be used as results.
200-
:type results: List[openvino.Node]
198+
:param results: List of results.
199+
:type results: List[op.Result]
201200
:param parameters: List of parameters.
202-
:type parameters: List[op.Parameter]
201+
:type parameters: List[op.Parameter]
203202
:param name: String to set as model's friendly name.
204203
:type name: str
205-
)");
204+
)");
205+
206+
model.def(
207+
py::init([](const ov::NodeVector& results, const ov::ParameterVector& parameters, const std::string& name) {
208+
return make_model_with_tensor_names(ov::as_output_vector(results), parameters, name);
209+
}),
210+
py::arg("results"),
211+
py::arg("parameters"),
212+
py::arg("name") = "",
213+
R"(
214+
Create user-defined Model which is a representation of a model.
215+
216+
:param results: List of Nodes to be used as results.
217+
:type results: List[openvino.Node]
218+
:param parameters: List of parameters.
219+
:type parameters: List[op.Parameter]
220+
:param name: String to set as model's friendly name.
221+
:type name: str
222+
)");
206223

207224
model.def(py::init([](const std::shared_ptr<ov::Node>& result,
208225
const ov::ParameterVector& parameters,

src/bindings/python/tests/mock/mock_py_frontend/src/mock_py_frontend.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ bool FrontEndMockPy::supported_impl(const std::vector<ov::Any>& params) const {
386386

387387
std::shared_ptr<ov::Model> FrontEndMockPy::convert(const InputModel::Ptr& model) const {
388388
m_stat.m_convert_model++;
389-
return std::make_shared<ov::Model>(ov::NodeVector{}, ov::ParameterVector{});
389+
return std::make_shared<ov::Model>(ov::OutputVector{}, ov::ParameterVector{});
390390
}
391391

392392
void FrontEndMockPy::convert(const std::shared_ptr<ov::Model>& func) const {
@@ -395,12 +395,12 @@ void FrontEndMockPy::convert(const std::shared_ptr<ov::Model>& func) const {
395395

396396
std::shared_ptr<ov::Model> FrontEndMockPy::convert_partially(const InputModel::Ptr& model) const {
397397
m_stat.m_convert_partially++;
398-
return std::make_shared<ov::Model>(ov::NodeVector{}, ov::ParameterVector{});
398+
return std::make_shared<ov::Model>(ov::OutputVector{}, ov::ParameterVector{});
399399
}
400400

401401
std::shared_ptr<ov::Model> FrontEndMockPy::decode(const InputModel::Ptr& model) const {
402402
m_stat.m_decode++;
403-
return std::make_shared<ov::Model>(ov::NodeVector{}, ov::ParameterVector{});
403+
return std::make_shared<ov::Model>(ov::OutputVector{}, ov::ParameterVector{});
404404
}
405405

406406
void FrontEndMockPy::normalize(const std::shared_ptr<ov::Model>& function) const {

src/common/snippets/tests/src/lowered/pass/buffer_allocation.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,3 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_BufferAllocation_EltwiseOptimized, Eltwi
141141
} // namespace snippets
142142
} // namespace test
143143
} // namespace ov
144-

src/common/snippets/tests/src/pass/movebroadcast.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ TEST_F(TransformationTestsF, InsertBroadcastMove) {
2121
auto data0 = std::make_shared<ov::op::v0::Parameter>(element::f32, Shape{2, 3});
2222
auto data1 = std::make_shared<ov::op::v0::Parameter>(element::f32, Shape{1, 2, 1});
2323
auto add = std::make_shared<ov::op::v1::Add>(data0, data1);
24-
model = std::make_shared<Model>(NodeVector{add}, ParameterVector{data0, data1});
24+
model = std::make_shared<Model>(OutputVector{add}, ParameterVector{data0, data1});
2525

2626
manager.register_pass<snippets::pass::InsertMoveBroadcast>();
2727
}
@@ -30,6 +30,6 @@ TEST_F(TransformationTestsF, InsertBroadcastMove) {
3030
auto data1 = std::make_shared<ov::op::v0::Parameter>(element::f32, Shape{1, 2, 1});
3131
auto move1 = std::make_shared<snippets::isa::BroadcastMove>(data1, ov::Dimension{3});
3232
auto add = std::make_shared<ov::op::v1::Add>(data0, move1);
33-
model_ref = std::make_shared<Model>(NodeVector{add}, ParameterVector{data0, data1});
33+
model_ref = std::make_shared<Model>(OutputVector{add}, ParameterVector{data0, data1});
3434
}
3535
}

src/common/snippets/tests/src/pass/softmax_reshape_elimination.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ TEST_F(TransformationTestsF, SoftmaxV1ReshapeElimination) {
2222
auto softmax_v1 = std::make_shared<ov::op::v1::Softmax>(reshape0, 1);
2323
auto shape1 = std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{3}, std::vector<int32_t>{2, 3, 240});
2424
auto reshape1 = std::make_shared<ov::op::v1::Reshape>(softmax_v1, shape1, false);
25-
model = std::make_shared<Model>(NodeVector{reshape1}, ParameterVector{data});
25+
model = std::make_shared<Model>(OutputVector{reshape1}, ParameterVector{data});
2626

2727
manager.register_pass<snippets::pass::SoftmaxReshapeElimination>();
2828
}
2929
{
3030
auto data = std::make_shared<ov::op::v0::Parameter>(element::f32, Shape{2, 3, 240});
3131
auto softmax_v1 = std::make_shared<ov::op::v1::Softmax>(data, 2);
32-
model_ref = std::make_shared<Model>(NodeVector{softmax_v1}, ParameterVector{data});
32+
model_ref = std::make_shared<Model>(OutputVector{softmax_v1}, ParameterVector{data});
3333
}
3434
}
3535

@@ -41,14 +41,14 @@ TEST_F(TransformationTestsF, SoftmaxV8ReshapeElimination) {
4141
auto softmax_v1 = std::make_shared<ov::op::v8::Softmax>(reshape0, -1);
4242
auto shape1 = std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{4}, std::vector<int32_t>{1, 2, 340, 240});
4343
auto reshape1 = std::make_shared<ov::op::v1::Reshape>(softmax_v1, shape1, false);
44-
model = std::make_shared<Model>(NodeVector{reshape1}, ParameterVector{data});
44+
model = std::make_shared<Model>(OutputVector{reshape1}, ParameterVector{data});
4545

4646
manager.register_pass<snippets::pass::SoftmaxReshapeElimination>();
4747
}
4848
{
4949
auto data = std::make_shared<ov::op::v0::Parameter>(element::f32, Shape{1, 2, 340, 240});
5050
auto softmax_v1 = std::make_shared<ov::op::v8::Softmax>(data, 3);
51-
model_ref = std::make_shared<Model>(NodeVector{softmax_v1}, ParameterVector{data});
51+
model_ref = std::make_shared<Model>(OutputVector{softmax_v1}, ParameterVector{data});
5252
}
5353
}
5454

@@ -60,7 +60,7 @@ TEST_F(TransformationTestsF, SoftmaxReshapeElimination_IncorrectReshape) {
6060
auto softmax_v1 = std::make_shared<ov::op::v8::Softmax>(reshape0, -1);
6161
auto shape1 = std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{4}, std::vector<int32_t>{1, 2, 340, 240});
6262
auto reshape1 = std::make_shared<ov::op::v1::Reshape>(softmax_v1, shape1, false);
63-
model = std::make_shared<Model>(NodeVector{reshape1}, ParameterVector{data});
63+
model = std::make_shared<Model>(OutputVector{reshape1}, ParameterVector{data});
6464

6565
manager.register_pass<snippets::pass::SoftmaxReshapeElimination>();
6666
}
@@ -74,13 +74,13 @@ TEST_F(TransformationTestsF, SoftmaxV8ReshapeElimination_DynamicBatch) {
7474
auto softmax_v1 = std::make_shared<ov::op::v8::Softmax>(reshape0, -1);
7575
auto shape1 = std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{4}, std::vector<int32_t>{-1, 2, 340, 240});
7676
auto reshape1 = std::make_shared<ov::op::v1::Reshape>(softmax_v1, shape1, false);
77-
model = std::make_shared<Model>(NodeVector{reshape1}, ParameterVector{data});
77+
model = std::make_shared<Model>(OutputVector{reshape1}, ParameterVector{data});
7878

7979
manager.register_pass<snippets::pass::SoftmaxReshapeElimination>();
8080
}
8181
{
8282
auto data = std::make_shared<ov::op::v0::Parameter>(element::f32, ov::PartialShape{-1, 2, 340, 240});
8383
auto softmax_v1 = std::make_shared<ov::op::v8::Softmax>(data, 3);
84-
model_ref = std::make_shared<Model>(NodeVector{softmax_v1}, ParameterVector{data});
84+
model_ref = std::make_shared<Model>(OutputVector{softmax_v1}, ParameterVector{data});
8585
}
8686
}

src/common/transformations/tests/common_optimizations/add_fake_quantize_fusion.cpp

+17-17
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ TEST_F(TransformationTestsF, AddFakeQuantizeFusion) {
3232
auto output_low = opset5::Constant::create(element::f32, Shape{}, {0});
3333
auto output_high = opset5::Constant::create(element::f32, Shape{}, {10});
3434
auto fq = std::make_shared<opset5::FakeQuantize>(add, input_low, input_high, output_low, output_high, 11);
35-
model = std::make_shared<Model>(NodeVector{fq}, ParameterVector{data});
35+
model = std::make_shared<Model>(OutputVector{fq}, ParameterVector{data});
3636
manager.register_pass<ov::pass::AddFakeQuantizeFusion>();
3737
}
3838
{
@@ -42,7 +42,7 @@ TEST_F(TransformationTestsF, AddFakeQuantizeFusion) {
4242
auto output_low = opset5::Constant::create(element::f32, Shape{}, {0});
4343
auto output_high = opset5::Constant::create(element::f32, Shape{}, {10});
4444
auto fq = std::make_shared<opset5::FakeQuantize>(data, input_low, input_high, output_low, output_high, 11);
45-
model_ref = std::make_shared<Model>(NodeVector{fq}, ParameterVector{data});
45+
model_ref = std::make_shared<Model>(OutputVector{fq}, ParameterVector{data});
4646
}
4747
}
4848

@@ -64,7 +64,7 @@ TEST_F(TransformationTestsF, AddFakeQuantizeFusionWithConvolutionAndScalarConsta
6464
auto output_low = opset5::Constant::create(element::f32, Shape{}, {0});
6565
auto output_high = opset5::Constant::create(element::f32, Shape{}, {10});
6666
auto fq = std::make_shared<opset5::FakeQuantize>(add, input_low, input_high, output_low, output_high, 11);
67-
model = std::make_shared<Model>(NodeVector{fq}, ParameterVector{data, filter});
67+
model = std::make_shared<Model>(OutputVector{fq}, ParameterVector{data, filter});
6868
manager.register_pass<ov::pass::AddFakeQuantizeFusion>();
6969
}
7070
{
@@ -81,7 +81,7 @@ TEST_F(TransformationTestsF, AddFakeQuantizeFusionWithConvolutionAndScalarConsta
8181
auto output_low = opset5::Constant::create(element::f32, Shape{}, {0});
8282
auto output_high = opset5::Constant::create(element::f32, Shape{}, {10});
8383
auto fq = std::make_shared<opset5::FakeQuantize>(conv, input_low, input_high, output_low, output_high, 11);
84-
model_ref = std::make_shared<Model>(NodeVector{fq}, ParameterVector{data, filter});
84+
model_ref = std::make_shared<Model>(OutputVector{fq}, ParameterVector{data, filter});
8585
}
8686
}
8787

@@ -96,7 +96,7 @@ TEST_F(TransformationTestsF, AddFakeQuantizeFusionConstantOnFirstInput) {
9696
auto output_low = opset5::Constant::create(element::f32, Shape{}, {0});
9797
auto output_high = opset5::Constant::create(element::f32, Shape{}, {10});
9898
auto fq = std::make_shared<opset5::FakeQuantize>(add, input_low, input_high, output_low, output_high, 11);
99-
model = std::make_shared<Model>(NodeVector{fq}, ParameterVector{data});
99+
model = std::make_shared<Model>(OutputVector{fq}, ParameterVector{data});
100100
manager.register_pass<ov::pass::AddFakeQuantizeFusion>();
101101
}
102102
{
@@ -106,7 +106,7 @@ TEST_F(TransformationTestsF, AddFakeQuantizeFusionConstantOnFirstInput) {
106106
auto output_low = opset5::Constant::create(element::f32, Shape{}, {0});
107107
auto output_high = opset5::Constant::create(element::f32, Shape{}, {10});
108108
auto fq = std::make_shared<opset5::FakeQuantize>(data, input_low, input_high, output_low, output_high, 11);
109-
model_ref = std::make_shared<Model>(NodeVector{fq}, ParameterVector{data});
109+
model_ref = std::make_shared<Model>(OutputVector{fq}, ParameterVector{data});
110110
}
111111
}
112112

@@ -121,7 +121,7 @@ TEST_F(TransformationTestsF, AddFakeQuantizeFusionConstantWithEqualValues) {
121121
auto output_low = opset5::Constant::create(element::f32, Shape{}, {0});
122122
auto output_high = opset5::Constant::create(element::f32, Shape{}, {10});
123123
auto fq = std::make_shared<opset5::FakeQuantize>(add, input_low, input_high, output_low, output_high, 11);
124-
model = std::make_shared<Model>(NodeVector{fq}, ParameterVector{data});
124+
model = std::make_shared<Model>(OutputVector{fq}, ParameterVector{data});
125125
manager.register_pass<ov::pass::AddFakeQuantizeFusion>();
126126
}
127127
{
@@ -131,7 +131,7 @@ TEST_F(TransformationTestsF, AddFakeQuantizeFusionConstantWithEqualValues) {
131131
auto output_low = opset5::Constant::create(element::f32, Shape{}, {0});
132132
auto output_high = opset5::Constant::create(element::f32, Shape{}, {10});
133133
auto fq = std::make_shared<opset5::FakeQuantize>(data, input_low, input_high, output_low, output_high, 11);
134-
model_ref = std::make_shared<Model>(NodeVector{fq}, ParameterVector{data});
134+
model_ref = std::make_shared<Model>(OutputVector{fq}, ParameterVector{data});
135135
}
136136
}
137137

@@ -146,7 +146,7 @@ TEST_F(TransformationTestsF, AddFakeQuantizeFusionReshape) {
146146
auto output_low = opset5::Constant::create(element::f32, Shape{}, {0});
147147
auto output_high = opset5::Constant::create(element::f32, Shape{}, {10});
148148
auto fq = std::make_shared<opset5::FakeQuantize>(add, input_low, input_high, output_low, output_high, 11);
149-
model = std::make_shared<Model>(NodeVector{fq}, ParameterVector{data});
149+
model = std::make_shared<Model>(OutputVector{fq}, ParameterVector{data});
150150
manager.register_pass<ov::pass::AddFakeQuantizeFusion>();
151151
}
152152
{
@@ -156,7 +156,7 @@ TEST_F(TransformationTestsF, AddFakeQuantizeFusionReshape) {
156156
auto output_low = opset5::Constant::create(element::f32, Shape{}, {0});
157157
auto output_high = opset5::Constant::create(element::f32, Shape{}, {10});
158158
auto fq = std::make_shared<opset5::FakeQuantize>(data, input_low, input_high, output_low, output_high, 11);
159-
model_ref = std::make_shared<Model>(NodeVector{fq}, ParameterVector{data});
159+
model_ref = std::make_shared<Model>(OutputVector{fq}, ParameterVector{data});
160160
}
161161
}
162162

@@ -171,7 +171,7 @@ TEST_F(TransformationTestsF, AddFakeQuantizeFusionWithPerChannelConstant) {
171171
auto output_low = opset5::Constant::create(element::f32, Shape{}, {0});
172172
auto output_high = opset5::Constant::create(element::f32, Shape{}, {10});
173173
auto fq = std::make_shared<opset5::FakeQuantize>(add, input_low, input_high, output_low, output_high, 11);
174-
model = std::make_shared<Model>(NodeVector{fq}, ParameterVector{data});
174+
model = std::make_shared<Model>(OutputVector{fq}, ParameterVector{data});
175175
manager.register_pass<ov::pass::AddFakeQuantizeFusion>();
176176
}
177177
{
@@ -181,7 +181,7 @@ TEST_F(TransformationTestsF, AddFakeQuantizeFusionWithPerChannelConstant) {
181181
auto output_low = opset5::Constant::create(element::f32, Shape{}, {0});
182182
auto output_high = opset5::Constant::create(element::f32, Shape{}, {10});
183183
auto fq = std::make_shared<opset5::FakeQuantize>(data, input_low, input_high, output_low, output_high, 11);
184-
model_ref = std::make_shared<Model>(NodeVector{fq}, ParameterVector{data});
184+
model_ref = std::make_shared<Model>(OutputVector{fq}, ParameterVector{data});
185185
}
186186
}
187187

@@ -195,7 +195,7 @@ TEST_F(TransformationTestsF, NegativeAddFakeQuantizeFusionNotAConstant) {
195195
auto output_low = opset5::Constant::create(element::f32, Shape{}, {0});
196196
auto output_high = opset5::Constant::create(element::f32, Shape{}, {10});
197197
auto fq = std::make_shared<opset5::FakeQuantize>(add, input_low, input_high, output_low, output_high, 11);
198-
model = std::make_shared<Model>(NodeVector{fq}, ParameterVector{data, add_2nd_input});
198+
model = std::make_shared<Model>(OutputVector{fq}, ParameterVector{data, add_2nd_input});
199199
manager.register_pass<ov::pass::AddFakeQuantizeFusion>();
200200
}
201201

@@ -216,7 +216,7 @@ TEST_F(TransformationTestsF, NegativeAddFakeQuantizeFusionWithConvolutionAndNonS
216216
auto output_low = opset5::Constant::create(element::f32, Shape{}, {0});
217217
auto output_high = opset5::Constant::create(element::f32, Shape{}, {10});
218218
auto fq = std::make_shared<opset5::FakeQuantize>(add, input_low, input_high, output_low, output_high, 11);
219-
model = std::make_shared<Model>(NodeVector{fq}, ParameterVector{data, filter});
219+
model = std::make_shared<Model>(OutputVector{fq}, ParameterVector{data, filter});
220220
manager.register_pass<ov::pass::AddFakeQuantizeFusion>();
221221
}
222222

@@ -230,7 +230,7 @@ TEST_F(TransformationTestsF, NegativeAddFakeQuantizeFusionLowPrecision) {
230230
auto output_low = opset5::Constant::create(element::f16, Shape{}, {0});
231231
auto output_high = opset5::Constant::create(element::f16, Shape{}, {10});
232232
auto fq = std::make_shared<opset5::FakeQuantize>(add, input_low, input_high, output_low, output_high, 11);
233-
model = std::make_shared<Model>(NodeVector{fq}, ParameterVector{data});
233+
model = std::make_shared<Model>(OutputVector{fq}, ParameterVector{data});
234234
model_ref = model->clone();
235235
manager.register_pass<ov::pass::AddFakeQuantizeFusion>();
236236
}
@@ -245,7 +245,7 @@ TEST_F(TransformationTestsF, NegativeAddFakeQuantizeFusionWithNonPerChannelConst
245245
auto output_low = opset5::Constant::create(element::f32, Shape{}, {0});
246246
auto output_high = opset5::Constant::create(element::f32, Shape{}, {10});
247247
auto fq = std::make_shared<opset5::FakeQuantize>(add, input_low, input_high, output_low, output_high, 11);
248-
model = std::make_shared<Model>(NodeVector{fq}, ParameterVector{data});
248+
model = std::make_shared<Model>(OutputVector{fq}, ParameterVector{data});
249249
manager.register_pass<ov::pass::AddFakeQuantizeFusion>();
250250
}
251251

@@ -258,6 +258,6 @@ TEST_F(TransformationTestsF, AddFakeQuantizeFusionWithBroadcastingConstant) {
258258
auto output_low = opset5::Constant::create(element::f32, Shape{}, {0});
259259
auto output_high = opset5::Constant::create(element::f32, Shape{}, {10});
260260
auto fq = std::make_shared<opset5::FakeQuantize>(add, input_low, input_high, output_low, output_high, 11);
261-
model = std::make_shared<Model>(NodeVector{fq}, ParameterVector{data});
261+
model = std::make_shared<Model>(OutputVector{fq}, ParameterVector{data});
262262
manager.register_pass<ov::pass::AddFakeQuantizeFusion>();
263263
}

src/common/transformations/tests/common_optimizations/align_eltwise_input_ranks.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ TEST_P(AlignEltwiseInputRanksTestP, FusionTest) {
3737
auto low = op::v0::Constant::create(element::f32, const_shape, {0});
3838
auto high = op::v0::Constant::create(element::f32, const_shape, {20});
3939
auto fq = std::make_shared<opset8::FakeQuantize>(add, low, high, low, high, 256);
40-
model = std::make_shared<Model>(NodeVector{less, logical_or, fq}, ParameterVector{data});
40+
model = std::make_shared<Model>(OutputVector{less, logical_or, fq}, ParameterVector{data});
4141

4242
manager.register_pass<ov::pass::AlignEltwiseInputRanks>();
4343
}
@@ -58,7 +58,7 @@ TEST_P(AlignEltwiseInputRanksTestP, FusionTest) {
5858
auto low = op::v0::Constant::create(element::f32, expected_const_shape, {0});
5959
auto high = op::v0::Constant::create(element::f32, expected_const_shape, {20});
6060
auto fq = std::make_shared<opset8::FakeQuantize>(add, low, high, low, high, 256);
61-
model_ref = std::make_shared<Model>(NodeVector{less, logical_or, fq}, ParameterVector{data});
61+
model_ref = std::make_shared<Model>(OutputVector{less, logical_or, fq}, ParameterVector{data});
6262
}
6363
comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES);
6464
}

0 commit comments

Comments
 (0)