From c18c103f0f2c0a511b082f63bfb55ce61e15fa85 Mon Sep 17 00:00:00 2001 From: Roman Lyamin Date: Thu, 9 Jul 2020 10:22:34 +0300 Subject: [PATCH] [IE TESTS] Added single layer tests (#1137) --- .../single_layer_tests/activation.cpp | 20 +++++++++- .../single_layer_tests/activation.cpp | 18 ++++++++- .../include/single_layer_tests/activation.hpp | 34 +++++++++++----- .../src/single_layer_tests/activation.cpp | 32 ++++++++++++++- .../ngraph_functions/utils/ngraph_helpers.hpp | 18 ++++++++- .../tests/ngraph_functions/src/activation.cpp | 40 +++++++++++++++++++ 6 files changed, 147 insertions(+), 15 deletions(-) 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 567b9aec4ef..ed919aa6ec9 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 @@ -29,13 +29,29 @@ const std::vector activationTypes = { Exp, Log, Sign, - Abs + Abs, + Clamp, + Negative, + Acos, + Asin, + Atan, + Cos, + Cosh, + Floor, + Sin, + Sinh, + Sqrt, + Tan, + Elu, + Erf, + HardSigmoid, + Selu }; const auto basicCases = ::testing::Combine( ::testing::ValuesIn(activationTypes), ::testing::ValuesIn(netPrecisions), - ::testing::Values(std::vector({1, 50}), std::vector({1, 128})), + ::testing::Values(std::vector({1, 50}), std::vector({1, 128})), ::testing::Values(CommonTestUtils::DEVICE_CPU) ); 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 a18b692c506..957b6a9b857 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 @@ -24,7 +24,23 @@ const std::vector activationTypes = { Log, Sign, Abs, - Gelu + Gelu, + Clamp, + Negative, + Acos, + Asin, + Atan, + Cos, + Cosh, + Floor, + Sin, + Sinh, + Sqrt, + Tan, + Elu, + Erf, + HardSigmoid, + Selu }; const auto basicCases = ::testing::Combine( diff --git a/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/activation.hpp b/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/activation.hpp index c4870a58632..b58e3e8767c 100644 --- a/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/activation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/activation.hpp @@ -32,15 +32,31 @@ namespace LayerTestsDefinitions { static std::map activationNames = { - {ngraph::helpers::ActivationTypes::Sigmoid, "Sigmoid"}, - {ngraph::helpers::ActivationTypes::Tanh, "Tanh"}, - {ngraph::helpers::ActivationTypes::Relu, "Relu"}, - {ngraph::helpers::ActivationTypes::LeakyRelu, "LeakyRelu"}, - {ngraph::helpers::ActivationTypes::Exp, "Exp"}, - {ngraph::helpers::ActivationTypes::Log, "Log"}, - {ngraph::helpers::ActivationTypes::Sign, "Sign"}, - {ngraph::helpers::ActivationTypes::Abs, "Abs"}, - {ngraph::helpers::ActivationTypes::Gelu, "Gelu"} + {ngraph::helpers::ActivationTypes::Sigmoid, "Sigmoid"}, + {ngraph::helpers::ActivationTypes::Tanh, "Tanh"}, + {ngraph::helpers::ActivationTypes::Relu, "Relu"}, + {ngraph::helpers::ActivationTypes::LeakyRelu, "LeakyRelu"}, + {ngraph::helpers::ActivationTypes::Exp, "Exp"}, + {ngraph::helpers::ActivationTypes::Log, "Log"}, + {ngraph::helpers::ActivationTypes::Sign, "Sign"}, + {ngraph::helpers::ActivationTypes::Abs, "Abs"}, + {ngraph::helpers::ActivationTypes::Gelu, "Gelu"}, + {ngraph::helpers::ActivationTypes::Clamp, "Clamp"}, + {ngraph::helpers::ActivationTypes::Negative, "Negative"}, + {ngraph::helpers::ActivationTypes::Acos, "Acos"}, + {ngraph::helpers::ActivationTypes::Asin, "Asin"}, + {ngraph::helpers::ActivationTypes::Atan, "Atan"}, + {ngraph::helpers::ActivationTypes::Cos, "Cos"}, + {ngraph::helpers::ActivationTypes::Cosh, "Cosh"}, + {ngraph::helpers::ActivationTypes::Floor, "Floor"}, + {ngraph::helpers::ActivationTypes::Sin, "Sin"}, + {ngraph::helpers::ActivationTypes::Sinh, "Sinh"}, + {ngraph::helpers::ActivationTypes::Sqrt, "Sqrt"}, + {ngraph::helpers::ActivationTypes::Tan, "Tan"}, + {ngraph::helpers::ActivationTypes::Elu, "Elu"}, + {ngraph::helpers::ActivationTypes::Erf, "Erf"}, + {ngraph::helpers::ActivationTypes::HardSigmoid, "HardSigmoid"}, + {ngraph::helpers::ActivationTypes::Selu, "Selu"} }; typedef std::tuple< diff --git a/inference-engine/tests/functional/plugin/shared/src/single_layer_tests/activation.cpp b/inference-engine/tests/functional/plugin/shared/src/single_layer_tests/activation.cpp index e5630ff6543..8a5c4cfccec 100644 --- a/inference-engine/tests/functional/plugin/shared/src/single_layer_tests/activation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/single_layer_tests/activation.cpp @@ -47,8 +47,36 @@ void ActivationLayerTest::SetUp() { InferenceEngine::Blob::Ptr ActivationLayerTest::GenerateInput(const InferenceEngine::InputInfo &info) const { bool inPrcSigned = function->get_parameters()[0]->get_element_type().is_signed(); - uint32_t data_range = 20; - int32_t data_start_from = activationType == ngraph::helpers::ActivationTypes::Log ? 1 : -10; + int32_t data_start_from; + uint32_t data_range; + + switch (activationType) { + case ngraph::helpers::ActivationTypes::Log: { + data_start_from = 1; + data_range = 20; + break; + } + case ngraph::helpers::ActivationTypes::Sqrt: { + data_start_from = 0; + data_range = 20; + break; + } + case ngraph::helpers::ActivationTypes::Asin: { + data_start_from = -1; + data_range = 2; + break; + } + case ngraph::helpers::ActivationTypes::Acos: { + data_start_from = -1; + data_range = 2; + break; + } + default: { + data_start_from = -10; + data_range = 20; + break; + } + } if (!inPrcSigned) { data_range = 15; data_start_from = 0; diff --git a/inference-engine/tests/ngraph_functions/include/ngraph_functions/utils/ngraph_helpers.hpp b/inference-engine/tests/ngraph_functions/include/ngraph_functions/utils/ngraph_helpers.hpp index 4a2b75ee0d3..9b60bd53a5c 100644 --- a/inference-engine/tests/ngraph_functions/include/ngraph_functions/utils/ngraph_helpers.hpp +++ b/inference-engine/tests/ngraph_functions/include/ngraph_functions/utils/ngraph_helpers.hpp @@ -89,7 +89,23 @@ enum ActivationTypes { Log, Sign, Abs, - Gelu + Gelu, + Clamp, + Negative, + Acos, + Asin, + Atan, + Cos, + Cosh, + Floor, + Sin, + Sinh, + Sqrt, + Tan, + Elu, + Erf, + HardSigmoid, + Selu }; enum EltwiseTypes { diff --git a/inference-engine/tests/ngraph_functions/src/activation.cpp b/inference-engine/tests/ngraph_functions/src/activation.cpp index 03d9a53c6fe..426f1ac33be 100644 --- a/inference-engine/tests/ngraph_functions/src/activation.cpp +++ b/inference-engine/tests/ngraph_functions/src/activation.cpp @@ -19,6 +19,14 @@ std::shared_ptr makeActivation(const ngraph::Output &in, ngraph::element::f32, ngraph::Shape{1}, std::vector{0.01f}); + auto selu_alpha = std::make_shared( + type, ngraph::Shape(), 1.6732f); + auto selu_lambda = std::make_shared( + type, ngraph::Shape(), 1.0507f); + auto hard_sigmoid_alpha = std::make_shared( + type, ngraph::Shape(), 0.2f); + auto hard_sigmoid_beta = std::make_shared( + type, ngraph::Shape(), 0.5f); switch (activationType) { case ngraph::helpers::ActivationTypes::Sigmoid: @@ -39,6 +47,38 @@ std::shared_ptr makeActivation(const ngraph::Output &in, return std::make_shared(in); case ngraph::helpers::ActivationTypes::Gelu: return std::make_shared(in); + case ngraph::helpers::ActivationTypes::Clamp: + return std::make_shared(in, -2.0, 2.0); + case ngraph::helpers::ActivationTypes::Negative: + return std::make_shared(in); + case ngraph::helpers::ActivationTypes::Acos: + return std::make_shared(in); + case ngraph::helpers::ActivationTypes::Asin: + return std::make_shared(in); + case ngraph::helpers::ActivationTypes::Atan: + return std::make_shared(in); + case ngraph::helpers::ActivationTypes::Cos: + return std::make_shared(in); + case ngraph::helpers::ActivationTypes::Cosh: + return std::make_shared(in); + case ngraph::helpers::ActivationTypes::Floor: + return std::make_shared(in); + case ngraph::helpers::ActivationTypes::Sin: + return std::make_shared(in); + case ngraph::helpers::ActivationTypes::Sinh: + return std::make_shared(in); + case ngraph::helpers::ActivationTypes::Sqrt: + return std::make_shared(in); + case ngraph::helpers::ActivationTypes::Tan: + return std::make_shared(in); + case ngraph::helpers::ActivationTypes::Elu: + return std::make_shared(in, 0.1); + case ngraph::helpers::ActivationTypes::Erf: + return std::make_shared(in); + case ngraph::helpers::ActivationTypes::HardSigmoid: + return std::make_shared(in, hard_sigmoid_alpha, hard_sigmoid_beta); + case ngraph::helpers::ActivationTypes::Selu: + return std::make_shared(in, selu_alpha, selu_lambda); default: throw std::runtime_error("Can't create layer for this activation type"); }