Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
166fb921
Unverified
Commit
166fb921
authored
Oct 10, 2019
by
Nagy Mostafa
Committed by
GitHub
Oct 10, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into nmostafa/update_mlir
parents
285a24ae
27199cee
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
46 changed files
with
423 additions
and
205 deletions
+423
-205
layout.html
doc/sphinx/ngraph_theme/layout.html
+3
-3
ngversions.html
doc/sphinx/ngraph_theme/ngversions.html
+4
-5
theme.css
doc/sphinx/ngraph_theme/static/css/theme.css
+1
-0
index.rst
doc/sphinx/source/backends/index.rst
+8
-1
index.rst
doc/sphinx/source/core/constructing-graphs/index.rst
+5
-2
index.rst
doc/sphinx/source/core/fusion/index.rst
+1
-1
overview.rst
doc/sphinx/source/core/fusion/overview.rst
+3
-1
overview.rst
doc/sphinx/source/core/overview.rst
+7
-6
passes-that-use-matcher.rst
doc/sphinx/source/core/passes/passes-that-use-matcher.rst
+1
-1
passes.rst
doc/sphinx/source/core/passes/passes.rst
+6
-5
fw_overview.rst
doc/sphinx/source/frameworks/fw_overview.rst
+52
-0
index.rst
doc/sphinx/source/frameworks/index.rst
+4
-6
onnx_integ.rst
doc/sphinx/source/frameworks/onnx_integ.rst
+3
-3
other.rst
doc/sphinx/source/frameworks/other.rst
+4
-4
overview.rst
doc/sphinx/source/frameworks/overview.rst
+34
-33
paddle_integ.rst
doc/sphinx/source/frameworks/paddle_integ.rst
+10
-12
quickstart.rst
doc/sphinx/source/frameworks/quickstart.rst
+17
-14
tensorflow_connect.rst
doc/sphinx/source/frameworks/tensorflow_connect.rst
+2
-2
list.rst
doc/sphinx/source/frameworks/validated/list.rst
+1
-1
ExecutionInterfaceRunGraphs.png
doc/sphinx/source/graphics/ExecutionInterfaceRunGraphs.png
+0
-0
PaddlePaddleDir.svg
doc/sphinx/source/graphics/PaddlePaddleDir.svg
+0
-0
execution-interface.png
doc/sphinx/source/graphics/execution-interface.png
+0
-0
nGraphCompilerstack.png
doc/sphinx/source/graphics/nGraphCompilerstack.png
+0
-0
index.rst
doc/sphinx/source/index.rst
+14
-20
index.rst
doc/sphinx/source/ops/index.rst
+19
-4
max.rst
doc/sphinx/source/ops/max.rst
+1
-1
min.rst
doc/sphinx/source/ops/min.rst
+1
-1
contribution-guide.rst
doc/sphinx/source/project/contribution-guide.rst
+1
-1
release-notes.rst
doc/sphinx/source/project/release-notes.rst
+24
-18
sitemap.rst
doc/sphinx/source/sitemap.rst
+0
-12
lowerer.cpp
src/contrib/mlir/compiler/lowerer.cpp
+7
-3
node.hpp
src/ngraph/node.hpp
+11
-0
avg_pool.cpp
src/ngraph/op/avg_pool.cpp
+2
-2
avg_pool.hpp
src/ngraph/op/avg_pool.hpp
+1
-1
constant.hpp
src/ngraph/op/constant.hpp
+2
-2
op.hpp
src/ngraph/op/op.hpp
+0
-14
reverse.cpp
src/ngraph/op/reverse.cpp
+6
-6
reverse.hpp
src/ngraph/op/reverse.hpp
+5
-0
softmax.cpp
src/ngraph/op/softmax.cpp
+17
-8
softmax.hpp
src/ngraph/op/softmax.hpp
+4
-0
opset0_downgrade.cpp
src/ngraph/pass/opset0_downgrade.cpp
+34
-0
cpu_emitter.hpp
src/ngraph/runtime/cpu/cpu_emitter.hpp
+1
-1
gather.hpp
src/ngraph/runtime/cpu/kernel/gather.hpp
+2
-3
serializer.cpp
src/ngraph/serializer.cpp
+0
-0
core_ops.mlir
test/mlir/affine_conversion/core_ops.mlir
+27
-6
reverse_opset_pass.cpp
test/opset_pass/reverse_opset_pass.cpp
+78
-2
No files found.
doc/sphinx/ngraph_theme/layout.html
View file @
166fb921
...
...
@@ -84,9 +84,9 @@
<body>
<div
id=
"menu-float"
class=
"menu-float"
>
<a
href=
"https://www.ngraph.ai"
>
Home
</a>
<a
href=
"https://www.youtube.com/embed/C9S0nmNS8bQ"
>
Video
</a>
<a
href=
"https://www.ngraph.ai/ecosystem"
>
Ecosystem
</a>
<a
href=
"https://www.ngraph.ai"
target=
"_blank"
>
Home
</a>
<a
href=
"https://www.youtube.com/embed/C9S0nmNS8bQ"
target=
"_blank"
>
Video
</a>
<a
href=
"https://www.ngraph.ai/ecosystem"
target=
"_blank"
>
Ecosystem
</a>
<a
href=
"https://ngraph.nervanasys.com/docs/latest"
>
Docs
</a>
<a
href=
"https://www.ngraph.ai/tutorials"
>
Tutorials
</a>
<a
href=
"https://ngraph.slack.com/"
><img
src=
"https://cdn.brandfolder.io/5H442O3W/as/pl546j-7le8zk-5h439l/Slack_Mark_Monochrome_White.png?width=35&height=35"
></a>
...
...
doc/sphinx/ngraph_theme/ngversions.html
View file @
166fb921
...
...
@@ -10,13 +10,12 @@
<dd>
<!-- Until our https://docs.ngraph.ai/ publishing is set up, we link to GitHub -->
<ul>
<!-- <li><a href="https://github.com/NervanaSystems/ngraph/releases/tag/v0.26">0.26</a></li> -->
<li><a
href=
"https://github.com/NervanaSystems/ngraph/releases/tag/v0.26.0
"
>
0.26.0
</a></li>
<li><a
href=
"https://github.com/NervanaSystems/ngraph/releases/tag/v0.2
6.0
"
>
0.25.1
</a></li>
<li><a
href=
"https://github.com/NervanaSystems/ngraph/releases/tag/v0.26.0
-rc.3"
>
Prerelease 0.26
</a></li>
<li><a
href=
"https://github.com/NervanaSystems/ngraph/releases/tag/v0.2
5.1-rc.4
"
>
0.25.1
</a></li>
<li><a
href=
"https://github.com/NervanaSystems/ngraph/releases/tag/v0.25.0"
>
0.25.0
</a></li>
<li><a
href=
"https://github.com/NervanaSystems/ngraph/releases/tag/v0.24.0"
>
0.24.0
</a></li>
<li><a
href=
"https://github.com/NervanaSystems/ngraph/releases/tag/v0.23.0"
>
0.23.0
</a></li>
<li><a
href=
"https://github.com/NervanaSystems/ngraph/releases/tag/v0.22.0"
>
0.22.0
</a></li>
<li><a
href=
"https://github.com/NervanaSystems/ngraph/releases/tag/v0.21.0"
>
0.21.0
</a></li>
<li><a
href=
"https://github.com/NervanaSystems/ngraph/releases/tag/v0.22.2-rc.0"
>
0.22.2
</a></li>
<li><a
href=
"https://github.com/NervanaSystems/ngraph/releases/tag/v0.22.1"
>
0.22.1
</a></li>
</ul></dd>
</dl>
<dl>
...
...
doc/sphinx/ngraph_theme/static/css/theme.css
View file @
166fb921
...
...
@@ -1645,6 +1645,7 @@ h1 {
h2
{
font-size
:
133%
;
text-decoration
:
underline
4px
dotted
#D3D3D3
;
margin-top
:
-2px
;
}
h2
,
.rst-content
.toctree-wrapper
p
.caption
{
...
...
doc/sphinx/source/backends/index.rst
View file @
166fb921
...
...
@@ -51,7 +51,7 @@ How to use?
#. A single iteration of the executable is executed by calling the ``call``
method on the ``Executable`` object.
.. figure:: ../graphics/
execution-interface
.png
.. figure:: ../graphics/
ExecutionInterfaceRunGraphs
.png
:width: 650px
The execution interface for nGraph
...
...
@@ -69,6 +69,13 @@ interface; each backend implements the following five functions:
* And, finally, the ``call()`` method is used to invoke an nGraph function
against a particular set of tensors.
How to display ngraph-related passes executed during runtime?
-------------------------------------------------------------
One easy way to get info about passes is to set the environment variable
:envvar:`NGRAPH_PROFILE_PASS_ENABLE=1`. With this set, the pass manager
will dump the name and execution time of each pass.
.. _ngraph_bridge:
...
...
doc/sphinx/source/core/constructing-graphs/index.rst
View file @
166fb921
..
howto/index:
..
core/constructing-graphs/index.rst:
Constructing graphs
.. _constructing_graphs:
Constructing Graphs
===================
.. toctree::
...
...
doc/sphinx/source/core/fusion/index.rst
View file @
166fb921
.. fusion/index.rst:
Pattern
m
atcher
Pattern
M
atcher
###############
.. toctree::
...
...
doc/sphinx/source/core/fusion/overview.rst
View file @
166fb921
.. fusion/overview.rst
.. core/fusion/overview.rst
.. _fusion_overview:
Overview: Optimize graphs with nGraph Compiler fusions
-------------------------------------------------------
...
...
doc/sphinx/source/core/overview.rst
View file @
166fb921
.. core/overview.rst:
Overview
========
Basic concepts
========
======
.. figure:: ../graphics/
whole-
stack.png
.. figure:: ../graphics/
nGraphCompiler
stack.png
:alt: The whole stack
The whole nGraph Compiler stack
...
...
@@ -13,7 +13,7 @@ The nGraph Compiler stack consists of bridges, core, and backends. We'll examine
each of these briefly to get started.
A framework bridge interfaces with the "frontend" Core API. A framework bridge
is a component that sits between a framework like TensorFlow or
MXNet
, and the
is a component that sits between a framework like TensorFlow or
PaddlePaddle
, and the
nGraph Core frontend API. A framework bridge does two things: first, it
translates a framework's operations into graphs in nGraph’s in-memory
:abbr:`Intermediary Representation (IR)`. Second, it executes the nGraph IR
...
...
@@ -24,8 +24,9 @@ are some common patterns: a fairly typical example for a graph-based framework
is illustrated here, and consists of basically two phases: a **clustering**
phase and a **translation** phase.
.. figure:: ../graphics/translation-flow-to-ng-fofx.png
:alt: The whole stack
.. figure:: ../graphics/overview-translation-flow.svg
:width: 725px
:alt: Translation flow to an nGraph function graph
Translation flow to an nGraph function
...
...
doc/sphinx/source/core/passes/passes-that-use-matcher.rst
View file @
166fb921
..
fusion
/passes-that-use-matcher.rst:
..
core/passes
/passes-that-use-matcher.rst:
Passes that use Matcher
...
...
doc/sphinx/source/core/passes/passes.rst
View file @
166fb921
.. core/passes:
.. core/passes
/passes.rst
:
Compiler passes
.. _core_compiler_passes:
Compiler Passes
===============
.. toctree::
...
...
@@ -11,9 +13,8 @@ Compiler passes
passes-that-use-matcher.rst
Overview
--------
Basic concepts
--------------
*Generic graph optimization passes*
...
...
doc/sphinx/source/frameworks/fw_overview.rst
0 → 100644
View file @
166fb921
:orphan:
.. frameworks/fw_overview:
.. _fw_overview:
Overview
========
A framework is "supported" with a framework :term:`bridge` that can be written or
cloned and used to connect to nGraph device backends while maintaining the
framework's programmatic or user interface. There is a bridge for the
`TensorFlow framework`_. We also have a :doc:`paddle_integ` bridge. Intel
previously contributed work to an MXNet bridge; however, support for this
bridge is no longer active.
`ONNX`_ on its own is not a framework; however, it can be used with nGraph's
:doc:`../python_api/index` to import and execute ONNX models.
.. figure:: ../graphics/overview-framework-bridges.svg
:width: 960px
:alt: Framework bridge to a graph construction
Framework bridge to nGraph
Once connected via the bridge, the framework can then run and train a deep
learning model with various workloads on various backends using nGraph Compiler
as an optimizing compiler available through the framework.
While a :abbr:`Deep Learning (DL)` :term:`framework` is ultimately meant for
end use by data scientists, or for deployment in cloud container environments,
nGraph Core ops and the nGraph C++ Library are designed for framework builders
themselves. We invite anyone working on new and novel frameworks or neural
network designs to explore our highly-modularized stack of components that
can be implemented or integrated in countless ways.
Please read this section if you are considering incorporating components from
the nGraph Compiler stack in your framework or neural network design. Contents
here are also useful if you are working on something built-from-scratch, or on
an existing framework that is less widely-supported than the popular frameworks
like TensorFlow and PyTorch.
.. figure:: ../graphics/overview-translation-flow.svg
:width: 725px
:alt: Translation flow to nGraph function graph
.. _TensorFlow framework: https://github.com/tensorflow/ngraph-bridge/README.md
.. _ONNX: http://onnx.ai/
.. _tune the workload to extract best performance: https://ai.intel.com/accelerating-deep-learning-training-inference-system-level-optimizations
.. _a few small: https://software.intel.com/en-us/articles/boosting-deep-learning-training-inference-performance-on-xeon-and-xeon-phi
doc/sphinx/source/frameworks/index.rst
View file @
166fb921
.. frameworks/index.rst
Working with Frameworks
=======================
.. include:: overview.rst
#######################
.. toctree::
:maxdepth: 1
getting_started.rst
overview.rst
quickstart.rst
onnx_integ.rst
paddle_integ.rst
tensorflow_connect.rst
generic_configs
.rst
other
.rst
doc/sphinx/source/frameworks/onnx_integ.rst
View file @
166fb921
.. frameworks/onnx_integ.rst:
ONNX
Support
============
ONNX
overview
============
=
nGraph is able to import and execute ONNX models. Models are converted to
nGraph's :abbr:`Intermediate Representation (IR)` and converted to ``Function``
...
...
@@ -78,7 +78,7 @@ data:
Find more information about nGraph and ONNX in the
`nGraph ONNX`_ GitHub
\*
repository.
`nGraph ONNX`_ GitHub repository.
.. _ngraph ONNX: https://github.com/NervanaSystems/ngraph-onnx
...
...
doc/sphinx/source/frameworks/
generic_configs
.rst
→
doc/sphinx/source/frameworks/
other
.rst
View file @
166fb921
.. frameworks/
generic_configs
.rst:
.. frameworks/
other
.rst:
.. _
generic_configs
:
.. _
fw_other
:
Integrating
new
frameworks
==========================
Integrating
other
frameworks
==========================
==
This section details some of the *configuration options* and some of the
*environment variables* that can be used to tune for optimal performance when
...
...
doc/sphinx/source/frameworks/overview.rst
View file @
166fb921
.. frameworks/overview.rst
.. _fw_overview:
Basic concepts
==============
Overview
========
.. figure:: ../graphics/overview-framework-bridges.svg
:width: 960px
:alt: Bridge to nGraph graph construction API
A framework is "supported" with a framework :term:`bridge` that can be written or
cloned and used to connect to nGraph device backends while maintaining the
framework's programmatic or user interface. A `bridge currently exists`_ for the
TensorFlow framework. We also have a bridge to do :doc:`paddle_integ`. Intel
previously contributed work to an MXNet bridge; however, support for this
bridge is no longer active.
A framework bridge connects to the nGraph graph construction API
`ONNX`_ on its own is not a framework; however, it can be used with nGraph's
:doc:`../python_api/index` to import and execute ONNX models.
To understand how a data science :term:`framework` (:doc:`TensorFlow <tensorflow_connect>`,
PyTorch, :doc:`paddle_integ`, and others) can unlock acceleration available in
the nGraph Compiler, it helps to familiarize yourself with some basic concepts.
.. figure:: ../graphics/overview-framework-bridges.svg
:width: 960px
:alt: JiT compiling of a computation
We use the term :term:`bridge` to describe code that connects to any nGraph
device backend(s) while maintaining the framework's programmatic or user
interface. We have a `bridge for the TensorFlow framework`_. We also have a
:doc:`paddle_integ` bridge. Intel previously :doc:`contributed work to an MXNet bridge <../project/extras/testing_latency>`;
however, support for the MXNet bridge is no longer active.
`ONNX`_ on its own is not a framework; it can be used with nGraph's
:doc:`../python_api/index` to import and execute ONNX models.
:abbr:`Just-in-Time (JiT)` Compiling for computation. nGraph `Core`
components are colored in blue.
Because it is framework agnostic (providing opportunities to optimize at the
graph level), nGraph can do the heavy lifting required by many popular
:doc:`workloads <validated/list>` without any additional effort of the framework user.
Optimizations that were previously available only after careful integration of
a kernel or hardware-specific library are exposed via the
:doc:`Core graph construction API <../core/constructing-graphs/index>`
Once connected via the bridge, the framework can then run and train a deep
learning model with various workloads on various backends using nGraph Compiler
as an optimizing compiler available through the framework.
The illustration above shows how this works.
While a :abbr:`Deep Learning (DL)` :term:`framework` is ultimately meant for
end use by data scientists, or for deployment in cloud container environments,
nGraph Core ops and the nGraph C++ Library are designed for framework builders
themselves. We invite anyone working on new and novel frameworks or neural
network designs to explore our highly-modularized stack of components that
can be implemented or integrated in countless ways.
While a :abbr:`Deep Learning (DL)` framework is ultimately meant for end-use by
data scientists, or for deployment in cloud container environments, nGraph's
:doc:`Core ops <../core/overview>` are designed for framework builders themselves.
We invite anyone working on new and novel frameworks or neural network designs
to explore our highly-modularized stack of components.
Please read this section if you are considering incorporating components from
the nGraph Compiler stack in your framework or neural network design. Contents
here are also useful if you are working on something built-from-scratch, or on
an existing framework that is less widely-supported than the popular frameworks
like TensorFlow and PyTorch.
Please read the :doc:`other` section for other framework-agnostic
configurations available to users of the nGraph Compiler stack.
.. figure:: ../graphics/overview-translation-flow.svg
:width: 725px
:alt: Translation flow to nGraph function graph
:alt: Translation flow to an nGraph function graph
.. _bridge
currently exists
: https://github.com/tensorflow/ngraph-bridge/README.md
.. _bridge
for the TensorFlow framework
: https://github.com/tensorflow/ngraph-bridge/README.md
.. _ONNX: http://onnx.ai/
.. _tune the workload to extract best performance: https://ai.intel.com/accelerating-deep-learning-training-inference-system-level-optimizations
.. _a few small: https://software.intel.com/en-us/articles/boosting-deep-learning-training-inference-performance-on-xeon-and-xeon-phi
\ No newline at end of file
doc/sphinx/source/frameworks/paddle_integ.rst
View file @
166fb921
.. frameworks/paddle_integ.rst:
PaddlePaddle
============
nGraph PaddlePaddle integration overview
----------------------------------------
PaddlePaddle integration
========================
PaddlePaddle is an open source deep learning framework developed by Baidu. It
aims to enable performant large-scale distributed computation for deep learning.
...
...
@@ -67,7 +64,7 @@ is organized in the following file structure:
.. _figure-paddle-dir:
.. figure:: ../graphics/
paddlepaddle_directory.pn
g
.. figure:: ../graphics/
PaddlePaddleDir.sv
g
:width: 555px
:alt:
...
...
@@ -135,8 +132,8 @@ and nGraph bridges are provided below:
are managed through a map.
- SetOutputNode: sets the constructed node to the map.
- Related code :
+
``Paddle/fluid/operators/ngraph/ngraph_bridge.h`` `link to ngraph_bridge header code`_
+
``Paddle/fluid/operators/ngraph/ngraph_bridge.cc`` `link to ngraph_bridge cpp code`_
-
``Paddle/fluid/operators/ngraph/ngraph_bridge.h`` `link to ngraph_bridge header code`_
-
``Paddle/fluid/operators/ngraph/ngraph_bridge.cc`` `link to ngraph_bridge cpp code`_
nGraph compilation control and trigger method
----------------------------------------------
...
...
@@ -149,8 +146,9 @@ nGraph compilation control and trigger method
#. **Trigger Control** -- ``FLAGS_use_ngraph`` triggers nGraph. If this option
is set to ``true``, nGraph will be triggered by the PaddlePaddle executor
to convert and execute the supported subgraph. `Examples are provided`_ under
``paddle/benchmark/fluid/ngraph``.
to convert and execute the supported subgraph. Demos are provided under
``paddle/benchmark/fluid/train/demo`` (link `train_demo`_) and ``paddle/benchmark/fluid/train/imdb_demo``
(link `imdb_demo`_)
.. _link to ngraph_engine_op header code: https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/fluid/operators/ngraph/ngraph_engine_op.h
...
...
@@ -160,5 +158,5 @@ nGraph compilation control and trigger method
.. _located in the ngraph ops: https://github.com/PaddlePaddle/Paddle/tree/develop/paddle/fluid/operators/ngraph/ops
.. _link to ngraph_bridge header code: https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/fluid/operators/ngraph/ngraph_bridge.h
.. _link to ngraph_bridge cpp code: https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/fluid/operators/ngraph/ngraph_bridge.cc
.. _
Examples are provided: https://github.com/PaddlePaddle/Paddle/tree/develop/benchmark/fluid
.. _
train_demo: https://github.com/PaddlePaddle/Paddle/tree/develop/paddle/fluid/train/demo
.. _imdb_demo: https://github.com/PaddlePaddle/Paddle/tree/develop/paddle/fluid/train/imdb_demo
doc/sphinx/source/frameworks/
getting_started
.rst
→
doc/sphinx/source/frameworks/
quickstart
.rst
View file @
166fb921
.. frameworks/
getting_started
.rst
.. frameworks/
quickstart
.rst
Getting Started
###############
.. _fw_quickstart:
Quick start
===========
No matter what your level of experience with :abbr:`Deep Learning (DL)` systems
may be, nGraph provides a path to start working with the DL stack. Let's begin
with the easiest and most straightforward options.
.. figure:: ../graphics/translation-flow-to-ng-fofx.png
:width: 725px
:alt: Translation flow to nGraph function graph
TensorFlow
----------
The easiest way to get started is to use the latest PyPI `ngraph-tensorflow-bridge`_,
which has instructions for Linux* systems, and tips for users of Mac OS X.
which has instructions for Linux
\
* systems, and tips for users of Mac OS X.
You can install TensorFlow
\* and nGraph to
a virtual environment; otherwise, the code
You can install TensorFlow
and nGraph in
a virtual environment; otherwise, the code
will install to a system location.
.. code-block:: console
...
...
@@ -45,15 +46,15 @@ Output will look something like:
More detail in the `ngraph_bridge examples`_ directory.
See also the `diagnostic tools`_.
ONNX
====
----
Another easy way to get started working with the :abbr:`DL (Deep Learning)`
stack is to try the examples available via `nGraph ONNX`_.
Installation
------------
To prepare your environment to use nGraph and ONNX, install the Python packages
for nGraph, ONNX and NumPy:
...
...
@@ -67,18 +68,18 @@ Now you can start exploring some of the :doc:`onnx_integ` examples.
See also nGraph's :doc:`../python_api/index`.
PlaidML
=======
-------
See the :ref:`ngraph_plaidml_backend` section on how to build the
nGraph-PlaidML.
Other integration paths
=======================
-----------------------
If you are considering incorporating components from the nGraph Compiler stack
in your framework or neural network design, another useful doc is the section
on :doc:`
generic-configs`
. Contents here are also useful if you are working on
on :doc:`
other`
. Contents here are also useful if you are working on
something built-from-scratch, or on an existing framework that is less
widely-supported than the popular frameworks like TensorFlow and PyTorch.
...
...
@@ -86,3 +87,4 @@ widely-supported than the popular frameworks like TensorFlow and PyTorch.
.. _ngraph-tensorflow-bridge: https://pypi.org/project/ngraph-tensorflow-bridge
.. _ngraph ONNX: https://github.com/NervanaSystems/ngraph-onnx
.. _ngraph_bridge examples: https://github.com/tensorflow/ngraph-bridge/blob/master/examples/README.md
.. _diagnostic tools: https://github.com/tensorflow/ngraph-bridge/blob/master/diagnostics/README.md
\ No newline at end of file
doc/sphinx/source/frameworks/tensorflow_connect.rst
View file @
166fb921
.. frameworks/tensorflow_connect.rst:
Connect TensorFlow\*
====================
nGraph Bridge for TensorFlow
====================
========
See the `README`_ on the `ngraph_bridge repo`_ for the many ways to connect
...
...
doc/sphinx/source/frameworks/validated/list.rst
View file @
166fb921
...
...
@@ -3,7 +3,7 @@
.. _validated:
Validated
w
orkloads
Validated
W
orkloads
###################
We have validated performance [#f1]_ for the following workloads:
...
...
doc/sphinx/source/graphics/ExecutionInterfaceRunGraphs.png
0 → 100644
View file @
166fb921
42.7 KB
doc/sphinx/source/graphics/PaddlePaddleDir.svg
0 → 100644
View file @
166fb921
This diff is collapsed.
Click to expand it.
doc/sphinx/source/graphics/execution-interface.png
deleted
100644 → 0
View file @
285a24ae
114 KB
doc/sphinx/source/graphics/nGraphCompilerstack.png
0 → 100644
View file @
166fb921
32.8 KB
doc/sphinx/source/index.rst
View file @
166fb921
...
...
@@ -12,9 +12,9 @@
.. limitations under the License.
.. ---------------------------------------------------------------------------
######################
nGraph Compiler stack
######################
nGraph Compiler stack
Documentation
######################
#############
.. _ngraph_home:
...
...
@@ -23,36 +23,25 @@ nGraph Compiler stack
nGraph Compiler stack documentation for version |version|.
Documentation for the latest (master) development branch can be found
at https://ngraph.nervanasys.com/docs/latest
.. https://docs.ngraph.ai/
.. only:: (development or daily)
nGraph Compiler stack documentation for the master tree under development
(version |version|).
The nGraph Library and Compiler stack are provided under the `Apache 2.0 license`_
(found in the LICENSE file in the project's `repo`_). It may also import or reference
packages, scripts, and other files that use licensing.
.. _Apache 2.0 license: https://github.com/NervanaSystems/ngraph/blob/master/LICENSE
.. _repo: https://github.com/NervanaSystems/ngraph
.. toctree::
:name: mastertoctree
:titlesonly:
.. toctree::
:maxdepth: 1
:caption: Getting Started
introduction.rst
features.rst
project/release-notes.rst
.. toctree::
:maxdepth:
1
:maxdepth:
2
:caption: Framework Support
frameworks/index.rst
...
...
@@ -89,15 +78,20 @@ packages, scripts, and other files that use licensing.
.. toctree::
:maxdepth: 1
:caption:
Project Metadata
:caption:
Contributing
project/release-notes.rst
project/contribution-guide.rst
project/index.rst
project/extras/index.rst
glossary.rst
.. toctree::
:maxdepth: 1
:hidden:
project/release-notes.rst
project/index.rst
project/extras/index.rst
.. only:: html
...
...
doc/sphinx/source/ops/index.rst
View file @
166fb921
...
...
@@ -160,15 +160,30 @@ Not currently a comprehensive list.
More about Core Ops
-------------------
An ``Op``'s primary role is to function as a node in a directed acyclic graph
dependency computation graph.
An ``Op``'s primary role is to function as a node in a ddirected acyclic
computation graph.
*Core ops* are ops that are available and generally useful to all framework
bridges and that can be compiled by all transformers. A framework bridge may
define framework-specific ops to simplify graph construction, provided that the
bridge can enable every transformer to replace all such ops with equivalent
clusters or subgraphs composed of core ops. In a similar manner, transformers may define
transformer-specific ops to represent kernels or other intermediate operations.
clusters or subgraphs composed of core ops. In a similar manner, transformers
may define transformer-specific ops to represent kernels or other intermediate
operations.
The input and output ports of ops are any of the functions which work with
``Output<Node>/Input<Node>``. Previous functions that worked at the level
of ops are deprecated, like::
Node::get_element_type()
as it does not take any input. This function has been replaced with new
functions like::
Node::get_output_element_type(index)
where there is no ambiguity.
If a framework supports extending the set of ops it offers, a bridge may even
expose transformer-specific ops to the framework user.
...
...
doc/sphinx/source/ops/max.rst
View file @
166fb921
...
...
@@ -44,6 +44,6 @@ Outputs
C++ Interface
=============
.. doxygenclass:: ngraph::op::Max
.. doxygenclass:: ngraph::op::
v0::
Max
:project: ngraph
:members: m_axes
doc/sphinx/source/ops/min.rst
View file @
166fb921
...
...
@@ -44,6 +44,6 @@ Outputs
C++ Interface
=============
.. doxygenclass:: ngraph::op::Min
.. doxygenclass:: ngraph::op::
v0::
Min
:project: ngraph
:members: m_axes
doc/sphinx/source/project/contribution-guide.rst
View file @
166fb921
...
...
@@ -4,7 +4,7 @@
.. _contribution_guide:
##################
Contribution
g
uide
Contribution
G
uide
##################
...
...
doc/sphinx/source/project/release-notes.rst
View file @
166fb921
...
...
@@ -2,6 +2,8 @@
:orphan:
.. _release_notes:
Release Notes
#############
...
...
@@ -18,19 +20,33 @@ We are pleased to announce the release of version |version|.
Core updates for |version|
--------------------------
+ All ops support ``Output<Node>`` arguments
+ Additional ops
+ ONNX handling unknown domains
+ Provenance works with builders and fused ops
+ ``RPATH`` for finding openmpi
+ Negative indices/axes fixes
+ Migrate some ``get_argument`` removals
+ Negative indices/axes fixes
+ Better support for MKL-DNN 1.0 (DNNL)
Latest documentation updates
----------------------------
Latest documentation updates for |version|
------------------------------------------
+ Note the only support for nGPU is now through PlaidML; nGraph support for nGPU
(via cuDNN) has been deprecated.
+ iGPU works only with nGraph version `0.24`.
+ Add new Sphinx-friendly theme (can be built natively for an alternative to ngraph.ai docs).
+ Update PaddlePaddle documentation to reflect demo directories instead of example directory.
+ Update doc regarding the validation of ``Sum`` op.
.. important:: Pre-releases (``-rc-0.*``) have newer features, and are less stable.
Changelog on Previous Releases
==============================
...
...
@@ -41,7 +57,7 @@ Changelog on Previous Releases
+ Add rank id to trace file name
+ Allow provenance merging to be disabled
+ Remove some white-listed compiler warnings
+ Provenance
on builders
and fused op expansions
+ Provenance
, builders, ops that make ops,
and fused op expansions
0.25.0
...
...
@@ -136,8 +152,8 @@ Changelog on Previous Releases
+ Provenance improvements
0.19
----
pre-0.20
----
----
+ More dynamic shape preparation
+ Distributed interface factored out
...
...
@@ -153,11 +169,7 @@ Changelog on Previous Releases
+ Add graph visualization tools to doc
+ Update doxygen to be friendlier to frontends
0.18
----
.. 0.18
+ Python formatting issue
+ mkl-dnn work-around
+ Event tracing improvements
...
...
@@ -166,10 +178,7 @@ Changelog on Previous Releases
+ ONNX quantization
+ More fusions
0.17
----
.. 0.17
+ Allow negative padding in more places
+ Add code generation for some quantized ops
+ Preliminary dynamic shape support
...
...
@@ -177,10 +186,7 @@ Changelog on Previous Releases
+ Pad op takes CoordinateDiff instead of Shape pad values to allow for negative
padding.
0.16
----
.. 0.16
+ NodeInput and NodeOutput classes prepare for simplifications of Node
+ Test improvements
+ Additional quantization ops
...
...
doc/sphinx/source/sitemap.rst
deleted
100644 → 0
View file @
285a24ae
:orphan:
.. toctree::
:includehidden:
frameworks/index
project/index
python_api/index
inspection/index
core/overview
backends/index
project/extras/index
src/contrib/mlir/compiler/lowerer.cpp
View file @
166fb921
...
...
@@ -589,10 +589,14 @@ namespace
IndexedValue
iRes
(
result
),
iLhs
(
lhs
),
iRhs
(
rhs
);
ValueHandle
zeroInit
(
rewriter
.
create
<
ConstantOp
>
(
loc
,
rewriter
.
getZeroAttr
(
elemTy
)));
{
IndexHandle
n
,
k
;
LoopBuilder
(
&
n
,
nLb
,
nUb
,
nStep
)(
[
&
]
{
LoopBuilder
(
&
k
,
kLb
,
kUb
,
kStep
)([
&
]
{
iRes
(
n
,
k
)
=
zeroInit
;
});
});
}
LoopBuilder
(
&
n
,
nLb
,
nUb
,
nStep
)([
&
]
{
LoopBuilder
(
&
k
,
kLb
,
kUb
,
kStep
)([
&
]
{
iRes
(
n
,
k
)
=
zeroInit
;
LoopBuilder
(
&
m
,
mLb
,
mUb
,
mStep
)([
&
]
{
iRes
(
n
,
k
)
+=
iLhs
(
n
,
m
)
*
iRhs
(
m
,
k
);
});
LoopBuilder
(
&
m
,
mLb
,
mUb
,
mStep
)([
&
]
{
LoopBuilder
(
&
k
,
kLb
,
kUb
,
kStep
)([
&
]
{
iRes
(
n
,
k
)
+=
iLhs
(
n
,
m
)
*
iRhs
(
m
,
k
);
});
});
});
...
...
src/ngraph/node.hpp
View file @
166fb921
...
...
@@ -37,6 +37,7 @@
#include "ngraph/descriptor/output.hpp"
#include "ngraph/descriptor/tensor.hpp"
#include "ngraph/op/util/attr_types.hpp"
#include "ngraph/op/util/op_annotations.hpp"
#include "ngraph/placement.hpp"
#include "ngraph/strides.hpp"
#include "ngraph/type.hpp"
...
...
@@ -485,6 +486,15 @@ namespace ngraph
/// \throw std::out_of_range if the node does not have at least `output_index+1` outputs.
Output
<
const
Node
>
output
(
size_t
output_index
)
const
;
void
set_op_annotations
(
std
::
shared_ptr
<
ngraph
::
op
::
util
::
OpAnnotations
>
op_annotations
)
{
m_op_annotations
=
op_annotations
;
}
std
::
shared_ptr
<
ngraph
::
op
::
util
::
OpAnnotations
>
get_op_annotations
()
const
{
return
m_op_annotations
;
}
private
:
descriptor
::
Input
&
get_input_descriptor
(
size_t
position
);
descriptor
::
Output
&
get_output_descriptor
(
size_t
position
);
...
...
@@ -504,6 +514,7 @@ namespace ngraph
std
::
unordered_map
<
Node
*
,
autodiff
::
Adjoints
>
m_adjoint_map
;
Placement
m_placement
=
Placement
::
DEFAULT
;
size_t
m_placement_index
=
placement_invalid
;
std
::
shared_ptr
<
ngraph
::
op
::
util
::
OpAnnotations
>
m_op_annotations
;
};
/// \brief A handle for one of a node's inputs.
...
...
src/ngraph/op/avg_pool.cpp
View file @
166fb921
...
...
@@ -234,13 +234,13 @@ shared_ptr<Node> op::v0::AvgPool::get_default_value() const
}
op
::
v0
::
AvgPoolBackprop
::
AvgPoolBackprop
(
const
Shape
&
forward_arg_shape
,
const
shared_ptr
<
Node
>&
delta
,
const
Output
<
Node
>&
delta
,
const
Shape
&
window_shape
,
const
Strides
&
window_movement_strides
,
const
Shape
&
padding_below
,
const
Shape
&
padding_above
,
bool
include_padding_in_avg_computation
)
:
Op
(
check_single_output_args
({
delta
})
)
:
Op
(
{
delta
}
)
,
m_forward_arg_shape
(
forward_arg_shape
)
,
m_window_shape
(
window_shape
)
,
m_window_movement_strides
(
window_movement_strides
)
...
...
src/ngraph/op/avg_pool.hpp
View file @
166fb921
...
...
@@ -179,7 +179,7 @@ namespace ngraph
const
NodeTypeInfo
&
get_type_info
()
const
override
{
return
type_info
;
}
AvgPoolBackprop
()
=
default
;
AvgPoolBackprop
(
const
Shape
&
forward_arg_shape
,
const
std
::
shared_ptr
<
Node
>&
delta
,
const
Output
<
Node
>&
delta
,
const
Shape
&
window_shape
,
const
Strides
&
window_movement_strides
,
const
Shape
&
padding_below
,
...
...
src/ngraph/op/constant.hpp
View file @
166fb921
...
...
@@ -30,7 +30,7 @@ namespace ngraph
namespace
op
{
/// \brief Class for constants.
class
Constant
:
public
Node
class
Constant
:
public
Op
{
public
:
NGRAPH_API
...
...
@@ -251,7 +251,7 @@ namespace ngraph
protected
:
void
*
get_data_ptr_nc
()
{
return
(
m_data
?
m_data
->
get_ptr
()
:
nullptr
);
}
Constant
(
const
OutputVector
&
args
)
:
Node
(
args
)
:
Op
(
args
)
,
m_shape
({})
{
}
...
...
src/ngraph/op/op.hpp
View file @
166fb921
...
...
@@ -18,9 +18,7 @@
#include <string>
#include "ngraph/autodiff/adjoints.hpp"
#include "ngraph/node.hpp"
#include "ngraph/op/util/op_annotations.hpp"
namespace
ngraph
{
...
...
@@ -30,15 +28,6 @@ namespace ngraph
class
Op
:
public
Node
{
public
:
void
set_op_annotations
(
std
::
shared_ptr
<
ngraph
::
op
::
util
::
OpAnnotations
>
op_annotations
)
{
m_op_annotations
=
op_annotations
;
}
std
::
shared_ptr
<
ngraph
::
op
::
util
::
OpAnnotations
>
get_op_annotations
()
const
{
return
m_op_annotations
;
}
virtual
bool
is_op
()
const
override
{
return
true
;
}
protected
:
Op
()
...
...
@@ -48,9 +37,6 @@ namespace ngraph
Op
(
const
NodeVector
&
arguments
);
Op
(
const
OutputVector
&
arguments
);
Op
(
const
std
::
string
&
node_type
,
const
NodeVector
&
arguments
);
private
:
std
::
shared_ptr
<
ngraph
::
op
::
util
::
OpAnnotations
>
m_op_annotations
;
};
}
}
src/ngraph/op/reverse.cpp
View file @
166fb921
...
...
@@ -24,16 +24,16 @@
using
namespace
std
;
using
namespace
ngraph
;
constexpr
NodeTypeInfo
op
::
Reverse
::
type_info
;
constexpr
NodeTypeInfo
op
::
v0
::
Reverse
::
type_info
;
op
::
Reverse
::
Reverse
(
const
Output
<
Node
>&
arg
,
const
AxisSet
&
reversed_axes
)
op
::
v0
::
Reverse
::
Reverse
(
const
Output
<
Node
>&
arg
,
const
AxisSet
&
reversed_axes
)
:
Op
({
arg
})
,
m_reversed_axes
(
reversed_axes
)
{
constructor_validate_and_infer_types
();
}
void
op
::
Reverse
::
validate_and_infer_types
()
void
op
::
v0
::
Reverse
::
validate_and_infer_types
()
{
const
auto
input_shape
=
get_input_partial_shape
(
0
);
const
Dimension
input_rank
=
input_shape
.
rank
();
...
...
@@ -56,13 +56,13 @@ void op::Reverse::validate_and_infer_types()
set_output_type
(
0
,
get_input_element_type
(
0
),
input_shape
);
}
shared_ptr
<
Node
>
op
::
Reverse
::
copy_with_new_args
(
const
NodeVector
&
new_args
)
const
shared_ptr
<
Node
>
op
::
v0
::
Reverse
::
copy_with_new_args
(
const
NodeVector
&
new_args
)
const
{
check_new_args_count
(
this
,
new_args
);
return
make_shared
<
Reverse
>
(
new_args
.
at
(
0
),
m_reversed_axes
);
return
make_shared
<
v0
::
Reverse
>
(
new_args
.
at
(
0
),
m_reversed_axes
);
}
void
op
::
Reverse
::
generate_adjoints
(
autodiff
::
Adjoints
&
adjoints
,
const
NodeVector
&
deltas
)
void
op
::
v0
::
Reverse
::
generate_adjoints
(
autodiff
::
Adjoints
&
adjoints
,
const
NodeVector
&
deltas
)
{
auto
delta
=
deltas
.
at
(
0
);
...
...
src/ngraph/op/reverse.hpp
View file @
166fb921
...
...
@@ -21,6 +21,8 @@
namespace
ngraph
{
namespace
op
{
namespace
v0
{
// clang-format off
/// \brief Axis-reverse operation.
...
...
@@ -77,6 +79,7 @@ namespace ngraph
AxisSet
m_reversed_axes
;
};
}
namespace
v1
{
...
...
@@ -131,5 +134,7 @@ namespace ngraph
Mode
m_mode
;
};
}
// default opset version
using
v0
::
Reverse
;
}
}
src/ngraph/op/softmax.cpp
View file @
166fb921
...
...
@@ -53,14 +53,6 @@ op::v0::Softmax::Softmax(const Output<Node>& arg, const AxisSet& axes)
input_shape
,
")."
);
}
if
(
input_shape
.
is_static
())
{
set_output_type
(
0
,
get_input_element_type
(
0
),
input_shape
.
to_shape
());
}
else
{
set_output_type
(
0
,
get_input_element_type
(
0
),
PartialShape
::
dynamic
());
}
// empty axes == all axes
if
(
m_axes
.
size
()
==
0
)
...
...
@@ -72,6 +64,19 @@ op::v0::Softmax::Softmax(const Output<Node>& arg, const AxisSet& axes)
}
}
void
op
::
v0
::
Softmax
::
validate_and_infer_types
()
{
const
PartialShape
&
input_shape
=
get_input_partial_shape
(
0
);
if
(
input_shape
.
is_static
())
{
set_output_type
(
0
,
get_input_element_type
(
0
),
input_shape
.
to_shape
());
}
else
{
set_output_type
(
0
,
get_input_element_type
(
0
),
PartialShape
::
dynamic
());
}
}
shared_ptr
<
Node
>
op
::
v0
::
Softmax
::
copy_with_new_args
(
const
NodeVector
&
new_args
)
const
{
check_new_args_count
(
this
,
new_args
);
...
...
@@ -128,7 +133,11 @@ op::v1::Softmax::Softmax(const Output<Node>& arg, const size_t axis)
") is out of bounds (argument shape: "
,
input_shape
,
")."
);
}
void
op
::
v1
::
Softmax
::
validate_and_infer_types
()
{
const
PartialShape
&
input_shape
=
get_input_partial_shape
(
0
);
if
(
input_shape
.
is_static
())
set_output_type
(
0
,
get_input_element_type
(
0
),
input_shape
.
to_shape
());
else
...
...
src/ngraph/op/softmax.hpp
View file @
166fb921
...
...
@@ -43,6 +43,8 @@ namespace ngraph
///
Softmax
(
const
Output
<
Node
>&
arg
,
const
AxisSet
&
axes
);
void
validate_and_infer_types
()
override
;
virtual
std
::
shared_ptr
<
Node
>
copy_with_new_args
(
const
NodeVector
&
new_args
)
const
override
;
...
...
@@ -79,6 +81,8 @@ namespace ngraph
///
Softmax
(
const
Output
<
Node
>&
arg
,
const
size_t
axis
);
void
validate_and_infer_types
()
override
;
size_t
get_version
()
const
override
{
return
1
;
}
virtual
std
::
shared_ptr
<
Node
>
copy_with_new_args
(
const
NodeVector
&
new_args
)
const
override
;
...
...
src/ngraph/pass/opset0_downgrade.cpp
View file @
166fb921
...
...
@@ -15,8 +15,10 @@
//*****************************************************************************
#include "ngraph/pass/opset0_downgrade.hpp"
#include "ngraph/graph_util.hpp"
#include "ngraph/op/constant.hpp"
#include "ngraph/op/get_output_element.hpp"
#include "ngraph/op/pad.hpp"
#include "ngraph/op/reverse.hpp"
using
namespace
std
;
using
namespace
ngraph
;
...
...
@@ -87,6 +89,38 @@ bool pass::Opset0Downgrade::run_on_node(shared_ptr<Node> node)
modified
=
true
;
break
;
}
case
OP_TYPEID
:
:
Reverse
:
{
auto
tmp
=
as_type_ptr
<
op
::
v1
::
Reverse
>
(
node
);
auto
axes_node
=
tmp
->
input_value
(
1
).
get_node_shared_ptr
();
NGRAPH_CHECK
(
axes_node
->
is_constant
(),
"Unable to convert Reverse:v1 to Reverse:v0 "
"if reduction axes are not constant. Node: "
,
*
node
);
const
auto
axes_node_const
=
as_type_ptr
<
op
::
Constant
>
(
axes_node
);
AxisSet
axes
{};
if
(
tmp
->
get_mode
()
==
op
::
v1
::
Reverse
::
Mode
::
INDEX
)
{
axes
=
axes_node_const
->
get_axis_vector_val
();
}
else
// Mode::MASK
{
auto
axes_mask
=
axes_node_const
->
get_vector
<
bool
>
();
for
(
size_t
i
=
0
;
i
<
axes_mask
.
size
();
++
i
)
{
if
(
axes_mask
[
i
])
{
axes
.
emplace
(
i
);
}
}
}
auto
replacement_node
=
make_shared
<
op
::
v0
::
Reverse
>
(
node
->
input
(
0
).
get_source_output
(),
axes
);
replace_node
(
node
,
replacement_node
);
modified
=
true
;
break
;
}
default
:
break
;
}
#if defined(__clang__)
...
...
src/ngraph/runtime/cpu/cpu_emitter.hpp
View file @
166fb921
...
...
@@ -29,6 +29,7 @@
#include "ngraph/op/min.hpp"
#include "ngraph/op/pad.hpp"
#include "ngraph/op/product.hpp"
#include "ngraph/op/reverse.hpp"
#include "ngraph/op/sum.hpp"
#include "ngraph/runtime/cpu/cpu_external_function.hpp"
#include "ngraph/runtime/cpu/cpu_tensor_view_wrapper.hpp"
...
...
@@ -127,7 +128,6 @@ namespace ngraph
class
QuantizedMaxPool
;
class
QuantizedAvgPool
;
class
MaxPoolWithIndices
;
class
Reverse
;
class
ReverseSequence
;
class
MaxPoolWithIndicesBackprop
;
class
Erf
;
...
...
src/ngraph/runtime/cpu/kernel/gather.hpp
View file @
166fb921
...
...
@@ -85,7 +85,6 @@ namespace ngraph
static_cast
<
ElementType
*>
(
inputs
),
in_dims
);
auto
indices_ptr
=
static_cast
<
IndicesType
*>
(
indices
);
IndicesType
index_value
;
auto
indices_rank
=
indices_shape
.
size
();
auto
outer_loop_num
=
1
;
for
(
size_t
i
=
0
;
i
<
axis
;
i
++
)
...
...
@@ -125,7 +124,7 @@ namespace ngraph
// at axis
in_extents
[
axis
]
=
1
;
// at axis, get the value from indices arg
index_value
=
indices_ptr
[
0
];
IndicesType
index_value
=
indices_ptr
[
0
];
// take care of negative indices
in_offsets
[
axis
]
=
index_value
>=
0
?
index_value
:
index_value
+
axis_length
;
...
...
@@ -200,7 +199,7 @@ namespace ngraph
}
// at axis, get the value from indices arg
int
k
=
i
%
num_indices
;
index_value
=
indices_ptr
[
k
];
IndicesType
index_value
=
indices_ptr
[
k
];
// take care of negative indices
in_offsets
[
axis
]
=
index_value
>=
0
?
index_value
:
index_value
+
axis_length
;
...
...
src/ngraph/serializer.cpp
View file @
166fb921
This diff is collapsed.
Click to expand it.
test/mlir/affine_conversion/core_ops.mlir
View file @
166fb921
...
...
@@ -5,13 +5,34 @@
// -----
// Gather Op
// CHECK: affine.for
[[i:%
.*]] = 0 to 16 {
// CHECK:
[[L0:%.*]] = affine.load %{{.*\[}}[[i]]{{\]}}
// CHECK:
[[GATHER_IDX:%.*]] = index_cast
[[L0]]
// CHECK: affine.for
[[j:%
.*]] = 0 to 32 {
// CHECK:
[[VALUE:%.*]] = load %{{.*\[}}[[GATHER_IDX]], [[j]]{{\]}}
// CHECK: affine.store
[[VALUE]], %{{.*\[}}[[i]], [[j]]{{\]}}
// CHECK: affine.for
%[[I:
.*]] = 0 to 16 {
// CHECK:
%[[L0:.*]] = affine.load %{{.*}}[%[[I]]]
// CHECK:
%[[GATHER_IDX:.*]] = index_cast %
[[L0]]
// CHECK: affine.for
%[[J:
.*]] = 0 to 32 {
// CHECK:
%[[VALUE:.*]] = load %{{.*}}[%[[GATHER_IDX]], %[[J]]]
// CHECK: affine.store
%[[VALUE]], {{.*}}[%[[I]], %[[J]]]
func @simple_gather(%arg0: !ng.tensor<16x!ng.i64>, %arg1: !ng.tensor<512x32xf32>) -> !ng.tensor<16x32xf32> {
%0 = "ng.gather"(%arg1, %arg0) {axis = 0 : i64} : (!ng.tensor<512x32xf32>, !ng.tensor<16x!ng.i64>) -> !ng.tensor<16x32xf32>
"ng.return"(%0) : (!ng.tensor<16x32xf32>) -> ()
}
// -----
// Dot Op
// CHECK: affine.for %[[I:.*]] = 0 to 16
// CHECK-NEXT: affine.for %[[J:.*]] = 0 to 32
// CHECK-NEXT: affine.store %{{.*}}, %[[RESULT:.*]][%[[I]], %[[J]]]
// CHECK: }
// CHECK-NEXT: }
// CHECK: affine.for %[[K:.*]] = 0 to 16
// CHECK-NEXT: affine.for {{%.*}} = 0 to 8
// CHECK-NEXT: affine.for %[[M:.*]] = 0 to 32
// CHECK: affine.load
// CHECK: affine.load
// CHECK: mulf
// CHECK: %[[R:.*]] = addf
// CHECK: affine.store %[[R]], %[[RESULT]][%[[K]], %[[M]]]
func @simple_dot(%arg0: !ng.tensor<16x8xf32>, %arg1: !ng.tensor<8x32xf32>) -> !ng.tensor<16x32xf32> {
%0 = "ng.dot"(%arg0, %arg1) : (!ng.tensor<16x8xf32>, !ng.tensor<8x32xf32>) -> !ng.tensor<16x32xf32>
"ng.return"(%0) : (!ng.tensor<16x32xf32>) -> ()
}
test/opset_pass/reverse_opset_pass.cpp
View file @
166fb921
...
...
@@ -19,18 +19,19 @@
#include "ngraph/ngraph.hpp"
#include "ngraph/pass/manager.hpp"
#include "ngraph/pass/opset0_downgrade.hpp"
#include "ngraph/pass/opset1_upgrade.hpp"
#include "util/type_prop.hpp"
using
namespace
std
;
using
namespace
ngraph
;
TEST
(
serializ
e
,
opset1_reverse_upgrade
)
TEST
(
opset_upgrad
e
,
opset1_reverse_upgrade
)
{
const
auto
data
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
2
,
2
,
2
});
const
AxisSet
reverse_axes
{
1
,
2
};
const
auto
reverse_v0
=
make_shared
<
op
::
Reverse
>
(
data
,
reverse_axes
);
const
auto
reverse_v0
=
make_shared
<
op
::
v0
::
Reverse
>
(
data
,
reverse_axes
);
const
auto
result
=
make_shared
<
op
::
Result
>
(
reverse_v0
);
auto
f
=
make_shared
<
Function
>
(
ResultVector
{
result
},
ParameterVector
{
data
});
...
...
@@ -50,3 +51,78 @@ TEST(serialize, opset1_reverse_upgrade)
// should match the number of elements of v0::Reverse reverse_axes attribute
EXPECT_EQ
(
rev_axes_input_shape
,
Shape
{
2
});
}
TEST
(
opset_downgrade
,
opset0_reverse_downgrade_index_mode
)
{
const
auto
data
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
2
,
2
,
2
});
const
auto
reverse_axes
=
make_shared
<
op
::
Constant
>
(
element
::
i64
,
Shape
{
2
},
vector
<
int64_t
>
{
1
,
2
});
auto
mode
=
op
::
v1
::
Reverse
::
Mode
::
INDEX
;
const
auto
reverse_v1
=
make_shared
<
op
::
v1
::
Reverse
>
(
data
,
reverse_axes
,
mode
);
const
auto
result
=
make_shared
<
op
::
Result
>
(
reverse_v1
);
auto
f
=
make_shared
<
Function
>
(
ResultVector
{
result
},
ParameterVector
{
data
});
ngraph
::
pass
::
Manager
pass_manager
;
pass_manager
.
register_pass
<
pass
::
Opset0Downgrade
>
();
pass_manager
.
run_passes
(
f
);
const
auto
pass_replacement_node
=
f
->
get_result
()
->
input
(
0
).
get_source_output
().
get_node_shared_ptr
();
const
auto
reverse_v0
=
static_pointer_cast
<
op
::
v0
::
Reverse
>
(
pass_replacement_node
);
EXPECT_EQ
(
reverse_v0
->
description
(),
"Reverse"
);
EXPECT_EQ
(
reverse_v0
->
get_version
(),
0
);
EXPECT_EQ
(
reverse_v0
->
get_reversed_axes
(),
AxisSet
({
1
,
2
}));
}
TEST
(
opset_downgrade
,
opset0_reverse_downgrade_mask_mode
)
{
const
auto
data
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
2
,
2
,
2
});
const
auto
reverse_axes
=
make_shared
<
op
::
Constant
>
(
element
::
boolean
,
Shape
{
3
},
vector
<
bool
>
{
true
,
false
,
true
});
auto
mode
=
op
::
v1
::
Reverse
::
Mode
::
MASK
;
const
auto
reverse_v1
=
make_shared
<
op
::
v1
::
Reverse
>
(
data
,
reverse_axes
,
mode
);
const
auto
result
=
make_shared
<
op
::
Result
>
(
reverse_v1
);
auto
f
=
make_shared
<
Function
>
(
ResultVector
{
result
},
ParameterVector
{
data
});
ngraph
::
pass
::
Manager
pass_manager
;
pass_manager
.
register_pass
<
pass
::
Opset0Downgrade
>
();
pass_manager
.
run_passes
(
f
);
const
auto
pass_replacement_node
=
f
->
get_result
()
->
input
(
0
).
get_source_output
().
get_node_shared_ptr
();
const
auto
reverse_v0
=
static_pointer_cast
<
op
::
v0
::
Reverse
>
(
pass_replacement_node
);
EXPECT_EQ
(
reverse_v0
->
description
(),
"Reverse"
);
EXPECT_EQ
(
reverse_v0
->
get_version
(),
0
);
EXPECT_EQ
(
reverse_v0
->
get_reversed_axes
(),
AxisSet
({
0
,
2
}));
}
TEST
(
opset_downgrade
,
opset0_reverse_downgrade_axes_not_constant
)
{
const
auto
data
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
2
,
2
,
2
});
const
auto
axes
=
make_shared
<
op
::
Parameter
>
(
element
::
boolean
,
Shape
{
3
});
const
auto
reverse_v1
=
make_shared
<
op
::
v1
::
Reverse
>
(
data
,
axes
,
op
::
v1
::
Reverse
::
Mode
::
MASK
);
const
auto
result
=
make_shared
<
op
::
Result
>
(
reverse_v1
);
auto
f
=
make_shared
<
Function
>
(
ResultVector
{
result
},
ParameterVector
{
data
,
axes
});
ngraph
::
pass
::
Manager
pass_manager
;
pass_manager
.
register_pass
<
pass
::
Opset0Downgrade
>
();
try
{
pass_manager
.
run_passes
(
f
);
FAIL
()
<<
"Exception after Opset0Downgrade pass was not thrown."
;
}
catch
(
const
ngraph_error
&
error
)
{
EXPECT_HAS_SUBSTRING
(
error
.
what
(),
std
::
string
(
"Unable to convert Reverse:v1 to Reverse:v0"
));
}
catch
(...)
{
FAIL
()
<<
"Reverse:v1 pass failed for unexpected reason"
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment