diff --git a/src/core/tests/all_close_f.cpp b/src/core/tests/all_close_f.cpp index b91cb96e57f..31ade659fa1 100644 --- a/src/core/tests/all_close_f.cpp +++ b/src/core/tests/all_close_f.cpp @@ -4,6 +4,8 @@ #include "common_test_utils/all_close_f.hpp" +#include + #include #include #include @@ -11,9 +13,6 @@ #include #include "common_test_utils/float_util.hpp" -#include "gtest/gtest.h" -#include "ngraph/env_util.hpp" -#include "ngraph/ngraph.hpp" using namespace std; diff --git a/src/core/tests/any.cpp b/src/core/tests/any.cpp index 97f902c319a..f164347ce13 100644 --- a/src/core/tests/any.cpp +++ b/src/core/tests/any.cpp @@ -2,15 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "openvino/core/deprecated.hpp" - -OPENVINO_SUPPRESS_DEPRECATED_START #include "openvino/core/any.hpp" -OPENVINO_SUPPRESS_DEPRECATED_END + +#include #include -#include "gtest/gtest.h" #include "openvino/core/runtime_attribute.hpp" using namespace ov; diff --git a/src/core/tests/bfloat16.cpp b/src/core/tests/bfloat16.cpp index 287b1be972c..bb3a35dc995 100644 --- a/src/core/tests/bfloat16.cpp +++ b/src/core/tests/bfloat16.cpp @@ -2,19 +2,19 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ngraph/type/bfloat16.hpp" +#include "openvino/core/type/bfloat16.hpp" + +#include #include #include #include "common_test_utils/float_util.hpp" -#include "gtest/gtest.h" -#include "ngraph/log.hpp" #include "ngraph/runtime/aligned_buffer.hpp" #include "openvino/util/log.hpp" using namespace std; -using namespace ngraph; +using namespace ov; template std::string to_hex(T value) { @@ -140,7 +140,7 @@ TEST(bfloat16, numeric_limits) { } TEST(benchmark, bfloat16) { - NGRAPH_SUPPRESS_DEPRECATED_START + OPENVINO_SUPPRESS_DEPRECATED_START size_t buffer_size = 128 * 3 * 224 * 224; ngraph::runtime::AlignedBuffer data(buffer_size * sizeof(float), 4096); float* f = static_cast(data.get_ptr()); @@ -155,7 +155,7 @@ TEST(benchmark, bfloat16) { { ngraph::runtime::AlignedBuffer bf_data(buffer_size * sizeof(bfloat16), 4096); bfloat16* p = static_cast(bf_data.get_ptr()); - stopwatch timer; + ngraph::stopwatch timer; timer.start(); for (size_t i = 0; i < buffer_size; ++i) { p[i] = bfloat16(f[i]); @@ -167,7 +167,7 @@ TEST(benchmark, bfloat16) { { ngraph::runtime::AlignedBuffer bf_data(buffer_size * sizeof(bfloat16), 4096); bfloat16* p = static_cast(bf_data.get_ptr()); - stopwatch timer; + ngraph::stopwatch timer; timer.start(); for (size_t i = 0; i < buffer_size; ++i) { p[i] = bfloat16::truncate(f[i]); @@ -179,7 +179,7 @@ TEST(benchmark, bfloat16) { { ngraph::runtime::AlignedBuffer bf_data(buffer_size * sizeof(bfloat16), 4096); bfloat16* p = static_cast(bf_data.get_ptr()); - stopwatch timer; + ngraph::stopwatch timer; timer.start(); for (size_t i = 0; i < buffer_size; ++i) { p[i] = bfloat16::round_to_nearest(f[i]); @@ -191,7 +191,7 @@ TEST(benchmark, bfloat16) { { ngraph::runtime::AlignedBuffer bf_data(buffer_size * sizeof(bfloat16), 4096); bfloat16* p = static_cast(bf_data.get_ptr()); - stopwatch timer; + ngraph::stopwatch timer; timer.start(); for (size_t i = 0; i < buffer_size; ++i) { p[i] = bfloat16::round_to_nearest_even(f[i]); @@ -199,7 +199,7 @@ TEST(benchmark, bfloat16) { timer.stop(); OPENVINO_INFO << "float to bfloat16 round to nearest even " << timer.get_milliseconds() << "ms"; } - NGRAPH_SUPPRESS_DEPRECATED_END + OPENVINO_SUPPRESS_DEPRECATED_END } TEST(bfloat16, assigns) { diff --git a/src/core/tests/build_graph.cpp b/src/core/tests/build_graph.cpp index 5194704f017..7fdebc1799c 100644 --- a/src/core/tests/build_graph.cpp +++ b/src/core/tests/build_graph.cpp @@ -2,36 +2,47 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include #include "common_test_utils/graph_comparator.hpp" #include "common_test_utils/test_tools.hpp" #include "common_test_utils/type_prop.hpp" -#include "gtest/gtest.h" #include "ngraph/builder/autobroadcast.hpp" -#include "ngraph/file_util.hpp" -#include "ngraph/ngraph.hpp" -#include "ngraph/opsets/opset5.hpp" -#include "ngraph/opsets/opset7.hpp" - -NGRAPH_SUPPRESS_DEPRECATED_START +#include "ngraph/graph_util.hpp" +#include "openvino/core/except.hpp" +#include "openvino/op/abs.hpp" +#include "openvino/op/acos.hpp" +#include "openvino/op/add.hpp" +#include "openvino/op/assign.hpp" +#include "openvino/op/concat.hpp" +#include "openvino/op/matmul.hpp" +#include "openvino/op/parameter.hpp" +#include "openvino/op/read_value.hpp" +#include "openvino/op/relu.hpp" +#include "openvino/op/reshape.hpp" +#include "openvino/op/result.hpp" +#include "openvino/op/split.hpp" +#include "openvino/op/squeeze.hpp" +#include "openvino/op/util/variable.hpp" using namespace std; -using namespace ngraph; +using namespace ov; TEST(build_graph, build_simple) { // Function with 4 parameters - auto arg0 = make_shared(element::f32, Shape{7, 3}); - auto arg1 = make_shared(element::f32, Shape{3}); - auto arg2 = make_shared(element::f32, Shape{32, 7}); - auto arg3 = make_shared(element::f32, Shape{32, 7}); - auto broadcast_1 = builder::opset1::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); - auto b1 = builder::opset1::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); - auto dot = make_shared(arg2, arg0); + auto arg0 = make_shared(element::f32, Shape{7, 3}); + auto arg1 = make_shared(element::f32, Shape{3}); + auto arg2 = make_shared(element::f32, Shape{32, 7}); + auto arg3 = make_shared(element::f32, Shape{32, 7}); + auto broadcast_1 = ngraph::builder::opset1::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); + auto b1 = ngraph::builder::opset1::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); + auto dot = make_shared(arg2, arg0); ASSERT_EQ(dot->input_value(0).get_node_shared_ptr(), arg2); ASSERT_EQ(dot->input_value(1).get_node_shared_ptr(), arg0); - auto cluster_0 = make_shared(dot, ParameterVector{arg0, arg1, arg2, arg3}); + auto cluster_0 = make_shared(dot, ParameterVector{arg0, arg1, arg2, arg3}); ASSERT_EQ(cluster_0->get_output_op(0)->input_value(0).get_node_shared_ptr(), dot); } @@ -40,16 +51,16 @@ TEST(build_graph, literal) { // float scalar from a float // auto float0 = FloatConstant::make(3.0); vector float_t{3.0}; - auto float0 = make_shared(element::f32, Shape{1}, float_t); + auto float0 = make_shared(element::f32, Shape{1}, float_t); ASSERT_EQ(float0->get_vector(), std::vector{3.0}); ASSERT_EQ(float0->get_element_type(), element::f32); ASSERT_EQ(float0->get_shape(), Shape{1}); - auto d = make_shared(float0, float0); + auto d = make_shared(float0, float0); ASSERT_EQ(d->input_values().at(0).get_node_shared_ptr(), float0); ASSERT_EQ(d->input_values().at(1).get_node_shared_ptr(), float0); vector int32{3}; - auto int32_0 = make_shared(element::i32, Shape{}, int32); + auto int32_0 = make_shared(element::i32, Shape{}, int32); ASSERT_EQ(int32_0->get_vector(), std::vector{3}); ASSERT_EQ(int32_0->get_element_type(), element::i32); ASSERT_EQ(int32_0->get_shape(), Shape{}); @@ -60,7 +71,7 @@ TEST(build_graph, tensor) { // auto float0 = FloatConstant::make(3.0); Shape shape{2, 3}; vector float_t(shape_size(shape), 0); - auto float0 = make_shared(element::f32, shape, float_t); + auto float0 = make_shared(element::f32, shape, float_t); ASSERT_EQ(float0->get_element_type(), element::f32); ASSERT_EQ(float0->get_shape(), shape); auto d = make_shared(float0, float0); @@ -69,7 +80,7 @@ TEST(build_graph, tensor) { Shape ishape{3, 5}; vector idata(shape_size(ishape), 0); - auto int32_0 = make_shared(element::i32, ishape, idata); + auto int32_0 = make_shared(element::i32, ishape, idata); ASSERT_EQ(int32_0->get_element_type(), element::i32); ASSERT_EQ(int32_0->get_shape(), ishape); } @@ -77,21 +88,21 @@ TEST(build_graph, tensor) { // Check functions with undeclared parameters TEST(build_graph, function_undeclared_parameters) { // Function with 4 parameters - auto arg0 = make_shared(element::f32, Shape{7, 3}); - auto arg1 = make_shared(element::f32, Shape{3}); - auto arg2 = make_shared(element::f32, Shape{32, 7}); - auto arg3 = make_shared(element::f32, Shape{32, 7}); - auto broadcast_1 = builder::opset1::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); - auto b1 = builder::opset1::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); - auto dot = make_shared(arg2, arg0); + auto arg0 = make_shared(element::f32, Shape{7, 3}); + auto arg1 = make_shared(element::f32, Shape{3}); + auto arg2 = make_shared(element::f32, Shape{32, 7}); + auto arg3 = make_shared(element::f32, Shape{32, 7}); + auto broadcast_1 = ngraph::builder::opset1::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); + auto b1 = ngraph::builder::opset1::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); + auto dot = make_shared(arg2, arg0); ASSERT_EQ(dot->input_values()[0].get_node_shared_ptr(), arg2); ASSERT_EQ(dot->input_values()[1].get_node_shared_ptr(), arg0); try { - auto f = make_shared(dot, ParameterVector{arg0, arg1, arg3}); + auto f = make_shared(dot, ParameterVector{arg0, arg1, arg3}); f->get_ops(); // Should have thrown, so fail if it didn't FAIL() << "Undeclared parameter not detected."; - } catch (const ngraph_error& error) { + } catch (const ov::Exception& error) { EXPECT_HAS_SUBSTRING(error.what(), std::string("Model references undeclared parameter")); } catch (...) { FAIL() << "Model construction failed for unexpected reason"; @@ -102,13 +113,13 @@ TEST(build_graph, function_undeclared_parameters) { TEST(build_graph, no_arg_construction) { // The ops // Parameters aren't converted yet - auto arg0 = make_shared(element::f32, Shape{7}); - auto arg1 = make_shared(element::f32, Shape{7}); - auto arg2 = make_shared(element::f32, Shape{7}); - auto arg3 = make_shared(element::f32, Shape{7}); + auto arg0 = make_shared(element::f32, Shape{7}); + auto arg1 = make_shared(element::f32, Shape{7}); + auto arg2 = make_shared(element::f32, Shape{7}); + auto arg3 = make_shared(element::f32, Shape{7}); auto add0 = make_shared(); - auto abs0 = make_shared(); - auto acos0 = make_shared(); + auto abs0 = make_shared(); + auto acos0 = make_shared(); auto add1 = make_shared(); add0->set_argument(1, arg0); add0->set_argument(0, arg1); @@ -117,39 +128,41 @@ TEST(build_graph, no_arg_construction) { add1->set_argument(0, acos0); add1->set_argument(1, abs0); NodeVector ops{arg0, arg1, add0, abs0, acos0, add1}; - validate_nodes_and_infer_types(ops); + OPENVINO_SUPPRESS_DEPRECATED_START + ngraph::validate_nodes_and_infer_types(ops); + OPENVINO_SUPPRESS_DEPRECATED_END ASSERT_EQ(add1->get_output_shape(0), Shape{7}); } TEST(build_graph, multi_output_split_dynamic) { - const auto data = make_shared(element::f32, PartialShape::dynamic()); - const auto axis = op::Constant::create(element::i64, Shape{}, {1}); + const auto data = make_shared(element::f32, PartialShape::dynamic()); + const auto axis = op::v0::Constant::create(element::i64, Shape{}, {1}); const auto split = make_shared(data, axis, 2); - auto abs = make_shared(split->output(1)); + auto abs = make_shared(split->output(1)); EXPECT_TRUE(abs->get_output_partial_shape(0).same_scheme(PartialShape::dynamic())); - auto new_parameter = make_shared(element::f32, Shape{2, 4}); + auto new_parameter = make_shared(element::f32, Shape{2, 4}); split->input(0).replace_source_output(new_parameter->output(0)); - auto f = make_shared(abs, ParameterVector{new_parameter}); + auto f = make_shared(abs, ParameterVector{new_parameter}); f->validate_nodes_and_infer_types(); EXPECT_EQ(abs->get_shape(), (Shape{2, 2})); } TEST(build_graph, function_revalidate_and_infer) { - auto arg = make_shared(element::f32, Shape{2, 4, 6, 8}); - auto pattern = op::Constant::create(element::i64, Shape{6}, {1, 3, 16, 2, 2, 2}); + auto arg = make_shared(element::f32, Shape{2, 4, 6, 8}); + auto pattern = op::v0::Constant::create(element::i64, Shape{6}, {1, 3, 16, 2, 2, 2}); auto r = make_shared(arg, pattern, true); - auto relu = make_shared(r); - auto f = make_shared(relu, ParameterVector{arg}); + auto relu = make_shared(r); + auto f = make_shared(relu, ParameterVector{arg}); EXPECT_EQ(r->get_output_element_type(0), element::f32); EXPECT_EQ(r->get_output_shape(0), (Shape{1, 3, 16, 2, 2, 2})); EXPECT_EQ(f->get_output_shape(0), (Shape{1, 3, 16, 2, 2, 2})); - auto new_pattern = op::Constant::create(element::i64, Shape{2}, {32, 12}); + auto new_pattern = op::v0::Constant::create(element::i64, Shape{2}, {32, 12}); r->input(1).replace_source_output(new_pattern->output(0)); f->validate_nodes_and_infer_types(); @@ -167,17 +180,17 @@ TEST(build_graph, default_output_checks) { } TEST(build_graph, build_graph_with_sink) { - auto arg = make_shared(element::f32, Shape{2, 4}); - auto init_const = op::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto read = make_shared(init_const, "v0"); + auto arg = make_shared(element::f32, Shape{2, 4}); + auto init_const = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto read = make_shared(init_const, "v0"); std::vector> args = {arg, read}; - auto pattern = make_shared(args, 1); - auto res = make_shared(pattern); - const auto axis = op::Constant::create(element::i64, Shape{}, {1}); + auto pattern = make_shared(args, 1); + auto res = make_shared(pattern); + const auto axis = op::v0::Constant::create(element::i64, Shape{}, {1}); auto crop = make_shared(pattern, axis, 3); - auto assign = make_shared(crop, "v0"); + auto assign = make_shared(crop, "v0"); - auto f = make_shared(ResultVector({res}), SinkVector({assign}), ParameterVector{arg}); + auto f = make_shared(ResultVector({res}), SinkVector({assign}), ParameterVector{arg}); SinkVector sinks = f->get_sinks(); EXPECT_EQ(sinks.size(), 1); @@ -187,17 +200,17 @@ TEST(build_graph, build_graph_with_sink) { } TEST(build_graph, build_graph_with_sink_output_ctor) { - auto arg = make_shared(element::f32, Shape{2, 4}); - auto init_const = op::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto read = make_shared(init_const, "v0"); + auto arg = make_shared(element::f32, Shape{2, 4}); + auto init_const = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto read = make_shared(init_const, "v0"); std::vector> args = {arg, read}; - auto pattern = make_shared(args, 1); - auto res = make_shared(pattern); - const auto axis = op::Constant::create(element::i64, Shape{}, {1}); + auto pattern = make_shared(args, 1); + auto res = make_shared(pattern); + const auto axis = op::v0::Constant::create(element::i64, Shape{}, {1}); auto crop = make_shared(pattern, axis, 3); - auto assign = make_shared(crop, "v0"); + auto assign = make_shared(crop, "v0"); - auto f = make_shared(OutputVector({pattern->output(0)}), SinkVector({assign}), ParameterVector{arg}); + auto f = make_shared(OutputVector({pattern->output(0)}), SinkVector({assign}), ParameterVector{arg}); SinkVector sinks = f->get_sinks(); EXPECT_EQ(sinks.size(), 1); @@ -207,17 +220,17 @@ TEST(build_graph, build_graph_with_sink_output_ctor) { } TEST(build_graph, build_graph_with_add_sink) { - auto arg = make_shared(element::f32, Shape{2, 4}); - auto init_const = op::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto read = make_shared(init_const, "v0"); + auto arg = make_shared(element::f32, Shape{2, 4}); + auto init_const = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto read = make_shared(init_const, "v0"); std::vector> args = {arg, read}; - auto pattern = make_shared(args, 1); - auto res = make_shared(pattern); - const auto axis = op::Constant::create(element::i64, Shape{}, {1}); + auto pattern = make_shared(args, 1); + auto res = make_shared(pattern); + const auto axis = op::v0::Constant::create(element::i64, Shape{}, {1}); auto crop = make_shared(pattern, axis, 3); - auto assign = make_shared(crop, "v0"); + auto assign = make_shared(crop, "v0"); - auto f = make_shared(ResultVector({res}), ParameterVector{arg}); + auto f = make_shared(ResultVector({res}), ParameterVector{arg}); NodeVector nodes = f->get_ops(); EXPECT_EQ(nodes.size(), 5); @@ -233,17 +246,17 @@ TEST(build_graph, build_graph_with_add_sink) { } TEST(build_graph, build_graph_with_wrong_remove_sink) { - auto arg = make_shared(element::f32, Shape{2, 4}); - auto init_const = op::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto read = make_shared(init_const, "v0"); + auto arg = make_shared(element::f32, Shape{2, 4}); + auto init_const = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto read = make_shared(init_const, "v0"); std::vector> args = {arg, read}; - auto pattern = make_shared(args, 1); - auto res = make_shared(pattern); - const auto axis = op::Constant::create(element::i64, Shape{}, {1}); + auto pattern = make_shared(args, 1); + auto res = make_shared(pattern); + const auto axis = op::v0::Constant::create(element::i64, Shape{}, {1}); auto crop = make_shared(pattern, axis, 3); - auto assign = make_shared(crop, "v0"); + auto assign = make_shared(crop, "v0"); - auto f = make_shared(ResultVector({res}), SinkVector({assign}), ParameterVector{arg}); + auto f = make_shared(ResultVector({res}), SinkVector({assign}), ParameterVector{arg}); SinkVector sinks = f->get_sinks(); EXPECT_EQ(sinks.size(), 1); @@ -256,17 +269,17 @@ TEST(build_graph, build_graph_with_wrong_remove_sink) { } TEST(build_graph, build_graph_with_remove_sink) { - auto arg = make_shared(element::f32, Shape{2, 4}); - auto init_const = op::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto read = make_shared(init_const, "v0"); + auto arg = make_shared(element::f32, Shape{2, 4}); + auto init_const = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto read = make_shared(init_const, "v0"); std::vector> args = {arg, read}; - auto pattern = make_shared(args, 1); - auto res = make_shared(pattern); - const auto axis = op::Constant::create(element::i64, Shape{}, {1}); + auto pattern = make_shared(args, 1); + auto res = make_shared(pattern); + const auto axis = op::v0::Constant::create(element::i64, Shape{}, {1}); auto crop = make_shared(pattern, axis, 3); - auto assign = make_shared(crop, "v0"); + auto assign = make_shared(crop, "v0"); - auto f = make_shared(ResultVector({res}), SinkVector({assign}), ParameterVector{arg}); + auto f = make_shared(ResultVector({res}), SinkVector({assign}), ParameterVector{arg}); pattern->input(1).replace_source_output(arg); @@ -281,17 +294,17 @@ TEST(build_graph, build_graph_with_remove_sink) { } TEST(build_graph, build_graph_with_add_result) { - auto arg = make_shared(element::f32, Shape{2, 4}); - auto init_const = op::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto read = make_shared(init_const, "v0"); + auto arg = make_shared(element::f32, Shape{2, 4}); + auto init_const = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto read = make_shared(init_const, "v0"); std::vector> args = {arg, read}; - auto pattern = make_shared(args, 1); - auto res = make_shared(pattern); - const auto axis = op::Constant::create(element::i64, Shape{}, {1}); + auto pattern = make_shared(args, 1); + auto res = make_shared(pattern); + const auto axis = op::v0::Constant::create(element::i64, Shape{}, {1}); auto crop = make_shared(pattern, axis, 3); - auto res2 = make_shared(crop); + auto res2 = make_shared(crop); - auto f = make_shared(ResultVector({res}), ParameterVector{arg}); + auto f = make_shared(ResultVector({res}), ParameterVector{arg}); NodeVector nodes = f->get_ops(); EXPECT_EQ(nodes.size(), 5); @@ -307,17 +320,17 @@ TEST(build_graph, build_graph_with_add_result) { } TEST(build_graph, build_graph_with_remove_result) { - auto arg = make_shared(element::f32, Shape{2, 4}); - auto init_const = op::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto read = make_shared(init_const, "v0"); + auto arg = make_shared(element::f32, Shape{2, 4}); + auto init_const = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto read = make_shared(init_const, "v0"); std::vector> args = {arg, read}; - auto pattern = make_shared(args, 1); - auto res = make_shared(pattern); - const auto axis = op::Constant::create(element::i64, Shape{}, {1}); + auto pattern = make_shared(args, 1); + auto res = make_shared(pattern); + const auto axis = op::v0::Constant::create(element::i64, Shape{}, {1}); auto crop = make_shared(pattern, axis, 3); - auto res2 = make_shared(crop); + auto res2 = make_shared(crop); - auto f = make_shared(ResultVector({res, res2}), ParameterVector{arg}); + auto f = make_shared(ResultVector({res, res2}), ParameterVector{arg}); NodeVector nodes = f->get_ops(); EXPECT_EQ(nodes.size(), 8); @@ -332,18 +345,18 @@ TEST(build_graph, build_graph_with_remove_result) { } TEST(build_graph, build_graph_with_add_parameter) { - auto arg = make_shared(element::f32, Shape{2, 4}); - auto arg2 = make_shared(element::f32, Shape{2, 2}); - auto init_const = op::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto read = make_shared(init_const, "v0"); + auto arg = make_shared(element::f32, Shape{2, 4}); + auto arg2 = make_shared(element::f32, Shape{2, 2}); + auto init_const = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto read = make_shared(init_const, "v0"); std::vector> args = {arg, read}; - auto pattern = make_shared(args, 1); - auto res = make_shared(pattern); - const auto axis = op::Constant::create(element::i64, Shape{}, {1}); + auto pattern = make_shared(args, 1); + auto res = make_shared(pattern); + const auto axis = op::v0::Constant::create(element::i64, Shape{}, {1}); auto crop = make_shared(pattern, axis, 3); - auto res2 = make_shared(crop); + auto res2 = make_shared(crop); - auto f = make_shared(ResultVector({res, res2}), ParameterVector{arg}); + auto f = make_shared(ResultVector({res, res2}), ParameterVector{arg}); NodeVector nodes = f->get_ops(); EXPECT_EQ(nodes.size(), 8); @@ -361,18 +374,18 @@ TEST(build_graph, build_graph_with_add_parameter) { } TEST(build_graph, build_graph_with_remove_parameter) { - auto arg = make_shared(element::f32, Shape{2, 4}); - auto arg2 = make_shared(element::f32, Shape{2, 2}); - auto init_const = op::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto read = make_shared(init_const, "v0"); + auto arg = make_shared(element::f32, Shape{2, 4}); + auto arg2 = make_shared(element::f32, Shape{2, 2}); + auto init_const = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto read = make_shared(init_const, "v0"); std::vector> args = {arg, arg2}; - auto pattern = make_shared(args, 1); - auto res = make_shared(pattern); - const auto axis = op::Constant::create(element::i64, Shape{}, {1}); + auto pattern = make_shared(args, 1); + auto res = make_shared(pattern); + const auto axis = op::v0::Constant::create(element::i64, Shape{}, {1}); auto crop = make_shared(pattern, axis, 3); - auto res2 = make_shared(crop); + auto res2 = make_shared(crop); - auto f = make_shared(ResultVector({res, res2}), ParameterVector{arg, arg2}); + auto f = make_shared(ResultVector({res, res2}), ParameterVector{arg, arg2}); NodeVector nodes = f->get_ops(); EXPECT_EQ(nodes.size(), 7); @@ -388,20 +401,20 @@ TEST(build_graph, build_graph_with_remove_parameter) { } TEST(build_graph, build_graph_with_remove_parameter_indexing) { - auto arg = make_shared(element::f32, Shape{2, 4}); - auto arg2 = make_shared(element::f32, Shape{2, 2}); - auto init_const = op::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto read = make_shared(init_const, "v0"); - auto assign = make_shared(read, "v0"); + auto arg = make_shared(element::f32, Shape{2, 4}); + auto arg2 = make_shared(element::f32, Shape{2, 2}); + auto init_const = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto read = make_shared(init_const, "v0"); + auto assign = make_shared(read, "v0"); assign->add_control_dependency(read); std::vector> args = {arg2, arg}; - auto pattern = make_shared(args, 1); - auto res = make_shared(pattern); - const auto axis = op::Constant::create(element::i64, Shape{}, {1}); + auto pattern = make_shared(args, 1); + auto res = make_shared(pattern); + const auto axis = op::v0::Constant::create(element::i64, Shape{}, {1}); auto crop = make_shared(pattern, axis, 3); - auto res2 = make_shared(crop); + auto res2 = make_shared(crop); - auto f = make_shared(ResultVector({res, res2}), ParameterVector{arg2, arg}); + auto f = make_shared(ResultVector({res, res2}), ParameterVector{arg2, arg}); NodeVector nodes = f->get_ops(); EXPECT_EQ(nodes.size(), 7); @@ -421,144 +434,144 @@ TEST(build_graph, build_graph_with_remove_parameter_indexing) { TEST(build_graph, build_graph_parameters_autodetection) { // Function with 4 parameters - using namespace opset7; - auto arg0 = make_shared(element::f32, Shape{7, 3}); - auto arg1 = make_shared(element::f32, Shape{3}); - auto arg2 = make_shared(element::f32, Shape{32, 7}); - auto arg3 = make_shared(element::f32, Shape{32, 7}); - auto broadcast_1 = builder::opset1::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); - auto b1 = builder::opset1::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); - auto dot = make_shared(arg2, arg0); + auto arg0 = make_shared(element::f32, Shape{7, 3}); + auto arg1 = make_shared(element::f32, Shape{3}); + auto arg2 = make_shared(element::f32, Shape{32, 7}); + auto arg3 = make_shared(element::f32, Shape{32, 7}); + auto broadcast_1 = ngraph::builder::opset1::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); + auto b1 = ngraph::builder::opset1::make_broadcast(arg3, Shape{10, 32, 7}, AxisSet{0}); + auto dot = make_shared(arg2, arg0); - auto f = make_shared(OutputVector{dot}); + auto f = make_shared(OutputVector{dot}); EXPECT_EQ(f->get_parameters().size(), 2); } TEST(build_graph, build_graph_parameters_variables_autodetection) { - using namespace opset7; - auto arg = make_shared(element::f32, Shape{2, 4}); - auto arg2 = make_shared(element::f32, Shape{2, 2}); - auto init_const = Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto arg = make_shared(element::f32, Shape{2, 4}); + auto arg2 = make_shared(element::f32, Shape{2, 2}); + auto init_const = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto variable = make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, "v0"}); - auto read = make_shared(init_const, variable); - auto assign = make_shared(read, variable); + auto variable = + make_shared(op::util::VariableInfo{PartialShape::dynamic(), element::dynamic, "v0"}); + auto read = make_shared(init_const, variable); + auto assign = make_shared(read, variable); assign->add_control_dependency(read); std::vector> args = {arg2, arg}; - auto pattern = make_shared(args, 1); - auto res = make_shared(pattern); - const auto axis = Constant::create(element::i64, Shape{}, {1}); - auto crop = make_shared(pattern, axis, 3); - auto res2 = make_shared(crop); + auto pattern = make_shared(args, 1); + auto res = make_shared(pattern); + const auto axis = op::v0::Constant::create(element::i64, Shape{}, {1}); + auto crop = make_shared(pattern, axis, 3); + auto res2 = make_shared(crop); - auto f = make_shared(OutputVector{res, res2}, SinkVector{assign}); + auto f = make_shared(OutputVector{res, res2}, SinkVector{assign}); NodeVector nodes = f->get_ops(); EXPECT_EQ(nodes.size(), 10); ParameterVector params = f->get_parameters(); EXPECT_EQ(params.size(), 2); - VariableVector variables = f->get_variables(); + op::util::VariableVector variables = f->get_variables(); EXPECT_EQ(variables.size(), 1); } TEST(build_graph, build_graph_variables_ctors) { - using namespace opset7; - auto arg = make_shared(element::f32, Shape{2, 4}); - auto arg2 = make_shared(element::f32, Shape{2, 2}); - auto init_const = Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto arg = make_shared(element::f32, Shape{2, 4}); + auto arg2 = make_shared(element::f32, Shape{2, 2}); + auto init_const = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto variable = make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, "v0"}); - auto read = make_shared(init_const, variable); - auto assign = make_shared(read, variable); + auto variable = + make_shared(op::util::VariableInfo{PartialShape::dynamic(), element::dynamic, "v0"}); + auto read = make_shared(init_const, variable); + auto assign = make_shared(read, variable); assign->add_control_dependency(read); std::vector> args = {arg2, arg}; - auto pattern = make_shared(args, 1); - auto res = make_shared(pattern); - const auto axis = Constant::create(element::i64, Shape{}, {1}); - auto crop = make_shared(pattern, axis, 3); - auto res2 = make_shared(crop); + auto pattern = make_shared(args, 1); + auto res = make_shared(pattern); + const auto axis = op::v0::Constant::create(element::i64, Shape{}, {1}); + auto crop = make_shared(pattern, axis, 3); + auto res2 = make_shared(crop); { - auto f = make_shared(OutputVector{res, res2}, - SinkVector{assign}, - ParameterVector{arg, arg2}, - VariableVector{variable}); + auto f = make_shared(OutputVector{res, res2}, + SinkVector{assign}, + ParameterVector{arg, arg2}, + op::util::VariableVector{variable}); NodeVector nodes = f->get_ops(); EXPECT_EQ(nodes.size(), 10); ParameterVector params = f->get_parameters(); EXPECT_EQ(params.size(), 2); - VariableVector variables = f->get_variables(); + op::util::VariableVector variables = f->get_variables(); EXPECT_EQ(variables.size(), 1); } // autodetect variables { - auto f = make_shared(OutputVector{res, res2}, SinkVector{assign}, ParameterVector{arg, arg2}); + auto f = make_shared(OutputVector{res, res2}, SinkVector{assign}, ParameterVector{arg, arg2}); NodeVector nodes = f->get_ops(); EXPECT_EQ(nodes.size(), 10); ParameterVector params = f->get_parameters(); EXPECT_EQ(params.size(), 2); - VariableVector variables = f->get_variables(); + op::util::VariableVector variables = f->get_variables(); EXPECT_EQ(variables.size(), 1); } } TEST(build_graph, build_graph_unregistred_variables) { - using namespace opset7; - auto arg = make_shared(element::f32, Shape{2, 4}); - auto arg2 = make_shared(element::f32, Shape{2, 2}); - auto init_const = Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto arg = make_shared(element::f32, Shape{2, 4}); + auto arg2 = make_shared(element::f32, Shape{2, 2}); + auto init_const = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto variable = make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, "v0"}); - auto variable_2 = make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, "v1"}); - auto read = make_shared(init_const, variable); - auto read_2 = make_shared(init_const, variable_2); - auto assign = make_shared(read, variable); - auto assign_2 = make_shared(read_2, variable_2); + auto variable = + make_shared(op::util::VariableInfo{PartialShape::dynamic(), element::dynamic, "v0"}); + auto variable_2 = + make_shared(op::util::VariableInfo{PartialShape::dynamic(), element::dynamic, "v1"}); + auto read = make_shared(init_const, variable); + auto read_2 = make_shared(init_const, variable_2); + auto assign = make_shared(read, variable); + auto assign_2 = make_shared(read_2, variable_2); assign->add_control_dependency(read); std::vector> args = {arg2, arg}; - auto pattern = make_shared(args, 1); - auto res = make_shared(pattern); - const auto axis = Constant::create(element::i64, Shape{}, {1}); - auto crop = make_shared(pattern, axis, 3); - auto res2 = make_shared(crop); + auto pattern = make_shared(args, 1); + auto res = make_shared(pattern); + const auto axis = op::v0::Constant::create(element::i64, Shape{}, {1}); + auto crop = make_shared(pattern, axis, 3); + auto res2 = make_shared(crop); - EXPECT_ANY_THROW(const auto unused = make_shared(OutputVector{res, res2}, - SinkVector{assign, assign_2}, - ParameterVector{arg, arg2}, - VariableVector{variable})); + EXPECT_ANY_THROW(const auto unused = make_shared(OutputVector{res, res2}, + SinkVector{assign, assign_2}, + ParameterVector{arg, arg2}, + op::util::VariableVector{variable})); } TEST(build_graph, build_graph_with_sinks_compare) { - shared_ptr f0, f1; + shared_ptr f0, f1; { - auto init_const0 = op::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto init_const1 = op::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto read0 = make_shared(init_const0, "v0"); - auto read1 = make_shared(init_const1, "v1"); + auto init_const0 = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto init_const1 = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto read0 = make_shared(init_const0, "v0"); + auto read1 = make_shared(init_const1, "v1"); std::vector> args = {read0, read1}; - auto add = make_shared(read0, read1); - auto assign0 = make_shared(add, "v0"); - auto assign1 = make_shared(add, "v1"); + auto add = make_shared(read0, read1); + auto assign0 = make_shared(add, "v0"); + auto assign1 = make_shared(add, "v1"); - f0 = make_shared(ResultVector({}), SinkVector({assign0, assign1}), ParameterVector{}); + f0 = make_shared(ResultVector({}), SinkVector({assign0, assign1}), ParameterVector{}); } { - auto init_const0 = op::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto init_const1 = op::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto read0 = make_shared(init_const0, "v0"); - auto read1 = make_shared(init_const1, "v1"); - auto add = make_shared(read0, read1); - auto squeeze = make_shared(add); - auto assign0 = make_shared(squeeze, "v0"); - auto assign1 = make_shared(add, "v1"); + auto init_const0 = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto init_const1 = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto read0 = make_shared(init_const0, "v0"); + auto read1 = make_shared(init_const1, "v1"); + auto add = make_shared(read0, read1); + auto squeeze = make_shared(add); + auto assign0 = make_shared(squeeze, "v0"); + auto assign1 = make_shared(add, "v1"); - f1 = make_shared(ResultVector({}), SinkVector({assign0, assign1}), ParameterVector{}); + f1 = make_shared(ResultVector({}), SinkVector({assign0, assign1}), ParameterVector{}); } const auto fc = FunctionsComparator::with_default() .enable(FunctionsComparator::ATTRIBUTES) @@ -568,41 +581,41 @@ TEST(build_graph, build_graph_with_sinks_compare) { } TEST(build_graph, build_graph_with_sinks_compare_reads) { - shared_ptr f0, f1; + shared_ptr f0, f1; { - auto variable0 = make_shared(VariableInfo{Shape{2, 2}, element::f32, "v0"}); - auto variable1 = make_shared(VariableInfo{Shape{2, 2}, element::f32, "v1"}); + auto variable0 = make_shared(op::util::VariableInfo{Shape{2, 2}, element::f32, "v0"}); + auto variable1 = make_shared(op::util::VariableInfo{Shape{2, 2}, element::f32, "v1"}); - auto init_const0 = op::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto read0 = make_shared(init_const0, variable0); - auto assign0 = make_shared(read0, variable0); + auto init_const0 = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto read0 = make_shared(init_const0, variable0); + auto assign0 = make_shared(read0, variable0); - auto init_const1 = op::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto read1 = make_shared(init_const1, variable1); - auto assign1 = make_shared(read1, variable1); + auto init_const1 = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto read1 = make_shared(init_const1, variable1); + auto assign1 = make_shared(read1, variable1); - f0 = make_shared(ResultVector({}), - SinkVector({assign0, assign1}), - ParameterVector{}, - VariableVector{variable0, variable1}); + f0 = make_shared(ResultVector({}), + SinkVector({assign0, assign1}), + ParameterVector{}, + op::util::VariableVector{variable0, variable1}); } { - auto variable0 = make_shared(VariableInfo{Shape{2, 2}, element::f32, "v0"}); - auto variable1 = make_shared(VariableInfo{Shape{2, 2}, element::f32, "v1"}); + auto variable0 = make_shared(op::util::VariableInfo{Shape{2, 2}, element::f32, "v0"}); + auto variable1 = make_shared(op::util::VariableInfo{Shape{2, 2}, element::f32, "v1"}); - auto init_const0 = op::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto read0 = make_shared(init_const0, variable1); - auto assign0 = make_shared(read0, variable0); + auto init_const0 = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto read0 = make_shared(init_const0, variable1); + auto assign0 = make_shared(read0, variable0); - auto init_const1 = op::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto read1 = make_shared(init_const1, variable0); - auto assign1 = make_shared(read1, variable1); + auto init_const1 = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto read1 = make_shared(init_const1, variable0); + auto assign1 = make_shared(read1, variable1); - f1 = make_shared(ResultVector({}), - SinkVector({assign0, assign1}), - ParameterVector{}, - VariableVector{variable0, variable1}); + f1 = make_shared(ResultVector({}), + SinkVector({assign0, assign1}), + ParameterVector{}, + op::util::VariableVector{variable0, variable1}); } const auto fc = FunctionsComparator::with_default() .enable(FunctionsComparator::ATTRIBUTES) @@ -612,35 +625,35 @@ TEST(build_graph, build_graph_with_sinks_compare_reads) { } TEST(build_graph, build_graph_with_sinks_compare_results) { - shared_ptr f0, f1; + shared_ptr f0, f1; { - auto variable0 = make_shared(VariableInfo{Shape{2, 2}, element::f32, "v0"}); - auto init_const0 = op::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto read0 = make_shared(init_const0, variable0); - auto op = make_shared(read0); - auto assign0 = make_shared(read0, variable0); - auto result0 = make_shared(assign0); - auto result1 = make_shared(op); + auto variable0 = make_shared(op::util::VariableInfo{Shape{2, 2}, element::f32, "v0"}); + auto init_const0 = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto read0 = make_shared(init_const0, variable0); + auto op = make_shared(read0); + auto assign0 = make_shared(read0, variable0); + auto result0 = make_shared(assign0); + auto result1 = make_shared(op); - f0 = make_shared(ResultVector({result0, result1}), - SinkVector({assign0}), - ParameterVector{}, - VariableVector{variable0}); + f0 = make_shared(ResultVector({result0, result1}), + SinkVector({assign0}), + ParameterVector{}, + op::util::VariableVector{variable0}); } { - auto variable0 = make_shared(VariableInfo{Shape{2, 2}, element::f32, "v0"}); - auto init_const0 = op::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); - auto read0 = make_shared(init_const0, variable0); - auto op = make_shared(read0); - auto assign0 = make_shared(read0, variable0); - auto result0 = make_shared(assign0); - auto result1 = make_shared(op); + auto variable0 = make_shared(op::util::VariableInfo{Shape{2, 2}, element::f32, "v0"}); + auto init_const0 = op::v0::Constant::create(element::f32, Shape{2, 2}, {0, 0, 0, 0}); + auto read0 = make_shared(init_const0, variable0); + auto op = make_shared(read0); + auto assign0 = make_shared(read0, variable0); + auto result0 = make_shared(assign0); + auto result1 = make_shared(op); - f1 = make_shared(ResultVector({result0, result1}), - SinkVector({assign0}), - ParameterVector{}, - VariableVector{variable0}); + f1 = make_shared(ResultVector({result0, result1}), + SinkVector({assign0}), + ParameterVector{}, + op::util::VariableVector{variable0}); } const auto fc = FunctionsComparator::with_default() .enable(FunctionsComparator::ATTRIBUTES) diff --git a/src/core/tests/builder_autobroadcast.cpp b/src/core/tests/builder_autobroadcast.cpp deleted file mode 100644 index f33c22f3766..00000000000 --- a/src/core/tests/builder_autobroadcast.cpp +++ /dev/null @@ -1,387 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "gtest/gtest.h" -#include "ngraph/builder/autobroadcast.hpp" -#include "ngraph/ngraph.hpp" - -NGRAPH_SUPPRESS_DEPRECATED_START - -using namespace std; -using namespace ngraph; - -shared_ptr getParamFromShape(const Shape& shape) { - return make_shared(element::f32, shape); -} - -inline const Shape& getShapeFromParam(const shared_ptr& node) { - return node->get_shape(); -} - -// input shapes are equal so AutoBroadcast does nothing -TEST(autobroadcast, no_broadcast_equal) { - Shape s2345{2, 3, 4, 5}; - auto lhs = getParamFromShape(s2345); - auto rhs = getParamFromShape(s2345); - - auto shaped = builder::numpy_broadcast({lhs, rhs}); - const shared_ptr& ab_lhs = shaped.first; - const shared_ptr& ab_rhs = shaped.second; - - EXPECT_EQ(ab_lhs, lhs); // no change - EXPECT_EQ(getShapeFromParam(ab_lhs), s2345); - - EXPECT_EQ(ab_rhs, rhs); // no change - EXPECT_EQ(getShapeFromParam(ab_rhs), s2345); -} - -// input shapes are incompatable -TEST(autobroadcast, no_broadcast_incompatable) { - Shape s2345{2, 3, 4, 5}; - Shape s6789{6, 7, 8, 9}; - auto lhs = getParamFromShape(s2345); - auto rhs = getParamFromShape(s6789); - - EXPECT_THROW(builder::numpy_broadcast({lhs, rhs}), builder::numpy_autobroadcast_incompatible_shapes); -} - -// basic broadcast test -// 1D to 2D -// lhs broadcast to 2,3 -TEST(autobroadcast, normal_broadcast_2d) { - Shape s3{3}; - Shape s23{2, 3}; - auto lhs = getParamFromShape(s3); - auto rhs = getParamFromShape(s23); - - auto shaped = builder::numpy_broadcast({lhs, rhs}); - const shared_ptr& ab_lhs = shaped.first; - const shared_ptr& ab_rhs = shaped.second; - - EXPECT_NE(ab_lhs, lhs); - EXPECT_EQ(getShapeFromParam(ab_lhs), s23); - - EXPECT_EQ(ab_rhs, rhs); // no change - EXPECT_EQ(getShapeFromParam(ab_rhs), s23); -} - -// basic broadcast test -// 2D to 3D -// lhs broadcast to 2,3,4 -TEST(autobroadcast, normal_broadcast_3d) { - Shape s34{3, 4}; - Shape s234{2, 3, 4}; - auto lhs = getParamFromShape(s34); - auto rhs = getParamFromShape(s234); - - auto shaped = builder::numpy_broadcast({lhs, rhs}); - const shared_ptr& ab_lhs = shaped.first; - const shared_ptr& ab_rhs = shaped.second; - - EXPECT_NE(ab_lhs, lhs); - EXPECT_EQ(getShapeFromParam(ab_lhs), s234); - - EXPECT_EQ(ab_rhs, rhs); // no change - EXPECT_EQ(getShapeFromParam(ab_rhs), s234); -} - -// basic broadcast test -// 3D to 4D -// lhs broadcast to 2,3,4,5 -TEST(autobroadcast, normal_broadcast_4d) { - Shape s345{3, 4, 5}; - Shape s2345{2, 3, 4, 5}; - auto lhs = getParamFromShape(s345); - auto rhs = getParamFromShape(s2345); - - auto shaped = builder::numpy_broadcast({lhs, rhs}); - const shared_ptr& ab_lhs = shaped.first; - const shared_ptr& ab_rhs = shaped.second; - - EXPECT_NE(ab_lhs, lhs); - EXPECT_EQ(getShapeFromParam(ab_lhs), s2345); - - EXPECT_EQ(ab_rhs, rhs); // no change - EXPECT_EQ(getShapeFromParam(ab_rhs), s2345); -} - -// basic reshape and broadcast test -// rhs reshape to 2,3,4 then -// rhs broadcast to 2,3,4,5 -TEST(autobroadcast, reshape_1x_broadcast) { - Shape s2345{2, 3, 4, 5}; - Shape s2341{2, 3, 4, 1}; - auto lhs = getParamFromShape(s2345); - auto rhs = getParamFromShape(s2341); - - auto shaped = builder::numpy_broadcast({lhs, rhs}); - const shared_ptr& ab_lhs = shaped.first; - const shared_ptr& ab_rhs = shaped.second; - - EXPECT_EQ(ab_lhs, lhs); // no change - EXPECT_EQ(getShapeFromParam(ab_lhs), s2345); - - EXPECT_NE(ab_rhs, rhs); - EXPECT_EQ(getShapeFromParam(ab_rhs), s2345); -} - -// same as above, but additionally -// lhs reshape to 2,4,5 then -// lhs broadcast to 2,3,4,5 -TEST(autobroadcast, reshape_2x_broadcast) { - Shape s2145{2, 1, 4, 5}; - Shape s2341{2, 3, 4, 1}; - auto lhs = getParamFromShape(s2145); - auto rhs = getParamFromShape(s2341); - - auto shaped = builder::numpy_broadcast({lhs, rhs}); - const shared_ptr& ab_lhs = shaped.first; - const shared_ptr& ab_rhs = shaped.second; - - Shape s2345{2, 3, 4, 5}; - - EXPECT_NE(ab_lhs, lhs); - EXPECT_EQ(getShapeFromParam(ab_lhs), s2345); - - EXPECT_NE(ab_rhs, rhs); - EXPECT_EQ(getShapeFromParam(ab_rhs), s2345); -} - -// matching singular dimension on axis 2 -// should not require reshape of either lhs or rhs -// i.e. this should be the same as normal broadcast casse -// rhs broadcast to 2,3,1,5 -TEST(autobroadcast, broadcast_with_dim1) { - Shape s2315{2, 3, 1, 5}; - Shape s315{3, 1, 5}; - auto lhs = getParamFromShape(s2315); - auto rhs = getParamFromShape(s315); - - auto shaped = builder::numpy_broadcast({lhs, rhs}); - const shared_ptr& ab_lhs = shaped.first; - const shared_ptr& ab_rhs = shaped.second; - - EXPECT_EQ(ab_lhs, lhs); // no change - EXPECT_EQ(getShapeFromParam(ab_lhs), s2315); - - EXPECT_NE(ab_rhs, rhs); - EXPECT_EQ(getShapeFromParam(ab_rhs), s2315); -} - -// reshape only test -// rhs reshape to 1,3,4,5 with no broadcast -TEST(autobroadcast, broadcast_with_leading_dim1) { - Shape s1345{1, 3, 4, 5}; - Shape s345{3, 4, 5}; - auto lhs = getParamFromShape(s1345); - auto rhs = getParamFromShape(s345); - - auto shaped = builder::numpy_broadcast({lhs, rhs}); - const shared_ptr& ab_lhs = shaped.first; - const shared_ptr& ab_rhs = shaped.second; - - EXPECT_EQ(ab_lhs, lhs); // no change - EXPECT_EQ(getShapeFromParam(ab_lhs), s1345); - - EXPECT_NE(ab_rhs, rhs); - EXPECT_EQ(getShapeFromParam(ab_rhs), s1345); -} - -TEST(autobroadcast, numpy_broadcast_for_matmul_op_2d) { - const Shape lhs{3, 1, 4, 6}; - const Shape rhs{6, 5}; - const auto lhs_node = make_shared(element::f32, lhs); - const auto rhs_node = make_shared(element::f32, rhs); - - const OutputVector result = builder::numpy_broadcast_for_matmul_operation(lhs_node, rhs_node); - - EXPECT_EQ(result.at(0).get_shape(), (Shape{3, 1, 4, 6})); - EXPECT_EQ(result.at(1).get_shape(), (Shape{3, 1, 6, 5})); -} - -TEST(autobroadcast, numpy_broadcast_for_matmul_op_3d) { - const Shape lhs{3, 1, 4, 6}; - const Shape rhs{2, 6, 5}; - const auto lhs_node = make_shared(element::f32, lhs); - const auto rhs_node = make_shared(element::f32, rhs); - - const OutputVector result = builder::numpy_broadcast_for_matmul_operation(lhs_node, rhs_node); - - EXPECT_EQ(result.at(0).get_shape(), (Shape{3, 2, 4, 6})); - EXPECT_EQ(result.at(1).get_shape(), (Shape{3, 2, 6, 5})); -} - -TEST(autobroadcast, numpy_broadcast_for_matmul_op_nop) { - const Shape lhs{4, 6}; - const Shape rhs{6, 5}; - const auto lhs_node = make_shared(element::f32, lhs); - const auto rhs_node = make_shared(element::f32, rhs); - - const OutputVector result = builder::numpy_broadcast_for_matmul_operation(lhs_node, rhs_node); - - EXPECT_EQ(result.at(0).get_shape(), (Shape{4, 6})); - EXPECT_EQ(result.at(1).get_shape(), (Shape{6, 5})); -} - -TEST(autobroadcast, opset1_legacy_broadcast_scalar) { - const Shape lhs{2, 3, 4, 5}; - const Shape rhs{}; - size_t start_match_axis{3}; - const auto lhs_node = make_shared(element::f32, lhs); - const auto rhs_node = make_shared(element::f32, rhs); - - const Output result = - builder::opset1::legacy_broadcast_for_binary_operation(lhs_node, rhs_node, start_match_axis); - - EXPECT_EQ(result.get_shape(), lhs); -} - -TEST(autobroadcast, opset1_legacy_broadcast_1elem_tensor) { - const Shape lhs{2, 3, 4, 5}; - const Shape rhs{1, 1, 1}; - size_t start_match_axis{1}; - const auto lhs_node = make_shared(element::f32, lhs); - const auto rhs_node = make_shared(element::f32, rhs); - - const Output result = - builder::opset1::legacy_broadcast_for_binary_operation(lhs_node, rhs_node, start_match_axis); - - EXPECT_EQ(result.get_shape(), lhs); -} - -TEST(autobroadcast, opset1_legacy_broadcast_1d) { - const Shape lhs{2, 3, 4, 5}; - const Shape rhs{5}; - size_t start_match_axis{3}; - const auto lhs_node = make_shared(element::f32, lhs); - const auto rhs_node = make_shared(element::f32, rhs); - - const Output result = - builder::opset1::legacy_broadcast_for_binary_operation(lhs_node, rhs_node, start_match_axis); - - EXPECT_EQ(result.get_shape(), lhs); -} - -TEST(autobroadcast, opset1_legacy_broadcast_2d) { - const Shape lhs{2, 3, 4, 5}; - const Shape rhs{4, 5}; - size_t start_match_axis{2}; - const auto lhs_node = make_shared(element::f32, lhs); - const auto rhs_node = make_shared(element::f32, rhs); - - const Output result = - builder::opset1::legacy_broadcast_for_binary_operation(lhs_node, rhs_node, start_match_axis); - - EXPECT_EQ(result.get_shape(), lhs); -} - -TEST(autobroadcast, opset1_legacy_broadcast_2d_inside) { - const Shape lhs{2, 3, 4, 5}; - const Shape rhs{3, 4}; - size_t start_match_axis{1}; - const auto lhs_node = make_shared(element::f32, lhs); - const auto rhs_node = make_shared(element::f32, rhs); - - const Output result = - builder::opset1::legacy_broadcast_for_binary_operation(lhs_node, rhs_node, start_match_axis); - - EXPECT_EQ(result.get_shape(), lhs); -} - -TEST(autobroadcast, opset1_legacy_broadcast_1d_left) { - const Shape lhs{2, 3, 4, 5}; - const Shape rhs{2}; - size_t start_match_axis{0}; - const auto lhs_node = make_shared(element::f32, lhs); - const auto rhs_node = make_shared(element::f32, rhs); - - const Output result = - builder::opset1::legacy_broadcast_for_binary_operation(lhs_node, rhs_node, start_match_axis); - - EXPECT_EQ(result.get_shape(), lhs); -} - -TEST(autobroadcast, opset1_legacy_broadcast_identical) { - const Shape lhs{2, 3, 4, 5}; - size_t start_match_axis{0}; - const auto lhs_node = make_shared(element::f32, lhs); - const auto rhs_node = make_shared(element::f32, lhs); - - const Output result = - builder::opset1::legacy_broadcast_for_binary_operation(lhs_node, rhs_node, start_match_axis); - - EXPECT_EQ(result.get_shape(), lhs); -} - -TEST(autobroadcast, axes_mapping_from_bcast_axes) { - const Shape output_shape{2, 3, 4, 5}; - const Shape input_shape{3, 5}; - const AxisSet broadcast_axes{0, 2}; - - auto axes_mapping = builder::opset1::get_axes_mapping_output(output_shape, broadcast_axes); - EXPECT_TRUE(op::is_constant(axes_mapping.get_node())); - Shape axes_mapping_shape = ov::as_type(axes_mapping.get_node())->get_shape_val(); - EXPECT_EQ(axes_mapping_shape.size(), 2); - EXPECT_EQ(axes_mapping_shape, (Shape{1, 3})); -} - -TEST(autobroadcast, axes_mapping_from_bcast_axes_scalar) { - const Shape output_shape{2, 3, 4, 5}; - const Shape input_shape{}; - const AxisSet broadcast_axes{0, 1, 2, 3}; - - auto axes_mapping = builder::opset1::get_axes_mapping_output(output_shape, broadcast_axes); - EXPECT_TRUE(op::is_constant(axes_mapping.get_node())); - Shape axes_mapping_shape = ov::as_type(axes_mapping.get_node())->get_shape_val(); - EXPECT_EQ(axes_mapping_shape.size(), 0); - EXPECT_EQ(axes_mapping_shape, (Shape{})); -} - -TEST(autobroadcast, axes_mapping_from_bcast_axes_identical) { - const Shape output_shape{2, 3, 4, 5}; - const Shape input_shape(output_shape); - const AxisSet broadcast_axes{}; - - auto axes_mapping = builder::opset1::get_axes_mapping_output(output_shape, broadcast_axes); - EXPECT_TRUE(op::is_constant(axes_mapping.get_node())); - Shape axes_mapping_shape = ov::as_type(axes_mapping.get_node())->get_shape_val(); - EXPECT_EQ(axes_mapping_shape.size(), output_shape.size()); - EXPECT_EQ(axes_mapping_shape, (Shape{0, 1, 2, 3})); -} - -TEST(autobroadcast, axes_mapping_start_match_axis) { - const PartialShape output_shape{2, 3, 4, 5}; - const PartialShape input_shape{3, 4}; - const std::size_t start_match_axis{1}; - - auto axes_mapping = builder::opset1::get_axes_mapping_output(output_shape, input_shape, start_match_axis); - EXPECT_TRUE(op::is_constant(axes_mapping.get_node())); - Shape axes_mapping_shape = ov::as_type(axes_mapping.get_node())->get_shape_val(); - EXPECT_EQ(axes_mapping_shape.size(), 2); - EXPECT_EQ(axes_mapping_shape, (Shape{1, 2})); -} - -TEST(autobroadcast, axes_mapping_start_match_axis_scalar) { - const PartialShape output_shape{2, 3, 4, 5}; - const PartialShape input_shape{}; - const std::size_t start_match_axis{4}; - - auto axes_mapping = builder::opset1::get_axes_mapping_output(output_shape, input_shape, start_match_axis); - EXPECT_TRUE(op::is_constant(axes_mapping.get_node())); - Shape axes_mapping_shape = ov::as_type(axes_mapping.get_node())->get_shape_val(); - EXPECT_EQ(axes_mapping_shape.size(), 0); - EXPECT_EQ(axes_mapping_shape, (Shape{})); -} - -TEST(autobroadcast, axes_mapping_start_match_axis_identical) { - const PartialShape output_shape{2, 3, 4, 5}; - const PartialShape input_shape{2, 3, 4, 5}; - const std::size_t start_match_axis{0}; - - auto axes_mapping = builder::opset1::get_axes_mapping_output(output_shape, input_shape, start_match_axis); - EXPECT_TRUE(op::is_constant(axes_mapping.get_node())); - Shape axes_mapping_shape = ov::as_type(axes_mapping.get_node())->get_shape_val(); - EXPECT_EQ(axes_mapping_shape.size(), output_shape.rank().get_length()); - EXPECT_EQ(axes_mapping_shape, (Shape{0, 1, 2, 3})); -} diff --git a/src/core/tests/check.cpp b/src/core/tests/check.cpp index 42d086da6ac..6583a2c8c72 100644 --- a/src/core/tests/check.cpp +++ b/src/core/tests/check.cpp @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ngraph/check.hpp" - #include #include "common_test_utils/test_assertions.hpp" @@ -50,44 +48,6 @@ TEST(check, check_with_explanation) { EXPECT_TRUE(check_failure_thrown); } -TEST(check, ngraph_check_true_string_info) { - NGRAPH_CHECK(true, "this should not throw"); -} - -TEST(check, ngraph_check_true_non_string_info) { - NGRAPH_CHECK(true, "this should not throw", 123); -} - -TEST(check, ngraph_check_true_no_info) { - NGRAPH_CHECK(true); -} - -TEST(check, ngraph_check_false_string_info) { - EXPECT_THROW({ NGRAPH_CHECK(false, "this should throw"); }, ngraph::CheckFailure); -} - -TEST(check, ngraph_check_false_non_string_info) { - EXPECT_THROW({ NGRAPH_CHECK(false, "this should throw", 123); }, ngraph::CheckFailure); -} - -TEST(check, ngraph_check_false_no_info) { - EXPECT_THROW({ NGRAPH_CHECK(false); }, ngraph::CheckFailure); -} - -TEST(check, ngraph_check_with_explanation) { - bool check_failure_thrown = false; - - try { - NGRAPH_CHECK(false, "xyzzyxyzzy", 123); - } catch (const ngraph::CheckFailure& e) { - check_failure_thrown = true; - EXPECT_PRED_FORMAT2(testing::IsSubstring, "Check 'false' failed at", e.what()); - EXPECT_PRED_FORMAT2(testing::IsSubstring, "xyzzyxyzzy123", e.what()); - } - - EXPECT_TRUE(check_failure_thrown); -} - TEST(check, ov_throw_exception_check_relative_path_to_source) { using namespace testing; const auto path = ov::util::path_join({"src", "core", "tests", "check.cpp"}); diff --git a/src/core/tests/constant.cpp b/src/core/tests/constant.cpp index cbf135373b3..09432d9b20d 100644 --- a/src/core/tests/constant.cpp +++ b/src/core/tests/constant.cpp @@ -2,15 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "openvino/op/constant.hpp" + #include #include #include "common_test_utils/type_prop.hpp" -#include "ngraph/ngraph.hpp" -#include "ngraph/runtime/host_tensor.hpp" +#include "openvino/core/except.hpp" -using namespace ngraph; +using namespace ov; using namespace std; // @@ -20,7 +21,7 @@ using namespace std; TEST(constant, boolean_string) { Shape shape{4}; vector input{"1", "0", "1", "0"}; - op::Constant c(element::boolean, shape, input); + ov::op::v0::Constant c(element::boolean, shape, input); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -43,7 +44,7 @@ TEST(constant, boolean_string) { TEST(constant, boolean_string_broadcast) { Shape shape{4}; - op::Constant c(element::boolean, shape, vector{"1"}); + ov::op::v0::Constant c(element::boolean, shape, vector{"1"}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -60,7 +61,7 @@ TEST(constant, boolean_string_broadcast) { TEST(constant, boolean_vector) { Shape shape{4}; - op::Constant c(element::boolean, shape, vector{1, 0, 1, 0}); + ov::op::v0::Constant c(element::boolean, shape, vector{1, 0, 1, 0}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -77,7 +78,7 @@ TEST(constant, boolean_vector) { TEST(constant, boolean_vector_broadcast) { Shape shape{4}; - op::Constant c(element::boolean, shape, vector{1}); + ov::op::v0::Constant c(element::boolean, shape, vector{1}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -99,7 +100,7 @@ TEST(constant, boolean_vector_broadcast) { TEST(constant, float_string) { Shape shape{4}; vector input{"1", "0", "1", "0"}; - op::Constant c(element::f32, shape, input); + ov::op::v0::Constant c(element::f32, shape, input); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -122,7 +123,7 @@ TEST(constant, float_string) { TEST(constant, float_string_broadcast) { Shape shape{4}; - op::Constant c(element::f32, shape, vector{"1"}); + ov::op::v0::Constant c(element::f32, shape, vector{"1"}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -139,7 +140,7 @@ TEST(constant, float_string_broadcast) { TEST(constant, float_vector) { Shape shape{4}; - op::Constant c(element::f32, shape, vector{1, 0, 1, 0}); + ov::op::v0::Constant c(element::f32, shape, vector{1, 0, 1, 0}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -156,7 +157,7 @@ TEST(constant, float_vector) { TEST(constant, float_vector_broadcast) { Shape shape{4}; - op::Constant c(element::f32, shape, vector{1}); + ov::op::v0::Constant c(element::f32, shape, vector{1}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -178,7 +179,7 @@ TEST(constant, float_vector_broadcast) { TEST(constant, double_string) { Shape shape{4}; vector input{"1", "0", "1", "0"}; - op::Constant c(element::f64, shape, input); + ov::op::v0::Constant c(element::f64, shape, input); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -201,7 +202,7 @@ TEST(constant, double_string) { TEST(constant, double_string_broadcast) { Shape shape{4}; - op::Constant c(element::f64, shape, vector{"1"}); + ov::op::v0::Constant c(element::f64, shape, vector{"1"}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -218,7 +219,7 @@ TEST(constant, double_string_broadcast) { TEST(constant, double_vector) { Shape shape{4}; - op::Constant c(element::f64, shape, vector{1, 0, 1, 0}); + ov::op::v0::Constant c(element::f64, shape, vector{1, 0, 1, 0}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -235,7 +236,7 @@ TEST(constant, double_vector) { TEST(constant, double_vector_broadcast) { Shape shape{4}; - op::Constant c(element::f64, shape, vector{1}); + ov::op::v0::Constant c(element::f64, shape, vector{1}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -257,7 +258,7 @@ TEST(constant, double_vector_broadcast) { TEST(constant, int4_string) { Shape shape{3}; std::vector input{"1", "0", "-1"}; - op::Constant c(element::i4, shape, input); + ov::op::v0::Constant c(element::i4, shape, input); auto v = c.cast_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -277,7 +278,7 @@ TEST(constant, int4_string) { TEST(constant, int4_string_broadcast_negative_number) { Shape shape{3}; - op::Constant c(element::i4, shape, vector{"-1"}); + ov::op::v0::Constant c(element::i4, shape, vector{"-1"}); auto v = c.cast_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], -1); @@ -293,7 +294,7 @@ TEST(constant, int4_string_broadcast_negative_number) { TEST(constant, int4_string_broadcast_positive_number) { Shape shape{3}; - op::Constant c(element::i4, shape, vector{"1"}); + ov::op::v0::Constant c(element::i4, shape, vector{"1"}); auto v = c.cast_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -309,7 +310,7 @@ TEST(constant, int4_string_broadcast_positive_number) { TEST(constant, int4_vector_negative_number) { Shape shape{3}; - op::Constant c(element::i4, shape, vector{-1, -2, -1}); + ov::op::v0::Constant c(element::i4, shape, vector{-1, -2, -1}); auto v = c.cast_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], int8_t(-1)); @@ -323,7 +324,7 @@ TEST(constant, int4_vector_negative_number) { TEST(constant, int4_vector_positive_number) { Shape shape{3}; - op::Constant c(element::i4, shape, vector{1, 2, 5}); + ov::op::v0::Constant c(element::i4, shape, vector{1, 2, 5}); auto v = c.cast_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], int8_t(1)); @@ -337,7 +338,7 @@ TEST(constant, int4_vector_positive_number) { TEST(constant, int4_vector_broadcast_negative_number) { Shape shape{3}; - op::Constant c(element::i4, shape, vector{-1}); + ov::op::v0::Constant c(element::i4, shape, vector{-1}); auto v = c.cast_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], int8_t(-1)); @@ -351,7 +352,7 @@ TEST(constant, int4_vector_broadcast_negative_number) { TEST(constant, int4_vector_broadcast_positive_number) { Shape shape{3}; - op::Constant c(element::i4, shape, vector{3}); + ov::op::v0::Constant c(element::i4, shape, vector{3}); auto v = c.cast_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], int8_t(3)); @@ -365,17 +366,19 @@ TEST(constant, int4_vector_broadcast_positive_number) { TEST(constant, int4_input_value_validation) { Shape shape{2}; - EXPECT_THROW(op::Constant c(element::i4, shape, 8), ::ngraph::CheckFailure); - EXPECT_THROW(op::Constant c(element::i4, shape, -9), ::ngraph::CheckFailure); + EXPECT_THROW(ov::op::v0::Constant c(element::i4, shape, 8), ::ngraph::CheckFailure); + EXPECT_THROW(ov::op::v0::Constant c(element::i4, shape, -9), ::ngraph::CheckFailure); - EXPECT_THROW(op::Constant c(element::i4, shape, std::vector{-9}), ::ngraph::CheckFailure); - EXPECT_THROW(op::Constant c(element::i4, shape, std::vector{8}), ::ngraph::CheckFailure); + EXPECT_THROW(ov::op::v0::Constant c(element::i4, shape, std::vector{-9}), ::ngraph::CheckFailure); + EXPECT_THROW(ov::op::v0::Constant c(element::i4, shape, std::vector{8}), ::ngraph::CheckFailure); - EXPECT_THROW(op::Constant c(element::i4, shape, std::vector{-9, 1}), ::ngraph::CheckFailure); - EXPECT_THROW(op::Constant c(element::i4, shape, std::vector{8, 2}), ::ngraph::CheckFailure); + EXPECT_THROW(ov::op::v0::Constant c(element::i4, shape, std::vector{-9, 1}), ::ngraph::CheckFailure); + EXPECT_THROW(ov::op::v0::Constant c(element::i4, shape, std::vector{8, 2}), ::ngraph::CheckFailure); - EXPECT_THROW(op::Constant c(element::i4, shape, std::vector{"-9", "1"}), ::ngraph::CheckFailure); - EXPECT_THROW(op::Constant c(element::i4, shape, std::vector{"8", "1"}), ::ngraph::CheckFailure); + EXPECT_THROW(ov::op::v0::Constant c(element::i4, shape, std::vector{"-9", "1"}), + ::ngraph::CheckFailure); + EXPECT_THROW(ov::op::v0::Constant c(element::i4, shape, std::vector{"8", "1"}), + ::ngraph::CheckFailure); } // @@ -385,7 +388,7 @@ TEST(constant, int4_input_value_validation) { TEST(constant, int8_string) { Shape shape{4}; std::vector input{"1", "0", "1", "0"}; - op::Constant c(element::i8, shape, input); + ov::op::v0::Constant c(element::i8, shape, input); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -410,7 +413,7 @@ TEST(constant, int8_string) { TEST(constant, int8_string_broadcast) { Shape shape{4}; - op::Constant c(element::i8, shape, vector{"1"}); + ov::op::v0::Constant c(element::i8, shape, vector{"1"}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -429,7 +432,7 @@ TEST(constant, int8_string_broadcast) { TEST(constant, int8_vector) { Shape shape{4}; - op::Constant c(element::i8, shape, vector{1, 0, 1, 0}); + ov::op::v0::Constant c(element::i8, shape, vector{1, 0, 1, 0}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -446,7 +449,7 @@ TEST(constant, int8_vector) { TEST(constant, int8_vector_broadcast) { Shape shape{4}; - op::Constant c(element::i8, shape, vector{1}); + ov::op::v0::Constant c(element::i8, shape, vector{1}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -468,7 +471,7 @@ TEST(constant, int8_vector_broadcast) { TEST(constant, int16_string) { Shape shape{4}; vector input{"1", "0", "1", "0"}; - op::Constant c(element::i16, shape, input); + ov::op::v0::Constant c(element::i16, shape, input); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -491,7 +494,7 @@ TEST(constant, int16_string) { TEST(constant, int16_string_broadcast) { Shape shape{4}; - op::Constant c(element::i16, shape, vector{"1"}); + ov::op::v0::Constant c(element::i16, shape, vector{"1"}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -508,7 +511,7 @@ TEST(constant, int16_string_broadcast) { TEST(constant, int16_vector) { Shape shape{4}; - op::Constant c(element::i16, shape, vector{1, 0, 1, 0}); + ov::op::v0::Constant c(element::i16, shape, vector{1, 0, 1, 0}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -525,7 +528,7 @@ TEST(constant, int16_vector) { TEST(constant, int16_vector_broadcast) { Shape shape{4}; - op::Constant c(element::i16, shape, vector{1}); + ov::op::v0::Constant c(element::i16, shape, vector{1}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -547,7 +550,7 @@ TEST(constant, int16_vector_broadcast) { TEST(constant, int32_string) { Shape shape{4}; vector input{"1", "0", "1", "0"}; - op::Constant c(element::i32, shape, input); + ov::op::v0::Constant c(element::i32, shape, input); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -570,7 +573,7 @@ TEST(constant, int32_string) { TEST(constant, int32_string_broadcast) { Shape shape{4}; - op::Constant c(element::i32, shape, vector{"1"}); + ov::op::v0::Constant c(element::i32, shape, vector{"1"}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -587,7 +590,7 @@ TEST(constant, int32_string_broadcast) { TEST(constant, int32_vector) { Shape shape{4}; - op::Constant c(element::i32, shape, vector{1, 0, 1, 0}); + ov::op::v0::Constant c(element::i32, shape, vector{1, 0, 1, 0}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -604,7 +607,7 @@ TEST(constant, int32_vector) { TEST(constant, int32_vector_broadcast) { Shape shape{4}; - op::Constant c(element::i32, shape, vector{1}); + ov::op::v0::Constant c(element::i32, shape, vector{1}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -626,7 +629,7 @@ TEST(constant, int32_vector_broadcast) { TEST(constant, int64_string) { Shape shape{4}; vector input{"1", "0", "1", "0"}; - op::Constant c(element::i64, shape, input); + ov::op::v0::Constant c(element::i64, shape, input); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -649,7 +652,7 @@ TEST(constant, int64_string) { TEST(constant, int64_string_broadcast) { Shape shape{4}; - op::Constant c(element::i64, shape, vector{"1"}); + ov::op::v0::Constant c(element::i64, shape, vector{"1"}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -666,7 +669,7 @@ TEST(constant, int64_string_broadcast) { TEST(constant, int64_vector) { Shape shape{4}; - op::Constant c(element::i64, shape, vector{1, 0, 1, 0}); + ov::op::v0::Constant c(element::i64, shape, vector{1, 0, 1, 0}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -683,7 +686,7 @@ TEST(constant, int64_vector) { TEST(constant, int64_vector_broadcast) { Shape shape{4}; - op::Constant c(element::i64, shape, vector{1}); + ov::op::v0::Constant c(element::i64, shape, vector{1}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -705,7 +708,7 @@ TEST(constant, int64_vector_broadcast) { TEST(constant, uint1_string) { Shape shape{4}; vector input{"1", "0", "1", "0"}; - op::Constant c(element::u1, shape, input); + ov::op::v0::Constant c(element::u1, shape, input); auto v = c.cast_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -725,7 +728,7 @@ TEST(constant, uint1_string) { TEST(constant, uint1_string_broadcast) { Shape shape{4}; - op::Constant c(element::u1, shape, vector{"1"}); + ov::op::v0::Constant c(element::u1, shape, vector{"1"}); auto v = c.cast_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -740,7 +743,7 @@ TEST(constant, uint1_string_broadcast) { TEST(constant, uint1_vector_less_than_single_byte) { Shape shape{4}; vector input{1, 0, 1, 0}; - op::Constant c(element::u1, shape, input); + ov::op::v0::Constant c(element::u1, shape, input); auto v = c.cast_vector(); ASSERT_EQ(v.size(), shape_size(shape)); for (unsigned i = 0; i != input.size(); ++i) { @@ -754,7 +757,7 @@ TEST(constant, uint1_vector_less_than_single_byte) { TEST(constant, uint1_vector_bigger_than_single_byte) { Shape shape{12}; vector input{1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0}; - op::Constant c(element::u1, shape, input); + ov::op::v0::Constant c(element::u1, shape, input); auto v = c.cast_vector(); ASSERT_EQ(v.size(), shape_size(shape)); for (unsigned i = 0; i != input.size(); ++i) { @@ -767,7 +770,7 @@ TEST(constant, uint1_vector_bigger_than_single_byte) { TEST(constant, uint1_vector_broadcast) { Shape shape{3}; - op::Constant c(element::u1, shape, vector{1}); + ov::op::v0::Constant c(element::u1, shape, vector{1}); auto v = c.cast_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], int8_t(1)); @@ -785,7 +788,7 @@ TEST(constant, uint1_vector_broadcast) { TEST(constant, uint4_string) { Shape shape{4}; vector input{"1", "0", "1", "0"}; - op::Constant c(element::u4, shape, input); + ov::op::v0::Constant c(element::u4, shape, input); auto v = c.cast_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -806,7 +809,7 @@ TEST(constant, uint4_string) { TEST(constant, uint4_string_broadcast) { Shape shape{4}; - op::Constant c(element::u4, shape, vector{"1"}); + ov::op::v0::Constant c(element::u4, shape, vector{"1"}); auto v = c.cast_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -821,7 +824,7 @@ TEST(constant, uint4_string_broadcast) { TEST(constant, uint4_vector) { Shape shape{4}; - op::Constant c(element::u4, shape, vector{1, 0, 1, 0}); + ov::op::v0::Constant c(element::u4, shape, vector{1, 0, 1, 0}); auto v = c.cast_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -836,7 +839,7 @@ TEST(constant, uint4_vector) { TEST(constant, uint4_vector_broadcast) { Shape shape{3}; - op::Constant c(element::u4, shape, vector{1}); + ov::op::v0::Constant c(element::u4, shape, vector{1}); auto v = c.cast_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], int8_t(1)); @@ -852,17 +855,19 @@ TEST(constant, uint4_vector_broadcast) { TEST(constant, uint4_input_value_validation) { Shape shape{2}; - EXPECT_THROW(op::Constant c(element::u4, shape, 16), ::ngraph::CheckFailure); - EXPECT_THROW(op::Constant c(element::u4, shape, -1), ::ngraph::CheckFailure); + EXPECT_THROW(ov::op::v0::Constant c(element::u4, shape, 16), ::ngraph::CheckFailure); + EXPECT_THROW(ov::op::v0::Constant c(element::u4, shape, -1), ::ngraph::CheckFailure); - EXPECT_THROW(op::Constant c(element::u4, shape, std::vector{-1}), ::ngraph::CheckFailure); - EXPECT_THROW(op::Constant c(element::u4, shape, std::vector{16}), ::ngraph::CheckFailure); + EXPECT_THROW(ov::op::v0::Constant c(element::u4, shape, std::vector{-1}), ::ngraph::CheckFailure); + EXPECT_THROW(ov::op::v0::Constant c(element::u4, shape, std::vector{16}), ::ngraph::CheckFailure); - EXPECT_THROW(op::Constant c(element::u4, shape, std::vector{-1, 1}), ::ngraph::CheckFailure); - EXPECT_THROW(op::Constant c(element::u4, shape, std::vector{16, 2}), ::ngraph::CheckFailure); + EXPECT_THROW(ov::op::v0::Constant c(element::u4, shape, std::vector{-1, 1}), ::ngraph::CheckFailure); + EXPECT_THROW(ov::op::v0::Constant c(element::u4, shape, std::vector{16, 2}), ::ngraph::CheckFailure); - EXPECT_THROW(op::Constant c(element::u4, shape, std::vector{"-1", "1"}), ::ngraph::CheckFailure); - EXPECT_THROW(op::Constant c(element::u4, shape, std::vector{"16", "1"}), ::ngraph::CheckFailure); + EXPECT_THROW(ov::op::v0::Constant c(element::u4, shape, std::vector{"-1", "1"}), + ::ngraph::CheckFailure); + EXPECT_THROW(ov::op::v0::Constant c(element::u4, shape, std::vector{"16", "1"}), + ::ngraph::CheckFailure); } // @@ -872,7 +877,7 @@ TEST(constant, uint4_input_value_validation) { TEST(constant, uint8_string) { Shape shape{4}; vector input{"1", "0", "1", "0"}; - op::Constant c(element::u8, shape, input); + ov::op::v0::Constant c(element::u8, shape, input); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -895,7 +900,7 @@ TEST(constant, uint8_string) { TEST(constant, uint8_string_broadcast) { Shape shape{4}; - op::Constant c(element::u8, shape, vector{"1"}); + ov::op::v0::Constant c(element::u8, shape, vector{"1"}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -912,7 +917,7 @@ TEST(constant, uint8_string_broadcast) { TEST(constant, uint8_vector) { Shape shape{4}; - op::Constant c(element::u8, shape, vector{1, 0, 1, 0}); + ov::op::v0::Constant c(element::u8, shape, vector{1, 0, 1, 0}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -929,7 +934,7 @@ TEST(constant, uint8_vector) { TEST(constant, uint8_vector_broadcast) { Shape shape{4}; - op::Constant c(element::u8, shape, vector{1}); + ov::op::v0::Constant c(element::u8, shape, vector{1}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -951,7 +956,7 @@ TEST(constant, uint8_vector_broadcast) { TEST(constant, uint16_string) { Shape shape{4}; vector input{"1", "0", "1", "0"}; - op::Constant c(element::u16, shape, input); + ov::op::v0::Constant c(element::u16, shape, input); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -974,7 +979,7 @@ TEST(constant, uint16_string) { TEST(constant, uint16_string_broadcast) { Shape shape{4}; - op::Constant c(element::u16, shape, vector{"1"}); + ov::op::v0::Constant c(element::u16, shape, vector{"1"}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -991,7 +996,7 @@ TEST(constant, uint16_string_broadcast) { TEST(constant, uint16_vector) { Shape shape{4}; - op::Constant c(element::u16, shape, vector{1, 0, 1, 0}); + ov::op::v0::Constant c(element::u16, shape, vector{1, 0, 1, 0}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -1008,7 +1013,7 @@ TEST(constant, uint16_vector) { TEST(constant, uint16_vector_broadcast) { Shape shape{4}; - op::Constant c(element::u16, shape, vector{1}); + ov::op::v0::Constant c(element::u16, shape, vector{1}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -1030,7 +1035,7 @@ TEST(constant, uint16_vector_broadcast) { TEST(constant, uint32_string) { Shape shape{4}; vector input{"1", "0", "1", "0"}; - op::Constant c(element::u32, shape, input); + ov::op::v0::Constant c(element::u32, shape, input); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -1053,7 +1058,7 @@ TEST(constant, uint32_string) { TEST(constant, uint32_string_broadcast) { Shape shape{4}; - op::Constant c(element::u32, shape, vector{"1"}); + ov::op::v0::Constant c(element::u32, shape, vector{"1"}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -1070,7 +1075,7 @@ TEST(constant, uint32_string_broadcast) { TEST(constant, uint32_vector) { Shape shape{4}; - op::Constant c(element::u32, shape, vector{1, 0, 1, 0}); + ov::op::v0::Constant c(element::u32, shape, vector{1, 0, 1, 0}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -1087,7 +1092,7 @@ TEST(constant, uint32_vector) { TEST(constant, uint32_vector_broadcast) { Shape shape{4}; - op::Constant c(element::u32, shape, vector{1}); + ov::op::v0::Constant c(element::u32, shape, vector{1}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -1109,7 +1114,7 @@ TEST(constant, uint32_vector_broadcast) { TEST(constant, uint64_string) { Shape shape{4}; vector input{"1", "0", "1", "0"}; - op::Constant c(element::u64, shape, input); + ov::op::v0::Constant c(element::u64, shape, input); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -1132,7 +1137,7 @@ TEST(constant, uint64_string) { TEST(constant, uint64_string_broadcast) { Shape shape{4}; - op::Constant c(element::u64, shape, vector{"1"}); + ov::op::v0::Constant c(element::u64, shape, vector{"1"}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -1149,7 +1154,7 @@ TEST(constant, uint64_string_broadcast) { TEST(constant, uint64_vector) { Shape shape{4}; - op::Constant c(element::u64, shape, vector{1, 0, 1, 0}); + ov::op::v0::Constant c(element::u64, shape, vector{1, 0, 1, 0}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -1166,7 +1171,7 @@ TEST(constant, uint64_vector) { TEST(constant, uint64_vector_broadcast) { Shape shape{4}; - op::Constant c(element::u64, shape, vector{1}); + ov::op::v0::Constant c(element::u64, shape, vector{1}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], 1); @@ -1188,7 +1193,7 @@ TEST(constant, uint64_vector_broadcast) { TEST(constant, bfloat16_string) { Shape shape{4}; vector input{"1", "0", "1", "0"}; - op::Constant c(element::bf16, shape, input); + ov::op::v0::Constant c(element::bf16, shape, input); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], bfloat16(1)); @@ -1211,7 +1216,7 @@ TEST(constant, bfloat16_string) { TEST(constant, bfloat16_string_broadcast) { Shape shape{4}; - op::Constant c(element::bf16, shape, vector{"1"}); + ov::op::v0::Constant c(element::bf16, shape, vector{"1"}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], bfloat16(1)); @@ -1228,7 +1233,7 @@ TEST(constant, bfloat16_string_broadcast) { TEST(constant, bfloat16_vector) { Shape shape{4}; - op::Constant c(element::bf16, shape, vector{1, 0, 1, 0}); + ov::op::v0::Constant c(element::bf16, shape, vector{1, 0, 1, 0}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], bfloat16(1)); @@ -1245,7 +1250,7 @@ TEST(constant, bfloat16_vector) { TEST(constant, bfloat16_vector_broadcast) { Shape shape{4}; - op::Constant c(element::bf16, shape, vector{1}); + ov::op::v0::Constant c(element::bf16, shape, vector{1}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], bfloat16(1)); @@ -1267,7 +1272,7 @@ TEST(constant, bfloat16_vector_broadcast) { TEST(constant, float16_string) { Shape shape{4}; vector input{"1", "0", "1", "0"}; - op::Constant c(element::f16, shape, input); + ov::op::v0::Constant c(element::f16, shape, input); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], float16(1)); @@ -1290,7 +1295,7 @@ TEST(constant, float16_string) { TEST(constant, float16_string_broadcast) { Shape shape{4}; - op::Constant c(element::f16, shape, vector{"1"}); + ov::op::v0::Constant c(element::f16, shape, vector{"1"}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], float16(1)); @@ -1307,7 +1312,7 @@ TEST(constant, float16_string_broadcast) { TEST(constant, float16_vector) { Shape shape{4}; - op::Constant c(element::f16, shape, vector{1, 0, 1, 0}); + ov::op::v0::Constant c(element::f16, shape, vector{1, 0, 1, 0}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], float16(1)); @@ -1324,7 +1329,7 @@ TEST(constant, float16_vector) { TEST(constant, float16_vector_broadcast) { Shape shape{4}; - op::Constant c(element::f16, shape, vector{1}); + ov::op::v0::Constant c(element::f16, shape, vector{1}); auto v = c.get_vector(); ASSERT_EQ(v.size(), shape_size(shape)); EXPECT_EQ(v[0], float16(1)); @@ -1341,8 +1346,8 @@ TEST(constant, float16_vector_broadcast) { TEST(constant, shared_data) { Shape shape{100, 200}; - auto c1 = make_shared(element::f16, shape, vector{123}); - auto c2 = static_pointer_cast(c1->clone_with_new_inputs({})); + auto c1 = make_shared(element::f16, shape, vector{123}); + auto c2 = static_pointer_cast(c1->clone_with_new_inputs({})); const int16_t* p1 = c1->get_data_ptr(); const int16_t* p2 = c2->get_data_ptr(); EXPECT_EQ(p1, p2); @@ -1352,7 +1357,7 @@ template ::testing::AssertionResult test_convert() { Shape shape{5}; vector expected{1, 2, 3, 4, 5}; - auto c1 = make_shared(ov::element::from(), shape, expected); + auto c1 = make_shared(ov::element::from(), shape, expected); vector actual = c1->template cast_vector(); ::testing::AssertionResult rc = (actual == expected ? ::testing::AssertionSuccess() : ::testing::AssertionFailure()); @@ -1522,7 +1527,7 @@ template ::testing::AssertionResult test_uniform_ctor() { Shape shape{5}; vector expected{3, 3, 3, 3, 3}; - auto c1 = make_shared(ov::element::from(), shape, 3); + auto c1 = make_shared(ov::element::from(), shape, 3); vector actual = c1->template cast_vector(); ::testing::AssertionResult rc = (actual == expected ? ::testing::AssertionSuccess() : ::testing::AssertionFailure()); @@ -1689,32 +1694,30 @@ TEST(constant, construct_uniform) { } TEST(constant, bad_get_data_ptr) { - op::Constant c(element::f32, Shape{}, vector{1.0}); + ov::op::v0::Constant c(element::f32, Shape{}, vector{1.0}); EXPECT_EQ(*c.get_data_ptr(), 1.0); try { c.get_data_ptr(); FAIL() << "Bad type not detected."; - } catch (const CheckFailure& error) { + } catch (const AssertFailure& error) { EXPECT_HAS_SUBSTRING(error.what(), std::string("get_data_ptr")); } try { c.get_data_ptr(); FAIL() << "Bad type not detected."; - } catch (const CheckFailure& error) { + } catch (const AssertFailure& error) { EXPECT_HAS_SUBSTRING(error.what(), std::string("get_data_ptr")); } } -OPENVINO_SUPPRESS_DEPRECATED_START - -TEST(constant, hold_host_tensor) { +TEST(constant, hold_tensor) { Shape shape{4}; void* hostDataPtr = nullptr; - std::shared_ptr constOp; + std::shared_ptr constOp; { - auto tensor = std::make_shared(element::f32, Shape{1, 2, 3, 3}); - hostDataPtr = tensor->get_data_ptr(); - constOp = std::make_shared(tensor); + auto tensor = ov::Tensor(element::f32, Shape{1, 2, 3, 3}); + hostDataPtr = tensor.data(); + constOp = std::make_shared(tensor); } const void* constDataPtr = constOp->get_data_ptr(); ASSERT_EQ(constDataPtr, hostDataPtr); @@ -1727,12 +1730,14 @@ TEST(constant, lazy_bitwise_identical) { auto shape = Shape{10, 1000, 1000}; auto type = element::i32; auto byte_size = shape_size(shape) * sizeof(int32_t); + OPENVINO_SUPPRESS_DEPRECATED_START auto aligned_weights_buffer = std::make_shared(byte_size); std::memset(aligned_weights_buffer->get_ptr(), 1, byte_size); auto weights = std::make_shared>>( aligned_weights_buffer->get_ptr(), aligned_weights_buffer->size(), aligned_weights_buffer); + OPENVINO_SUPPRESS_DEPRECATED_END using namespace std::chrono; auto create_constant = [&]() { @@ -1778,20 +1783,3 @@ TEST(constant, lazy_bitwise_identical) { // '10' times is guaranteed to be faster here (typical value is ~200'000) EXPECT_GT(bitwise_check_count_only, bitwise_check_count * 10); } - -// Disabled just because of long execution time. Enable for nightly builds in future -TEST(constant, DISABLED_nightly_huge_size_4GB) { - uint64_t start = 1llu << 32; - uint64_t s = start + 5; - std::vector data(s); - for (uint64_t i = start; i < s; i++) { - data[i] = static_cast(i - start + 42); - } - Shape shape{static_cast(s)}; - op::Constant c(element::u8, shape, data.data()); - auto v = c.get_vector(); - ASSERT_EQ(v.size(), shape_size(shape)); - for (uint64_t i = start; i < s; i++) { - EXPECT_EQ(v[i], i - start + 42) << i << " failed"; - } -} diff --git a/src/core/tests/control_dependencies.cpp b/src/core/tests/control_dependencies.cpp index ea300d8aae9..ba7d5ae8b3c 100644 --- a/src/core/tests/control_dependencies.cpp +++ b/src/core/tests/control_dependencies.cpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include #include #include @@ -11,19 +13,15 @@ #include "common_test_utils/all_close.hpp" #include "common_test_utils/ndarray.hpp" #include "common_test_utils/test_tools.hpp" -#include "gtest/gtest.h" -#include "ngraph/file_util.hpp" -#include "ngraph/graph_util.hpp" -#include "ngraph/log.hpp" -#include "ngraph/ngraph.hpp" -#include "ngraph/op/batch_norm.hpp" -#include "ngraph/op/parameter.hpp" -#include "ngraph/pass/manager.hpp" -#include "ngraph/pass/visualize_tree.hpp" -#include "ngraph/pattern/matcher.hpp" -#include "ngraph/util.hpp" +#include "openvino/core/graph_util.hpp" +#include "openvino/core/model.hpp" +#include "openvino/op/abs.hpp" +#include "openvino/op/add.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/op.hpp" +#include "openvino/pass/pattern/matcher.hpp" -using namespace ngraph; +using namespace ov; using namespace std; class ControlDependencyOp : public ov::op::Op { @@ -83,74 +81,74 @@ public: } TEST(control_dependencies, cdep_ops) { - auto A = make_shared(element::f32, Shape{}); - auto B = make_shared(element::f32, Shape{}); - auto absn = make_shared(A); + auto A = make_shared(element::f32, Shape{}); + auto B = make_shared(element::f32, Shape{}); + auto absn = make_shared(A); auto cdop = make_shared(OutputVector{A}, std::set>{absn}); - auto f = make_shared(cdop, ParameterVector{A, B}); + auto f = make_shared(cdop, ParameterVector{A, B}); test_ordered_ops(f, NodeVector{absn}); } TEST(control_dependencies, two_cdep_ops) { - auto A = make_shared(element::f32, Shape{}); - auto B = make_shared(element::f32, Shape{}); - auto absn = make_shared(A); - auto C = make_shared(element::f32, Shape{}); - auto absn_c = make_shared(C); + auto A = make_shared(element::f32, Shape{}); + auto B = make_shared(element::f32, Shape{}); + auto absn = make_shared(A); + auto C = make_shared(element::f32, Shape{}); + auto absn_c = make_shared(C); auto cdop = make_shared(OutputVector{A}, std::set>{absn, absn_c}); - auto f = make_shared(cdop, ParameterVector{A, B, C}); + auto f = make_shared(cdop, ParameterVector{A, B, C}); test_ordered_ops(f, NodeVector{absn, absn_c}); } TEST(control_dependencies, two_cdep_ops_op_on_top) { - auto A = make_shared(element::f32, Shape{}); - auto absn = make_shared(A); - auto B = make_shared(element::f32, Shape{}); - auto absn_b = make_shared(B); + auto A = make_shared(element::f32, Shape{}); + auto absn = make_shared(A); + auto B = make_shared(element::f32, Shape{}); + auto absn_b = make_shared(B); auto cdop = make_shared(OutputVector{A}, std::set>{absn, absn_b}); - auto absn_cdop = make_shared(cdop); + auto absn_cdop = make_shared(cdop); - auto f = make_shared(absn_cdop, ParameterVector{A, B}); + auto f = make_shared(absn_cdop, ParameterVector{A, B}); test_ordered_ops(f, NodeVector{absn, absn_b}); } TEST(control_dependencies, clone_function_cdop) { - auto A = make_shared(element::f32, Shape{}); - auto absn = make_shared(A); + auto A = make_shared(element::f32, Shape{}); + auto absn = make_shared(A); auto cdop = make_shared(OutputVector{A}, std::set>{absn}); - auto f = make_shared(cdop, ParameterVector{A}); + auto f = make_shared(cdop, ParameterVector{A}); test_ordered_ops(f, NodeVector{absn}); auto clone = f->clone(); - auto matcher = std::make_shared(cdop); + auto matcher = std::make_shared(cdop); auto cdop_clone = clone->get_results().at(0)->input_value(0).get_node_shared_ptr(); ASSERT_TRUE(matcher->match(cdop_clone)); auto cloned_deps = cdop_clone->get_control_dependencies(); ASSERT_EQ(cloned_deps.size(), 1); auto cloned_abs = *begin(cloned_deps); - ASSERT_TRUE(is_type(cloned_abs)); + ASSERT_TRUE(is_type(cloned_abs)); } TEST(control_dependencies, clone_function_cdop_abs) { - auto A = make_shared(element::f32, Shape{}); - auto absn = make_shared(A); - auto B = make_shared(element::f32, Shape{}); - auto absn_b = make_shared(B); + auto A = make_shared(element::f32, Shape{}); + auto absn = make_shared(A); + auto B = make_shared(element::f32, Shape{}); + auto absn_b = make_shared(B); auto cdop = make_shared(OutputVector{A}, std::set>{absn, absn_b}); - auto absn_cdop = make_shared(cdop); + auto absn_cdop = make_shared(cdop); - auto f = make_shared(absn_cdop, ParameterVector{A, B}); + auto f = make_shared(absn_cdop, ParameterVector{A, B}); auto clone = f->clone(); - auto matcher = std::make_shared(cdop); + auto matcher = std::make_shared(cdop); auto cdop_clone = clone->get_results().at(0)->input_value(0).get_node_shared_ptr()->input_value(0).get_node_shared_ptr(); ASSERT_TRUE(matcher->match(cdop_clone)); auto cloned_deps = cdop_clone->get_control_dependencies(); ASSERT_EQ(cloned_deps.size(), 2); for (auto ccdep : cloned_deps) { - ASSERT_TRUE(is_type(ccdep)); + ASSERT_TRUE(is_type(ccdep)); } } @@ -161,8 +159,8 @@ static size_t count_control_dependencies(const shared_ptr& node, const sha TEST(control_dependencies, replace_node) { Shape shape{2, 2}; - auto A = make_shared(element::f32, shape); - auto B = make_shared(element::f32, shape); + auto A = make_shared(element::f32, shape); + auto B = make_shared(element::f32, shape); auto MUL_AB = make_shared(A, B); auto MUL_BA = make_shared(B, A); auto ADD = make_shared(A, B); @@ -170,7 +168,7 @@ TEST(control_dependencies, replace_node) { ADD->add_control_dependency(MUL_AB); ASSERT_TRUE(1 == count_control_dependencies(ADD, MUL_AB)); ASSERT_TRUE(0 == count_control_dependencies(ADD, MUL_BA)); - replace_node(MUL_AB, MUL_BA); + ov::replace_node(MUL_AB, MUL_BA); ASSERT_TRUE(0 == count_control_dependencies(ADD, MUL_AB)); ASSERT_TRUE(1 == count_control_dependencies(ADD, MUL_BA)); } diff --git a/src/core/tests/convert_u1_to_string.cpp b/src/core/tests/convert_u1_to_string.cpp index 3fa4b0780ae..cfb4e826876 100644 --- a/src/core/tests/convert_u1_to_string.cpp +++ b/src/core/tests/convert_u1_to_string.cpp @@ -4,14 +4,14 @@ #include "common_test_utils/test_tools.hpp" #include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" +#include "openvino/op/constant.hpp" -using namespace ngraph; +using namespace ov; using namespace std; TEST(convert_u1_to_string, convert_u1_to_string) { vector values{171, 16}; - auto constant = make_shared(element::u1, Shape{12}, &values[0]); + auto constant = make_shared(element::u1, Shape{12}, &values[0]); vector ref{"1", "0", "1", "0", "1", "0", "1", "1", "0", "0", "0", "1"}; for (size_t i = 0; i < 12; ++i) { diff --git a/src/core/tests/coordinate.cpp b/src/core/tests/coordinate.cpp index 2d89b81b186..2fcb6bc8a79 100644 --- a/src/core/tests/coordinate.cpp +++ b/src/core/tests/coordinate.cpp @@ -2,30 +2,31 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "openvino/core/coordinate.hpp" + #include -#include #include #include #include "common_test_utils/ndarray.hpp" #include "common_test_utils/test_tools.hpp" #include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" +#include "ngraph/coordinate_transform.hpp" using namespace std; -using namespace ngraph; -NGRAPH_SUPPRESS_DEPRECATED_START +using namespace ov; +OPENVINO_SUPPRESS_DEPRECATED_START TEST(coordinate, shape0d) { - auto ct = CoordinateTransform({}); + auto ct = ngraph::CoordinateTransform({}); ASSERT_EQ(shape_size(ct.get_target_shape()), 1); auto it = ct.begin(); - EXPECT_EQ(*it++, Coordinate({})); + EXPECT_EQ(*it++, ov::Coordinate({})); EXPECT_TRUE(it == ct.end()); } TEST(coordinate, shape1d) { - auto ct = CoordinateTransform({3}); + auto ct = ngraph::CoordinateTransform({3}); ASSERT_EQ(shape_size(ct.get_target_shape()), 3); auto it = ct.begin(); EXPECT_EQ(*it++, Coordinate({0})); @@ -35,7 +36,7 @@ TEST(coordinate, shape1d) { } TEST(coordinate, shape2d) { - auto ct = CoordinateTransform({2, 3}); + auto ct = ngraph::CoordinateTransform({2, 3}); ASSERT_EQ(shape_size(ct.get_target_shape()), 6); auto it = ct.begin(); EXPECT_EQ(*it++, Coordinate({0, 0})); @@ -48,7 +49,7 @@ TEST(coordinate, shape2d) { } TEST(coordinate, shape3d) { - auto ct = CoordinateTransform({2, 3, 4}); + auto ct = ngraph::CoordinateTransform({2, 3, 4}); ASSERT_EQ(shape_size(ct.get_target_shape()), 24); auto it = ct.begin(); EXPECT_EQ(*it++, Coordinate({0, 0, 0})); @@ -79,22 +80,12 @@ TEST(coordinate, shape3d) { } TEST(coordinate, zero_sized_axis) { - auto ct = CoordinateTransform({2, 0, 4}); + auto ct = ngraph::CoordinateTransform({2, 0, 4}); ASSERT_EQ(shape_size(ct.get_target_shape()), 0); auto it = ct.begin(); EXPECT_TRUE(it == ct.end()); } -TEST(DISABLED_coordinate, random) { - auto ct = CoordinateTransform({2, 3, 4}); - ASSERT_EQ(shape_size(ct.get_target_shape()), 24); - auto it = ct.begin(); - it += 5; - EXPECT_EQ(*it, Coordinate({0, 1, 1})); - it += -2; - EXPECT_EQ(*it, Coordinate({0, 1, 1})); -} - TEST(coordinate, corner) { Shape source_shape{10, 10}; Coordinate source_start_corner = Coordinate{3, 3}; @@ -106,14 +97,14 @@ TEST(coordinate, corner) { CoordinateDiff target_padding_above = CoordinateDiff(source_shape.size(), 0); Strides source_dilation_strides = Strides(source_shape.size(), 1); - auto ct = CoordinateTransform(source_shape, - source_start_corner, - source_end_corner, - source_strides, - source_axis_order, - target_padding_below, - target_padding_above, - source_dilation_strides); + auto ct = ngraph::CoordinateTransform(source_shape, + source_start_corner, + source_end_corner, + source_strides, + source_axis_order, + target_padding_below, + target_padding_above, + source_dilation_strides); ASSERT_EQ(shape_size(ct.get_target_shape()), 9); auto it = ct.begin(); @@ -140,14 +131,14 @@ TEST(coordinate, strides) { CoordinateDiff target_padding_above = CoordinateDiff(source_shape.size(), 0); Strides source_dilation_strides = Strides(source_shape.size(), 1); - auto ct = CoordinateTransform(source_shape, - source_start_corner, - source_end_corner, - source_strides, - source_axis_order, - target_padding_below, - target_padding_above, - source_dilation_strides); + auto ct = ngraph::CoordinateTransform(source_shape, + source_start_corner, + source_end_corner, + source_strides, + source_axis_order, + target_padding_below, + target_padding_above, + source_dilation_strides); ASSERT_EQ(shape_size(ct.get_target_shape()), 20); auto it = ct.begin(); @@ -184,14 +175,14 @@ TEST(coordinate, axis_order) { CoordinateDiff target_padding_above = CoordinateDiff(source_shape.size(), 0); Strides source_dilation_strides = Strides(source_shape.size(), 1); - auto ct = CoordinateTransform(source_shape, - source_start_corner, - source_end_corner, - source_strides, - source_axis_order, - target_padding_below, - target_padding_above, - source_dilation_strides); + auto ct = ngraph::CoordinateTransform(source_shape, + source_start_corner, + source_end_corner, + source_strides, + source_axis_order, + target_padding_below, + target_padding_above, + source_dilation_strides); ASSERT_EQ(shape_size(ct.get_target_shape()), 24); auto it = ct.begin(); @@ -221,94 +212,3 @@ TEST(coordinate, axis_order) { EXPECT_EQ(ct.to_source_coordinate(*it++), Coordinate({2, 1, 3})); EXPECT_TRUE(it == ct.end()); } - -TEST(DISABLED_coordinate, padding) { - Shape source_shape{10, 10}; - Coordinate source_start_corner = Coordinate{0, 0}; - Coordinate source_end_corner{source_shape}; - Strides source_strides = Strides(source_shape.size(), 1); - AxisVector source_axis_order(source_shape.size()); - iota(source_axis_order.begin(), source_axis_order.end(), 0); - CoordinateDiff target_padding_below = CoordinateDiff(source_shape.size(), 0); - CoordinateDiff target_padding_above = CoordinateDiff(source_shape.size(), 0); - Strides source_dilation_strides = Strides(source_shape.size(), 1); - - auto ct = CoordinateTransform(source_shape, - source_start_corner, - source_end_corner, - source_strides, - source_axis_order, - target_padding_below, - target_padding_above, - source_dilation_strides); - - // for (const Coordinate& c : ct) - // { - // cout << c << ", " << ct.to_source_coordinate(c) << endl; - // } - - ASSERT_EQ(shape_size(ct.get_target_shape()), 24); - auto it = ct.begin(); - - EXPECT_TRUE(it == ct.end()); -} - -TEST(DISABLED_coordinate, dilation) { - Shape source_shape{10, 10}; - Coordinate source_start_corner = Coordinate{0, 0}; - Coordinate source_end_corner{source_shape}; - Strides source_strides = Strides(source_shape.size(), 1); - AxisVector source_axis_order(source_shape.size()); - iota(source_axis_order.begin(), source_axis_order.end(), 0); - CoordinateDiff target_padding_below = CoordinateDiff(source_shape.size(), 0); - CoordinateDiff target_padding_above = CoordinateDiff(source_shape.size(), 0); - Strides source_dilation_strides = Strides(source_shape.size(), 1); - - auto ct = CoordinateTransform(source_shape, - source_start_corner, - source_end_corner, - source_strides, - source_axis_order, - target_padding_below, - target_padding_above, - source_dilation_strides); - - // for (const Coordinate& c : ct) - // { - // cout << ct.to_source_coordinate(c) << endl; - // } - - ASSERT_EQ(shape_size(ct.get_target_shape()), 24); - auto it = ct.begin(); - - EXPECT_TRUE(it == ct.end()); -} - -TEST(benchmark, coordinate) { - Shape source_shape{128, 3, 2000, 1000}; - Coordinate source_start_corner = Coordinate{0, 0, 0, 0}; - Coordinate source_end_corner{source_shape}; - Strides source_strides = Strides(source_shape.size(), 1); - AxisVector source_axis_order(source_shape.size()); - iota(source_axis_order.begin(), source_axis_order.end(), 0); - CoordinateDiff target_padding_below = CoordinateDiff(source_shape.size(), 0); - CoordinateDiff target_padding_above = CoordinateDiff(source_shape.size(), 0); - Strides source_dilation_strides = Strides(source_shape.size(), 1); - - stopwatch timer; - timer.start(); - auto ct = CoordinateTransform(source_shape, - source_start_corner, - source_end_corner, - source_strides, - source_axis_order, - target_padding_below, - target_padding_above, - source_dilation_strides); - - for (const Coordinate& c : ct) { - (void)c; - } - timer.stop(); - cout << "time: " << timer.get_milliseconds() << endl; -} diff --git a/src/core/tests/coordinate_range.cpp b/src/core/tests/coordinate_range.cpp index 9e7ca57c8c8..f8218f98f1e 100644 --- a/src/core/tests/coordinate_range.cpp +++ b/src/core/tests/coordinate_range.cpp @@ -2,17 +2,18 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "ngraph/coordinate_range.hpp" + #include -#include #include #include #include "gtest/gtest.h" +#include "openvino/core/coordinate.hpp" -using namespace ngraph; -using namespace ngraph::coordinates; +using namespace ov; using Index = size_t; -using ExpectedOutput = std::vector>; +using ExpectedOutput = std::vector>; /// /// @@ -24,7 +25,7 @@ TEST(coordinate_range, slice_range_shape0d) { const Shape s; const Coordinate start_corner(s.size()); - auto slice_range = slice(s, start_corner, s); + auto slice_range = ngraph::coordinates::slice(s, start_corner, s); auto it = slice_range.begin(); EXPECT_EQ(it, begin(slice_range)); EXPECT_FALSE(it == slice_range.end()); @@ -41,7 +42,7 @@ TEST(coordinate_range, slice_range_shape1d) { ASSERT_EQ(expected.size(), shape_size(s)) << "check epxected data"; auto expected_val = begin(expected); - for (auto slice_range : slice(s, start_corner, s)) { + for (auto slice_range : ngraph::coordinates::slice(s, start_corner, s)) { auto index = slice_range.begin_index; for (size_t i = 0; i < slice_range.element_number; index += slice_range.step, ++i) { EXPECT_EQ(index, expected_val->first); @@ -64,7 +65,7 @@ TEST(coordinate_range, slice_range_shape2d) { ASSERT_EQ(expected.size(), shape_size(s)) << "check epxected data"; auto expected_val = begin(expected); - for (auto slice_range : slice(s, start_corner, s)) { + for (auto slice_range : ngraph::coordinates::slice(s, start_corner, s)) { auto index = slice_range.begin_index; for (size_t i = 0; i < slice_range.element_number; index += slice_range.step, ++i) { EXPECT_EQ(index, expected_val->first); @@ -91,7 +92,7 @@ TEST(coordinate_range, slice_range_shape3d) { ASSERT_EQ(expected.size(), shape_size(s)) << "check epxected data"; auto expected_val = begin(expected); - for (auto slice_range : slice(s, start_corner, s)) { + for (auto slice_range : ngraph::coordinates::slice(s, start_corner, s)) { auto index = slice_range.begin_index; for (size_t i = 0; i < slice_range.element_number; index += slice_range.step, ++i) { EXPECT_EQ(index, expected_val->first); @@ -105,7 +106,7 @@ TEST(coordinate_range, slice_range_zero_sized_axis) { const Shape s{2, 0, 4}; const Coordinate start_corner(s.size()); - auto slice_range = slice(s, start_corner, s); + auto slice_range = ngraph::coordinates::slice(s, start_corner, s); auto it = slice_range.begin(); EXPECT_TRUE(it == slice_range.end()) << "Expect empyt range"; } @@ -115,10 +116,10 @@ TEST(coordinate_range, slice_range_zero_sized_axis) { /// TEST(coordinate_range, slice_range_input_validataion) { const Shape s{10, 10, 10}; - EXPECT_THROW(slice(s, {1}, {1}), std::domain_error); - EXPECT_THROW(slice(s, s, {1}), std::domain_error); - EXPECT_THROW(slice(s, {1}, s), std::domain_error); - EXPECT_THROW(slice(s, s, s, {}), std::domain_error); + EXPECT_THROW(ngraph::coordinates::slice(s, {1}, {1}), std::domain_error); + EXPECT_THROW(ngraph::coordinates::slice(s, s, {1}), std::domain_error); + EXPECT_THROW(ngraph::coordinates::slice(s, {1}, s), std::domain_error); + EXPECT_THROW(ngraph::coordinates::slice(s, s, s, {}), std::domain_error); } namespace { @@ -164,7 +165,7 @@ TEST(coordinate_range, slice_range_corner) { << "check epxected data"; auto expected_val = begin(expected); - for (auto slice_range : slice(s, source_start_corner, source_end_corner)) { + for (auto slice_range : ngraph::coordinates::slice(s, source_start_corner, source_end_corner)) { auto index = slice_range.begin_index; for (size_t i = 0; i < slice_range.element_number; index += slice_range.step, ++i) { EXPECT_EQ(index, expected_val->first); @@ -194,7 +195,7 @@ TEST(coordinate_range, slice_range_strides) { << "check epxected data"; auto expected_val = begin(expected); - for (auto slice_range : slice(s, source_start_corner, source_end_corner, source_strides)) { + for (auto slice_range : ngraph::coordinates::slice(s, source_start_corner, source_end_corner, source_strides)) { auto index = slice_range.begin_index; for (size_t i = 0; i < slice_range.element_number; index += slice_range.step, ++i) { EXPECT_EQ(index, expected_val->first); @@ -215,7 +216,7 @@ TEST(coordinate_range, reverse_range_shape0d) { const Shape s; const AxisSet reverset_axis{}; - auto reverse_range = reverse(s, reverset_axis); + auto reverse_range = ngraph::coordinates::reverse(s, reverset_axis); auto it = reverse_range.begin(); EXPECT_EQ(it, begin(reverse_range)); auto v = *it; // if it is not end it has to be dereferencable; @@ -231,9 +232,9 @@ TEST(coordinate_range, reverse_range_shape1d) { EXPECT_EQ(expected.size(), shape_size(s)) << "check epxected data"; auto expected_val = begin(expected); - for (auto reverse_range : reverse(s, reverset_axis)) { + for (auto reverse_range : ngraph::coordinates::reverse(s, reverset_axis)) { auto index = reverse_range.begin_index; - ASSERT_EQ(reverse_range.direction, Direction::forward); + ASSERT_EQ(reverse_range.direction, ngraph::coordinates::Direction::forward); for (size_t i = 0; i < reverse_range.element_number; index += reverse_range.step, ++i) { EXPECT_EQ(index, expected_val->first); ++expected_val; @@ -256,9 +257,9 @@ TEST(coordinate_range, reverse_range_shape2d) { EXPECT_EQ(expected.size(), shape_size(s)) << "check epxected data"; auto expected_val = begin(expected); - for (auto reverse_range : reverse(s, reverset_axis)) { + for (auto reverse_range : ngraph::coordinates::reverse(s, reverset_axis)) { auto index = reverse_range.begin_index; - ASSERT_EQ(reverse_range.direction, Direction::forward); + ASSERT_EQ(reverse_range.direction, ngraph::coordinates::Direction::forward); for (size_t i = 0; i < reverse_range.element_number; index += reverse_range.step, ++i) { EXPECT_EQ(index, expected_val->first); ++expected_val; @@ -285,9 +286,9 @@ TEST(coordinate_range, reverse_range_shape3d) { EXPECT_EQ(expected.size(), shape_size(s)) << "check epxected data"; auto expected_val = begin(expected); - for (auto reverse_range : reverse(s, reverset_axis)) { + for (auto reverse_range : ngraph::coordinates::reverse(s, reverset_axis)) { auto index = reverse_range.begin_index; - ASSERT_EQ(reverse_range.direction, Direction::forward); + ASSERT_EQ(reverse_range.direction, ngraph::coordinates::Direction::forward); for (size_t i = 0; i < reverse_range.element_number; index += reverse_range.step, ++i) { EXPECT_EQ(index, expected_val->first); ++expected_val; @@ -301,7 +302,7 @@ TEST(coordinate_range, reverse_range_shape3d) { TEST(coordinate_range, reverse_range_zero_sized_axis) { const Shape s{2, 0, 4}; - auto reverse_range = reverse(s, {}); + auto reverse_range = ngraph::coordinates::reverse(s, {}); auto it = reverse_range.begin(); EXPECT_TRUE(it == reverse_range.end()) << "Expect empyt range"; } @@ -311,7 +312,7 @@ TEST(coordinate_range, reverse_range_zero_sized_axis) { /// TEST(coordinate_range, reverse_range_input_validataion) { const Shape s{10, 10, 10}; - EXPECT_THROW(reverse(s, {10}), std::domain_error); + EXPECT_THROW(ngraph::coordinates::reverse(s, {10}), std::domain_error); } TEST(coordinate_range, reverse_range_2d) { @@ -325,9 +326,9 @@ TEST(coordinate_range, reverse_range_2d) { {29, {2, 9}}, {28, {2, 8}}, {27, {2, 7}}, {26, {2, 6}}, {25, {2, 5}}, {24, {2, 4}}, {23, {2, 3}}, {22, {2, 2}}, {21, {2, 1}}, {20, {2, 0}}}; // clang-format on auto expected_val = begin(expected); - for (auto reverse_range : reverse(s, reverset_axis)) { + for (auto reverse_range : ngraph::coordinates::reverse(s, reverset_axis)) { auto index = reverse_range.begin_index; - ASSERT_EQ(reverse_range.direction, Direction::reverse); + ASSERT_EQ(reverse_range.direction, ngraph::coordinates::Direction::reverse); for (size_t i = 0; i < reverse_range.element_number; index -= reverse_range.step, ++i) { EXPECT_EQ(index, expected_val->first); ++expected_val; @@ -358,9 +359,9 @@ TEST(coordinate_range, reverse_1_range_3d) { // clang-format on auto expected_val = begin(expected); - for (auto reverse_range : reverse(s, reverset_axis)) { + for (auto reverse_range : ngraph::coordinates::reverse(s, reverset_axis)) { auto index = reverse_range.begin_index; - ASSERT_EQ(reverse_range.direction, Direction::forward); + ASSERT_EQ(reverse_range.direction, ngraph::coordinates::Direction::forward); for (size_t i = 0; i < reverse_range.element_number; index += reverse_range.step, ++i) { EXPECT_EQ(index, expected_val->first); ++expected_val; @@ -391,9 +392,9 @@ TEST(coordinate_range, reverse_2_range_3d) { // clang-format on auto expected_val = begin(expected); - for (auto reverse_range : reverse(s, reverset_axis)) { + for (auto reverse_range : ngraph::coordinates::reverse(s, reverset_axis)) { auto index = reverse_range.begin_index; - ASSERT_EQ(reverse_range.direction, Direction::reverse); + ASSERT_EQ(reverse_range.direction, ngraph::coordinates::Direction::reverse); for (size_t i = 0; i < reverse_range.element_number; index -= reverse_range.step, ++i) { EXPECT_EQ(index, expected_val->first); ++expected_val; diff --git a/src/core/tests/copy.cpp b/src/core/tests/copy.cpp index 394be64de6b..d7b2b4256f4 100644 --- a/src/core/tests/copy.cpp +++ b/src/core/tests/copy.cpp @@ -2,24 +2,61 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include #include -#include "common_test_utils/ndarray.hpp" -#include "common_test_utils/test_tools.hpp" -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" -#include "ngraph/opsets/opset5.hpp" -#include "openvino/opsets/opset8.hpp" +#include "openvino/core/shape.hpp" +#include "openvino/op/abs.hpp" +#include "openvino/op/acos.hpp" +#include "openvino/op/add.hpp" +#include "openvino/op/asin.hpp" +#include "openvino/op/atan.hpp" +#include "openvino/op/broadcast.hpp" +#include "openvino/op/ceiling.hpp" +#include "openvino/op/concat.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/convert.hpp" +#include "openvino/op/cos.hpp" +#include "openvino/op/cosh.hpp" +#include "openvino/op/divide.hpp" +#include "openvino/op/equal.hpp" +#include "openvino/op/exp.hpp" +#include "openvino/op/floor.hpp" +#include "openvino/op/greater.hpp" +#include "openvino/op/greater_eq.hpp" +#include "openvino/op/less.hpp" +#include "openvino/op/less_eq.hpp" +#include "openvino/op/log.hpp" +#include "openvino/op/loop.hpp" +#include "openvino/op/maximum.hpp" +#include "openvino/op/minimum.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/negative.hpp" +#include "openvino/op/not_equal.hpp" +#include "openvino/op/parameter.hpp" +#include "openvino/op/power.hpp" +#include "openvino/op/random_uniform.hpp" +#include "openvino/op/reduce_sum.hpp" +#include "openvino/op/reshape.hpp" +#include "openvino/op/select.hpp" +#include "openvino/op/sign.hpp" +#include "openvino/op/sin.hpp" +#include "openvino/op/sinh.hpp" +#include "openvino/op/strided_slice.hpp" +#include "openvino/op/subtract.hpp" +#include "openvino/op/tan.hpp" +#include "openvino/op/tanh.hpp" using namespace std; -using namespace ngraph; +using namespace ov; template bool check_unary() { - Shape shape{1}; - auto arg0 = make_shared(element::f32, shape); - OutputVector new_args{make_shared(element::f32, shape)}; + ov::Shape shape{1}; + auto arg0 = make_shared(element::f32, shape); + OutputVector new_args{make_shared(element::f32, shape)}; auto node = make_shared(arg0); auto new_node = node->copy_with_new_inputs(new_args); @@ -30,10 +67,10 @@ bool check_unary() { template bool check_binary() { Shape shape{1}; - auto arg0 = make_shared(element::f32, shape); - auto arg1 = make_shared(element::f32, shape); - OutputVector new_args{make_shared(element::f32, shape), - make_shared(element::f32, shape)}; + auto arg0 = make_shared(element::f32, shape); + auto arg1 = make_shared(element::f32, shape); + OutputVector new_args{make_shared(element::f32, shape), + make_shared(element::f32, shape)}; auto node = make_shared(arg0, arg1); auto new_node = node->copy_with_new_inputs(new_args); @@ -42,38 +79,38 @@ bool check_binary() { } TEST(copy, abs) { - ASSERT_TRUE(check_unary()); + ASSERT_TRUE(check_unary()); } TEST(copy, acos) { - ASSERT_TRUE(check_unary()); + ASSERT_TRUE(check_unary()); } TEST(copy, add) { - ASSERT_TRUE(check_binary()); + ASSERT_TRUE(check_binary()); } TEST(copy, asin) { - ASSERT_TRUE(check_unary()); + ASSERT_TRUE(check_unary()); } TEST(copy, atan) { - ASSERT_TRUE(check_unary()); + ASSERT_TRUE(check_unary()); } TEST(copy, broadcast) { Shape shape{1, 3}; Shape new_shape{4, 1, 3}; AxisSet axes{1, 2}; - auto arg0 = make_shared(element::f32, shape); - OutputVector new_args{make_shared(element::f32, shape), - op::Constant::create(element::u64, Shape{new_shape.size()}, new_shape), - op::Constant::create(element::i64, Shape{axes.size()}, axes.to_vector())}; + auto arg0 = make_shared(element::f32, shape); + OutputVector new_args{make_shared(element::f32, shape), + ov::op::v0::Constant::create(element::u64, Shape{new_shape.size()}, new_shape), + ov::op::v0::Constant::create(element::i64, Shape{axes.size()}, axes.to_vector())}; - auto node = - make_shared(arg0, - op::Constant::create(element::u64, Shape{new_shape.size()}, new_shape), - op::Constant::create(element::i64, Shape{axes.size()}, axes.to_vector())); + auto node = make_shared( + arg0, + ov::op::v0::Constant::create(element::u64, Shape{new_shape.size()}, new_shape), + ov::op::v0::Constant::create(element::i64, Shape{axes.size()}, axes.to_vector())); auto new_node = node->copy_with_new_inputs(new_args); auto node_cast = ov::as_type_ptr(new_node); ASSERT_NE(node_cast, nullptr); @@ -88,19 +125,19 @@ TEST(copy, broadcast) { } TEST(copy, ceiling) { - ASSERT_TRUE(check_unary()); + ASSERT_TRUE(check_unary()); } TEST(copy, concat) { Shape shape{1}; - auto arg0 = make_shared(element::f32, shape); - auto arg1 = make_shared(element::f32, shape); - OutputVector new_args{make_shared(element::f32, shape), - make_shared(element::f32, shape)}; + auto arg0 = make_shared(element::f32, shape); + auto arg1 = make_shared(element::f32, shape); + OutputVector new_args{make_shared(element::f32, shape), + make_shared(element::f32, shape)}; int64_t axis = 0; - auto node = make_shared(NodeVector{arg0, arg1}, axis); + auto node = make_shared(NodeVector{arg0, arg1}, axis); auto new_node = node->clone_with_new_inputs(new_args); - auto node_cast = ov::as_type_ptr(new_node); + auto node_cast = ov::as_type_ptr(new_node); ASSERT_NE(node_cast, nullptr); ASSERT_TRUE(nullptr != new_node); @@ -112,9 +149,9 @@ TEST(copy, constant) { Shape shape{}; vector c{2.4f}; auto& et = element::f32; - auto node = op::Constant::create(et, shape, c); + auto node = ov::op::v0::Constant::create(et, shape, c); auto new_node = node->clone_with_new_inputs(OutputVector{}); - auto node_cast = ov::as_type_ptr(new_node); + auto node_cast = ov::as_type_ptr(new_node); ASSERT_NE(node_cast, nullptr); ASSERT_TRUE(nullptr != new_node); ASSERT_TRUE(OutputVector{} == new_node->input_values()); @@ -126,12 +163,12 @@ TEST(copy, constant) { TEST(copy, convert) { Shape shape; auto& et = element::f64; - auto arg0 = make_shared(element::f32, shape); - OutputVector new_args{make_shared(element::f32, shape)}; + auto arg0 = make_shared(element::f32, shape); + OutputVector new_args{make_shared(element::f32, shape)}; - auto node = make_shared(arg0, et); + auto node = make_shared(arg0, et); auto new_node = node->clone_with_new_inputs(new_args); - auto node_cast = ov::as_type_ptr(new_node); + auto node_cast = ov::as_type_ptr(new_node); ASSERT_NE(node_cast, nullptr); ASSERT_TRUE(nullptr != new_node); @@ -140,11 +177,11 @@ TEST(copy, convert) { } TEST(copy, cos) { - ASSERT_TRUE(check_unary()); + ASSERT_TRUE(check_unary()); } TEST(copy, cosh) { - ASSERT_TRUE(check_unary()); + ASSERT_TRUE(check_unary()); } TEST(copy, divide) { @@ -156,11 +193,11 @@ TEST(copy, equal) { } TEST(copy, exp) { - ASSERT_TRUE(check_unary()); + ASSERT_TRUE(check_unary()); } TEST(copy, floor) { - ASSERT_TRUE(check_unary()); + ASSERT_TRUE(check_unary()); } TEST(copy, greater_eq) { @@ -180,7 +217,7 @@ TEST(copy, less) { } TEST(copy, log) { - ASSERT_TRUE(check_unary()); + ASSERT_TRUE(check_unary()); } TEST(copy, maximum) { @@ -196,7 +233,7 @@ TEST(copy, multiply) { } TEST(copy, negative) { - ASSERT_TRUE(check_unary()); + ASSERT_TRUE(check_unary()); } TEST(copy, not_equal) { @@ -205,9 +242,9 @@ TEST(copy, not_equal) { TEST(copy, parameter) { Shape shape{1}; - auto node = make_shared(element::f32, shape); + auto node = make_shared(element::f32, shape); auto new_node = node->clone_with_new_inputs({}); - auto node_cast = ov::as_type_ptr(new_node); + auto node_cast = ov::as_type_ptr(new_node); ASSERT_NE(node_cast, nullptr); ASSERT_TRUE(nullptr != new_node); @@ -222,12 +259,12 @@ TEST(copy, power) { TEST(copy, reduce_sum) { Shape shape{4, 3}; AxisSet axes{1}; - auto arg0 = make_shared(element::f32, shape); + auto arg0 = make_shared(element::f32, shape); - auto axes_node = op::Constant::create(element::i64, {axes.size()}, axes.to_vector()); + auto axes_node = ov::op::v0::Constant::create(element::i64, {axes.size()}, axes.to_vector()); auto node = make_shared(arg0, axes_node, true); - OutputVector new_args{make_shared(element::f32, shape), - op::Constant::create(element::i64, {axes.size()}, axes.to_vector())}; + OutputVector new_args{make_shared(element::f32, shape), + ov::op::v0::Constant::create(element::i64, {axes.size()}, axes.to_vector())}; auto new_node = node->clone_with_new_inputs(new_args); auto node_cast = ov::as_type_ptr(new_node); ASSERT_NE(node_cast, nullptr); @@ -242,11 +279,11 @@ TEST(copy, reshape) { Shape shape_in{2, 3, 4}; Shape shape_out{6, 4}; - auto arg0 = make_shared(element::f32, shape_in); - OutputVector new_args{make_shared(element::f32, shape_in), - op::Constant::create(element::u64, {shape_out.size()}, shape_out)}; + auto arg0 = make_shared(element::f32, shape_in); + OutputVector new_args{make_shared(element::f32, shape_in), + ov::op::v0::Constant::create(element::u64, {shape_out.size()}, shape_out)}; - auto shape_pattern = op::Constant::create(element::u64, {shape_out.size()}, shape_out); + auto shape_pattern = ov::op::v0::Constant::create(element::u64, {shape_out.size()}, shape_out); auto node = make_shared(arg0, shape_pattern, false); auto new_node = node->clone_with_new_inputs(new_args); auto node_cast = ov::as_type_ptr(new_node); @@ -259,12 +296,12 @@ TEST(copy, reshape) { TEST(copy, select) { Shape shape{1}; - auto arg0 = make_shared(element::boolean, shape); - auto arg1 = make_shared(element::f32, shape); - auto arg2 = make_shared(element::f32, shape); - OutputVector new_args{make_shared(element::boolean, shape), - make_shared(element::f32, shape), - make_shared(element::f32, shape)}; + auto arg0 = make_shared(element::boolean, shape); + auto arg1 = make_shared(element::f32, shape); + auto arg2 = make_shared(element::f32, shape); + OutputVector new_args{make_shared(element::boolean, shape), + make_shared(element::f32, shape), + make_shared(element::f32, shape)}; auto node = make_shared(arg0, arg1, arg2); auto new_node = node->clone_with_new_inputs(new_args); @@ -276,15 +313,15 @@ TEST(copy, select) { } TEST(copy, sign) { - ASSERT_TRUE(check_unary()); + ASSERT_TRUE(check_unary()); } TEST(copy, sin) { - ASSERT_TRUE(check_unary()); + ASSERT_TRUE(check_unary()); } TEST(copy, sinh) { - ASSERT_TRUE(check_unary()); + ASSERT_TRUE(check_unary()); } TEST(copy, strided_slice) { @@ -293,15 +330,15 @@ TEST(copy, strided_slice) { Coordinate upper{2, 3, 4}; Strides strides{1, 1, 1}; - auto arg0 = make_shared(element::f32, shape_in); - OutputVector new_args{make_shared(element::f32, shape_in), - op::Constant::create(element::u64, {lower.size()}, lower), - op::Constant::create(element::u64, {upper.size()}, upper), - op::Constant::create(element::i64, {strides.size()}, strides)}; + auto arg0 = make_shared(element::f32, shape_in); + OutputVector new_args{make_shared(element::f32, shape_in), + ov::op::v0::Constant::create(element::u64, {lower.size()}, lower), + ov::op::v0::Constant::create(element::u64, {upper.size()}, upper), + ov::op::v0::Constant::create(element::i64, {strides.size()}, strides)}; - auto begin_node = op::Constant::create(element::i64, {lower.size()}, lower); - auto end_node = op::Constant::create(element::i64, {upper.size()}, upper); - auto strides_node = op::Constant::create(element::i64, {strides.size()}, strides); + auto begin_node = ov::op::v0::Constant::create(element::i64, {lower.size()}, lower); + auto end_node = ov::op::v0::Constant::create(element::i64, {upper.size()}, upper); + auto strides_node = ov::op::v0::Constant::create(element::i64, {strides.size()}, strides); auto node = make_shared(arg0, begin_node, end_node, @@ -334,38 +371,38 @@ TEST(copy, subtract) { } TEST(copy, tan) { - ASSERT_TRUE(check_unary()); + ASSERT_TRUE(check_unary()); } TEST(copy, tanh) { - ASSERT_TRUE(check_unary()); + ASSERT_TRUE(check_unary()); } TEST(copy, loop) { // That which we iterate over - auto X = make_shared(element::f32, Shape{32, 1, 10}); - auto Y = make_shared(element::f32, Shape{32, 1, 10}); - auto M = make_shared(element::f32, Shape{32, 1, 10}); + auto X = make_shared(element::f32, Shape{32, 1, 10}); + auto Y = make_shared(element::f32, Shape{32, 1, 10}); + auto M = make_shared(element::f32, Shape{32, 1, 10}); // Set up the cell body, a function from (Xi, Yi) -> (Zo) // Body parameters - auto current_iteration = make_shared(element::i64, Shape{}); - auto Xi = make_shared(element::f32, PartialShape::dynamic()); - auto Yi = make_shared(element::f32, PartialShape::dynamic()); - auto M_body = make_shared(element::f32, PartialShape::dynamic()); - auto body_condition = std::make_shared(ngraph::element::boolean, ngraph::Shape{}, true); + auto current_iteration = make_shared(element::i64, Shape{}); + auto Xi = make_shared(element::f32, PartialShape::dynamic()); + auto Yi = make_shared(element::f32, PartialShape::dynamic()); + auto M_body = make_shared(element::f32, PartialShape::dynamic()); + auto body_condition = std::make_shared(ov::element::boolean, ov::Shape{}, true); - auto trip_count = std::make_shared(ngraph::element::i64, ngraph::Shape{}, 10); - auto exec_condition = std::make_shared(ngraph::element::boolean, ngraph::Shape{}, true); + auto trip_count = std::make_shared(ov::element::i64, ov::Shape{}, 10); + auto exec_condition = std::make_shared(ov::element::boolean, ov::Shape{}, true); // Body - auto sum = make_shared(Xi, Yi); - auto Zo = make_shared(sum, M_body); - auto body = make_shared(OutputVector{Zo, body_condition}, - ParameterVector{Xi, current_iteration, Yi, M_body}); + auto sum = make_shared(Xi, Yi); + auto Zo = make_shared(sum, M_body); + auto body = + make_shared(OutputVector{Zo, body_condition}, ParameterVector{Xi, current_iteration, Yi, M_body}); - auto loop = make_shared(trip_count, exec_condition); + auto loop = make_shared(trip_count, exec_condition); loop->set_function(body); - loop->set_special_body_ports(ngraph::opset5::Loop::SpecialBodyPorts{1, 1}); + loop->set_special_body_ports(ov::op::v5::Loop::SpecialBodyPorts{1, 1}); loop->set_invariant_input(Xi, X); loop->set_invariant_input(Yi, Y); @@ -379,13 +416,13 @@ TEST(copy, loop) { auto out2 = loop->get_concatenated_slices(Zo, 0, 1, 1, -1, 1); loop->validate_and_infer_types(); // That which we iterate over - auto X_new = make_shared(element::f32, Shape{3, 2, 5}); - auto Y_new = make_shared(element::f32, Shape{3, 2, 5}); - auto M_new = make_shared(element::f32, Shape{3, 2, 5}); + auto X_new = make_shared(element::f32, Shape{3, 2, 5}); + auto Y_new = make_shared(element::f32, Shape{3, 2, 5}); + auto M_new = make_shared(element::f32, Shape{3, 2, 5}); OutputVector new_args = {trip_count, exec_condition, X_new, Y_new, M_new}; auto loop_copy = loop->clone_with_new_inputs(new_args); - auto node_cast = std::dynamic_pointer_cast(loop_copy); + auto node_cast = std::dynamic_pointer_cast(loop_copy); ASSERT_NE(node_cast, nullptr); ASSERT_TRUE(nullptr != loop_copy); EXPECT_EQ(loop->get_num_iterations(), node_cast->get_num_iterations()); @@ -408,11 +445,11 @@ TEST(copy, random_uniform) { auto shape = std::vector{1, 2, 3}; float min = 0., max = 1.; - const auto min_val_param = make_shared(element::f32, Shape{1}); - const auto max_val_param = make_shared(element::f32, Shape{1}); - auto out_shape = make_shared(element::i64, Shape{3}, std::vector{1, 2, 3}); + const auto min_val_param = make_shared(element::f32, Shape{1}); + const auto max_val_param = make_shared(element::f32, Shape{1}); + auto out_shape = make_shared(element::i64, Shape{3}, std::vector{1, 2, 3}); auto ru = - std::make_shared(out_shape, min_val_param, max_val_param, element::f32, 150, 10); + std::make_shared(out_shape, min_val_param, max_val_param, element::f32, 150, 10); // Call `evaluate` to update m_state auto outputs = ov::TensorVector{{element::i64, out_shape->get_shape(), shape.data()}}; @@ -421,12 +458,12 @@ TEST(copy, random_uniform) { {element::f32, min_val_param->get_shape(), &min}, {element::f32, max_val_param->get_shape(), &max}}); - auto out_shape_c = make_shared(element::i64, Shape{4}, std::vector{4, 3, 2, 1}); - const auto min_val_param_c = make_shared(element::f32, Shape{1}); - const auto max_val_param_c = make_shared(element::f32, Shape{1}); + auto out_shape_c = make_shared(element::i64, Shape{4}, std::vector{4, 3, 2, 1}); + const auto min_val_param_c = make_shared(element::f32, Shape{1}); + const auto max_val_param_c = make_shared(element::f32, Shape{1}); OutputVector new_args{out_shape_c, min_val_param_c, max_val_param_c}; auto new_ru = ru->clone_with_new_inputs(new_args); - auto node_cast = ov::as_type_ptr(new_ru); + auto node_cast = ov::as_type_ptr(new_ru); ASSERT_NE(node_cast, nullptr); ASSERT_TRUE(nullptr != new_ru); diff --git a/src/core/tests/copy_runtime_info.cpp b/src/core/tests/copy_runtime_info.cpp index e2d61f86c8c..4755e40651f 100644 --- a/src/core/tests/copy_runtime_info.cpp +++ b/src/core/tests/copy_runtime_info.cpp @@ -7,18 +7,16 @@ #include #include #include -#include -#include #include "gtest/gtest.h" -#include "ngraph/graph_util.hpp" -#include "ngraph/log.hpp" -#include "ngraph/ngraph.hpp" -#include "ngraph/opsets/opset3.hpp" -#include "ngraph/pass/graph_rewrite.hpp" -#include "ngraph/pass/manager.hpp" +#include "openvino/core/graph_util.hpp" +#include "openvino/core/node.hpp" +#include "openvino/core/rt_info.hpp" +#include "openvino/core/runtime_attribute.hpp" +#include "openvino/op/parameter.hpp" +#include "openvino/op/relu.hpp" -using namespace ngraph; +using namespace ov; using namespace std; class TestAttributeNoCopyable : public ov::RuntimeAttribute { @@ -71,19 +69,19 @@ public: return rt_info.count(TestAttributeMergable::get_type_info_static()); } - ov::Any merge(const ngraph::NodeVector& nodes) const override { + ov::Any merge(const ov::NodeVector& nodes) const override { return {TestAttributeMergable()}; } }; TEST(copy_runtime_info, node_to_node_1) { - auto a = make_shared(element::f32, Shape{1}); - auto b = make_shared(element::f32, Shape{1}); + auto a = make_shared(element::f32, Shape{1}); + auto b = make_shared(element::f32, Shape{1}); TestAttributeCopyable::set(a); TestAttributeNoCopyable::set(b); - copy_runtime_info(a, b); + ov::copy_runtime_info(a, b); ASSERT_TRUE(TestAttributeCopyable::exists_in(a)); ASSERT_TRUE(TestAttributeCopyable::exists_in(b)); @@ -96,8 +94,8 @@ TEST(copy_runtime_info, node_to_node_1) { } TEST(copy_runtime_info, node_to_node_2) { - auto a = make_shared(element::f32, Shape{1}); - auto b = make_shared(element::f32, Shape{1}); + auto a = make_shared(element::f32, Shape{1}); + auto b = make_shared(element::f32, Shape{1}); TestAttributeCopyable::set(a); TestAttributeNoCopyable::set(a); @@ -112,9 +110,9 @@ TEST(copy_runtime_info, node_to_node_2) { } TEST(copy_runtime_info, node_to_nodes) { - auto a = make_shared(element::f32, Shape{1}); - auto b = make_shared(element::f32, Shape{1}); - auto c = make_shared(element::f32, Shape{1}); + auto a = make_shared(element::f32, Shape{1}); + auto b = make_shared(element::f32, Shape{1}); + auto c = make_shared(element::f32, Shape{1}); TestAttributeCopyable::set(a); TestAttributeNoCopyable::set(b); @@ -132,9 +130,9 @@ TEST(copy_runtime_info, node_to_nodes) { } TEST(copy_runtime_info, nodes_to_node_1) { - auto a = make_shared(element::f32, Shape{1}); - auto b = make_shared(element::f32, Shape{1}); - auto c = make_shared(element::f32, Shape{1}); + auto a = make_shared(element::f32, Shape{1}); + auto b = make_shared(element::f32, Shape{1}); + auto c = make_shared(element::f32, Shape{1}); TestAttributeCopyable::set(a); TestAttributeNoCopyable::set(a); @@ -149,9 +147,9 @@ TEST(copy_runtime_info, nodes_to_node_1) { } TEST(copy_runtime_info, nodes_to_node_2) { - auto a = make_shared(element::f32, Shape{1}); - auto b = make_shared(element::f32, Shape{1}); - auto c = make_shared(element::f32, Shape{1}); + auto a = make_shared(element::f32, Shape{1}); + auto b = make_shared(element::f32, Shape{1}); + auto c = make_shared(element::f32, Shape{1}); TestAttributeMergable::set(a); TestAttributeMergable::set(b); @@ -164,8 +162,8 @@ TEST(copy_runtime_info, nodes_to_node_2) { } TEST(copy_runtime_info, nodes_to_node_3) { - auto a = make_shared(element::f32, Shape{1}); - auto b = make_shared(element::f32, Shape{1}); + auto a = make_shared(element::f32, Shape{1}); + auto b = make_shared(element::f32, Shape{1}); TestAttributeCopyable::set(a); TestAttributeNoCopyable::set(b); @@ -177,10 +175,10 @@ TEST(copy_runtime_info, nodes_to_node_3) { } TEST(copy_runtime_info, replace_output_update_name) { - auto a = make_shared(element::f32, Shape{1}); - auto b = make_shared(a); - auto c = make_shared(b); - auto d = make_shared(c); + auto a = make_shared(element::f32, Shape{1}); + auto b = make_shared(a); + auto c = make_shared(b); + auto d = make_shared(c); TestAttributeMergable::set(b); TestAttributeMergable::set(c); diff --git a/src/core/tests/element_type.cpp b/src/core/tests/element_type.cpp index 5db6d0b9156..7be26553419 100644 --- a/src/core/tests/element_type.cpp +++ b/src/core/tests/element_type.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ngraph/type/element_type.hpp" +#include "openvino/core/type/element_type.hpp" #include diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 2a332e80837..848a91dbbfa 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -2,118 +2,113 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ngraph/file_util.hpp" +#include "openvino/util/file_util.hpp" + +#include #include #include #include #include -#include "gtest/gtest.h" -#include "openvino/util/file_util.hpp" - -NGRAPH_SUPPRESS_DEPRECATED_START - using namespace std; -using namespace ngraph; +using namespace ov; TEST(file_util, path_join) { { string s1 = ""; string s2 = ""; - EXPECT_STREQ("", file_util::path_join(s1, s2).c_str()); + EXPECT_STREQ("", ov::util::path_join({s1, s2}).c_str()); } { string s1 = ""; string s2 = "/test1/test2"; - EXPECT_STREQ("/test1/test2", file_util::path_join(s1, s2).c_str()); + EXPECT_STREQ("/test1/test2", ov::util::path_join({s1, s2}).c_str()); } { string s1 = ""; string s2 = "/test1/test2/"; - EXPECT_STREQ("/test1/test2/", file_util::path_join(s1, s2).c_str()); + EXPECT_STREQ("/test1/test2/", ov::util::path_join({s1, s2}).c_str()); } { string s1 = ""; string s2 = "test1/test2"; - EXPECT_STREQ("test1/test2", file_util::path_join(s1, s2).c_str()); + EXPECT_STREQ("test1/test2", ov::util::path_join({s1, s2}).c_str()); } { string s1 = "/x1/x2"; string s2 = ""; - EXPECT_STREQ("/x1/x2", file_util::path_join(s1, s2).c_str()); + EXPECT_STREQ("/x1/x2", ov::util::path_join({s1, s2}).c_str()); } { string s1 = "/x1/x2/"; string s2 = "/"; - EXPECT_STREQ("/", file_util::path_join(s1, s2).c_str()); + EXPECT_STREQ("/", ov::util::path_join({s1, s2}).c_str()); } { string s1 = "/x1/x2"; string s2 = "/test1/test2"; - EXPECT_STREQ("/test1/test2", file_util::path_join(s1, s2).c_str()); + EXPECT_STREQ("/test1/test2", ov::util::path_join({s1, s2}).c_str()); } { string s1 = "/x1/x2/"; string s2 = "test1/test2"; - EXPECT_STREQ("/x1/x2/test1/test2", file_util::path_join(s1, s2).c_str()); + EXPECT_STREQ("/x1/x2/test1/test2", ov::util::path_join({s1, s2}).c_str()); } { string s1 = "/x1/x2"; string s2 = "test1/test2"; #ifndef _WIN32 - EXPECT_STREQ("/x1/x2/test1/test2", file_util::path_join(s1, s2).c_str()); + EXPECT_STREQ("/x1/x2/test1/test2", ov::util::path_join({s1, s2}).c_str()); #else - EXPECT_STREQ("/x1/x2\\test1/test2", file_util::path_join(s1, s2).c_str()); + EXPECT_STREQ("/x1/x2\\test1/test2", ov::util::path_join({s1, s2}).c_str()); #endif } { string s1 = "/"; string s2 = "test1/test2"; - EXPECT_STREQ("/test1/test2", file_util::path_join(s1, s2).c_str()); + EXPECT_STREQ("/test1/test2", ov::util::path_join({s1, s2}).c_str()); } } TEST(file_util, sanitize_path) { { string path = "../../tensor.data"; - EXPECT_STREQ("tensor.data", file_util::sanitize_path(path).c_str()); + EXPECT_STREQ("tensor.data", ov::util::sanitize_path(path).c_str()); } { string path = "/../tensor.data"; - EXPECT_STREQ("tensor.data", file_util::sanitize_path(path).c_str()); + EXPECT_STREQ("tensor.data", ov::util::sanitize_path(path).c_str()); } { string path = ".."; - EXPECT_STREQ("", file_util::sanitize_path(path).c_str()); + EXPECT_STREQ("", ov::util::sanitize_path(path).c_str()); } { string path = "workspace/data/tensor.data"; - EXPECT_STREQ("workspace/data/tensor.data", file_util::sanitize_path(path).c_str()); + EXPECT_STREQ("workspace/data/tensor.data", ov::util::sanitize_path(path).c_str()); } { string path = "..\\..\\tensor.data"; - EXPECT_STREQ("tensor.data", file_util::sanitize_path(path).c_str()); + EXPECT_STREQ("tensor.data", ov::util::sanitize_path(path).c_str()); } { string path = "C:\\workspace\\tensor.data"; - EXPECT_STREQ("workspace\\tensor.data", file_util::sanitize_path(path).c_str()); + EXPECT_STREQ("workspace\\tensor.data", ov::util::sanitize_path(path).c_str()); } } -NGRAPH_SUPPRESS_DEPRECATED_END - using namespace testing; class TrimFileTest : public Test { diff --git a/src/core/tests/float16.cpp b/src/core/tests/float16.cpp index 545ac74dd61..88038c4b712 100644 --- a/src/core/tests/float16.cpp +++ b/src/core/tests/float16.cpp @@ -2,17 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ngraph/type/float16.hpp" +#include "openvino/core/type/float16.hpp" + +#include #include #include #include "common_test_utils/float_util.hpp" -#include "gtest/gtest.h" -#include "ngraph/runtime/aligned_buffer.hpp" using namespace std; -using namespace ngraph; +using namespace ov; TEST(float16, conversions) { float16 f16; diff --git a/src/core/tests/framework_node.cpp b/src/core/tests/framework_node.cpp index 52144b89191..6ad3b1ddc47 100644 --- a/src/core/tests/framework_node.cpp +++ b/src/core/tests/framework_node.cpp @@ -2,12 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ngraph/op/util/framework_node.hpp" +#include "openvino/op/util/framework_node.hpp" + +#include #include -#include "gtest/gtest.h" - TEST(framework_node, attrs) { ov::op::util::FrameworkNodeAttrs attrs; diff --git a/src/core/tests/graph_rewrite.cpp b/src/core/tests/graph_rewrite.cpp index 30a4e2db12c..5d20493c81c 100644 --- a/src/core/tests/graph_rewrite.cpp +++ b/src/core/tests/graph_rewrite.cpp @@ -4,71 +4,72 @@ #include -#include -#include -#include -#include - -NGRAPH_SUPPRESS_DEPRECATED_START +#include "common_test_utils/ngraph_test_utils.hpp" +#include "openvino/core/rtti.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/divide.hpp" +#include "openvino/op/op.hpp" +#include "openvino/op/relu.hpp" +#include "openvino/op/result.hpp" +#include "openvino/op/tanh.hpp" +#include "openvino/pass/pattern/op/label.hpp" using namespace ::testing; using namespace std; -using namespace ngraph; +using namespace ov; +using namespace ov::pass; -class TestPass : public ngraph::pass::MatcherPass { +class TestPass : public ov::pass::MatcherPass { public: - NGRAPH_RTTI_DECLARATION; + OPENVINO_RTTI("TestPass"); TestPass() : MatcherPass() { - auto divide = - std::make_shared(element::f32, Shape{}, pattern::has_class()); - ngraph::graph_rewrite_callback callback = [this](pattern::Matcher& m) { + auto divide = std::make_shared(element::f32, + Shape{}, + pattern::has_class()); + ov::graph_rewrite_callback callback = [this](pattern::Matcher& m) { if (transformation_callback(m.get_match_root())) { - auto relu = std::make_shared(m.get_match_root()->input_value(0)); - ngraph::replace_node(m.get_match_root(), relu); + auto relu = std::make_shared(m.get_match_root()->input_value(0)); + ov::replace_node(m.get_match_root(), relu); return true; } return false; }; - auto m = std::make_shared(divide, "TestMatcher"); + auto m = std::make_shared(divide, "TestMatcher"); this->register_matcher(m, callback); } }; -class GatherNodesPass : public ngraph::pass::MatcherPass { +class GatherNodesPass : public ov::pass::MatcherPass { public: - NGRAPH_RTTI_DECLARATION; + OPENVINO_RTTI("GatherNodesPass"); GatherNodesPass(NodeVector& order) : MatcherPass() { - ngraph::matcher_pass_callback callback = [&order](pattern::Matcher& m) { + ov::matcher_pass_callback callback = [&order](pattern::Matcher& m) { order.push_back(m.get_match_root()); return false; }; - auto m = std::make_shared(ngraph::pattern::any_input(), "GatherNodesPass"); + auto m = std::make_shared(ov::pass::pattern::any_input(), "GatherNodesPass"); this->register_matcher(m, callback); } }; -class Anchor : public ngraph::pass::GraphRewrite { +class Anchor : public ov::pass::GraphRewrite { public: - NGRAPH_RTTI_DECLARATION; + OPENVINO_RTTI("Anchor"); Anchor() : GraphRewrite() {} }; -NGRAPH_RTTI_DEFINITION(TestPass, "TestPass"); -NGRAPH_RTTI_DEFINITION(Anchor, "Anchor"); -NGRAPH_RTTI_DEFINITION(GatherNodesPass, "GatherNodesPass"); - -std::shared_ptr get_function() { - auto data = std::make_shared(ngraph::element::f32, ngraph::Shape{3, 1, 2}); - auto divide_constant = ngraph::opset3::Constant::create(ngraph::element::f32, ngraph::Shape{1}, {1.5}); - auto divide = std::make_shared(data, divide_constant); - return std::make_shared(ngraph::NodeVector{divide}, ngraph::ParameterVector{data}); +std::shared_ptr get_model() { + auto data = std::make_shared(ov::element::f32, ov::Shape{3, 1, 2}); + auto divide_constant = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{1}, {1.5}); + auto divide = std::make_shared(data, divide_constant); + return std::make_shared(ov::NodeVector{divide}, ov::ParameterVector{data}); } -ngraph::pass::param_callback get_callback() { +ov::pass::param_callback get_callback() { return [](const std::shared_ptr& node) -> bool { - if (std::dynamic_pointer_cast(node)) { + if (std::dynamic_pointer_cast(node)) { return true; } else { return false; @@ -77,10 +78,10 @@ ngraph::pass::param_callback get_callback() { } TEST(GraphRewriteOrderTest, MatcherPass) { - auto f = get_function(); + auto f = get_model(); NodeVector order; - ngraph::pass::Manager m; + ov::pass::Manager m; auto pass = m.register_pass(); pass->add_matcher(order); m.run_passes(f); @@ -89,10 +90,10 @@ TEST(GraphRewriteOrderTest, MatcherPass) { } TEST(BackwardGraphRewriteOrderTest, MatcherPass) { - auto f = get_function(); + auto f = get_model(); NodeVector order; - ngraph::pass::Manager m; + ov::pass::Manager m; auto pass = m.register_pass(); pass->add_matcher(order); m.run_passes(f); @@ -103,28 +104,28 @@ TEST(BackwardGraphRewriteOrderTest, MatcherPass) { } TEST(GraphRewriteTest, MatcherPassCallback) { - auto f = get_function(); + auto f = get_model(); Anchor anchor; anchor.add_matcher()->set_callback(get_callback()); anchor.run_on_model(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); } TEST(GraphRewriteTest, GraphRewriteCallback) { - auto f = get_function(); + auto f = get_model(); Anchor anchor; anchor.add_matcher(); anchor.set_callback(get_callback()); anchor.run_on_model(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); } TEST(GraphRewriteTest, ManagerCallbackDeprecated) { - auto f = get_function(); + auto f = get_model(); pass::Manager manager; auto anchor = manager.register_pass(); @@ -132,11 +133,11 @@ TEST(GraphRewriteTest, ManagerCallbackDeprecated) { manager.get_pass_config()->set_callback(get_callback()); manager.run_passes(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); } TEST(GraphRewriteTest, ManagerCallback) { - auto f = get_function(); + auto f = get_model(); pass::Manager manager; auto anchor = manager.register_pass(); @@ -145,129 +146,127 @@ TEST(GraphRewriteTest, ManagerCallback) { pass_config->set_callback(get_callback()); manager.run_passes(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); } TEST(GraphRewriteTest, ManagerCallback2) { - auto f = get_function(); + auto f = get_model(); pass::Manager manager; auto anchor = manager.register_pass(); manager.get_pass_config()->set_callback(get_callback()); manager.run_passes(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); } -class PrivateDivide : public ngraph::opset3::Divide { +class PrivateDivide : public ov::op::v1::Divide { public: - NGRAPH_RTTI_DECLARATION; - using ngraph::opset3::Divide::Divide; + OPENVINO_OP("PrivateDivide", "test_opset", ov::op::v1::Divide); + using ov::op::v1::Divide::Divide; }; -NGRAPH_RTTI_DEFINITION(PrivateDivide, "PrivateDivide", ngraph::opset3::Divide); - -std::shared_ptr get_derived_function() { - auto data = std::make_shared(ngraph::element::f32, ngraph::Shape{3, 1, 2}); - auto divide_constant = ngraph::opset3::Constant::create(ngraph::element::f32, ngraph::Shape{1}, {1.5}); +std::shared_ptr get_derived_model() { + auto data = std::make_shared(ov::element::f32, ov::Shape{3, 1, 2}); + auto divide_constant = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{1}, {1.5}); auto divide = std::make_shared(data, divide_constant); - return std::make_shared(ngraph::NodeVector{divide}, ngraph::ParameterVector{data}); + return std::make_shared(ov::NodeVector{divide}, ov::ParameterVector{data}); } TEST(GraphRewriteTest, MatcherPassCallbackDerived) { - auto f = get_derived_function(); + auto f = get_derived_model(); Anchor anchor; anchor.add_matcher()->set_callback(get_callback()); anchor.run_on_model(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); } -class TypeBasedTestPass : public ngraph::pass::MatcherPass { +class TypeBasedTestPass : public ov::pass::MatcherPass { public: TypeBasedTestPass() : MatcherPass() { - auto divide = std::make_shared(std::make_shared(), - std::make_shared()); - // element::f32, Shape{}, pattern::has_class()); - ngraph::graph_rewrite_callback callback = [this](pattern::Matcher& m) { + auto divide = std::make_shared(std::make_shared(), + std::make_shared()); + // element::f32, Shape{}, pattern::has_class()); + ov::graph_rewrite_callback callback = [this](pattern::Matcher& m) { if (transformation_callback(m.get_match_root())) { - auto relu = std::make_shared(m.get_match_root()->input_value(0)); - ngraph::replace_node(m.get_match_root(), relu); + auto relu = std::make_shared(m.get_match_root()->input_value(0)); + ov::replace_node(m.get_match_root(), relu); return true; } return false; }; - auto m = std::make_shared(divide, "TestMatcher"); + auto m = std::make_shared(divide, "TestMatcher"); this->register_matcher(m, callback); } }; -class TypeBasedTestPassDerived : public ngraph::pass::MatcherPass { +class TypeBasedTestPassDerived : public ov::pass::MatcherPass { public: TypeBasedTestPassDerived() : MatcherPass() { - auto divide = std::make_shared(std::make_shared(), - std::make_shared()); - ngraph::graph_rewrite_callback callback = [this](pattern::Matcher& m) { + auto divide = std::make_shared(std::make_shared(), + std::make_shared()); + ov::graph_rewrite_callback callback = [this](pattern::Matcher& m) { if (transformation_callback(m.get_match_root())) { - auto tanh = std::make_shared(m.get_match_root()->input_value(0)); - ngraph::replace_node(m.get_match_root(), tanh); + auto tanh = std::make_shared(m.get_match_root()->input_value(0)); + ov::replace_node(m.get_match_root(), tanh); return true; } return false; }; - auto m = std::make_shared(divide, "TestMatcher"); + auto m = std::make_shared(divide, "TestMatcher"); this->register_matcher(m, callback); } }; TEST(GraphRewriteTest, TypeBasedMatcherPassCallback) { - auto f = get_function(); + auto f = get_model(); Anchor anchor; anchor.add_matcher()->set_callback(get_callback()); anchor.run_on_model(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); } TEST(GraphRewriteTest, TypeBasedMatcherPassCallbackDerived) { - auto f = get_derived_function(); + auto f = get_derived_model(); Anchor anchor; anchor.add_matcher()->set_callback(get_callback()); anchor.run_on_model(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); } TEST(GraphRewriteTest, TypeBasedMatcherPassOrder1) { - auto f = get_derived_function(); + auto f = get_derived_model(); Anchor anchor; anchor.add_matcher()->set_callback(get_callback()); anchor.add_matcher()->set_callback(get_callback()); anchor.run_on_model(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); } TEST(GraphRewriteTest, TypeBasedMatcherPassOrder2) { - auto f = get_derived_function(); + auto f = get_derived_model(); Anchor anchor; anchor.add_matcher()->set_callback(get_callback()); anchor.add_matcher()->set_callback(get_callback()); anchor.run_on_model(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); } TEST(PassConfigTest, Test1) { { - auto f = get_function(); + auto f = get_model(); pass::Manager manager; manager.register_pass(); @@ -277,11 +276,11 @@ TEST(PassConfigTest, Test1) { manager.run_passes(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); } { - auto f = get_function(); + auto f = get_model(); pass::Manager manager; manager.register_pass(); @@ -291,13 +290,13 @@ TEST(PassConfigTest, Test1) { manager.run_passes(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); } { - auto f = get_function(); + auto f = get_model(); - auto pass_config = std::make_shared(); + auto pass_config = std::make_shared(); pass::Manager manager(pass_config); manager.register_pass(); @@ -306,11 +305,11 @@ TEST(PassConfigTest, Test1) { manager.run_passes(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); } { - auto f = get_function(); + auto f = get_model(); pass::Manager manager; auto anchor = manager.register_pass(); @@ -321,11 +320,11 @@ TEST(PassConfigTest, Test1) { manager.run_passes(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); } { - auto f = get_function(); + auto f = get_model(); pass::Manager manager; auto anchor = manager.register_pass(); @@ -336,7 +335,7 @@ TEST(PassConfigTest, Test1) { manager.run_passes(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); } { @@ -348,7 +347,7 @@ TEST(PassConfigTest, Test1) { } { - auto f = get_function(); + auto f = get_model(); pass::Manager manager; manager.register_pass(); @@ -358,15 +357,15 @@ TEST(PassConfigTest, Test1) { pass_config->disable(); manager.run_passes(f); - ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 0); pass_config->enable(); manager.run_passes(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); } { - auto f = get_function(); + auto f = get_model(); pass::Manager manager; auto anchor = manager.register_pass(); @@ -377,26 +376,26 @@ TEST(PassConfigTest, Test1) { pass_config->disable(); manager.run_passes(f); - ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 0); pass_config->enable(); manager.run_passes(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); } } -class CheckConsumers : public ngraph::pass::MatcherPass { +class CheckConsumers : public ov::pass::MatcherPass { public: NGRAPH_RTTI_DECLARATION; CheckConsumers() { - ngraph::matcher_pass_callback callback = [](pattern::Matcher& m) -> bool { + ov::matcher_pass_callback callback = [](pattern::Matcher& m) -> bool { auto node = m.get_match_root(); auto consumers = [](Node* node) { int64_t cnt{0}; for (auto output : node->outputs()) { cnt += output.get_target_inputs().size(); } - if (ov::as_type(node) || ov::as_type(node)) { + if (ov::as_type(node) || ov::as_type(node)) { cnt += 1; } return cnt; @@ -429,7 +428,7 @@ public: return false; }; - auto m = std::make_shared(ngraph::pattern::any_input(), "CheckConsumers"); + auto m = std::make_shared(ov::pass::pattern::any_input(), "CheckConsumers"); this->register_matcher(m, callback); } }; @@ -437,7 +436,7 @@ public: NGRAPH_RTTI_DEFINITION(CheckConsumers, "CheckConsumers"); TEST(GraphRewriteTest, nodes_use_count) { - auto f = get_function(); + auto f = get_model(); pass::Manager m; m.register_pass(); ASSERT_NO_THROW(m.run_passes(f)); diff --git a/src/core/tests/input_output_assign.cpp b/src/core/tests/input_output_assign.cpp index 8ee2057294c..be2544115c3 100644 --- a/src/core/tests/input_output_assign.cpp +++ b/src/core/tests/input_output_assign.cpp @@ -2,21 +2,23 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" - -NGRAPH_SUPPRESS_DEPRECATED_START +#include "openvino/core/shape.hpp" +#include "openvino/core/type/element_type.hpp" +#include "openvino/op/add.hpp" +#include "openvino/op/parameter.hpp" using namespace std; -using namespace ngraph; +using namespace ov; TEST(input_output, param_tensor) { // Params have no arguments, so we can check that the value becomes a tensor output - auto& et = element::f32; - Shape shape{2, 4}; - auto param = make_shared(et, shape); + auto& et = ov::element::f32; + ov::Shape shape{2, 4}; + auto param = make_shared(et, shape); ASSERT_EQ(param->get_output_size(), 1); ASSERT_EQ(et, param->get_element_type()); @@ -24,8 +26,8 @@ TEST(input_output, param_tensor) { } TEST(input_output, simple_output) { - auto param_0 = make_shared(element::f32, Shape{2, 4}); - auto param_1 = make_shared(element::f32, Shape{2, 4}); + auto param_0 = make_shared(element::f32, Shape{2, 4}); + auto param_1 = make_shared(element::f32, Shape{2, 4}); auto add = make_shared(param_0, param_1); // Sort the ops diff --git a/src/core/tests/int4.cpp b/src/core/tests/int4.cpp index 964b74c7a37..2edb82dda01 100644 --- a/src/core/tests/int4.cpp +++ b/src/core/tests/int4.cpp @@ -2,17 +2,18 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include "common_test_utils/test_tools.hpp" -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" +#include "openvino/op/constant.hpp" #include "openvino/runtime/tensor.hpp" -using namespace ngraph; +using namespace ov; using namespace std; TEST(int4, convert_i4_to_string) { vector values{171, 16}; - auto constant = make_shared(element::i4, Shape{3}, &values[0]); + auto constant = make_shared(element::i4, Shape{3}, &values[0]); vector ref{"-6", "-5", "1"}; for (size_t i = 0; i < 3; ++i) { @@ -22,7 +23,7 @@ TEST(int4, convert_i4_to_string) { TEST(int4, tensor_or_constant_size) { vector values{171, 16}; - auto constant = make_shared(element::i4, Shape{3}, &values[0]); + auto constant = make_shared(element::i4, Shape{3}, &values[0]); EXPECT_EQ(2, constant->get_byte_size()); ov::Tensor runtime_tensor(ov::element::i4, ov::Shape{3}); diff --git a/src/core/tests/intervals.cpp b/src/core/tests/intervals.cpp index 16c32d63473..b9d3d4cfee6 100644 --- a/src/core/tests/intervals.cpp +++ b/src/core/tests/intervals.cpp @@ -4,14 +4,13 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "ngraph/interval.hpp" +#include "openvino/core/interval.hpp" using namespace std; -using namespace ngraph; -using ::testing::Return; +using namespace ov; TEST(intervals, size) { - EXPECT_TRUE(Interval().size() > 0); + EXPECT_TRUE(ov::Interval().size() > 0); EXPECT_TRUE(Interval(2).size() == 1); EXPECT_TRUE(Interval(1, 5).size() == 5); EXPECT_TRUE(Interval(3, 2).size() == 0); diff --git a/src/core/tests/main.cpp b/src/core/tests/main.cpp index 763af02d65e..b60d348073e 100644 --- a/src/core/tests/main.cpp +++ b/src/core/tests/main.cpp @@ -6,8 +6,6 @@ #include #include "gtest/gtest.h" -#include "ngraph/log.hpp" -#include "ngraph/ngraph.hpp" using namespace std; diff --git a/src/core/tests/matcher_pass.cpp b/src/core/tests/matcher_pass.cpp index 79be164bae2..ae0b6d911c7 100644 --- a/src/core/tests/matcher_pass.cpp +++ b/src/core/tests/matcher_pass.cpp @@ -2,56 +2,52 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include #include #include #include #include -#include -#include -#include "gtest/gtest.h" -#include "ngraph/graph_util.hpp" -#include "ngraph/log.hpp" -#include "ngraph/ngraph.hpp" -#include "ngraph/opsets/opset3.hpp" -#include "ngraph/pass/graph_rewrite.hpp" -#include "ngraph/pass/manager.hpp" +#include "openvino/core/rt_info.hpp" +#include "openvino/op/relu.hpp" +#include "openvino/pass/graph_rewrite.hpp" +#include "openvino/pass/pattern/op/wrap_type.hpp" -using namespace ngraph; +using namespace ov; +using namespace ov::pass; using namespace std; -OPENVINO_SUPPRESS_DEPRECATED_START - -class TestMatcherPass : public pass::MatcherPass { +class TestMatcherPass : public ov::pass::MatcherPass { public: TestMatcherPass() { - auto m_relu1 = ngraph::pattern::wrap_type(pattern::consumers_count(1)); - auto m_relu2 = ngraph::pattern::wrap_type({m_relu1}); + auto m_relu1 = ov::pass::pattern::wrap_type(pattern::consumers_count(1)); + auto m_relu2 = ov::pass::pattern::wrap_type({m_relu1}); - ngraph::graph_rewrite_callback callback = [=](pattern::Matcher& m) { + ov::graph_rewrite_callback callback = [=](pattern::Matcher& m) { // Map that helps to connect labels with matched outputs auto& node_to_output = m.get_pattern_value_map(); // Create new Relu operation and add register it for additional execution - auto new_relu = register_new_node( - node_to_output.at(m_relu1).get_node_shared_ptr()->input_value(0)); + auto new_relu = + register_new_node(node_to_output.at(m_relu1).get_node_shared_ptr()->input_value(0)); // Copy runtime info attributes to newly created operation - ngraph::copy_runtime_info(m.get_matched_nodes(), new_relu); + ov::copy_runtime_info(m.get_matched_nodes(), new_relu); // Save last Relu name to new Relu operation new_relu->set_friendly_name(m.get_match_root()->get_friendly_name()); // Replace Relu->Relu with Relu - ngraph::replace_node(m.get_match_root(), new_relu); + ov::replace_node(m.get_match_root(), new_relu); // Return true as the root node was changed return true; }; // Register pattern with Divide operation as a pattern root node - auto m = std::make_shared(m_relu2, "ReluReluFusion"); + auto m = std::make_shared(m_relu2, "ReluReluFusion"); // Register Matcher this->register_matcher(m, callback); } @@ -60,10 +56,10 @@ public: TEST(pattern, matcher_pass) { { TestMatcherPass test_matcher; - auto a = make_shared(element::f32, Shape{1}); - auto b = make_shared(a); - auto c = make_shared(b); - auto f = std::make_shared(ngraph::NodeVector{c}, ParameterVector{a}); + auto a = make_shared(element::f32, Shape{1}); + auto b = make_shared(a); + auto c = make_shared(b); + auto f = std::make_shared(ov::NodeVector{c}, ParameterVector{a}); ASSERT_TRUE(test_matcher.get_matcher()->match(c->output(0))); ASSERT_TRUE(test_matcher.get_matcher()->get_matched_nodes().size() == 2); @@ -78,22 +74,22 @@ TEST(pattern, matcher_pass) { { TestMatcherPass test_matcher; - auto a = make_shared(element::f32, Shape{1}); - auto b = make_shared(a); - auto c = make_shared(b); - auto f = std::make_shared(ngraph::NodeVector{b, c}, ParameterVector{a}); + auto a = make_shared(element::f32, Shape{1}); + auto b = make_shared(a); + auto c = make_shared(b); + auto f = std::make_shared(ov::NodeVector{b, c}, ParameterVector{a}); ASSERT_FALSE(test_matcher.get_matcher()->match(c->output(0))); } { - std::shared_ptr f; + std::shared_ptr f; { - auto a = make_shared(element::f32, Shape{1}); - auto b = make_shared(a); - auto c = make_shared(b); - auto d = make_shared(c); - f = std::make_shared(ngraph::NodeVector{d}, ParameterVector{a}); + auto a = make_shared(element::f32, Shape{1}); + auto b = make_shared(a); + auto c = make_shared(b); + auto d = make_shared(c); + f = std::make_shared(ov::NodeVector{d}, ParameterVector{a}); } pass::GraphRewrite pass; diff --git a/src/core/tests/misc.cpp b/src/core/tests/misc.cpp deleted file mode 100644 index ea89a5c55a9..00000000000 --- a/src/core/tests/misc.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "misc.hpp" - -FILE* port_open(const char* command, const char* type) { -#ifdef _WIN32 - return _popen(command, type); -#elif defined(__linux) || defined(__EMSCRIPTEN__) || defined(__APPLE__) - return popen(command, type); -#endif -} - -int port_close(FILE* stream) { -#ifdef _WIN32 - return _pclose(stream); -#elif defined(__linux) || defined(__EMSCRIPTEN__) || defined(__APPLE__) - return pclose(stream); -#endif -} - -int set_environment(const char* name, const char* value, int overwrite) { -#ifdef _WIN32 - return _putenv_s(name, value); -#elif defined(__linux) || defined(__EMSCRIPTEN__) || defined(__APPLE__) - return setenv(name, value, overwrite); -#endif -} - -int unset_environment(const char* name) { -#ifdef _WIN32 - return _putenv_s(name, ""); -#elif defined(__linux) || defined(__EMSCRIPTEN__) || defined(__APPLE__) - return unsetenv(name); -#endif -} diff --git a/src/core/tests/misc.hpp b/src/core/tests/misc.hpp deleted file mode 100644 index 21d45aff112..00000000000 --- a/src/core/tests/misc.hpp +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once -#include -#include - -FILE* port_open(const char* command, const char* type); -int port_close(FILE* stream); -int set_environment(const char* name, const char* value, int overwrite); -int unset_environment(const char* name); diff --git a/src/core/tests/model.cpp b/src/core/tests/model.cpp index aa404120c0b..90391a5a923 100644 --- a/src/core/tests/model.cpp +++ b/src/core/tests/model.cpp @@ -533,12 +533,12 @@ TEST(model, multiple_inputs_outputs_model_from_const_model) { TEST(model, parameter_result_function) { std::shared_ptr function = nullptr; { - auto param = std::make_shared(ov::element::f16, ngraph::Shape({1, 3, 24, 24})); + auto param = std::make_shared(ov::element::f16, ov::Shape({1, 3, 24, 24})); param->set_friendly_name("param"); param->output(0).get_tensor().set_names({"data"}); auto result = std::make_shared(param); result->set_friendly_name("result"); - function = std::make_shared(ngraph::ResultVector{result}, ngraph::ParameterVector{param}); + function = std::make_shared(ov::ResultVector{result}, ov::ParameterVector{param}); function->set_friendly_name("ParamResult"); } @@ -562,12 +562,12 @@ TEST(model, constant_result_function) { std::shared_ptr constant = nullptr; { - constant = std::make_shared(ov::element::f32, ngraph::Shape({1, 3, 24, 24})); + constant = std::make_shared(ov::element::f32, ov::Shape({1, 3, 24, 24})); constant->set_friendly_name("constant"); constant->output(0).get_tensor().set_names({"data"}); auto result = std::make_shared(constant); result->set_friendly_name("result"); - function = std::make_shared(ngraph::ResultVector{result}, ngraph::ParameterVector{}); + function = std::make_shared(ov::ResultVector{result}, ov::ParameterVector{}); function->set_friendly_name("ConstResult"); } @@ -585,7 +585,7 @@ TEST(model, constant_result_function) { } TEST(model_reshape, ReshapedDynamicShapeLayout) { - std::shared_ptr ngraph; + std::shared_ptr model; { ov::PartialShape shape({-1, 3, 22, 22}); ov::element::Type type(ov::element::Type_t::f32); @@ -594,21 +594,21 @@ TEST(model_reshape, ReshapedDynamicShapeLayout) { auto relu = std::make_shared(param); ov::ParameterVector params = {param}; - ngraph = std::make_shared(relu, params); + model = std::make_shared(relu, params); } - EXPECT_TRUE(ngraph->input().get_partial_shape().is_dynamic()); + EXPECT_TRUE(model->input().get_partial_shape().is_dynamic()); std::map new_shape; new_shape["tensor"] = ov::Shape{1, 3, 22, 22}; - EXPECT_NO_THROW(ngraph->reshape(new_shape)); + EXPECT_NO_THROW(model->reshape(new_shape)); - EXPECT_FALSE(ngraph->input().get_partial_shape().is_dynamic()); - EXPECT_FALSE(ngraph->get_parameters().front()->get_partial_shape().is_dynamic()); + EXPECT_FALSE(model->input().get_partial_shape().is_dynamic()); + EXPECT_FALSE(model->get_parameters().front()->get_partial_shape().is_dynamic()); } TEST(model_reshape, ReshapeBatchReLU) { - std::shared_ptr ngraph; + std::shared_ptr model; { ov::PartialShape shape({1, 3, 22, 22}); ov::element::Type type(ov::element::Type_t::f32); @@ -620,24 +620,24 @@ TEST(model_reshape, ReshapeBatchReLU) { ov::ParameterVector params = {param}; ov::ResultVector results = {result}; - ngraph = std::make_shared(results, params); + model = std::make_shared(results, params); } - EXPECT_EQ(ngraph->get_parameters()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); - EXPECT_EQ(ngraph->get_results()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); + EXPECT_EQ(model->get_parameters()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); + EXPECT_EQ(model->get_results()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); { std::map new_shape; new_shape["tensor2"] = ov::PartialShape{2, 3, 22, 22}; - EXPECT_NO_THROW(ngraph->reshape(new_shape)); + EXPECT_NO_THROW(model->reshape(new_shape)); } - EXPECT_EQ(ngraph->get_parameters()[0]->get_shape(), ov::Shape({2, 3, 22, 22})); - EXPECT_EQ(ngraph->get_results()[0]->get_shape(), ov::Shape({2, 3, 22, 22})); + EXPECT_EQ(model->get_parameters()[0]->get_shape(), ov::Shape({2, 3, 22, 22})); + EXPECT_EQ(model->get_results()[0]->get_shape(), ov::Shape({2, 3, 22, 22})); } TEST(model_reshape, ReshapeSpatialReLU) { - std::shared_ptr ngraph; + std::shared_ptr model; { ov::PartialShape shape({1, 3, 22, 22}); ov::element::Type type(ov::element::Type_t::f32); @@ -649,24 +649,24 @@ TEST(model_reshape, ReshapeSpatialReLU) { ov::ParameterVector params = {param}; ov::ResultVector results = {result}; - ngraph = std::make_shared(results, params); + model = std::make_shared(results, params); } - EXPECT_EQ(ngraph->get_parameters()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); - EXPECT_EQ(ngraph->get_results()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); + EXPECT_EQ(model->get_parameters()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); + EXPECT_EQ(model->get_results()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); { std::map new_shape; new_shape["tensor"] = ov::PartialShape{1, 3, 25, 25}; - EXPECT_NO_THROW(ngraph->reshape(new_shape)); + EXPECT_NO_THROW(model->reshape(new_shape)); } - EXPECT_EQ(ngraph->get_parameters()[0]->get_shape(), ov::Shape({1, 3, 25, 25})); - EXPECT_EQ(ngraph->get_results()[0]->get_shape(), ov::Shape({1, 3, 25, 25})); + EXPECT_EQ(model->get_parameters()[0]->get_shape(), ov::Shape({1, 3, 25, 25})); + EXPECT_EQ(model->get_results()[0]->get_shape(), ov::Shape({1, 3, 25, 25})); } TEST(model_reshape, ReshapeSpatialReLUWithoutReplaceParameter) { - std::shared_ptr ngraph; + std::shared_ptr model; { ov::PartialShape shape({1, 3, 22, 22}); ov::element::Type type(ov::element::Type_t::f32); @@ -677,24 +677,24 @@ TEST(model_reshape, ReshapeSpatialReLUWithoutReplaceParameter) { ov::ParameterVector params = {param}; ov::ResultVector results = {result}; - ngraph = std::make_shared(results, params); + model = std::make_shared(results, params); } - EXPECT_EQ(ngraph->get_parameters()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); - EXPECT_EQ(ngraph->get_results()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); + EXPECT_EQ(model->get_parameters()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); + EXPECT_EQ(model->get_results()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); { - ngraph->get_parameters()[0]->set_partial_shape({1, 3, 25, 25}); - ngraph->validate_nodes_and_infer_types(); + model->get_parameters()[0]->set_partial_shape({1, 3, 25, 25}); + model->validate_nodes_and_infer_types(); } - EXPECT_EQ(ngraph->input().get_partial_shape(), ov::Shape({1, 3, 25, 25})); - EXPECT_EQ(ngraph->output().get_partial_shape(), ov::Shape({1, 3, 25, 25})); + EXPECT_EQ(model->input().get_partial_shape(), ov::Shape({1, 3, 25, 25})); + EXPECT_EQ(model->output().get_partial_shape(), ov::Shape({1, 3, 25, 25})); } TEST(model_reshape, ReshapeSpatialReLUStaticToDynamic) { const ov::PartialShape refShape{1, 3, ov::Dimension::dynamic(), 25}; - std::shared_ptr ngraph; + std::shared_ptr model; { ov::PartialShape shape({1, 3, 22, 22}); ov::element::Type type(ov::element::Type_t::f32); @@ -706,27 +706,27 @@ TEST(model_reshape, ReshapeSpatialReLUStaticToDynamic) { ov::ParameterVector params = {param}; ov::ResultVector results = {result}; - ngraph = std::make_shared(results, params); + model = std::make_shared(results, params); } - EXPECT_EQ(ngraph->get_parameters()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); - EXPECT_EQ(ngraph->get_results()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); + EXPECT_EQ(model->get_parameters()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); + EXPECT_EQ(model->get_results()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); { std::map new_shape; new_shape["tensor"] = refShape; - EXPECT_NO_THROW(ngraph->reshape(new_shape)); + EXPECT_NO_THROW(model->reshape(new_shape)); } - EXPECT_TRUE(ngraph->input(0).get_partial_shape().is_dynamic()); - EXPECT_TRUE(ngraph->output(0).get_partial_shape().is_dynamic()); - EXPECT_EQ(ngraph->input(0).get_partial_shape(), refShape); - EXPECT_EQ(ngraph->output(0).get_partial_shape(), refShape); + EXPECT_TRUE(model->input(0).get_partial_shape().is_dynamic()); + EXPECT_TRUE(model->output(0).get_partial_shape().is_dynamic()); + EXPECT_EQ(model->input(0).get_partial_shape(), refShape); + EXPECT_EQ(model->output(0).get_partial_shape(), refShape); } TEST(model_reshape, ReshapeSpatialReLUStaticToFullyDynamic) { const ov::PartialShape refShape = ov::PartialShape::dynamic(); - std::shared_ptr ngraph; + std::shared_ptr model; { ov::PartialShape shape({1, 3, 22, 22}); ov::element::Type type(ov::element::Type_t::f32); @@ -738,27 +738,27 @@ TEST(model_reshape, ReshapeSpatialReLUStaticToFullyDynamic) { ov::ParameterVector params = {param}; ov::ResultVector results = {result}; - ngraph = std::make_shared(results, params); + model = std::make_shared(results, params); } - EXPECT_EQ(ngraph->get_parameters()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); - EXPECT_EQ(ngraph->get_results()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); + EXPECT_EQ(model->get_parameters()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); + EXPECT_EQ(model->get_results()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); { std::map new_shape; new_shape["tensor"] = refShape; - EXPECT_NO_THROW(ngraph->reshape(new_shape)); + EXPECT_NO_THROW(model->reshape(new_shape)); } - EXPECT_TRUE(ngraph->input().get_partial_shape().is_dynamic()); - EXPECT_TRUE(ngraph->output().get_partial_shape().is_dynamic()); - EXPECT_EQ(ngraph->input().get_partial_shape(), refShape); - EXPECT_EQ(ngraph->output().get_partial_shape(), refShape); + EXPECT_TRUE(model->input().get_partial_shape().is_dynamic()); + EXPECT_TRUE(model->output().get_partial_shape().is_dynamic()); + EXPECT_EQ(model->input().get_partial_shape(), refShape); + EXPECT_EQ(model->output().get_partial_shape(), refShape); } TEST(model_reshape, ReshapeSpatialReLUDynamicToDynamic) { const ov::PartialShape refShape{1, 3, ov::Dimension::dynamic(), 25}; - std::shared_ptr ngraph; + std::shared_ptr model; { ov::PartialShape shape({1, 3, 22, ov::Dimension::dynamic()}); ov::element::Type type(ov::element::Type_t::f32); @@ -770,22 +770,22 @@ TEST(model_reshape, ReshapeSpatialReLUDynamicToDynamic) { ov::ParameterVector params = {param}; ov::ResultVector results = {result}; - ngraph = std::make_shared(results, params); + model = std::make_shared(results, params); } - EXPECT_EQ(ngraph->input().get_partial_shape(), ov::PartialShape({1, 3, 22, ov::Dimension::dynamic()})); - EXPECT_EQ(ngraph->output().get_partial_shape(), ov::PartialShape({1, 3, 22, ov::Dimension::dynamic()})); + EXPECT_EQ(model->input().get_partial_shape(), ov::PartialShape({1, 3, 22, ov::Dimension::dynamic()})); + EXPECT_EQ(model->output().get_partial_shape(), ov::PartialShape({1, 3, 22, ov::Dimension::dynamic()})); { std::map new_shape; new_shape["tensor"] = refShape; - EXPECT_NO_THROW(ngraph->reshape(new_shape)); + EXPECT_NO_THROW(model->reshape(new_shape)); } - EXPECT_TRUE(ngraph->input().get_partial_shape().is_dynamic()); - EXPECT_TRUE(ngraph->output().get_partial_shape().is_dynamic()); - EXPECT_EQ(ngraph->input().get_partial_shape(), refShape); - EXPECT_EQ(ngraph->output().get_partial_shape(), refShape); + EXPECT_TRUE(model->input().get_partial_shape().is_dynamic()); + EXPECT_TRUE(model->output().get_partial_shape().is_dynamic()); + EXPECT_EQ(model->input().get_partial_shape(), refShape); + EXPECT_EQ(model->output().get_partial_shape(), refShape); } TEST(model_reshape, TestInvalidReshape) { @@ -840,7 +840,7 @@ TEST(model_reshape, TestReshapeWithInvalidShapesForTheSameTensor) { } TEST(model_reshape, ReshapeBatchReLUByIndex) { - std::shared_ptr ngraph; + std::shared_ptr model; ov::Output port; { ov::PartialShape shape({1, 3, 22, 22}); @@ -854,24 +854,24 @@ TEST(model_reshape, ReshapeBatchReLUByIndex) { ov::ParameterVector params = {param}; ov::ResultVector results = {result}; - ngraph = std::make_shared(results, params); + model = std::make_shared(results, params); } - EXPECT_EQ(ngraph->get_parameters()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); - EXPECT_EQ(ngraph->get_results()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); + EXPECT_EQ(model->get_parameters()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); + EXPECT_EQ(model->get_results()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); { std::map new_shape; new_shape[0] = ov::PartialShape{2, 3, 22, 22}; - EXPECT_NO_THROW(ngraph->reshape(new_shape)); + EXPECT_NO_THROW(model->reshape(new_shape)); } - EXPECT_EQ(ngraph->get_parameters()[0]->get_shape(), ov::Shape({2, 3, 22, 22})); - EXPECT_EQ(ngraph->get_results()[0]->get_shape(), ov::Shape({2, 3, 22, 22})); + EXPECT_EQ(model->get_parameters()[0]->get_shape(), ov::Shape({2, 3, 22, 22})); + EXPECT_EQ(model->get_results()[0]->get_shape(), ov::Shape({2, 3, 22, 22})); } TEST(model_reshape, ReshapeBatchReLUByPort) { - std::shared_ptr ngraph; + std::shared_ptr model; ov::Output port; { ov::PartialShape shape({1, 3, 22, 22}); @@ -885,24 +885,24 @@ TEST(model_reshape, ReshapeBatchReLUByPort) { ov::ParameterVector params = {param}; ov::ResultVector results = {result}; - ngraph = std::make_shared(results, params); + model = std::make_shared(results, params); } - EXPECT_EQ(ngraph->get_parameters()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); - EXPECT_EQ(ngraph->get_results()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); + EXPECT_EQ(model->get_parameters()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); + EXPECT_EQ(model->get_results()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); { std::map, ov::PartialShape> new_shape; new_shape[port] = ov::PartialShape{2, 3, 22, 22}; - EXPECT_NO_THROW(ngraph->reshape(new_shape)); + EXPECT_NO_THROW(model->reshape(new_shape)); } - EXPECT_EQ(ngraph->get_parameters()[0]->get_shape(), ov::Shape({2, 3, 22, 22})); - EXPECT_EQ(ngraph->get_results()[0]->get_shape(), ov::Shape({2, 3, 22, 22})); + EXPECT_EQ(model->get_parameters()[0]->get_shape(), ov::Shape({2, 3, 22, 22})); + EXPECT_EQ(model->get_results()[0]->get_shape(), ov::Shape({2, 3, 22, 22})); } TEST(model_reshape, ReshapeBatchReLUWithOneInput) { - std::shared_ptr ngraph; + std::shared_ptr model; ov::Output port; { ov::PartialShape shape({1, 3, 22, 22}); @@ -916,20 +916,20 @@ TEST(model_reshape, ReshapeBatchReLUWithOneInput) { ov::ParameterVector params = {param}; ov::ResultVector results = {result}; - ngraph = std::make_shared(results, params); + model = std::make_shared(results, params); } - EXPECT_EQ(ngraph->get_parameters()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); - EXPECT_EQ(ngraph->get_results()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); + EXPECT_EQ(model->get_parameters()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); + EXPECT_EQ(model->get_results()[0]->get_shape(), ov::Shape({1, 3, 22, 22})); { ov::PartialShape new_shape; new_shape = ov::PartialShape{2, 3, 22, 22}; - EXPECT_NO_THROW(ngraph->reshape(new_shape)); + EXPECT_NO_THROW(model->reshape(new_shape)); } - EXPECT_EQ(ngraph->get_parameters()[0]->get_shape(), ov::Shape({2, 3, 22, 22})); - EXPECT_EQ(ngraph->get_results()[0]->get_shape(), ov::Shape({2, 3, 22, 22})); + EXPECT_EQ(model->get_parameters()[0]->get_shape(), ov::Shape({2, 3, 22, 22})); + EXPECT_EQ(model->get_results()[0]->get_shape(), ov::Shape({2, 3, 22, 22})); } TEST(model_reshape, IncoreectReshapeBatchWithMultipleInputs) { diff --git a/src/core/tests/node_input_output.cpp b/src/core/tests/node_input_output.cpp index ebbbc5acff4..14034a42491 100644 --- a/src/core/tests/node_input_output.cpp +++ b/src/core/tests/node_input_output.cpp @@ -2,22 +2,22 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include #include #include #include -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" +#include "openvino/op/add.hpp" +#include "openvino/op/parameter.hpp" -NGRAPH_SUPPRESS_DEPRECATED_START - -using namespace ngraph; +using namespace ov; using namespace std; TEST(node_input_output, input_create) { - auto x = make_shared(element::f32, Shape{1, 2, 3, 4}); - auto y = make_shared(element::f32, Shape{1, 2, 3, 4}); + auto x = make_shared(element::f32, Shape{1, 2, 3, 4}); + auto y = make_shared(element::f32, Shape{1, 2, 3, 4}); auto add = make_shared(x, y); auto add_in_0 = add->input(0); @@ -41,8 +41,8 @@ TEST(node_input_output, input_create) { } TEST(node_input_output, input_create_const) { - auto x = make_shared(element::f32, Shape{1, 2, 3, 4}); - auto y = make_shared(element::f32, Shape{1, 2, 3, 4}); + auto x = make_shared(element::f32, Shape{1, 2, 3, 4}); + auto y = make_shared(element::f32, Shape{1, 2, 3, 4}); auto add = make_shared(x, y); auto add_in_0 = add->input(0); @@ -66,8 +66,8 @@ TEST(node_input_output, input_create_const) { } TEST(node_input_output, output_create) { - auto x = make_shared(element::f32, Shape{1, 2, 3, 4}); - auto y = make_shared(element::f32, Shape{1, 2, 3, 4}); + auto x = make_shared(element::f32, Shape{1, 2, 3, 4}); + auto y = make_shared(element::f32, Shape{1, 2, 3, 4}); auto add = make_shared(x, y); auto add_out_0 = add->output(0); @@ -88,8 +88,8 @@ TEST(node_input_output, output_create) { } TEST(node_input_output, output_create_const) { - auto x = make_shared(element::f32, Shape{1, 2, 3, 4}); - auto y = make_shared(element::f32, Shape{1, 2, 3, 4}); + auto x = make_shared(element::f32, Shape{1, 2, 3, 4}); + auto y = make_shared(element::f32, Shape{1, 2, 3, 4}); auto add = make_shared(x, y); auto add_out_0 = add->output(0); @@ -105,8 +105,8 @@ TEST(node_input_output, output_create_const) { } TEST(node_input_output, output_rt_info) { - auto x = make_shared(element::f32, Shape{1, 2, 3, 4}); - auto y = make_shared(element::f32, Shape{1, 2, 3, 4}); + auto x = make_shared(element::f32, Shape{1, 2, 3, 4}); + auto y = make_shared(element::f32, Shape{1, 2, 3, 4}); auto add = make_shared(x, y); auto add_const = make_shared(x, y); @@ -121,9 +121,9 @@ TEST(node_input_output, output_rt_info) { } TEST(node_input_output, input_set_argument) { - auto x = make_shared(element::f32, Shape{1}); - auto y = make_shared(element::f32, Shape{2}); - auto z = make_shared(element::f32, Shape{3}); + auto x = make_shared(element::f32, Shape{1}); + auto y = make_shared(element::f32, Shape{2}); + auto z = make_shared(element::f32, Shape{3}); auto add = make_shared(x, y); diff --git a/src/core/tests/op.cpp b/src/core/tests/op.cpp index 75278a88d03..20f6d919c89 100644 --- a/src/core/tests/op.cpp +++ b/src/core/tests/op.cpp @@ -2,44 +2,43 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include #include #include #include #include -#include "gmock/gmock.h" -#include "gtest/gtest.h" -#include "ngraph/graph_util.hpp" -#include "ngraph/ngraph.hpp" -#include "ngraph/opsets/opset.hpp" - -NGRAPH_SUPPRESS_DEPRECATED_START +#include "openvino/op/add.hpp" +#include "openvino/op/parameter.hpp" +#include "openvino/op/util/op_types.hpp" +#include "openvino/opsets/opset.hpp" using namespace std; -using namespace ngraph; +using namespace ov; TEST(op, is_op) { - auto arg0 = make_shared(element::f32, Shape{1}); + auto arg0 = make_shared(element::f32, Shape{1}); ASSERT_NE(nullptr, arg0); - EXPECT_TRUE(op::is_parameter(arg0)); + EXPECT_TRUE(op::util::is_parameter(arg0)); } TEST(op, is_parameter) { - auto arg0 = make_shared(element::f32, Shape{1}); + auto arg0 = make_shared(element::f32, Shape{1}); ASSERT_NE(nullptr, arg0); auto t0 = make_shared(arg0, arg0); ASSERT_NE(nullptr, t0); - EXPECT_FALSE(op::is_parameter(t0)); + EXPECT_FALSE(op::util::is_parameter(t0)); } TEST(op, opset_multi_thread) { - auto doTest = [&](std::function fun) { - std::atomic opset{nullptr}; + auto doTest = [&](std::function fun) { + std::atomic opset{nullptr}; std::atomic_bool failed{false}; auto threadFun = [&]() { - const ngraph::OpSet* op = &fun(); - const ngraph::OpSet* current = opset; + const ov::OpSet* op = &fun(); + const ov::OpSet* current = opset; do { if (current != nullptr && current != op) { failed = true; @@ -53,11 +52,16 @@ TEST(op, opset_multi_thread) { t2.join(); ASSERT_FALSE(failed); }; - doTest(ngraph::get_opset1); - doTest(ngraph::get_opset2); - doTest(ngraph::get_opset3); - doTest(ngraph::get_opset4); - doTest(ngraph::get_opset5); - doTest(ngraph::get_opset6); - doTest(ngraph::get_opset7); + doTest(ov::get_opset1); + doTest(ov::get_opset2); + doTest(ov::get_opset3); + doTest(ov::get_opset4); + doTest(ov::get_opset5); + doTest(ov::get_opset6); + doTest(ov::get_opset7); + doTest(ov::get_opset8); + doTest(ov::get_opset9); + doTest(ov::get_opset10); + doTest(ov::get_opset11); + doTest(ov::get_opset12); } diff --git a/src/core/tests/opset1.cpp b/src/core/tests/opset1.cpp index e5970fffba6..6a800064109 100644 --- a/src/core/tests/opset1.cpp +++ b/src/core/tests/opset1.cpp @@ -2,20 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ngraph/opsets/opset1.hpp" +#include "openvino/opsets/opset1.hpp" #include #include #include #include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" -#include "ngraph/opsets/opset.hpp" using namespace std; -using namespace ngraph; - -NGRAPH_SUPPRESS_DEPRECATED_START +using namespace ov; namespace { string capitulate(string name) { diff --git a/src/core/tests/partial_shape.cpp b/src/core/tests/partial_shape.cpp index abc484ac4e3..0d23114e219 100644 --- a/src/core/tests/partial_shape.cpp +++ b/src/core/tests/partial_shape.cpp @@ -2,15 +2,21 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "common_test_utils/test_tools.hpp" -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" -#include "ngraph/validation_util.hpp" +#include "openvino/core/partial_shape.hpp" -using namespace ngraph; +#include + +#include "common_test_utils/test_tools.hpp" +#include "ngraph/shape_util.hpp" +#include "ngraph/validation_util.hpp" +#include "openvino/core/coordinate_diff.hpp" +#include "openvino/core/descriptor/tensor.hpp" +#include "openvino/op/parameter.hpp" + +using namespace ov; TEST(partial_shape, interators) { - const PartialShape ps({1, 2, 3}); + const ov::PartialShape ps({1, 2, 3}); ASSERT_TRUE(ps.is_static()); { auto p = ps; @@ -688,28 +694,28 @@ TEST(partial_shape, partial_shape_relaxes_refines_static_static_not_eq) { OPENVINO_SUPPRESS_DEPRECATED_START TEST(partial_shape, partial_shape_project_rank_dynamic) { PartialShape s1{PartialShape::dynamic()}; - PartialShape s2 = project(s1, AxisSet{284, 0, 103}); + PartialShape s2 = ngraph::project(s1, AxisSet{284, 0, 103}); ASSERT_TRUE(s2.rank().is_dynamic()); } TEST(partial_shape, partial_shape_project_rank_static_dynamic) { PartialShape s1{Dimension::dynamic(), 2, Dimension::dynamic(), 3}; - PartialShape s2 = project(s1, AxisSet{0, 3}); + PartialShape s2 = ngraph::project(s1, AxisSet{0, 3}); ASSERT_TRUE(s2.same_scheme(PartialShape{Dimension::dynamic(), 3})); } TEST(partial_shape, partial_shape_reduce_rank_dynamic) { PartialShape s1{PartialShape::dynamic()}; - PartialShape s2 = reduce(s1, AxisSet{284, 0, 103}, false); + PartialShape s2 = ngraph::reduce(s1, AxisSet{284, 0, 103}, false); ASSERT_TRUE(s2.rank().is_dynamic()); } TEST(partial_shape, partial_shape_reduce_rank_static_dynamic) { PartialShape s1{Dimension::dynamic(), 2, Dimension::dynamic(), 3}; - PartialShape s2 = reduce(s1, AxisSet{0, 3}, false); + PartialShape s2 = ngraph::reduce(s1, AxisSet{0, 3}, false); ASSERT_TRUE(s2.same_scheme(PartialShape{2, Dimension::dynamic()})); } @@ -717,14 +723,14 @@ TEST(partial_shape, partial_shape_reduce_rank_static_dynamic) { TEST(partial_shape, partial_shape_inject_pairs_rank_dynamic) { PartialShape s1{PartialShape::dynamic()}; PartialShape s2 = - inject_pairs(s1, std::vector>{{0, Dimension::dynamic()}, {207, 909}}); + ngraph::inject_pairs(s1, std::vector>{{0, Dimension::dynamic()}, {207, 909}}); ASSERT_TRUE(s2.rank().is_dynamic()); } TEST(partial_shape, partial_shape_inject_pairs_rank_static) { PartialShape s1{1, Dimension::dynamic()}; - PartialShape s2 = inject_pairs( + PartialShape s2 = ngraph::inject_pairs( s1, std::vector>{{0, Dimension::dynamic()}, {2, 909}, {4, Dimension::dynamic()}}); @@ -800,7 +806,7 @@ TEST(partial_shape, copy_with_back_inserter_iterator) { } TEST(partial_shape, infer_windowed_reduction_rank_dynamic_rank_dynamic_ok) { - auto node = std::make_shared(element::f32, Shape{}); + auto node = std::make_shared(element::f32, Shape{}); PartialShape data_shape{PartialShape::dynamic()}; Strides data_dilation{1, 1, 1, 1}; CoordinateDiff data_padding_below{0, 0, 0, 0}; @@ -810,15 +816,15 @@ TEST(partial_shape, infer_windowed_reduction_rank_dynamic_rank_dynamic_ok) { Strides window_dilation{1, 1, 1, 1}; bool is_window_all_in_padding_allowed = true; OPENVINO_SUPPRESS_DEPRECATED_START - PartialShape result_shape = infer_windowed_reduction_output_shape(node.get(), - data_shape, - data_dilation, - data_padding_below, - data_padding_above, - window_shape, - window_strides, - window_dilation, - is_window_all_in_padding_allowed); + PartialShape result_shape = ngraph::infer_windowed_reduction_output_shape(node.get(), + data_shape, + data_dilation, + data_padding_below, + data_padding_above, + window_shape, + window_strides, + window_dilation, + is_window_all_in_padding_allowed); OPENVINO_SUPPRESS_DEPRECATED_END ASSERT_TRUE(result_shape.same_scheme( @@ -826,7 +832,7 @@ TEST(partial_shape, infer_windowed_reduction_rank_dynamic_rank_dynamic_ok) { } TEST(partial_shape, infer_windowed_reduction_rank_dynamic_rank_dynamic_zero_data_dilation) { - auto node = std::make_shared(element::f32, Shape{}); + auto node = std::make_shared(element::f32, Shape{}); PartialShape data_shape{PartialShape::dynamic()}; Strides data_dilation{1, 1, 0, 1}; CoordinateDiff data_padding_below{0, 0, 0, 0}; @@ -838,22 +844,22 @@ TEST(partial_shape, infer_windowed_reduction_rank_dynamic_rank_dynamic_zero_data OPENVINO_SUPPRESS_DEPRECATED_START ASSERT_THROW( { - PartialShape result_shape = infer_windowed_reduction_output_shape(node.get(), - data_shape, - data_dilation, - data_padding_below, - data_padding_above, - window_shape, - window_strides, - window_dilation, - is_window_all_in_padding_allowed); + PartialShape result_shape = ngraph::infer_windowed_reduction_output_shape(node.get(), + data_shape, + data_dilation, + data_padding_below, + data_padding_above, + window_shape, + window_strides, + window_dilation, + is_window_all_in_padding_allowed); }, NodeValidationFailure); OPENVINO_SUPPRESS_DEPRECATED_END } TEST(partial_shape, infer_windowed_reduction_rank_dynamic_rank_dynamic_zero_window_dilation) { - auto node = std::make_shared(element::f32, Shape{}); + auto node = std::make_shared(element::f32, Shape{}); PartialShape data_shape{PartialShape::dynamic()}; Strides data_dilation{1, 1, 1, 1}; CoordinateDiff data_padding_below{0, 0, 0, 0}; @@ -865,22 +871,22 @@ TEST(partial_shape, infer_windowed_reduction_rank_dynamic_rank_dynamic_zero_wind OPENVINO_SUPPRESS_DEPRECATED_START ASSERT_THROW( { - PartialShape result_shape = infer_windowed_reduction_output_shape(node.get(), - data_shape, - data_dilation, - data_padding_below, - data_padding_above, - window_shape, - window_strides, - window_dilation, - is_window_all_in_padding_allowed); + PartialShape result_shape = ngraph::infer_windowed_reduction_output_shape(node.get(), + data_shape, + data_dilation, + data_padding_below, + data_padding_above, + window_shape, + window_strides, + window_dilation, + is_window_all_in_padding_allowed); }, NodeValidationFailure); OPENVINO_SUPPRESS_DEPRECATED_END } TEST(partial_shape, infer_windowed_reduction_rank_dynamic_rank_dynamic_zero_window_strides) { - auto node = std::make_shared(element::f32, Shape{}); + auto node = std::make_shared(element::f32, Shape{}); PartialShape data_shape{PartialShape::dynamic()}; Strides data_dilation{1, 1, 1, 1}; CoordinateDiff data_padding_below{0, 0, 0, 0}; @@ -892,22 +898,22 @@ TEST(partial_shape, infer_windowed_reduction_rank_dynamic_rank_dynamic_zero_wind OPENVINO_SUPPRESS_DEPRECATED_START ASSERT_THROW( { - PartialShape result_shape = infer_windowed_reduction_output_shape(node.get(), - data_shape, - data_dilation, - data_padding_below, - data_padding_above, - window_shape, - window_strides, - window_dilation, - is_window_all_in_padding_allowed); + PartialShape result_shape = ngraph::infer_windowed_reduction_output_shape(node.get(), + data_shape, + data_dilation, + data_padding_below, + data_padding_above, + window_shape, + window_strides, + window_dilation, + is_window_all_in_padding_allowed); }, NodeValidationFailure); OPENVINO_SUPPRESS_DEPRECATED_END } TEST(partial_shape, infer_windowed_reduction_rank_static_dynamic_rank_dynamic_ok) { - auto node = std::make_shared(element::f32, Shape{}); + auto node = std::make_shared(element::f32, Shape{}); PartialShape data_shape{Dimension::dynamic(), 2, 3, Dimension::dynamic()}; Strides data_dilation{1, 1, 1, 1}; CoordinateDiff data_padding_below{0, 0, 0, 0}; @@ -918,22 +924,22 @@ TEST(partial_shape, infer_windowed_reduction_rank_static_dynamic_rank_dynamic_ok bool is_window_all_in_padding_allowed = true; OPENVINO_SUPPRESS_DEPRECATED_START - PartialShape result_shape = infer_windowed_reduction_output_shape(node.get(), - data_shape, - data_dilation, - data_padding_below, - data_padding_above, - window_shape, - window_strides, - window_dilation, - is_window_all_in_padding_allowed); + PartialShape result_shape = ngraph::infer_windowed_reduction_output_shape(node.get(), + data_shape, + data_dilation, + data_padding_below, + data_padding_above, + window_shape, + window_strides, + window_dilation, + is_window_all_in_padding_allowed); OPENVINO_SUPPRESS_DEPRECATED_END ASSERT_TRUE(result_shape.same_scheme(PartialShape::dynamic(4))); } TEST(partial_shape, infer_windowed_reduction_rank_static_dynamic_rank_dynamic_zero_data_post_padding) { - auto node = std::make_shared(element::f32, Shape{}); + auto node = std::make_shared(element::f32, Shape{}); PartialShape data_shape{Dimension::dynamic(), 2, 3, Dimension::dynamic()}; Strides data_dilation{1, 1, 1, 1}; CoordinateDiff data_padding_below{0, -1, 0, 0}; @@ -945,22 +951,22 @@ TEST(partial_shape, infer_windowed_reduction_rank_static_dynamic_rank_dynamic_ze OPENVINO_SUPPRESS_DEPRECATED_START ASSERT_THROW( { - PartialShape result_shape = infer_windowed_reduction_output_shape(node.get(), - data_shape, - data_dilation, - data_padding_below, - data_padding_above, - window_shape, - window_strides, - window_dilation, - is_window_all_in_padding_allowed); + PartialShape result_shape = ngraph::infer_windowed_reduction_output_shape(node.get(), + data_shape, + data_dilation, + data_padding_below, + data_padding_above, + window_shape, + window_strides, + window_dilation, + is_window_all_in_padding_allowed); }, NodeValidationFailure); OPENVINO_SUPPRESS_DEPRECATED_END } TEST(partial_shape, infer_windowed_reduction_rank_static_dynamic_rank_dynamic_neg_padding_ok) { - auto node = std::make_shared(element::f32, Shape{}); + auto node = std::make_shared(element::f32, Shape{}); PartialShape data_shape{Dimension::dynamic(), 4, 3, Dimension::dynamic()}; Strides data_dilation{1, 1, 1, 1}; CoordinateDiff data_padding_below{0, -1, 0, 0}; @@ -970,22 +976,22 @@ TEST(partial_shape, infer_windowed_reduction_rank_static_dynamic_rank_dynamic_ne Strides window_dilation{1, 1, 1, 1}; bool is_window_all_in_padding_allowed = true; OPENVINO_SUPPRESS_DEPRECATED_START - PartialShape result_shape = infer_windowed_reduction_output_shape(node.get(), - data_shape, - data_dilation, - data_padding_below, - data_padding_above, - window_shape, - window_strides, - window_dilation, - is_window_all_in_padding_allowed); + PartialShape result_shape = ngraph::infer_windowed_reduction_output_shape(node.get(), + data_shape, + data_dilation, + data_padding_below, + data_padding_above, + window_shape, + window_strides, + window_dilation, + is_window_all_in_padding_allowed); OPENVINO_SUPPRESS_DEPRECATED_END ASSERT_TRUE(result_shape.same_scheme(PartialShape::dynamic(4))); } TEST(partial_shape, infer_windowed_reduction_rank_dynamic_rank_static_dynamic_ok) { - auto node = std::make_shared(element::f32, Shape{}); + auto node = std::make_shared(element::f32, Shape{}); PartialShape data_shape{PartialShape::dynamic()}; Strides data_dilation{1, 1, 1, 1}; CoordinateDiff data_padding_below{0, 0, 0, 0}; @@ -996,22 +1002,22 @@ TEST(partial_shape, infer_windowed_reduction_rank_dynamic_rank_static_dynamic_ok bool is_window_all_in_padding_allowed = true; OPENVINO_SUPPRESS_DEPRECATED_START - PartialShape result_shape = infer_windowed_reduction_output_shape(node.get(), - data_shape, - data_dilation, - data_padding_below, - data_padding_above, - window_shape, - window_strides, - window_dilation, - is_window_all_in_padding_allowed); + PartialShape result_shape = ngraph::infer_windowed_reduction_output_shape(node.get(), + data_shape, + data_dilation, + data_padding_below, + data_padding_above, + window_shape, + window_strides, + window_dilation, + is_window_all_in_padding_allowed); OPENVINO_SUPPRESS_DEPRECATED_END ASSERT_TRUE(result_shape.same_scheme(PartialShape::dynamic(4))); } TEST(partial_shape, infer_windowed_reduction_rank_dynamic_rank_static_dynamic_window_dim_zero) { - auto node = std::make_shared(element::f32, Shape{}); + auto node = std::make_shared(element::f32, Shape{}); PartialShape data_shape{PartialShape::dynamic()}; Strides data_dilation{1, 1, 1, 1}; CoordinateDiff data_padding_below{0, 0, 0, 0}; @@ -1024,22 +1030,22 @@ TEST(partial_shape, infer_windowed_reduction_rank_dynamic_rank_static_dynamic_wi OPENVINO_SUPPRESS_DEPRECATED_START ASSERT_THROW( { - PartialShape result_shape = infer_windowed_reduction_output_shape(node.get(), - data_shape, - data_dilation, - data_padding_below, - data_padding_above, - window_shape, - window_strides, - window_dilation, - is_window_all_in_padding_allowed); + PartialShape result_shape = ngraph::infer_windowed_reduction_output_shape(node.get(), + data_shape, + data_dilation, + data_padding_below, + data_padding_above, + window_shape, + window_strides, + window_dilation, + is_window_all_in_padding_allowed); }, NodeValidationFailure); OPENVINO_SUPPRESS_DEPRECATED_END } TEST(partial_shape, infer_windowed_reduction_rank_dynamic_rank_static_dynamic_window_dilated_dim_zero) { - auto node = std::make_shared(element::f32, Shape{}); + auto node = std::make_shared(element::f32, Shape{}); PartialShape data_shape{PartialShape::dynamic()}; Strides data_dilation{1, 1, 1, 1}; CoordinateDiff data_padding_below{0, 0, 0, 0}; @@ -1052,22 +1058,22 @@ TEST(partial_shape, infer_windowed_reduction_rank_dynamic_rank_static_dynamic_wi OPENVINO_SUPPRESS_DEPRECATED_START ASSERT_THROW( { - PartialShape result_shape = infer_windowed_reduction_output_shape(node.get(), - data_shape, - data_dilation, - data_padding_below, - data_padding_above, - window_shape, - window_strides, - window_dilation, - is_window_all_in_padding_allowed); + PartialShape result_shape = ngraph::infer_windowed_reduction_output_shape(node.get(), + data_shape, + data_dilation, + data_padding_below, + data_padding_above, + window_shape, + window_strides, + window_dilation, + is_window_all_in_padding_allowed); }, NodeValidationFailure); OPENVINO_SUPPRESS_DEPRECATED_END } TEST(partial_shape, infer_windowed_reduction_rank_dynamic_rank_static_dynamic_window_all_in_padding_ok) { - auto node = std::make_shared(element::f32, Shape{}); + auto node = std::make_shared(element::f32, Shape{}); PartialShape data_shape{PartialShape::dynamic()}; Strides data_dilation{1, 1, 1, 1}; CoordinateDiff data_padding_below{0, 0, 3, 0}; @@ -1078,22 +1084,22 @@ TEST(partial_shape, infer_windowed_reduction_rank_dynamic_rank_static_dynamic_wi bool is_window_all_in_padding_allowed = true; OPENVINO_SUPPRESS_DEPRECATED_START - PartialShape result_shape = infer_windowed_reduction_output_shape(node.get(), - data_shape, - data_dilation, - data_padding_below, - data_padding_above, - window_shape, - window_strides, - window_dilation, - is_window_all_in_padding_allowed); + PartialShape result_shape = ngraph::infer_windowed_reduction_output_shape(node.get(), + data_shape, + data_dilation, + data_padding_below, + data_padding_above, + window_shape, + window_strides, + window_dilation, + is_window_all_in_padding_allowed); OPENVINO_SUPPRESS_DEPRECATED_END ASSERT_TRUE(result_shape.same_scheme(PartialShape::dynamic(4))); } TEST(partial_shape, infer_windowed_reduction_rank_dynamic_rank_static_dynamic_window_all_in_padding_not_ok) { - auto node = std::make_shared(element::f32, Shape{}); + auto node = std::make_shared(element::f32, Shape{}); PartialShape data_shape{PartialShape::dynamic()}; Strides data_dilation{1, 1, 1, 1}; CoordinateDiff data_padding_below{0, 0, 3, 0}; @@ -1106,22 +1112,22 @@ TEST(partial_shape, infer_windowed_reduction_rank_dynamic_rank_static_dynamic_wi OPENVINO_SUPPRESS_DEPRECATED_START ASSERT_THROW( { - PartialShape result_shape = infer_windowed_reduction_output_shape(node.get(), - data_shape, - data_dilation, - data_padding_below, - data_padding_above, - window_shape, - window_strides, - window_dilation, - is_window_all_in_padding_allowed); + PartialShape result_shape = ngraph::infer_windowed_reduction_output_shape(node.get(), + data_shape, + data_dilation, + data_padding_below, + data_padding_above, + window_shape, + window_strides, + window_dilation, + is_window_all_in_padding_allowed); }, NodeValidationFailure); OPENVINO_SUPPRESS_DEPRECATED_END } TEST(partial_shape, infer_windowed_reduction_rank_dynamic_rank_static_dynamic_dilated_window_not_all_in_padding) { - auto node = std::make_shared(element::f32, Shape{}); + auto node = std::make_shared(element::f32, Shape{}); PartialShape data_shape{PartialShape::dynamic()}; Strides data_dilation{1, 1, 1, 1}; CoordinateDiff data_padding_below{0, 0, 3, 0}; @@ -1132,22 +1138,22 @@ TEST(partial_shape, infer_windowed_reduction_rank_dynamic_rank_static_dynamic_di bool is_window_all_in_padding_allowed = false; OPENVINO_SUPPRESS_DEPRECATED_START - PartialShape result_shape = infer_windowed_reduction_output_shape(node.get(), - data_shape, - data_dilation, - data_padding_below, - data_padding_above, - window_shape, - window_strides, - window_dilation, - is_window_all_in_padding_allowed); + PartialShape result_shape = ngraph::infer_windowed_reduction_output_shape(node.get(), + data_shape, + data_dilation, + data_padding_below, + data_padding_above, + window_shape, + window_strides, + window_dilation, + is_window_all_in_padding_allowed); OPENVINO_SUPPRESS_DEPRECATED_END ASSERT_TRUE(result_shape.same_scheme(PartialShape::dynamic(4))); } TEST(partial_shape, infer_windowed_reduction_rank_static_dynamic_rank_static_dynamic_ok) { - auto node = std::make_shared(element::f32, Shape{}); + auto node = std::make_shared(element::f32, Shape{}); PartialShape data_shape{Dimension::dynamic(), Dimension::dynamic(), 6, 4}; Strides data_dilation{1, 1, 1, 1}; CoordinateDiff data_padding_below{0, 0, 0, 0}; @@ -1158,15 +1164,15 @@ TEST(partial_shape, infer_windowed_reduction_rank_static_dynamic_rank_static_dyn bool is_window_all_in_padding_allowed = true; OPENVINO_SUPPRESS_DEPRECATED_START - PartialShape result_shape = infer_windowed_reduction_output_shape(node.get(), - data_shape, - data_dilation, - data_padding_below, - data_padding_above, - window_shape, - window_strides, - window_dilation, - is_window_all_in_padding_allowed); + PartialShape result_shape = ngraph::infer_windowed_reduction_output_shape(node.get(), + data_shape, + data_dilation, + data_padding_below, + data_padding_above, + window_shape, + window_strides, + window_dilation, + is_window_all_in_padding_allowed); OPENVINO_SUPPRESS_DEPRECATED_END ASSERT_TRUE( @@ -1174,7 +1180,7 @@ TEST(partial_shape, infer_windowed_reduction_rank_static_dynamic_rank_static_dyn } TEST(partial_shape, infer_windowed_reduction_rank_static_dynamic_rank_static_dynamic_with_padding_ok) { - auto node = std::make_shared(element::f32, Shape{}); + auto node = std::make_shared(element::f32, Shape{}); PartialShape data_shape{Dimension::dynamic(), Dimension::dynamic(), 6, 4}; Strides data_dilation{1, 1, 1, 1}; CoordinateDiff data_padding_below{0, 0, 2, 0}; @@ -1185,15 +1191,15 @@ TEST(partial_shape, infer_windowed_reduction_rank_static_dynamic_rank_static_dyn bool is_window_all_in_padding_allowed = true; OPENVINO_SUPPRESS_DEPRECATED_START - PartialShape result_shape = infer_windowed_reduction_output_shape(node.get(), - data_shape, - data_dilation, - data_padding_below, - data_padding_above, - window_shape, - window_strides, - window_dilation, - is_window_all_in_padding_allowed); + PartialShape result_shape = ngraph::infer_windowed_reduction_output_shape(node.get(), + data_shape, + data_dilation, + data_padding_below, + data_padding_above, + window_shape, + window_strides, + window_dilation, + is_window_all_in_padding_allowed); OPENVINO_SUPPRESS_DEPRECATED_END ASSERT_TRUE( @@ -1201,7 +1207,7 @@ TEST(partial_shape, infer_windowed_reduction_rank_static_dynamic_rank_static_dyn } TEST(partial_shape, infer_windowed_reduction_rank_static_dynamic_rank_static_dynamic_with_padding_and_stride_ok) { - auto node = std::make_shared(element::f32, Shape{}); + auto node = std::make_shared(element::f32, Shape{}); PartialShape data_shape{Dimension::dynamic(), Dimension::dynamic(), 6, 4}; Strides data_dilation{1, 1, 1, 1}; CoordinateDiff data_padding_below{0, 0, 2, 0}; @@ -1212,15 +1218,15 @@ TEST(partial_shape, infer_windowed_reduction_rank_static_dynamic_rank_static_dyn bool is_window_all_in_padding_allowed = true; OPENVINO_SUPPRESS_DEPRECATED_START - PartialShape result_shape = infer_windowed_reduction_output_shape(node.get(), - data_shape, - data_dilation, - data_padding_below, - data_padding_above, - window_shape, - window_strides, - window_dilation, - is_window_all_in_padding_allowed); + PartialShape result_shape = ngraph::infer_windowed_reduction_output_shape(node.get(), + data_shape, + data_dilation, + data_padding_below, + data_padding_above, + window_shape, + window_strides, + window_dilation, + is_window_all_in_padding_allowed); OPENVINO_SUPPRESS_DEPRECATED_END ASSERT_TRUE( @@ -1228,7 +1234,7 @@ TEST(partial_shape, infer_windowed_reduction_rank_static_dynamic_rank_static_dyn } TEST(partial_shape, infer_windowed_reduction_rank_static_dynamic_rank_static_dynamic_window_too_big) { - auto node = std::make_shared(element::f32, Shape{}); + auto node = std::make_shared(element::f32, Shape{}); PartialShape data_shape{Dimension::dynamic(), Dimension::dynamic(), 6, 4}; Strides data_dilation{1, 1, 1, 1}; CoordinateDiff data_padding_below{0, 0, 0, 0}; @@ -1241,22 +1247,22 @@ TEST(partial_shape, infer_windowed_reduction_rank_static_dynamic_rank_static_dyn OPENVINO_SUPPRESS_DEPRECATED_START ASSERT_THROW( { - PartialShape result_shape = infer_windowed_reduction_output_shape(node.get(), - data_shape, - data_dilation, - data_padding_below, - data_padding_above, - window_shape, - window_strides, - window_dilation, - is_window_all_in_padding_allowed); + PartialShape result_shape = ngraph::infer_windowed_reduction_output_shape(node.get(), + data_shape, + data_dilation, + data_padding_below, + data_padding_above, + window_shape, + window_strides, + window_dilation, + is_window_all_in_padding_allowed); }, NodeValidationFailure); OPENVINO_SUPPRESS_DEPRECATED_END } TEST(partial_shape, infer_windowed_reduction_rank_static_dynamic_rank_static_dynamic_window_not_too_big_padding) { - auto node = std::make_shared(element::f32, Shape{}); + auto node = std::make_shared(element::f32, Shape{}); PartialShape data_shape{Dimension::dynamic(), Dimension::dynamic(), 6, 4}; Strides data_dilation{1, 1, 1, 1}; CoordinateDiff data_padding_below{0, 0, 5, 0}; @@ -1267,15 +1273,15 @@ TEST(partial_shape, infer_windowed_reduction_rank_static_dynamic_rank_static_dyn bool is_window_all_in_padding_allowed = true; OPENVINO_SUPPRESS_DEPRECATED_START - PartialShape result_shape = infer_windowed_reduction_output_shape(node.get(), - data_shape, - data_dilation, - data_padding_below, - data_padding_above, - window_shape, - window_strides, - window_dilation, - is_window_all_in_padding_allowed); + PartialShape result_shape = ngraph::infer_windowed_reduction_output_shape(node.get(), + data_shape, + data_dilation, + data_padding_below, + data_padding_above, + window_shape, + window_strides, + window_dilation, + is_window_all_in_padding_allowed); OPENVINO_SUPPRESS_DEPRECATED_END ASSERT_TRUE( @@ -1283,7 +1289,7 @@ TEST(partial_shape, infer_windowed_reduction_rank_static_dynamic_rank_static_dyn } TEST(partial_shape, infer_windowed_reduction_rank_static_dynamic_rank_static_dynamic_window_dilated_too_big) { - auto node = std::make_shared(element::f32, Shape{}); + auto node = std::make_shared(element::f32, Shape{}); PartialShape data_shape{Dimension::dynamic(), Dimension::dynamic(), 6, 4}; Strides data_dilation{1, 1, 1, 1}; CoordinateDiff data_padding_below{0, 0, 5, 0}; @@ -1296,15 +1302,15 @@ TEST(partial_shape, infer_windowed_reduction_rank_static_dynamic_rank_static_dyn OPENVINO_SUPPRESS_DEPRECATED_START ASSERT_THROW( { - PartialShape result_shape = infer_windowed_reduction_output_shape(node.get(), - data_shape, - data_dilation, - data_padding_below, - data_padding_above, - window_shape, - window_strides, - window_dilation, - is_window_all_in_padding_allowed); + PartialShape result_shape = ngraph::infer_windowed_reduction_output_shape(node.get(), + data_shape, + data_dilation, + data_padding_below, + data_padding_above, + window_shape, + window_strides, + window_dilation, + is_window_all_in_padding_allowed); }, NodeValidationFailure); OPENVINO_SUPPRESS_DEPRECATED_END diff --git a/src/core/tests/constant_folding.cpp b/src/core/tests/pass/constant_folding.cpp similarity index 66% rename from src/core/tests/constant_folding.cpp rename to src/core/tests/pass/constant_folding.cpp index afb78f029e9..372d8eb387e 100644 --- a/src/core/tests/constant_folding.cpp +++ b/src/core/tests/pass/constant_folding.cpp @@ -2,31 +2,29 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "ngraph/pass/constant_folding.hpp" +#include "openvino/pass/constant_folding.hpp" -#include +#include #include "common_test_utils/all_close_f.hpp" #include "common_test_utils/ngraph_test_utils.hpp" #include "common_test_utils/test_tools.hpp" -#include "gmock/gmock.h" -#include "ngraph/ngraph.hpp" -#include "ngraph/opsets/opset1.hpp" -#include "ngraph/opsets/opset5.hpp" -#include "ngraph/pass/manager.hpp" -#include "openvino/opsets/opset11.hpp" +#include "openvino/op/acosh.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/loop.hpp" #include "transformations/common_optimizations/disable_shapeof_constant_folding.hpp" +#include "transformations/utils/utils.hpp" -using namespace ngraph; +using namespace ov; using namespace std; -static std::shared_ptr get_result_constant(std::shared_ptr f, size_t pos = 0) { - return ov::as_type_ptr(f->get_results().at(pos)->input_value(0).get_node_shared_ptr()); +static std::shared_ptr get_result_constant(std::shared_ptr m, size_t pos = 0) { + return ov::as_type_ptr(m->get_results().at(pos)->input_value(0).get_node_shared_ptr()); } template -static std::vector get_result_constant_data(std::shared_ptr f, size_t pos) { - auto new_const = get_result_constant(f, pos); +static std::vector get_result_constant_data(std::shared_ptr m, size_t pos) { + auto new_const = get_result_constant(m, pos); return new_const->cast_vector(); } @@ -112,19 +110,19 @@ TEST(constant_folding, acosh) { for (float f : values_in) { expected.push_back(std::acosh(f)); } - auto constant = make_shared(element::f32, shape_in, values_in); + auto constant = make_shared(element::f32, shape_in, values_in); constant->set_friendly_name("constant"); - auto acosh = make_shared(constant); + auto acosh = make_shared(constant); acosh->set_friendly_name("test"); - auto f = make_shared(acosh, ParameterVector{}); + auto m = make_shared(acosh, ParameterVector{}); - run_constant_folding(f); + run_constant_folding(m); - EXPECT_EQ(count_ops_of_type(f), 0); - EXPECT_EQ(count_ops_of_type(f), 1); - ASSERT_EQ(f->get_results().size(), 1); + EXPECT_EQ(count_ops_of_type(m), 0); + EXPECT_EQ(count_ops_of_type(m), 1); + ASSERT_EQ(m->get_results().size(), 1); - auto new_const = get_result_constant(f); + auto new_const = get_result_constant(m); EXPECT_TRUE(new_const); check_names(new_const, {"constant", "test"}); @@ -141,19 +139,19 @@ TEST(constant_folding, asinh) { for (float f : values_in) { expected.push_back(std::asinh(f)); } - auto constant = make_shared(element::f32, shape_in, values_in); + auto constant = make_shared(element::f32, shape_in, values_in); constant->set_friendly_name("constant"); - auto asinh = make_shared(constant); + auto asinh = make_shared(constant); asinh->set_friendly_name("test"); - auto f = make_shared(asinh, ParameterVector{}); + auto m = make_shared(asinh, ParameterVector{}); - run_constant_folding(f); + run_constant_folding(m); - EXPECT_EQ(count_ops_of_type(f), 0); - EXPECT_EQ(count_ops_of_type(f), 1); - ASSERT_EQ(f->get_results().size(), 1); + EXPECT_EQ(count_ops_of_type(m), 0); + EXPECT_EQ(count_ops_of_type(m), 1); + ASSERT_EQ(m->get_results().size(), 1); - auto new_const = get_result_constant(f); + auto new_const = get_result_constant(m); EXPECT_TRUE(new_const); check_names(new_const, {"constant", "test"}); @@ -169,19 +167,19 @@ TEST(constant_folding, atanh) { for (float f : values_in) { expected.push_back(std::atanh(f)); } - auto constant = make_shared(element::f32, shape_in, values_in); + auto constant = make_shared(element::f32, shape_in, values_in); constant->set_friendly_name("constant"); - auto atanh = make_shared(constant); + auto atanh = make_shared(constant); atanh->set_friendly_name("test"); - auto f = make_shared(atanh, ParameterVector{}); + auto m = make_shared(atanh, ParameterVector{}); - run_constant_folding(f); + run_constant_folding(m); - EXPECT_EQ(count_ops_of_type(f), 0); - EXPECT_EQ(count_ops_of_type(f), 1); - ASSERT_EQ(f->get_results().size(), 1); + EXPECT_EQ(count_ops_of_type(m), 0); + EXPECT_EQ(count_ops_of_type(m), 1); + ASSERT_EQ(m->get_results().size(), 1); - auto new_const = get_result_constant(f); + auto new_const = get_result_constant(m); EXPECT_TRUE(new_const); check_names(new_const, {"constant", "test"}); @@ -195,21 +193,21 @@ TEST(constant_folding, constant_squeeze) { Shape axes_shape{1}; vector values_in{0, 1, 2, 3, 4, 5, 6, 7}; - auto constant = make_shared(element::f32, shape_in, values_in); + auto constant = make_shared(element::f32, shape_in, values_in); constant->set_friendly_name("constant"); vector values_axes{2}; - auto constant_axes = op::Constant::create(element::i64, axes_shape, values_axes); + auto constant_axes = op::v0::Constant::create(element::i64, axes_shape, values_axes); constant_axes->set_friendly_name("constant_axes"); - auto squeeze = make_shared(constant, constant_axes); + auto squeeze = make_shared(constant, constant_axes); squeeze->set_friendly_name("test"); - auto f = make_shared(squeeze, ParameterVector{}); + auto m = make_shared(squeeze, ParameterVector{}); - run_constant_folding(f); + run_constant_folding(m); - ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(m), 0); + ASSERT_EQ(count_ops_of_type(m), 1); - auto new_const = get_result_constant(f); + auto new_const = get_result_constant(m); EXPECT_TRUE(new_const); check_names(new_const, {"constant", "constant_axes", "test"}); ASSERT_EQ(new_const->get_shape(), shape_out); @@ -224,19 +222,19 @@ TEST(constant_folding, constant_unsqueeze) { Shape axes_shape{2}; vector values_in{0, 1, 2, 3, 4, 5, 6, 7}; - auto constant = make_shared(element::f32, shape_in, values_in); + auto constant = make_shared(element::f32, shape_in, values_in); constant->set_friendly_name("constant"); vector values_axes{2, 3}; - auto constant_axes = op::Constant::create(element::i64, axes_shape, values_axes); + auto constant_axes = ov::op::v0::Constant::create(element::i64, axes_shape, values_axes); constant_axes->set_friendly_name("constant_axes"); auto unsqueeze = make_shared(constant, constant_axes); unsqueeze->set_friendly_name("test"); - auto f = make_shared(unsqueeze, ParameterVector{}); + auto f = make_shared(unsqueeze, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -249,22 +247,22 @@ TEST(constant_folding, constant_unsqueeze) { TEST(constant_folding, constant_broadcast_v1) { vector values_in{0, 1}; - auto constant_in = make_shared(element::i32, Shape{2}, values_in); + auto constant_in = make_shared(element::i32, Shape{2}, values_in); constant_in->set_friendly_name("constant_in"); vector shape_in{2, 4}; - auto constant_shape = make_shared(element::i64, Shape{2}, shape_in); + auto constant_shape = make_shared(element::i64, Shape{2}, shape_in); constant_shape->set_friendly_name("constant_shape"); vector axes_in{0}; - auto constant_axes = make_shared(element::i64, Shape{1}, axes_in); + auto constant_axes = make_shared(element::i64, Shape{1}, axes_in); constant_axes->set_friendly_name("constant_axes"); auto broadcast_v1 = make_shared(constant_in, constant_shape, constant_axes); broadcast_v1->set_friendly_name("test"); - auto f = make_shared(broadcast_v1, ParameterVector{}); + auto f = make_shared(broadcast_v1, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -277,19 +275,19 @@ TEST(constant_folding, constant_broadcast_v1) { TEST(constant_folding, constant_broadcast_v1_with_target_shape) { vector values_in{1}; - auto constant_in = make_shared(element::i32, Shape{1, 1, 1, 1}, values_in); + auto constant_in = make_shared(element::i32, Shape{1, 1, 1, 1}, values_in); constant_in->set_friendly_name("constant_in"); vector shape_in{1, 3, 1, 1}; - auto target_shape = make_shared(element::i64, Shape{4}, shape_in); + auto target_shape = make_shared(element::i64, Shape{4}, shape_in); target_shape->set_friendly_name("target_shape"); auto broadcast_v1 = make_shared(constant_in, target_shape); broadcast_v1->set_friendly_name("test"); - auto f = make_shared(broadcast_v1, ParameterVector{}); + auto f = make_shared(broadcast_v1, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -302,19 +300,19 @@ TEST(constant_folding, constant_broadcast_v1_with_target_shape) { TEST(constant_folding, constant_broadcast_v1_numpy) { vector values_in{0, 1}; - auto constant_in = make_shared(element::i32, Shape{2}, values_in); + auto constant_in = make_shared(element::i32, Shape{2}, values_in); constant_in->set_friendly_name("constant_in"); vector shape_in{4, 2}; - auto constant_shape = make_shared(element::i64, Shape{2}, shape_in); + auto constant_shape = make_shared(element::i64, Shape{2}, shape_in); constant_shape->set_friendly_name("constant_shape"); auto broadcast_v1 = make_shared(constant_in, constant_shape); broadcast_v1->set_friendly_name("test"); - auto f = make_shared(broadcast_v1, ParameterVector{}); + auto f = make_shared(broadcast_v1, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -337,39 +335,40 @@ TEST(constant_folding, constant_unary_binary) { vector values_i{0, 1}; vector values_j{-3, 5}; vector values_k{3, 5}; - auto a = make_shared(element::i32, Shape{2, 2}, values_a); + auto a = make_shared(element::i32, Shape{2, 2}, values_a); a->set_friendly_name("a"); - auto b = make_shared(element::i32, Shape{2, 2}, values_b); + auto b = make_shared(element::i32, Shape{2, 2}, values_b); b->set_friendly_name("b"); - auto c = make_shared(element::i32, Shape{2, 2}, values_c); + auto c = make_shared(element::i32, Shape{2, 2}, values_c); c->set_friendly_name("c"); - auto d = make_shared(element::i32, Shape{2, 2}, values_d); + auto d = make_shared(element::i32, Shape{2, 2}, values_d); d->set_friendly_name("d"); - auto e = make_shared(element::i32, Shape{2}, values_e); + auto e = make_shared(element::i32, Shape{2}, values_e); e->set_friendly_name("e"); - auto f = make_shared(element::i32, Shape{2}, values_f); + auto f = make_shared(element::i32, Shape{2}, values_f); f->set_friendly_name("f"); - auto g = make_shared(element::i32, Shape{2}, values_g); + auto g = make_shared(element::i32, Shape{2}, values_g); g->set_friendly_name("g"); - auto h = make_shared(element::boolean, Shape{2, 2}, values_h); + auto h = make_shared(element::boolean, Shape{2, 2}, values_h); h->set_friendly_name("h"); - auto i = make_shared(element::boolean, Shape{2}, values_i); + auto i = make_shared(element::boolean, Shape{2}, values_i); i->set_friendly_name("i"); - auto j = make_shared(element::i8, Shape{2}, values_j); + auto j = make_shared(element::i8, Shape{2}, values_j); j->set_friendly_name("j"); - auto k = make_shared(element::u8, Shape{2}, values_k); + auto k = make_shared(element::u8, Shape{2}, values_k); k->set_friendly_name("k"); - auto doubles = make_shared(element::f64, Shape{2}, std::vector{4.0, 9.0}); + auto doubles = make_shared(element::f64, Shape{2}, std::vector{4.0, 9.0}); doubles->set_friendly_name("doubles"); - auto doubles2 = make_shared(element::f64, Shape{2}, std::vector{4.0, 1.0}); + auto doubles2 = make_shared(element::f64, Shape{2}, std::vector{4.0, 1.0}); doubles2->set_friendly_name("doubles2"); - auto shorts = make_shared(element::i16, Shape{3}, std::vector{14, -3, -3}); + auto shorts = make_shared(element::i16, Shape{3}, std::vector{14, -3, -3}); shorts->set_friendly_name("shorts"); - auto shorts2 = make_shared(element::i16, Shape{1}, std::vector{-3}); + auto shorts2 = make_shared(element::i16, Shape{1}, std::vector{-3}); shorts2->set_friendly_name("shorts2"); - auto unsigned_shorts = make_shared(element::u16, Shape{3}, std::vector{14, 300, 14}); + auto unsigned_shorts = + make_shared(element::u16, Shape{3}, std::vector{14, 300, 14}); unsigned_shorts->set_friendly_name("unsigned_shorts"); - auto unsigned_shorts2 = make_shared(element::u16, Shape{1}, std::vector{300}); + auto unsigned_shorts2 = make_shared(element::u16, Shape{1}, std::vector{300}); unsigned_shorts2->set_friendly_name("unsigned_shorts2"); auto add = make_shared(a, b); @@ -386,11 +385,11 @@ TEST(constant_folding, constant_unary_binary) { min->set_friendly_name("min"); auto max = make_shared(a, c); max->set_friendly_name("max"); - auto absn = make_shared(c); + auto absn = make_shared(c); absn->set_friendly_name("absn"); - auto neg = make_shared(c); + auto neg = make_shared(c); neg->set_friendly_name("neg"); - auto sqrt = make_shared(d); + auto sqrt = make_shared(d); sqrt->set_friendly_name("sqrt"); auto add_autob_numpy = make_shared(a, e, op::AutoBroadcastType::NUMPY); add_autob_numpy->set_friendly_name("add_autob_numpy"); @@ -420,9 +419,9 @@ TEST(constant_folding, constant_unary_binary) { less_eq_autob_numpy->set_friendly_name("less_eq_autob_numpy"); auto logical_or_autob_numpy = make_shared(h, i, op::AutoBroadcastType::NUMPY); logical_or_autob_numpy->set_friendly_name("logical_or_autob_numpy"); - auto logical_xor_autob_numpy = make_shared(h, i, op::AutoBroadcastType::NUMPY); + auto logical_xor_autob_numpy = make_shared(h, i, op::AutoBroadcastType::NUMPY); logical_xor_autob_numpy->set_friendly_name("logical_xor_autob_numpy"); - auto doubles_sqrt = make_shared(doubles); + auto doubles_sqrt = make_shared(doubles); doubles_sqrt->set_friendly_name("doubles_sqrt"); auto sub_int8 = make_shared(j, j); sub_int8->set_friendly_name("sub_int8"); @@ -435,42 +434,42 @@ TEST(constant_folding, constant_unary_binary) { auto equal_unsigned_shorts = make_shared(unsigned_shorts, unsigned_shorts2, op::AutoBroadcastType::NUMPY); equal_unsigned_shorts->set_friendly_name("equal_unsigned_shorts"); - auto neg_sqrt = make_shared(c); + auto neg_sqrt = make_shared(c); neg_sqrt->set_friendly_name("neg_sqrt"); - auto func = make_shared(NodeVector{add, - sub, - mul, - divn, - pow, - min, - max, - absn, - neg, - sqrt, - add_autob_numpy, - sub_autob_numpy, - mul_autob_numpy, - div_autob_numpy, - pow_autob_numpy, - min_autob_numpy, - max_autob_numpy, - equal_autob_numpy, - not_equal_autob_numpy, - greater_autob_numpy, - greater_eq_autob_numpy, - less_autob_numpy, - less_eq_autob_numpy, - logical_or_autob_numpy, - logical_xor_autob_numpy, - doubles_sqrt, - sub_int8, - sub_uint8, - equal_doubles, - equal_shorts, - equal_unsigned_shorts}, - ParameterVector{}); - auto func_error = make_shared(NodeVector{neg_sqrt}, ParameterVector{}); + auto func = make_shared(NodeVector{add, + sub, + mul, + divn, + pow, + min, + max, + absn, + neg, + sqrt, + add_autob_numpy, + sub_autob_numpy, + mul_autob_numpy, + div_autob_numpy, + pow_autob_numpy, + min_autob_numpy, + max_autob_numpy, + equal_autob_numpy, + not_equal_autob_numpy, + greater_autob_numpy, + greater_eq_autob_numpy, + less_autob_numpy, + less_eq_autob_numpy, + logical_or_autob_numpy, + logical_xor_autob_numpy, + doubles_sqrt, + sub_int8, + sub_uint8, + equal_doubles, + equal_shorts, + equal_unsigned_shorts}, + ParameterVector{}); + auto func_error = make_shared(NodeVector{neg_sqrt}, ParameterVector{}); run_constant_folding(func); @@ -578,16 +577,16 @@ TEST(constant_folding, constant_unary_binary) { template static void test_const_convert(const vector& values_in, const vector& values_expected) { - auto constant = op::Constant::create(from, Shape{values_in.size()}, values_in); + auto constant = ov::op::v0::Constant::create(from, Shape{values_in.size()}, values_in); constant->set_friendly_name("constant"); - auto convert = make_shared(constant, to); + auto convert = make_shared(constant, to); convert->set_friendly_name("test"); - auto f = make_shared(convert, ParameterVector{}); + auto f = make_shared(convert, ParameterVector{}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -659,16 +658,16 @@ TEST(constant_folding, const_convert) { TEST(constant_folding, shape_of_v0) { Shape input_shape{3, 4, 0, 22, 608, 909, 3}; - auto param = make_shared(element::boolean, input_shape); + auto param = make_shared(element::boolean, input_shape); param->set_friendly_name("param"); auto shape_of = make_shared(param); shape_of->set_friendly_name("test"); - auto f = make_shared(shape_of, ParameterVector{param}); + auto f = make_shared(shape_of, ParameterVector{param}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -682,16 +681,16 @@ TEST(constant_folding, shape_of_v0) { TEST(constant_folding, shape_of_v3) { Shape input_shape{3, 4, 0, 22, 608, 909, 3}; - auto param = make_shared(element::boolean, input_shape); + auto param = make_shared(element::boolean, input_shape); param->set_friendly_name("param"); auto shape_of = make_shared(param); shape_of->set_friendly_name("test"); - auto f = make_shared(shape_of, ParameterVector{param}); + auto f = make_shared(shape_of, ParameterVector{param}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -705,16 +704,16 @@ TEST(constant_folding, shape_of_v3) { TEST(constant_folding, shape_of_i32_v3) { Shape input_shape{3, 4, 0, 22, 608, 909, 3}; - auto param = make_shared(element::boolean, input_shape); + auto param = make_shared(element::boolean, input_shape); param->set_friendly_name("param"); auto shape_of = make_shared(param, element::i32); shape_of->set_friendly_name("test"); - auto f = make_shared(shape_of, ParameterVector{param}); + auto f = make_shared(shape_of, ParameterVector{param}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -728,10 +727,10 @@ TEST(constant_folding, shape_of_i32_v3) { TEST(constant_folding, shape_of_dynamic_v0) { PartialShape input_shape{3, 4, Dimension::dynamic(), 22, 608, 909, 3}; - auto param = make_shared(element::boolean, input_shape); + auto param = make_shared(element::boolean, input_shape); auto shape_of = make_shared(param); shape_of->set_friendly_name("test"); - auto f = make_shared(shape_of, ParameterVector{param}); + auto f = make_shared(shape_of, ParameterVector{param}); run_constant_folding(f); @@ -745,10 +744,10 @@ TEST(constant_folding, shape_of_dynamic_v0) { TEST(constant_folding, shape_of_dynamic_v3) { PartialShape input_shape{3, 4, Dimension::dynamic(), 22, 608, 909, 3}; - auto param = make_shared(element::boolean, input_shape); + auto param = make_shared(element::boolean, input_shape); auto shape_of = make_shared(param); shape_of->set_friendly_name("test"); - auto f = make_shared(shape_of, ParameterVector{param}); + auto f = make_shared(shape_of, ParameterVector{param}); run_constant_folding(f); @@ -762,10 +761,10 @@ TEST(constant_folding, shape_of_dynamic_v3) { TEST(constant_folding, shape_of_dynamic_i32_v3) { PartialShape input_shape{3, 4, Dimension::dynamic(), 22, 608, 909, 3}; - auto param = make_shared(element::boolean, input_shape); + auto param = make_shared(element::boolean, input_shape); auto shape_of = make_shared(param, element::i32); shape_of->set_friendly_name("test"); - auto f = make_shared(shape_of, ParameterVector{param}); + auto f = make_shared(shape_of, ParameterVector{param}); run_constant_folding(f); @@ -780,10 +779,10 @@ TEST(constant_folding, shape_of_dynamic_i32_v3) { TEST(constant_folding, shape_of_dynamic_double_folding_v0) { PartialShape input_shape{3, 4, Dimension::dynamic(), 22, 608, 909, 3}; - auto param = make_shared(element::boolean, input_shape); + auto param = make_shared(element::boolean, input_shape); auto shape_of = make_shared(param); shape_of->set_friendly_name("test"); - auto f = make_shared(shape_of, ParameterVector{param}); + auto f = make_shared(shape_of, ParameterVector{param}); run_constant_folding(f); @@ -797,10 +796,10 @@ TEST(constant_folding, shape_of_dynamic_double_folding_v0) { TEST(constant_folding, shape_of_dynamic_double_folding_v3) { PartialShape input_shape{3, 4, Dimension::dynamic(), 22, 608, 909, 3}; - auto param = make_shared(element::boolean, input_shape); + auto param = make_shared(element::boolean, input_shape); auto shape_of = make_shared(param); shape_of->set_friendly_name("test"); - auto f = make_shared(shape_of, ParameterVector{param}); + auto f = make_shared(shape_of, ParameterVector{param}); run_constant_folding(f); @@ -816,15 +815,15 @@ TEST(constant_folding, shape_of_dynamic_double_folding_v3) { TEST(constant_folding, shape_of_rank_dynamic_v0) { PartialShape input_shape{PartialShape::dynamic()}; - auto param = make_shared(element::boolean, input_shape); + auto param = make_shared(element::boolean, input_shape); auto shape_of = make_shared(param); shape_of->set_friendly_name("test"); - auto f = make_shared(shape_of, ParameterVector{param}); + auto f = make_shared(shape_of, ParameterVector{param}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 1); - ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 0); auto result_shape_of = f->get_results().at(0)->get_input_node_shared_ptr(0); ASSERT_EQ(result_shape_of, shape_of); @@ -834,15 +833,15 @@ TEST(constant_folding, shape_of_rank_dynamic_v0) { TEST(constant_folding, shape_of_rank_dynamic_v3) { PartialShape input_shape{PartialShape::dynamic()}; - auto param = make_shared(element::boolean, input_shape); + auto param = make_shared(element::boolean, input_shape); auto shape_of = make_shared(param); shape_of->set_friendly_name("test"); - auto f = make_shared(shape_of, ParameterVector{param}); + auto f = make_shared(shape_of, ParameterVector{param}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 1); - ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 0); auto result_shape_of = f->get_results().at(0)->get_input_node_shared_ptr(0); ASSERT_EQ(result_shape_of, shape_of); @@ -853,18 +852,18 @@ void const_reverse(const element::Type& axes_elem_type) { Shape input_shape{3, 3}; vector values_in{1, 2, 3, 4, 5, 6, 7, 8, 9}; - auto constant = op::Constant::create(element::i32, input_shape, values_in); + auto constant = ov::op::v0::Constant::create(element::i32, input_shape, values_in); constant->set_friendly_name("constant"); - auto axes = op::Constant::create(axes_elem_type, {1}, {1}); + auto axes = ov::op::v0::Constant::create(axes_elem_type, {1}, {1}); axes->set_friendly_name("axes"); auto convert = make_shared(constant, axes, op::v1::Reverse::Mode::INDEX); convert->set_friendly_name("test"); - auto f = make_shared(convert, ParameterVector{}); + auto f = make_shared(convert, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -893,20 +892,20 @@ TEST(constant_folding, const_reduceprod) { Shape output_shape{3}; vector values_in{1, 2, 3, 4, 5, 6, 7, 8, 9}; - auto constant = op::Constant::create(element::i32, input_shape, values_in); + auto constant = ov::op::v0::Constant::create(element::i32, input_shape, values_in); constant->set_friendly_name("constant"); Shape axes_shape{1}; vector values_axes{1}; - auto constant_axes = op::Constant::create(element::i64, axes_shape, values_axes); + auto constant_axes = ov::op::v0::Constant::create(element::i64, axes_shape, values_axes); constant_axes->set_friendly_name("constant_axes"); auto convert = make_shared(constant, constant_axes); convert->set_friendly_name("test"); - auto f = make_shared(convert, ParameterVector{}); + auto f = make_shared(convert, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -925,20 +924,20 @@ TEST(constant_folding, const_reduceprod_keepdims) { Shape output_shape{3, 1}; vector values_in{1, 2, 3, 4, 5, 6, 7, 8, 9}; - auto constant = op::Constant::create(element::i32, input_shape, values_in); + auto constant = ov::op::v0::Constant::create(element::i32, input_shape, values_in); constant->set_friendly_name("constant"); Shape axes_shape{1}; vector values_axes{1}; - auto constant_axes = op::Constant::create(element::i64, axes_shape, values_axes); + auto constant_axes = ov::op::v0::Constant::create(element::i64, axes_shape, values_axes); constant_axes->set_friendly_name("constant_axes"); auto convert = make_shared(constant, constant_axes, true); convert->set_friendly_name("test"); - auto f = make_shared(convert, ParameterVector{}); + auto f = make_shared(convert, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -957,19 +956,19 @@ TEST(constant_folding, const_reducesum) { Shape output_shape{3}; vector values_in{1, 2, 3, 4, 5, 6, 7, 8, 9}; - auto constant = op::Constant::create(element::i32, input_shape, values_in); + auto constant = ov::op::v0::Constant::create(element::i32, input_shape, values_in); constant->set_friendly_name("constant"); Shape axes_shape{1}; vector values_axes{1}; - auto constant_axes = op::Constant::create(element::i64, axes_shape, values_axes); + auto constant_axes = ov::op::v0::Constant::create(element::i64, axes_shape, values_axes); constant_axes->set_friendly_name("constant_axes"); auto convert = make_shared(constant, constant_axes); convert->set_friendly_name("test"); - auto f = make_shared(convert, ParameterVector{}); + auto f = make_shared(convert, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -988,20 +987,20 @@ TEST(constant_folding, const_reducesum_keepdims) { Shape output_shape{3, 1}; vector values_in{1, 2, 3, 4, 5, 6, 7, 8, 9}; - auto constant = op::Constant::create(element::i32, input_shape, values_in); + auto constant = ov::op::v0::Constant::create(element::i32, input_shape, values_in); constant->set_friendly_name("constant"); Shape axes_shape{1}; vector values_axes{1}; - auto constant_axes = op::Constant::create(element::i64, axes_shape, values_axes); + auto constant_axes = ov::op::v0::Constant::create(element::i64, axes_shape, values_axes); constant_axes->set_friendly_name("constant_axes"); auto convert = make_shared(constant, constant_axes, true); convert->set_friendly_name("test"); - auto f = make_shared(convert, ParameterVector{}); + auto f = make_shared(convert, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1020,20 +1019,20 @@ TEST(constant_folding, const_reducemax) { Shape output_shape{3}; vector values_in{1, 2, 3, 4, 5, 6}; - auto constant = op::Constant::create(element::i32, input_shape, values_in); + auto constant = ov::op::v0::Constant::create(element::i32, input_shape, values_in); constant->set_friendly_name("constant"); Shape axes_shape{1}; vector values_axes{1}; - auto constant_axes = op::Constant::create(element::i64, axes_shape, values_axes); + auto constant_axes = ov::op::v0::Constant::create(element::i64, axes_shape, values_axes); constant_axes->set_friendly_name("constant_axes"); auto convert = make_shared(constant, constant_axes); convert->set_friendly_name("test"); - auto f = make_shared(convert, ParameterVector{}); + auto f = make_shared(convert, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1052,20 +1051,20 @@ TEST(constant_folding, const_reducemax_keepdims) { Shape output_shape{3, 1}; vector values_in{1, 2, 3, 4, 5, 6}; - auto constant = op::Constant::create(element::i32, input_shape, values_in); + auto constant = ov::op::v0::Constant::create(element::i32, input_shape, values_in); constant->set_friendly_name("constant"); Shape axes_shape{1}; vector values_axes{1}; - auto constant_axes = op::Constant::create(element::i64, axes_shape, values_axes); + auto constant_axes = ov::op::v0::Constant::create(element::i64, axes_shape, values_axes); constant_axes->set_friendly_name("constant_axes"); auto convert = make_shared(constant, constant_axes, true); convert->set_friendly_name("test"); - auto f = make_shared(convert, ParameterVector{}); + auto f = make_shared(convert, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1084,20 +1083,20 @@ TEST(constant_folding, const_reducemin) { Shape output_shape{3}; vector values_in{1, 2, 3, 4, 5, 6}; - auto constant = op::Constant::create(element::i32, input_shape, values_in); + auto constant = ov::op::v0::Constant::create(element::i32, input_shape, values_in); constant->set_friendly_name("constant"); Shape axes_shape{1}; vector values_axes{1}; - auto constant_axes = op::Constant::create(element::i64, axes_shape, values_axes); + auto constant_axes = ov::op::v0::Constant::create(element::i64, axes_shape, values_axes); constant_axes->set_friendly_name("constant_axes"); auto convert = make_shared(constant, constant_axes); convert->set_friendly_name("test"); - auto f = make_shared(convert, ParameterVector{}); + auto f = make_shared(convert, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1116,20 +1115,20 @@ TEST(constant_folding, const_reducemin_keepdims) { Shape output_shape{3, 1}; vector values_in{1, 2, 3, 4, 5, 6}; - auto constant = op::Constant::create(element::i32, input_shape, values_in); + auto constant = ov::op::v0::Constant::create(element::i32, input_shape, values_in); constant->set_friendly_name("constant"); Shape axes_shape{1}; vector values_axes{1}; - auto constant_axes = op::Constant::create(element::i64, axes_shape, values_axes); + auto constant_axes = ov::op::v0::Constant::create(element::i64, axes_shape, values_axes); constant_axes->set_friendly_name("constant_axes"); auto convert = make_shared(constant, constant_axes, true); convert->set_friendly_name("test"); - auto f = make_shared(convert, ParameterVector{}); + auto f = make_shared(convert, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1148,20 +1147,20 @@ TEST(constant_folding, const_reducemean) { Shape output_shape{3}; vector values_in{1, 2, 3, 4, 5, 6, 7, 8, 9}; - auto constant = op::Constant::create(element::i32, input_shape, values_in); + auto constant = ov::op::v0::Constant::create(element::i32, input_shape, values_in); constant->set_friendly_name("constant"); Shape axes_shape{1}; vector values_axes{1}; - auto constant_axes = op::Constant::create(element::i64, axes_shape, values_axes); + auto constant_axes = ov::op::v0::Constant::create(element::i64, axes_shape, values_axes); constant_axes->set_friendly_name("constant_axes"); auto convert = make_shared(constant, constant_axes); convert->set_friendly_name("test"); - auto f = make_shared(convert, ParameterVector{}); + auto f = make_shared(convert, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1180,20 +1179,20 @@ TEST(constant_folding, const_reducemean_keepdims) { Shape output_shape{3, 1}; vector values_in{1, 2, 3, 4, 5, 6, 7, 8, 9}; - auto constant = op::Constant::create(element::i32, input_shape, values_in); + auto constant = ov::op::v0::Constant::create(element::i32, input_shape, values_in); constant->set_friendly_name("constant"); Shape axes_shape{1}; vector values_axes{1}; - auto constant_axes = op::Constant::create(element::i64, axes_shape, values_axes); + auto constant_axes = ov::op::v0::Constant::create(element::i64, axes_shape, values_axes); constant_axes->set_friendly_name("constant_axes"); auto convert = make_shared(constant, constant_axes, true); convert->set_friendly_name("test"); - auto f = make_shared(convert, ParameterVector{}); + auto f = make_shared(convert, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1211,18 +1210,18 @@ TEST(constant_folding, const_reduce_logical_and__no_keepdims) { const Shape input_shape{3, 3}; const vector values_in{0, 1, 1, 0, 1, 0, 1, 1, 1}; - const auto data = op::Constant::create(element::boolean, input_shape, values_in); + const auto data = ov::op::v0::Constant::create(element::boolean, input_shape, values_in); data->set_friendly_name("data"); - const auto axes = op::Constant::create(element::i64, {1}, {1}); + const auto axes = ov::op::v0::Constant::create(element::i64, {1}, {1}); axes->set_friendly_name("axes"); const auto convert = make_shared(data, axes, false); convert->set_friendly_name("test"); - auto f = make_shared(convert, ParameterVector{}); + auto f = make_shared(convert, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); const auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1242,18 +1241,18 @@ TEST(constant_folding, const_reduce_logical_and__keepdims) { const Shape input_shape{3, 3}; const vector values_in{0, 1, 1, 0, 1, 0, 1, 1, 1}; - const auto data = op::Constant::create(element::boolean, input_shape, values_in); + const auto data = ov::op::v0::Constant::create(element::boolean, input_shape, values_in); data->set_friendly_name("data"); - const auto axes = op::Constant::create(element::i64, {1}, {1}); + const auto axes = ov::op::v0::Constant::create(element::i64, {1}, {1}); axes->set_friendly_name("axes"); const auto convert = make_shared(data, axes, true); convert->set_friendly_name("test"); - auto f = make_shared(convert, ParameterVector{}); + auto f = make_shared(convert, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); const auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1275,18 +1274,18 @@ TEST(constant_folding, const_reduce_logical_and__keepdims_3d) { const Shape input_shape{2, 2, 2}; const vector values_in{1, 1, 0, 0, 1, 0, 0, 1}; - const auto data = op::Constant::create(element::boolean, input_shape, values_in); + const auto data = ov::op::v0::Constant::create(element::boolean, input_shape, values_in); data->set_friendly_name("data"); - const auto axes = op::Constant::create(element::i64, {2}, {0, 2}); + const auto axes = ov::op::v0::Constant::create(element::i64, {2}, {0, 2}); axes->set_friendly_name("axes"); const auto convert = make_shared(data, axes, true); convert->set_friendly_name("test"); - auto f = make_shared(convert, ParameterVector{}); + auto f = make_shared(convert, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); const auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1306,18 +1305,18 @@ TEST(constant_folding, const_reduce_logical_or__no_keepdims) { const Shape input_shape{3, 3}; const vector values_in{1, 0, 0, 1, 0, 1, 0, 0, 0}; - const auto data = op::Constant::create(element::boolean, input_shape, values_in); + const auto data = ov::op::v0::Constant::create(element::boolean, input_shape, values_in); data->set_friendly_name("data"); - const auto axes = op::Constant::create(element::i64, {1}, {1}); + const auto axes = ov::op::v0::Constant::create(element::i64, {1}, {1}); axes->set_friendly_name("axes"); const auto convert = make_shared(data, axes, false); convert->set_friendly_name("test"); - auto f = make_shared(convert, ParameterVector{}); + auto f = make_shared(convert, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); const auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1334,18 +1333,18 @@ TEST(constant_folding, const_reduce_logical_or__no_keepdims) { } TEST(constant_folding, const_concat) { - auto constant0 = op::Constant::create(element::i32, Shape{2, 3}, vector{1, 2, 3, 4, 5, 6}); + auto constant0 = ov::op::v0::Constant::create(element::i32, Shape{2, 3}, vector{1, 2, 3, 4, 5, 6}); constant0->set_friendly_name("constant0"); - auto constant1 = op::Constant::create(element::i32, Shape{2, 1}, vector{7, 8}); + auto constant1 = ov::op::v0::Constant::create(element::i32, Shape{2, 1}, vector{7, 8}); constant1->set_friendly_name("constant1"); - auto concat = make_shared(NodeVector{constant0, constant1}, 1); + auto concat = make_shared(NodeVector{constant0, constant1}, 1); concat->set_friendly_name("test"); - auto f = make_shared(concat, ParameterVector{}); + auto f = make_shared(concat, ParameterVector{}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1358,18 +1357,18 @@ TEST(constant_folding, const_concat) { } TEST(constant_folding, const_concat_3d_single_elem) { - auto constant_1 = op::Constant::create(element::i32, Shape{1, 1, 1}, vector{1}); + auto constant_1 = ov::op::v0::Constant::create(element::i32, Shape{1, 1, 1}, vector{1}); constant_1->set_friendly_name("constant_1"); - auto constant_2 = op::Constant::create(element::i32, Shape{1, 1, 1}, vector{2}); + auto constant_2 = ov::op::v0::Constant::create(element::i32, Shape{1, 1, 1}, vector{2}); constant_2->set_friendly_name("constant_2"); - auto concat = make_shared(NodeVector{constant_1, constant_2}, 0); + auto concat = make_shared(NodeVector{constant_1, constant_2}, 0); concat->set_friendly_name("test"); - auto f = make_shared(concat, ParameterVector{}); + auto f = make_shared(concat, ParameterVector{}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); @@ -1383,20 +1382,20 @@ TEST(constant_folding, const_concat_3d_single_elem) { } TEST(constant_folding, const_concat_axis_2) { - auto constant_1 = op::Constant::create(element::i32, Shape{3, 1, 2}, vector{1, 2, 3, 4, 5, 6}); + auto constant_1 = ov::op::v0::Constant::create(element::i32, Shape{3, 1, 2}, vector{1, 2, 3, 4, 5, 6}); constant_1->set_friendly_name("constant_1"); - auto constant_2 = op::Constant::create(element::i32, - Shape{3, 1, 4}, - vector{7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18}); + auto constant_2 = ov::op::v0::Constant::create(element::i32, + Shape{3, 1, 4}, + vector{7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18}); constant_2->set_friendly_name("constant_2"); - auto concat = make_shared(NodeVector{constant_1, constant_2}, 2); + auto concat = make_shared(NodeVector{constant_1, constant_2}, 2); concat->set_friendly_name("test"); - auto f = make_shared(concat, ParameterVector{}); + auto f = make_shared(concat, ParameterVector{}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); @@ -1410,21 +1409,23 @@ TEST(constant_folding, const_concat_axis_2) { } TEST(constant_folding, const_concat_axis_1_bool_type) { - auto constant_1 = op::Constant::create(element::boolean, Shape{1, 1, 2}, vector{true, true}); + auto constant_1 = ov::op::v0::Constant::create(element::boolean, Shape{1, 1, 2}, vector{true, true}); constant_1->set_friendly_name("constant_1"); - auto constant_2 = op::Constant::create(element::boolean, Shape{1, 2, 2}, vector{true, false, true, false}); + auto constant_2 = + ov::op::v0::Constant::create(element::boolean, Shape{1, 2, 2}, vector{true, false, true, false}); constant_2->set_friendly_name("constant_2"); - auto constant_3 = - op::Constant::create(element::boolean, Shape{1, 3, 2}, vector{true, false, true, false, true, false}); + auto constant_3 = ov::op::v0::Constant::create(element::boolean, + Shape{1, 3, 2}, + vector{true, false, true, false, true, false}); constant_3->set_friendly_name("constant_3"); - auto concat = make_shared(NodeVector{constant_1, constant_2, constant_3}, 1); + auto concat = make_shared(NodeVector{constant_1, constant_2, constant_3}, 1); concat->set_friendly_name("test"); - auto f = make_shared(concat, ParameterVector{}); + auto f = make_shared(concat, ParameterVector{}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); @@ -1438,16 +1439,16 @@ TEST(constant_folding, const_concat_axis_1_bool_type) { } TEST(constant_folding, const_logical_not) { - auto constant = op::Constant::create(element::boolean, Shape{2, 3}, vector{0, 1, 0, 0, 1, 1}); + auto constant = ov::op::v0::Constant::create(element::boolean, Shape{2, 3}, vector{0, 1, 0, 0, 1, 1}); constant->set_friendly_name("constant"); auto logical_not = make_shared(constant); logical_not->set_friendly_name("test"); - auto f = make_shared(logical_not, ParameterVector{}); + auto f = make_shared(logical_not, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1460,18 +1461,18 @@ TEST(constant_folding, const_logical_not) { } TEST(constant_folding, const_equal) { - auto constant0 = op::Constant::create(element::i32, Shape{2, 3}, vector{1, 2, 3, 4, 5, 6}); + auto constant0 = ov::op::v0::Constant::create(element::i32, Shape{2, 3}, vector{1, 2, 3, 4, 5, 6}); constant0->set_friendly_name("constant0"); - auto constant1 = op::Constant::create(element::i32, Shape{2, 3}, vector{1, 2, 2, 3, 5, 6}); + auto constant1 = ov::op::v0::Constant::create(element::i32, Shape{2, 3}, vector{1, 2, 2, 3, 5, 6}); constant1->set_friendly_name("constant1"); auto eq = make_shared(constant0, constant1); eq->set_friendly_name("test"); - auto f = make_shared(eq, ParameterVector{}); + auto f = make_shared(eq, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1484,18 +1485,18 @@ TEST(constant_folding, const_equal) { } TEST(constant_folding, const_not_equal) { - auto constant0 = op::Constant::create(element::i32, Shape{2, 3}, vector{1, 2, 3, 4, 5, 6}); + auto constant0 = ov::op::v0::Constant::create(element::i32, Shape{2, 3}, vector{1, 2, 3, 4, 5, 6}); constant0->set_friendly_name("constant0"); - auto constant1 = op::Constant::create(element::i32, Shape{2, 3}, vector{1, 2, 2, 3, 5, 6}); + auto constant1 = ov::op::v0::Constant::create(element::i32, Shape{2, 3}, vector{1, 2, 2, 3, 5, 6}); constant1->set_friendly_name("constant1"); auto eq = make_shared(constant0, constant1); eq->set_friendly_name("test"); - auto f = make_shared(eq, ParameterVector{}); + auto f = make_shared(eq, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1508,18 +1509,18 @@ TEST(constant_folding, const_not_equal) { } TEST(constant_folding, const_greater) { - auto constant0 = op::Constant::create(element::i32, Shape{2, 3}, vector{1, 2, 3, 4, 5, 6}); + auto constant0 = ov::op::v0::Constant::create(element::i32, Shape{2, 3}, vector{1, 2, 3, 4, 5, 6}); constant0->set_friendly_name("constant0"); - auto constant1 = op::Constant::create(element::i32, Shape{2, 3}, vector{2, 2, 2, 5, 5, 5}); + auto constant1 = ov::op::v0::Constant::create(element::i32, Shape{2, 3}, vector{2, 2, 2, 5, 5, 5}); constant1->set_friendly_name("constant1"); auto eq = make_shared(constant0, constant1); eq->set_friendly_name("test"); - auto f = make_shared(eq, ParameterVector{}); + auto f = make_shared(eq, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1532,18 +1533,18 @@ TEST(constant_folding, const_greater) { } TEST(constant_folding, const_greater_eq) { - auto constant0 = op::Constant::create(element::i32, Shape{2, 3}, vector{1, 2, 3, 4, 5, 6}); + auto constant0 = ov::op::v0::Constant::create(element::i32, Shape{2, 3}, vector{1, 2, 3, 4, 5, 6}); constant0->set_friendly_name("constant0"); - auto constant1 = op::Constant::create(element::i32, Shape{2, 3}, vector{2, 2, 2, 5, 5, 5}); + auto constant1 = ov::op::v0::Constant::create(element::i32, Shape{2, 3}, vector{2, 2, 2, 5, 5, 5}); constant1->set_friendly_name("constant1"); auto eq = make_shared(constant0, constant1); eq->set_friendly_name("test"); - auto f = make_shared(eq, ParameterVector{}); + auto f = make_shared(eq, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1556,18 +1557,18 @@ TEST(constant_folding, const_greater_eq) { } TEST(constant_folding, const_less) { - auto constant0 = op::Constant::create(element::i32, Shape{2, 3}, vector{1, 2, 3, 4, 5, 6}); + auto constant0 = ov::op::v0::Constant::create(element::i32, Shape{2, 3}, vector{1, 2, 3, 4, 5, 6}); constant0->set_friendly_name("constant0"); - auto constant1 = op::Constant::create(element::i32, Shape{2, 3}, vector{2, 2, 2, 5, 5, 5}); + auto constant1 = ov::op::v0::Constant::create(element::i32, Shape{2, 3}, vector{2, 2, 2, 5, 5, 5}); constant1->set_friendly_name("constant1"); auto eq = make_shared(constant0, constant1); eq->set_friendly_name("test"); - auto f = make_shared(eq, ParameterVector{}); + auto f = make_shared(eq, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1580,18 +1581,18 @@ TEST(constant_folding, const_less) { } TEST(constant_folding, const_less_eq) { - auto constant0 = op::Constant::create(element::i32, Shape{2, 3}, vector{1, 2, 3, 4, 5, 6}); + auto constant0 = ov::op::v0::Constant::create(element::i32, Shape{2, 3}, vector{1, 2, 3, 4, 5, 6}); constant0->set_friendly_name("constant0"); - auto constant1 = op::Constant::create(element::i32, Shape{2, 3}, vector{2, 2, 2, 5, 5, 5}); + auto constant1 = ov::op::v0::Constant::create(element::i32, Shape{2, 3}, vector{2, 2, 2, 5, 5, 5}); constant1->set_friendly_name("constant1"); auto eq = make_shared(constant0, constant1); eq->set_friendly_name("test"); - auto f = make_shared(eq, ParameterVector{}); + auto f = make_shared(eq, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1604,18 +1605,18 @@ TEST(constant_folding, const_less_eq) { } TEST(constant_folding, const_or) { - auto constant0 = op::Constant::create(element::boolean, Shape{2, 3}, vector{0, 0, 1, 0, 1, 1}); + auto constant0 = ov::op::v0::Constant::create(element::boolean, Shape{2, 3}, vector{0, 0, 1, 0, 1, 1}); constant0->set_friendly_name("constant0"); - auto constant1 = op::Constant::create(element::boolean, Shape{2, 3}, vector{0, 1, 1, 1, 0, 1}); + auto constant1 = ov::op::v0::Constant::create(element::boolean, Shape{2, 3}, vector{0, 1, 1, 1, 0, 1}); constant1->set_friendly_name("constant1"); auto eq = make_shared(constant0, constant1); eq->set_friendly_name("test"); - auto f = make_shared(eq, ParameterVector{}); + auto f = make_shared(eq, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1628,18 +1629,18 @@ TEST(constant_folding, const_or) { } TEST(constant_folding, const_xor) { - auto constant0 = op::Constant::create(element::boolean, Shape{2, 3}, vector{0, 0, 1, 0, 1, 1}); + auto constant0 = ov::op::v0::Constant::create(element::boolean, Shape{2, 3}, vector{0, 0, 1, 0, 1, 1}); constant0->set_friendly_name("constant0"); - auto constant1 = op::Constant::create(element::boolean, Shape{2, 3}, vector{0, 1, 1, 1, 0, 1}); + auto constant1 = ov::op::v0::Constant::create(element::boolean, Shape{2, 3}, vector{0, 1, 1, 1, 0, 1}); constant1->set_friendly_name("constant1"); - auto eq = make_shared(constant0, constant1); + auto eq = make_shared(constant0, constant1); eq->set_friendly_name("test"); - auto f = make_shared(eq, ParameterVector{}); + auto f = make_shared(eq, ParameterVector{}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1653,16 +1654,16 @@ TEST(constant_folding, const_xor) { TEST(constant_folding, const_ceiling) { auto constant = - op::Constant::create(element::f32, Shape{2, 3}, vector{0.0f, 0.1f, -0.1f, -2.5f, 2.5f, 3.0f}); + ov::op::v0::Constant::create(element::f32, Shape{2, 3}, vector{0.0f, 0.1f, -0.1f, -2.5f, 2.5f, 3.0f}); constant->set_friendly_name("constant"); - auto ceil = make_shared(constant); + auto ceil = make_shared(constant); ceil->set_friendly_name("test"); - auto f = make_shared(ceil, ParameterVector{}); + auto f = make_shared(ceil, ParameterVector{}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1676,16 +1677,16 @@ TEST(constant_folding, const_ceiling) { TEST(constant_folding, const_floor) { auto constant = - op::Constant::create(element::f32, Shape{2, 3}, vector{0.0f, 0.1f, -0.1f, -2.5f, 2.5f, 3.0f}); + ov::op::v0::Constant::create(element::f32, Shape{2, 3}, vector{0.0f, 0.1f, -0.1f, -2.5f, 2.5f, 3.0f}); constant->set_friendly_name("constant"); - auto floor = make_shared(constant); + auto floor = make_shared(constant); floor->set_friendly_name("test"); - auto f = make_shared(floor, ParameterVector{}); + auto f = make_shared(floor, ParameterVector{}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1699,22 +1700,22 @@ TEST(constant_folding, const_floor) { TEST(constant_folding, const_gather_v1) { auto constant_data = - op::Constant::create(element::f32, - Shape{2, 5}, - vector{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f}); + ov::op::v0::Constant::create(element::f32, + Shape{2, 5}, + vector{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f}); constant_data->set_friendly_name("constant_data"); - auto constant_indices = op::Constant::create(element::i64, Shape{4}, vector{0, 3, 2, 2}); + auto constant_indices = ov::op::v0::Constant::create(element::i64, Shape{4}, vector{0, 3, 2, 2}); constant_indices->set_friendly_name("constant_indices"); - auto constant_axis = op::Constant::create(element::i64, Shape{1}, vector{1}); + auto constant_axis = ov::op::v0::Constant::create(element::i64, Shape{1}, vector{1}); constant_axis->set_friendly_name("constant_axis"); auto gather = make_shared(constant_data, constant_indices, constant_axis); gather->set_friendly_name("test"); - auto f = make_shared(gather, ParameterVector{}); + auto f = make_shared(gather, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1728,22 +1729,22 @@ TEST(constant_folding, const_gather_v1) { TEST(constant_folding, const_gather_v1_scalar) { auto constant_data = - op::Constant::create(element::f32, - Shape{2, 5}, - vector{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f}); + ov::op::v0::Constant::create(element::f32, + Shape{2, 5}, + vector{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f}); constant_data->set_friendly_name("constant_data"); - auto constant_indices = op::Constant::create(element::i64, Shape{4}, vector{0, 3, 2, 2}); + auto constant_indices = ov::op::v0::Constant::create(element::i64, Shape{4}, vector{0, 3, 2, 2}); constant_indices->set_friendly_name("constant_indices"); - auto constant_axis = op::Constant::create(element::i64, Shape{}, vector{1}); + auto constant_axis = ov::op::v0::Constant::create(element::i64, Shape{}, vector{1}); constant_axis->set_friendly_name("constant_axis"); auto gather = make_shared(constant_data, constant_indices, constant_axis); gather->set_friendly_name("test"); - auto f = make_shared(gather, ParameterVector{}); + auto f = make_shared(gather, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1756,29 +1757,29 @@ TEST(constant_folding, const_gather_v1_scalar) { } TEST(constant_folding, const_gather_v1_subgraph) { - const auto A = make_shared(element::f32, Shape{1}); + const auto A = make_shared(element::f32, Shape{1}); const float b_value = 3.21f; - const auto B_const = op::Constant::create(element::f32, {1}, {b_value}); - const auto C = make_shared(element::f32, Shape{1}); + const auto B_const = ov::op::v0::Constant::create(element::f32, {1}, {b_value}); + const auto C = make_shared(element::f32, Shape{1}); const int64_t axis = 0; - const auto axis_const = op::Constant::create(element::i64, {}, {axis}); + const auto axis_const = ov::op::v0::Constant::create(element::i64, {}, {axis}); axis_const->set_friendly_name("axis_const"); - const auto concat = make_shared(NodeVector{A, B_const, C}, axis); + const auto concat = make_shared(NodeVector{A, B_const, C}, axis); concat->set_friendly_name("concat"); const vector indices{1}; - const auto indices_const = op::Constant::create(element::i64, {indices.size()}, indices); + const auto indices_const = ov::op::v0::Constant::create(element::i64, {indices.size()}, indices); indices_const->set_friendly_name("indices_const"); const auto gather = make_shared(concat, indices_const, axis_const); gather->set_friendly_name("test"); - auto f = make_shared(gather, ParameterVector{A, C}); + auto f = make_shared(gather, ParameterVector{A, C}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 0); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); const auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1789,29 +1790,29 @@ TEST(constant_folding, const_gather_v1_subgraph) { } TEST(constant_folding, const_gather_v1_subgraph_neg_axis) { - const auto A = make_shared(element::f32, Shape{1}); + const auto A = make_shared(element::f32, Shape{1}); const float b_value = 1.23f; - const auto B = make_shared(element::f32, Shape{1}); - const auto C_const = op::Constant::create(element::f32, {1}, {b_value}); + const auto B = make_shared(element::f32, Shape{1}); + const auto C_const = ov::op::v0::Constant::create(element::f32, {1}, {b_value}); const int64_t axis = 0; - const auto axis_const = op::Constant::create(element::i64, {}, {axis}); + const auto axis_const = ov::op::v0::Constant::create(element::i64, {}, {axis}); axis_const->set_friendly_name("axis_const"); - const auto concat = make_shared(NodeVector{A, B, C_const}, axis); + const auto concat = make_shared(NodeVector{A, B, C_const}, axis); concat->set_friendly_name("concat"); const vector indices{-1}; - const auto indices_const = op::Constant::create(element::i64, {indices.size()}, indices); + const auto indices_const = ov::op::v0::Constant::create(element::i64, {indices.size()}, indices); indices_const->set_friendly_name("indices_const"); const auto gather = make_shared(concat, indices_const, axis_const); gather->set_friendly_name("test"); - auto f = make_shared(gather, ParameterVector{A, B}); + auto f = make_shared(gather, ParameterVector{A, B}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 0); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); const auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1822,145 +1823,145 @@ TEST(constant_folding, const_gather_v1_subgraph_neg_axis) { } TEST(constant_folding, const_gather_v1_subgraph_no_constant_input) { - const auto A = make_shared(element::f32, Shape{1}); - const auto B = make_shared(element::f32, Shape{1}); - const auto C = make_shared(element::f32, Shape{1}); + const auto A = make_shared(element::f32, Shape{1}); + const auto B = make_shared(element::f32, Shape{1}); + const auto C = make_shared(element::f32, Shape{1}); const int64_t axis = 0; - const auto axis_const = op::Constant::create(element::i64, {}, {axis}); + const auto axis_const = ov::op::v0::Constant::create(element::i64, {}, {axis}); - const auto concat = make_shared(NodeVector{A, B, C}, axis); + const auto concat = make_shared(NodeVector{A, B, C}, axis); const vector indices{1}; - const auto indices_const = op::Constant::create(element::i64, {indices.size()}, indices); + const auto indices_const = ov::op::v0::Constant::create(element::i64, {indices.size()}, indices); const auto gather = make_shared(concat, indices_const, axis_const); gather->set_friendly_name("test"); - auto f = make_shared(gather, ParameterVector{A, B, C}); + auto f = make_shared(gather, ParameterVector{A, B, C}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 0); ASSERT_EQ(count_ops_of_type(f), 0); } TEST(constant_folding, const_gather_v1_subgraph_no_constant_input_scalar) { - const auto A = make_shared(element::f32, Shape{1}); - const auto B = make_shared(element::f32, Shape{1}); - const auto C = make_shared(element::f32, Shape{1}); + const auto A = make_shared(element::f32, Shape{1}); + const auto B = make_shared(element::f32, Shape{1}); + const auto C = make_shared(element::f32, Shape{1}); const int64_t axis = 0; - const auto axis_const = op::Constant::create(element::i64, {}, {axis}); + const auto axis_const = ov::op::v0::Constant::create(element::i64, {}, {axis}); - const auto concat = make_shared(NodeVector{A, B, C}, axis); + const auto concat = make_shared(NodeVector{A, B, C}, axis); const vector indices{1}; - const auto indices_const = op::Constant::create(element::i64, {}, indices); + const auto indices_const = ov::op::v0::Constant::create(element::i64, {}, indices); const auto gather = make_shared(concat, indices_const, axis_const); - auto f = make_shared(gather, ParameterVector{A, B, C}); + auto f = make_shared(gather, ParameterVector{A, B, C}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 0); ASSERT_EQ(count_ops_of_type(f), 0); ASSERT_EQ(count_ops_of_type(f), 1); } TEST(constant_folding, const_gather_v1_subgraph_skip_if_non_zero_axis) { - const auto A = make_shared(element::f32, Shape{2, 2}); - const auto B = make_shared(element::f32, Shape{2, 2}); - const auto C = make_shared(element::f32, Shape{2, 2}); + const auto A = make_shared(element::f32, Shape{2, 2}); + const auto B = make_shared(element::f32, Shape{2, 2}); + const auto C = make_shared(element::f32, Shape{2, 2}); const int64_t axis = 1; - const auto axis_const = op::Constant::create(element::i64, {}, {axis}); + const auto axis_const = ov::op::v0::Constant::create(element::i64, {}, {axis}); - const auto concat = make_shared(NodeVector{A, B, C}, axis); + const auto concat = make_shared(NodeVector{A, B, C}, axis); const vector indices{1}; - const auto indices_const = op::Constant::create(element::i64, {indices.size()}, indices); + const auto indices_const = ov::op::v0::Constant::create(element::i64, {indices.size()}, indices); const auto gather = make_shared(concat, indices_const, axis_const); - auto f = make_shared(gather, ParameterVector{A, B, C}); + auto f = make_shared(gather, ParameterVector{A, B, C}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); ASSERT_EQ(count_ops_of_type(f), 1); } TEST(constant_folding, const_gather_v1_subgraph_skip_if_non_single_indices) { - const auto A = make_shared(element::f32, Shape{1}); - const auto B = make_shared(element::f32, Shape{1}); - const auto C = make_shared(element::f32, Shape{1}); + const auto A = make_shared(element::f32, Shape{1}); + const auto B = make_shared(element::f32, Shape{1}); + const auto C = make_shared(element::f32, Shape{1}); const int64_t axis = 0; - const auto axis_const = op::Constant::create(element::i64, {}, {axis}); + const auto axis_const = ov::op::v0::Constant::create(element::i64, {}, {axis}); - const auto concat = make_shared(NodeVector{A, B, C}, axis); + const auto concat = make_shared(NodeVector{A, B, C}, axis); const vector indices{0, 1}; - const auto indices_const = op::Constant::create(element::i64, {indices.size()}, indices); + const auto indices_const = ov::op::v0::Constant::create(element::i64, {indices.size()}, indices); const auto gather = make_shared(concat, indices_const, axis_const); - auto f = make_shared(gather, ParameterVector{A, B, C}); + auto f = make_shared(gather, ParameterVector{A, B, C}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); ASSERT_EQ(count_ops_of_type(f), 1); } TEST(constant_folding, const_gather_v1_subgraph_skip_if_concat_output_shape_dynamic) { - const auto A = make_shared(element::f32, PartialShape::dynamic()); - const auto B = make_shared(element::f32, Shape{1}); - const auto C = make_shared(element::f32, Shape{1}); + const auto A = make_shared(element::f32, PartialShape::dynamic()); + const auto B = make_shared(element::f32, Shape{1}); + const auto C = make_shared(element::f32, Shape{1}); const int64_t axis = 0; - const auto axis_const = op::Constant::create(element::i64, {}, {axis}); + const auto axis_const = ov::op::v0::Constant::create(element::i64, {}, {axis}); - const auto concat = make_shared(NodeVector{A, B, C}, axis); + const auto concat = make_shared(NodeVector{A, B, C}, axis); const vector indices{1}; - const auto indices_const = op::Constant::create(element::i64, {indices.size()}, indices); + const auto indices_const = ov::op::v0::Constant::create(element::i64, {indices.size()}, indices); const auto gather = make_shared(concat, indices_const, axis_const); - auto f = make_shared(gather, ParameterVector{A, B, C}); + auto f = make_shared(gather, ParameterVector{A, B, C}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); ASSERT_EQ(count_ops_of_type(f), 1); } TEST(constant_folding, const_gather_v1_subgraph_skip_if_not_single_input) { - const auto A = make_shared(element::f32, Shape{2}); - const auto B = make_shared(element::f32, Shape{1}); - const auto C = make_shared(element::f32, Shape{1}); + const auto A = make_shared(element::f32, Shape{2}); + const auto B = make_shared(element::f32, Shape{1}); + const auto C = make_shared(element::f32, Shape{1}); const int64_t axis = 0; - const auto axis_const = op::Constant::create(element::i64, {}, {axis}); + const auto axis_const = ov::op::v0::Constant::create(element::i64, {}, {axis}); - const auto concat = make_shared(NodeVector{A, B, C}, axis); + const auto concat = make_shared(NodeVector{A, B, C}, axis); const vector indices{1}; - const auto indices_const = op::Constant::create(element::i64, {indices.size()}, indices); + const auto indices_const = ov::op::v0::Constant::create(element::i64, {indices.size()}, indices); const auto gather = make_shared(concat, indices_const, axis_const); - auto f = make_shared(gather, ParameterVector{A, B, C}); + auto f = make_shared(gather, ParameterVector{A, B, C}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); ASSERT_EQ(count_ops_of_type(f), 1); } TEST(constant_folding, const_gather_v7) { auto constant_data = - op::Constant::create(element::f32, - Shape{2, 5}, - vector{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f}); + ov::op::v0::Constant::create(element::f32, + Shape{2, 5}, + vector{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f}); constant_data->set_friendly_name("constant_data"); - auto constant_indices = op::Constant::create(element::i64, Shape{4}, vector{0, 3, 2, 2}); + auto constant_indices = ov::op::v0::Constant::create(element::i64, Shape{4}, vector{0, 3, 2, 2}); constant_indices->set_friendly_name("constant_indices"); - auto constant_axis = op::Constant::create(element::i64, Shape{1}, vector{1}); + auto constant_axis = ov::op::v0::Constant::create(element::i64, Shape{1}, vector{1}); constant_axis->set_friendly_name("constant_axis"); auto gather = make_shared(constant_data, constant_indices, constant_axis); gather->set_friendly_name("test"); - auto f = make_shared(gather, ParameterVector{}); + auto f = make_shared(gather, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -1974,22 +1975,22 @@ TEST(constant_folding, const_gather_v7) { TEST(constant_folding, const_gather_v7_scalar) { auto constant_data = - op::Constant::create(element::f32, - Shape{2, 5}, - vector{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f}); + ov::op::v0::Constant::create(element::f32, + Shape{2, 5}, + vector{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f}); constant_data->set_friendly_name("constant_data"); - auto constant_indices = op::Constant::create(element::i64, Shape{4}, vector{0, 3, 2, 2}); + auto constant_indices = ov::op::v0::Constant::create(element::i64, Shape{4}, vector{0, 3, 2, 2}); constant_indices->set_friendly_name("constant_indices"); - auto constant_axis = op::Constant::create(element::i64, Shape{}, vector{1}); + auto constant_axis = ov::op::v0::Constant::create(element::i64, Shape{}, vector{1}); constant_axis->set_friendly_name("constant_axis"); auto gather = make_shared(constant_data, constant_indices, constant_axis); gather->set_friendly_name("test"); - auto f = make_shared(gather, ParameterVector{}); + auto f = make_shared(gather, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -2002,29 +2003,29 @@ TEST(constant_folding, const_gather_v7_scalar) { } TEST(constant_folding, const_gather_v7_subgraph) { - const auto A = make_shared(element::f32, Shape{1}); + const auto A = make_shared(element::f32, Shape{1}); const float b_value = 3.21f; - const auto B_const = op::Constant::create(element::f32, {1}, {b_value}); - const auto C = make_shared(element::f32, Shape{1}); + const auto B_const = ov::op::v0::Constant::create(element::f32, {1}, {b_value}); + const auto C = make_shared(element::f32, Shape{1}); const int64_t axis = 0; - const auto axis_const = op::Constant::create(element::i64, {}, {axis}); + const auto axis_const = ov::op::v0::Constant::create(element::i64, {}, {axis}); axis_const->set_friendly_name("axis_const"); - const auto concat = make_shared(NodeVector{A, B_const, C}, axis); + const auto concat = make_shared(NodeVector{A, B_const, C}, axis); concat->set_friendly_name("concat"); const vector indices{1}; - const auto indices_const = op::Constant::create(element::i64, {indices.size()}, indices); + const auto indices_const = ov::op::v0::Constant::create(element::i64, {indices.size()}, indices); indices_const->set_friendly_name("indices_const"); const auto gather = make_shared(concat, indices_const, axis_const); gather->set_friendly_name("test"); - auto f = make_shared(gather, ParameterVector{A, C}); + auto f = make_shared(gather, ParameterVector{A, C}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 0); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); const auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -2035,29 +2036,29 @@ TEST(constant_folding, const_gather_v7_subgraph) { } TEST(constant_folding, const_gather_v7_subgraph_neg_axis) { - const auto A = make_shared(element::f32, Shape{1}); + const auto A = make_shared(element::f32, Shape{1}); const float b_value = 1.23f; - const auto B = make_shared(element::f32, Shape{1}); - const auto C_const = op::Constant::create(element::f32, {1}, {b_value}); + const auto B = make_shared(element::f32, Shape{1}); + const auto C_const = ov::op::v0::Constant::create(element::f32, {1}, {b_value}); const int64_t axis = 0; - const auto axis_const = op::Constant::create(element::i64, {}, {axis}); + const auto axis_const = ov::op::v0::Constant::create(element::i64, {}, {axis}); axis_const->set_friendly_name("axis_const"); - const auto concat = make_shared(NodeVector{A, B, C_const}, axis); + const auto concat = make_shared(NodeVector{A, B, C_const}, axis); concat->set_friendly_name("concat"); const vector indices{-1}; - const auto indices_const = op::Constant::create(element::i64, {indices.size()}, indices); + const auto indices_const = ov::op::v0::Constant::create(element::i64, {indices.size()}, indices); indices_const->set_friendly_name("indices_const"); const auto gather = make_shared(concat, indices_const, axis_const); gather->set_friendly_name("test"); - auto f = make_shared(gather, ParameterVector{A, B}); + auto f = make_shared(gather, ParameterVector{A, B}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 0); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); const auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -2068,124 +2069,124 @@ TEST(constant_folding, const_gather_v7_subgraph_neg_axis) { } TEST(constant_folding, const_gather_v7_subgraph_no_constant_input) { - const auto A = make_shared(element::f32, Shape{1}); - const auto B = make_shared(element::f32, Shape{1}); - const auto C = make_shared(element::f32, Shape{1}); + const auto A = make_shared(element::f32, Shape{1}); + const auto B = make_shared(element::f32, Shape{1}); + const auto C = make_shared(element::f32, Shape{1}); const int64_t axis = 0; - const auto axis_const = op::Constant::create(element::i64, {}, {axis}); + const auto axis_const = ov::op::v0::Constant::create(element::i64, {}, {axis}); - const auto concat = make_shared(NodeVector{A, B, C}, axis); + const auto concat = make_shared(NodeVector{A, B, C}, axis); const vector indices{1}; - const auto indices_const = op::Constant::create(element::i64, {indices.size()}, indices); + const auto indices_const = ov::op::v0::Constant::create(element::i64, {indices.size()}, indices); const auto gather = make_shared(concat, indices_const, axis_const); gather->set_friendly_name("test"); - auto f = make_shared(gather, ParameterVector{A, B, C}); + auto f = make_shared(gather, ParameterVector{A, B, C}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 0); ASSERT_EQ(count_ops_of_type(f), 0); } TEST(constant_folding, const_gather_v7_subgraph_no_constant_input_scalar) { - const auto A = make_shared(element::f32, Shape{1}); - const auto B = make_shared(element::f32, Shape{1}); - const auto C = make_shared(element::f32, Shape{1}); + const auto A = make_shared(element::f32, Shape{1}); + const auto B = make_shared(element::f32, Shape{1}); + const auto C = make_shared(element::f32, Shape{1}); const int64_t axis = 0; - const auto axis_const = op::Constant::create(element::i64, {}, {axis}); + const auto axis_const = ov::op::v0::Constant::create(element::i64, {}, {axis}); - const auto concat = make_shared(NodeVector{A, B, C}, axis); + const auto concat = make_shared(NodeVector{A, B, C}, axis); const vector indices{1}; - const auto indices_const = op::Constant::create(element::i64, {}, indices); + const auto indices_const = ov::op::v0::Constant::create(element::i64, {}, indices); const auto gather = make_shared(concat, indices_const, axis_const); - auto f = make_shared(gather, ParameterVector{A, B, C}); + auto f = make_shared(gather, ParameterVector{A, B, C}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 0); ASSERT_EQ(count_ops_of_type(f), 0); ASSERT_EQ(count_ops_of_type(f), 1); } TEST(constant_folding, const_gather_v7_subgraph_skip_if_non_zero_axis) { - const auto A = make_shared(element::f32, Shape{2, 2}); - const auto B = make_shared(element::f32, Shape{2, 2}); - const auto C = make_shared(element::f32, Shape{2, 2}); + const auto A = make_shared(element::f32, Shape{2, 2}); + const auto B = make_shared(element::f32, Shape{2, 2}); + const auto C = make_shared(element::f32, Shape{2, 2}); const int64_t axis = 1; - const auto axis_const = op::Constant::create(element::i64, {}, {axis}); + const auto axis_const = ov::op::v0::Constant::create(element::i64, {}, {axis}); - const auto concat = make_shared(NodeVector{A, B, C}, axis); + const auto concat = make_shared(NodeVector{A, B, C}, axis); const vector indices{1}; - const auto indices_const = op::Constant::create(element::i64, {indices.size()}, indices); + const auto indices_const = ov::op::v0::Constant::create(element::i64, {indices.size()}, indices); const auto gather = make_shared(concat, indices_const, axis_const); - auto f = make_shared(gather, ParameterVector{A, B, C}); + auto f = make_shared(gather, ParameterVector{A, B, C}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); ASSERT_EQ(count_ops_of_type(f), 1); } TEST(constant_folding, const_gather_v7_subgraph_skip_if_non_single_indices) { - const auto A = make_shared(element::f32, Shape{1}); - const auto B = make_shared(element::f32, Shape{1}); - const auto C = make_shared(element::f32, Shape{1}); + const auto A = make_shared(element::f32, Shape{1}); + const auto B = make_shared(element::f32, Shape{1}); + const auto C = make_shared(element::f32, Shape{1}); const int64_t axis = 0; - const auto axis_const = op::Constant::create(element::i64, {}, {axis}); + const auto axis_const = ov::op::v0::Constant::create(element::i64, {}, {axis}); - const auto concat = make_shared(NodeVector{A, B, C}, axis); + const auto concat = make_shared(NodeVector{A, B, C}, axis); const vector indices{0, 1}; - const auto indices_const = op::Constant::create(element::i64, {indices.size()}, indices); + const auto indices_const = ov::op::v0::Constant::create(element::i64, {indices.size()}, indices); const auto gather = make_shared(concat, indices_const, axis_const); - auto f = make_shared(gather, ParameterVector{A, B, C}); + auto f = make_shared(gather, ParameterVector{A, B, C}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); ASSERT_EQ(count_ops_of_type(f), 1); } TEST(constant_folding, const_gather_v7_subgraph_skip_if_concat_output_shape_dynamic) { - const auto A = make_shared(element::f32, PartialShape::dynamic()); - const auto B = make_shared(element::f32, Shape{1}); - const auto C = make_shared(element::f32, Shape{1}); + const auto A = make_shared(element::f32, PartialShape::dynamic()); + const auto B = make_shared(element::f32, Shape{1}); + const auto C = make_shared(element::f32, Shape{1}); const int64_t axis = 0; - const auto axis_const = op::Constant::create(element::i64, {}, {axis}); + const auto axis_const = ov::op::v0::Constant::create(element::i64, {}, {axis}); - const auto concat = make_shared(NodeVector{A, B, C}, axis); + const auto concat = make_shared(NodeVector{A, B, C}, axis); const vector indices{1}; - const auto indices_const = op::Constant::create(element::i64, {indices.size()}, indices); + const auto indices_const = ov::op::v0::Constant::create(element::i64, {indices.size()}, indices); const auto gather = make_shared(concat, indices_const, axis_const); - auto f = make_shared(gather, ParameterVector{A, B, C}); + auto f = make_shared(gather, ParameterVector{A, B, C}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); ASSERT_EQ(count_ops_of_type(f), 1); } TEST(constant_folding, const_gather_v7_subgraph_skip_if_not_single_input) { - const auto A = make_shared(element::f32, Shape{2}); - const auto B = make_shared(element::f32, Shape{1}); - const auto C = make_shared(element::f32, Shape{1}); + const auto A = make_shared(element::f32, Shape{2}); + const auto B = make_shared(element::f32, Shape{1}); + const auto C = make_shared(element::f32, Shape{1}); const int64_t axis = 0; - const auto axis_const = op::Constant::create(element::i64, {}, {axis}); + const auto axis_const = ov::op::v0::Constant::create(element::i64, {}, {axis}); - const auto concat = make_shared(NodeVector{A, B, C}, axis); + const auto concat = make_shared(NodeVector{A, B, C}, axis); const vector indices{1}; - const auto indices_const = op::Constant::create(element::i64, {indices.size()}, indices); + const auto indices_const = ov::op::v0::Constant::create(element::i64, {indices.size()}, indices); const auto gather = make_shared(concat, indices_const, axis_const); - auto f = make_shared(gather, ParameterVector{A, B, C}); + auto f = make_shared(gather, ParameterVector{A, B, C}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); ASSERT_EQ(count_ops_of_type(f), 1); } @@ -2193,13 +2194,13 @@ TEST(constant_folding, const_strided_slice) { Shape shape_in{16}; vector values_in{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; - auto constant = make_shared(element::i32, shape_in, values_in); + auto constant = make_shared(element::i32, shape_in, values_in); constant->set_friendly_name("constant"); - auto begin = op::Constant::create(element::i64, {1}, {2}); + auto begin = ov::op::v0::Constant::create(element::i64, {1}, {2}); begin->set_friendly_name("begin"); - auto end = op::Constant::create(element::i64, {1}, {15}); + auto end = ov::op::v0::Constant::create(element::i64, {1}, {15}); end->set_friendly_name("end"); - auto stride = op::Constant::create(element::i64, {1}, {3}); + auto stride = ov::op::v0::Constant::create(element::i64, {1}, {3}); stride->set_friendly_name("stride"); auto slice = make_shared(constant, begin, @@ -2209,12 +2210,12 @@ TEST(constant_folding, const_strided_slice) { std::vector{0}); slice->set_friendly_name("test"); - auto f = make_shared(slice, ParameterVector{}); + auto f = make_shared(slice, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -2227,22 +2228,22 @@ TEST(constant_folding, const_strided_slice) { TEST(constant_folding, strided_slice_ignored_dynamic_begin_end_values_from_shape_of) { const auto constant = - make_shared(element::i32, - Shape{1, 1, 2, 4, 2}, - std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}); + make_shared(element::i32, + Shape{1, 1, 2, 4, 2}, + std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}); constant->set_friendly_name("constant"); const auto begin_shape = PartialShape{0, -1, 0, 0, 0}; - const auto p_begin = std::make_shared(element::i64, begin_shape); - const auto shape_of_begin = std::make_shared(p_begin); + const auto p_begin = std::make_shared(element::i64, begin_shape); + const auto shape_of_begin = std::make_shared(p_begin); shape_of_begin->set_friendly_name("begin"); const auto end_shape = PartialShape{-1, 512, 2, 2, 16}; - const auto p_end = std::make_shared(element::i64, end_shape); - const auto shape_of_end = std::make_shared(p_end); + const auto p_end = std::make_shared(element::i64, end_shape); + const auto shape_of_end = std::make_shared(p_end); shape_of_end->set_friendly_name("end"); - const auto stride = op::Constant::create(element::i64, {5}, {1, 1, 1, 1, 1}); + const auto stride = ov::op::v0::Constant::create(element::i64, {5}, {1, 1, 1, 1, 1}); stride->set_friendly_name("stride"); const auto slice = make_shared(constant, @@ -2258,7 +2259,7 @@ TEST(constant_folding, strided_slice_ignored_dynamic_begin_end_values_from_shape run_constant_folding(model); ASSERT_EQ(count_ops_of_type(model), 0); - ASSERT_EQ(count_ops_of_type(model), 1); + ASSERT_EQ(count_ops_of_type(model), 1); const auto new_const = get_result_constant(model); ASSERT_TRUE(new_const); @@ -2271,22 +2272,22 @@ TEST(constant_folding, strided_slice_ignored_dynamic_begin_end_values_from_shape TEST(constant_folding, strided_slice_all_ignore_mask_set_for_non_parameter_begin_end) { const auto constant = - make_shared(element::i32, - Shape{1, 1, 2, 4, 2}, - std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}); + make_shared(element::i32, + Shape{1, 1, 2, 4, 2}, + std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}); constant->set_friendly_name("constant"); const auto begin_shape = PartialShape{{2, 5}, -1, 10, 1, {0, 200}}; - const auto p_begin = std::make_shared(element::i64, begin_shape); - const auto shape_of_begin = std::make_shared(p_begin); + const auto p_begin = std::make_shared(element::i64, begin_shape); + const auto shape_of_begin = std::make_shared(p_begin); shape_of_begin->set_friendly_name("begin"); const auto end_shape = PartialShape{-1, 1, {2, 3}, 0, 0}; - const auto p_end = std::make_shared(element::i64, end_shape); - const auto shape_of_end = std::make_shared(p_end); + const auto p_end = std::make_shared(element::i64, end_shape); + const auto shape_of_end = std::make_shared(p_end); shape_of_end->set_friendly_name("end"); - const auto stride = op::Constant::create(element::i64, {5}, {1, 1, 1, 2, 2}); + const auto stride = ov::op::v0::Constant::create(element::i64, {5}, {1, 1, 1, 2, 2}); stride->set_friendly_name("stride"); const auto slice = make_shared(constant, @@ -2302,7 +2303,7 @@ TEST(constant_folding, strided_slice_all_ignore_mask_set_for_non_parameter_begin run_constant_folding(model); ASSERT_EQ(count_ops_of_type(model), 0); - ASSERT_EQ(count_ops_of_type(model), 1); + ASSERT_EQ(count_ops_of_type(model), 1); const auto new_const = get_result_constant(model); ASSERT_TRUE(new_const); @@ -2315,20 +2316,20 @@ TEST(constant_folding, strided_slice_all_ignore_mask_set_for_non_parameter_begin TEST(constant_folding, strided_slice_all_ignore_mask_set_for_parameter_begin_end) { const auto constant = - make_shared(element::i32, - Shape{1, 1, 2, 4, 2}, - std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}); + make_shared(element::i32, + Shape{1, 1, 2, 4, 2}, + std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}); constant->set_friendly_name("constant"); const auto begin_shape = PartialShape{{1, 5}}; - const auto p_begin = std::make_shared(element::i64, begin_shape); + const auto p_begin = std::make_shared(element::i64, begin_shape); p_begin->set_friendly_name("begin"); const auto end_shape = PartialShape{5}; - const auto p_end = std::make_shared(element::i64, end_shape); + const auto p_end = std::make_shared(element::i64, end_shape); p_end->set_friendly_name("end"); - const auto stride = op::Constant::create(element::i64, {5}, {1, 1, 1, 2, 2}); + const auto stride = ov::op::v0::Constant::create(element::i64, {5}, {1, 1, 1, 2, 2}); stride->set_friendly_name("stride"); const auto slice = make_shared(constant, @@ -2344,7 +2345,7 @@ TEST(constant_folding, strided_slice_all_ignore_mask_set_for_parameter_begin_end run_constant_folding(model); ASSERT_EQ(count_ops_of_type(model), 0); - ASSERT_EQ(count_ops_of_type(model), 1); + ASSERT_EQ(count_ops_of_type(model), 1); const auto new_const = get_result_constant(model); ASSERT_TRUE(new_const); @@ -2357,20 +2358,20 @@ TEST(constant_folding, strided_slice_all_ignore_mask_set_for_parameter_begin_end TEST(constant_folding, strided_slice_not_all_ignore_mask_set_for_parameter_begin_end) { const auto constant = - make_shared(element::i32, - Shape{1, 1, 2, 4, 2}, - std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}); + make_shared(element::i32, + Shape{1, 1, 2, 4, 2}, + std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}); constant->set_friendly_name("constant"); const auto begin_shape = PartialShape::dynamic(); - const auto p_begin = std::make_shared(element::i64, begin_shape); + const auto p_begin = std::make_shared(element::i64, begin_shape); p_begin->set_friendly_name("begin"); const auto end_shape = PartialShape{5}; - const auto p_end = std::make_shared(element::i64, end_shape); + const auto p_end = std::make_shared(element::i64, end_shape); p_end->set_friendly_name("end"); - const auto stride = op::Constant::create(element::i64, {5}, {1, 1, 1, 2, 2}); + const auto stride = ov::op::v0::Constant::create(element::i64, {5}, {1, 1, 1, 2, 2}); stride->set_friendly_name("stride"); const auto slice = make_shared(constant, @@ -2386,27 +2387,27 @@ TEST(constant_folding, strided_slice_not_all_ignore_mask_set_for_parameter_begin run_constant_folding(model); ASSERT_EQ(count_ops_of_type(model), 1); - ASSERT_EQ(count_ops_of_type(model), 2); + ASSERT_EQ(count_ops_of_type(model), 2); } TEST(constant_folding, strided_slice_not_ignored_dynamic_begin_from_shape_of) { const auto constant = - make_shared(element::i32, - Shape{1, 1, 2, 4, 2}, - std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}); + make_shared(element::i32, + Shape{1, 1, 2, 4, 2}, + std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}); constant->set_friendly_name("constant"); const auto begin_shape = PartialShape{0, -1, 0, 0, 0}; - const auto p_begin = std::make_shared(element::i64, begin_shape); - const auto shape_of_begin = std::make_shared(p_begin); + const auto p_begin = std::make_shared(element::i64, begin_shape); + const auto shape_of_begin = std::make_shared(p_begin); shape_of_begin->set_friendly_name("begin"); const auto end_shape = PartialShape{-1, 512, 2, 2, 16}; - const auto p_end = std::make_shared(element::i64, end_shape); - const auto shape_of_end = std::make_shared(p_end); + const auto p_end = std::make_shared(element::i64, end_shape); + const auto shape_of_end = std::make_shared(p_end); shape_of_end->set_friendly_name("end"); - const auto stride = op::Constant::create(element::i64, {5}, {1, 1, 1, 1, 1}); + const auto stride = ov::op::v0::Constant::create(element::i64, {5}, {1, 1, 1, 1, 1}); stride->set_friendly_name("stride"); const auto slice = make_shared(constant, @@ -2422,27 +2423,27 @@ TEST(constant_folding, strided_slice_not_ignored_dynamic_begin_from_shape_of) { run_constant_folding(model); ASSERT_EQ(count_ops_of_type(model), 1); - ASSERT_EQ(count_ops_of_type(model), 2); + ASSERT_EQ(count_ops_of_type(model), 2); } TEST(constant_folding, strided_slice_can_be_folded_but_is_blocked_by_shape_of_which_got_folding_disabled) { const auto constant = - make_shared(element::i32, - Shape{1, 1, 2, 4, 2}, - std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}); + make_shared(element::i32, + Shape{1, 1, 2, 4, 2}, + std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}); constant->set_friendly_name("constant"); const auto begin_shape = PartialShape{0, -1, 0, 0, 0}; - const auto p_begin = std::make_shared(element::i64, begin_shape); - const auto shape_of_begin = std::make_shared(p_begin); + const auto p_begin = std::make_shared(element::i64, begin_shape); + const auto shape_of_begin = std::make_shared(p_begin); shape_of_begin->set_friendly_name("begin"); const auto end_shape = PartialShape{-1, 512, 2, 2, 16}; - const auto p_end = std::make_shared(element::i64, end_shape); - const auto shape_of_end = std::make_shared(p_end); + const auto p_end = std::make_shared(element::i64, end_shape); + const auto shape_of_end = std::make_shared(p_end); shape_of_end->set_friendly_name("end"); - const auto stride = op::Constant::create(element::i64, {5}, {1, 1, 1, 1, 1}); + const auto stride = ov::op::v0::Constant::create(element::i64, {5}, {1, 1, 1, 1, 1}); stride->set_friendly_name("stride"); const auto slice = make_shared(constant, @@ -2462,27 +2463,27 @@ TEST(constant_folding, strided_slice_can_be_folded_but_is_blocked_by_shape_of_wh pass_manager.run_passes(model); ASSERT_EQ(count_ops_of_type(model), 1); - ASSERT_EQ(count_ops_of_type(model), 2); + ASSERT_EQ(count_ops_of_type(model), 2); } TEST(constant_folding, strided_slice_is_foldable_but_got_set_disable_constant_fold) { const auto constant = - make_shared(element::i32, - Shape{1, 1, 2, 4, 2}, - std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}); + make_shared(element::i32, + Shape{1, 1, 2, 4, 2}, + std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}); constant->set_friendly_name("constant"); const auto begin_shape = PartialShape{0, -1, 0, 0, 0}; - const auto p_begin = std::make_shared(element::i64, begin_shape); - const auto shape_of_begin = std::make_shared(p_begin); + const auto p_begin = std::make_shared(element::i64, begin_shape); + const auto shape_of_begin = std::make_shared(p_begin); shape_of_begin->set_friendly_name("begin"); const auto end_shape = PartialShape{-1, 512, 2, 2, 16}; - const auto p_end = std::make_shared(element::i64, end_shape); - const auto shape_of_end = std::make_shared(p_end); + const auto p_end = std::make_shared(element::i64, end_shape); + const auto shape_of_end = std::make_shared(p_end); shape_of_end->set_friendly_name("end"); - const auto stride = op::Constant::create(element::i64, {5}, {1, 1, 1, 1, 1}); + const auto stride = ov::op::v0::Constant::create(element::i64, {5}, {1, 1, 1, 1, 1}); stride->set_friendly_name("stride"); const auto slice = make_shared(constant, @@ -2500,7 +2501,7 @@ TEST(constant_folding, strided_slice_is_foldable_but_got_set_disable_constant_fo run_constant_folding(model); ASSERT_EQ(count_ops_of_type(model), 1); - ASSERT_EQ(count_ops_of_type(model), 2); + ASSERT_EQ(count_ops_of_type(model), 2); } TEST(constant_folding, constant_dyn_reshape) { @@ -2510,18 +2511,18 @@ TEST(constant_folding, constant_dyn_reshape) { Shape shape_shape{3}; vector values_shape{2, 4, 1}; - auto constant_in = make_shared(element::f32, shape_in, values_in); + auto constant_in = make_shared(element::f32, shape_in, values_in); constant_in->set_friendly_name("constant_in"); - auto constant_shape = make_shared(element::i64, shape_shape, values_shape); + auto constant_shape = make_shared(element::i64, shape_shape, values_shape); constant_shape->set_friendly_name("constant_shape"); auto dyn_reshape = make_shared(constant_in, constant_shape, false); dyn_reshape->set_friendly_name("test"); - auto f = make_shared(dyn_reshape, ParameterVector{}); + auto f = make_shared(dyn_reshape, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -2543,22 +2544,22 @@ TEST(constant_folding, constant_dyn_reshape_shape_not_originally_constant) { vector values_shape_a{1, 3, 0}; vector values_shape_b{1, 1, 1}; - auto constant_in = make_shared(element::f32, shape_in, values_in); + auto constant_in = make_shared(element::f32, shape_in, values_in); constant_in->set_friendly_name("constant_in"); - auto constant_shape_a = make_shared(element::i64, shape_shape, values_shape_a); + auto constant_shape_a = make_shared(element::i64, shape_shape, values_shape_a); constant_shape_a->set_friendly_name("constant_shape_a"); - auto constant_shape_b = make_shared(element::i64, shape_shape, values_shape_b); + auto constant_shape_b = make_shared(element::i64, shape_shape, values_shape_b); constant_shape_b->set_friendly_name("constant_shape_b"); auto add = std::make_shared(constant_shape_a, constant_shape_b); add->set_friendly_name("add"); auto dyn_reshape = make_shared(constant_in, add, false); dyn_reshape->set_friendly_name("test"); - auto f = make_shared(dyn_reshape, ParameterVector{}); + auto f = make_shared(dyn_reshape, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -2569,18 +2570,18 @@ TEST(constant_folding, constant_dyn_reshape_shape_not_originally_constant) { } TEST(constant_folding, const_reshape_no_data_copy) { - auto const_data = op::Constant::create(element::f32, Shape{1, 64}, {1}); - auto const_reshape = op::Constant::create(element::i64, Shape{2}, {2, 32}); + auto const_data = ov::op::v0::Constant::create(element::f32, Shape{1, 64}, {1}); + auto const_reshape = ov::op::v0::Constant::create(element::i64, Shape{2}, {2, 32}); auto reshape = std::make_shared(const_data, const_reshape, false); - auto consumer1 = std::make_shared(reshape); - auto consumer2 = std::make_shared(reshape); + auto consumer1 = std::make_shared(reshape); + auto consumer2 = std::make_shared(reshape); - auto f = std::make_shared(NodeVector{consumer1, consumer2}, ParameterVector{}); + auto f = std::make_shared(NodeVector{consumer1, consumer2}, ParameterVector{}); run_constant_folding(f); - auto const1 = std::dynamic_pointer_cast(consumer1->input_value(0).get_node_shared_ptr()); - auto const2 = std::dynamic_pointer_cast(consumer2->input_value(0).get_node_shared_ptr()); + auto const1 = std::dynamic_pointer_cast(consumer1->input_value(0).get_node_shared_ptr()); + auto const2 = std::dynamic_pointer_cast(consumer2->input_value(0).get_node_shared_ptr()); ASSERT_TRUE(const1); ASSERT_TRUE(const2); @@ -2589,18 +2590,18 @@ TEST(constant_folding, const_reshape_no_data_copy) { } TEST(constant_folding, const_squeeze_no_data_copy) { - auto const_data = op::Constant::create(element::f32, Shape{1, 64}, {1}); - auto const_reshape = op::Constant::create(element::i64, Shape{1}, {0}); + auto const_data = ov::op::v0::Constant::create(element::f32, Shape{1, 64}, {1}); + auto const_reshape = ov::op::v0::Constant::create(element::i64, Shape{1}, {0}); auto reshape = std::make_shared(const_data, const_reshape); - auto consumer1 = std::make_shared(reshape); - auto consumer2 = std::make_shared(reshape); + auto consumer1 = std::make_shared(reshape); + auto consumer2 = std::make_shared(reshape); - auto f = std::make_shared(NodeVector{consumer1, consumer2}, ParameterVector{}); + auto f = std::make_shared(NodeVector{consumer1, consumer2}, ParameterVector{}); run_constant_folding(f); - auto const1 = std::dynamic_pointer_cast(consumer1->input_value(0).get_node_shared_ptr()); - auto const2 = std::dynamic_pointer_cast(consumer2->input_value(0).get_node_shared_ptr()); + auto const1 = std::dynamic_pointer_cast(consumer1->input_value(0).get_node_shared_ptr()); + auto const2 = std::dynamic_pointer_cast(consumer2->input_value(0).get_node_shared_ptr()); ASSERT_TRUE(const1); ASSERT_TRUE(const2); @@ -2609,18 +2610,18 @@ TEST(constant_folding, const_squeeze_no_data_copy) { } TEST(constant_folding, const_unsqueeze_no_data_copy) { - auto const_data = op::Constant::create(element::f32, Shape{1, 64}, {1}); - auto const_reshape = op::Constant::create(element::i64, Shape{1}, {0}); + auto const_data = ov::op::v0::Constant::create(element::f32, Shape{1, 64}, {1}); + auto const_reshape = ov::op::v0::Constant::create(element::i64, Shape{1}, {0}); auto reshape = std::make_shared(const_data, const_reshape); - auto consumer1 = std::make_shared(reshape); - auto consumer2 = std::make_shared(reshape); + auto consumer1 = std::make_shared(reshape); + auto consumer2 = std::make_shared(reshape); - auto f = std::make_shared(NodeVector{consumer1, consumer2}, ParameterVector{}); + auto f = std::make_shared(NodeVector{consumer1, consumer2}, ParameterVector{}); run_constant_folding(f); - auto const1 = std::dynamic_pointer_cast(consumer1->input_value(0).get_node_shared_ptr()); - auto const2 = std::dynamic_pointer_cast(consumer2->input_value(0).get_node_shared_ptr()); + auto const1 = std::dynamic_pointer_cast(consumer1->input_value(0).get_node_shared_ptr()); + auto const2 = std::dynamic_pointer_cast(consumer2->input_value(0).get_node_shared_ptr()); ASSERT_TRUE(const1); ASSERT_TRUE(const2); @@ -2635,18 +2636,18 @@ TEST(constant_folding, constant_transpose) { Shape shape_perm{2}; vector values_perm{1, 0}; - auto constant_in = make_shared(element::f64, shape_in, values_in); + auto constant_in = make_shared(element::f64, shape_in, values_in); constant_in->set_friendly_name("constant_in"); - auto constant_perm = make_shared(element::i64, shape_perm, values_perm); + auto constant_perm = make_shared(element::i64, shape_perm, values_perm); constant_perm->set_friendly_name("constant_perm"); - auto transpose = make_shared(constant_in, constant_perm); + auto transpose = make_shared(constant_in, constant_perm); transpose->set_friendly_name("test"); - auto f = make_shared(transpose, ParameterVector{}); + auto f = make_shared(transpose, ParameterVector{}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -2663,20 +2664,20 @@ void range_test(T start, T stop, T step, const vector& values_expected) { vector values_stop{stop}; vector values_step{step}; - auto constant_start = make_shared(ov::element::from(), Shape{}, values_start); + auto constant_start = make_shared(ov::element::from(), Shape{}, values_start); constant_start->set_friendly_name("constant_start"); - auto constant_stop = make_shared(ov::element::from(), Shape{}, values_stop); + auto constant_stop = make_shared(ov::element::from(), Shape{}, values_stop); constant_stop->set_friendly_name("constant_stop"); - auto constant_step = make_shared(ov::element::from(), Shape{}, values_step); + auto constant_step = make_shared(ov::element::from(), Shape{}, values_step); constant_step->set_friendly_name("constant_step"); - auto range = make_shared(constant_start, constant_stop, constant_step); + auto range = make_shared(constant_start, constant_stop, constant_step); range->set_friendly_name("test"); - auto f = make_shared(range, ParameterVector{}); + auto f = make_shared(range, ParameterVector{}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -2705,20 +2706,20 @@ TEST(constant_folding, constant_v1_select) { vector values_t{1, 2, 3, 4}; vector values_f{11, 12, 13, 14, 15, 16, 17, 18}; - auto constant_selection = make_shared(element::boolean, Shape{4}, values_selection); + auto constant_selection = make_shared(element::boolean, Shape{4}, values_selection); constant_selection->set_friendly_name("constant_selection"); - auto constant_t = make_shared(element::i64, Shape{4}, values_t); + auto constant_t = make_shared(element::i64, Shape{4}, values_t); constant_t->set_friendly_name("constant_t"); - auto constant_f = make_shared(element::i64, Shape{2, 4}, values_f); + auto constant_f = make_shared(element::i64, Shape{2, 4}, values_f); constant_f->set_friendly_name("constant_f"); auto select = make_shared(constant_selection, constant_t, constant_f); select->set_friendly_name("test"); - auto f = make_shared(select, ParameterVector{}); + auto f = make_shared(select, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -2731,17 +2732,17 @@ TEST(constant_folding, constant_v1_select) { TEST(constant_folding, constant_v1_split) { vector data{.1f, .2f, .3f, .4f, .5f, .6f}; - const auto const_data = op::Constant::create(element::f32, Shape{data.size()}, data); - const auto const_axis = op::Constant::create(element::i64, Shape{}, {0}); + const auto const_data = ov::op::v0::Constant::create(element::f32, Shape{data.size()}, data); + const auto const_axis = ov::op::v0::Constant::create(element::i64, Shape{}, {0}); const auto num_splits = 3; auto split_v1 = make_shared(const_data, const_axis, num_splits); - auto f = make_shared(split_v1->outputs(), ParameterVector{}); + auto f = make_shared(split_v1->outputs(), ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), num_splits); + ASSERT_EQ(count_ops_of_type(f), num_splits); auto res1 = get_result_constant(f); auto res2 = get_result_constant(f, 1); @@ -2760,17 +2761,17 @@ TEST(constant_folding, constant_v1_split) { TEST(constant_folding, constant_v1_split_specialized) { vector data{.1f, .2f, .3f, .4f, .5f, .6f}; - const auto const_data = op::Constant::create(element::f32, Shape{data.size()}, data); - const auto const_axis = op::Constant::create(element::i64, Shape{}, {0}); + const auto const_data = ov::op::v0::Constant::create(element::f32, Shape{data.size()}, data); + const auto const_axis = ov::op::v0::Constant::create(element::i64, Shape{}, {0}); const auto num_splits = 3; auto split_v1 = make_shared(const_data, const_axis, num_splits); - auto f = make_shared(split_v1->outputs(), ParameterVector{}); + auto f = make_shared(split_v1->outputs(), ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), num_splits); + ASSERT_EQ(count_ops_of_type(f), num_splits); auto res1 = get_result_constant(f); auto res2 = get_result_constant(f, 1); @@ -2796,20 +2797,20 @@ TEST(constant_folding, constant_v1_split_axis_1_4_splits) { 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63}; - const auto const_data = op::Constant::create(element::i64, Shape{4, 4, 4}, data); + const auto const_data = ov::op::v0::Constant::create(element::i64, Shape{4, 4, 4}, data); const_data->set_friendly_name("const_data"); - const auto const_axis = op::Constant::create(element::i64, Shape{}, {1}); + const auto const_axis = ov::op::v0::Constant::create(element::i64, Shape{}, {1}); const_axis->set_friendly_name("const_axis"); const auto num_splits = 4; auto split_v1 = make_shared(const_data, const_axis, num_splits); split_v1->set_friendly_name("test"); - auto f = make_shared(split_v1->outputs(), ParameterVector{}); + auto f = make_shared(split_v1->outputs(), ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), num_splits); + ASSERT_EQ(count_ops_of_type(f), num_splits); auto res1 = get_result_constant(f); auto res2 = get_result_constant(f, 1); @@ -2843,17 +2844,17 @@ TEST(constant_folding, constant_v1_split_axis_1_2_splits) { 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63}; - const auto const_data = op::Constant::create(element::i64, Shape{4, 4, 4}, data); - const auto const_axis = op::Constant::create(element::i64, Shape{}, {1}); + const auto const_data = ov::op::v0::Constant::create(element::i64, Shape{4, 4, 4}, data); + const auto const_axis = ov::op::v0::Constant::create(element::i64, Shape{}, {1}); const auto num_splits = 2; auto split_v1 = make_shared(const_data, const_axis, num_splits); - auto f = make_shared(split_v1->outputs(), ParameterVector{}); + auto f = make_shared(split_v1->outputs(), ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), num_splits); + ASSERT_EQ(count_ops_of_type(f), num_splits); auto res1 = get_result_constant(f); auto res2 = get_result_constant(f, 1); @@ -2879,18 +2880,19 @@ TEST(constant_folding, constant_v1_variadic_split_axis_1_2_splits) { 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63}; - const auto const_data = op::Constant::create(element::i64, Shape{4, 4, 4}, data); - const auto const_axis = op::Constant::create(element::i16, Shape{}, {1}); + const auto const_data = ov::op::v0::Constant::create(element::i64, Shape{4, 4, 4}, data); + const auto const_axis = ov::op::v0::Constant::create(element::i16, Shape{}, {1}); vector values_lengths{3, 1}; - auto constant_lengths = make_shared(element::i64, Shape{values_lengths.size()}, values_lengths); + auto constant_lengths = + make_shared(element::i64, Shape{values_lengths.size()}, values_lengths); auto variadic_split_v1 = make_shared(const_data, const_axis, constant_lengths); - auto f = make_shared(variadic_split_v1->outputs(), ParameterVector{}); + auto f = make_shared(variadic_split_v1->outputs(), ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), values_lengths.size()); + ASSERT_EQ(count_ops_of_type(f), values_lengths.size()); auto res1 = get_result_constant(f); auto res2 = get_result_constant(f, 1); @@ -2915,18 +2917,19 @@ TEST(constant_folding, constant_v1_variadic_split_axis_1_3_splits_neg_length) { 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63}; - const auto const_data = op::Constant::create(element::i64, Shape{4, 4, 4}, data); - const auto const_axis = op::Constant::create(element::i32, Shape{}, {1}); + const auto const_data = ov::op::v0::Constant::create(element::i64, Shape{4, 4, 4}, data); + const auto const_axis = ov::op::v0::Constant::create(element::i32, Shape{}, {1}); vector values_lengths{1, 1, -1}; - auto constant_lengths = make_shared(element::i64, Shape{values_lengths.size()}, values_lengths); + auto constant_lengths = + make_shared(element::i64, Shape{values_lengths.size()}, values_lengths); auto variadic_split_v1 = make_shared(const_data, const_axis, constant_lengths); - auto f = make_shared(variadic_split_v1->outputs(), ParameterVector{}); + auto f = make_shared(variadic_split_v1->outputs(), ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), values_lengths.size()); + ASSERT_EQ(count_ops_of_type(f), values_lengths.size()); auto res1 = get_result_constant(f); auto res2 = get_result_constant(f, 1); @@ -2950,19 +2953,19 @@ TEST(constant_folding, constant_v1_one_hot) { const float on_value = 1.123f; const float off_value = 0.321f; - const auto indices_const = op::Constant::create(element::i64, Shape{3}, indices); - const auto depth_const = op::Constant::create(element::i64, Shape{}, {3}); - const auto on_const = op::Constant::create(element::f32, Shape{}, {on_value}); - const auto off_const = op::Constant::create(element::f32, Shape{}, {off_value}); + const auto indices_const = ov::op::v0::Constant::create(element::i64, Shape{3}, indices); + const auto depth_const = ov::op::v0::Constant::create(element::i64, Shape{}, {3}); + const auto on_const = ov::op::v0::Constant::create(element::f32, Shape{}, {on_value}); + const auto off_const = ov::op::v0::Constant::create(element::f32, Shape{}, {off_value}); int64_t axis = 1; auto one_hot_v1 = make_shared(indices_const, depth_const, on_const, off_const, axis); - auto f = make_shared(one_hot_v1, ParameterVector{}); + auto f = make_shared(one_hot_v1, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto res = get_result_constant(f); ASSERT_TRUE(res); @@ -2978,19 +2981,19 @@ TEST(constant_folding, constant_v1_one_hot_negative_axes) { const int32_t on_value = 4; const int32_t off_value = 1; - const auto indices_const = op::Constant::create(element::i64, Shape{4}, indices); - const auto depth_const = op::Constant::create(element::i64, Shape{}, {3}); - const auto on_const = op::Constant::create(element::i32, Shape{}, {on_value}); - const auto off_const = op::Constant::create(element::i32, Shape{}, {off_value}); + const auto indices_const = ov::op::v0::Constant::create(element::i64, Shape{4}, indices); + const auto depth_const = ov::op::v0::Constant::create(element::i64, Shape{}, {3}); + const auto on_const = ov::op::v0::Constant::create(element::i32, Shape{}, {on_value}); + const auto off_const = ov::op::v0::Constant::create(element::i32, Shape{}, {off_value}); int64_t axis = -1; auto one_hot_v1 = make_shared(indices_const, depth_const, on_const, off_const, axis); - auto f = make_shared(one_hot_v1, ParameterVector{}); + auto f = make_shared(one_hot_v1, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto res = get_result_constant(f); ASSERT_TRUE(res); @@ -3016,24 +3019,24 @@ TEST(constant_folding, constant_v1_one_hot_negative_axes_2) { auto on_value = true; auto off_value = false; - const auto indices_const = op::Constant::create(element::i64, Shape{2, 2}, indices); + const auto indices_const = ov::op::v0::Constant::create(element::i64, Shape{2, 2}, indices); indices_const->set_friendly_name("indices_const"); - const auto depth_const = op::Constant::create(element::i64, Shape{}, {3}); + const auto depth_const = ov::op::v0::Constant::create(element::i64, Shape{}, {3}); depth_const->set_friendly_name("depth_const"); - const auto on_const = op::Constant::create(element::boolean, Shape{}, {on_value}); + const auto on_const = ov::op::v0::Constant::create(element::boolean, Shape{}, {on_value}); on_const->set_friendly_name("on_const"); - const auto off_const = op::Constant::create(element::boolean, Shape{}, {off_value}); + const auto off_const = ov::op::v0::Constant::create(element::boolean, Shape{}, {off_value}); off_const->set_friendly_name("off_const"); int64_t axis = -1; auto one_hot_v1 = make_shared(indices_const, depth_const, on_const, off_const, axis); one_hot_v1->set_friendly_name("test"); - auto f = make_shared(one_hot_v1, ParameterVector{}); + auto f = make_shared(one_hot_v1, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto res = get_result_constant(f); ASSERT_TRUE(res); @@ -3061,19 +3064,19 @@ TEST(constant_folding, constant_tile_1d) { Shape shape_out{4}; vector values_in{0, 1}; - auto data = make_shared(element::i32, shape_in, values_in); + auto data = make_shared(element::i32, shape_in, values_in); data->set_friendly_name("data"); vector values_repeats{2}; - auto repeats = make_shared(element::i64, shape_repeats, values_repeats); + auto repeats = make_shared(element::i64, shape_repeats, values_repeats); repeats->set_friendly_name("repeats"); auto tile = make_shared(data, repeats); tile->set_friendly_name("test"); - auto f = make_shared(tile, ParameterVector{}); + auto f = make_shared(tile, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -3090,19 +3093,19 @@ TEST(constant_folding, constant_tile_3d_small_data_rank) { Shape shape_out{2, 2, 4}; vector values_in{0, 1}; - auto data = make_shared(element::i32, shape_in, values_in); + auto data = make_shared(element::i32, shape_in, values_in); data->set_friendly_name("data"); vector values_repeats{2, 2, 2}; - auto repeats = make_shared(element::i64, shape_repeats, values_repeats); + auto repeats = make_shared(element::i64, shape_repeats, values_repeats); repeats->set_friendly_name("repeats"); auto tile = make_shared(data, repeats); tile->set_friendly_name("test"); - auto f = make_shared(tile, ParameterVector{}); + auto f = make_shared(tile, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -3119,19 +3122,19 @@ TEST(constant_folding, constant_tile_3d_few_repeats) { Shape shape_out{2, 2, 3}; vector values_in{1, 2, 3, 4, 5, 6}; - auto data = make_shared(element::i32, shape_in, values_in); + auto data = make_shared(element::i32, shape_in, values_in); data->set_friendly_name("data"); vector values_repeats{2, 1}; - auto repeats = make_shared(element::i64, shape_repeats, values_repeats); + auto repeats = make_shared(element::i64, shape_repeats, values_repeats); repeats->set_friendly_name("repeats"); auto tile = make_shared(data, repeats); tile->set_friendly_name("test"); - auto f = make_shared(tile, ParameterVector{}); + auto f = make_shared(tile, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -3148,19 +3151,19 @@ TEST(constant_folding, constant_tile_1d_0_repeats) { Shape shape_out{}; vector values_in{0, 1}; - auto data = make_shared(element::i32, shape_in, values_in); + auto data = make_shared(element::i32, shape_in, values_in); data->set_friendly_name("data"); vector values_repeats{0}; - auto repeats = make_shared(element::i64, shape_repeats, values_repeats); + auto repeats = make_shared(element::i64, shape_repeats, values_repeats); repeats->set_friendly_name("repeats"); auto tile = make_shared(data, repeats); tile->set_friendly_name("test"); - auto f = make_shared(tile, ParameterVector{}); + auto f = make_shared(tile, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -3177,19 +3180,19 @@ TEST(constant_folding, constant_tile_2d_0_repeats) { Shape shape_out{}; vector values_in{0, 1, 2, 3}; - auto data = make_shared(element::i32, shape_in, values_in); + auto data = make_shared(element::i32, shape_in, values_in); data->set_friendly_name("data"); vector values_repeats{0, 0}; - auto repeats = make_shared(element::i64, shape_repeats, values_repeats); + auto repeats = make_shared(element::i64, shape_repeats, values_repeats); repeats->set_friendly_name("repeats"); auto tile = make_shared(data, repeats); tile->set_friendly_name("test"); - auto f = make_shared(tile, ParameterVector{}); + auto f = make_shared(tile, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -3206,19 +3209,19 @@ TEST(constant_folding, constant_tile_0_rank_data) { Shape shape_out{4}; vector values_in{1}; - auto data = make_shared(element::i32, shape_in, values_in); + auto data = make_shared(element::i32, shape_in, values_in); data->set_friendly_name("data"); vector values_repeats{4}; - auto repeats = make_shared(element::i64, shape_repeats, values_repeats); + auto repeats = make_shared(element::i64, shape_repeats, values_repeats); repeats->set_friendly_name("repeats"); auto tile = make_shared(data, repeats); tile->set_friendly_name("test"); - auto f = make_shared(tile, ParameterVector{}); + auto f = make_shared(tile, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -3230,18 +3233,18 @@ TEST(constant_folding, constant_tile_0_rank_data) { } TEST(constant_folding, constant_non_zero_0D) { - auto data = op::Constant::create(element::i32, Shape{}, {1}); + auto data = ov::op::v0::Constant::create(element::i32, Shape{}, {1}); data->set_friendly_name("data"); auto non_zero = make_shared(data); non_zero->set_friendly_name("test"); - auto f = make_shared(non_zero, ParameterVector{}); + auto f = make_shared(non_zero, ParameterVector{}); run_constant_folding(f); // Fold into constant with shape of {1, 1} for scalar input with // non-zero value ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); const auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -3255,16 +3258,16 @@ TEST(constant_folding, constant_non_zero_0D) { TEST(constant_folding, constant_non_zero_1D) { vector values_in{0, 1, 0, 1}; - auto data = make_shared(element::i32, Shape{4}, values_in); + auto data = make_shared(element::i32, Shape{4}, values_in); data->set_friendly_name("data"); auto non_zero = make_shared(data); non_zero->set_friendly_name("test"); - auto f = make_shared(non_zero, ParameterVector{}); + auto f = make_shared(non_zero, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); const auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -3278,16 +3281,16 @@ TEST(constant_folding, constant_non_zero_1D) { TEST(constant_folding, constant_non_zero_int32_output_type) { vector values_in{0, 1, 0, 1}; - auto data = make_shared(element::i32, Shape{4}, values_in); + auto data = make_shared(element::i32, Shape{4}, values_in); data->set_friendly_name("data"); auto non_zero = make_shared(data, element::i32); non_zero->set_friendly_name("test"); - auto f = make_shared(non_zero, ParameterVector{}); + auto f = make_shared(non_zero, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); const auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -3302,16 +3305,16 @@ TEST(constant_folding, constant_non_zero_int32_output_type) { TEST(constant_folding, constant_non_zero_1D_all_indices) { const vector values_in{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f}; - const auto data = make_shared(element::f32, Shape{values_in.size()}, values_in); + const auto data = make_shared(element::f32, Shape{values_in.size()}, values_in); data->set_friendly_name("data"); const auto non_zero = make_shared(data); non_zero->set_friendly_name("test"); - auto f = make_shared(non_zero, ParameterVector{}); + auto f = make_shared(non_zero, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); const auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -3325,16 +3328,16 @@ TEST(constant_folding, constant_non_zero_1D_all_indices) { TEST(constant_folding, constant_non_zero_2D) { vector values_in{1, 0, 0, 0, 1, 0, 1, 1, 0}; - auto data = make_shared(element::i32, Shape{3, 3}, values_in); + auto data = make_shared(element::i32, Shape{3, 3}, values_in); data->set_friendly_name("data"); auto non_zero = make_shared(data); non_zero->set_friendly_name("test"); - auto f = make_shared(non_zero, ParameterVector{}); + auto f = make_shared(non_zero, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); const auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -3348,16 +3351,16 @@ TEST(constant_folding, constant_non_zero_2D) { TEST(constant_folding, DISABLED_constant_non_zero_2D_all_indices) { const vector values_in{1, 1, 1, 1, 1, 1, 1, 1, 1}; - const auto data = make_shared(element::i8, Shape{3, 3}, values_in); + const auto data = make_shared(element::i8, Shape{3, 3}, values_in); data->set_friendly_name("data"); const auto non_zero = make_shared(data); non_zero->set_friendly_name("test"); - auto f = make_shared(non_zero, ParameterVector{}); + auto f = make_shared(non_zero, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); const auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -3371,17 +3374,17 @@ TEST(constant_folding, DISABLED_constant_non_zero_2D_all_indices) { TEST(constant_folding, DISABLED_constant_non_zero_2D_all_zeros) { const vector values_in{0, 0, 0, 0, 0, 0}; - const auto data = make_shared(element::u8, Shape{2, 3}, values_in); + const auto data = make_shared(element::u8, Shape{2, 3}, values_in); data->set_friendly_name("data"); const auto non_zero = make_shared(data); non_zero->set_friendly_name("test"); - auto f = make_shared(non_zero, ParameterVector{}); + auto f = make_shared(non_zero, ParameterVector{}); run_constant_folding(f); // fold into Constant with shape of {0} ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); const auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -3391,16 +3394,16 @@ TEST(constant_folding, DISABLED_constant_non_zero_2D_all_zeros) { TEST(constant_folding, constant_non_zero_3D) { vector values_in{1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0}; - auto data = make_shared(element::i32, Shape{2, 3, 3}, values_in); + auto data = make_shared(element::i32, Shape{2, 3, 3}, values_in); data->set_friendly_name("data"); auto non_zero = make_shared(data); non_zero->set_friendly_name("test"); - auto f = make_shared(non_zero, ParameterVector{}); + auto f = make_shared(non_zero, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); const auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -3418,24 +3421,25 @@ TEST(constant_folding, constant_scatter_elements_update_basic) { const Shape indices_shape{2, 3}; const auto data_const = - op::Constant::create(element::f32, data_shape, std::vector(shape_size(data_shape), 0.f)); + ov::op::v0::Constant::create(element::f32, data_shape, std::vector(shape_size(data_shape), 0.f)); data_const->set_friendly_name("data_const"); - const auto indices_const = op::Constant::create(element::i32, indices_shape, {1, 0, 2, 0, 2, 1}); + const auto indices_const = ov::op::v0::Constant::create(element::i32, indices_shape, {1, 0, 2, 0, 2, 1}); indices_const->set_friendly_name("indices_const"); - const auto updates_const = op::Constant::create(element::f32, indices_shape, {1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f}); + const auto updates_const = + ov::op::v0::Constant::create(element::f32, indices_shape, {1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f}); updates_const->set_friendly_name("updates_const"); - const auto axis_const = op::Constant::create(element::i64, Shape{}, {0}); + const auto axis_const = ov::op::v0::Constant::create(element::i64, Shape{}, {0}); axis_const->set_friendly_name("axis_const"); auto scatter_elem_updt = make_shared(data_const, indices_const, updates_const, axis_const); scatter_elem_updt->set_friendly_name("test"); - auto f = make_shared(scatter_elem_updt, ParameterVector{}); + auto f = make_shared(scatter_elem_updt, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto result_node = get_result_constant(f); ASSERT_TRUE(result_node); @@ -3450,19 +3454,20 @@ TEST(constant_folding, constant_scatter_elements_update_negative_axis) { const Shape indices_shape{2, 3}; const auto data_const = - op::Constant::create(element::f32, data_shape, std::vector(shape_size(data_shape), 0.f)); - const auto indices_const = op::Constant::create(element::i32, indices_shape, {1, 0, 2, 0, 2, 1}); - const auto updates_const = op::Constant::create(element::f32, indices_shape, {1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f}); - const auto axis_const = op::Constant::create(element::i64, Shape{}, {-1}); + ov::op::v0::Constant::create(element::f32, data_shape, std::vector(shape_size(data_shape), 0.f)); + const auto indices_const = ov::op::v0::Constant::create(element::i32, indices_shape, {1, 0, 2, 0, 2, 1}); + const auto updates_const = + ov::op::v0::Constant::create(element::f32, indices_shape, {1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f}); + const auto axis_const = ov::op::v0::Constant::create(element::i64, Shape{}, {-1}); auto scatter_elem_updt = make_shared(data_const, indices_const, updates_const, axis_const); - auto f = make_shared(scatter_elem_updt, ParameterVector{}); + auto f = make_shared(scatter_elem_updt, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto result_node = get_result_constant(f); ASSERT_TRUE(result_node); @@ -3476,19 +3481,20 @@ TEST(constant_folding, constant_scatter_elements_update_1d_axis) { const Shape indices_shape{2, 3}; const auto data_const = - op::Constant::create(element::f32, data_shape, std::vector(shape_size(data_shape), 0.f)); - const auto indices_const = op::Constant::create(element::i32, indices_shape, {1, 0, 2, 0, 2, 1}); - const auto updates_const = op::Constant::create(element::f32, indices_shape, {1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f}); - const auto axis_const = op::Constant::create(element::i64, Shape{1}, {0}); + ov::op::v0::Constant::create(element::f32, data_shape, std::vector(shape_size(data_shape), 0.f)); + const auto indices_const = ov::op::v0::Constant::create(element::i32, indices_shape, {1, 0, 2, 0, 2, 1}); + const auto updates_const = + ov::op::v0::Constant::create(element::f32, indices_shape, {1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f}); + const auto axis_const = ov::op::v0::Constant::create(element::i64, Shape{1}, {0}); auto scatter_elem_updt = make_shared(data_const, indices_const, updates_const, axis_const); - auto f = make_shared(scatter_elem_updt, ParameterVector{}); + auto f = make_shared(scatter_elem_updt, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto result_node = get_result_constant(f); ASSERT_TRUE(result_node); @@ -3502,20 +3508,21 @@ TEST(constant_folding, constant_scatter_elements_update_3d_i16) { const Shape indices_shape{2, 2, 3}; const auto data_const = - op::Constant::create(element::i16, data_shape, std::vector(shape_size(data_shape), 0)); - const auto indices_const = op::Constant::create(element::i16, indices_shape, {1, 0, 2, 0, 2, 1, 2, 2, 2, 0, 1, 0}); + ov::op::v0::Constant::create(element::i16, data_shape, std::vector(shape_size(data_shape), 0)); + const auto indices_const = + ov::op::v0::Constant::create(element::i16, indices_shape, {1, 0, 2, 0, 2, 1, 2, 2, 2, 0, 1, 0}); const auto updates_const = - op::Constant::create(element::i16, indices_shape, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}); - const auto axis_const = op::Constant::create(element::i64, Shape{}, {1}); + ov::op::v0::Constant::create(element::i16, indices_shape, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}); + const auto axis_const = ov::op::v0::Constant::create(element::i64, Shape{}, {1}); auto scatter_elem_updt = make_shared(data_const, indices_const, updates_const, axis_const); - auto f = make_shared(scatter_elem_updt, ParameterVector{}); + auto f = make_shared(scatter_elem_updt, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto result_node = get_result_constant(f); ASSERT_TRUE(result_node); @@ -3529,19 +3536,19 @@ TEST(constant_folding, constant_scatter_elements_update_one_elem) { const Shape indices_shape{1, 1, 1}; const auto input_data = std::vector(shape_size(data_shape), 0); - const auto data_const = op::Constant::create(element::i32, data_shape, input_data); - const auto indices_const = op::Constant::create(element::i32, indices_shape, {1}); - const auto updates_const = op::Constant::create(element::i32, indices_shape, {2}); - const auto axis_const = op::Constant::create(element::i64, Shape{}, {0}); + const auto data_const = ov::op::v0::Constant::create(element::i32, data_shape, input_data); + const auto indices_const = ov::op::v0::Constant::create(element::i32, indices_shape, {1}); + const auto updates_const = ov::op::v0::Constant::create(element::i32, indices_shape, {2}); + const auto axis_const = ov::op::v0::Constant::create(element::i64, Shape{}, {0}); auto scatter_elem_updt = make_shared(data_const, indices_const, updates_const, axis_const); - auto f = make_shared(scatter_elem_updt, ParameterVector{}); + auto f = make_shared(scatter_elem_updt, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto result_node = get_result_constant(f); ASSERT_TRUE(result_node); @@ -3557,18 +3564,18 @@ void test_constant_folding_reshape_v1(Shape& shape_in, Shape shape_shape, vector values_shape, bool zero_flag = false) { - auto constant_in = make_shared(element::f32, shape_in, values_in); + auto constant_in = make_shared(element::f32, shape_in, values_in); constant_in->set_friendly_name("constant_in"); - auto constant_shape = make_shared(element::i64, shape_shape, values_shape); + auto constant_shape = make_shared(element::i64, shape_shape, values_shape); constant_shape->set_friendly_name("constant_shape"); auto dyn_reshape = make_shared(constant_in, constant_shape, zero_flag); dyn_reshape->set_friendly_name("test"); - auto f = make_shared(dyn_reshape, ParameterVector{}); + auto f = make_shared(dyn_reshape, ParameterVector{}); run_constant_folding(f); ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 1); + ASSERT_EQ(count_ops_of_type(f), 1); auto new_const = get_result_constant(f); ASSERT_TRUE(new_const); @@ -3605,27 +3612,27 @@ TEST(constant_folding, constant_dyn_reshape_v1_pattern_with_zero_dims) { } TEST(constant_folding, disable_constant_folding) { - auto data = std::make_shared(element::f16, Shape{1, 3, 22, 22}); + auto data = std::make_shared(element::f16, Shape{1, 3, 22, 22}); // In this test case following sub-graph will be consumed by Interpolate, so during shape inference Interpolate // will request values from this sub-graph and ConstantFolding pass will try to use this pre-calculated values // to fold it. But in our case we are disabling CF for this sub-graph first and then enable CF to check that all // checks inside ConstantFolding transformation are working and doesn't cache anytihng. auto gather = ov::op::util::node_to_get_shape_value_of_indices_from_shape_source(data, {2, 3}); - auto convert = std::make_shared(gather, element::f16); - auto divide_constant = op::Constant::create(element::f16, Shape{1}, {0.5}); - auto divide = std::make_shared(convert, divide_constant); - auto convert_after = std::make_shared(divide, element::i32); + auto convert = std::make_shared(gather, element::f16); + auto divide_constant = ov::op::v0::Constant::create(element::f16, Shape{1}, {0.5}); + auto divide = std::make_shared(convert, divide_constant); + auto convert_after = std::make_shared(divide, element::i32); - opset1::Interpolate::Attributes interp_attr; + op::v0::Interpolate::Attributes interp_attr; interp_attr.antialias = false; interp_attr.axes = {2, 3}; interp_attr.mode = "nearest"; interp_attr.pads_begin = {0, 0, 0, 0}; interp_attr.pads_end = {0, 0, 0, 0}; - auto interpolate = std::make_shared(data, convert_after, interp_attr); - auto f = std::make_shared(NodeVector{interpolate}, ParameterVector{data}); + auto interpolate = std::make_shared(data, convert_after, interp_attr); + auto f = std::make_shared(NodeVector{interpolate}, ParameterVector{data}); ov::disable_constant_folding(convert); @@ -3638,7 +3645,7 @@ TEST(constant_folding, disable_constant_folding) { run_constant_folding(f); // After we enabled CF the sub-graph will be folded to Constant - ASSERT_TRUE(ov::is_type(interpolate->get_input_node_shared_ptr(1))); + ASSERT_TRUE(ov::is_type(interpolate->get_input_node_shared_ptr(1))); // Check that DisableConstantFolding attribute wasn't propagated to some other nodes during CF for (auto node : f->get_ordered_ops()) { @@ -3649,12 +3656,12 @@ TEST(constant_folding, disable_constant_folding) { TEST(constant_folding, disable_constant_folding_simple) { // This test case checks the behaviour of CF pass when output values are not precalculated // so CF triggers another branch where it goes through nodes and trying to fold one by one. - auto data = std::make_shared(element::f32, Shape{1, 3, 22, 22}); - auto reshape = std::make_shared(op::Constant::create(element::f32, Shape{3}, {1, 2, 3}), - op::Constant::create(element::i64, Shape{3}, {3, 1, 1}), + auto data = std::make_shared(element::f32, Shape{1, 3, 22, 22}); + auto reshape = std::make_shared(ov::op::v0::Constant::create(element::f32, Shape{3}, {1, 2, 3}), + ov::op::v0::Constant::create(element::i64, Shape{3}, {3, 1, 1}), true); - auto divide = std::make_shared(data, reshape); - auto f = std::make_shared(NodeVector{divide}, ParameterVector{data}); + auto divide = std::make_shared(data, reshape); + auto f = std::make_shared(NodeVector{divide}, ParameterVector{data}); ov::disable_constant_folding(reshape); @@ -3668,7 +3675,7 @@ TEST(constant_folding, disable_constant_folding_simple) { run_constant_folding(f); // After we enabled CF the sub-graph will be folded to Constant - ASSERT_TRUE(ov::is_type(divide->get_input_node_shared_ptr(1))); + ASSERT_TRUE(ov::is_type(divide->get_input_node_shared_ptr(1))); // Check that DisableConstantFolding attribute wasn't propagated to some other nodes during CF for (auto node : f->get_ordered_ops()) { @@ -3677,12 +3684,12 @@ TEST(constant_folding, disable_constant_folding_simple) { } TEST(constant_folding, disable_constant_folding_check) { - auto data = std::make_shared(element::f32, Shape{1, 3, 22, 22}); - auto shapeof1 = std::make_shared(data); - auto reshape1 = std::make_shared(data, shapeof1, true); - auto shapeof2 = std::make_shared(reshape1); - auto reshape2 = std::make_shared(reshape1, shapeof2, true); - auto f = std::make_shared(NodeVector{reshape2}, ParameterVector{data}); + auto data = std::make_shared(element::f32, Shape{1, 3, 22, 22}); + auto shapeof1 = std::make_shared(data); + auto reshape1 = std::make_shared(data, shapeof1, true); + auto shapeof2 = std::make_shared(reshape1); + auto reshape2 = std::make_shared(reshape1, shapeof2, true); + auto f = std::make_shared(NodeVector{reshape2}, ParameterVector{data}); ov::disable_constant_folding(shapeof1); @@ -3700,26 +3707,26 @@ TEST(constant_folding, disable_constant_folding_check) { ASSERT_TRUE(shapeof2->get_rt_info().count("can_be_folded")); ASSERT_TRUE(shapeof2->get_rt_info().at("can_be_folded").as()); - ASSERT_TRUE(ov::is_type(reshape2->get_input_node_shared_ptr(1))); + ASSERT_TRUE(ov::is_type(reshape2->get_input_node_shared_ptr(1))); } TEST(constant_folding, constant_loop) { - auto X = make_shared(element::f32, Shape{2, 1, 3}, std::vector{0, 1, 2, 3, 4, 5}); - auto Y = make_shared(element::f32, Shape{1, 1, 3}, std::vector{1, 2, 3}); + auto X = make_shared(element::f32, Shape{2, 1, 3}, std::vector{0, 1, 2, 3, 4, 5}); + auto Y = make_shared(element::f32, Shape{1, 1, 3}, std::vector{1, 2, 3}); // Body parameters - auto Xi = make_shared(element::f32, PartialShape::dynamic()); - auto Yi = make_shared(element::f32, PartialShape::dynamic()); - auto body_condition = std::make_shared(ngraph::element::boolean, ngraph::Shape{1}, true); + auto Xi = make_shared(element::f32, PartialShape::dynamic()); + auto Yi = make_shared(element::f32, PartialShape::dynamic()); + auto body_condition = std::make_shared(ov::element::boolean, ov::Shape{1}, true); - auto trip_count = std::make_shared(ngraph::element::i64, ngraph::Shape{1}, 2); - auto exec_condition = std::make_shared(ngraph::element::boolean, ngraph::Shape{1}, true); + auto trip_count = std::make_shared(ov::element::i64, ov::Shape{1}, 2); + auto exec_condition = std::make_shared(ov::element::boolean, ov::Shape{1}, true); // Body - auto sum = make_shared(Xi, Yi); - auto body = make_shared(OutputVector{body_condition, sum}, ParameterVector{Xi, Yi}); - auto loop = make_shared(trip_count, exec_condition); + auto sum = make_shared(Xi, Yi); + auto body = make_shared(OutputVector{body_condition, sum}, ParameterVector{Xi, Yi}); + auto loop = make_shared(trip_count, exec_condition); loop->set_function(body); - loop->set_special_body_ports(ngraph::opset5::Loop::SpecialBodyPorts{-1, 0}); + loop->set_special_body_ports(ov::op::v5::Loop::SpecialBodyPorts{-1, 0}); loop->set_sliced_input(Xi, X, 0, 1, 1, -1, 0); loop->set_invariant_input(Yi, Y); @@ -3727,24 +3734,24 @@ TEST(constant_folding, constant_loop) { auto out0 = loop->get_iter_value(sum, -1); auto out1 = loop->get_concatenated_slices(sum, 0, 1, 1, -1, 0); - auto result0 = make_shared(out0); - auto result1 = make_shared(out1); + auto result0 = make_shared(out0); + auto result1 = make_shared(out1); auto results = ResultVector{result0, result1}; - auto f = make_shared(results, ParameterVector{}); + auto f = make_shared(results, ParameterVector{}); run_constant_folding(f); - ASSERT_EQ(count_ops_of_type(f), 0); - ASSERT_EQ(count_ops_of_type(f), 2); + ASSERT_EQ(count_ops_of_type(f), 0); + ASSERT_EQ(count_ops_of_type(f), 2); auto result_node_0 = get_result_constant(f); auto result_node_1 = get_result_constant(f, 1); ASSERT_TRUE(result_node_0); ASSERT_TRUE(result_node_1); - const ngraph::Shape shape_0{1, 1, 3}; - const ngraph::Shape shape_1{2, 1, 3}; + const ov::Shape shape_0{1, 1, 3}; + const ov::Shape shape_1{2, 1, 3}; ASSERT_EQ(shape_0, result_node_0->get_output_shape(0)); ASSERT_EQ(shape_1, result_node_1->get_output_shape(0)); @@ -3755,9 +3762,9 @@ TEST(constant_folding, constant_loop) { } TEST(constant_folding, disable_constant_folding_for_shapeof) { - auto data = std::make_shared(element::f32, Shape{1, 3, 22, 22}); - auto shapeof = std::make_shared(data); - auto reshape = std::make_shared(data, shapeof, true); + auto data = std::make_shared(element::f32, Shape{1, 3, 22, 22}); + auto shapeof = std::make_shared(data); + auto reshape = std::make_shared(data, shapeof, true); auto model = std::make_shared(NodeVector{reshape}, ParameterVector{data}); ov::disable_constant_folding(shapeof); @@ -3768,12 +3775,12 @@ TEST(constant_folding, disable_constant_folding_for_shapeof) { } TEST(constant_folding, disable_constant_folding_for_squeeze_unsqueeze) { - auto const_data = op::Constant::create(element::f32, Shape{1, 64}, {1}); - auto const_axes = op::Constant::create(element::i64, Shape{1}, {0}); + auto const_data = ov::op::v0::Constant::create(element::f32, Shape{1, 64}, {1}); + auto const_axes = ov::op::v0::Constant::create(element::i64, Shape{1}, {0}); auto squeeze = std::make_shared(const_data, const_axes); auto unsqueeze = make_shared(const_data, const_axes); - auto consumer1 = std::make_shared(squeeze); - auto consumer2 = std::make_shared(unsqueeze); + auto consumer1 = std::make_shared(squeeze); + auto consumer2 = std::make_shared(unsqueeze); auto model = std::make_shared(NodeVector{consumer1, consumer2}, ParameterVector{}); @@ -3782,15 +3789,15 @@ TEST(constant_folding, disable_constant_folding_for_squeeze_unsqueeze) { run_constant_folding(model); - ASSERT_EQ(count_ops_of_type(model), 1); - ASSERT_EQ(count_ops_of_type(model), 1); + ASSERT_EQ(count_ops_of_type(model), 1); + ASSERT_EQ(count_ops_of_type(model), 1); } TEST(constant_folding, disable_constant_folding_for_convert_like) { - auto data = op::Constant::create(element::f32, Shape{1, 64}, {1}); - auto like = op::Constant::create(element::i64, Shape{1, 64}, {1}); + auto data = ov::op::v0::Constant::create(element::f32, Shape{1, 64}, {1}); + auto like = ov::op::v0::Constant::create(element::i64, Shape{1, 64}, {1}); auto convert_like = std::make_shared(data, like); - auto consumer1 = std::make_shared(convert_like); + auto consumer1 = std::make_shared(convert_like); auto model = std::make_shared(NodeVector{consumer1}, ParameterVector{}); @@ -3802,10 +3809,10 @@ TEST(constant_folding, disable_constant_folding_for_convert_like) { } TEST(constant_folding, fold_convert_like_node) { - auto data = op::Constant::create(element::f32, Shape{1, 64}, {1}); - auto like = op::Constant::create(element::i64, Shape{1, 64}, {1}); + auto data = ov::op::v0::Constant::create(element::f32, Shape{1, 64}, {1}); + auto like = ov::op::v0::Constant::create(element::i64, Shape{1, 64}, {1}); auto convert_like = std::make_shared(data, like); - auto consumer1 = std::make_shared(convert_like); + auto consumer1 = std::make_shared(convert_like); auto model = std::make_shared(NodeVector{consumer1}, ParameterVector{}); @@ -3815,10 +3822,10 @@ TEST(constant_folding, fold_convert_like_node) { } TEST(constant_folding, fold_convert_like_but_node_is_not_foldable) { - auto data = std::make_shared(element::f32, Shape{1, 64}); - auto like = op::Constant::create(element::i64, Shape{1, 64}, {1}); + auto data = std::make_shared(element::f32, Shape{1, 64}); + auto like = ov::op::v0::Constant::create(element::i64, Shape{1, 64}, {1}); auto convert_like = std::make_shared(data, like); - auto consumer1 = std::make_shared(convert_like); + auto consumer1 = std::make_shared(convert_like); auto model = std::make_shared(NodeVector{consumer1}, ParameterVector{data}); @@ -3848,8 +3855,8 @@ TEST(constant_folding, evaluate_on_tensor_vector) { vector values_a{1, 2, 3, 4}; vector values_b{1, 2, 3, 4}; auto data_shape = Shape{2, 2}; - auto a = make_shared(element::i32, data_shape, values_a); - auto b = make_shared(element::i32, data_shape, values_b); + auto a = make_shared(element::i32, data_shape, values_a); + auto b = make_shared(element::i32, data_shape, values_b); auto mock = std::make_shared<::testing::StrictMock>(a, b); EXPECT_CALL(*mock, evaluate).Times(1); @@ -3866,43 +3873,43 @@ TEST(constant_folding, evaluate_on_tensor_vector) { } TEST(constant_folding, gather_with_dynamic_shapes_in_data_input) { - auto in_0 = std::make_shared(ov::element::i64, ov::PartialShape{30}); + auto in_0 = std::make_shared(ov::element::i64, ov::PartialShape{30}); // dynamic input to Gather - auto in_1 = std::make_shared(ov::element::i32, ov::PartialShape{-1, 2}); + auto in_1 = std::make_shared(ov::element::i32, ov::PartialShape{-1, 2}); in_1->set_friendly_name("in_1"); - auto shape_of = std::make_shared(in_1); + auto shape_of = std::make_shared(in_1); shape_of->set_friendly_name("shape_of"); - auto indices = std::make_shared(ov::element::i32, ov::Shape{1}, std::vector{1}); + auto indices = std::make_shared(ov::element::i32, ov::Shape{1}, std::vector{1}); indices->set_friendly_name("indices"); - auto axis = std::make_shared(ov::element::i32, ov::Shape{1}, std::vector{0}); + auto axis = std::make_shared(ov::element::i32, ov::Shape{1}, std::vector{0}); axis->set_friendly_name("axis"); - auto gather = std::make_shared(shape_of, indices, axis); + auto gather = std::make_shared(shape_of, indices, axis); gather->set_friendly_name("test"); - auto in_2 = std::make_shared(ov::element::i32, ov::Shape{1}, std::vector{10}); + auto in_2 = std::make_shared(ov::element::i32, ov::Shape{1}, std::vector{10}); in_2->set_friendly_name("in_2"); - auto in_3 = std::make_shared(ov::element::i32, ov::Shape{1}, std::vector{1}); + auto in_3 = std::make_shared(ov::element::i32, ov::Shape{1}, std::vector{1}); in_3->set_friendly_name("in_3"); - auto strided_slice = std::make_shared(in_0, - gather, - in_2, - in_3, - std::vector{0, 0}, - std::vector{0, 0}, - std::vector{0, 0}, - std::vector{0, 1}); + auto strided_slice = std::make_shared(in_0, + gather, + in_2, + in_3, + std::vector{0, 0}, + std::vector{0, 0}, + std::vector{0, 0}, + std::vector{0, 1}); strided_slice->set_friendly_name("strided_slice"); - auto res = std::make_shared(strided_slice); + auto res = std::make_shared(strided_slice); res->set_friendly_name("result"); auto model = std::make_shared(ov::ResultVector{res}, ov::ParameterVector{in_0, in_1}); run_constant_folding(model); - ASSERT_EQ(count_ops_of_type(model), 0); - ASSERT_EQ(count_ops_of_type(model), 1); + ASSERT_EQ(count_ops_of_type(model), 0); + ASSERT_EQ(count_ops_of_type(model), 1); - auto new_const = dynamic_pointer_cast(strided_slice->input_value(1).get_node_shared_ptr()); + auto new_const = dynamic_pointer_cast(strided_slice->input_value(1).get_node_shared_ptr()); EXPECT_NE(new_const, nullptr); check_names(new_const, {"shape_of", "indices", "axis", "test"}); @@ -3917,4 +3924,4 @@ TEST(constant_folding, parameter_with_unspecified_type_from_host_tensor) { auto res = std::make_shared(param); auto model = std::make_shared(ov::ResultVector{res}, ov::ParameterVector{param}); EXPECT_NO_THROW(run_constant_folding(model)); -} \ No newline at end of file +} diff --git a/src/core/tests/pass_config.cpp b/src/core/tests/pass_config.cpp index ead11b94b10..4ea1b28f467 100644 --- a/src/core/tests/pass_config.cpp +++ b/src/core/tests/pass_config.cpp @@ -4,60 +4,56 @@ #include -#include -#include -#include -#include - #include "common_test_utils/test_tools.hpp" +#include "openvino/core/rtti.hpp" +#include "openvino/op/relu.hpp" +#include "openvino/op/sigmoid.hpp" +#include "openvino/pass/graph_rewrite.hpp" +#include "openvino/pass/manager.hpp" +#include "openvino/pass/pattern/op/wrap_type.hpp" using namespace ::testing; using namespace std; -using namespace ngraph; +using namespace ov; +using namespace ov::pass; -OPENVINO_SUPPRESS_DEPRECATED_START - -class RenameReLU : public ngraph::pass::MatcherPass { +class RenameReLU : public ov::pass::MatcherPass { public: - NGRAPH_RTTI_DECLARATION; + OPENVINO_RTTI("RanameReLU"); RenameReLU() : MatcherPass() { - auto relu = pattern::wrap_type(); - ngraph::matcher_pass_callback callback = [](pattern::Matcher& m) { + auto relu = ov::pass::pattern::wrap_type(); + ov::matcher_pass_callback callback = [](pattern::Matcher& m) { auto relu = m.get_match_root(); relu->set_friendly_name("renamed"); return false; }; - auto m = std::make_shared(relu, "RenameReLU"); + auto m = std::make_shared(relu, "RenameReLU"); this->register_matcher(m, callback); } }; -NGRAPH_RTTI_DEFINITION(RenameReLU, "RenameReLU"); - -class RenameSigmoid : public ngraph::pass::MatcherPass { +class RenameSigmoid : public ov::pass::MatcherPass { public: - NGRAPH_RTTI_DECLARATION; + OPENVINO_RTTI("RenameSigmoid"); RenameSigmoid() : MatcherPass() { - auto sigmoid = pattern::wrap_type(); - ngraph::matcher_pass_callback callback = [](pattern::Matcher& m) { + auto sigmoid = pattern::wrap_type(); + ov::matcher_pass_callback callback = [](pattern::Matcher& m) { auto sigmoid = m.get_match_root(); sigmoid->set_friendly_name("renamed"); return false; }; - auto m = std::make_shared(sigmoid, "RenameSigmoid"); + auto m = std::make_shared(sigmoid, "RenameSigmoid"); this->register_matcher(m, callback); } }; -NGRAPH_RTTI_DEFINITION(RenameSigmoid, "RenameSigmoid"); - -class TestFunctionPass : public ngraph::pass::FunctionPass { +class TestModelPass : public pass::ModelPass { public: - NGRAPH_RTTI_DECLARATION; + OPENVINO_RTTI("TestModelPass"); - bool run_on_model(const std::shared_ptr& f) override { + bool run_on_model(const std::shared_ptr& f) override { pass::Manager manager(get_pass_config()); manager.register_pass(); @@ -68,36 +64,32 @@ public: } }; -NGRAPH_RTTI_DEFINITION(TestFunctionPass, "TestFunctionPass"); - -class TestGraphRewritePass : public ngraph::pass::GraphRewrite { +class TestGraphRewritePass : public pass::GraphRewrite { public: - NGRAPH_RTTI_DECLARATION; + OPENVINO_RTTI("TestGraphRewritePass"); TestGraphRewritePass() { add_matcher(); add_matcher(); } }; -NGRAPH_RTTI_DEFINITION(TestGraphRewritePass, "TestGraphRewritePass"); - -std::tuple, std::shared_ptr, std::shared_ptr> get_test_function() { - auto data = std::make_shared(ngraph::element::f32, ngraph::Shape{3, 1, 2}); - auto relu = std::make_shared(data); +std::tuple, std::shared_ptr, std::shared_ptr> get_test_function() { + auto data = std::make_shared(ov::element::f32, ov::Shape{3, 1, 2}); + auto relu = std::make_shared(data); relu->set_friendly_name("relu"); - auto sigmoid = std::make_shared(relu); + auto sigmoid = std::make_shared(relu); sigmoid->set_friendly_name("sigmoid"); - auto f = std::make_shared(ngraph::NodeVector{sigmoid}, ngraph::ParameterVector{data}); - return std::tuple, std::shared_ptr, std::shared_ptr>(f, relu, sigmoid); + auto f = std::make_shared(ov::NodeVector{sigmoid}, ov::ParameterVector{data}); + return std::tuple, std::shared_ptr, std::shared_ptr>(f, relu, sigmoid); } TEST(PassConfig, EnableDisablePasses1) { - std::shared_ptr f; + std::shared_ptr f; std::shared_ptr relu, sigmoid; std::tie(f, relu, sigmoid) = get_test_function(); pass::Manager manager; - manager.register_pass(); + manager.register_pass(); manager.run_passes(f); ASSERT_EQ(relu->get_friendly_name(), "relu"); @@ -105,12 +97,12 @@ TEST(PassConfig, EnableDisablePasses1) { } TEST(PassConfig, EnableDisablePasses2) { - std::shared_ptr f; + std::shared_ptr f; std::shared_ptr relu, sigmoid; std::tie(f, relu, sigmoid) = get_test_function(); pass::Manager manager; - manager.register_pass(); + manager.register_pass(); auto pass_config = manager.get_pass_config(); pass_config->disable(); @@ -128,12 +120,12 @@ TEST(PassConfig, EnableDisablePasses2) { } TEST(PassConfig, EnableDisablePasses3) { - std::shared_ptr f; + std::shared_ptr f; std::shared_ptr relu, sigmoid; std::tie(f, relu, sigmoid) = get_test_function(); pass::Manager manager; - manager.register_pass(); + manager.register_pass(); auto pass_config = manager.get_pass_config(); pass_config->enable(); @@ -144,12 +136,12 @@ TEST(PassConfig, EnableDisablePasses3) { } TEST(PassConfig, EnableDisablePasses4) { - std::shared_ptr f; + std::shared_ptr f; std::shared_ptr relu, sigmoid; std::tie(f, relu, sigmoid) = get_test_function(); pass::Manager manager; - manager.register_pass(); + manager.register_pass(); auto pass_config = manager.get_pass_config(); pass_config->enable(); @@ -166,7 +158,7 @@ TEST(PassConfig, EnableDisablePasses4) { } TEST(PassConfig, EnableDisablePasses5) { - std::shared_ptr f; + std::shared_ptr f; std::shared_ptr relu, sigmoid; std::tie(f, relu, sigmoid) = get_test_function(); @@ -179,7 +171,7 @@ TEST(PassConfig, EnableDisablePasses5) { } TEST(PassConfig, EnableDisablePasses6) { - std::shared_ptr f; + std::shared_ptr f; std::shared_ptr relu, sigmoid; std::tie(f, relu, sigmoid) = get_test_function(); @@ -202,7 +194,7 @@ TEST(PassConfig, EnableDisablePasses6) { } TEST(PassConfig, EnableDisablePasses7) { - std::shared_ptr f; + std::shared_ptr f; std::shared_ptr relu, sigmoid; std::tie(f, relu, sigmoid) = get_test_function(); @@ -218,7 +210,7 @@ TEST(PassConfig, EnableDisablePasses7) { } TEST(PassConfig, EnableDisablePasses8) { - std::shared_ptr f; + std::shared_ptr f; std::shared_ptr relu, sigmoid; std::tie(f, relu, sigmoid) = get_test_function(); @@ -241,7 +233,7 @@ TEST(PassConfig, EnableDisablePasses8) { } TEST(PassConfig, EnableDisablePasses9) { - std::shared_ptr f; + std::shared_ptr f; std::shared_ptr relu, sigmoid; std::tie(f, relu, sigmoid) = get_test_function(); @@ -265,19 +257,19 @@ TEST(PassConfig, EnableDisablePasses9) { ASSERT_EQ(sigmoid->get_friendly_name(), "renamed"); } -class TestNestedMatcher : public ngraph::pass::MatcherPass { +class TestNestedMatcher : public ov::pass::MatcherPass { public: NGRAPH_RTTI_DECLARATION; TestNestedMatcher() : MatcherPass() { auto any_op = pattern::any_input(); - ngraph::matcher_pass_callback callback = [this](pattern::Matcher& m) { + ov::matcher_pass_callback callback = [this](pattern::Matcher& m) { auto root = m.get_match_root(); auto pass_config = this->get_pass_config(); - if (std::dynamic_pointer_cast(root) && !pass_config->is_disabled()) { + if (std::dynamic_pointer_cast(root) && !pass_config->is_disabled()) { auto pass = std::make_shared(); pass->set_pass_config(pass_config); pass->apply(root); - } else if (std::dynamic_pointer_cast(root) && !pass_config->is_disabled()) { + } else if (std::dynamic_pointer_cast(root) && !pass_config->is_disabled()) { auto pass = std::make_shared(); pass->set_pass_config(pass_config); pass->apply(root); @@ -285,7 +277,7 @@ public: return false; }; - auto m = std::make_shared(any_op, "TestNestedMatcher"); + auto m = std::make_shared(any_op, "TestNestedMatcher"); this->register_matcher(m, callback); } }; @@ -303,7 +295,7 @@ public: NGRAPH_RTTI_DEFINITION(TestNestedGraphRewrite, "TestNestedGraphRewrite"); TEST(PassConfig, EnableDisablePasses10) { - std::shared_ptr f; + std::shared_ptr f; std::shared_ptr relu, sigmoid; std::tie(f, relu, sigmoid) = get_test_function(); @@ -327,7 +319,7 @@ TEST(PassConfig, EnableDisablePasses10) { } TEST(PassConfig, EnableDisablePasses11) { - std::shared_ptr f; + std::shared_ptr f; std::shared_ptr relu, sigmoid; std::tie(f, relu, sigmoid) = get_test_function(); diff --git a/src/core/tests/pass_manager.cpp b/src/core/tests/pass_manager.cpp index 6932f67913d..14c3222c897 100644 --- a/src/core/tests/pass_manager.cpp +++ b/src/core/tests/pass_manager.cpp @@ -2,22 +2,26 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include #include #include #include #include "common_test_utils/test_tools.hpp" -#include "gtest/gtest.h" -#include "ngraph/graph_util.hpp" -#include "ngraph/ngraph.hpp" -#include "ngraph/pass/manager.hpp" +#include "openvino/core/graph_util.hpp" +#include "openvino/core/model.hpp" +#include "openvino/op/add.hpp" +#include "openvino/op/matmul.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/parameter.hpp" +#include "openvino/pass/manager.hpp" +#include "openvino/pass/pass.hpp" -using namespace ngraph; +using namespace ov; using namespace std; -OPENVINO_SUPPRESS_DEPRECATED_START - std::shared_ptr make_test_graph() { auto arg_0 = std::make_shared(ov::element::f32, ov::Shape{2, 2}); auto arg_1 = std::make_shared(ov::element::f32, ov::Shape{2, 2}); @@ -74,7 +78,7 @@ TEST(pass_manager, add) { auto graph = make_test_graph(); size_t node_count = 0; - traverse_nodes(graph, [&](shared_ptr /* node */) { + ov::traverse_nodes(graph, [&](shared_ptr /* node */) { node_count++; }); pass_manager.run_passes(graph); @@ -82,13 +86,3 @@ TEST(pass_manager, add) { EXPECT_EQ(node_count, sorted.size()); EXPECT_TRUE(validate_list(sorted)); } - -namespace { -class DummyPass : public pass::FunctionPass { -public: - DummyPass() {} - bool run_on_model(const std::shared_ptr& /* f */) override { - return false; - } -}; -} // namespace diff --git a/src/core/tests/pattern.cpp b/src/core/tests/pattern.cpp index f4b2de44180..ccc3f3aef8e 100644 --- a/src/core/tests/pattern.cpp +++ b/src/core/tests/pattern.cpp @@ -2,61 +2,59 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include -#include #include #include #include #include -#include #include "common_test_utils/matcher.hpp" +#include "common_test_utils/ngraph_test_utils.hpp" #include "common_test_utils/test_tools.hpp" -#include "gtest/gtest.h" -#include "ngraph/file_util.hpp" -#include "ngraph/graph_util.hpp" -#include "ngraph/log.hpp" -#include "ngraph/ngraph.hpp" -#include "ngraph/op/add.hpp" -#include "ngraph/op/batch_norm.hpp" -#include "ngraph/op/constant.hpp" -#include "ngraph/op/divide.hpp" -#include "ngraph/op/multiply.hpp" -#include "ngraph/op/sqrt.hpp" -#include "ngraph/op/subtract.hpp" -#include "ngraph/op/util/op_types.hpp" #include "ngraph/pass/graph_rewrite.hpp" -#include "ngraph/pass/manager.hpp" -#include "ngraph/pattern/matcher.hpp" -#include "ngraph/pattern/op/branch.hpp" -#include "ngraph/pattern/op/label.hpp" -#include "ngraph/pattern/op/or.hpp" -#include "ngraph/pattern/op/skip.hpp" -#include "ngraph/pattern/op/true.hpp" -#include "openvino/util/log.hpp" +#include "openvino/op/abs.hpp" +#include "openvino/op/add.hpp" +#include "openvino/op/broadcast.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/divide.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/parameter.hpp" +#include "openvino/op/reduce_sum.hpp" +#include "openvino/op/relu.hpp" +#include "openvino/op/subtract.hpp" +#include "openvino/op/util/op_types.hpp" +#include "openvino/pass/graph_rewrite.hpp" +#include "openvino/pass/manager.hpp" +#include "openvino/pass/pattern/matcher.hpp" +#include "openvino/pass/pattern/op/branch.hpp" +#include "openvino/pass/pattern/op/label.hpp" +#include "openvino/pass/pattern/op/or.hpp" +#include "openvino/pass/pattern/op/true.hpp" +#include "openvino/pass/pattern/op/wrap_type.hpp" -NGRAPH_SUPPRESS_DEPRECATED_START - -using namespace ngraph; +using namespace ov; +using namespace ov::pass; using namespace std; static std::shared_ptr construct_constant_node(int n) { - return op::Constant::create(element::i32, Shape{}, {n}); + return ov::op::v0::Constant::create(element::i32, Shape{}, {n}); } -static std::shared_ptr construct_variance_graph() { +static std::shared_ptr construct_variance_graph() { // construct varaiance - auto N = op::Constant::create(element::f32, Shape{3}, {2, 2, 2}); - auto input = std::make_shared(element::f32, Shape{2, 3}); + auto N = ov::op::v0::Constant::create(element::f32, Shape{3}, {2, 2, 2}); + auto input = std::make_shared(element::f32, Shape{2, 3}); auto input_sq = std::make_shared(input, input); - auto sum_input = std::make_shared(input, op::Constant::create(element::i64, {1}, {0})); + auto sum_input = std::make_shared(input, ov::op::v0::Constant::create(element::i64, {1}, {0})); auto square_sumed_input = std::make_shared(sum_input, sum_input); auto sum_squared_input = - std::make_shared(input_sq, op::Constant::create(element::i64, {1}, {0})); + std::make_shared(input_sq, ov::op::v0::Constant::create(element::i64, {1}, {0})); auto avg_input_sum_sq = std::make_shared(square_sumed_input, N); auto xmu = std::make_shared(sum_squared_input, avg_input_sum_sq); auto variance = std::make_shared(xmu, N); - auto variance_label = std::make_shared(variance, nullptr, NodeVector{variance}); + auto variance_label = std::make_shared(variance, nullptr, NodeVector{variance}); return variance_label; } @@ -64,14 +62,14 @@ static std::shared_ptr construct_variance_graph() { static std::shared_ptr construct_mean_graph() { // construct mean; auto input = std::make_shared(element::f32, Shape{2, 3}); - auto N = op::Constant::create(element::f32, Shape{3}, {2, 2, 2}); - auto sum_input1 = std::make_shared(input, op::Constant::create(element::i64, {1}, {0})); + auto N = ov::op::v0::Constant::create(element::f32, Shape{3}, {2, 2, 2}); + auto sum_input1 = std::make_shared(input, ov::op::v0::Constant::create(element::i64, {1}, {0})); auto mean = std::make_shared(sum_input1, N); auto mean_label = std::make_shared(mean, nullptr, NodeVector{mean}); return mean_label; } -class TestGraphRewrite : public ngraph::pass::GraphRewrite { +class TestGraphRewrite : public ov::pass::GraphRewrite { public: void construct_multiply_by_one() { // pattern #1 : a * 1 = a @@ -85,8 +83,8 @@ public: auto pattern_map = m.get_pattern_map(); size_t const_node_index = m.get_match_root()->input_value(0).get_node_shared_ptr() == pattern_map[pattern]; - auto const_node = - ov::as_type_ptr(m.get_match_root()->input_value(const_node_index).get_node_shared_ptr()); + auto const_node = ov::as_type_ptr( + m.get_match_root()->input_value(const_node_index).get_node_shared_ptr()); auto second_node = m.get_match_root()->input_value(const_node_index).get_node_shared_ptr(); OPENVINO_DEBUG << "second_node = " << second_node->get_name() << " , pattern = " << pattern_map[pattern]->get_name(); @@ -143,8 +141,8 @@ public: auto pattern_map = m.get_pattern_map(); size_t const_node_index = m.get_match_root()->input_value(0).get_node_shared_ptr() == pattern_map[pattern]; - auto const_node = - ov::as_type_ptr(m.get_match_root()->input_value(const_node_index).get_node_shared_ptr()); + auto const_node = ov::as_type_ptr( + m.get_match_root()->input_value(const_node_index).get_node_shared_ptr()); auto second_node = m.get_match_root()->input_value(const_node_index).get_node_shared_ptr(); OPENVINO_DEBUG << "second_node = " << second_node->get_name() << " , pattern = " << pattern_map[pattern]->get_name(); @@ -198,8 +196,8 @@ public: static void run_passes(pass::Manager& pass_manager, shared_ptr graph, - std::vector> parms) { - auto func = make_shared(graph, ParameterVector{parms}); + std::vector> parms) { + auto func = make_shared(graph, ParameterVector{parms}); pass_manager.run_passes(func); } @@ -209,14 +207,14 @@ TEST(pattern, graph_rewrite) { pass_manager.register_pass(); { - auto a = make_shared(element::i32, shape); - auto b = make_shared(element::i32, shape); - auto c = make_shared(element::i32, shape); + auto a = make_shared(element::i32, shape); + auto b = make_shared(element::i32, shape); + auto c = make_shared(element::i32, shape); auto iconst0 = construct_constant_node(0); auto graph_a = make_shared(a, iconst0); auto graph_b = make_shared(b, iconst0); - auto f = std::make_shared(ngraph::NodeVector{a, b, graph_a, c, graph_b}, ParameterVector{a, b, c}); + auto f = std::make_shared(ngraph::NodeVector{a, b, graph_a, c, graph_b}, ParameterVector{a, b, c}); pass_manager.run_passes(f); ASSERT_TRUE(graph_a->get_output_target_inputs(0).empty()); @@ -227,8 +225,8 @@ TEST(pattern, graph_rewrite) { } { - auto a = make_shared(element::i32, shape); - auto b = make_shared(element::i32, shape); + auto a = make_shared(element::i32, shape); + auto b = make_shared(element::i32, shape); auto iconst0 = construct_constant_node(0); auto sum = make_shared(a, iconst0); auto graph = make_shared(b, sum); @@ -240,8 +238,8 @@ TEST(pattern, graph_rewrite) { } { - auto a = make_shared(element::i32, shape); - auto b = make_shared(element::i32, shape); + auto a = make_shared(element::i32, shape); + auto b = make_shared(element::i32, shape); auto iconst1 = construct_constant_node(1); auto mul = make_shared(a, iconst1); auto graph = make_shared(b, mul); @@ -253,8 +251,8 @@ TEST(pattern, graph_rewrite) { } { - auto a = make_shared(element::i32, shape); - auto b = make_shared(element::i32, shape); + auto a = make_shared(element::i32, shape); + auto b = make_shared(element::i32, shape); auto iconst1 = construct_constant_node(1); auto multiply = make_shared(make_shared(a, iconst1), iconst1); multiply = make_shared(make_shared(multiply, iconst1), iconst1); @@ -266,8 +264,8 @@ TEST(pattern, graph_rewrite) { } { - auto a = make_shared(element::i32, shape); - auto b = make_shared(element::i32, shape); + auto a = make_shared(element::i32, shape); + auto b = make_shared(element::i32, shape); auto iconst0 = construct_constant_node(0); auto iconst1 = construct_constant_node(1); auto mul = make_shared(make_shared(a, iconst0), iconst1); @@ -279,8 +277,8 @@ TEST(pattern, graph_rewrite) { } { - auto a = make_shared(element::i32, shape); - auto b = make_shared(element::i32, shape); + auto a = make_shared(element::i32, shape); + auto b = make_shared(element::i32, shape); auto iconst1 = construct_constant_node(1); auto mul = make_shared(iconst1, make_shared(iconst1, a)); mul = make_shared(iconst1, make_shared(iconst1, mul)); @@ -294,12 +292,12 @@ TEST(pattern, graph_rewrite) { TEST(pattern, matcher) { Shape shape{}; - auto a = make_shared(element::i32, shape); + auto a = make_shared(element::i32, shape); TestMatcher n; ASSERT_TRUE(n.match(a, a)); ASSERT_EQ(n.get_matched_nodes(), (NodeVector{a})); - auto abs = make_shared(a); + auto abs = make_shared(a); auto any = std::make_shared(a); ASSERT_TRUE(n.match(any, abs)); ASSERT_EQ(n.get_matched_nodes(), (NodeVector{abs, a})); @@ -320,10 +318,10 @@ TEST(pattern, matcher) { ASSERT_FALSE(n.match(pattern_false, a)); ASSERT_EQ(n.get_matched_nodes(), (NodeVector{})); - auto b = make_shared(element::i32, shape); + auto b = make_shared(element::i32, shape); auto is_bea = [](std::shared_ptr node) -> bool { - return op::is_binary_elementwise_arithmetic(node); + return op::util::is_binary_elementwise_arithmetic(node); }; auto bea = std::make_shared(a, is_bea, NodeVector{a, b}); auto add_ab = std::make_shared(a, b); @@ -355,7 +353,7 @@ TEST(pattern, matcher) { ASSERT_TRUE(n.match(bea_label, ab)); ASSERT_EQ(n.get_pattern_map()[bea_label], ab); - auto d = make_shared(element::i32, shape); + auto d = make_shared(element::i32, shape); ASSERT_FALSE(n.match(d, b)); ASSERT_FALSE(n.match(std::make_shared(abs, b), std::make_shared(b, b))); @@ -373,7 +371,7 @@ TEST(pattern, matcher) { ASSERT_EQ(n.get_pattern_map()[pattern], abs); ASSERT_EQ(n.get_matched_nodes(), (NodeVector{add_absb, abs, b})); - auto c = make_shared(element::i32, shape); + auto c = make_shared(element::i32, shape); auto mul_add_absb = std::make_shared(c, add_absb); ASSERT_TRUE( n.match(std::make_shared(c, std::make_shared(b, pattern)), mul_add_absb)); @@ -399,7 +397,7 @@ TEST(pattern, matcher) { ASSERT_TRUE(n.match(make_shared(pattern, iconst1_0), make_shared(a, iconst1_1))); // different iconst ASSERT_EQ(n.get_pattern_map()[pattern], a); - auto fconst1_0 = op::Constant::create(element::f32, shape, {1}); + auto fconst1_0 = ov::op::v0::Constant::create(element::f32, shape, {1}); auto patternf = std::make_shared(fconst1_0); ASSERT_TRUE(n.match(make_shared(patternf, fconst1_0), make_shared(a, iconst1_1))); // different iconst @@ -413,7 +411,7 @@ TEST(pattern, matcher) { ASSERT_FALSE(n.match(label, std::make_shared(a, b))); - ASSERT_TRUE(n.match(make_shared(label), make_shared(add))); + ASSERT_TRUE(n.match(make_shared(label), make_shared(add))); ASSERT_EQ(n.get_pattern_map()[label], add); // Correct argument order @@ -468,17 +466,17 @@ TEST(pattern, matcher) { { TestMatcher sm(Output{}, "TestMatcher", true); // exact shape and type - auto scalar_param = make_shared(element::i32, Shape{}); + auto scalar_param = make_shared(element::i32, Shape{}); auto label_dynamic_shape = make_shared(element::i32, PartialShape::dynamic()); - auto param = make_shared(element::f32, Shape{}); + auto param = make_shared(element::f32, Shape{}); ASSERT_TRUE(sm.match(label_dynamic_shape, scalar_param)); // wrong type - auto scalar_param_wrong_type = make_shared(element::f32, Shape{}); + auto scalar_param_wrong_type = make_shared(element::f32, Shape{}); ASSERT_FALSE(sm.match(label, scalar_param_wrong_type)); // dynamic dimension auto label_dynamic_dimension = make_shared(element::i32, PartialShape{Dimension::dynamic()}); - auto vector_param = make_shared(element::i32, Shape{10}); + auto vector_param = make_shared(element::i32, Shape{10}); ASSERT_TRUE(sm.match(label_dynamic_dimension, vector_param)); // dynamic type auto label_dynamic_type = make_shared(element::dynamic, PartialShape{Dimension::dynamic()}); @@ -490,9 +488,9 @@ TEST(pattern, mean) { // construct mean TestMatcher n; - auto input = std::make_shared(element::f32, Shape{2, 3}); - auto N = op::Constant::create(element::f32, Shape{3}, {2, 2, 2}); - auto sum_input1 = std::make_shared(input, op::Constant::create(element::i64, {1}, {0})); + auto input = std::make_shared(element::f32, Shape{2, 3}); + auto N = ov::op::v0::Constant::create(element::f32, Shape{3}, {2, 2, 2}); + auto sum_input1 = std::make_shared(input, ov::op::v0::Constant::create(element::i64, {1}, {0})); auto mean = std::make_shared(sum_input1, N); auto mean_graph = construct_mean_graph(); @@ -503,13 +501,13 @@ TEST(pattern, mean) { TEST(pattern, variance) { // construct variance TestMatcher n; - auto N = op::Constant::create(element::f32, Shape{3}, {2, 2, 2}); + auto N = ov::op::v0::Constant::create(element::f32, Shape{3}, {2, 2, 2}); auto input = std::make_shared(element::f32, Shape{2, 3}); auto input_sq = std::make_shared(input, input); - auto sum_input = std::make_shared(input, op::Constant::create(element::i64, {1}, {0})); + auto sum_input = std::make_shared(input, ov::op::v0::Constant::create(element::i64, {1}, {0})); auto square_sumed_input = std::make_shared(sum_input, sum_input); auto sum_squared_input = - std::make_shared(input_sq, op::Constant::create(element::i64, {1}, {0})); + std::make_shared(input_sq, ov::op::v0::Constant::create(element::i64, {1}, {0})); auto avg_input_sum_sq = std::make_shared(square_sumed_input, N); auto xmu = std::make_shared(sum_squared_input, avg_input_sum_sq); auto variance = std::make_shared(xmu, N); @@ -520,46 +518,44 @@ TEST(pattern, variance) { } TEST(pattern, previous_matches) { - using ngraph::pattern::Matcher; Shape shape{}; - Matcher::PatternMap previous_matches; - auto a = make_shared(element::i32, shape); - auto b = make_shared(element::i32, shape); + ov::pass::pattern::Matcher::PatternMap previous_matches; + auto a = make_shared(element::i32, shape); + auto b = make_shared(element::i32, shape); auto pattern = std::make_shared(b); - auto abs = make_shared(a); + auto abs = make_shared(a); auto add = make_shared(abs, b); { - Matcher n(make_shared(pattern, b)); + pattern::Matcher n(make_shared(pattern, b)); ASSERT_TRUE(n.match(add, previous_matches)); ASSERT_EQ(n.get_pattern_map()[pattern], abs); } { - Matcher n(make_shared(pattern, b)); + pattern::Matcher n(make_shared(pattern, b)); previous_matches.insert(std::make_pair(pattern, a)); ASSERT_FALSE(n.match(add, previous_matches)); } } TEST(pattern, test_sort) { - using ngraph::pattern::Matcher; Shape shape{}; - auto a = make_shared(element::i32, shape); - auto b = make_shared(element::i32, shape); - auto abs1 = make_shared(a); - auto abs2 = make_shared(b); + auto a = make_shared(element::i32, shape); + auto b = make_shared(element::i32, shape); + auto abs1 = make_shared(a); + auto abs2 = make_shared(b); shared_ptr add = make_shared(abs1, abs2); - auto pa = make_shared(element::i32, shape); - auto pb = make_shared(element::i32, shape); - auto pabs1 = make_shared(pa); + auto pa = make_shared(element::i32, shape); + auto pb = make_shared(element::i32, shape); + auto pabs1 = make_shared(pa); auto pabs1_label = std::make_shared(pabs1); - auto pabs2 = make_shared(b); + auto pabs2 = make_shared(b); shared_ptr padd = make_shared(pabs1_label, pabs2); { - Matcher n1(padd); + pattern::Matcher n1(padd); ASSERT_TRUE(n1.match(add)); auto r1 = n1.get_pattern_map()[pabs1_label]; ASSERT_TRUE(n1.match(add)); @@ -568,20 +564,19 @@ TEST(pattern, test_sort) { } TEST(pattern, recurrent_pattern) { - using ngraph::pattern::RecurrentMatcher; Shape shape{}; - ngraph::pattern::Matcher::PatternMap previous_matches; - auto a = make_shared(element::i32, shape); - auto b = make_shared(element::i32, shape); + pass::pattern::Matcher::PatternMap previous_matches; + auto a = make_shared(element::i32, shape); + auto b = make_shared(element::i32, shape); auto rpattern = std::make_shared(b); auto iconst0 = construct_constant_node(0); - auto abs = make_shared(a); + auto abs = make_shared(a); auto add1 = make_shared(iconst0, b); auto add2 = make_shared(iconst0, add1); auto add3 = make_shared(iconst0, add2); auto padd = make_shared(iconst0, rpattern); std::set> empty_correlated_matches; - RecurrentMatcher rm(padd, rpattern, empty_correlated_matches); + pattern::RecurrentMatcher rm(padd, rpattern, empty_correlated_matches); ASSERT_TRUE(rm.match(add3)); ASSERT_EQ(rm.get_number_of_bound_labels(), 3); auto recurrent_matches = rm.get_bound_nodes_for_pattern(rpattern); @@ -595,7 +590,7 @@ TEST(pattern, recurrent_pattern) { auto add2_2 = make_shared(iconst1, add1); auto add3_2 = make_shared(iconst0, add2_2); auto padd2 = make_shared(iconst_label, rpattern); - RecurrentMatcher rm2(padd2, rpattern, empty_correlated_matches); + pattern::RecurrentMatcher rm2(padd2, rpattern, empty_correlated_matches); ASSERT_TRUE(rm2.match(add3_2)); ASSERT_EQ(rm2.get_number_of_bound_labels(), 4); recurrent_matches = rm2.get_bound_nodes_for_pattern(rpattern); @@ -610,7 +605,7 @@ TEST(pattern, recurrent_pattern) { // Non-matching correlated labels std::set> correlated_matches; correlated_matches.insert(iconst_label); - RecurrentMatcher rm3(padd2, rpattern, correlated_matches); + pattern::RecurrentMatcher rm3(padd2, rpattern, correlated_matches); ASSERT_TRUE(rm3.match(add3_2)); ASSERT_EQ(rm3.get_number_of_bound_labels(), 4); iconst_matches = rm3.get_bound_nodes_for_pattern(iconst_label); @@ -631,6 +626,7 @@ TEST(pattern, recurrent_pattern) { ASSERT_EQ(iconst_matches.at(2), iconst0); } +OPENVINO_SUPPRESS_DEPRECATED_START class TestRecurrentGraphRewrite : public ngraph::pass::RecurrentGraphRewrite { public: void construct_recurrent_add() { @@ -684,21 +680,21 @@ TEST(pattern, recurrent_graph_rewrite) { pass_manager.register_pass(); { - auto a = make_shared(element::i32, shape); + auto a = make_shared(element::i32, shape); auto iconst0 = construct_constant_node(0); auto add_a1 = make_shared(a, iconst0); auto add_a2 = make_shared(add_a1, iconst0); auto add_a3 = make_shared(add_a2, iconst0); - auto abs_add_a3 = std::make_shared(add_a3); + auto abs_add_a3 = std::make_shared(add_a3); - auto b = make_shared(element::i32, shape); + auto b = make_shared(element::i32, shape); auto add_b1 = make_shared(b, iconst0); auto add_b2 = make_shared(add_b1, iconst0); - auto abs_add_b2 = std::make_shared(add_b2); + auto abs_add_b2 = std::make_shared(add_b2); auto graph = make_shared(abs_add_a3, abs_add_b2); - auto f = std::make_shared(ngraph::NodeVector{graph}, ParameterVector{a, b}); + auto f = std::make_shared(ngraph::NodeVector{graph}, ParameterVector{a, b}); pass_manager.run_passes(f); auto left_abs = graph->input_value(0).get_node_shared_ptr(); @@ -710,21 +706,24 @@ TEST(pattern, recurrent_graph_rewrite) { ASSERT_EQ(add_b, b); } } +OPENVINO_SUPPRESS_DEPRECATED_END TEST(pattern, label_on_skip) { Shape shape{2, 2}; - auto a = make_shared(element::i32, shape); - auto b = make_shared(element::i32, Shape{}); + auto a = make_shared(element::i32, shape); + auto b = make_shared(element::i32, Shape{}); + OPENVINO_SUPPRESS_DEPRECATED_START auto iconst = ngraph::make_zero(element::i32, Shape{}); auto label = std::make_shared(iconst); auto const_label = std::make_shared(iconst, ngraph::is_zero, NodeVector{iconst}); + OPENVINO_SUPPRESS_DEPRECATED_END auto bcst_pred = [](std::shared_ptr n) { return ov::as_type_ptr(n) != nullptr; }; - auto shape_const = op::Constant::create(element::u64, Shape{shape.size()}, shape); - auto axes_const = op::Constant::create(element::u8, Shape{}, {0}); + auto shape_const = ov::op::v0::Constant::create(element::u64, Shape{shape.size()}, shape); + auto axes_const = ov::op::v0::Constant::create(element::u8, Shape{}, {0}); auto bcst = std::make_shared(OutputVector{const_label, shape_const, axes_const}, bcst_pred); auto bcst_label = std::make_shared(bcst, nullptr, NodeVector{bcst}); auto matcher = @@ -745,32 +744,32 @@ TEST(pattern, label_on_skip) { TEST(pattern, is_contained_match) { Shape shape{}; - auto a = make_shared(element::i32, shape); - auto absn = make_shared(a); + auto a = make_shared(element::i32, shape); + auto absn = make_shared(a); TestMatcher n; auto label_a = std::make_shared(a); - auto label_abs = make_shared(a); + auto label_abs = make_shared(a); ASSERT_TRUE(n.match(label_abs, absn)); - auto result_absn = make_shared(absn); + auto result_absn = make_shared(absn); ASSERT_TRUE(n.is_contained_match()); - auto absn2 = make_shared(absn); - auto result_absn2 = make_shared(absn2); - auto label_abs2 = make_shared(label_abs); + auto absn2 = make_shared(absn); + auto result_absn2 = make_shared(absn2); + auto label_abs2 = make_shared(label_abs); ASSERT_TRUE(n.match(label_abs2, absn2)); ASSERT_FALSE(n.is_contained_match()); } TEST(pattern, wrap_type_single_op) { - auto a = make_shared(element::f32, Shape{1, 3, 64, 64}); - auto b = make_shared(a); - auto c = make_shared(a); - auto mul1 = make_shared(a, op::Constant::create(element::f32, Shape{}, {1})); - auto mul2 = make_shared(op::Constant::create(element::f32, Shape{}, {1}), a); + auto a = make_shared(element::f32, Shape{1, 3, 64, 64}); + auto b = make_shared(a); + auto c = make_shared(a); + auto mul1 = make_shared(a, ov::op::v0::Constant::create(element::f32, Shape{}, {1})); + auto mul2 = make_shared(ov::op::v0::Constant::create(element::f32, Shape{}, {1}), a); { - auto m = pattern::wrap_type(); + auto m = pattern::wrap_type(); auto matcher = std::make_shared(m, "AbsMatcher"); ASSERT_TRUE(matcher->match(static_pointer_cast(b))); ASSERT_EQ(matcher->get_matched_nodes().size(), 1); @@ -779,8 +778,8 @@ TEST(pattern, wrap_type_single_op) { ASSERT_FALSE(matcher->match(static_pointer_cast(c))); } { - auto m1 = pattern::wrap_type(); - auto m2 = pattern::wrap_type({m1}); + auto m1 = pattern::wrap_type(); + auto m2 = pattern::wrap_type({m1}); auto matcher = std::make_shared(m2, "ParamAbsMatcher"); ASSERT_TRUE(matcher->match(static_pointer_cast(b))); ASSERT_EQ(matcher->get_matched_nodes().size(), 2); @@ -789,13 +788,15 @@ TEST(pattern, wrap_type_single_op) { ASSERT_FALSE(matcher->match(static_pointer_cast(c))); } { - auto m1 = pattern::wrap_type({pattern::any_input(), pattern::wrap_type()}); + auto m1 = + pattern::wrap_type({pattern::any_input(), pattern::wrap_type()}); auto matcher = std::make_shared(m1, "MultiplyMatcher"); ASSERT_TRUE(matcher->match(static_pointer_cast(mul1))); ASSERT_TRUE(matcher->match(static_pointer_cast(mul2))); } { - auto m1 = pattern::wrap_type({pattern::wrap_type(), pattern::any_input()}); + auto m1 = + pattern::wrap_type({pattern::wrap_type(), pattern::any_input()}); auto matcher = std::make_shared(m1, "MultiplyMatcher"); ASSERT_TRUE(matcher->match(static_pointer_cast(mul1))); ASSERT_TRUE(matcher->match(static_pointer_cast(mul2))); @@ -803,11 +804,11 @@ TEST(pattern, wrap_type_single_op) { } TEST(pattern, wrap_type_multi_op) { - auto a = make_shared(element::f32, Shape{1, 3, 64, 64}); - auto b = make_shared(a); - auto c = make_shared(a); - auto mul = make_shared(a, op::Constant::create(element::f32, Shape{}, {1})); - auto add = make_shared(op::Constant::create(element::f32, Shape{}, {1}), a); + auto a = make_shared(element::f32, Shape{1, 3, 64, 64}); + auto b = make_shared(a); + auto c = make_shared(a); + auto mul = make_shared(a, ov::op::v0::Constant::create(element::f32, Shape{}, {1})); + auto add = make_shared(ov::op::v0::Constant::create(element::f32, Shape{}, {1}), a); { auto m = pattern::wrap_type(); diff --git a/src/core/tests/preprocess.cpp b/src/core/tests/preprocess.cpp index a1c5eff03fd..0ce5d3a8f35 100644 --- a/src/core/tests/preprocess.cpp +++ b/src/core/tests/preprocess.cpp @@ -5,8 +5,7 @@ #include "common_test_utils/test_assertions.hpp" #include "common_test_utils/test_tools.hpp" #include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" -#include "ngraph/ops.hpp" +#include "openvino/core/except.hpp" #include "openvino/core/preprocess/pre_post_process.hpp" #include "openvino/opsets/opset8.hpp" #include "openvino/util/common_util.hpp" @@ -1991,7 +1990,7 @@ TEST(pre_post_process, exception_safety) { .custom([](const Output& node) -> Output { OPENVINO_THROW("test error"); }); - p.build(), ngraph::ngraph_error); + p.build(), ov::Exception); EXPECT_EQ(f->get_parameters().size(), 2); EXPECT_EQ(f->input(0).get_element_type(), element::f32); diff --git a/src/core/tests/replace_node.cpp b/src/core/tests/replace_node.cpp index 3d0d8fd16e2..aca03711031 100644 --- a/src/core/tests/replace_node.cpp +++ b/src/core/tests/replace_node.cpp @@ -2,12 +2,20 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include "common_test_utils/type_prop.hpp" -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" +#include "openvino/core/model.hpp" +#include "openvino/op/add.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/parameter.hpp" +#include "openvino/op/relu.hpp" +#include "openvino/op/split.hpp" +#include "openvino/op/subtract.hpp" using namespace std; -using namespace ngraph; +using namespace ov; // // Graph before (params in [] brackets, constants in () parens, results in {} braces): @@ -47,24 +55,24 @@ using namespace ngraph; // {r} // TEST(replace_node, replace_nodes) { - auto x = make_shared(element::f32, Shape{2}); - auto y = make_shared(element::f32, Shape{2}); - auto z = make_shared(element::f32, Shape{2}); + auto x = make_shared(element::f32, Shape{2}); + auto y = make_shared(element::f32, Shape{2}); + auto z = make_shared(element::f32, Shape{2}); auto add = make_shared(x, y); - auto k = make_shared(element::f32, Shape{2}, vector{1, 2}); + auto k = make_shared(element::f32, Shape{2}, vector{1, 2}); auto mul = make_shared(add, k); auto sub = make_shared(mul, z); - auto f = make_shared(NodeVector{sub}, ParameterVector{x, y, z}); + auto f = make_shared(NodeVector{sub}, ParameterVector{x, y, z}); - unordered_map, shared_ptr> parameter_replacement_map; - auto x_replacement = make_shared(element::f32, Shape{2}); + unordered_map, shared_ptr> parameter_replacement_map; + auto x_replacement = make_shared(element::f32, Shape{2}); parameter_replacement_map[x] = x_replacement; unordered_map, shared_ptr> body_replacement_map; - auto y_replacement = make_shared(element::f32, Shape{2}, vector{3, 4}); - auto k_replacement = make_shared(element::f32, Shape{2}, vector{5, 6}); + auto y_replacement = make_shared(element::f32, Shape{2}, vector{3, 4}); + auto k_replacement = make_shared(element::f32, Shape{2}, vector{5, 6}); auto z_replacement = make_shared(x_replacement, mul); body_replacement_map[y] = y_replacement; body_replacement_map[k] = k_replacement; @@ -108,12 +116,12 @@ TEST(replace_node, replace_nodes) { } TEST(replace_node, simple_node_replacement) { - auto param = std::make_shared(element::i64, Shape{1, 64}); + auto param = std::make_shared(element::i64, Shape{1, 64}); param->output(0).get_tensor().set_names({"a", "b"}); - auto relu = std::make_shared(param); + auto relu = std::make_shared(param); relu->output(0).get_tensor().set_names({"c", "d"}); - auto new_relu = std::make_shared(param); + auto new_relu = std::make_shared(param); new_relu->output(0).get_tensor().set_names({"f"}); replace_node(relu, new_relu); @@ -121,11 +129,11 @@ TEST(replace_node, simple_node_replacement) { } TEST(replace_node, node_elimination) { - auto param = std::make_shared(element::i64, Shape{1, 64}); + auto param = std::make_shared(element::i64, Shape{1, 64}); param->output(0).get_tensor().set_names({"a", "b"}); - auto relu1 = std::make_shared(param); + auto relu1 = std::make_shared(param); relu1->output(0).get_tensor().set_names({"c", "d"}); - auto relu2 = std::make_shared(relu1); + auto relu2 = std::make_shared(relu1); relu2->output(0).get_tensor().set_names({"e", "f"}); ASSERT_TRUE(replace_output_update_name(relu2->output(0), relu2->input_value(0))); @@ -134,11 +142,11 @@ TEST(replace_node, node_elimination) { } TEST(replace_node, node_elimination_1) { - auto param = std::make_shared(element::i64, Shape{3, 64}); - auto split = std::make_shared(param, op::Constant::create(element::i64, Shape{}, {0}), 3); - auto relu1 = std::make_shared(split->output(2)); - auto relu2 = std::make_shared(relu1); - auto result2 = std::make_shared(relu2); + auto param = std::make_shared(element::i64, Shape{3, 64}); + auto split = std::make_shared(param, ov::op::v0::Constant::create(element::i64, Shape{}, {0}), 3); + auto relu1 = std::make_shared(split->output(2)); + auto relu2 = std::make_shared(relu1); + auto result2 = std::make_shared(relu2); // relu1 can be removed because we don't have to preserve name ASSERT_TRUE(replace_output_update_name(relu1->output(0), relu1->input_value(0))); @@ -148,44 +156,44 @@ TEST(replace_node, node_elimination_1) { } TEST(replace_node, node_elimination_2) { - auto param = std::make_shared(element::i64, Shape{3, 64}); - auto relu1 = std::make_shared(param); - auto result1 = std::make_shared(relu1); - auto relu2 = std::make_shared(relu1); - auto result2 = std::make_shared(relu2); + auto param = std::make_shared(element::i64, Shape{3, 64}); + auto relu1 = std::make_shared(param); + auto result1 = std::make_shared(relu1); + auto relu2 = std::make_shared(relu1); + auto result2 = std::make_shared(relu2); // relu2 can't be removed because relu1 has Result as consumer ASSERT_FALSE(replace_output_update_name(relu2->output(0), relu2->input_value(0))); } TEST(replace_node, node_elimination_3) { - auto param = std::make_shared(element::i64, Shape{3, 64}); - auto relu1 = std::make_shared(param); - auto relu2 = std::make_shared(relu1); - auto relu3 = std::make_shared(relu1); - auto result2 = std::make_shared(relu3); + auto param = std::make_shared(element::i64, Shape{3, 64}); + auto relu1 = std::make_shared(param); + auto relu2 = std::make_shared(relu1); + auto relu3 = std::make_shared(relu1); + auto result2 = std::make_shared(relu3); // relu3 can be removed because relu1 has no Result as consumer ASSERT_TRUE(replace_output_update_name(relu3->output(0), relu3->input_value(0))); } TEST(replace_node, node_elimination_4) { - auto param = std::make_shared(element::i64, Shape{3, 64}); - auto relu1 = std::make_shared(param); - auto split = std::make_shared(relu1, op::Constant::create(element::i64, Shape{}, {0}), 3); - auto relu2 = std::make_shared(split->output(2)); - auto result2 = std::make_shared(relu2); + auto param = std::make_shared(element::i64, Shape{3, 64}); + auto relu1 = std::make_shared(param); + auto split = std::make_shared(relu1, ov::op::v0::Constant::create(element::i64, Shape{}, {0}), 3); + auto relu2 = std::make_shared(split->output(2)); + auto result2 = std::make_shared(relu2); ASSERT_TRUE(replace_output_update_name(split->output(2), split->input_value(0))); } TEST(replace_node, output_replacement) { - auto param = std::make_shared(element::i64, Shape{1, 64}); + auto param = std::make_shared(element::i64, Shape{1, 64}); param->output(0).get_tensor().set_names({"a", "b"}); - auto relu = std::make_shared(param); + auto relu = std::make_shared(param); relu->output(0).get_tensor().set_names({"c", "d"}); - auto new_relu = std::make_shared(param); + auto new_relu = std::make_shared(param); new_relu->output(0).get_tensor().set_names({"f"}); relu->output(0).replace(new_relu->output(0)); @@ -194,13 +202,13 @@ TEST(replace_node, output_replacement) { } TEST(replace_node, source_replacement) { - auto param = std::make_shared(element::i64, Shape{1, 64}); + auto param = std::make_shared(element::i64, Shape{1, 64}); param->output(0).get_tensor().set_names({"a", "b"}); - auto param1 = std::make_shared(element::i64, Shape{1, 64}); + auto param1 = std::make_shared(element::i64, Shape{1, 64}); param1->output(0).get_tensor().set_names({"c", "d"}); - auto relu = std::make_shared(param); + auto relu = std::make_shared(param); relu->input(0).replace_source_output(param1->output(0)); ASSERT_EQ(param->output(0).get_tensor().get_names(), std::unordered_set({"a", "b"})); diff --git a/src/core/tests/reshape_opt_kernel.cpp b/src/core/tests/reshape_opt_kernel.cpp index dc20cdf9653..c2f894589ca 100644 --- a/src/core/tests/reshape_opt_kernel.cpp +++ b/src/core/tests/reshape_opt_kernel.cpp @@ -2,15 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include #include #include "common_test_utils/ndarray.hpp" -#include "gtest/gtest.h" -#include "ngraph/axis_vector.hpp" #include "ngraph/runtime/opt_kernel/reshape.hpp" -#include "ngraph/shape.hpp" +#include "openvino/core/axis_vector.hpp" +using namespace ov; using namespace ngraph; namespace { @@ -31,8 +32,8 @@ AxisVector get_axis_order(AxisOrder order, size_t size) { struct TestParams { AxisOrder order; - test::NDArrayBase input; - test::NDArrayBase output; + ngraph::test::NDArrayBase input; + ngraph::test::NDArrayBase output; }; struct ReshapeOptKernel : ::testing::TestWithParam {}; @@ -50,12 +51,12 @@ TEST_P(ReshapeOptKernel, reshape_opt_kernel) { for (size_t i = 0; i < out_shape.size(); i++) out_shape[i] = in_shape[axis_order[i]]; - runtime::opt_kernel::reshape((const char*)p.input.data(), - (char*)output_buff.data(), - in_shape, - axis_order, - out_shape, - sizeof(ElementValue)); + ngraph::runtime::opt_kernel::reshape((const char*)p.input.data(), + (char*)output_buff.data(), + in_shape, + axis_order, + out_shape, + sizeof(ElementValue)); EXPECT_EQ(p.output.get_vector(), output_buff); } diff --git a/src/core/tests/rtti.cpp b/src/core/tests/rtti.cpp index 70bed7009fd..67d203591b0 100644 --- a/src/core/tests/rtti.cpp +++ b/src/core/tests/rtti.cpp @@ -4,10 +4,9 @@ #include "common_test_utils/test_tools.hpp" #include "gtest/gtest.h" -#include "ngraph/node.hpp" #include "openvino/op/op.hpp" -using namespace ngraph; +using namespace ov; using namespace std; class OpType : public ov::op::Op { @@ -50,7 +49,6 @@ public: } }; -OPENVINO_SUPPRESS_DEPRECATED_START TEST(rtti, op_with_type) { auto op = OpType(); auto type_info = op.get_type_info(); diff --git a/src/core/tests/shape.cpp b/src/core/tests/shape.cpp index bb8d8a13f97..fc80a7ab30c 100644 --- a/src/core/tests/shape.cpp +++ b/src/core/tests/shape.cpp @@ -2,16 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "openvino/core/shape.hpp" + +#include + #include -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" - using namespace std; -using namespace ngraph; +using namespace ov; TEST(shape, test_shape_size) { - ASSERT_EQ(1, shape_size(Shape{})); + ASSERT_EQ(1, shape_size(ov::Shape{})); ASSERT_EQ(2 * 3 * 5, shape_size(Shape{2, 3, 5})); } diff --git a/src/core/tests/tensor.cpp b/src/core/tests/tensor.cpp index aff275b1487..7a4942ef49b 100644 --- a/src/core/tests/tensor.cpp +++ b/src/core/tests/tensor.cpp @@ -10,26 +10,24 @@ #include "common_test_utils/test_tools.hpp" #include "gtest/gtest.h" -#include "ngraph/function.hpp" -#include "ngraph/ngraph.hpp" -#include "ngraph/opsets/opset6.hpp" -#include "ngraph/pass/manager.hpp" +#include "ngraph/node.hpp" +#include "openvino/core/model.hpp" +#include "openvino/op/parameter.hpp" +#include "openvino/op/relu.hpp" #include "tensor_conversion_util.hpp" -NGRAPH_SUPPRESS_DEPRECATED_START - using namespace std; -using namespace ngraph; +using namespace ov; TEST(tensor, tensor_names) { - auto arg0 = make_shared(element::f32, Shape{1}); + auto arg0 = make_shared(element::f32, Shape{1}); arg0->set_friendly_name("data"); arg0->get_output_tensor(0).set_names({"input"}); - auto relu = make_shared(arg0); + auto relu = make_shared(arg0); relu->set_friendly_name("relu"); relu->get_output_tensor(0).set_names({"relu_t", "identity"}); - auto f0 = make_shared(relu, ParameterVector{arg0}); + auto f0 = make_shared(relu, ParameterVector{arg0}); ASSERT_EQ(arg0->get_output_tensor(0).get_names(), relu->get_input_tensor(0).get_names()); ASSERT_EQ(arg0->get_output_tensor(0).get_names(), relu->input_value(0).get_tensor().get_names()); @@ -39,14 +37,18 @@ TEST(tensor, tensor_names) { TEST(tensor, wrap_tensor_with_unspecified_type) { auto param = std::make_shared(element::undefined, ov::PartialShape{}); + OPENVINO_SUPPRESS_DEPRECATED_START auto tensor = ov::util::wrap_tensor(param->output(0)); + OPENVINO_SUPPRESS_DEPRECATED_END // !tensor means that the tensor is not initialized EXPECT_EQ(!tensor, true); } TEST(tensor, wrap_tensor_with_unspecified_type_from_host_tensor) { + OPENVINO_SUPPRESS_DEPRECATED_START auto host_tensor = std::make_shared(element::undefined, ov::PartialShape{}); auto tensor = ov::util::wrap_tensor(host_tensor); + OPENVINO_SUPPRESS_DEPRECATED_END // !tensor means that the tensor is not initialized EXPECT_EQ(!tensor, true); } diff --git a/src/core/tests/threading.cpp b/src/core/tests/threading.cpp index b2150552704..a43e252ff74 100644 --- a/src/core/tests/threading.cpp +++ b/src/core/tests/threading.cpp @@ -17,7 +17,7 @@ #include "openvino/opsets/opset8.hpp" #include "ov_ops/type_relaxed.hpp" -using namespace ngraph; +using namespace ov; using namespace std; std::shared_ptr create_complex_function(size_t wide = 50) { @@ -70,7 +70,7 @@ std::shared_ptr create_complex_function(size_t wide = 50) { nodes.push(out); } auto result = std::make_shared(nodes.front()); - return std::make_shared(ov::ResultVector{result}, ov::ParameterVector{parameter}); + return std::make_shared(ov::ResultVector{result}, ov::ParameterVector{parameter}); } TEST(threading, get_friendly_name) { @@ -83,14 +83,14 @@ TEST(threading, get_friendly_name) { auto add_a3 = make_shared(add_a2, iconst0); auto abs_add_a3 = std::make_shared(add_a3); - auto b = make_shared(element::i32, shape); + auto b = make_shared(element::i32, shape); auto add_b1 = make_shared(b, iconst0); auto add_b2 = make_shared(add_b1, iconst0); auto abs_add_b2 = std::make_shared(add_b2); auto graph = make_shared(abs_add_a3, abs_add_b2); - auto f = std::make_shared(ov::NodeVector{graph}, ParameterVector{a, b}); + auto f = std::make_shared(ov::NodeVector{graph}, ParameterVector{a, b}); const auto compare_names = [](const std::vector& names) { static std::unordered_set ref_names; @@ -104,7 +104,7 @@ TEST(threading, get_friendly_name) { } }; - const auto get_friendly_name = [&](const std::shared_ptr& f) { + const auto get_friendly_name = [&](const std::shared_ptr& f) { std::vector names; for (const auto& op : f->get_ops()) { names.emplace_back(op->get_friendly_name()); @@ -149,12 +149,12 @@ TEST(threading, check_atomic_guard) { TEST(threading, clone_with_new_inputs) { auto function = create_complex_function(100); - const auto cloneNodes = [&](const std::shared_ptr& f) { + const auto cloneNodes = [&](const std::shared_ptr& f) { auto orderedOps = function->get_ordered_ops(); std::vector> nodes; for (const auto& op : orderedOps) { - ngraph::OutputVector inputsForShapeInfer; - std::shared_ptr opToShapeInfer; + ov::OutputVector inputsForShapeInfer; + std::shared_ptr opToShapeInfer; const auto inSize = op->get_input_size(); for (size_t i = 0; i < inSize; i++) { diff --git a/src/core/tests/type_info.cpp b/src/core/tests/type_info.cpp index 98c1f9c8e14..c4a681f4b6d 100644 --- a/src/core/tests/type_info.cpp +++ b/src/core/tests/type_info.cpp @@ -8,7 +8,6 @@ #include "openvino/opsets/opset.hpp" #include "openvino/util/common_util.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START TEST(type_info, compare_old_type) { ov::DiscreteTypeInfo type1("type1"); ov::DiscreteTypeInfo type2("type2"); diff --git a/src/core/tests/type_prop_layers.cpp b/src/core/tests/type_prop_layers.cpp index f5bbaa9927e..897ebd56352 100644 --- a/src/core/tests/type_prop_layers.cpp +++ b/src/core/tests/type_prop_layers.cpp @@ -2,31 +2,33 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" -#include "ngraph/op/ctc_greedy_decoder.hpp" -#include "ngraph/op/interpolate.hpp" -#include "ngraph/op/region_yolo.hpp" -#include "ngraph/op/reorg_yolo.hpp" -#include "ngraph/op/roi_pooling.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/ctc_greedy_decoder.hpp" +#include "openvino/op/interpolate.hpp" +#include "openvino/op/parameter.hpp" +#include "openvino/op/region_yolo.hpp" +#include "openvino/op/reorg_yolo.hpp" +#include "openvino/op/roi_pooling.hpp" using namespace std; -using namespace ngraph; +using namespace ov; TEST(type_prop_layers, ctc_greedy_decoder) { - auto input = make_shared(element::f32, Shape{88, 2, 48}); - auto seq_len = make_shared(element::f32, Shape{88, 2}); - auto op = make_shared(input, seq_len, false); + auto input = make_shared(element::f32, Shape{88, 2, 48}); + auto seq_len = make_shared(element::f32, Shape{88, 2}); + auto op = make_shared(input, seq_len, false); ASSERT_EQ(op->get_shape(), (Shape{2, 88, 1, 1})); } TEST(type_prop_layers, interpolate) { - auto image = make_shared(element::f32, Shape{2, 2, 33, 65}); - auto dyn_output_shape = make_shared(element::i64, Shape{2}); + auto image = make_shared(element::f32, Shape{2, 2, 33, 65}); + auto dyn_output_shape = make_shared(element::i64, Shape{2}); auto output_shape = op::v0::Constant::create(element::i64, Shape{2}, {15, 30}); - op::v0::InterpolateAttrs attrs; + op::v0::Interpolate::Attributes attrs; attrs.axes = {2, 3}; attrs.mode = "nearest"; attrs.align_corners = true; @@ -42,32 +44,32 @@ TEST(type_prop_layers, interpolate) { } TEST(type_prop_layers, region_yolo1) { - auto inputs = make_shared(element::f32, Shape{1, 125, 13, 13}); - auto op = make_shared(inputs, 0, 0, 0, true, std::vector{}, 0, 1); + auto inputs = make_shared(element::f32, Shape{1, 125, 13, 13}); + auto op = make_shared(inputs, 0, 0, 0, true, std::vector{}, 0, 1); ASSERT_EQ(op->get_shape(), (Shape{1 * 125, 13, 13})); } TEST(type_prop_layers, region_yolo2) { - auto inputs = make_shared(element::f32, Shape{1, 125, 13, 13}); - auto op = make_shared(inputs, 0, 0, 0, true, std::vector{}, 0, 2); + auto inputs = make_shared(element::f32, Shape{1, 125, 13, 13}); + auto op = make_shared(inputs, 0, 0, 0, true, std::vector{}, 0, 2); ASSERT_EQ(op->get_shape(), (Shape{1 * 125 * 13, 13})); } TEST(type_prop_layers, region_yolo3) { - auto inputs = make_shared(element::f32, Shape{1, 125, 13, 13}); - auto op = make_shared(inputs, 4, 80, 1, false, std::vector{6, 7, 8}, 0, -1); + auto inputs = make_shared(element::f32, Shape{1, 125, 13, 13}); + auto op = make_shared(inputs, 4, 80, 1, false, std::vector{6, 7, 8}, 0, -1); ASSERT_EQ(op->get_shape(), (Shape{1, (80 + 4 + 1) * 3, 13, 13})); } TEST(type_prop_layers, reorg_yolo) { - auto inputs = make_shared(element::f32, Shape{2, 24, 34, 62}); - auto op = make_shared(inputs, Strides{2}); + auto inputs = make_shared(element::f32, Shape{2, 24, 34, 62}); + auto op = make_shared(inputs, Strides{2}); ASSERT_EQ(op->get_shape(), (Shape{2, 96, 17, 31})); } TEST(type_prop_layers, roi_pooling) { - auto inputs = make_shared(element::f32, Shape{2, 3, 4, 5}); - auto coords = make_shared(element::f32, Shape{150, 5}); - auto op = make_shared(inputs, coords, Shape{6, 6}, 0.0625f, "max"); + auto inputs = make_shared(element::f32, Shape{2, 3, 4, 5}); + auto coords = make_shared(element::f32, Shape{150, 5}); + auto op = make_shared(inputs, coords, Shape{6, 6}, 0.0625f, "max"); ASSERT_EQ(op->get_shape(), (Shape{150, 3, 6, 6})); } diff --git a/src/core/tests/type_relaxed_copy.cpp b/src/core/tests/type_relaxed_copy.cpp index 2472678dde0..700f26602fa 100644 --- a/src/core/tests/type_relaxed_copy.cpp +++ b/src/core/tests/type_relaxed_copy.cpp @@ -40,8 +40,8 @@ TEST_F(TypeRelaxedThreading, TypeRelaxedCloning) { auto inp1 = std::make_shared(element::i8, PartialShape{-1, -1, -1, -1}); auto inp2 = std::make_shared(element::i8, PartialShape{-1, -1, -1, -1}); - auto matMulRelaxed = std::make_shared>( - *as_type_ptr(ngraph::builder::makeMatMul(inp1_f32, inp2_f32, false, false)), + auto matMulRelaxed = std::make_shared>( + *as_type_ptr(ngraph::builder::makeMatMul(inp1_f32, inp2_f32, false, false)), element::f32); auto matMul = matMulRelaxed->clone_with_new_inputs({inp1, inp2}); @@ -50,4 +50,4 @@ TEST_F(TypeRelaxedThreading, TypeRelaxedCloning) { auto inp4 = std::make_shared(element::i8, PartialShape{-1, -1, -1, -1}); auto copied_matMul = matMulRelaxed->clone_with_new_inputs({inp3, inp4}); }); -} \ No newline at end of file +} diff --git a/src/core/tests/uint4.cpp b/src/core/tests/uint4.cpp index 8a571b5931d..5c3b0a5e06a 100644 --- a/src/core/tests/uint4.cpp +++ b/src/core/tests/uint4.cpp @@ -4,14 +4,14 @@ #include "common_test_utils/test_tools.hpp" #include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" +#include "openvino/op/constant.hpp" -using namespace ngraph; +using namespace ov; using namespace std; TEST(uint4, convert_u4_to_string) { vector values{171, 16}; - auto constant = make_shared(element::u4, Shape{3}, &values[0]); + auto constant = make_shared(element::u4, Shape{3}, &values[0]); vector ref{"10", "11", "1"}; for (size_t i = 0; i < 3; ++i) { @@ -21,7 +21,7 @@ TEST(uint4, convert_u4_to_string) { TEST(uint4, tensor_or_constant_size) { vector values{171, 16}; - auto constant = make_shared(element::u4, Shape{3}, &values[0]); + auto constant = make_shared(element::u4, Shape{3}, &values[0]); EXPECT_EQ(2, constant->get_byte_size()); ov::Tensor runtime_tensor(ov::element::u4, ov::Shape{3}); @@ -30,7 +30,7 @@ TEST(uint4, tensor_or_constant_size) { TEST(u1, tensor_or_constant_size) { vector values{171, 16}; - auto constant = make_shared(element::u1, Shape{3}, &values[0]); + auto constant = make_shared(element::u1, Shape{3}, &values[0]); EXPECT_EQ(1, constant->get_byte_size()); ov::Tensor runtime_tensor(ov::element::u1, ov::Shape{3}); diff --git a/src/core/tests/validation_utils.cpp b/src/core/tests/validation_utils.cpp index 694633ae03b..bb764230409 100644 --- a/src/core/tests/validation_utils.cpp +++ b/src/core/tests/validation_utils.cpp @@ -39,7 +39,7 @@ TEST(get_constant_from_source, invalidation_check) { } TEST(get_constant_from_source, extract_static_dim_from_dynamic_shape_check) { - auto data = std::make_shared(ngraph::element::f32, ov::PartialShape{-1, 1, 128}); + auto data = std::make_shared(ov::element::f32, ov::PartialShape{-1, 1, 128}); auto shape = std::make_shared(data); auto one = ov::opset8::Constant::create(ov::element::i64, {1}, {1}); auto zero = ov::opset8::Constant::create(ov::element::i64, {1}, {0});