Files
openvino/ngraph/test/visitors/op/binary_ops.hpp
T
Dawid Kożykowski b4ad7a1755 Refactor visitor tests for BinaryElementwiseArithmetic ops (#6667)
* add binary_elementwise file

* change binary_elementwise.hpp to binary_ops.hpp

* migrate mod operation test o typed template test

* add tests for remaining binary ops

* remove comment

* fix formatting to match clang-format

* add RVO-exploit string concatenating andbeautify the code

* add validation for attributes number

* add missing visit_attributes() calls

* add missing 4th param to NGRAPH_RTTI_DEFINITION calls

* fix formatting to match clang-format
2021-07-26 15:49:14 +03:00

61 lines
1.8 KiB
C++

// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include "gtest/gtest.h"
#include "util/visitor.hpp"
template <typename T, ngraph::element::Type_t ELEMENT_TYPE>
class BinaryOperatorType
{
public:
using op_type = T;
static constexpr ngraph::element::Type_t element_type = ELEMENT_TYPE;
};
template <typename T>
class BinaryOperatorVisitor : public testing::Test
{
};
class BinaryOperatorTypeName
{
public:
template <typename T>
static std::string GetName(int)
{
using OP_Type = typename T::op_type;
constexpr ngraph::element::Type precision(T::element_type);
const ngraph::Node::type_info_t typeinfo = OP_Type::get_type_info_static();
return std::string{typeinfo.name} + "_" + precision.get_type_name();
}
};
TYPED_TEST_SUITE_P(BinaryOperatorVisitor);
TYPED_TEST_P(BinaryOperatorVisitor, Auto_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{3, 2, 1});
auto auto_broadcast = ngraph::op::AutoBroadcastType::NUMPY;
const auto op_func = std::make_shared<OP_Type>(A, B, auto_broadcast);
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);