Migrate acos operation from ngraph backend test to template plugin reference test (#7461)
* Remove fp16 of Convert layer test from skip_tests.config.cpp as it works now * update repo * add acos in template plugin reference test * Create visitor API test for target operation Acos-1 * remove acos backend test * remove acos backend test * add test casses of int ata type * remove boolean from acos evaluate
This commit is contained in:
parent
6159a5b0bc
commit
b3050c268a
87
docs/template_plugin/tests/functional/op_reference/acos.cpp
Normal file
87
docs/template_plugin/tests/functional/op_reference/acos.cpp
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
// Copyright (C) 2018-2021 Intel Corporation
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include <ie_core.hpp>
|
||||||
|
#include <ie_ngraph_utils.hpp>
|
||||||
|
#include <ngraph/ngraph.hpp>
|
||||||
|
#include <shared_test_classes/base/layer_test_utils.hpp>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "base_reference_test.hpp"
|
||||||
|
|
||||||
|
using namespace ngraph;
|
||||||
|
|
||||||
|
namespace reference_tests {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
struct AcosParams {
|
||||||
|
Tensor input;
|
||||||
|
Tensor expected;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Builder : ParamsBuilder<AcosParams> {
|
||||||
|
REFERENCE_TESTS_ADD_SET_PARAM(Builder, input);
|
||||||
|
REFERENCE_TESTS_ADD_SET_PARAM(Builder, expected);
|
||||||
|
};
|
||||||
|
|
||||||
|
class ReferenceAcosLayerTest : public testing::TestWithParam<AcosParams>, public CommonReferenceTest {
|
||||||
|
public:
|
||||||
|
void SetUp() override {
|
||||||
|
auto params = GetParam();
|
||||||
|
function = CreateFunction(params.input.shape, params.input.type);
|
||||||
|
inputData = {params.input.data};
|
||||||
|
refOutData = {params.expected.data};
|
||||||
|
}
|
||||||
|
static std::string getTestCaseName(const testing::TestParamInfo<AcosParams>& obj) {
|
||||||
|
auto param = obj.param;
|
||||||
|
std::ostringstream result;
|
||||||
|
result << "shape=" << param.input.shape << "_";
|
||||||
|
result << "type=" << param.input.type;
|
||||||
|
return result.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static std::shared_ptr<Function> CreateFunction(const Shape& shape, const element::Type& type) {
|
||||||
|
const auto in = std::make_shared<op::Parameter>(type, shape);
|
||||||
|
const auto acos = std::make_shared<op::Acos>(in);
|
||||||
|
return std::make_shared<Function>(NodeVector {acos}, ParameterVector {in});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_P(ReferenceAcosLayerTest, AcosWithHardcodedRefs) {
|
||||||
|
Exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
|
smoke_Acos_With_Hardcoded_Refs, ReferenceAcosLayerTest,
|
||||||
|
::testing::Values(Builder {}
|
||||||
|
.input({{11}, element::f16, std::vector<ngraph::float16> {-1.f, -0.75f, -0.5f, -0.25f, -0.125f,
|
||||||
|
0.f, 0.125f, 0.25f, 0.5f, 0.75f, 1.f}})
|
||||||
|
.expected({{11}, element::f16, std::vector<ngraph::float16> {3.14159265f, 2.41885841f, 2.09439510f, 1.82347658f, 1.69612416f,
|
||||||
|
1.57079633f, 1.44546850f, 1.31811607f, 1.04719755f, 0.72273425f,
|
||||||
|
0.00000000f}}),
|
||||||
|
Builder {}
|
||||||
|
.input({{11}, element::f32, std::vector<float> {-1.f, -0.75f, -0.5f, -0.25f, -0.125f,
|
||||||
|
0.f, 0.125f, 0.25f, 0.5f, 0.75f, 1.f}})
|
||||||
|
.expected({{11}, element::f32, std::vector<float> {3.14159265f, 2.41885841f, 2.09439510f, 1.82347658f, 1.69612416f,
|
||||||
|
1.57079633f, 1.44546850f, 1.31811607f, 1.04719755f, 0.72273425f,
|
||||||
|
0.00000000f}}),
|
||||||
|
Builder {}
|
||||||
|
.input({{3}, element::i32, std::vector<int32_t> {-1, 0, 1}})
|
||||||
|
.expected({{3}, element::i32, std::vector<int32_t> {3, 1, 0}}),
|
||||||
|
Builder {}
|
||||||
|
.input({{3}, element::i64, std::vector<int64_t> {-1, 0, 1}})
|
||||||
|
.expected({{3}, element::i64, std::vector<int64_t> {3, 1, 0}}),
|
||||||
|
Builder {}
|
||||||
|
.input({{2}, element::u32, std::vector<uint32_t> {0, 1}})
|
||||||
|
.expected({{2}, element::u32, std::vector<uint32_t> {1, 0}}),
|
||||||
|
Builder {}
|
||||||
|
.input({{2}, element::u64, std::vector<uint64_t> {0, 1}})
|
||||||
|
.expected({{2}, element::u64, std::vector<uint64_t> {1, 0}})),
|
||||||
|
ReferenceAcosLayerTest::getTestCaseName);
|
||||||
|
} // namespace reference_tests
|
@ -43,7 +43,6 @@ bool evaluate_acos(const ov::HostTensorPtr& arg0, const ov::HostTensorPtr& out,
|
|||||||
out->set_unary(arg0);
|
out->set_unary(arg0);
|
||||||
|
|
||||||
switch (arg0->get_element_type()) {
|
switch (arg0->get_element_type()) {
|
||||||
NGRAPH_TYPE_CASE(evaluate_acos, boolean, arg0, out, count);
|
|
||||||
NGRAPH_TYPE_CASE(evaluate_acos, i32, arg0, out, count);
|
NGRAPH_TYPE_CASE(evaluate_acos, i32, arg0, out, count);
|
||||||
NGRAPH_TYPE_CASE(evaluate_acos, i64, arg0, out, count);
|
NGRAPH_TYPE_CASE(evaluate_acos, i64, arg0, out, count);
|
||||||
NGRAPH_TYPE_CASE(evaluate_acos, u32, arg0, out, count);
|
NGRAPH_TYPE_CASE(evaluate_acos, u32, arg0, out, count);
|
||||||
@ -72,7 +71,6 @@ bool ov::op::v0::Acos::has_evaluate() const {
|
|||||||
case ngraph::element::u64:
|
case ngraph::element::u64:
|
||||||
case ngraph::element::f16:
|
case ngraph::element::f16:
|
||||||
case ngraph::element::f32:
|
case ngraph::element::f32:
|
||||||
case ngraph::element::boolean:
|
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -245,6 +245,7 @@ set(SRC
|
|||||||
visitors/partial_shape.cpp
|
visitors/partial_shape.cpp
|
||||||
visitors/user_op.cpp
|
visitors/user_op.cpp
|
||||||
visitors/value_map.cpp
|
visitors/value_map.cpp
|
||||||
|
visitors/op/acos.cpp
|
||||||
visitors/op/acosh.cpp
|
visitors/op/acosh.cpp
|
||||||
visitors/op/adaptive_avg_pool.cpp
|
visitors/op/adaptive_avg_pool.cpp
|
||||||
visitors/op/adaptive_max_pool.cpp
|
visitors/op/adaptive_max_pool.cpp
|
||||||
@ -411,7 +412,6 @@ add_subdirectory(util)
|
|||||||
set(MULTI_TEST_SRC
|
set(MULTI_TEST_SRC
|
||||||
backend/abc.in.cpp
|
backend/abc.in.cpp
|
||||||
backend/abs.in.cpp
|
backend/abs.in.cpp
|
||||||
backend/acos.in.cpp
|
|
||||||
backend/adaptive_avg_pool.in.cpp
|
backend/adaptive_avg_pool.in.cpp
|
||||||
backend/adaptive_max_pool.in.cpp
|
backend/adaptive_max_pool.in.cpp
|
||||||
backend/add.in.cpp
|
backend/add.in.cpp
|
||||||
|
@ -1,54 +0,0 @@
|
|||||||
// Copyright (C) 2018-2021 Intel Corporation
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cinttypes>
|
|
||||||
#include <cmath>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <random>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
#ifdef ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS
|
|
||||||
#define DEFAULT_FLOAT_TOLERANCE_BITS ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS
|
|
||||||
#define DEFAULT_DOUBLE_TOLERANCE_BITS ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS
|
|
||||||
#endif
|
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
#include "ngraph/ngraph.hpp"
|
|
||||||
#include "util/engine/test_engines.hpp"
|
|
||||||
#include "util/test_case.hpp"
|
|
||||||
#include "util/test_control.hpp"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace ngraph;
|
|
||||||
|
|
||||||
static string s_manifest = "${MANIFEST}";
|
|
||||||
using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME});
|
|
||||||
|
|
||||||
NGRAPH_TEST(${BACKEND_NAME}, acos) {
|
|
||||||
Shape shape{11};
|
|
||||||
auto A = make_shared<op::Parameter>(element::f32, shape);
|
|
||||||
auto f = make_shared<Function>(make_shared<op::Acos>(A), ParameterVector{A});
|
|
||||||
|
|
||||||
auto test_case = test::TestCase<TestEngine>(f);
|
|
||||||
test_case.add_input<float>({-1.f, -0.75f, -0.5f, -0.25f, -0.125f, 0.f, 0.125f, 0.25f, 0.5f, 0.75f, 1.f});
|
|
||||||
test_case.add_expected_output<float>(shape,
|
|
||||||
{3.14159265f,
|
|
||||||
2.41885841f,
|
|
||||||
2.09439510f,
|
|
||||||
1.82347658f,
|
|
||||||
1.69612416f,
|
|
||||||
1.57079633f,
|
|
||||||
1.44546850f,
|
|
||||||
1.31811607f,
|
|
||||||
1.04719755f,
|
|
||||||
0.72273425f,
|
|
||||||
0.00000000f});
|
|
||||||
test_case.run();
|
|
||||||
}
|
|
9
ngraph/test/visitors/op/acos.cpp
Normal file
9
ngraph/test/visitors/op/acos.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// Copyright (C) 2018-2021 Intel Corporation
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "unary_ops.hpp"
|
||||||
|
|
||||||
|
using Type = ::testing::Types<UnaryOperatorType<ngraph::op::Acos, ngraph::element::f32>>;
|
||||||
|
|
||||||
|
INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_attribute, UnaryOperatorVisitor, Type, UnaryOperatorTypeName);
|
Loading…
Reference in New Issue
Block a user