Skip to content

Commit ad1c824

Browse files
authored
Eliminate reader tests (openvinotoolkit#13409)
* remove reader tests #1 * remove reader tests #2 * remove reader tests #3 * remove reader tests #4 * Add clone_with_new_inputs to visitor tests * fixes
1 parent ee93ddc commit ad1c824

File tree

233 files changed

+2303
-29501
lines changed

Some content is hidden

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

233 files changed

+2303
-29501
lines changed

src/core/tests/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ set(SRC
270270
visitors/dimension.cpp
271271
visitors/user_op.cpp
272272
visitors/value_map.cpp
273+
visitors/op/abs.cpp
273274
visitors/op/acos.cpp
274275
visitors/op/acosh.cpp
275276
visitors/op/adaptive_avg_pool.cpp
@@ -288,6 +289,7 @@ set(SRC
288289
visitors/op/bucketize.cpp
289290
visitors/op/ceiling.cpp
290291
visitors/op/clamp.cpp
292+
visitors/op/concat.cpp
291293
visitors/op/constant.cpp
292294
visitors/op/convert.cpp
293295
visitors/op/convert_color_i420.cpp
@@ -380,6 +382,7 @@ set(SRC
380382
visitors/op/proposal.cpp
381383
visitors/op/psroi_pooling.cpp
382384
visitors/op/random_uniform.cpp
385+
visitors/op/range.cpp
383386
visitors/op/rdft.cpp
384387
visitors/op/read_value.cpp
385388
visitors/op/reduce_l1.cpp
@@ -430,6 +433,7 @@ set(SRC
430433
visitors/op/tan.cpp
431434
visitors/op/tanh.cpp
432435
visitors/op/tensor_iterator.cpp
436+
visitors/op/tile.cpp
433437
visitors/op/topk.cpp
434438
visitors/op/transpose.cpp
435439
visitors/op/unsqueeze.cpp

src/core/tests/visitors/op/abs.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright (C) 2018-2022 Intel Corporation
2+
// SPDX-License-Identifier: Apache-2.0
3+
//
4+
5+
#include "unary_ops.hpp"
6+
7+
using Type = ::testing::Types<UnaryOperatorType<ngraph::op::Abs, ngraph::element::f32>>;
8+
9+
INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_attribute, UnaryOperatorVisitor, Type, UnaryOperatorTypeName);

src/core/tests/visitors/op/adaptive_avg_pool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ TEST(attributes, adaptive_avg_pool_op) {
1818
const auto out_shape = op::Constant::create<int64_t>(element::i64, Shape{2}, {4, 3});
1919

2020
const auto adaptive_pool = make_shared<opset8::AdaptiveAvgPool>(A, out_shape);
21-
NodeBuilder builder(adaptive_pool);
21+
NodeBuilder builder(adaptive_pool, {A, out_shape});
2222

2323
const auto expected_attr_count = 0;
2424
EXPECT_EQ(builder.get_value_map_size(), expected_attr_count);

src/core/tests/visitors/op/adaptive_max_pool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ TEST(attributes, adaptive_max_pool_op) {
1818
const auto out_shape = op::Constant::create<int64_t>(element::i64, Shape{2}, {4, 3});
1919

2020
const auto adaptive_pool = make_shared<opset8::AdaptiveMaxPool>(A, out_shape);
21-
NodeBuilder builder(adaptive_pool);
21+
NodeBuilder builder(adaptive_pool, {A, out_shape});
2222
auto g_adaptive_pool = ov::as_type_ptr<opset8::AdaptiveMaxPool>(builder.create());
2323

2424
const auto expected_attr_count = 1;

src/core/tests/visitors/op/assign.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ TEST(attributes, assign_v3_op) {
2020
const string variable_id = "v0";
2121
const auto read_value = make_shared<opset3::ReadValue>(in, variable_id);
2222
const auto assign = make_shared<opset3::Assign>(read_value, variable_id);
23-
NodeBuilder builder(assign);
23+
NodeBuilder builder(assign, {read_value});
2424

2525
// attribute count
2626
const auto expected_attr_count = 1;
@@ -33,7 +33,7 @@ TEST(attributes, assign_v6_op) {
3333
const auto variable = std::make_shared<Variable>(VariableInfo{PartialShape::dynamic(), element::dynamic, "v0"});
3434
const auto read_value = make_shared<opset6::ReadValue>(in, variable);
3535
const auto assign = make_shared<opset6::Assign>(read_value, variable);
36-
NodeBuilder builder(assign);
36+
NodeBuilder builder(assign, {read_value});
3737

3838
// attribute count
3939
const auto expected_attr_count = 1;

src/core/tests/visitors/op/avg_pool.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ TEST(attributes, avg_pool_op) {
2929
auto avg_pool =
3030
make_shared<opset1::AvgPool>(data, strides, pads_begin, pads_end, kernel, exclude_pad, rounding_mode, auto_pad);
3131

32-
NodeBuilder builder(avg_pool);
32+
NodeBuilder builder(avg_pool, {data});
3333
auto g_avg_pool = ov::as_type_ptr<opset1::AvgPool>(builder.create());
3434

3535
EXPECT_EQ(g_avg_pool->get_strides(), avg_pool->get_strides());
@@ -54,7 +54,7 @@ TEST(attributes, avg_pool_v8_op) {
5454

5555
const auto avg_pool =
5656
make_shared<opset8::AvgPool>(data, strides, pads_begin, pads_end, kernel, exclude_pad, rounding_mode, auto_pad);
57-
NodeBuilder builder(avg_pool);
57+
NodeBuilder builder(avg_pool, {data});
5858
auto g_avg_pool = ov::as_type_ptr<opset8::AvgPool>(builder.create());
5959

6060
EXPECT_EQ(g_avg_pool->get_strides(), avg_pool->get_strides());

src/core/tests/visitors/op/batch_norm.cpp

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,44 @@ using namespace ngraph;
1616
using ngraph::test::NodeBuilder;
1717
using ngraph::test::ValueMap;
1818

19-
template <class T>
20-
class BatchNormAttrTest : public ::testing::Test {};
21-
22-
TYPED_TEST_SUITE_P(BatchNormAttrTest);
23-
24-
TYPED_TEST_P(BatchNormAttrTest, batch_norm_inference_op) {
19+
TEST(attributes, batch_norm_inference_op_v5) {
2520
PartialShape in_shape{1, 10};
2621
PartialShape ch_shape{in_shape[1]};
2722
element::Type et = element::f32;
2823
double epsilon = 0.001;
2924

30-
NodeBuilder::get_ops().register_factory<TypeParam>();
25+
NodeBuilder::get_ops().register_factory<op::v5::BatchNormInference>();
3126
auto data_batch = make_shared<op::Parameter>(et, in_shape);
3227
auto gamma = make_shared<op::Parameter>(et, ch_shape);
3328
auto beta = make_shared<op::Parameter>(et, ch_shape);
3429
auto mean = make_shared<op::Parameter>(et, ch_shape);
3530
auto var = make_shared<op::Parameter>(et, ch_shape);
36-
auto batch_norm = make_shared<TypeParam>(data_batch, gamma, beta, mean, var, epsilon);
31+
auto batch_norm = make_shared<op::v5::BatchNormInference>(data_batch, gamma, beta, mean, var, epsilon);
3732

3833
const auto expected_attr_count = 1;
39-
NodeBuilder builder(batch_norm);
34+
NodeBuilder builder(batch_norm, {data_batch, gamma, beta, mean, var});
4035
EXPECT_EQ(builder.get_value_map_size(), expected_attr_count);
41-
auto g_batch_norm = ov::as_type_ptr<TypeParam>(builder.create());
36+
auto g_batch_norm = ov::as_type_ptr<op::v5::BatchNormInference>(builder.create());
4237
EXPECT_EQ(g_batch_norm->get_eps_value(), batch_norm->get_eps_value());
4338
}
4439

45-
REGISTER_TYPED_TEST_SUITE_P(BatchNormAttrTest, batch_norm_inference_op);
40+
TEST(attributes, batch_norm_inference_op_v0) {
41+
PartialShape in_shape{1, 10};
42+
PartialShape ch_shape{in_shape[1]};
43+
element::Type et = element::f32;
44+
double epsilon = 0.001;
4645

47-
using Types = ::testing::Types<op::v0::BatchNormInference, op::v5::BatchNormInference>;
46+
NodeBuilder::get_ops().register_factory<op::v0::BatchNormInference>();
47+
auto data_batch = make_shared<op::Parameter>(et, in_shape);
48+
auto gamma = make_shared<op::Parameter>(et, ch_shape);
49+
auto beta = make_shared<op::Parameter>(et, ch_shape);
50+
auto mean = make_shared<op::Parameter>(et, ch_shape);
51+
auto var = make_shared<op::Parameter>(et, ch_shape);
52+
auto batch_norm = make_shared<op::v0::BatchNormInference>(data_batch, gamma, beta, mean, var, epsilon);
4853

49-
INSTANTIATE_TYPED_TEST_SUITE_P(attributes, BatchNormAttrTest, Types);
54+
const auto expected_attr_count = 1;
55+
NodeBuilder builder(batch_norm, {gamma, beta, data_batch, mean, var});
56+
EXPECT_EQ(builder.get_value_map_size(), expected_attr_count);
57+
auto g_batch_norm = ov::as_type_ptr<op::v0::BatchNormInference>(builder.create());
58+
EXPECT_EQ(g_batch_norm->get_eps_value(), batch_norm->get_eps_value());
59+
}

src/core/tests/visitors/op/batch_to_space.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ TEST(attributes, batch_to_space_op) {
1919
auto crops_end = make_shared<op::Constant>(element::i64, Shape{2}, vector<int64_t>{0, 0});
2020
auto batch2space = make_shared<op::v1::BatchToSpace>(data, block_shape, crops_begin, crops_end);
2121

22-
NodeBuilder builder(batch2space);
22+
NodeBuilder builder(batch2space, {data});
2323
const auto expected_attr_count = 0;
2424

2525
EXPECT_EQ(builder.get_value_map_size(), expected_attr_count);

src/core/tests/visitors/op/binary_convolution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ TEST(attributes, bin_convolution) {
4040
mode,
4141
pad_value,
4242
auto_pad);
43-
NodeBuilder builder(conv);
43+
NodeBuilder builder(conv, {data_batch, filters});
4444
auto g_convolution = ov::as_type_ptr<op::v1::BinaryConvolution>(builder.create());
4545

4646
// attribute count

src/core/tests/visitors/op/binary_ops.hpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,32 @@ TYPED_TEST_P(BinaryOperatorVisitor, Auto_Broadcast)
4949
auto auto_broadcast = ngraph::op::AutoBroadcastType::NUMPY;
5050

5151
const auto op_func = std::make_shared<OP_Type>(A, B, auto_broadcast);
52-
ngraph::test::NodeBuilder builder(op_func);
52+
ngraph::test::NodeBuilder builder(op_func, {A, B});
5353
const auto g_op_func = ngraph::as_type_ptr<OP_Type>(builder.create());
5454

5555
const auto expected_attr_count = 1;
5656
EXPECT_EQ(builder.get_value_map_size(), expected_attr_count);
5757
EXPECT_EQ(op_func->get_autob(), g_op_func->get_autob());
5858
}
5959

60-
REGISTER_TYPED_TEST_SUITE_P(BinaryOperatorVisitor, Auto_Broadcast);
60+
TYPED_TEST_P(BinaryOperatorVisitor, No_Broadcast)
61+
{
62+
using OP_Type = typename TypeParam::op_type;
63+
const ngraph::element::Type_t element_type = TypeParam::element_type;
64+
65+
ngraph::test::NodeBuilder::get_ops().register_factory<OP_Type>();
66+
const auto A =
67+
std::make_shared<ngraph::op::Parameter>(element_type, ngraph::PartialShape{1, 2, 3});
68+
const auto B =
69+
std::make_shared<ngraph::op::Parameter>(element_type, ngraph::PartialShape{1, 2, 3});
70+
71+
const auto op_func = std::make_shared<OP_Type>(A, B);
72+
ngraph::test::NodeBuilder builder(op_func, {A, B});
73+
const auto g_op_func = ngraph::as_type_ptr<OP_Type>(builder.create());
74+
75+
const auto expected_attr_count = 1;
76+
EXPECT_EQ(builder.get_value_map_size(), expected_attr_count);
77+
EXPECT_EQ(op_func->get_autob(), g_op_func->get_autob());
78+
}
79+
80+
REGISTER_TYPED_TEST_SUITE_P(BinaryOperatorVisitor, Auto_Broadcast, No_Broadcast);

0 commit comments

Comments
 (0)