Commit 6ca1a511 authored by amy.zhuang's avatar amy.zhuang

Merge branch 'master' into ayzhuang/in-place-concat

parents 749a1c6b 9debc0bc
...@@ -68,7 +68,7 @@ function build_ngraph() { ...@@ -68,7 +68,7 @@ function build_ngraph() {
make install || return 1 make install || return 1
cd "${ngraph_directory}/ngraph/python" cd "${ngraph_directory}/ngraph/python"
if [ ! -d ./pybind11 ]; then if [ ! -d ./pybind11 ]; then
git clone --recursive -b allow-nonconstructible-holders https://github.com/jagerman/pybind11.git git clone --recursive https://github.com/pybind/pybind11.git
fi fi
export PYBIND_HEADERS_PATH="${ngraph_directory}/ngraph/python/pybind11" export PYBIND_HEADERS_PATH="${ngraph_directory}/ngraph/python/pybind11"
export NGRAPH_CPP_BUILD_PATH="${ngraph_directory}/ngraph_dist" export NGRAPH_CPP_BUILD_PATH="${ngraph_directory}/ngraph_dist"
......
...@@ -39,7 +39,7 @@ RUN make install ...@@ -39,7 +39,7 @@ RUN make install
# Prepare nGraph Python API # Prepare nGraph Python API
WORKDIR /root/ngraph/python WORKDIR /root/ngraph/python
RUN git clone --recursive -b allow-nonconstructible-holders https://github.com/jagerman/pybind11.git RUN git clone --recursive https://github.com/pybind/pybind11.git
ENV NGRAPH_CPP_BUILD_PATH /root/ngraph_dist ENV NGRAPH_CPP_BUILD_PATH /root/ngraph_dist
ENV LD_LIBRARY_PATH /root/ngraph_dist/lib ENV LD_LIBRARY_PATH /root/ngraph_dist/lib
ENV PYBIND_HEADERS_PATH /root/ngraph/python/pybind11 ENV PYBIND_HEADERS_PATH /root/ngraph/python/pybind11
......
...@@ -196,27 +196,10 @@ if(WIN32) ...@@ -196,27 +196,10 @@ if(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
endif() endif()
include(unit_test_control)
set(UNIT_TEST_CONFIG_LIST "" CACHE INTERNAL "")
if (NGRAPH_INTERPRETER_ENABLE)
unit_test_control(BACKEND INTERPRETER MANIFEST src/ngraph/runtime/interpreter/unit_test.manifest)
endif()
# Set true if CPU backend is built by default
if (NGRAPH_CPU_ENABLE) if (NGRAPH_CPU_ENABLE)
unit_test_control(BACKEND CPU MANIFEST src/ngraph/runtime/cpu/unit_test.manifest)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNGRAPH_CPU_ENABLE") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNGRAPH_CPU_ENABLE")
endif() endif()
if (NGRAPH_INTELGPU_ENABLE)
unit_test_control(BACKEND INTELGPU MANIFEST src/ngraph/runtime/intelgpu/unit_test.manifest)
endif()
if (NGRAPH_GPU_ENABLE)
unit_test_control(BACKEND GPU MANIFEST src/ngraph/runtime/gpu/unit_test.manifest)
endif()
if (NOT DEFINED NGRAPH_TBB_ENABLE) if (NOT DEFINED NGRAPH_TBB_ENABLE)
set(NGRAPH_TBB_ENABLE ${NGRAPH_CPU_ENABLE}) set(NGRAPH_TBB_ENABLE ${NGRAPH_CPU_ENABLE})
endif() endif()
......
# nGraph Library [![Build Status][build-status-badge]][build-status] # nGraph Library [![Build Status][build-status-badge]][build-status]
Welcome to the open-source repository for the **Intel® nGraph Library**. Our code
Welcome to the open-source repository for the Intel® nGraph™ Library. Our code
base provides a Compiler and runtime suite of tools (APIs) designed to give base provides a Compiler and runtime suite of tools (APIs) designed to give
developers maximum flexibility for their software design, allowing them to developers maximum flexibility for their software design, allowing them to
create or customize a scalable solution using any framework while also avoiding create or customize a scalable solution using any framework while also avoiding
...@@ -11,7 +10,9 @@ backends, and it will be able to run on any backends we support in the future ...@@ -11,7 +10,9 @@ backends, and it will be able to run on any backends we support in the future
with minimal disruption to your model. With nGraph, you can co-evolve your with minimal disruption to your model. With nGraph, you can co-evolve your
software and hardware's capabilities to stay at the forefront of your industry. software and hardware's capabilities to stay at the forefront of your industry.
The nGraph Compiler is Intel's graph compiler for Artificial Neural Networks. ![nGraph ecosystem][ngraph-ecosystem]
The **nGraph Compiler** is Intel's graph compiler for Artificial Neural Networks.
Documentation in this repo describes how you can program any framework Documentation in this repo describes how you can program any framework
to run training and inference computations on a variety of Backends including to run training and inference computations on a variety of Backends including
Intel® Architecture Processors (CPUs), Intel® Nervana™ Neural Network Processors Intel® Architecture Processors (CPUs), Intel® Nervana™ Neural Network Processors
...@@ -24,18 +25,29 @@ whatever scenario you need. ...@@ -24,18 +25,29 @@ whatever scenario you need.
nGraph provides both a C++ API for framework developers and a Python API which nGraph provides both a C++ API for framework developers and a Python API which
can run inference on models imported from ONNX. can run inference on models imported from ONNX.
![nGraph ecosystem][ngraph-ecosystem] See the [Release Notes] for recent changes.
|Framework | bridge available? | ONNX support? | | Framework | bridge available? | ONNX support? |
|------------|-------------------|----------------| |----------------|-------------------|----------------|
| neon | yes | yes | | TensorFlow* | yes | yes |
| MXNet* | yes | yes | | MXNet* | yes | yes |
| TensorFlow*| yes | yes | | PaddlePaddle | yes | yes |
| PyTorch* | not yet | yes | | PyTorch* | no | yes |
| Chainer* | not yet | yes | | Chainer* | no | yes |
| CNTK* | not yet | yes | | CNTK* | no | yes |
| Caffe2* | not yet | yes | | Caffe2* | no | yes |
| Backend | current support | future support |
|-----------------------------------------------|-------------------|----------------|
| Intel® Architecture CPU | yes | yes |
| Intel® Nervana™ Neural Network Processor (NNP)| yes | yes |
| Intel [Movidius™ Myriad™ 2] VPUs | coming soon | yes |
| Intel® Architecture GPUs | via PlaidML | yes |
| AMD* GPUs | via PlaidML | yes |
| NVIDIA* GPUs | via PlaidML | some |
| Field Programmable Gate Arrays (FPGA) | no | yes |
## Documentation ## Documentation
...@@ -72,12 +84,13 @@ to improve the Library: ...@@ -72,12 +84,13 @@ to improve the Library:
[install]: http://ngraph.nervanasys.com/docs/latest/buildlb.html [install]: http://ngraph.nervanasys.com/docs/latest/buildlb.html
[framework integration guides]: http://ngraph.nervanasys.com/docs/latest/framework-integration-guides.html [framework integration guides]: http://ngraph.nervanasys.com/docs/latest/framework-integration-guides.html
[release notes]: http://ngraph.nervanasys.com/docs/latest/project/release-notes.html
[Github issues]: https://github.com/NervanaSystems/ngraph/issues [Github issues]: https://github.com/NervanaSystems/ngraph/issues
[contrib guide]: http://ngraph.nervanasys.com/docs/latest/project/code-contributor-README.html [contrib guide]: http://ngraph.nervanasys.com/docs/latest/project/code-contributor-README.html
[pull request]: https://github.com/NervanaSystems/ngraph/pulls [pull request]: https://github.com/NervanaSystems/ngraph/pulls
[how to import]: http://ngraph.nervanasys.com/docs/latest/howto/import.html [how to import]: http://ngraph.nervanasys.com/docs/latest/howto/import.html
[ngraph-ecosystem]: doc/sphinx/source/graphics/ngraph-ecosystem.png "nGraph Ecosystem" [ngraph-ecosystem]: doc/sphinx/source/graphics/599px-Intel-ngraph-ecosystem.png "nGraph Ecosystem"
[build-status]: https://travis-ci.org/NervanaSystems/ngraph/branches [build-status]: https://travis-ci.org/NervanaSystems/ngraph/branches
[build-status-badge]: https://travis-ci.org/NervanaSystems/ngraph.svg?branch=master [build-status-badge]: https://travis-ci.org/NervanaSystems/ngraph.svg?branch=master
[develop-without-lockin]: doc/sphinx/source/graphics/develop-without-lockin.png "Develop on any part of the stack wtihout lockin" [develop-without-lockin]: doc/sphinx/source/graphics/develop-without-lockin.png "Develop on any part of the stack wtihout lockin"
[Movidius]:https://www.movidius.com/solutions/vision-processing-unit [Movidius™ Myriad™ 2]:https://www.movidius.com/solutions/vision-processing-unit
# ******************************************************************************
# Copyright 2017-2018 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.
# ******************************************************************************
function(UNIT_TEST_CONTROL)
set(options)
set(oneValueArgs BACKEND MANIFEST)
set(multiValueArgs)
cmake_parse_arguments(UNIT_TEST_CONTROL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (UNIT_TEST_CONTROL_MANIFEST)
get_filename_component(UNIT_TEST_CONTROL_MANIFEST ${UNIT_TEST_CONTROL_MANIFEST} ABSOLUTE)
set(CONFIG_STRING "${UNIT_TEST_CONTROL_BACKEND}@${UNIT_TEST_CONTROL_MANIFEST}")
else()
set(CONFIG_STRING "${UNIT_TEST_CONTROL_BACKEND}@")
endif()
set(UNIT_TEST_CONFIG_LIST "${UNIT_TEST_CONFIG_LIST};${CONFIG_STRING}" CACHE INTERNAL "")
endfunction()
...@@ -68,9 +68,9 @@ author = 'Intel Corporation' ...@@ -68,9 +68,9 @@ author = 'Intel Corporation'
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = '0.8' version = '0.9'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '0.8.0' release = '0.9.0'
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.
......
...@@ -30,8 +30,8 @@ software engineers, and others with the means to make their work :ref:`portable` ...@@ -30,8 +30,8 @@ software engineers, and others with the means to make their work :ref:`portable`
:abbr:`Machine Learning (ML)` hardware available today: optimized Deep Learning :abbr:`Machine Learning (ML)` hardware available today: optimized Deep Learning
computation devices. computation devices.
.. figure:: graphics/ngraph-ecosystem.png .. figure:: graphics/599px-Intel-ngraph-ecosystem.png
:width: 650px :width: 599px
.. _portable: .. _portable:
...@@ -66,16 +66,15 @@ Python-based API. See the `ngraph onnx companion tool`_ to get started. ...@@ -66,16 +66,15 @@ Python-based API. See the `ngraph onnx companion tool`_ to get started.
.. csv-table:: .. csv-table::
:header: "Framework", "Bridge Code Available?", "ONNX Support?" :header: "Framework", "Bridge Available?", "ONNX Support?"
:widths: 27, 10, 10 :widths: 27, 10, 10
TensorFlow, Yes, Yes TensorFlow, Yes, Yes
MXNet, Yes, Yes MXNet, Yes, Yes
PaddlePaddle, Coming Soon, Yes PaddlePaddle, Coming Soon, Yes
neon, none needed, Yes PyTorch, No, Yes
PyTorch, Coming Soon, Yes CNTK, No, Yes
CNTK, Not yet, Yes Other, Custom, Custom
Other, Not yet, Doable
.. _deployable: .. _deployable:
...@@ -104,14 +103,16 @@ model to run on a variety of backends: ...@@ -104,14 +103,16 @@ model to run on a variety of backends:
.. csv-table:: .. csv-table::
:header: "Backend", "Current nGraph support", "Future nGraph support" :header: "Backend", "Current support", "Future nGraph support"
:widths: 35, 10, 10 :widths: 35, 10, 10
Intel® Architecture Processors (CPUs), Yes, Yes Intel® Architecture Processors (CPUs), Yes, Yes
Intel® Nervana™ Neural Network Processor™ (NNPs), Yes, Yes Intel® Nervana™ Neural Network Processor (NNPs), Yes, Yes
NVIDIA\* CUDA (GPUs), Yes, Some AMD\* GPUs, via PlaidML, Yes
NVIDIA\* GPUs, via PlaidML, Some
Intel® Architecture GPUs, Yes, Yes
:abbr:`Field Programmable Gate Arrays (FPGA)` (FPGAs), Coming soon, Yes :abbr:`Field Programmable Gate Arrays (FPGA)` (FPGAs), Coming soon, Yes
`Movidius`_, Not yet, Yes Intel Movidius™ Myriad™ 2 (VPU), Coming soon, Yes
Other, Not yet, Ask Other, Not yet, Ask
The value we're offering to the developer community is empowerment: we are The value we're offering to the developer community is empowerment: we are
...@@ -119,12 +120,11 @@ confident that Intel® Architecture already provides the best computational ...@@ -119,12 +120,11 @@ confident that Intel® Architecture already provides the best computational
resources available for the breadth of ML/DL tasks. We welcome ideas and resources available for the breadth of ML/DL tasks. We welcome ideas and
`contributions`_ from the community. `contributions`_ from the community.
Further project details can be found on our :doc:`project/about` page, or see Further project details can be found on our :doc:`project/about` page, or see
our :doc:`buildlb` guide for how to get started. our :doc:`buildlb` guide for how to get started.
.. note:: The library code is under active development as we're continually .. note:: The Library code is under active development as we're continually
adding support for more kinds of DL models and ops, framework compiler adding support for more kinds of DL models and ops, framework compiler
optimizations, and backends. optimizations, and backends.
...@@ -152,7 +152,6 @@ Contents ...@@ -152,7 +152,6 @@ Contents
project/index.rst project/index.rst
Indices and tables Indices and tables
================== ==================
...@@ -164,4 +163,3 @@ Indices and tables ...@@ -164,4 +163,3 @@ Indices and tables
.. _ngraph onnx companion tool: https://github.com/NervanaSystems/ngraph-onnx .. _ngraph onnx companion tool: https://github.com/NervanaSystems/ngraph-onnx
.. _Movidius: https://www.movidius.com/ .. _Movidius: https://www.movidius.com/
.. _contributions: https://github.com/NervanaSystems/ngraph#how-to-contribute .. _contributions: https://github.com/NervanaSystems/ngraph#how-to-contribute
\ No newline at end of file
...@@ -5,7 +5,7 @@ Overview ...@@ -5,7 +5,7 @@ Overview
Welcome to the documentation site for |InG|, an open-source C++ Compiler, Welcome to the documentation site for |InG|, an open-source C++ Compiler,
Library, and runtime suite for running training and inference on Library, and runtime suite for Deep Learning frameworks running training and inference on
:abbr:`Deep Neural Network (DNN)` models. nGraph is framework-neutral and can be :abbr:`Deep Neural Network (DNN)` models. nGraph is framework-neutral and can be
targeted for programming and deploying :abbr:`Deep Learning (DL)` applications targeted for programming and deploying :abbr:`Deep Learning (DL)` applications
on the most modern compute and edge devices. on the most modern compute and edge devices.
...@@ -22,8 +22,8 @@ Features ...@@ -22,8 +22,8 @@ Features
Develop without lock-in Develop without lock-in
~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~
.. figure:: ../graphics/develop-without-lockin.png .. figure:: ../graphics/599px-Intel-ngraph-ecosystem.png
:width: 650px :width: 599px
Being able to increase training performance or reduce inference latency by simply Being able to increase training performance or reduce inference latency by simply
...@@ -34,47 +34,6 @@ developers working with nGraph. Our commitment to bake flexibility into our ...@@ -34,47 +34,6 @@ developers working with nGraph. Our commitment to bake flexibility into our
ecosystem ensures developers' freedom to design user-facing APIs for various ecosystem ensures developers' freedom to design user-facing APIs for various
hardware deployments directly into their frameworks. hardware deployments directly into their frameworks.
.. figure:: ../graphics/ngraph-ecosystem.png
:width: 585px
nGraph currently supports :doc:`three popular <../framework-integration-guides>`
frameworks for :abbr:`Deep Learning (DL)` models through what we call
a :term:`bridge` that can be integrated during the framework's build time.
For developers working with other frameworks (even those not listed above),
we've created a :doc:`How to Guide <../howto/index>` so you can learn how to
create custom bridge code that can be used to
:doc:`compile and run <../howto/execute>` a training model.
Additionally, nGraph Library supports the `ONNX`_ format. Developers who
already have a "trained" model can use nGraph to bypass much of the
framework-based complexity and :doc:`../howto/import` to test or run it
on targeted and efficient backends with our user-friendly ``ngraph_api``.
With nGraph, data scientists can focus on data science rather than worrying
about how to adapt models to train and run efficiently on different devices.
Be sure to add the ``-DNGRAPH_ONNX_IMPORT_ENABLE=ON`` option when running `cmake`
to build the Library.
Supported platforms
--------------------
* Intel® Architecture Processors (CPUs),
* Intel® Nervana™ Neural Network Processor™ (NNPs), and
* NVIDIA\* CUDA (GPUs).
We built the first-generation of the Intel Nervana™ NNP family of processors
last year to show that the nGraph Library can be used to train a
:abbr:`Neural Network (NN)` more quickly. The more advanced the silicon, the
more powerful a lightweight a library can be. So while we do currently support
traditional GPUs, they are not advanced silicon, and trying to scale workloads
using traditional GPU libraries is clunky and brittle with bottlenecks. Iteration
from an already-trained NN model to one that can also perform inference
computations is immensely simplified. Read more about these compute-friendly
options on the documentation for :doc:`../fusion/index`.
.. note:: The library code is under active development as we're continually .. note:: The library code is under active development as we're continually
adding support for more kinds of DL models and ops, framework compiler adding support for more kinds of DL models and ops, framework compiler
optimizations, and backends. optimizations, and backends.
......
...@@ -15,13 +15,13 @@ ...@@ -15,13 +15,13 @@
.. limitations under the License. .. limitations under the License.
.. --------------------------------------------------------------------------- .. ---------------------------------------------------------------------------
nGraph Library docs nGraph Library docs
==================== ===================
Read this for changes affecting anything in ``ngraph/doc`` Read this for changes affecting anything in ``ngraph/doc``
---------------------------------------------------------- ----------------------------------------------------------
For updates to the Intel® nGraph Library ``/doc`` repo, please submit a PR with For updates to the Intel® nGraph Library ``/doc`` repo, please submit a PR with
any changes or ideas you'd like integrated. This helps us maintain trackability any changes or ideas you'd like integrated. This helps us maintain trackability
with respect to additions or feature requests. with respect to additions or feature requests.
...@@ -127,7 +127,7 @@ To build documentation locally, run: ...@@ -127,7 +127,7 @@ To build documentation locally, run:
.. code-block:: console .. code-block:: console
$ pip3 install [-I] Sphinx==1.6.5 [--user] $ pip3 install [-I] Sphinx==1.7.5 [--user]
$ pip3 install [-I] breathe numpy [--user] $ pip3 install [-I] breathe numpy [--user]
$ cd doc/sphinx/ $ cd doc/sphinx/
$ make html $ make html
...@@ -150,11 +150,16 @@ To build documentation in a python3 virtualenv, run: ...@@ -150,11 +150,16 @@ To build documentation in a python3 virtualenv, run:
Then point your browser at ``localhost:8000``. Then point your browser at ``localhost:8000``.
.. note:: For docs built in a virtual env, Sphinx latest changes may break
documentation; try building with a specific version of Sphinx.
For tips on writing reStructuredText-formatted documentation, see the `sphinx`_ For tips on writing reStructuredText-formatted documentation, see the `sphinx`_
stable reST documentation. stable reST documentation.
.. _ngraph repo: https://github.com/NervanaSystems/ngraph-cpp/ .. _ngraph repo: https://github.com/NervanaSystems/ngraph/
.. _documentation repo: https://github.com/NervanaSystems/private-ngraph/tree/master/doc .. _documentation repo: https://github.com/NervanaSystems/ngraph/tree/master/doc
.. _sphinx: http://www.sphinx-doc.org/en/stable/rest.html .. _sphinx: http://www.sphinx-doc.org/en/stable/rest.html
.. _wiki: https://github.com/NervanaSystems/ngraph/wiki/ .. _wiki: https://github.com/NervanaSystems/ngraph/wiki/
.. _breathe: https://breathe.readthedocs.io/en/latest/ .. _breathe: https://breathe.readthedocs.io/en/latest/
......
...@@ -3,5 +3,12 @@ ...@@ -3,5 +3,12 @@
Release Notes Release Notes
############# #############
This is the |version| of release. This is release |release|.
API Changes
===========
.. literalinclude:: ../../../../changes.md
...@@ -28,13 +28,17 @@ namespace ngraph ...@@ -28,13 +28,17 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector abs(const Node& node) inline NodeVector abs(const Node& node)
{ {
return {std::make_shared<ngraph::op::Abs>(node.get_ng_inputs().at(0))}; return {std::make_shared<ngraph::op::Abs>(node.get_ng_inputs().at(0))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -27,6 +27,8 @@ namespace ngraph ...@@ -27,6 +27,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector add(const Node& node) inline NodeVector add(const Node& node)
{ {
...@@ -35,7 +37,9 @@ namespace ngraph ...@@ -35,7 +37,9 @@ namespace ngraph
return {std::make_shared<ngraph::op::Add>(ng_inputs.at(0), ng_inputs.at(1))}; return {std::make_shared<ngraph::op::Add>(ng_inputs.at(0), ng_inputs.at(1))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -27,6 +27,8 @@ namespace ngraph ...@@ -27,6 +27,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector logical_and(const Node& node) inline NodeVector logical_and(const Node& node)
{ {
...@@ -35,7 +37,9 @@ namespace ngraph ...@@ -35,7 +37,9 @@ namespace ngraph
return {std::make_shared<ngraph::op::And>(ng_inputs.at(0), ng_inputs.at(1))}; return {std::make_shared<ngraph::op::And>(ng_inputs.at(0), ng_inputs.at(1))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,13 +25,17 @@ namespace ngraph ...@@ -25,13 +25,17 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector average_pool(const Node& node) NodeVector average_pool(const Node& node)
{ {
return convpool::make_ng_pool<ngraph::op::AvgPool>(node); return convpool::make_ng_pool<ngraph::op::AvgPool>(node);
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,6 +25,8 @@ namespace ngraph ...@@ -25,6 +25,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
/** /**
* @brief Convert ONNX AveragePool operation to an nGraph node. * @brief Convert ONNX AveragePool operation to an nGraph node.
...@@ -36,7 +38,9 @@ namespace ngraph ...@@ -36,7 +38,9 @@ namespace ngraph
*/ */
NodeVector average_pool(const Node& node); NodeVector average_pool(const Node& node);
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -27,6 +27,8 @@ namespace ngraph ...@@ -27,6 +27,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector batch_norm(const Node& node) NodeVector batch_norm(const Node& node)
{ {
...@@ -58,7 +60,9 @@ namespace ngraph ...@@ -58,7 +60,9 @@ namespace ngraph
return {std::make_shared<ngraph::op::BatchNorm>(epsilon, scale, bias, x)}; return {std::make_shared<ngraph::op::BatchNorm>(epsilon, scale, bias, x)};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -23,9 +23,14 @@ namespace ngraph ...@@ -23,9 +23,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector batch_norm(const Node& node); NodeVector batch_norm(const Node& node);
} // namespace op
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -29,6 +29,8 @@ namespace ngraph ...@@ -29,6 +29,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector cast(const Node& node) NodeVector cast(const Node& node)
{ {
...@@ -50,14 +52,18 @@ namespace ngraph ...@@ -50,14 +52,18 @@ namespace ngraph
case onnx::TensorProto_DataType_UINT16: elem_type = element::u16; break; case onnx::TensorProto_DataType_UINT16: elem_type = element::u16; break;
case onnx::TensorProto_DataType_UINT32: elem_type = element::u32; break; case onnx::TensorProto_DataType_UINT32: elem_type = element::u32; break;
case onnx::TensorProto_DataType_UINT64: elem_type = element::u64; break; case onnx::TensorProto_DataType_UINT64: elem_type = element::u64; break;
case onnx::TensorProto_DataType_UNDEFINED: elem_type = element::unspecified; break; case onnx::TensorProto_DataType_UNDEFINED:
elem_type = element::unspecified;
break;
default: ASSERT_IS_SUPPORTED(node, false) << "unsupported type"; default: ASSERT_IS_SUPPORTED(node, false) << "unsupported type";
} }
return {std::make_shared<ngraph::op::Convert>(data, elem_type)}; return {std::make_shared<ngraph::op::Convert>(data, elem_type)};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,9 +25,14 @@ namespace ngraph ...@@ -25,9 +25,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector cast(const Node& node); NodeVector cast(const Node& node);
} // namespace op
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -28,13 +28,17 @@ namespace ngraph ...@@ -28,13 +28,17 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector ceil(const Node& node) inline NodeVector ceil(const Node& node)
{ {
return {std::make_shared<ngraph::op::Ceiling>(node.get_ng_inputs().at(0))}; return {std::make_shared<ngraph::op::Ceiling>(node.get_ng_inputs().at(0))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -33,6 +33,8 @@ namespace ngraph ...@@ -33,6 +33,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector clip(const Node& node) NodeVector clip(const Node& node)
{ {
...@@ -40,24 +42,29 @@ namespace ngraph ...@@ -40,24 +42,29 @@ namespace ngraph
double max_value = double max_value =
node.get_attribute_value<double>("max", std::numeric_limits<double>::max()); node.get_attribute_value<double>("max", std::numeric_limits<double>::max());
double min_value = double min_value = node.get_attribute_value<double>(
node.get_attribute_value<double>("min", std::numeric_limits<double>::lowest()); "min", std::numeric_limits<double>::lowest());
std::shared_ptr<ngraph::Node> max_value_node = std::shared_ptr<ngraph::Node> max_value_node =
std::make_shared<ngraph::op::Constant>( std::make_shared<ngraph::op::Constant>(data->get_element_type(),
data->get_element_type(), ngraph::Shape{}, std::vector<double>{max_value}); ngraph::Shape{},
std::vector<double>{max_value});
max_value_node = make_broadcast_node(max_value_node, data->get_shape()); max_value_node = make_broadcast_node(max_value_node, data->get_shape());
std::shared_ptr<ngraph::Node> min_value_node = std::shared_ptr<ngraph::Node> min_value_node =
std::make_shared<ngraph::op::Constant>( std::make_shared<ngraph::op::Constant>(data->get_element_type(),
data->get_element_type(), ngraph::Shape{}, std::vector<double>{min_value}); ngraph::Shape{},
std::vector<double>{min_value});
min_value_node = make_broadcast_node(min_value_node, data->get_shape()); min_value_node = make_broadcast_node(min_value_node, data->get_shape());
return {std::make_shared<ngraph::op::Minimum>( return {std::make_shared<ngraph::op::Minimum>(
max_value_node, std::make_shared<ngraph::op::Maximum>(data, min_value_node))}; max_value_node,
std::make_shared<ngraph::op::Maximum>(data, min_value_node))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,9 +25,14 @@ namespace ngraph ...@@ -25,9 +25,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector clip(const Node& node); NodeVector clip(const Node& node);
} // namespace op
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -23,6 +23,8 @@ namespace ngraph ...@@ -23,6 +23,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector concat(const Node& node) NodeVector concat(const Node& node)
{ {
...@@ -32,7 +34,9 @@ namespace ngraph ...@@ -32,7 +34,9 @@ namespace ngraph
return {std::make_shared<ngraph::op::Concat>(inputs, axis)}; return {std::make_shared<ngraph::op::Concat>(inputs, axis)};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,9 +25,14 @@ namespace ngraph ...@@ -25,9 +25,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector concat(const Node& node); NodeVector concat(const Node& node);
} // namespace op
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -24,6 +24,8 @@ namespace ngraph ...@@ -24,6 +24,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
namespace namespace
{ {
...@@ -36,7 +38,8 @@ namespace ngraph ...@@ -36,7 +38,8 @@ namespace ngraph
} }
template <Tensor::Type> template <Tensor::Type>
inline std::shared_ptr<ngraph::op::Constant> make_ng_constant(const Tensor& tensor) inline std::shared_ptr<ngraph::op::Constant>
make_ng_constant(const Tensor& tensor)
{ {
throw error::tensor::unsupported_data_type{tensor}; throw error::tensor::unsupported_data_type{tensor};
} }
...@@ -114,7 +117,9 @@ namespace ngraph ...@@ -114,7 +117,9 @@ namespace ngraph
return {make_constant(node.get_attribute_value<Tensor>("value"))}; return {make_constant(node.get_attribute_value<Tensor>("value"))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,10 +25,14 @@ namespace ngraph ...@@ -25,10 +25,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector constant(const Node& node); NodeVector constant(const Node& node);
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -36,6 +36,8 @@ namespace ngraph ...@@ -36,6 +36,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
namespace namespace
{ {
...@@ -63,7 +65,8 @@ namespace ngraph ...@@ -63,7 +65,8 @@ namespace ngraph
// initial bounds for splice // initial bounds for splice
std::vector<std::size_t> data_lower_bounds(data->get_shape().size()); std::vector<std::size_t> data_lower_bounds(data->get_shape().size());
std::vector<std::size_t> data_upper_bounds{data->get_shape()}; std::vector<std::size_t> data_upper_bounds{data->get_shape()};
std::vector<std::size_t> filters_lower_bounds(filters->get_shape().size()); std::vector<std::size_t> filters_lower_bounds(
filters->get_shape().size());
std::vector<std::size_t> filters_upper_bounds{filters->get_shape()}; std::vector<std::size_t> filters_upper_bounds{filters->get_shape()};
for (std::size_t group{0}; group < groups; ++group) for (std::size_t group{0}; group < groups; ++group)
...@@ -136,7 +139,9 @@ namespace ngraph ...@@ -136,7 +139,9 @@ namespace ngraph
return {std::make_shared<ngraph::op::Add>(conv_node, broadcasted_bias)}; return {std::make_shared<ngraph::op::Add>(conv_node, broadcasted_bias)};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,6 +25,8 @@ namespace ngraph ...@@ -25,6 +25,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
/// \brief Performs ONNX Conv operation. /// \brief Performs ONNX Conv operation.
/// ///
...@@ -34,7 +36,9 @@ namespace ngraph ...@@ -34,7 +36,9 @@ namespace ngraph
/// operation. /// operation.
NodeVector conv(const Node& node); NodeVector conv(const Node& node);
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -27,6 +27,8 @@ namespace ngraph ...@@ -27,6 +27,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector div(const Node& node) inline NodeVector div(const Node& node)
{ {
...@@ -35,7 +37,9 @@ namespace ngraph ...@@ -35,7 +37,9 @@ namespace ngraph
return {std::make_shared<ngraph::op::Divide>(ng_inputs.at(0), ng_inputs.at(1))}; return {std::make_shared<ngraph::op::Divide>(ng_inputs.at(0), ng_inputs.at(1))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -37,27 +37,34 @@ namespace ngraph ...@@ -37,27 +37,34 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector elu(const Node& node) NodeVector elu(const Node& node)
{ {
auto data = node.get_ng_inputs().at(0); auto data = node.get_ng_inputs().at(0);
double alpha = node.get_attribute_value<double>("alpha", 1); double alpha = node.get_attribute_value<double>("alpha", 1);
std::shared_ptr<ngraph::Node> alpha_node = std::make_shared<ngraph::op::Constant>( std::shared_ptr<ngraph::Node> alpha_node =
std::make_shared<ngraph::op::Constant>(
data->get_element_type(), Shape{}, std::vector<double>{alpha}); data->get_element_type(), Shape{}, std::vector<double>{alpha});
alpha_node = make_broadcast_node(alpha_node, data->get_shape()); alpha_node = make_broadcast_node(alpha_node, data->get_shape());
std::shared_ptr<ngraph::Node> zero_node = std::make_shared<ngraph::op::Constant>( std::shared_ptr<ngraph::Node> zero_node =
std::make_shared<ngraph::op::Constant>(
data->get_element_type(), Shape{}, std::vector<double>{0}); data->get_element_type(), Shape{}, std::vector<double>{0});
zero_node = make_broadcast_node(zero_node, data->get_shape()); zero_node = make_broadcast_node(zero_node, data->get_shape());
return {std::make_shared<ngraph::op::Maximum>(data, zero_node) + return {std::make_shared<ngraph::op::Maximum>(data, zero_node) +
alpha_node * std::make_shared<ngraph::op::Exp>( alpha_node *
std::make_shared<ngraph::op::Exp>(
std::make_shared<ngraph::op::Minimum>(data, zero_node)) - std::make_shared<ngraph::op::Minimum>(data, zero_node)) -
alpha_node}; alpha_node};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,9 +25,14 @@ namespace ngraph ...@@ -25,9 +25,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector elu(const Node& node); NodeVector elu(const Node& node);
} // namespace op
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -27,6 +27,8 @@ namespace ngraph ...@@ -27,6 +27,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector equal(const Node& node) inline NodeVector equal(const Node& node)
{ {
...@@ -35,7 +37,9 @@ namespace ngraph ...@@ -35,7 +37,9 @@ namespace ngraph
return {std::make_shared<ngraph::op::Equal>(ng_inputs.at(0), ng_inputs.at(1))}; return {std::make_shared<ngraph::op::Equal>(ng_inputs.at(0), ng_inputs.at(1))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -28,13 +28,17 @@ namespace ngraph ...@@ -28,13 +28,17 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector exp(const Node& node) inline NodeVector exp(const Node& node)
{ {
return {std::make_shared<ngraph::op::Exp>(node.get_ng_inputs().at(0))}; return {std::make_shared<ngraph::op::Exp>(node.get_ng_inputs().at(0))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -24,6 +24,8 @@ namespace ngraph ...@@ -24,6 +24,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector flatten(const Node& node) NodeVector flatten(const Node& node)
{ {
...@@ -37,7 +39,9 @@ namespace ngraph ...@@ -37,7 +39,9 @@ namespace ngraph
return {reshape::flatten(data, axis)}; return {reshape::flatten(data, axis)};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -27,9 +27,14 @@ namespace ngraph ...@@ -27,9 +27,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector flatten(const Node& node); NodeVector flatten(const Node& node);
} // namespace op
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -28,13 +28,17 @@ namespace ngraph ...@@ -28,13 +28,17 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector floor(const Node& node) inline NodeVector floor(const Node& node)
{ {
return {std::make_shared<ngraph::op::Floor>(node.get_ng_inputs().at(0))}; return {std::make_shared<ngraph::op::Floor>(node.get_ng_inputs().at(0))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -31,6 +31,8 @@ namespace ngraph ...@@ -31,6 +31,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector gemm(const Node& node) NodeVector gemm(const Node& node)
{ {
...@@ -60,13 +62,17 @@ namespace ngraph ...@@ -60,13 +62,17 @@ namespace ngraph
std::shared_ptr<ngraph::Node> a_dot_b = std::shared_ptr<ngraph::Node> a_dot_b =
std::make_shared<ngraph::op::Dot>(input_a, input_b); std::make_shared<ngraph::op::Dot>(input_a, input_b);
std::shared_ptr<ngraph::Node> alpha_node = std::make_shared<ngraph::op::Constant>( std::shared_ptr<ngraph::Node> alpha_node =
a_dot_b->get_element_type(), ngraph::Shape{}, std::vector<double>{alpha}); std::make_shared<ngraph::op::Constant>(a_dot_b->get_element_type(),
ngraph::Shape{},
std::vector<double>{alpha});
alpha_node = make_broadcast_node(alpha_node, a_dot_b->get_shape()); alpha_node = make_broadcast_node(alpha_node, a_dot_b->get_shape());
a_dot_b = std::make_shared<ngraph::op::Multiply>(alpha_node, a_dot_b); a_dot_b = std::make_shared<ngraph::op::Multiply>(alpha_node, a_dot_b);
std::shared_ptr<ngraph::Node> beta_node = std::make_shared<ngraph::op::Constant>( std::shared_ptr<ngraph::Node> beta_node =
input_c->get_element_type(), ngraph::Shape{}, std::vector<double>{beta}); std::make_shared<ngraph::op::Constant>(input_c->get_element_type(),
ngraph::Shape{},
std::vector<double>{beta});
beta_node = make_broadcast_node(beta_node, input_c->get_shape()); beta_node = make_broadcast_node(beta_node, input_c->get_shape());
input_c = std::make_shared<ngraph::op::Multiply>(beta_node, input_c); input_c = std::make_shared<ngraph::op::Multiply>(beta_node, input_c);
...@@ -75,7 +81,9 @@ namespace ngraph ...@@ -75,7 +81,9 @@ namespace ngraph
return {std::make_shared<ngraph::op::Add>(a_dot_b, input_c)}; return {std::make_shared<ngraph::op::Add>(a_dot_b, input_c)};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -27,9 +27,14 @@ namespace ngraph ...@@ -27,9 +27,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector gemm(const Node& node); NodeVector gemm(const Node& node);
} // namespace op
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -27,15 +27,20 @@ namespace ngraph ...@@ -27,15 +27,20 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector greater(const Node& node) inline NodeVector greater(const Node& node)
{ {
NodeVector ng_inputs{ NodeVector ng_inputs{
numpy_style_broadcast_for_binary_operation(node.get_ng_inputs())}; numpy_style_broadcast_for_binary_operation(node.get_ng_inputs())};
return {std::make_shared<ngraph::op::Greater>(ng_inputs.at(0), ng_inputs.at(1))}; return {
std::make_shared<ngraph::op::Greater>(ng_inputs.at(0), ng_inputs.at(1))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -34,6 +34,8 @@ namespace ngraph ...@@ -34,6 +34,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector hard_sigmoid(const Node& node) NodeVector hard_sigmoid(const Node& node)
{ {
...@@ -42,11 +44,13 @@ namespace ngraph ...@@ -42,11 +44,13 @@ namespace ngraph
double alpha = node.get_attribute_value<double>("alpha", 0.2); double alpha = node.get_attribute_value<double>("alpha", 0.2);
double beta = node.get_attribute_value<double>("beta", 0.5); double beta = node.get_attribute_value<double>("beta", 0.5);
std::shared_ptr<ngraph::Node> alpha_node = std::make_shared<ngraph::op::Constant>( std::shared_ptr<ngraph::Node> alpha_node =
std::make_shared<ngraph::op::Constant>(
data->get_element_type(), ngraph::Shape{}, std::vector<double>{alpha}); data->get_element_type(), ngraph::Shape{}, std::vector<double>{alpha});
alpha_node = make_broadcast_node(alpha_node, data->get_shape()); alpha_node = make_broadcast_node(alpha_node, data->get_shape());
std::shared_ptr<ngraph::Node> beta_node = std::make_shared<ngraph::op::Constant>( std::shared_ptr<ngraph::Node> beta_node =
std::make_shared<ngraph::op::Constant>(
data->get_element_type(), ngraph::Shape{}, std::vector<double>{beta}); data->get_element_type(), ngraph::Shape{}, std::vector<double>{beta});
beta_node = make_broadcast_node(beta_node, data->get_shape()); beta_node = make_broadcast_node(beta_node, data->get_shape());
...@@ -54,7 +58,8 @@ namespace ngraph ...@@ -54,7 +58,8 @@ namespace ngraph
data->get_element_type(), Shape{}, std::vector<double>{1}); data->get_element_type(), Shape{}, std::vector<double>{1});
one_node = make_broadcast_node(one_node, data->get_shape()); one_node = make_broadcast_node(one_node, data->get_shape());
std::shared_ptr<ngraph::Node> zero_node = std::make_shared<ngraph::op::Constant>( std::shared_ptr<ngraph::Node> zero_node =
std::make_shared<ngraph::op::Constant>(
data->get_element_type(), Shape{}, std::vector<double>{0}); data->get_element_type(), Shape{}, std::vector<double>{0});
zero_node = make_broadcast_node(zero_node, data->get_shape()); zero_node = make_broadcast_node(zero_node, data->get_shape());
...@@ -64,7 +69,9 @@ namespace ngraph ...@@ -64,7 +69,9 @@ namespace ngraph
alpha_node * data + beta_node))}; alpha_node * data + beta_node))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,9 +25,14 @@ namespace ngraph ...@@ -25,9 +25,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector hard_sigmoid(const Node& node); NodeVector hard_sigmoid(const Node& node);
} // namespace op
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -26,8 +26,15 @@ namespace ngraph ...@@ -26,8 +26,15 @@ namespace ngraph
{ {
namespace op namespace op
{ {
inline NodeVector identity(const Node& node) { return {node.get_ng_inputs().at(0)}; } namespace set_1
} // namespace op {
inline NodeVector identity(const Node& node)
{
return {node.get_ng_inputs().at(0)};
}
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -37,6 +37,8 @@ namespace ngraph ...@@ -37,6 +37,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector leaky_relu(const Node& node) NodeVector leaky_relu(const Node& node)
{ {
...@@ -46,13 +48,16 @@ namespace ngraph ...@@ -46,13 +48,16 @@ namespace ngraph
ASSERT_VALID_ARGUMENT(node, ((alpha >= 0) && (alpha <= 1))) ASSERT_VALID_ARGUMENT(node, ((alpha >= 0) && (alpha <= 1)))
<< " alpha value should be in range (0,1)"; << " alpha value should be in range (0,1)";
std::shared_ptr<ngraph::Node> alpha_node = std::make_shared<ngraph::op::Constant>( std::shared_ptr<ngraph::Node> alpha_node =
std::make_shared<ngraph::op::Constant>(
data->get_element_type(), Shape{}, std::vector<double>{alpha}); data->get_element_type(), Shape{}, std::vector<double>{alpha});
alpha_node = make_broadcast_node(alpha_node, data->get_shape()); alpha_node = make_broadcast_node(alpha_node, data->get_shape());
return {std::make_shared<ngraph::op::Maximum>(data * alpha_node, data)}; return {std::make_shared<ngraph::op::Maximum>(data * alpha_node, data)};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,9 +25,14 @@ namespace ngraph ...@@ -25,9 +25,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector leaky_relu(const Node& node); NodeVector leaky_relu(const Node& node);
} // namespace op
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -27,6 +27,8 @@ namespace ngraph ...@@ -27,6 +27,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector less(const Node& node) inline NodeVector less(const Node& node)
{ {
...@@ -35,7 +37,9 @@ namespace ngraph ...@@ -35,7 +37,9 @@ namespace ngraph
return {std::make_shared<ngraph::op::Less>(ng_inputs.at(0), ng_inputs.at(1))}; return {std::make_shared<ngraph::op::Less>(ng_inputs.at(0), ng_inputs.at(1))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -28,13 +28,17 @@ namespace ngraph ...@@ -28,13 +28,17 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector log(const Node& node) inline NodeVector log(const Node& node)
{ {
return {std::make_shared<ngraph::op::Log>(node.get_ng_inputs().at(0))}; return {std::make_shared<ngraph::op::Log>(node.get_ng_inputs().at(0))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -30,13 +30,17 @@ namespace ngraph ...@@ -30,13 +30,17 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector log_softmax(const Node& node) inline NodeVector log_softmax(const Node& node)
{ {
return {std::make_shared<ngraph::op::Log>(softmax(node).at(0))}; return {std::make_shared<ngraph::op::Log>(softmax(node).at(0))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -26,6 +26,8 @@ namespace ngraph ...@@ -26,6 +26,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector lrn(const Node& node) NodeVector lrn(const Node& node)
{ {
...@@ -38,7 +40,9 @@ namespace ngraph ...@@ -38,7 +40,9 @@ namespace ngraph
return {std::make_shared<ngraph::op::LRN>(data, alpha, beta, bias, size)}; return {std::make_shared<ngraph::op::LRN>(data, alpha, beta, bias, size)};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,9 +25,13 @@ namespace ngraph ...@@ -25,9 +25,13 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector lrn(const Node& node); NodeVector lrn(const Node& node);
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -26,6 +26,8 @@ namespace ngraph ...@@ -26,6 +26,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector matmul(const Node& node) inline NodeVector matmul(const Node& node)
{ {
...@@ -33,7 +35,9 @@ namespace ngraph ...@@ -33,7 +35,9 @@ namespace ngraph
return {std::make_shared<ngraph::op::Dot>(ng_inputs.at(0), ng_inputs.at(1))}; return {std::make_shared<ngraph::op::Dot>(ng_inputs.at(0), ng_inputs.at(1))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -27,13 +27,17 @@ namespace ngraph ...@@ -27,13 +27,17 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector max(const Node& node) inline NodeVector max(const Node& node)
{ {
return variadic::make_ng_variadic_op<ngraph::op::Maximum>(node); return variadic::make_ng_variadic_op<ngraph::op::Maximum>(node);
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,13 +25,17 @@ namespace ngraph ...@@ -25,13 +25,17 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector max_pool(const Node& node) NodeVector max_pool(const Node& node)
{ {
return convpool::make_ng_pool<ngraph::op::MaxPool>(node); return convpool::make_ng_pool<ngraph::op::MaxPool>(node);
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,6 +25,8 @@ namespace ngraph ...@@ -25,6 +25,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
/** /**
* @brief Convert ONNX MaxPool operation to an nGraph node. * @brief Convert ONNX MaxPool operation to an nGraph node.
...@@ -36,7 +38,9 @@ namespace ngraph ...@@ -36,7 +38,9 @@ namespace ngraph
*/ */
NodeVector max_pool(const Node& node); NodeVector max_pool(const Node& node);
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -26,6 +26,8 @@ namespace ngraph ...@@ -26,6 +26,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector mean(const Node& node) NodeVector mean(const Node& node)
{ {
...@@ -41,7 +43,9 @@ namespace ngraph ...@@ -41,7 +43,9 @@ namespace ngraph
return {sum / count}; return {sum / count};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,10 +25,14 @@ namespace ngraph ...@@ -25,10 +25,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector mean(const Node& node); NodeVector mean(const Node& node);
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -27,13 +27,17 @@ namespace ngraph ...@@ -27,13 +27,17 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector min(const Node& node) inline NodeVector min(const Node& node)
{ {
return variadic::make_ng_variadic_op<ngraph::op::Minimum>(node); return variadic::make_ng_variadic_op<ngraph::op::Minimum>(node);
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -27,15 +27,20 @@ namespace ngraph ...@@ -27,15 +27,20 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector mul(const Node& node) inline NodeVector mul(const Node& node)
{ {
NodeVector ng_inputs{ NodeVector ng_inputs{
numpy_style_broadcast_for_binary_operation(node.get_ng_inputs())}; numpy_style_broadcast_for_binary_operation(node.get_ng_inputs())};
return {std::make_shared<ngraph::op::Multiply>(ng_inputs.at(0), ng_inputs.at(1))}; return {
std::make_shared<ngraph::op::Multiply>(ng_inputs.at(0), ng_inputs.at(1))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -26,9 +26,13 @@ namespace ngraph ...@@ -26,9 +26,13 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector neg(const Node& node) { return {-node.get_ng_inputs().at(0)}; } inline NodeVector neg(const Node& node) { return {-node.get_ng_inputs().at(0)}; }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -27,13 +27,17 @@ namespace ngraph ...@@ -27,13 +27,17 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector logical_not(const Node& node) inline NodeVector logical_not(const Node& node)
{ {
return {std::make_shared<ngraph::op::Not>(node.get_ng_inputs().at(0))}; return {std::make_shared<ngraph::op::Not>(node.get_ng_inputs().at(0))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -27,6 +27,8 @@ namespace ngraph ...@@ -27,6 +27,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector logical_or(const Node& node) inline NodeVector logical_or(const Node& node)
{ {
...@@ -35,7 +37,9 @@ namespace ngraph ...@@ -35,7 +37,9 @@ namespace ngraph
return {std::make_shared<ngraph::op::Or>(ng_inputs.at(0), ng_inputs.at(1))}; return {std::make_shared<ngraph::op::Or>(ng_inputs.at(0), ng_inputs.at(1))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -27,6 +27,8 @@ namespace ngraph ...@@ -27,6 +27,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector pow(const Node& node) inline NodeVector pow(const Node& node)
{ {
...@@ -35,7 +37,9 @@ namespace ngraph ...@@ -35,7 +37,9 @@ namespace ngraph
return {std::make_shared<ngraph::op::Power>(ng_inputs.at(0), ng_inputs.at(1))}; return {std::make_shared<ngraph::op::Power>(ng_inputs.at(0), ng_inputs.at(1))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -36,6 +36,8 @@ namespace ngraph ...@@ -36,6 +36,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector prelu(const Node& node) NodeVector prelu(const Node& node)
{ {
...@@ -47,8 +49,8 @@ namespace ngraph ...@@ -47,8 +49,8 @@ namespace ngraph
if ((slope_shape.size() == 1) && (slope_shape.at(0) != 1)) if ((slope_shape.size() == 1) && (slope_shape.at(0) != 1))
{ {
auto it = auto it = std::find(
std::find(std::begin(data_shape), std::end(data_shape), slope_shape.at(0)); std::begin(data_shape), std::end(data_shape), slope_shape.at(0));
auto index = std::distance(std::begin(data_shape), it); auto index = std::distance(std::begin(data_shape), it);
slope = make_broadcast_node(slope, data->get_shape(), index); slope = make_broadcast_node(slope, data->get_shape(), index);
} }
...@@ -61,7 +63,9 @@ namespace ngraph ...@@ -61,7 +63,9 @@ namespace ngraph
return {std::make_shared<ngraph::op::Maximum>(data * slope, data)}; return {std::make_shared<ngraph::op::Maximum>(data * slope, data)};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,9 +25,14 @@ namespace ngraph ...@@ -25,9 +25,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector prelu(const Node& node); NodeVector prelu(const Node& node);
} // namespace op
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -30,6 +30,8 @@ namespace ngraph ...@@ -30,6 +30,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector reciprocal(const Node& node) NodeVector reciprocal(const Node& node)
{ {
...@@ -42,7 +44,9 @@ namespace ngraph ...@@ -42,7 +44,9 @@ namespace ngraph
return {one_node / data}; return {one_node / data};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,9 +25,14 @@ namespace ngraph ...@@ -25,9 +25,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector reciprocal(const Node& node); NodeVector reciprocal(const Node& node);
} // namespace op
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -31,6 +31,8 @@ namespace ngraph ...@@ -31,6 +31,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector reduce_mean(const Node& node) NodeVector reduce_mean(const Node& node)
{ {
...@@ -55,6 +57,10 @@ namespace ngraph ...@@ -55,6 +57,10 @@ namespace ngraph
return {std::make_shared<ngraph::op::Divide>(sum_node, broadcasted_const_node)}; return {std::make_shared<ngraph::op::Divide>(sum_node, broadcasted_const_node)};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
} // namespace ngraph } // namespace ngraph
...@@ -38,6 +38,8 @@ namespace ngraph ...@@ -38,6 +38,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
/// \brief Compute the log sum of the input tensor's elements along the provided axes. /// \brief Compute the log sum of the input tensor's elements along the provided axes.
/// ///
...@@ -71,7 +73,8 @@ namespace ngraph ...@@ -71,7 +73,8 @@ namespace ngraph
inline NodeVector reduce_log_sum_exp(const Node& node) inline NodeVector reduce_log_sum_exp(const Node& node)
{ {
auto exp_node = std::make_shared<ngraph::op::Exp>(node.get_ng_inputs().at(0)); auto exp_node = std::make_shared<ngraph::op::Exp>(node.get_ng_inputs().at(0));
auto sum_node = reduction::make_ng_reduction_op<ngraph::op::Sum>(node, exp_node); auto sum_node =
reduction::make_ng_reduction_op<ngraph::op::Sum>(node, exp_node);
return {std::make_shared<ngraph::op::Log>(sum_node)}; return {std::make_shared<ngraph::op::Log>(sum_node)};
} }
...@@ -108,7 +111,8 @@ namespace ngraph ...@@ -108,7 +111,8 @@ namespace ngraph
NodeVector ng_inputs{node.get_ng_inputs()}; NodeVector ng_inputs{node.get_ng_inputs()};
auto square_node = auto square_node =
std::make_shared<ngraph::op::Multiply>(ng_inputs.at(0), ng_inputs.at(0)); std::make_shared<ngraph::op::Multiply>(ng_inputs.at(0), ng_inputs.at(0));
auto sum_node = reduction::make_ng_reduction_op<ngraph::op::Sum>(node, square_node); auto sum_node =
reduction::make_ng_reduction_op<ngraph::op::Sum>(node, square_node);
return {std::make_shared<ngraph::op::Sqrt>(sum_node)}; return {std::make_shared<ngraph::op::Sqrt>(sum_node)};
} }
...@@ -212,6 +216,10 @@ namespace ngraph ...@@ -212,6 +216,10 @@ namespace ngraph
return {reduction::make_ng_reduction_op<ngraph::op::Sum>(node, square_node)}; return {reduction::make_ng_reduction_op<ngraph::op::Sum>(node, square_node)};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
} // namespace ngraph } // namespace ngraph
...@@ -26,6 +26,8 @@ namespace ngraph ...@@ -26,6 +26,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector relu(const Node& node) inline NodeVector relu(const Node& node)
{ {
...@@ -33,7 +35,9 @@ namespace ngraph ...@@ -33,7 +35,9 @@ namespace ngraph
return {std::make_shared<ngraph::op::Relu>(ng_inputs.at(0))}; return {std::make_shared<ngraph::op::Relu>(ng_inputs.at(0))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -32,6 +32,8 @@ namespace ngraph ...@@ -32,6 +32,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector reshape(const Node& node) NodeVector reshape(const Node& node)
{ {
...@@ -39,7 +41,8 @@ namespace ngraph ...@@ -39,7 +41,8 @@ namespace ngraph
auto data = ng_inputs.at(0); auto data = ng_inputs.at(0);
auto data_shape = data->get_shape(); auto data_shape = data->get_shape();
auto output_shape = node.get_attribute_value<std::vector<std::size_t>>("shape", {}); auto output_shape =
node.get_attribute_value<std::vector<std::size_t>>("shape", {});
// If no shape argument (opset >= 5) and there is second input. // If no shape argument (opset >= 5) and there is second input.
if (output_shape.empty() && ng_inputs.size() == 2) if (output_shape.empty() && ng_inputs.size() == 2)
...@@ -58,14 +61,17 @@ namespace ngraph ...@@ -58,14 +61,17 @@ namespace ngraph
return {data}; return {data};
} }
output_shape = reshape::infer_dimensions(node.get_name(), data_shape, output_shape); output_shape =
reshape::infer_dimensions(node.get_name(), data_shape, output_shape);
return {std::make_shared<ngraph::op::Reshape>( return {std::make_shared<ngraph::op::Reshape>(
data, data,
reshape::get_default_axis_vector(data_shape.size()), reshape::get_default_axis_vector(data_shape.size()),
Shape{output_shape})}; Shape{output_shape})};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,6 +25,8 @@ namespace ngraph ...@@ -25,6 +25,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
/// ///
/// \brief Reshape the input tensor similar to numpy.reshape. /// \brief Reshape the input tensor similar to numpy.reshape.
...@@ -35,7 +37,9 @@ namespace ngraph ...@@ -35,7 +37,9 @@ namespace ngraph
/// ///
NodeVector reshape(const Node& node); NodeVector reshape(const Node& node);
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -40,33 +40,42 @@ namespace ngraph ...@@ -40,33 +40,42 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector selu(const Node& node) NodeVector selu(const Node& node)
{ {
auto data = node.get_ng_inputs().at(0); auto data = node.get_ng_inputs().at(0);
double alpha = node.get_attribute_value<double>("alpha", 1.67326319217681884765625); double alpha =
double gamma = node.get_attribute_value<double>("gamma", 1.05070102214813232421875); node.get_attribute_value<double>("alpha", 1.67326319217681884765625);
double gamma =
node.get_attribute_value<double>("gamma", 1.05070102214813232421875);
std::shared_ptr<ngraph::Node> alpha_node = std::make_shared<ngraph::op::Constant>( std::shared_ptr<ngraph::Node> alpha_node =
std::make_shared<ngraph::op::Constant>(
data->get_element_type(), ngraph::Shape{}, std::vector<double>{alpha}); data->get_element_type(), ngraph::Shape{}, std::vector<double>{alpha});
alpha_node = make_broadcast_node(alpha_node, data->get_shape()); alpha_node = make_broadcast_node(alpha_node, data->get_shape());
std::shared_ptr<ngraph::Node> gamma_node = std::make_shared<ngraph::op::Constant>( std::shared_ptr<ngraph::Node> gamma_node =
std::make_shared<ngraph::op::Constant>(
data->get_element_type(), ngraph::Shape{}, std::vector<double>{gamma}); data->get_element_type(), ngraph::Shape{}, std::vector<double>{gamma});
gamma_node = make_broadcast_node(gamma_node, data->get_shape()); gamma_node = make_broadcast_node(gamma_node, data->get_shape());
std::shared_ptr<ngraph::Node> zero_node = std::make_shared<ngraph::op::Constant>( std::shared_ptr<ngraph::Node> zero_node =
std::make_shared<ngraph::op::Constant>(
data->get_element_type(), ngraph::Shape{}, std::vector<double>{0}); data->get_element_type(), ngraph::Shape{}, std::vector<double>{0});
zero_node = make_broadcast_node(zero_node, data->get_shape()); zero_node = make_broadcast_node(zero_node, data->get_shape());
return {gamma_node * return {gamma_node * (std::make_shared<ngraph::op::Maximum>(data, zero_node) +
(std::make_shared<ngraph::op::Maximum>(data, zero_node) +
alpha_node * std::make_shared<ngraph::op::Exp>( alpha_node * std::make_shared<ngraph::op::Exp>(
std::make_shared<ngraph::op::Minimum>(data, zero_node)) - std::make_shared<ngraph::op::Minimum>(
data, zero_node)) -
alpha_node)}; alpha_node)};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,9 +25,14 @@ namespace ngraph ...@@ -25,9 +25,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector selu(const Node& node); NodeVector selu(const Node& node);
} // namespace op
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -29,6 +29,8 @@ namespace ngraph ...@@ -29,6 +29,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector shape(const Node& node) NodeVector shape(const Node& node)
{ {
...@@ -39,7 +41,9 @@ namespace ngraph ...@@ -39,7 +41,9 @@ namespace ngraph
ngraph::element::i64, Shape{data_shape.size()}, data_shape)}; ngraph::element::i64, Shape{data_shape.size()}, data_shape)};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,9 +25,14 @@ namespace ngraph ...@@ -25,9 +25,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector shape(const Node& node); NodeVector shape(const Node& node);
} // namespace op
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -28,13 +28,17 @@ namespace ngraph ...@@ -28,13 +28,17 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector sigmoid(const Node& node) inline NodeVector sigmoid(const Node& node)
{ {
return {std::make_shared<ngraph::op::Sigmoid>(node.get_ng_inputs().at(0))}; return {std::make_shared<ngraph::op::Sigmoid>(node.get_ng_inputs().at(0))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -34,6 +34,8 @@ namespace ngraph ...@@ -34,6 +34,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector slice(const Node& node) NodeVector slice(const Node& node)
{ {
...@@ -54,13 +56,16 @@ namespace ngraph ...@@ -54,13 +56,16 @@ namespace ngraph
size_t axis = axes.at(idx); size_t axis = axes.at(idx);
lower_bounds.at(axis) = lower_bounds.at(axis) =
get_valid_array_idx(starts.at(idx), data_shape.at(axis)); get_valid_array_idx(starts.at(idx), data_shape.at(axis));
upper_bounds.at(axis) = get_valid_array_idx(ends.at(idx), data_shape.at(axis)); upper_bounds.at(axis) =
get_valid_array_idx(ends.at(idx), data_shape.at(axis));
} }
return {std::make_shared<ngraph::op::Slice>(data, lower_bounds, upper_bounds)}; return {std::make_shared<ngraph::op::Slice>(data, lower_bounds, upper_bounds)};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,9 +25,14 @@ namespace ngraph ...@@ -25,9 +25,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector slice(const Node& node); NodeVector slice(const Node& node);
} // namespace op
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -26,6 +26,8 @@ namespace ngraph ...@@ -26,6 +26,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector softmax(const Node& node) NodeVector softmax(const Node& node)
{ {
...@@ -50,7 +52,9 @@ namespace ngraph ...@@ -50,7 +52,9 @@ namespace ngraph
return {std::make_shared<ngraph::op::Softmax>(data, axes)}; return {std::make_shared<ngraph::op::Softmax>(data, axes)};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,9 +25,14 @@ namespace ngraph ...@@ -25,9 +25,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector softmax(const Node& node); NodeVector softmax(const Node& node);
} // namespace op
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -32,6 +32,8 @@ namespace ngraph ...@@ -32,6 +32,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector softplus(const Node& node) NodeVector softplus(const Node& node)
{ {
...@@ -41,11 +43,13 @@ namespace ngraph ...@@ -41,11 +43,13 @@ namespace ngraph
data->get_element_type(), Shape{}, std::vector<double>{1}); data->get_element_type(), Shape{}, std::vector<double>{1});
one_node = make_broadcast_node(one_node, data->get_shape()); one_node = make_broadcast_node(one_node, data->get_shape());
return {std::make_shared<ngraph::op::Log>(std::make_shared<ngraph::op::Exp>(data) + return {std::make_shared<ngraph::op::Log>(
one_node)}; std::make_shared<ngraph::op::Exp>(data) + one_node)};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,9 +25,14 @@ namespace ngraph ...@@ -25,9 +25,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector softplus(const Node& node); NodeVector softplus(const Node& node);
} // namespace op
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -32,6 +32,8 @@ namespace ngraph ...@@ -32,6 +32,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector softsign(const Node& node) NodeVector softsign(const Node& node)
{ {
...@@ -44,7 +46,9 @@ namespace ngraph ...@@ -44,7 +46,9 @@ namespace ngraph
return {data / (std::make_shared<ngraph::op::Abs>(data) + one_node)}; return {data / (std::make_shared<ngraph::op::Abs>(data) + one_node)};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,9 +25,14 @@ namespace ngraph ...@@ -25,9 +25,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector softsign(const Node& node); NodeVector softsign(const Node& node);
} // namespace op
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -79,6 +79,8 @@ namespace ngraph ...@@ -79,6 +79,8 @@ namespace ngraph
} // namespace error } // namespace error
namespace op namespace op
{
namespace set_1
{ {
namespace detail namespace detail
{ {
...@@ -105,7 +107,8 @@ namespace ngraph ...@@ -105,7 +107,8 @@ namespace ngraph
upper_bounds.at(axis) = upper_bounds.at(axis) =
get_valid_array_index(ends.at(index), node->get_shape().at(axis)); get_valid_array_index(ends.at(index), node->get_shape().at(axis));
} }
return std::make_shared<ngraph::op::Slice>(node, lower_bounds, upper_bounds); return std::make_shared<ngraph::op::Slice>(
node, lower_bounds, upper_bounds);
} }
} // namespace detail } // namespace detail
...@@ -145,14 +148,16 @@ namespace ngraph ...@@ -145,14 +148,16 @@ namespace ngraph
for (const auto& length_part : length_parts) for (const auto& length_part : length_parts)
{ {
std::size_t end_index{start_index + length_part}; std::size_t end_index{start_index + length_part};
outputs.push_back( outputs.push_back(detail::make_ng_slice(
detail::make_ng_slice(input, {axis_to_split}, {start_index}, {end_index})); input, {axis_to_split}, {start_index}, {end_index}));
start_index = end_index; start_index = end_index;
} }
return outputs; return outputs;
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,9 +25,14 @@ namespace ngraph ...@@ -25,9 +25,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector split(const Node& node); NodeVector split(const Node& node);
} // namespace op
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -28,13 +28,17 @@ namespace ngraph ...@@ -28,13 +28,17 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector sqrt(const Node& node) inline NodeVector sqrt(const Node& node)
{ {
return {std::make_shared<ngraph::op::Sqrt>(node.get_ng_inputs().at(0))}; return {std::make_shared<ngraph::op::Sqrt>(node.get_ng_inputs().at(0))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -29,6 +29,8 @@ namespace ngraph ...@@ -29,6 +29,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector squeeze(const Node& node) NodeVector squeeze(const Node& node)
{ {
...@@ -60,7 +62,9 @@ namespace ngraph ...@@ -60,7 +62,9 @@ namespace ngraph
return {std::make_shared<ngraph::op::Reshape>(data, input_order, data_shape)}; return {std::make_shared<ngraph::op::Reshape>(data, input_order, data_shape)};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,9 +25,14 @@ namespace ngraph ...@@ -25,9 +25,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector squeeze(const Node& node); NodeVector squeeze(const Node& node);
} // namespace op
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -27,15 +27,20 @@ namespace ngraph ...@@ -27,15 +27,20 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector sub(const Node& node) inline NodeVector sub(const Node& node)
{ {
NodeVector ng_inputs{ NodeVector ng_inputs{
numpy_style_broadcast_for_binary_operation(node.get_ng_inputs())}; numpy_style_broadcast_for_binary_operation(node.get_ng_inputs())};
return {std::make_shared<ngraph::op::Subtract>(ng_inputs.at(0), ng_inputs.at(1))}; return {
std::make_shared<ngraph::op::Subtract>(ng_inputs.at(0), ng_inputs.at(1))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -27,13 +27,17 @@ namespace ngraph ...@@ -27,13 +27,17 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector sum(const Node& node) inline NodeVector sum(const Node& node)
{ {
return variadic::make_ng_variadic_op<ngraph::op::Add>(node); return variadic::make_ng_variadic_op<ngraph::op::Add>(node);
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -28,13 +28,17 @@ namespace ngraph ...@@ -28,13 +28,17 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector tanh(const Node& node) inline NodeVector tanh(const Node& node)
{ {
return {std::make_shared<ngraph::op::Tanh>(node.get_ng_inputs().at(0))}; return {std::make_shared<ngraph::op::Tanh>(node.get_ng_inputs().at(0))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -35,13 +35,16 @@ namespace ngraph ...@@ -35,13 +35,16 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector thresholded_relu(const Node& node) NodeVector thresholded_relu(const Node& node)
{ {
auto data = node.get_ng_inputs().at(0); auto data = node.get_ng_inputs().at(0);
double alpha = node.get_attribute_value<double>("alpha", 1.0); double alpha = node.get_attribute_value<double>("alpha", 1.0);
std::shared_ptr<ngraph::Node> alpha_node = std::make_shared<ngraph::op::Constant>( std::shared_ptr<ngraph::Node> alpha_node =
std::make_shared<ngraph::op::Constant>(
data->get_element_type(), ngraph::Shape{}, std::vector<double>{alpha}); data->get_element_type(), ngraph::Shape{}, std::vector<double>{alpha});
alpha_node = make_broadcast_node(alpha_node, data->get_shape()); alpha_node = make_broadcast_node(alpha_node, data->get_shape());
...@@ -51,7 +54,9 @@ namespace ngraph ...@@ -51,7 +54,9 @@ namespace ngraph
return {data * data_map}; return {data * data_map};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,9 +25,14 @@ namespace ngraph ...@@ -25,9 +25,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector thresholded_relu(const Node& node); NodeVector thresholded_relu(const Node& node);
} // namespace op
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -27,18 +27,23 @@ namespace ngraph ...@@ -27,18 +27,23 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector transpose(const Node& node) NodeVector transpose(const Node& node)
{ {
std::shared_ptr<ngraph::Node> data = node.get_ng_inputs().at(0); std::shared_ptr<ngraph::Node> data = node.get_ng_inputs().at(0);
auto permute_axes = node.get_attribute_value<std::vector<std::size_t>>("perm", {}); auto permute_axes =
node.get_attribute_value<std::vector<std::size_t>>("perm", {});
return {(permute_axes.empty()) ? reshape::transpose(data) return {(permute_axes.empty()) ? reshape::transpose(data)
: reshape::reorder_axes(data, permute_axes)}; : reshape::reorder_axes(data, permute_axes)};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,9 +25,14 @@ namespace ngraph ...@@ -25,9 +25,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector transpose(const Node& node); NodeVector transpose(const Node& node);
} // namespace op
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -27,6 +27,8 @@ namespace ngraph ...@@ -27,6 +27,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector unsqueeze(const Node& node) NodeVector unsqueeze(const Node& node)
{ {
...@@ -52,7 +54,9 @@ namespace ngraph ...@@ -52,7 +54,9 @@ namespace ngraph
return {std::make_shared<ngraph::op::Reshape>(data, input_order, data_shape)}; return {std::make_shared<ngraph::op::Reshape>(data, input_order, data_shape)};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -25,9 +25,14 @@ namespace ngraph ...@@ -25,9 +25,14 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
NodeVector unsqueeze(const Node& node); NodeVector unsqueeze(const Node& node);
} // namespace op
} // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
...@@ -29,6 +29,8 @@ namespace ngraph ...@@ -29,6 +29,8 @@ namespace ngraph
namespace onnx_import namespace onnx_import
{ {
namespace op namespace op
{
namespace set_1
{ {
inline NodeVector logical_xor(const Node& node) inline NodeVector logical_xor(const Node& node)
{ {
...@@ -43,7 +45,9 @@ namespace ngraph ...@@ -43,7 +45,9 @@ namespace ngraph
std::make_shared<ngraph::op::And>(not_left, right))}; std::make_shared<ngraph::op::And>(not_left, right))};
} }
} // namespace op } // namespace set_1
} //namespace op
} // namespace onnx_import } // namespace onnx_import
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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