Refactor visitor tests for UnaryElementwiseArithmetic ops (#6756)
* remove namespace dependencies from header file * add RVO-exploit string concatenating * update acosh test * update erf test
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
//
|
||||
|
||||
#include "unary_ops.hpp"
|
||||
using Type = ::testing::Types<UnaryOperatorType<ngraph::op::Acosh, element::f32>>;
|
||||
|
||||
using Type = ::testing::Types<UnaryOperatorType<ngraph::op::Acosh, ngraph::element::f32>>;
|
||||
|
||||
INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_attribute,
|
||||
UnaryOperatorVisitor,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//
|
||||
|
||||
#include "unary_ops.hpp"
|
||||
using Type = ::testing::Types<UnaryOperatorType<ngraph::op::Asinh, element::f32>>;
|
||||
using Type = ::testing::Types<UnaryOperatorType<ngraph::op::Asinh, ngraph::element::f32>>;
|
||||
|
||||
INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_attribute,
|
||||
UnaryOperatorVisitor,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "unary_ops.hpp"
|
||||
|
||||
using Types = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Atan, element::f32>>;
|
||||
using Types = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Atan, ngraph::element::f32>>;
|
||||
|
||||
INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_attribute,
|
||||
UnaryOperatorVisitor,
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
//
|
||||
|
||||
#include "unary_ops.hpp"
|
||||
using Type = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Ceiling, element::f32>>;
|
||||
|
||||
using Type = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Ceiling, ngraph::element::f32>>;
|
||||
|
||||
INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_attribute,
|
||||
UnaryOperatorVisitor,
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
//
|
||||
|
||||
#include "unary_ops.hpp"
|
||||
using Type = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Cos, element::f32>>;
|
||||
|
||||
using Type = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Cos, ngraph::element::f32>>;
|
||||
|
||||
INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_attribute,
|
||||
UnaryOperatorVisitor,
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
//
|
||||
|
||||
#include "unary_ops.hpp"
|
||||
using Type = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Cosh, element::f32>>;
|
||||
|
||||
using Type = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Cosh, ngraph::element::f32>>;
|
||||
|
||||
INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_attribute,
|
||||
UnaryOperatorVisitor,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "unary_ops.hpp"
|
||||
|
||||
using Type = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Erf, element::f32>>;
|
||||
using Type = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Erf, ngraph::element::f32>>;
|
||||
|
||||
INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_atrribute,
|
||||
UnaryOperatorVisitor,
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#include "unary_ops.hpp"
|
||||
|
||||
using Types = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Floor, element::f32>,
|
||||
UnaryOperatorType<ngraph::op::v0::Floor, element::f16>>;
|
||||
using Types = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Floor, ngraph::element::f32>,
|
||||
UnaryOperatorType<ngraph::op::v0::Floor, ngraph::element::f16>>;
|
||||
|
||||
INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_attribute,
|
||||
UnaryOperatorVisitor,
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "unary_ops.hpp"
|
||||
using Types = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Log, element::f32>,
|
||||
UnaryOperatorType<ngraph::op::v0::Log, element::f16>>;
|
||||
|
||||
using Types = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Log, ngraph::element::f32>,
|
||||
UnaryOperatorType<ngraph::op::v0::Log, ngraph::element::f16>>;
|
||||
|
||||
INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_attribute,
|
||||
UnaryOperatorVisitor,
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#include "unary_ops.hpp"
|
||||
|
||||
using Types = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Negative, element::f32>,
|
||||
UnaryOperatorType<ngraph::op::v0::Negative, element::i32>>;
|
||||
using Types = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Negative, ngraph::element::f32>,
|
||||
UnaryOperatorType<ngraph::op::v0::Negative, ngraph::element::i32>>;
|
||||
|
||||
INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_attribute,
|
||||
UnaryOperatorVisitor,
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#include "unary_ops.hpp"
|
||||
|
||||
using Types = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Result, element::f32>,
|
||||
UnaryOperatorType<ngraph::op::v0::Result, element::f16>>;
|
||||
using Types = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Result, ngraph::element::f32>,
|
||||
UnaryOperatorType<ngraph::op::v0::Result, ngraph::element::f16>>;
|
||||
|
||||
INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_attribute,
|
||||
UnaryOperatorVisitor,
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
//
|
||||
|
||||
#include "unary_ops.hpp"
|
||||
using Type = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Sign, element::f32>>;
|
||||
|
||||
using Type = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Sign, ngraph::element::f32>>;
|
||||
|
||||
INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_attribute,
|
||||
UnaryOperatorVisitor,
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
//
|
||||
|
||||
#include "unary_ops.hpp"
|
||||
using Type = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Sinh, element::f32>>;
|
||||
|
||||
using Type = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Sinh, ngraph::element::f32>>;
|
||||
|
||||
INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_attribute,
|
||||
UnaryOperatorVisitor,
|
||||
Type,
|
||||
UnaryOperatorTypeName);
|
||||
UnaryOperatorVisitor,
|
||||
Type,
|
||||
UnaryOperatorTypeName);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "unary_ops.hpp"
|
||||
|
||||
using Types = ::testing::Types<UnaryOperatorType<ngraph::op::v4::SoftPlus, element::f32>>;
|
||||
using Types = ::testing::Types<UnaryOperatorType<ngraph::op::v4::SoftPlus, ngraph::element::f32>>;
|
||||
|
||||
INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_atrribute,
|
||||
UnaryOperatorVisitor,
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
//
|
||||
|
||||
#include "unary_ops.hpp"
|
||||
using Types = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Sqrt, element::f32>,
|
||||
UnaryOperatorType<ngraph::op::v0::Sqrt, element::f16>>;
|
||||
|
||||
using Types = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Sqrt, ngraph::element::f32>,
|
||||
UnaryOperatorType<ngraph::op::v0::Sqrt, ngraph::element::f16>>;
|
||||
|
||||
INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_attribute,
|
||||
UnaryOperatorVisitor,
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
//
|
||||
|
||||
#include "unary_ops.hpp"
|
||||
using Types = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Squeeze, element::f32>,
|
||||
UnaryOperatorType<ngraph::op::v0::Squeeze, element::f16>>;
|
||||
|
||||
using Types = ::testing::Types<UnaryOperatorType<ngraph::op::v0::Squeeze, ngraph::element::f32>,
|
||||
UnaryOperatorType<ngraph::op::v0::Squeeze, ngraph::element::f16>>;
|
||||
|
||||
INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_attribute,
|
||||
UnaryOperatorVisitor,
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "unary_ops.hpp"
|
||||
|
||||
using Type = ::testing::Types<UnaryOperatorType<ngraph::op::v4::Swish, element::f32>>;
|
||||
using Type = ::testing::Types<UnaryOperatorType<ngraph::op::v4::Swish, ngraph::element::f32>>;
|
||||
|
||||
INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_atrribute,
|
||||
UnaryOperatorVisitor,
|
||||
|
||||
@@ -4,21 +4,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "gtest/gtest.h"
|
||||
#include "ngraph/ngraph.hpp"
|
||||
|
||||
#include "ngraph/op/util/attr_types.hpp"
|
||||
#include "util/visitor.hpp"
|
||||
|
||||
using namespace ngraph;
|
||||
using ngraph::test::NodeBuilder;
|
||||
template <typename T, element::Type_t ELEMENT_TYPE>
|
||||
template <typename T, ngraph::element::Type_t ELEMENT_TYPE>
|
||||
class UnaryOperatorType
|
||||
{
|
||||
public:
|
||||
using op_type = T;
|
||||
static constexpr element::Type_t element_type = ELEMENT_TYPE;
|
||||
static constexpr ngraph::element::Type_t element_type = ELEMENT_TYPE;
|
||||
};
|
||||
template <typename T>
|
||||
class UnaryOperatorVisitor : public testing::Test
|
||||
@@ -32,11 +26,9 @@ public:
|
||||
static std::string GetName(int)
|
||||
{
|
||||
using OP_Type = typename T::op_type;
|
||||
constexpr element::Type precision(T::element_type);
|
||||
constexpr ngraph::element::Type precision(T::element_type);
|
||||
const ngraph::Node::type_info_t typeinfo = OP_Type::get_type_info_static();
|
||||
std::string op_name{typeinfo.name};
|
||||
op_name.append("_");
|
||||
return (op_name.append(precision.get_type_name()));
|
||||
return std::string{typeinfo.name} + "_" + precision.get_type_name();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -45,13 +37,13 @@ TYPED_TEST_SUITE_P(UnaryOperatorVisitor);
|
||||
TYPED_TEST_P(UnaryOperatorVisitor, No_Attribute_4D)
|
||||
{
|
||||
using OP_Type = typename TypeParam::op_type;
|
||||
const element::Type_t element_type = TypeParam::element_type;
|
||||
const ngraph::element::Type_t element_type = TypeParam::element_type;
|
||||
|
||||
NodeBuilder::get_ops().register_factory<OP_Type>();
|
||||
const auto A = std::make_shared<op::Parameter>(element_type, PartialShape{2, 2, 2, 2});
|
||||
ngraph::test::NodeBuilder::get_ops().register_factory<OP_Type>();
|
||||
const auto A = std::make_shared<ngraph::op::Parameter>(element_type, ngraph::PartialShape{2, 2, 2, 2});
|
||||
|
||||
const auto op_func = std::make_shared<OP_Type>(A);
|
||||
NodeBuilder builder(op_func);
|
||||
ngraph::test::NodeBuilder builder(op_func);
|
||||
const auto expected_attr_count = 0;
|
||||
EXPECT_EQ(builder.get_value_map_size(), expected_attr_count);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user