Files
openvino/docs/template_plugin/tests/functional/op_reference/sinh.cpp
Wilson Seok 8262aed30c Migrate ngraph backend test of arithmetic2 operations (#7500)
* Remove fp16 of Convert layer test from skip_tests.config.cpp as it works now

* update repo

* add sin asin template plugin reference test

* add cos template plugin reference test and remove asin/sin/cos ngraph backend test

* update CMakeList.txt

* add template plugin reference test for asinh, cosh, sinh, tanh

* remove ngraph backend test for asinh, cosh, sinh, tanh

* update CMakeList.txt

* add ngraph type prop test for tanh

* add ngraph visitor api test for asin, sin

* add atanh type in activation SLT

* remove boolean from sin/cos/tan/asin/sinh/cosh evaluate
2021-09-27 05:23:52 +03:00

103 lines
3.8 KiB
C++

// 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 SinhParams {
Tensor input;
Tensor expected;
};
struct Builder : ParamsBuilder<SinhParams> {
REFERENCE_TESTS_ADD_SET_PARAM(Builder, input);
REFERENCE_TESTS_ADD_SET_PARAM(Builder, expected);
};
class ReferenceSinhLayerTest : public testing::TestWithParam<SinhParams>, 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<SinhParams>& 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 Sinh = std::make_shared<op::Sinh>(in);
return std::make_shared<Function>(NodeVector {Sinh}, ParameterVector {in});
}
};
TEST_P(ReferenceSinhLayerTest, SinhWithHardcodedRefs) {
Exec();
}
} // namespace
INSTANTIATE_TEST_SUITE_P(
smoke_Sinh_With_Hardcoded_Refs, ReferenceSinhLayerTest,
::testing::Values(
Builder {}
.input({{11}, element::f16, std::vector<ngraph::float16> {-4.f, -2.f, -1.f, -0.5f, -0.25f, 0.f, 0.25f, 0.5f, 1.f, 2.f, 4.f}})
.expected({{11}, element::f16, std::vector<ngraph::float16> {-27.28991720f,
-3.62686041f,
-1.17520120f,
-0.52109531f,
-0.25261232f,
0.00000000f,
0.25261232f,
0.52109531f,
1.17520120f,
3.62686041f,
27.28991720f}}),
Builder {}
.input({{11}, element::f32, std::vector<float> {-4.f, -2.f, -1.f, -0.5f, -0.25f, 0.f, 0.25f, 0.5f, 1.f, 2.f, 4.f}})
.expected({{11}, element::f32, std::vector<float> {-27.28991720f,
-3.62686041f,
-1.17520120f,
-0.52109531f,
-0.25261232f,
0.00000000f,
0.25261232f,
0.52109531f,
1.17520120f,
3.62686041f,
27.28991720f}}),
Builder {}
.input({{7}, element::i32, std::vector<int32_t> {-4, -2, -1, 0, 1, 2, 4}})
.expected({{7}, element::i32, std::vector<int32_t> {-27, -4, -1, 0, 1, 4, 27}}),
Builder {}
.input({{7}, element::i64, std::vector<int64_t> {-4, -2, -1, 0, 1, 2, 4}})
.expected({{7}, element::i64, std::vector<int64_t> {-27, -4, -1, 0, 1, 4, 27}}),
Builder {}
.input({{4}, element::u32, std::vector<uint32_t> {0, 1, 2, 4}})
.expected({{4}, element::u32, std::vector<uint32_t> {0, 1, 4, 27}}),
Builder {}
.input({{4}, element::u64, std::vector<uint64_t> {0, 1, 2, 4}})
.expected({{4}, element::u64, std::vector<uint64_t> {0, 1, 4, 27}})),
ReferenceSinhLayerTest::getTestCaseName);
} // namespace reference_tests