Unverified Commit 7f98942d authored by Michał Karzyński's avatar Michał Karzyński Committed by GitHub

Use default_opset in ONNX importer code (#4332)

* Use default_opset in Gemm

* Use default_opset in Cos and Cosh

* Use default_opset in Slice

* Use default_opset in Log

* Use explicit opset0 in ScatterND

* Use default_opset in Hardmax

* Use default_opset in utils

* Remove redundant headers

* Style check
parent b2da4cee
......@@ -64,7 +64,9 @@ add_library(onnx_import STATIC
op/ceil.hpp
op/clip.cpp
op/clip.hpp
op/cos.cpp
op/cos.hpp
op/cosh.cpp
op/cosh.hpp
op/concat.cpp
op/concat.hpp
......@@ -116,6 +118,7 @@ add_library(onnx_import STATIC
op/leaky_relu.cpp
op/leaky_relu.hpp
op/less.hpp
op/log.cpp
op/log.hpp
op/log_softmax.cpp
op/log_softmax.hpp
......
//*****************************************************************************
// 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 "cos.hpp"
#include "default_opset.hpp"
namespace ngraph
{
namespace onnx_import
{
namespace op
{
namespace set_1
{
NodeVector cos(const Node& node)
{
return {std::make_shared<default_opset::Cos>(node.get_ng_inputs().at(0))};
}
} // namespace set_1
} // namespace op
} // namespace onnx_import
} // namespace ngraph
......@@ -16,11 +16,8 @@
#pragma once
#include <memory>
#include "core/node.hpp"
#include "ngraph/node.hpp"
#include "ngraph/op/cos.hpp"
#include "ngraph/output_vector.hpp"
namespace ngraph
{
......@@ -30,13 +27,9 @@ namespace ngraph
{
namespace set_1
{
inline NodeVector cos(const Node& node)
{
return {std::make_shared<ngraph::op::Cos>(node.get_ng_inputs().at(0))};
}
} // namespace set_1
} // namespace op
NodeVector cos(const Node& node);
}
}
} // namespace onnx_import
......
//*****************************************************************************
// 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 "cosh.hpp"
#include "default_opset.hpp"
namespace ngraph
{
namespace onnx_import
{
namespace op
{
namespace set_1
{
NodeVector cosh(const Node& node)
{
return {std::make_shared<default_opset::Cosh>(node.get_ng_inputs().at(0))};
}
} // namespace set_1
} // namespace op
} // namespace onnx_import
} // namespace ngraph
......@@ -16,11 +16,8 @@
#pragma once
#include <memory>
#include "core/node.hpp"
#include "ngraph/node.hpp"
#include "ngraph/op/cosh.hpp"
#include "ngraph/output_vector.hpp"
namespace ngraph
{
......@@ -30,14 +27,9 @@ namespace ngraph
{
namespace set_1
{
inline NodeVector cosh(const Node& node)
{
return {std::make_shared<ngraph::op::Cosh>(node.get_ng_inputs().at(0))};
}
} // namespace set_1
} // namespace op
NodeVector cosh(const Node& node);
}
}
} // namespace onnx_import
} // namespace ngraph
......@@ -73,7 +73,7 @@ namespace ngraph
input_a = ngraph::builder::opset1::flatten(input_a, 1);
input_b = ngraph::builder::opset1::flatten(input_b, 1);
auto matmul_node = std::make_shared<ngraph::op::MatMul>(input_a, input_b);
auto matmul_node = std::make_shared<default_opset::MatMul>(input_a, input_b);
auto alpha_times_product =
std::make_shared<default_opset::Multiply>(alpha_node, matmul_node);
......
......@@ -57,11 +57,11 @@ namespace ngraph
1);
const auto depth =
ngraph::op::Constant::create(ngraph::element::i64, Shape{}, {row_size});
default_opset::Constant::create(ngraph::element::i64, Shape{}, {row_size});
const auto on_value =
ngraph::op::Constant::create(ngraph::element::i64, Shape{}, {1});
default_opset::Constant::create(ngraph::element::i64, Shape{}, {1});
const auto off_value =
ngraph::op::Constant::create(ngraph::element::i64, Shape{}, {0});
default_opset::Constant::create(ngraph::element::i64, Shape{}, {0});
const auto results = std::make_shared<default_opset::OneHot>(
max_indices, depth, on_value, off_value, indices_axis);
......
//*****************************************************************************
// 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 "default_opset.hpp"
#include "log.hpp"
namespace ngraph
{
namespace onnx_import
{
namespace op
{
namespace set_1
{
NodeVector log(const Node& node)
{
return {std::make_shared<default_opset::Log>(node.get_ng_inputs().at(0))};
}
} // namespace set_1
} // namespace op
} // namespace onnx_import
} // namespace ngraph
......@@ -16,11 +16,8 @@
#pragma once
#include <memory>
#include "core/node.hpp"
#include "ngraph/node.hpp"
#include "ngraph/op/log.hpp"
#include "ngraph/output_vector.hpp"
namespace ngraph
{
......@@ -30,14 +27,9 @@ namespace ngraph
{
namespace set_1
{
inline NodeVector log(const Node& node)
{
return {std::make_shared<ngraph::op::Log>(node.get_ng_inputs().at(0))};
}
} // namespace set_1
} // namespace op
NodeVector log(const Node& node);
}
}
} // namespace onnx_import
......
......@@ -16,7 +16,7 @@
#include <memory>
#include "ngraph/op/fused/scatter_nd.hpp"
#include "ngraph/opsets/opset0.hpp"
#include "scatter_nd.hpp"
namespace ngraph
......@@ -34,7 +34,7 @@ namespace ngraph
auto indices = ng_inputs.at(1);
auto updates = ng_inputs.at(2);
return {std::make_shared<ngraph::op::ScatterND>(data, indices, updates)};
return {std::make_shared<opset0::ScatterND>(data, indices, updates)};
}
} // namespace set_1
......
......@@ -72,11 +72,11 @@ namespace ngraph
}
}
const auto begin = ngraph::op::Constant::create(
const auto begin = default_opset::Constant::create(
element::i64, Shape{lower_bounds.size()}, lower_bounds);
const auto end = ngraph::op::Constant::create(
const auto end = default_opset::Constant::create(
element::i64, Shape{upper_bounds.size()}, upper_bounds);
const auto strides = ngraph::op::Constant::create(
const auto strides = default_opset::Constant::create(
element::i64, Shape{data_rank}, std::vector<int64_t>(data_rank, 1));
return {std::make_shared<default_opset::StridedSlice>(
......
......@@ -87,7 +87,7 @@ namespace ngraph
///
/// \return A Constant node representing shifted identity matrix.
template <typename T = double>
std::shared_ptr<ngraph::op::Constant>
std::shared_ptr<default_opset::Constant>
shifted_square_identity(const Shape output_shape,
const element::Type& output_type,
const std::int64_t shift)
......
......@@ -107,9 +107,9 @@ namespace ngraph
const auto op_node = reduction_function(
ng_input,
std::make_shared<ngraph::op::Constant>(element::i64,
ngraph::Shape{reduction_axes.size()},
reduction_axes.to_vector()),
std::make_shared<default_opset::Constant>(element::i64,
ngraph::Shape{reduction_axes.size()},
reduction_axes.to_vector()),
static_cast<bool>(keepdims));
return op_node;
......
......@@ -19,6 +19,7 @@
#include <iterator>
#include <numeric>
#include "default_opset.hpp"
#include "ngraph/builder/make_constant.hpp"
#include "ngraph/builder/reshape.hpp"
#include "ngraph/shape.hpp"
......@@ -104,8 +105,8 @@ namespace ngraph
if (node->is_constant())
{
const auto value =
ngraph::as_type_ptr<ngraph::op::Constant>(node)->get_data_ptr();
return std::make_shared<ngraph::op::Constant>(
ngraph::as_type_ptr<default_opset::Constant>(node)->get_data_ptr();
return std::make_shared<default_opset::Constant>(
node->get_element_type(), ngraph::Shape{}, value);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment