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
This commit is contained in:
103
docs/template_plugin/tests/functional/op_reference/asin.cpp
Normal file
103
docs/template_plugin/tests/functional/op_reference/asin.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
// 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 AsinParams {
|
||||
Tensor input;
|
||||
Tensor expected;
|
||||
};
|
||||
|
||||
struct Builder : ParamsBuilder<AsinParams> {
|
||||
REFERENCE_TESTS_ADD_SET_PARAM(Builder, input);
|
||||
REFERENCE_TESTS_ADD_SET_PARAM(Builder, expected);
|
||||
};
|
||||
|
||||
class ReferenceAsinLayerTest : public testing::TestWithParam<AsinParams>, 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<AsinParams>& 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 Asin = std::make_shared<op::Asin>(in);
|
||||
return std::make_shared<Function>(NodeVector {Asin}, ParameterVector {in});
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ReferenceAsinLayerTest, AsinWithHardcodedRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
smoke_Asin_With_Hardcoded_Refs, ReferenceAsinLayerTest,
|
||||
::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> {-1.57079633f,
|
||||
-0.84806208f,
|
||||
-0.52359878f,
|
||||
-0.25268026f,
|
||||
-0.12532783f,
|
||||
0.00000000f,
|
||||
0.12532783f,
|
||||
0.25268026f,
|
||||
0.52359878f,
|
||||
0.84806208f,
|
||||
1.57079633f}}),
|
||||
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> {-1.57079633f,
|
||||
-0.84806208f,
|
||||
-0.52359878f,
|
||||
-0.25268026f,
|
||||
-0.12532783f,
|
||||
0.00000000f,
|
||||
0.12532783f,
|
||||
0.25268026f,
|
||||
0.52359878f,
|
||||
0.84806208f,
|
||||
1.57079633f}}),
|
||||
Builder {}
|
||||
.input({{3}, element::i32, std::vector<int32_t> {-1, 0, 1}})
|
||||
.expected({{3}, element::i32, std::vector<int32_t> {-1, 0, 1}}),
|
||||
Builder {}
|
||||
.input({{3}, element::i64, std::vector<int64_t> {-1, 0, 1}})
|
||||
.expected({{3}, element::i64, std::vector<int64_t> {-1, 0, 1}}),
|
||||
Builder {}
|
||||
.input({{2}, element::u32, std::vector<uint32_t> {0, 1}})
|
||||
.expected({{2}, element::u32, std::vector<uint32_t> {0, 1}}),
|
||||
Builder {}
|
||||
.input({{2}, element::u64, std::vector<uint64_t> {0, 1}})
|
||||
.expected({{2}, element::u64, std::vector<uint64_t> {0, 1}})),
|
||||
|
||||
ReferenceAsinLayerTest::getTestCaseName);
|
||||
} // namespace reference_tests
|
||||
103
docs/template_plugin/tests/functional/op_reference/asinh.cpp
Normal file
103
docs/template_plugin/tests/functional/op_reference/asinh.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
// 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 AsinhParams {
|
||||
Tensor input;
|
||||
Tensor expected;
|
||||
};
|
||||
|
||||
struct Builder : ParamsBuilder<AsinhParams> {
|
||||
REFERENCE_TESTS_ADD_SET_PARAM(Builder, input);
|
||||
REFERENCE_TESTS_ADD_SET_PARAM(Builder, expected);
|
||||
};
|
||||
|
||||
class ReferenceAsinhLayerTest : public testing::TestWithParam<AsinhParams>, 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<AsinhParams>& 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 Asinh = std::make_shared<op::Asinh>(in);
|
||||
return std::make_shared<Function>(NodeVector {Asinh}, ParameterVector {in});
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ReferenceAsinhLayerTest, AsinhWithHardcodedRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
smoke_Asinh_With_Hardcoded_Refs, ReferenceAsinhLayerTest,
|
||||
::testing::Values(
|
||||
Builder {}
|
||||
.input({{11}, element::f16, std::vector<ngraph::float16> {0.f, 1.f, -1.f, 2.f, -2.f, 3.f, -3.f, 4.f, 5.f, 10.f, 100.f}})
|
||||
.expected({{11}, element::f16, std::vector<ngraph::float16> {0.00000000f,
|
||||
0.88137359f,
|
||||
-0.88137359f,
|
||||
1.44363548f,
|
||||
-1.44363548f,
|
||||
1.81844646f,
|
||||
-1.81844646f,
|
||||
2.09471255f,
|
||||
2.31243834f,
|
||||
2.99822295f,
|
||||
5.29834237f}}),
|
||||
Builder {}
|
||||
.input({{11}, element::f32, std::vector<float> {0.f, 1.f, -1.f, 2.f, -2.f, 3.f, -3.f, 4.f, 5.f, 10.f, 100.f}})
|
||||
.expected({{11}, element::f32, std::vector<float> {0.00000000f,
|
||||
0.88137359f,
|
||||
-0.88137359f,
|
||||
1.44363548f,
|
||||
-1.44363548f,
|
||||
1.81844646f,
|
||||
-1.81844646f,
|
||||
2.09471255f,
|
||||
2.31243834f,
|
||||
2.99822295f,
|
||||
5.29834237f}}),
|
||||
Builder {}
|
||||
.input({{11}, element::i32, std::vector<int32_t> {-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5}})
|
||||
.expected({{11}, element::i32, std::vector<int32_t> {-2, -2, -2, -1, -1, 0, 1, 1, 2, 2, 2}}),
|
||||
Builder {}
|
||||
.input({{11}, element::i64, std::vector<int64_t> {-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5}})
|
||||
.expected({{11}, element::i64, std::vector<int64_t> {-2, -2, -2, -1, -1, 0, 1, 1, 2, 2, 2}}),
|
||||
Builder {}
|
||||
.input({{6}, element::u32, std::vector<uint32_t> {0, 1, 2, 3, 4, 5}})
|
||||
.expected({{6}, element::u32, std::vector<uint32_t> {0, 1, 1, 2, 2, 2}}),
|
||||
Builder {}
|
||||
.input({{6}, element::u64, std::vector<uint64_t> {0, 1, 2, 3, 4, 5}})
|
||||
.expected({{6}, element::u64, std::vector<uint64_t> {0, 1, 1, 2, 2, 2}})),
|
||||
|
||||
ReferenceAsinhLayerTest::getTestCaseName);
|
||||
} // namespace reference_tests
|
||||
103
docs/template_plugin/tests/functional/op_reference/cos.cpp
Normal file
103
docs/template_plugin/tests/functional/op_reference/cos.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
// 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 CosParams {
|
||||
Tensor input;
|
||||
Tensor expected;
|
||||
};
|
||||
|
||||
struct Builder : ParamsBuilder<CosParams> {
|
||||
REFERENCE_TESTS_ADD_SET_PARAM(Builder, input);
|
||||
REFERENCE_TESTS_ADD_SET_PARAM(Builder, expected);
|
||||
};
|
||||
|
||||
class ReferenceCosLayerTest : public testing::TestWithParam<CosParams>, 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<CosParams>& 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 Cos = std::make_shared<op::Cos>(in);
|
||||
return std::make_shared<Function>(NodeVector {Cos}, ParameterVector {in});
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ReferenceCosLayerTest, CosWithHardcodedRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
smoke_Cos_With_Hardcoded_Refs, ReferenceCosLayerTest,
|
||||
::testing::Values(
|
||||
Builder {}
|
||||
.input({{11}, element::f16, std::vector<ngraph::float16> {0.f, 0.25f, -0.25f, 0.5f, -0.5f, 1.f, -1.f, 2.f, -2.f, 4.f, -4.f}})
|
||||
.expected({{11}, element::f16, std::vector<ngraph::float16> {1.00000000f,
|
||||
0.96891242f,
|
||||
0.96891242f,
|
||||
0.87758256f,
|
||||
0.87758256f,
|
||||
0.54030231f,
|
||||
0.54030231f,
|
||||
-0.41614684f,
|
||||
-0.41614684f,
|
||||
-0.65364362f,
|
||||
-0.65364362f}}),
|
||||
Builder {}
|
||||
.input({{11}, element::f32, std::vector<float> {0.f, 0.25f, -0.25f, 0.5f, -0.5f, 1.f, -1.f, 2.f, -2.f, 4.f, -4.f}})
|
||||
.expected({{11}, element::f32, std::vector<float> {1.00000000f,
|
||||
0.96891242f,
|
||||
0.96891242f,
|
||||
0.87758256f,
|
||||
0.87758256f,
|
||||
0.54030231f,
|
||||
0.54030231f,
|
||||
-0.41614684f,
|
||||
-0.41614684f,
|
||||
-0.65364362f,
|
||||
-0.65364362f}}),
|
||||
Builder {}
|
||||
.input({{5}, element::i32, std::vector<int32_t> {1, 2, 3, 4, 5}})
|
||||
.expected({{5}, element::i32, std::vector<int32_t> {1, 0, -1, -1, 0}}),
|
||||
Builder {}
|
||||
.input({{5}, element::i64, std::vector<int64_t> {1, 2, 3, 4, 5}})
|
||||
.expected({{5}, element::i64, std::vector<int64_t> {1, 0, -1, -1, 0}}),
|
||||
Builder {}
|
||||
.input({{3}, element::u32, std::vector<uint32_t> {1, 2, 5}})
|
||||
.expected({{3}, element::u32, std::vector<uint32_t> {1, 0, 0}}),
|
||||
Builder {}
|
||||
.input({{3}, element::u64, std::vector<uint64_t> {1, 2, 5}})
|
||||
.expected({{3}, element::u64, std::vector<uint64_t> {1, 0, 0}})),
|
||||
|
||||
ReferenceCosLayerTest::getTestCaseName);
|
||||
} // namespace reference_tests
|
||||
103
docs/template_plugin/tests/functional/op_reference/cosh.cpp
Normal file
103
docs/template_plugin/tests/functional/op_reference/cosh.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
// 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 CoshParams {
|
||||
Tensor input;
|
||||
Tensor expected;
|
||||
};
|
||||
|
||||
struct Builder : ParamsBuilder<CoshParams> {
|
||||
REFERENCE_TESTS_ADD_SET_PARAM(Builder, input);
|
||||
REFERENCE_TESTS_ADD_SET_PARAM(Builder, expected);
|
||||
};
|
||||
|
||||
class ReferenceCoshLayerTest : public testing::TestWithParam<CoshParams>, 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<CoshParams>& 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 Cosh = std::make_shared<op::Cosh>(in);
|
||||
return std::make_shared<Function>(NodeVector {Cosh}, ParameterVector {in});
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ReferenceCoshLayerTest, CoshWithHardcodedRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
smoke_Cosh_With_Hardcoded_Refs, ReferenceCoshLayerTest,
|
||||
::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.30823284f,
|
||||
3.76219569f,
|
||||
1.54308063f,
|
||||
1.12762597f,
|
||||
1.03141310f,
|
||||
1.00000000f,
|
||||
1.03141310f,
|
||||
1.12762597f,
|
||||
1.54308063f,
|
||||
3.76219569f,
|
||||
27.30823284f}}),
|
||||
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.30823284f,
|
||||
3.76219569f,
|
||||
1.54308063f,
|
||||
1.12762597f,
|
||||
1.03141310f,
|
||||
1.00000000f,
|
||||
1.03141310f,
|
||||
1.12762597f,
|
||||
1.54308063f,
|
||||
3.76219569f,
|
||||
27.30823284f}}),
|
||||
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, 2, 1, 2, 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, 2, 1, 2, 4, 27}}),
|
||||
Builder {}
|
||||
.input({{4}, element::u32, std::vector<uint32_t> {0, 1, 2, 4}})
|
||||
.expected({{4}, element::u32, std::vector<uint32_t> {1, 2, 4, 27}}),
|
||||
Builder {}
|
||||
.input({{4}, element::u64, std::vector<uint64_t> {0, 1, 2, 4}})
|
||||
.expected({{4}, element::u64, std::vector<uint64_t> {1, 2, 4, 27}})),
|
||||
|
||||
ReferenceCoshLayerTest::getTestCaseName);
|
||||
} // namespace reference_tests
|
||||
103
docs/template_plugin/tests/functional/op_reference/sin.cpp
Normal file
103
docs/template_plugin/tests/functional/op_reference/sin.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
// 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 SinParams {
|
||||
Tensor input;
|
||||
Tensor expected;
|
||||
};
|
||||
|
||||
struct Builder : ParamsBuilder<SinParams> {
|
||||
REFERENCE_TESTS_ADD_SET_PARAM(Builder, input);
|
||||
REFERENCE_TESTS_ADD_SET_PARAM(Builder, expected);
|
||||
};
|
||||
|
||||
class ReferenceSinLayerTest : public testing::TestWithParam<SinParams>, 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<SinParams>& 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 Sin = std::make_shared<op::Sin>(in);
|
||||
return std::make_shared<Function>(NodeVector {Sin}, ParameterVector {in});
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ReferenceSinLayerTest, SinWithHardcodedRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
smoke_Sin_With_Hardcoded_Refs, ReferenceSinLayerTest,
|
||||
::testing::Values(
|
||||
Builder {}
|
||||
.input({{11}, element::f16, std::vector<ngraph::float16> {0.f, 0.25f, -0.25f, 0.5f, -0.5f, 1.f, -1.f, 2.f, -2.f, 4.f, -4.f}})
|
||||
.expected({{11}, element::f16, std::vector<ngraph::float16> {0.00000000f,
|
||||
0.24740396f,
|
||||
-0.24740396f,
|
||||
0.47942554f,
|
||||
-0.47942554f,
|
||||
0.84147098f,
|
||||
-0.84147098f,
|
||||
0.90929743f,
|
||||
-0.90929743f,
|
||||
-0.75680250f,
|
||||
0.75680250f}}),
|
||||
Builder {}
|
||||
.input({{11}, element::f32, std::vector<float> {0.f, 0.25f, -0.25f, 0.5f, -0.5f, 1.f, -1.f, 2.f, -2.f, 4.f, -4.f}})
|
||||
.expected({{11}, element::f32, std::vector<float> {0.00000000f,
|
||||
0.24740396f,
|
||||
-0.24740396f,
|
||||
0.47942554f,
|
||||
-0.47942554f,
|
||||
0.84147098f,
|
||||
-0.84147098f,
|
||||
0.90929743f,
|
||||
-0.90929743f,
|
||||
-0.75680250f,
|
||||
0.75680250f}}),
|
||||
Builder {}
|
||||
.input({{7}, element::i32, std::vector<int32_t> {0, 1, -1, 2, -2, 4, -4}})
|
||||
.expected({{7}, element::i32, std::vector<int32_t> {0, 0, 0, 0, 0, 0, 0}}),
|
||||
Builder {}
|
||||
.input({{7}, element::i64, std::vector<int64_t> {0, 1, -1, 2, -2, 4, -4}})
|
||||
.expected({{7}, element::i64, std::vector<int64_t> {0, 0, 0, 0, 0, 0, 0}}),
|
||||
Builder {}
|
||||
.input({{4}, element::u32, std::vector<uint32_t> {0, 1, 2, 4}})
|
||||
.expected({{4}, element::u32, std::vector<uint32_t> {0, 0, 0, 0}}),
|
||||
Builder {}
|
||||
.input({{4}, element::u64, std::vector<uint64_t> {0, 1, 2, 4}})
|
||||
.expected({{4}, element::u64, std::vector<uint64_t> {0, 0, 0, 0}})),
|
||||
|
||||
ReferenceSinLayerTest::getTestCaseName);
|
||||
} // namespace reference_tests
|
||||
103
docs/template_plugin/tests/functional/op_reference/sinh.cpp
Normal file
103
docs/template_plugin/tests/functional/op_reference/sinh.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
// 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
|
||||
103
docs/template_plugin/tests/functional/op_reference/tanh.cpp
Normal file
103
docs/template_plugin/tests/functional/op_reference/tanh.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
// 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 TanhParams {
|
||||
Tensor input;
|
||||
Tensor expected;
|
||||
};
|
||||
|
||||
struct Builder : ParamsBuilder<TanhParams> {
|
||||
REFERENCE_TESTS_ADD_SET_PARAM(Builder, input);
|
||||
REFERENCE_TESTS_ADD_SET_PARAM(Builder, expected);
|
||||
};
|
||||
|
||||
class ReferenceTanhLayerTest : public testing::TestWithParam<TanhParams>, 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<TanhParams>& 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 Tanh = std::make_shared<op::Tanh>(in);
|
||||
return std::make_shared<Function>(NodeVector {Tanh}, ParameterVector {in});
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ReferenceTanhLayerTest, TanhWithHardcodedRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
smoke_Tanh_With_Hardcoded_Refs, ReferenceTanhLayerTest,
|
||||
::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> {-0.99932930f,
|
||||
-0.96402758f,
|
||||
-0.76159416f,
|
||||
-0.46211716f,
|
||||
-0.24491866f,
|
||||
0.00000000f,
|
||||
0.24491866f,
|
||||
0.46211716f,
|
||||
0.76159416f,
|
||||
0.96402758f,
|
||||
0.99932930f}}),
|
||||
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> {-0.99932930f,
|
||||
-0.96402758f,
|
||||
-0.76159416f,
|
||||
-0.46211716f,
|
||||
-0.24491866f,
|
||||
0.00000000f,
|
||||
0.24491866f,
|
||||
0.46211716f,
|
||||
0.76159416f,
|
||||
0.96402758f,
|
||||
0.99932930f}}),
|
||||
Builder {}
|
||||
.input({{7}, element::i32, std::vector<int32_t> {-4, -2, -1, 0, 1, 2, 4}})
|
||||
.expected({{7}, element::i32, std::vector<int32_t> {-1, -1, -1, 0, 1, 1, 1}}),
|
||||
Builder {}
|
||||
.input({{7}, element::i64, std::vector<int64_t> {-4, -2, -1, 0, 1, 2, 4}})
|
||||
.expected({{7}, element::i64, std::vector<int64_t> {-1, -1, -1, 0, 1, 1, 1}}),
|
||||
Builder {}
|
||||
.input({{4}, element::u32, std::vector<uint32_t> {0, 1, 2, 4}})
|
||||
.expected({{4}, element::u32, std::vector<uint32_t> {0, 1, 1, 1}}),
|
||||
Builder {}
|
||||
.input({{4}, element::u64, std::vector<uint64_t> {0, 1, 2, 4}})
|
||||
.expected({{4}, element::u64, std::vector<uint64_t> {0, 1, 1, 1}})),
|
||||
|
||||
ReferenceTanhLayerTest::getTestCaseName);
|
||||
} // namespace reference_tests
|
||||
Reference in New Issue
Block a user