diff --git a/src/plugins/intel_gna/ops/softsign.cpp b/src/plugins/intel_gna/ops/softsign.cpp deleted file mode 100644 index 13678288fa2..00000000000 --- a/src/plugins/intel_gna/ops/softsign.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2018-2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "softsign.hpp" - -#include - -#include "ngraph/attribute_visitor.hpp" -#include "ngraph/runtime/host_tensor.hpp" - -#include -#include - -namespace ov { -namespace intel_gna { -namespace op { - -template -void softsign(const T* arg, T* out, size_t count) { - for (size_t i = 0; i < count; i++) { - out[i] = arg[i] / (1 + std::abs(arg[i])); - } -} - -SoftSign::SoftSign(const ngraph::Output& arg) : ov::op::util::UnaryElementwiseArithmetic(arg) { - constructor_validate_and_infer_types(); -} - -std::shared_ptr SoftSign::clone_with_new_inputs(const ngraph::OutputVector& new_args) const { - check_new_args_count(this, new_args); - return std::make_shared(new_args.at(0)); -} - -template -inline bool evaluate(const ov::Tensor& arg, ov::Tensor& out, const size_t count) { - using T = typename ngraph::element_type_traits::value_type; - softsign(arg.data(), out.data(), count); - return true; -} - -namespace { -bool evaluate_softsign(const ov::Tensor& arg, ov::Tensor& out) { - bool rc = true; - size_t count = shape_size(arg.get_shape()); - - switch (arg.get_element_type()) { - case ov::element::Type_t::f16: - rc = evaluate(arg, out, count); - break; - case ov::element::Type_t::f32: - rc = evaluate(arg, out, count); - break; - default: - rc = false; - break; - } - return rc; -} -} // namespace - -bool SoftSign::evaluate(ov::TensorVector& outputs, - const ov::TensorVector& inputs, - const ov::EvaluationContext& evaluation_context) const { - return evaluate_softsign(inputs[0], outputs[0]); -} - -bool SoftSign::has_evaluate() const { - switch (get_input_element_type(0)) { - case ngraph::element::f16: - case ngraph::element::f32: - return true; - default: - break; - } - return false; -} - -} // namespace op -} // namespace intel_gna -} // namespace ov diff --git a/src/plugins/intel_gna/ops/softsign.hpp b/src/plugins/intel_gna/ops/softsign.hpp deleted file mode 100644 index 8588cc49a4a..00000000000 --- a/src/plugins/intel_gna/ops/softsign.hpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2018-2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "openvino/op/op.hpp" -#include "ngraph/node.hpp" -#include "openvino/op/util/unary_elementwise_arithmetic.hpp" - -namespace ov { -namespace intel_gna { -namespace op { -/// \brief Neural Activation Function -/// f(x) = x/(1.0 + |x|) -/// -class SoftSign : public ov::op::util::UnaryElementwiseArithmetic { -public: - OPENVINO_OP("SoftSign", "intel_gna", ov::op::util::UnaryElementwiseArithmetic); - - SoftSign() = default; - /// \brief Constructs an SoftSign operation. - /// - /// \param data Input tensor - SoftSign(const ngraph::Output& arg); - std::shared_ptr clone_with_new_inputs(const ngraph::OutputVector& new_args) const override; - bool evaluate(ov::TensorVector& output_values, - const ov::TensorVector& input_values, - const ov::EvaluationContext & evaluation_context) const override; - bool has_evaluate() const override; -}; -} // namespace op -} // namespace intel_gna -} // namespace ov diff --git a/src/plugins/intel_gna/transformations/pwl_approximation.cpp b/src/plugins/intel_gna/transformations/pwl_approximation.cpp index ffdcc1f2ffb..7e353714ffb 100644 --- a/src/plugins/intel_gna/transformations/pwl_approximation.cpp +++ b/src/plugins/intel_gna/transformations/pwl_approximation.cpp @@ -45,7 +45,7 @@ bool split_search(double lower_bound, double upper_bound) { double break_bound = get_break_bound(); if (std::is_same::value || std::is_same::value || - std::is_same::value || + std::is_same::value || std::is_same::value || std::is_same::value) { return lower_bound < break_bound && upper_bound > break_bound; @@ -208,7 +208,7 @@ template bool is_negative(const details::Function& activation_function, double upper_bound) { if (std::is_same::value || std::is_same::value || - std::is_same::value) { + std::is_same::value) { return upper_bound == 0; } @@ -490,7 +490,7 @@ static std::shared_ptr create_matcher(ov::graph_rewrit ngraph::pattern::any_input(), ngraph::pattern::any_input() }); auto powerIE = ngraph::pattern::wrap_type({activation_input}); auto log = ngraph::pattern::wrap_type({activation_input}); - auto softsign = ngraph::pattern::wrap_type({activation_input}); + auto softsign = ngraph::pattern::wrap_type({activation_input}); auto activation_function = std::make_shared(ov::OutputVector{ sigmoid, tanh, exp, power, powerIE, log, softsign }); @@ -515,7 +515,7 @@ static std::shared_ptr create_matcher(ov::graph_rewrit ngraph::opset8::Power, ngraph::op::PowerIE, ngraph::opset8::Log, - ov::intel_gna::op::SoftSign>(), + ngraph::opset9::SoftSign>(), fake_quantize_iter != pattern_to_output.end() ? fake_quantize_iter->second.get_node_shared_ptr() : std::shared_ptr(), iter->second.get_node_shared_ptr(), diff --git a/src/plugins/intel_gna/transformations/pwl_approximation.hpp b/src/plugins/intel_gna/transformations/pwl_approximation.hpp index 71c69661e3b..525007afdb1 100644 --- a/src/plugins/intel_gna/transformations/pwl_approximation.hpp +++ b/src/plugins/intel_gna/transformations/pwl_approximation.hpp @@ -14,11 +14,10 @@ #include #include #include "ngraph/pattern/matcher.hpp" +#include #include #include -#include "ops/softsign.hpp" - namespace GNAPluginNS { /** * @ingroup ie_transformation_common_api @@ -178,7 +177,7 @@ struct Function { }; // struct Function template<> -struct Function { +struct Function { static const char* name() { return "softsign"; } @@ -206,7 +205,7 @@ struct Function { static double max_value() { return 1; } -}; // struct Function +}; // struct Function template<> struct Function { @@ -263,7 +262,7 @@ double lower_bound() { std::is_same::value || std::is_same::value || std::is_same::value || - std::is_same::value>()); + std::is_same::value>()); } template @@ -302,7 +301,7 @@ double upper_bound() { std::is_same::value || std::is_same::value || std::is_same::value || - std::is_same::value>()); + std::is_same::value>()); } template @@ -324,7 +323,7 @@ const char* name() { std::is_same::value || std::is_same::value || std::is_same::value || - std::is_same::value>()); + std::is_same::value>()); } template diff --git a/src/plugins/intel_gna/transformations/substitute_softsign.cpp b/src/plugins/intel_gna/transformations/substitute_softsign.cpp index 3e305d19119..16bc058a0f0 100644 --- a/src/plugins/intel_gna/transformations/substitute_softsign.cpp +++ b/src/plugins/intel_gna/transformations/substitute_softsign.cpp @@ -9,11 +9,11 @@ #include "transformations/utils/transformation_helper.hpp" #include "transformations/utils/utils.hpp" +#include #include #include #include #include -#include using namespace GNAPluginNS; @@ -22,7 +22,7 @@ using Node = std::shared_ptr; namespace { void DoTransformation(Node start_node, Node last_node) { - auto activation = std::make_shared(start_node); + auto activation = std::make_shared(start_node); activation->set_friendly_name(last_node->get_friendly_name()); ngraph::copy_runtime_info(last_node, activation); ngraph::replace_node(last_node, activation); diff --git a/src/tests/unit/gna/ngraph/op_eval/softsign.cpp b/src/tests/unit/gna/ngraph/op_eval/softsign.cpp deleted file mode 100644 index 1ba6b307579..00000000000 --- a/src/tests/unit/gna/ngraph/op_eval/softsign.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2018-2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "ops/softsign.hpp" - -#include -#include - -#include "execute_tools.hpp" -#include "gtest/gtest.h" -#include "ngraph/runtime/host_tensor.hpp" -#include "ngraph/validation_util.hpp" -#include "ngraph/opsets/opset8.hpp" - -TEST(op_eval, softsign) { - auto p = std::make_shared(ngraph::element::f32, ngraph::Shape{4}); - auto softsign = std::make_shared(p); - auto fun = std::make_shared(ngraph::OutputVector{softsign}, ngraph::ParameterVector{p}); - - float inputs[] = {-1.0, 0.0, 1.0, 20.0}; - std::vector expected_result{-0.5, 0.0, 0.5, 0.952381}; - - ov::TensorVector result(1); - ov::Tensor input{ov::element::f32, ov::Shape{4}, inputs}; - - ASSERT_TRUE(fun->evaluate(result, ov::TensorVector{input})); - - EXPECT_EQ(result.size(), 1); - EXPECT_EQ(result[0].get_element_type(), ngraph::element::f32); - EXPECT_EQ(result[0].get_shape(), ngraph::Shape{4}); - EXPECT_EQ(result[0].get_size(), 4); - - const float * result_data = result[0].data(); - for (size_t i = 0; i < result[0].get_size(); ++i) - EXPECT_NEAR(result_data[i], expected_result[i], 0.000001); -} - diff --git a/src/tests/unit/gna/ngraph/transformations/gna_pwl.cpp b/src/tests/unit/gna/ngraph/transformations/gna_pwl.cpp index b7087522360..f68213f364f 100644 --- a/src/tests/unit/gna/ngraph/transformations/gna_pwl.cpp +++ b/src/tests/unit/gna/ngraph/transformations/gna_pwl.cpp @@ -87,8 +87,8 @@ TEST(GnaPwlTest, Exp) { TEST(GnaPwlTest, SoftSign) { RunTest( - pwl_test::CreateActivationFunction({1, 32}), - pwl_test::CreateActivationFunction({1, 32}), + pwl_test::CreateActivationFunction({1, 32}), + pwl_test::CreateActivationFunction({1, 32}), -10, 10); } diff --git a/src/tests/unit/gna/ngraph/transformations/gna_substitute_softsign.cpp b/src/tests/unit/gna/ngraph/transformations/gna_substitute_softsign.cpp index e2e8ad6f5b6..93dece29b5a 100644 --- a/src/tests/unit/gna/ngraph/transformations/gna_substitute_softsign.cpp +++ b/src/tests/unit/gna/ngraph/transformations/gna_substitute_softsign.cpp @@ -8,11 +8,10 @@ #include "common_test_utils/ngraph_test_utils.hpp" #include +#include #include #include #include -#include - namespace testing { namespace { @@ -21,7 +20,7 @@ std::shared_ptr createSoftSignFunction() { auto input_params = std::make_shared(ngraph::element::f32, ngraph::Shape{ 1, 1, 1, 64 }); - auto softsign = std::make_shared(input_params); + auto softsign = std::make_shared(input_params); ngraph::ResultVector results{ std::make_shared(softsign) };