Add Acosh operator to ONNX importer opset4 (#1351)
This commit is contained in:
@@ -42,7 +42,6 @@ add_library(onnx_importer SHARED
|
||||
exceptions.cpp
|
||||
exceptions.hpp
|
||||
op/acos.hpp
|
||||
op/acosh.cpp
|
||||
op/acosh.hpp
|
||||
op/add.hpp
|
||||
op/add.cpp
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "ngraph/opsets/opset3.hpp"
|
||||
#include "ngraph/opsets/opset4.hpp"
|
||||
|
||||
namespace ngraph
|
||||
{
|
||||
namespace onnx_import
|
||||
{
|
||||
namespace default_opset = ngraph::opset3;
|
||||
namespace default_opset = ngraph::opset4;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,60 +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 "acosh.hpp"
|
||||
#include "default_opset.hpp"
|
||||
#include "ngraph/op/add.hpp"
|
||||
#include "ngraph/op/multiply.hpp"
|
||||
#include "ngraph/op/subtract.hpp"
|
||||
#include "ngraph/shape.hpp"
|
||||
|
||||
namespace ngraph
|
||||
{
|
||||
namespace onnx_import
|
||||
{
|
||||
namespace op
|
||||
{
|
||||
namespace set_1
|
||||
{
|
||||
NodeVector acosh(const Node& node)
|
||||
{
|
||||
std::shared_ptr<ngraph::Node> data{node.get_ng_inputs().at(0)};
|
||||
|
||||
// Define inverse hyperbolic cosine in terms of natural logarithm:
|
||||
//
|
||||
// arccosh(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::Subtract>(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
|
||||
@@ -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 acosh(const Node& node);
|
||||
inline NodeVector acosh(const Node& node)
|
||||
{
|
||||
return {std::make_shared<default_opset::Acosh>(node.get_ng_inputs().at(0))};
|
||||
}
|
||||
} // namespace set_1
|
||||
|
||||
} // namespace op
|
||||
|
||||
@@ -153,3 +153,4 @@ NGRAPH_OP(TopK, ngraph::op::v3)
|
||||
|
||||
// New operations added in opset4
|
||||
NGRAPH_OP(NonMaxSuppression, ngraph::op::v4)
|
||||
NGRAPH_OP(Acosh, ngraph::op::v3)
|
||||
|
||||
@@ -203,6 +203,8 @@ std::set<NodeTypeInfo> test::IE_Engine::get_ie_ops() const
|
||||
ie_ops.insert(opset2.begin(), opset2.end());
|
||||
const auto& opset3 = get_opset3().get_type_info_set();
|
||||
ie_ops.insert(opset3.begin(), opset3.end());
|
||||
const auto& opset4 = get_opset4().get_type_info_set();
|
||||
ie_ops.insert(opset4.begin(), opset4.end());
|
||||
return ie_ops;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user