Skip to content

Commit

Permalink
remove reader tests #2
Browse files Browse the repository at this point in the history
  • Loading branch information
olpipi committed Oct 14, 2022
1 parent 6fd3ce6 commit ad88f65
Show file tree
Hide file tree
Showing 24 changed files with 208 additions and 5,503 deletions.
2 changes: 2 additions & 0 deletions src/core/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ set(SRC
visitors/op/bucketize.cpp
visitors/op/ceiling.cpp
visitors/op/clamp.cpp
visitors/op/concat.cpp
visitors/op/constant.cpp
visitors/op/convert.cpp
visitors/op/convert_color_i420.cpp
Expand Down Expand Up @@ -372,6 +373,7 @@ set(SRC
visitors/op/proposal.cpp
visitors/op/psroi_pooling.cpp
visitors/op/random_uniform.cpp
visitors/op/range.cpp
visitors/op/rdft.cpp
visitors/op/read_value.cpp
visitors/op/reduce_l1.cpp
Expand Down
22 changes: 21 additions & 1 deletion src/core/tests/visitors/op/binary_ops.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,24 @@ TYPED_TEST_P(BinaryOperatorVisitor, Auto_Broadcast)
EXPECT_EQ(op_func->get_autob(), g_op_func->get_autob());
}

REGISTER_TYPED_TEST_SUITE_P(BinaryOperatorVisitor, Auto_Broadcast);
TYPED_TEST_P(BinaryOperatorVisitor, No_Broadcast)
{
using OP_Type = typename TypeParam::op_type;
const ngraph::element::Type_t element_type = TypeParam::element_type;

ngraph::test::NodeBuilder::get_ops().register_factory<OP_Type>();
const auto A =
std::make_shared<ngraph::op::Parameter>(element_type, ngraph::PartialShape{1, 2, 3});
const auto B =
std::make_shared<ngraph::op::Parameter>(element_type, ngraph::PartialShape{1, 2, 3});

const auto op_func = std::make_shared<OP_Type>(A, B);
ngraph::test::NodeBuilder builder(op_func);
const auto g_op_func = ngraph::as_type_ptr<OP_Type>(builder.create());

const auto expected_attr_count = 1;
EXPECT_EQ(builder.get_value_map_size(), expected_attr_count);
EXPECT_EQ(op_func->get_autob(), g_op_func->get_autob());
}

REGISTER_TYPED_TEST_SUITE_P(BinaryOperatorVisitor, Auto_Broadcast, No_Broadcast);
29 changes: 29 additions & 0 deletions src/core/tests/visitors/op/concat.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (C) 2018-2022 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//


#include "gtest/gtest.h"
#include "ngraph/ngraph.hpp"
#include "ngraph/op/util/attr_types.hpp"
#include "ngraph/opsets/opset1.hpp"
#include "util/visitor.hpp"

using namespace std;
using namespace ngraph;
using ngraph::test::NodeBuilder;
using ngraph::test::ValueMap;

TEST(attributes, concat_op) {
NodeBuilder::get_ops().register_factory<opset1::Concat>();
auto input1 = make_shared<op::Parameter>(element::i64, Shape{1, 2, 3});
auto input2 = make_shared<op::Parameter>(element::i64, Shape{1, 2, 3});
auto input3 = make_shared<op::Parameter>(element::i64, Shape{1, 2, 3});
int64_t axis = 2;

auto concat = make_shared<opset1::Concat>(ov::NodeVector{input1, input2, input3}, axis);
NodeBuilder builder(concat);
auto g_concat = ov::as_type_ptr<opset1::Concat>(builder.create());

EXPECT_EQ(g_concat->get_axis(), concat->get_axis());
}
23 changes: 22 additions & 1 deletion src/core/tests/visitors/op/gelu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using namespace std;
using namespace ngraph;
using ngraph::test::NodeBuilder;

TEST(attributes, gelu_op) {
TEST(attributes, gelu_op_erf) {
NodeBuilder::get_ops().register_factory<opset7::Gelu>();
const auto data_input = make_shared<op::Parameter>(element::f32, Shape{1, 2, 3});
const auto approximation_mode = op::GeluApproximationMode::ERF;
Expand All @@ -22,3 +22,24 @@ TEST(attributes, gelu_op) {

EXPECT_EQ(g_gelu->get_approximation_mode(), gelu->get_approximation_mode());
}

TEST(attributes, gelu_op_tanh) {
NodeBuilder::get_ops().register_factory<opset7::Gelu>();
const auto data_input = make_shared<op::Parameter>(element::f32, Shape{1, 2, 3});
const auto approximation_mode = op::GeluApproximationMode::TANH;
const auto gelu = make_shared<opset7::Gelu>(data_input, approximation_mode);
NodeBuilder builder(gelu);
auto g_gelu = ov::as_type_ptr<opset7::Gelu>(builder.create());

EXPECT_EQ(g_gelu->get_approximation_mode(), gelu->get_approximation_mode());
}

TEST(attributes, gelu_op) {
NodeBuilder::get_ops().register_factory<opset7::Gelu>();
const auto data_input = make_shared<op::Parameter>(element::f32, Shape{1, 2, 3});
const auto gelu = make_shared<opset7::Gelu>(data_input);
NodeBuilder builder(gelu);
auto g_gelu = ov::as_type_ptr<opset7::Gelu>(builder.create());

EXPECT_EQ(g_gelu->get_approximation_mode(), gelu->get_approximation_mode());
}
58 changes: 58 additions & 0 deletions src/core/tests/visitors/op/matmul.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,61 @@ TEST(attributes, matmul_op) {
EXPECT_EQ(g_matmul->get_transpose_a(), matmul->get_transpose_a());
EXPECT_EQ(g_matmul->get_transpose_b(), matmul->get_transpose_b());
}

TEST(attributes, matmul_op2) {
NodeBuilder::get_ops().register_factory<opset1::MatMul>();
auto A = make_shared<op::Parameter>(element::f32, Shape{10, 2});
auto B = make_shared<op::Parameter>(element::f32, Shape{2, 1});

bool transpose_a = false;
bool transpose_b = false;

auto matmul = make_shared<opset1::MatMul>(A, B, transpose_a, transpose_b);
NodeBuilder builder(matmul);
auto g_matmul = ov::as_type_ptr<opset1::MatMul>(builder.create());

EXPECT_EQ(g_matmul->get_transpose_a(), matmul->get_transpose_a());
EXPECT_EQ(g_matmul->get_transpose_b(), matmul->get_transpose_b());
}

TEST(attributes, matmul_op3) {
NodeBuilder::get_ops().register_factory<opset1::MatMul>();
auto A = make_shared<op::Parameter>(element::f32, Shape{2, 10});
auto B = make_shared<op::Parameter>(element::f32, Shape{2, 1});

bool transpose_a = true;
bool transpose_b = false;

auto matmul = make_shared<opset1::MatMul>(A, B, transpose_a, transpose_b);
NodeBuilder builder(matmul);
auto g_matmul = ov::as_type_ptr<opset1::MatMul>(builder.create());

EXPECT_EQ(g_matmul->get_transpose_a(), matmul->get_transpose_a());
EXPECT_EQ(g_matmul->get_transpose_b(), matmul->get_transpose_b());
}

TEST(attributes, matmul_op4) {
NodeBuilder::get_ops().register_factory<opset1::MatMul>();
auto A = make_shared<op::Parameter>(element::f32, Shape{2, 3, 2});
auto B = make_shared<op::Parameter>(element::f32, Shape{3, 2, 2, 1});

auto matmul = make_shared<opset1::MatMul>(A, B);
NodeBuilder builder(matmul);
auto g_matmul = ov::as_type_ptr<opset1::MatMul>(builder.create());

EXPECT_EQ(g_matmul->get_transpose_a(), matmul->get_transpose_a());
EXPECT_EQ(g_matmul->get_transpose_b(), matmul->get_transpose_b());
}

TEST(attributes, matmul_op5) {
NodeBuilder::get_ops().register_factory<opset1::MatMul>();
auto A = make_shared<op::Parameter>(element::f32, Shape{2});
auto B = make_shared<op::Parameter>(element::f32, Shape{2, 10});

auto matmul = make_shared<opset1::MatMul>(A, B);
NodeBuilder builder(matmul);
auto g_matmul = ov::as_type_ptr<opset1::MatMul>(builder.create());

EXPECT_EQ(g_matmul->get_transpose_a(), matmul->get_transpose_a());
EXPECT_EQ(g_matmul->get_transpose_b(), matmul->get_transpose_b());
}
16 changes: 16 additions & 0 deletions src/core/tests/visitors/op/pad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,19 @@ TEST(attributes, pad_op) {

EXPECT_EQ(g_pad->get_pad_mode(), pad->get_pad_mode());
}

TEST(attributes, pad_op2) {
NodeBuilder::get_ops().register_factory<opset1::Pad>();
auto arg = make_shared<op::Parameter>(element::f32, Shape{1, 2, 3});
auto pads_begin = make_shared<op::Parameter>(element::i64, Shape{1});
auto pads_end = make_shared<op::Parameter>(element::i64, Shape{1});
auto pad_value = make_shared<op::Parameter>(element::f32, Shape{});

auto pad_mode = op::PadMode::CONSTANT;

auto pad = make_shared<opset1::Pad>(arg, pads_begin, pads_end, pad_value, pad_mode);
NodeBuilder builder(pad);
auto g_pad = ov::as_type_ptr<opset1::Pad>(builder.create());

EXPECT_EQ(g_pad->get_pad_mode(), pad->get_pad_mode());
}
29 changes: 29 additions & 0 deletions src/core/tests/visitors/op/range.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (C) 2018-2022 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include "gtest/gtest.h"
#include "ngraph/ngraph.hpp"
#include "ngraph/op/util/attr_types.hpp"
#include "ngraph/opsets/opset1.hpp"
#include "ngraph/opsets/opset4.hpp"
#include "util/visitor.hpp"

using namespace std;
using namespace ngraph;
using ngraph::test::NodeBuilder;
using ngraph::test::ValueMap;

TEST(attributes, range_op) {
NodeBuilder::get_ops().register_factory<opset4::Range>();
auto start = make_shared<op::Parameter>(element::i64, Shape{});
auto stop = make_shared<op::Parameter>(element::i64, Shape{});
auto step = make_shared<op::Parameter>(element::i64, Shape{});
auto output_type = element::f32;

auto range = make_shared<opset4::Range>(start, stop, step, output_type);
NodeBuilder builder(range);
auto g_range = ov::as_type_ptr<opset4::Range>(builder.create());

EXPECT_EQ(g_range->get_output_type(), range->get_output_type());
}
20 changes: 19 additions & 1 deletion src/core/tests/visitors/op/select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using namespace ngraph;
using ngraph::test::NodeBuilder;
using ngraph::test::ValueMap;

TEST(attributes, select) {
TEST(attributes, select_fp32) {
NodeBuilder::get_ops().register_factory<opset1::Select>();
auto in_cond = std::make_shared<op::Parameter>(element::boolean, Shape{3, 2});
auto in_then = std::make_shared<op::Parameter>(element::f32, Shape{3, 2});
Expand All @@ -29,3 +29,21 @@ TEST(attributes, select) {
auto g_select = ov::as_type_ptr<opset1::Select>(builder.create());
EXPECT_EQ(g_select->get_autob(), select->get_autob());
}

TEST(attributes, select_i32) {
NodeBuilder::get_ops().register_factory<opset1::Select>();
auto in_cond = std::make_shared<op::Parameter>(element::boolean, Shape{3, 2});
auto in_then = std::make_shared<op::Parameter>(element::i32, Shape{3, 2});
auto in_else = std::make_shared<op::Parameter>(element::i32, Shape{3, 2});

auto auto_broadcast = op::AutoBroadcastType::NUMPY;

auto select = std::make_shared<opset1::Select>(in_cond, in_then, in_else, auto_broadcast);
NodeBuilder builder(select);

const auto expected_attr_count = 1;
EXPECT_EQ(builder.get_value_map_size(), expected_attr_count);

auto g_select = ov::as_type_ptr<opset1::Select>(builder.create());
EXPECT_EQ(g_select->get_autob(), select->get_autob());
}
15 changes: 12 additions & 3 deletions src/core/tests/visitors/op/split.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
#include "ngraph/ngraph.hpp"
#include "ngraph/op/util/attr_types.hpp"
#include "ngraph/opsets/opset1.hpp"
#include "ngraph/opsets/opset3.hpp"
#include "ngraph/opsets/opset4.hpp"
#include "ngraph/opsets/opset5.hpp"
#include "util/visitor.hpp"

using namespace std;
Expand All @@ -27,3 +24,15 @@ TEST(attributes, split_op) {

EXPECT_EQ(g_split->get_num_splits(), split->get_num_splits());
}

TEST(attributes, split_op2) {
NodeBuilder::get_ops().register_factory<opset1::Split>();
auto data = make_shared<op::Parameter>(element::i32, Shape{300});
auto axis = make_shared<op::Parameter>(element::i32, Shape{});
auto num_splits = 3;
auto split = make_shared<opset1::Split>(data, axis, num_splits);
NodeBuilder builder(split);
auto g_split = ov::as_type_ptr<opset1::Split>(builder.create());

EXPECT_EQ(g_split->get_num_splits(), split->get_num_splits());
}
Loading

0 comments on commit ad88f65

Please sign in to comment.