From 2875f01ba3ebd0e60fab2fbcc8fbff1d8eefc39a Mon Sep 17 00:00:00 2001 From: Patryk Elszkowski Date: Thu, 22 Jul 2021 11:59:59 +0200 Subject: [PATCH] Acosh ref impl (#6664) * minor changes in Op class and add ref impl for acosh * acosh in new test framework * add Acosh type test * add SLT for Acosh * run more test * new acosh plugin test * add visitor test * fix test utils * add template test for all supported types in Acosh * add builder to template tests * update grn template_plugin test * update maste to feature branch --- .../tests/functional/op_reference/acosh.cpp | 81 +++++++++++++++++++ .../op_reference/base_reference_test.cpp | 4 + .../op_reference/base_reference_test.hpp | 56 +++++++++++++ .../tests/functional/op_reference/convert.cpp | 1 + .../tests/functional/op_reference/grn.cpp | 37 ++++----- .../tests/functional/op_reference/select.cpp | 9 ++- .../tests/functional/op_reference/sign.cpp | 25 +++--- .../serialization/single_layer/activation.cpp | 1 + .../single_layer_tests/activation.cpp | 2 + .../single_layer_tests/activation.cpp | 1 + .../single_layer/activation.hpp | 1 + .../src/single_layer/activation.cpp | 6 ++ .../layer_tests_summary/utils/constants.py | 1 + .../ngraph_functions/utils/ngraph_helpers.hpp | 1 + .../ngraph_functions/src/activation.cpp | 2 + ngraph/core/include/ngraph/op/acosh.hpp | 4 +- .../ngraph/runtime/reference/acosh.hpp | 13 ++- ngraph/core/src/op/acosh.cpp | 2 +- ngraph/test/CMakeLists.txt | 2 +- ngraph/test/backend/acosh.in.cpp | 51 ------------ ngraph/test/runtime/ie/unit_test.manifest | 1 - ngraph/test/type_prop/acosh.cpp | 9 +++ ngraph/test/visitors/op/acosh.cpp | 11 +++ 23 files changed, 230 insertions(+), 91 deletions(-) create mode 100644 docs/template_plugin/tests/functional/op_reference/acosh.cpp delete mode 100644 ngraph/test/backend/acosh.in.cpp create mode 100644 ngraph/test/type_prop/acosh.cpp create mode 100644 ngraph/test/visitors/op/acosh.cpp diff --git a/docs/template_plugin/tests/functional/op_reference/acosh.cpp b/docs/template_plugin/tests/functional/op_reference/acosh.cpp new file mode 100644 index 00000000000000..e854c98b7e0f7a --- /dev/null +++ b/docs/template_plugin/tests/functional/op_reference/acosh.cpp @@ -0,0 +1,81 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include +#include +#include +#include +#include + +#include "base_reference_test.hpp" + +using namespace ngraph; + +namespace reference_tests { +namespace { + +struct AcoshParams { + Tensor input; + Tensor expected; +}; + +struct Builder : ParamsBuilder { + REFERENCE_TESTS_ADD_SET_PARAM(Builder, input); + REFERENCE_TESTS_ADD_SET_PARAM(Builder, expected); +}; + +class ReferenceAcoshLayerTest : public testing::TestWithParam, 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& 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 CreateFunction(const Shape& shape, const element::Type& type) { + const auto in = std::make_shared(type, shape); + const auto acosh = std::make_shared(in); + return std::make_shared(NodeVector {acosh}, ParameterVector {in}); + } +}; + +TEST_P(ReferenceAcoshLayerTest, AcoshWithHardcodedRefs) { + Exec(); +} + +} // namespace + +INSTANTIATE_TEST_SUITE_P( + smoke_Acosh_With_Hardcoded_Refs, ReferenceAcoshLayerTest, + ::testing::Values(Builder {} + .input({{8}, element::f16, std::vector {1.f, 2.f, 3.f, 4.f, 5.f, 10.f, 100.f, 1000.f}}) + .expected({{8}, element::f16, std::vector {0., 1.317, 1.763, 2.063, 2.292, 2.993, 5.298, 7.6012}}), + Builder {} + .input({{8}, element::f32, std::vector {1.f, 2.f, 3.f, 4.f, 5.f, 10.f, 100.f, 1000.f}}) + .expected({{8}, element::f32, std::vector {0., 1.317, 1.763, 2.063, 2.292, 2.993, 5.298, 7.6012}}), + Builder {} + .input({{8}, element::i32, std::vector {1, 2, 3, 4, 5, 10, 100, 1000}}) + .expected({{8}, element::i32, std::vector {0, 1, 2, 2, 2, 3, 5, 8}}), + Builder {} + .input({{8}, element::i64, std::vector {1, 2, 3, 4, 5, 10, 100, 1000}}) + .expected({{8}, element::i64, std::vector {0, 1, 2, 2, 2, 3, 5, 8}}), + Builder {} + .input({{8}, element::u32, std::vector {1, 2, 3, 4, 5, 10, 100, 1000}}) + .expected({{8}, element::u32, std::vector {0, 1, 2, 2, 2, 3, 5, 8}}), + Builder {} + .input({{8}, element::u64, std::vector {1, 2, 3, 4, 5, 10, 100, 1000}}) + .expected({{8}, element::u64, std::vector {0, 1, 2, 2, 2, 3, 5, 8}})), + ReferenceAcoshLayerTest::getTestCaseName); +} // namespace reference_tests diff --git a/docs/template_plugin/tests/functional/op_reference/base_reference_test.cpp b/docs/template_plugin/tests/functional/op_reference/base_reference_test.cpp index 51af4d2ea1a221..f2d2cf68aa39a2 100644 --- a/docs/template_plugin/tests/functional/op_reference/base_reference_test.cpp +++ b/docs/template_plugin/tests/functional/op_reference/base_reference_test.cpp @@ -9,6 +9,8 @@ using namespace InferenceEngine; +namespace reference_tests { + CommonReferenceTest::CommonReferenceTest(): targetDevice("TEMPLATE") { core = PluginCache::get().ie(targetDevice); } @@ -171,3 +173,5 @@ void CommonReferenceTest::ValidateBlobs(const InferenceEngine::Blob::Ptr& refBlo FAIL() << "Comparator for " << precision << " precision isn't supported"; } } + +} // namespace reference_tests diff --git a/docs/template_plugin/tests/functional/op_reference/base_reference_test.hpp b/docs/template_plugin/tests/functional/op_reference/base_reference_test.hpp index 6e3fd942a9e722..de08533405e566 100644 --- a/docs/template_plugin/tests/functional/op_reference/base_reference_test.hpp +++ b/docs/template_plugin/tests/functional/op_reference/base_reference_test.hpp @@ -5,8 +5,12 @@ #include #include #include +#include +#include #include +namespace reference_tests { + class CommonReferenceTest { public: CommonReferenceTest(); @@ -51,3 +55,55 @@ InferenceEngine::Blob::Ptr CreateBlob(const ngraph::element::Type& element_type, return blob; } +/// +/// Class which should help to build data for single input +/// +struct Tensor { + Tensor() = default; + + Tensor(const ngraph::Shape& shape, ngraph::element::Type type, const InferenceEngine::Blob::Ptr& data): shape {shape}, type {type}, data {data} {} + + template + Tensor(const ngraph::Shape& shape, ngraph::element::Type type, const std::vector& data_elements) + : Tensor {shape, type, CreateBlob(type, data_elements)} {} + + ngraph::Shape shape; + ngraph::element::Type type; + InferenceEngine::Blob::Ptr data; +}; + +/// +/// Class which should helps build test parameters. +/// +/// e.g.: +/// struct Params { +/// Tensor i,o; +/// int mul; +/// }; +/// struct TestParamsBuilder : ParamsBuilder +/// REFERENCE_TESTS_ADD_SET_PARAM(TestParamsBuilder, i); +/// REFERENCE_TESTS_ADD_SET_PARAM(TestParamsBuilder, o); +/// REFERENCE_TESTS_ADD_SET_PARAM(TestParamsBuilder, mul); +/// }; +/// +/// const Params p = TestParamsBuilder{} +/// .i(Tensor{{0}, i32, {1}}) +/// .o(Tensor{{0}, i32, {1}}) +/// .mul(10); +template +class ParamsBuilder { +protected: + Params params; + +public: + operator Params() const { + return params; + } +}; +#define REFERENCE_TESTS_ADD_SET_PARAM(builder_type, param_to_set) \ + builder_type& param_to_set(decltype(params.param_to_set) t) { \ + params.param_to_set = std::move(t); \ + return *this; \ + } + +} // namespace reference_tests diff --git a/docs/template_plugin/tests/functional/op_reference/convert.cpp b/docs/template_plugin/tests/functional/op_reference/convert.cpp index fb32fda4cbbfd8..b8e6f5846f7408 100644 --- a/docs/template_plugin/tests/functional/op_reference/convert.cpp +++ b/docs/template_plugin/tests/functional/op_reference/convert.cpp @@ -12,6 +12,7 @@ #include "base_reference_test.hpp" +using namespace reference_tests; using namespace ngraph; using namespace InferenceEngine; diff --git a/docs/template_plugin/tests/functional/op_reference/grn.cpp b/docs/template_plugin/tests/functional/op_reference/grn.cpp index 4d003b9b9a2fef..e7fc0c79f6b82b 100644 --- a/docs/template_plugin/tests/functional/op_reference/grn.cpp +++ b/docs/template_plugin/tests/functional/op_reference/grn.cpp @@ -12,21 +12,22 @@ #include "base_reference_test.hpp" +using namespace reference_tests; using namespace ngraph; using namespace InferenceEngine; namespace { struct GrnParams { template - GrnParams(const float bias, const ngraph::PartialShape& shape, const ngraph::element::Type& iType, const std::vector& iValues, + GrnParams(const float bias, const PartialShape& shape, const element::Type& iType, const std::vector& iValues, const std::vector& oValues) : bias(bias), pshape(shape), inType(iType), outType(iType), inputData(CreateBlob(iType, iValues)), refData(CreateBlob(iType, oValues)) {} float bias; - ngraph::PartialShape pshape; - ngraph::element::Type inType; - ngraph::element::Type outType; - InferenceEngine::Blob::Ptr inputData; - InferenceEngine::Blob::Ptr refData; + PartialShape pshape; + element::Type inType; + element::Type outType; + Blob::Ptr inputData; + Blob::Ptr refData; }; class ReferenceGrnLayerTest : public testing::TestWithParam, public CommonReferenceTest { @@ -60,21 +61,21 @@ TEST_P(ReferenceGrnLayerTest, CompareWithHardcodedRefs) { } template -std::vector generateGrnParams(const ngraph::element::Type& type) { +std::vector generateGrnParams(const element::Type& type) { using T = typename element_type_traits::value_type; std::vector grnParams { // bias 1e-6 // 2D // 3D // 4D - GrnParams(1e-6, ngraph::PartialShape {3, 4}, type, std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, + GrnParams(1e-6, PartialShape {3, 4}, type, std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, std::vector {0.182574, 0.365148, 0.547723, 0.730297, 0.379049, 0.454859, 0.530669, 0.606478, 0.426162, 0.473514, 0.520865, 0.568217}), - GrnParams(1e-6, ngraph::PartialShape {2, 3, 4}, type, + GrnParams(1e-6, PartialShape {2, 3, 4}, type, std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}, std::vector {0.0966737, 0.169031, 0.224231, 0.267261, 0.483368, 0.507093, 0.523205, 0.534522, 0.870063, 0.845154, 0.822179, 0.801784, 0.433574, 0.441836, 0.449215, 0.455842, 0.566982, 0.568075, 0.569005, 0.569803, 0.700389, 0.694314, 0.688796, 0.683763}), - GrnParams(1e-6, ngraph::PartialShape {1, 2, 3, 4}, type, + GrnParams(1e-6, PartialShape {1, 2, 3, 4}, type, std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}, std::vector {0.0766965, 0.141421, 0.196116, 0.242536, 0.282166, 0.316228, 0.345705, 0.371391, 0.393919, 0.413803, 0.431455, 0.447214, 0.997055, 0.989949, 0.980581, 0.970143, 0.959365, 0.948683, 0.938343, 0.928477, 0.919145, 0.910366, 0.902134, 0.894427}), - GrnParams(1e-6, ngraph::PartialShape {2, 2, 3, 4}, type, + GrnParams(1e-6, PartialShape {2, 2, 3, 4}, type, std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48}, std::vector {0.0766965, 0.141421, 0.196116, 0.242536, 0.282166, 0.316228, 0.345705, 0.371391, 0.393919, 0.413803, 0.431455, 0.447214, @@ -82,17 +83,17 @@ std::vector generateGrnParams(const ngraph::element::Type& type) { 0.559857, 0.564684, 0.56921, 0.573462, 0.577465, 0.581238, 0.584802, 0.588172, 0.591364, 0.594391, 0.597266, 0.6, 0.828589, 0.825307, 0.822192, 0.819232, 0.816416, 0.813733, 0.811176, 0.808736, 0.806405, 0.804176, 0.802043, 0.8}), // bias 100.25 // 2D // 3D // 4D - GrnParams(100.25, ngraph::PartialShape {3, 4}, type, std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, + GrnParams(100.25, PartialShape {3, 4}, type, std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, std::vector {0.0876216, 0.175243, 0.262865, 0.350486, 0.301923, 0.362308, 0.422693, 0.483077, 0.385076, 0.427863, 0.470649, 0.513435}), - GrnParams(100.25, ngraph::PartialShape {2, 3, 4}, type, + GrnParams(100.25, PartialShape {2, 3, 4}, type, std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}, std::vector {0.0694629, 0.129032, 0.179525, 0.222137, 0.347314, 0.387097, 0.418891, 0.444273, 0.625166, 0.645161, 0.658258, 0.66641, 0.41125, 0.421303, 0.430287, 0.438356, 0.537789, 0.541675, 0.54503, 0.547945, 0.664327, 0.662047, 0.659774, 0.657534}), - GrnParams(100.25, ngraph::PartialShape {1, 2, 3, 4}, type, + GrnParams(100.25, PartialShape {1, 2, 3, 4}, type, std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}, std::vector {0.0608299, 0.115422, 0.164091, 0.207321, 0.245662, 0.279675, 0.309889, 0.336786, 0.360795, 0.38229, 0.401596, 0.418994, 0.790789, 0.807954, 0.820457, 0.829283, 0.835252, 0.839026, 0.841128, 0.841965, 0.841854, 0.841037, 0.839701, 0.837989f}), - GrnParams(100.25, ngraph::PartialShape {2, 2, 3, 4}, type, + GrnParams(100.25, PartialShape {2, 2, 3, 4}, type, std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48}, std::vector {0.0608299, 0.115422, 0.164091, 0.207321, 0.245662, 0.279675, 0.309889, 0.336786, 0.360795, 0.38229, 0.401596, 0.418994, @@ -103,9 +104,9 @@ std::vector generateGrnParams(const ngraph::element::Type& type) { } std::vector generateGrnCombinedParams() { - const std::vector> grnTypeParams {generateGrnParams(ngraph::element::bf16), - generateGrnParams(ngraph::element::f16), - generateGrnParams(ngraph::element::f32)}; + const std::vector> grnTypeParams {generateGrnParams(element::bf16), + generateGrnParams(element::f16), + generateGrnParams(element::f32)}; std::vector combinedParams; std::for_each(grnTypeParams.begin(), grnTypeParams.end(), [&](std::vector params) { combinedParams.insert(combinedParams.end(), params.begin(), params.end()); diff --git a/docs/template_plugin/tests/functional/op_reference/select.cpp b/docs/template_plugin/tests/functional/op_reference/select.cpp index c4dec3f8172e83..0cbc242c61b202 100644 --- a/docs/template_plugin/tests/functional/op_reference/select.cpp +++ b/docs/template_plugin/tests/functional/op_reference/select.cpp @@ -12,6 +12,7 @@ #include "base_reference_test.hpp" +using namespace reference_tests; using namespace ngraph; using namespace InferenceEngine; @@ -33,12 +34,12 @@ struct SelectParams { element::Type data_type; op::AutoBroadcastSpec broadcast; PartialShape select_input_pshape; - InferenceEngine::Blob::Ptr select_input; + Blob::Ptr select_input; PartialShape if_input_pshape; - InferenceEngine::Blob::Ptr if_input; + Blob::Ptr if_input; PartialShape else_input_pshape; - InferenceEngine::Blob::Ptr else_input; - InferenceEngine::Blob::Ptr expected_output; + Blob::Ptr else_input; + Blob::Ptr expected_output; }; class ReferenceSelectLayerTest : public testing::TestWithParam, public CommonReferenceTest { diff --git a/docs/template_plugin/tests/functional/op_reference/sign.cpp b/docs/template_plugin/tests/functional/op_reference/sign.cpp index a5ff9b11978a90..ca1505cea1368e 100644 --- a/docs/template_plugin/tests/functional/op_reference/sign.cpp +++ b/docs/template_plugin/tests/functional/op_reference/sign.cpp @@ -12,19 +12,20 @@ #include "base_reference_test.hpp" +using namespace reference_tests; using namespace ngraph; using namespace InferenceEngine; struct SignParams { template - SignParams(const ngraph::PartialShape& shape, const ngraph::element::Type& iType, const ngraph::element::Type& oType, const std::vector& iValues, + SignParams(const PartialShape& shape, const element::Type& iType, const element::Type& oType, const std::vector& iValues, const std::vector& oValues) : pshape(shape), inType(iType), outType(oType), inputData(CreateBlob(iType, iValues)), refData(CreateBlob(oType, oValues)) {} - ngraph::PartialShape pshape; - ngraph::element::Type inType; - ngraph::element::Type outType; - InferenceEngine::Blob::Ptr inputData; - InferenceEngine::Blob::Ptr refData; + PartialShape pshape; + element::Type inType; + element::Type outType; + Blob::Ptr inputData; + Blob::Ptr refData; }; class ReferenceSignLayerTest : public testing::TestWithParam, public CommonReferenceTest { @@ -59,22 +60,22 @@ TEST_P(ReferenceSignLayerTest, CompareWithHardcodedRefs) { INSTANTIATE_TEST_SUITE_P( smoke_Sign_With_Hardcoded_Refs, ReferenceSignLayerTest, ::testing::Values( - SignParams(ngraph::PartialShape {6}, ngraph::element::f32, ngraph::element::f32, + SignParams(PartialShape {6}, element::f32, element::f32, std::vector {1, -2, 0, -4.8f, 4.8f, -0.0f}, std::vector {1, -1, 0, -1, 1, 0}), - SignParams(ngraph::PartialShape {6}, ngraph::element::f16, ngraph::element::f16, + SignParams(PartialShape {6}, element::f16, element::f16, std::vector {1, -2, 0, -4.8f, 4.8f, -0.0f}, std::vector {1, -1, 0, -1, 1, 0}), - SignParams(ngraph::PartialShape {6}, ngraph::element::u64, ngraph::element::u64, + SignParams(PartialShape {6}, element::u64, element::u64, std::vector {1, 2, 0, 4, 4, 0}, std::vector {1, 1, 0, 1, 1, 0}), - SignParams(ngraph::PartialShape {6}, ngraph::element::u32, ngraph::element::u32, + SignParams(PartialShape {6}, element::u32, element::u32, std::vector {1, 2, 0, 4, 4, 0}, std::vector {1, 1, 0, 1, 1, 0}), - SignParams(ngraph::PartialShape {6}, ngraph::element::i32, ngraph::element::i32, + SignParams(PartialShape {6}, element::i32, element::i32, std::vector {1, -2, 0, -4, 4, -0}, std::vector {1, -1, 0, -1, 1, 0}), - SignParams(ngraph::PartialShape {6}, ngraph::element::i64, ngraph::element::i64, + SignParams(PartialShape {6}, element::i64, element::i64, std::vector {1, -2, 0, -4, 4, -0}, std::vector {1, -1, 0, -1, 1, 0})), ReferenceSignLayerTest::getTestCaseName); diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/activation.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/activation.cpp index 355afbaf687576..efe2efaf5ee495 100644 --- a/inference-engine/tests/functional/inference_engine/serialization/single_layer/activation.cpp +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/activation.cpp @@ -36,6 +36,7 @@ const std::map>> activationTypes {Clamp, {{-2.0f, 2.0f}}}, {Negative, {}}, {Acos, {}}, + {Acosh, {}}, {Asin, {}}, {Asinh, {}}, {Atan, {}}, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp index 08745acac2d741..98b73bfb1d4818 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp @@ -37,6 +37,7 @@ const std::map>> activationTypes {Clamp, {{-2.0f, 2.0f}}}, {Negative, {}}, {Acos, {}}, + {Acosh, {}}, {Asin, {}}, {Asinh, {}}, {Atan, {}}, @@ -66,6 +67,7 @@ const std::map>> activationTypes // List of operations that should be tested also with integer precision const std::map>> intActivationTypes = { + {Acosh, {}}, {Asinh, {}}, {Atan, {}}, {Negative, {}}, diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/activation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/activation.cpp index 6bbf98451fe69d..78c383353e9b36 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/activation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/activation.cpp @@ -34,6 +34,7 @@ const std::map>> activationTypes {Clamp, {{-2.0f, 2.0f}}}, {Negative, {}}, {Acos, {}}, + {Acosh, {}}, {Asin, {}}, {Asinh, {}}, {Atan, {}}, diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/activation.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/activation.hpp index 5a9c5226f6f398..7e5ad37d2b9a32 100644 --- a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/activation.hpp +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/activation.hpp @@ -39,6 +39,7 @@ static std::map activationNames = {ngraph::helpers::ActivationTypes::Clamp, "Clamp"}, {ngraph::helpers::ActivationTypes::Negative, "Negative"}, {ngraph::helpers::ActivationTypes::Acos, "Acos"}, + {ngraph::helpers::ActivationTypes::Acosh, "Acosh"}, {ngraph::helpers::ActivationTypes::Asin, "Asin"}, {ngraph::helpers::ActivationTypes::Asinh, "Asinh"}, {ngraph::helpers::ActivationTypes::Atan, "Atan"}, diff --git a/inference-engine/tests/functional/shared_test_classes/src/single_layer/activation.cpp b/inference-engine/tests/functional/shared_test_classes/src/single_layer/activation.cpp index 5b90cfc2079dd6..e3d4956eee0350 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/single_layer/activation.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/single_layer/activation.cpp @@ -84,6 +84,12 @@ InferenceEngine::Blob::Ptr ActivationLayerTest::GenerateInput(const InferenceEng resolution = 32768; break; } + case ngraph::helpers::ActivationTypes::Acosh: { + data_start_from = 1; + data_range = 200; + resolution = 32768; + break; + } case ngraph::helpers::ActivationTypes::Ceiling: { data_start_from = -1000; data_range = 2000; diff --git a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py index fe6cc530fb4e5b..d383d0f95c278d 100644 --- a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py +++ b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py @@ -4,6 +4,7 @@ VERIFIED_OP_REFERENCES = [ 'Abs-1', 'Acos-1', + 'Acosh-3', 'Add-1', 'Asin-1', 'Asinh-3', diff --git a/inference-engine/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/utils/ngraph_helpers.hpp b/inference-engine/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/utils/ngraph_helpers.hpp index 47405a8e51c4f5..86ba1f04487462 100644 --- a/inference-engine/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/utils/ngraph_helpers.hpp +++ b/inference-engine/tests/ngraph_helpers/ngraph_functions/include/ngraph_functions/utils/ngraph_helpers.hpp @@ -99,6 +99,7 @@ enum ActivationTypes { Clamp, Negative, Acos, + Acosh, Asin, Asinh, Atan, diff --git a/inference-engine/tests/ngraph_helpers/ngraph_functions/src/activation.cpp b/inference-engine/tests/ngraph_helpers/ngraph_functions/src/activation.cpp index d8dce877b0f1df..1d784cbe55c567 100644 --- a/inference-engine/tests/ngraph_helpers/ngraph_functions/src/activation.cpp +++ b/inference-engine/tests/ngraph_helpers/ngraph_functions/src/activation.cpp @@ -46,6 +46,8 @@ std::shared_ptr makeActivation(const ngraph::Output &in, return std::make_shared(in); case ngraph::helpers::ActivationTypes::Acos: return std::make_shared(in); + case ngraph::helpers::ActivationTypes::Acosh: + return std::make_shared(in); case ngraph::helpers::ActivationTypes::Asin: return std::make_shared(in); case ngraph::helpers::ActivationTypes::Asinh: diff --git a/ngraph/core/include/ngraph/op/acosh.hpp b/ngraph/core/include/ngraph/op/acosh.hpp index 6937e8faf970c4..ad9ac7d2821324 100644 --- a/ngraph/core/include/ngraph/op/acosh.hpp +++ b/ngraph/core/include/ngraph/op/acosh.hpp @@ -19,8 +19,8 @@ namespace ngraph class NGRAPH_API Acosh : public util::UnaryElementwiseArithmetic { public: - static constexpr NodeTypeInfo type_info{"Acosh", 3}; - const NodeTypeInfo& get_type_info() const override { return type_info; } + NGRAPH_RTTI_DECLARATION; + /// \brief Constructs an Acosh operation. Acosh() = default; /// \brief Constructs an Acosh operation. diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/acosh.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/acosh.hpp index 7c01940cb802e2..e36da23ab5d10d 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/acosh.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/acosh.hpp @@ -13,7 +13,8 @@ namespace ngraph { namespace reference { - template + template ::value, bool>::type = true> void acosh(const T* arg, T* out, size_t count) { for (size_t i = 0; i < count; i++) @@ -21,6 +22,16 @@ namespace ngraph out[i] = std::acosh(arg[i]); } } + + template ::value, bool>::type = true> + void acosh(const T* arg, T* out, size_t count) + { + for (size_t i = 0; i < count; i++) + { + out[i] = std::roundl(std::acosh(arg[i])); + } + } } // namespace reference } // namespace runtime } // namespace ngraph diff --git a/ngraph/core/src/op/acosh.cpp b/ngraph/core/src/op/acosh.cpp index cc8d72a8f08d9f..3969cc2e4ee711 100644 --- a/ngraph/core/src/op/acosh.cpp +++ b/ngraph/core/src/op/acosh.cpp @@ -14,7 +14,7 @@ using namespace std; using namespace ngraph; -constexpr NodeTypeInfo op::v3::Acosh::type_info; +NGRAPH_RTTI_DEFINITION(op::v3::Acosh, "Acosh", 3, util::UnaryElementwiseArithmetic); op::v3::Acosh::Acosh(const Output& arg) : UnaryElementwiseArithmetic(arg) diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index acdabe9fb81ced..24d70dece93564 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -230,6 +230,7 @@ set(SRC visitors/partial_shape.cpp visitors/user_op.cpp visitors/value_map.cpp + visitors/op/acosh.cpp visitors/op/adaptive_avg_pool.cpp visitors/op/adaptive_max_pool.cpp visitors/op/asinh.cpp @@ -371,7 +372,6 @@ set(MULTI_TEST_SRC backend/abc.in.cpp backend/abs.in.cpp backend/acos.in.cpp - backend/acosh.in.cpp backend/adaptive_avg_pool.in.cpp backend/adaptive_max_pool.in.cpp backend/add.in.cpp diff --git a/ngraph/test/backend/acosh.in.cpp b/ngraph/test/backend/acosh.in.cpp deleted file mode 100644 index b3325349241fec..00000000000000 --- a/ngraph/test/backend/acosh.in.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include -#include -#include -#include -#include - -// 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}, acosh) -{ - Shape shape{11}; - auto A = make_shared(element::f32, shape); - auto f = make_shared(make_shared(A), ParameterVector{A}); - - vector input{0.f, 1.f, -1.f, 2.f, -2.f, 3.f, -3.f, 4.f, 5.f, 10.f, 100.f}; - vector expected; - for (float f : input) - { - expected.push_back(std::acosh(f)); - } - - auto test_case = test::TestCase(f); - test_case.add_input(input); - test_case.add_expected_output(shape, expected); - test_case.run(); -} diff --git a/ngraph/test/runtime/ie/unit_test.manifest b/ngraph/test/runtime/ie/unit_test.manifest index dbd2f28aea5108..3984346f97b353 100644 --- a/ngraph/test/runtime/ie/unit_test.manifest +++ b/ngraph/test/runtime/ie/unit_test.manifest @@ -1018,7 +1018,6 @@ IE_CPU.convert_like_dyn_float16_to_int64 # Operations were removed from opset IE_CPU.atanh IE_CPU.asinh -IE_CPU.acosh # Unsupported collapse op with dynamic shape IE_CPU.builder_opset1_collapse_dyn_shape diff --git a/ngraph/test/type_prop/acosh.cpp b/ngraph/test/type_prop/acosh.cpp new file mode 100644 index 00000000000000..eac5bec74b0132 --- /dev/null +++ b/ngraph/test/type_prop/acosh.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Type = ::testing::Types; + +INSTANTIATE_TYPED_TEST_SUITE_P(type_prop_acosh, UnaryOperator, Type); diff --git a/ngraph/test/visitors/op/acosh.cpp b/ngraph/test/visitors/op/acosh.cpp new file mode 100644 index 00000000000000..413a68710ab3c6 --- /dev/null +++ b/ngraph/test/visitors/op/acosh.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" +using Type = ::testing::Types>; + +INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_attribute, + UnaryOperatorVisitor, + Type, + UnaryOperatorTypeName);