Add asinh to onnx importer opset4 (#1436)

This commit is contained in:
Gabriele Galiero Casay 2020-07-23 17:03:06 +02:00 committed by GitHub
parent c1dec4ad42
commit 2936ea8800
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 61 deletions

View File

@ -51,7 +51,6 @@ add_library(onnx_importer SHARED
op/argmin.cpp
op/argmin.hpp
op/asin.hpp
op/asinh.cpp
op/asinh.hpp
op/atan.hpp
op/atanh.cpp

View File

@ -1,59 +0,0 @@
//*****************************************************************************
// Copyright 2017-2020 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include <memory>
#include "asinh.hpp"
#include "default_opset.hpp"
#include "ngraph/op/add.hpp"
#include "ngraph/op/multiply.hpp"
#include "ngraph/shape.hpp"
namespace ngraph
{
namespace onnx_import
{
namespace op
{
namespace set_1
{
NodeVector asinh(const Node& node)
{
std::shared_ptr<ngraph::Node> data{node.get_ng_inputs().at(0)};
// Define inverse hyperbolic sine in terms of natural logarithm:
//
// asinh(x) = ln(x + sqrt(x^2 + 1))
//
const auto one =
default_opset::Constant::create(data->get_element_type(), {}, {1.f});
const auto x_square = std::make_shared<default_opset::Multiply>(data, data);
const auto sqrt_args = std::make_shared<default_opset::Add>(x_square, one);
const auto sqrt_node = std::make_shared<default_opset::Sqrt>(sqrt_args);
const auto log_args = std::make_shared<default_opset::Add>(data, sqrt_node);
return {std::make_shared<default_opset::Log>(log_args)};
}
} // namespace set_1
} // namespace op
} // namespace onnx_import
} // namespace ngraph

View File

@ -17,6 +17,7 @@
#pragma once
#include "core/node.hpp"
#include "default_opset.hpp"
#include "ngraph/node.hpp"
namespace ngraph
@ -27,7 +28,10 @@ namespace ngraph
{
namespace set_1
{
NodeVector asinh(const Node& node);
inline NodeVector asinh(const Node& node)
{
return {std::make_shared<default_opset::Asinh>(node.get_ng_inputs().at(0))};
}
} // namespace set_1
} // namespace op

View File

@ -156,3 +156,4 @@ NGRAPH_OP(TopK, ngraph::op::v3)
NGRAPH_OP(NonMaxSuppression, ngraph::op::v4)
NGRAPH_OP(Mish, ngraph::op::v4)
NGRAPH_OP(CTCLoss, ngraph::op::v4)
NGRAPH_OP(Asinh, ngraph::op::v3)