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
4b84262c
Commit
4b84262c
authored
Jul 05, 2019
by
Robert Kimball
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into bob/async
parents
098b73c1
e090c6aa
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
596 additions
and
295 deletions
+596
-295
conf.py
doc/sphinx/conf.py
+17
-76
ngversions.html
doc/sphinx/ngraph_theme/ngversions.html
+7
-10
index.rst
doc/sphinx/source/backends/backend-api/index.rst
+0
-1
cpp-api.rst
doc/sphinx/source/backends/cpp-api.rst
+3
-2
index.rst
doc/sphinx/source/backends/dynamicbackend-api/index.rst
+3
-3
index.rst
doc/sphinx/source/backends/executable-api/index.rst
+0
-1
index.rst
doc/sphinx/source/backends/index.rst
+55
-0
conf.py
doc/sphinx/source/conf.py
+2
-2
generic-configs.rst
doc/sphinx/source/frameworks/generic-configs.rst
+67
-18
mxnet_integ.rst
doc/sphinx/source/frameworks/mxnet_integ.rst
+4
-1
onnx_integ.rst
doc/sphinx/source/frameworks/onnx_integ.rst
+6
-7
index.rst
doc/sphinx/source/index.rst
+0
-1
index.rst
doc/sphinx/source/inspection/index.rst
+4
-4
doc-contributor-README.rst
doc/sphinx/source/project/doc-contributor-README.rst
+35
-8
release-notes.rst
doc/sphinx/source/project/release-notes.rst
+45
-47
BUILDING.md
python/BUILDING.md
+5
-5
README.md
python/README.md
+3
-3
CMakeLists.txt
src/ngraph/CMakeLists.txt
+2
-1
distributed.cpp
src/ngraph/distributed.cpp
+1
-1
group_conv_transpose.cpp
src/ngraph/op/fused/group_conv_transpose.cpp
+2
-1
reshape.hpp
src/ngraph/op/util/reshape.hpp
+0
-81
aligned_buffer.cpp
src/ngraph/runtime/aligned_buffer.cpp
+28
-5
aligned_buffer.hpp
src/ngraph/runtime/aligned_buffer.hpp
+8
-1
allocator.cpp
src/ngraph/runtime/allocator.cpp
+55
-0
allocator.hpp
src/ngraph/runtime/allocator.hpp
+50
-0
backend.cpp
src/ngraph/runtime/backend.cpp
+7
-0
backend.hpp
src/ngraph/runtime/backend.hpp
+19
-0
cpu_backend.cpp
src/ngraph/runtime/cpu/cpu_backend.cpp
+35
-4
cpu_backend.hpp
src/ngraph/runtime/cpu/cpu_backend.hpp
+10
-1
cpu_call_frame.cpp
src/ngraph/runtime/cpu/cpu_call_frame.cpp
+5
-4
cpu_call_frame.hpp
src/ngraph/runtime/cpu/cpu_call_frame.hpp
+4
-2
cpu_external_function.cpp
src/ngraph/runtime/cpu/cpu_external_function.cpp
+4
-2
cpu_external_function.hpp
src/ngraph/runtime/cpu/cpu_external_function.hpp
+1
-2
cpu_runtime_context.hpp
src/ngraph/runtime/cpu/cpu_runtime_context.hpp
+0
-1
w.bin
test/files/onnx/convtranspose_output_shape/w.bin
+0
-0
x.bin
test/files/onnx/convtranspose_output_shape/x.bin
+0
-0
y.bin
test/files/onnx/convtranspose_output_shape/y.bin
+0
-0
convtranspose_output_shape.prototxt
test/models/onnx/convtranspose_output_shape.prototxt
+92
-0
onnx_import_convpool.in.cpp
test/onnx/onnx_import_convpool.in.cpp
+17
-0
No files found.
doc/sphinx/conf.py
View file @
4b84262c
#!/usr/bin/env python3
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
#
#
...
@@ -73,13 +71,11 @@ author = 'Intel Corporation'
...
@@ -73,13 +71,11 @@ author = 'Intel Corporation'
# built documents.
# built documents.
#
#
# The short X.Y version.
# The short X.Y version.
version
=
'0.2
2
'
version
=
'0.2
3
'
# The Documentation full version, including alpha/beta/rc tags. Some features
# The Documentation full version, including alpha/beta/rc tags. Some features
# available in the latest code will not necessarily be documented first.
# available in the latest code will not necessarily be documented first
# rc syntax may be tagged; this documentation supports various rc-naming conventions
release
=
'0.23.0'
release
=
'0.22.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.
...
@@ -107,38 +103,18 @@ todo_include_todos = True
...
@@ -107,38 +103,18 @@ todo_include_todos = True
# -- Options for HTML output ----------------------------------------------
# -- Options for HTML output ----------------------------------------------
html_title
=
'nGraph Compiler stack Documentation'
html_title
=
"Documentation for the nGraph Library and Compiler stack"
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme
=
'ngraph_theme'
html_theme
=
'ngraph_theme'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
# html_theme_options = {}
# html_theme_options = {}
html_theme_path
=
[
"../"
]
html_logo
=
'../ngraph_theme/static/logo.png'
if
tags
.
has
(
'release'
):
is_release
=
True
docs_title
=
'Docs /
%
s'
%
(
version
)
%
(
release
)
else
:
is_release
=
False
docs_title
=
'Docs / Latest'
# borrow this from the zephyr docs theme
html_context
=
{
# 'show_license': html_show_license, we have custom footers to attribute
# RTD, WTD, and Sphinx contributors; so we do not enable this
'docs_title'
:
docs_title
,
'is_release'
:
is_release
,
'theme_logo_only'
:
False
,
'current_version'
:
version
,
'versions'
:
(
(
"latest"
,
"../"
),
(
"0.20.0"
,
"/0.20.0/"
),
#not yet sure how we'll do this
(
"0.19.0"
,
"/0.19.0/"
),
(
"0.18.0"
,
"/0.18.0/"
),
(
"0.17.0"
,
"/0.17.0/"
),
(
"0.16.0"
,
"/0.16.0/"
),
)
}
html_logo
=
'../ngraph_theme/static/favicon.ico'
# The name of an image file (within the static path) to use as favicon of the
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
...
@@ -151,6 +127,7 @@ html_favicon = '../ngraph_theme/static/favicon.ico'
...
@@ -151,6 +127,7 @@ html_favicon = '../ngraph_theme/static/favicon.ico'
html_static_path
=
[
'../ngraph_theme/static'
]
html_static_path
=
[
'../ngraph_theme/static'
]
# Add any paths that contain custom themes here, relative to this directory.
# Add any paths that contain custom themes here, relative to this directory.
html_theme_path
=
[
"../"
]
# Custom sidebar templates, must be a dictionary that maps document names
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
# to template names.
...
@@ -165,26 +142,6 @@ html_sidebars = {
...
@@ -165,26 +142,6 @@ html_sidebars = {
}
}
# Custom added feature to allow redirecting old URLs
#
# list of tuples (old_url, new_url) for pages to redirect
# (URLs should be relative to document root, only)
html_redirect_pages
=
[
(
'backend-support'
,
'backends/index'
),
(
'core/core'
,
'core/overview.rst'
),
(
'core/fusion'
,
'core/fusion/index'
),
(
'frameworks/mxnet'
,
'frameworks/mxnet_intg.rst'
),
(
'frameworks/onnx'
,
'frameworks/onnx_intg.rst'
),
(
'frameworks/tensorflow'
,
'frameworks/tensorflow_connect.rst'
),
(
'frameworks/paddle'
,
'frameworks/paddle_integ.rst'
),
(
'inspection/inspection'
,
'inspection/index'
),
(
'releases/release-notes'
,
'releases/index'
),
# ('getting_started/getting_starting', 'getting_started/index'),
# mv to framework-specific helper directory
(
'project/project'
,
'project/index'
),
(
'python_api/'
,
'python_api/index'
),
]
# -- Options for HTMLHelp output ------------------------------------------
# -- Options for HTMLHelp output ------------------------------------------
# Output file base name for HTML help builder.
# Output file base name for HTML help builder.
...
@@ -195,11 +152,11 @@ htmlhelp_basename = 'IntelnGraphlibrarydoc'
...
@@ -195,11 +152,11 @@ htmlhelp_basename = 'IntelnGraphlibrarydoc'
latex_elements
=
{
latex_elements
=
{
# The paper size ('letterpaper' or 'a4paper').
# The paper size ('letterpaper' or 'a4paper').
#
#
#
'papersize': 'letterpaper',
'papersize'
:
'letterpaper'
,
# The font size ('10pt', '11pt' or '12pt').
# The font size ('10pt', '11pt' or '12pt').
#
#
#
'pointsize': '10pt',
'pointsize'
:
'10pt'
,
# Additional stuff for the LaTeX preamble.
# Additional stuff for the LaTeX preamble.
#
#
...
@@ -214,11 +171,10 @@ latex_elements = {
...
@@ -214,11 +171,10 @@ latex_elements = {
# (source start file, target name, title,
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
# author, documentclass [howto, manual, or own class]).
latex_documents
=
[
latex_documents
=
[
(
master_doc
,
'nGraphCompilerStack.tex'
,
'nGraph Compiler Stack Documentation'
,
(
master_doc
,
'nGraphCompilerStack.tex'
,
u
'nGraph Compiler Stack Documentation'
,
'Intel Corporation'
,
'manual'
),
u
'Intel Corporation'
,
'manual'
),
]
]
# -- Options for manual page output ---------------------------------------
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# One entry per manual page. List of tuples
...
@@ -244,22 +200,7 @@ breathe_projects = {
...
@@ -244,22 +200,7 @@ breathe_projects = {
}
}
rst_epilog
=
u"""
rst_epilog
=
u"""
.. |codename| replace:: Intel nGraph
.. include:: /replacements.txt
.. |project| replace:: Intel nGraph Library
.. |InG| replace:: Intel® nGraph
.. |copy| unicode:: U+000A9 .. COPYRIGHT SIGN
:ltrim:
.. |deg| unicode:: U+000B0 .. DEGREE SIGN
:ltrim:
.. |plusminus| unicode:: U+000B1 .. PLUS-MINUS SIGN
:rtrim:
.. |micro| unicode:: U+000B5 .. MICRO SIGN
:rtrim:
.. |trade| unicode:: U+02122 .. TRADEMARK SIGN
:ltrim:
.. |reg| unicode:: U+000AE .. REGISTERED TRADEMARK SIGN
:ltrim:
"""
"""
# -- autodoc Extension configuration --------------------------------------
# -- autodoc Extension configuration --------------------------------------
...
...
doc/sphinx/ngraph_theme/ngversions.html
View file @
4b84262c
...
@@ -6,16 +6,14 @@
...
@@ -6,16 +6,14 @@
</span>
</span>
<div
class=
"rst-other-versions"
>
<div
class=
"rst-other-versions"
>
<dl>
<dl>
<dt>
{{ _('
Previous
Versions') }}
</dt>
<dt>
{{ _('
Recent
Versions') }}
</dt>
<dd>
<!-- Until our https://docs.ngraph.ai/ publishing is set up, we link to GitHub -->
<dd>
<!-- Until our https://docs.ngraph.ai/ publishing is set up, we link to GitHub -->
<ul>
<ul>
<li><a
href=
"https://github.com/NervanaSystems/ngraph/releases/tag/v0.20.0"
>
0.20.0-rc.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.19.0-rc.2"
>
0.19.0-rc.2
</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.18.1"
>
0.18.1
</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.17.0-rc.1"
>
0.17.0-rc.1
</a></li>
<li><a
href=
"https://github.com/NervanaSystems/ngraph/releases/tag/v0.20.0"
>
0.20.0
</a></li>
<li><a
href=
"https://github.com/NervanaSystems/ngraph/releases/tag/v0.16.0-rc.3"
>
0.16.0-rc.3
</a></li>
<li><a
href=
"https://github.com/NervanaSystems/ngraph/releases/tag/v0.19.0"
>
0.19.0
</a></li>
<li><a
href=
"https://github.com/NervanaSystems/ngraph/releases/tag/v0.16.0-rc.2"
>
0.16.0-rc.2
</a></li>
<li><a
href=
"https://github.com/NervanaSystems/ngraph/releases/tag/v0.16.0-rc.1"
>
0.16.0-rc.1
</a></li>
</ul></dd>
</ul></dd>
</dl>
</dl>
<dl>
<dl>
...
@@ -28,4 +26,4 @@
...
@@ -28,4 +26,4 @@
</dd>
</dd>
</dl>
</dl>
</div>
</div>
</div>
</div>
\ No newline at end of file
doc/sphinx/source/backends/backend-api/index.rst
View file @
4b84262c
...
@@ -7,4 +7,3 @@ Backend
...
@@ -7,4 +7,3 @@ Backend
.. doxygenclass:: ngraph::runtime::Backend
.. doxygenclass:: ngraph::runtime::Backend
:project: ngraph
:project: ngraph
:members:
:members:
doc/sphinx/source/backends/cpp-api.rst
View file @
4b84262c
...
@@ -7,9 +7,10 @@ Backend APIs
...
@@ -7,9 +7,10 @@ Backend APIs
:maxdepth: 1
:maxdepth: 1
backend-api/index
backend-api/index
executable-api/index
dynamicbackend-api/index
hosttensor-api/index
plaidml-ng-api/index
plaidml-ng-api/index
executable-api/index
As of version ``0.15``, there is a new backend API to work with functions that
As of version ``0.15``, there is a new backend API to work with functions that
can be compiled as a runtime ``Executable``. Where previously ``Backend`` used a
can be compiled as a runtime ``Executable``. Where previously ``Backend`` used a
...
...
doc/sphinx/source/backends/
hosttensor
-api/index.rst
→
doc/sphinx/source/backends/
dynamicbackend
-api/index.rst
View file @
4b84262c
.. backends/hosttensor-api/index.rst:
.. backends/hosttensor-api/index.rst:
HostTensor
DynamicBackend
==========
==========
====
.. doxygenclass:: ngraph::runtime::
HostTensor
.. doxygenclass:: ngraph::runtime::
dynamic::DynamicBackend
:project: ngraph
:project: ngraph
:members:
:members:
doc/sphinx/source/backends/executable-api/index.rst
View file @
4b84262c
...
@@ -7,7 +7,6 @@ Executable
...
@@ -7,7 +7,6 @@ Executable
The ``compile`` function on an ``Executable`` has more direct methods to
The ``compile`` function on an ``Executable`` has more direct methods to
actions such as ``validate``, ``call``, ``get_performance_data``, and so on.
actions such as ``validate``, ``call``, ``get_performance_data``, and so on.
.. doxygenclass:: ngraph::runtime::Executable
.. doxygenclass:: ngraph::runtime::Executable
:project: ngraph
:project: ngraph
:members:
:members:
...
...
doc/sphinx/source/backends/index.rst
View file @
4b84262c
...
@@ -6,6 +6,7 @@ Developer Resources for Backends
...
@@ -6,6 +6,7 @@ Developer Resources for Backends
* :ref:`what_is_backend`
* :ref:`what_is_backend`
* :ref:`how_to_use`
* :ref:`how_to_use`
* :ref:`miscellaneous_resources`
.. _what_is_backend:
.. _what_is_backend:
...
@@ -60,3 +61,57 @@ interface; each backend implements the following five functions:
...
@@ -60,3 +61,57 @@ interface; each backend implements the following five functions:
for later execution.
for later execution.
* And, finally, the ``call()`` method is used to invoke an nGraph function
* And, finally, the ``call()`` method is used to invoke an nGraph function
against a particular set of tensors.
against a particular set of tensors.
.. _miscellaneous_resources:
Miscellaneous resources
=======================
Additional resources for device or framework-specific configurations:
OpenCL
------
OpenCL is needed for the :doc:`plaidml-ng-api/index`; this is not needed if
you have only a CPU backend.
#. Install the latest Linux driver for your system. You can find a list
of drivers at https://software.intel.com/en-us/articles/opencl-drivers;
You may need to install `OpenCL SDK`_ in case of an ``libOpenCL.so`` absence.
#. Any user added to "video" group:
.. code-block:: console
sudo usermod –a –G video <user_id>
may, for example, be able to find details at the ``/sys/module/[system]/parameters/`` location.
nGraph Bridge from TensorFlow\*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When specified as the generic backend -- either manually or automatically
from a framework -- ``NGRAPH`` defaults to CPU, and it also allows for
additional device configuration or selection.
Because nGraph can select backends, specifying the ``INTELGPU``
backend as a runtime environment variable also works if one is
present in your system:
:envvar:`NGRAPH_TF_BACKEND="INTELGPU"`
An `axpy.py example`_ is optionally available to test; outputs will vary
depending on the parameters specified.
.. code-block:: console
NGRAPH_TF_BACKEND="INTELGPU" python3 axpy.py
* ``NGRAPH_INTELGPU_DUMP_FUNCTION`` -- dumps nGraph’s functions
in dot format.
.. _axpy.py example: https://github.com/tensorflow/ngraph-bridge/blob/master/examples/axpy.py
.. _OpenCL SDK: https://software.intel.com/en-us/opencl-sdk
doc/sphinx/source/conf.py
View file @
4b84262c
...
@@ -73,11 +73,11 @@ author = 'Intel Corporation'
...
@@ -73,11 +73,11 @@ author = 'Intel Corporation'
# built documents.
# built documents.
#
#
# The short X.Y version.
# The short X.Y version.
version
=
'0.2
1
'
version
=
'0.2
2
'
# The Documentation full version, including alpha/beta/rc tags. Some features
# The Documentation full version, including alpha/beta/rc tags. Some features
# available in the latest code will not necessarily be documented first
# available in the latest code will not necessarily be documented first
release
=
'0.2
1
.0'
release
=
'0.2
2
.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.
...
...
doc/sphinx/source/frameworks/generic-configs.rst
View file @
4b84262c
...
@@ -5,8 +5,8 @@ Integrating new frameworks
...
@@ -5,8 +5,8 @@ Integrating new frameworks
This section details some of the *configuration options* and some of the
This section details some of the *configuration options* and some of the
*environment variables* that can be used to tune for optimal performance when
*environment variables* that can be used to tune for optimal performance when
your system already has a version of nGraph installed with one o
f our supported
your system already has a version of nGraph installed with one o
r more of our
backends.
supported :doc:`../backends/index`.
Regardless of the framework, after the :doc:`../buildlb` step, a good place
Regardless of the framework, after the :doc:`../buildlb` step, a good place
to start usually involves making the libraries available to the framework. On
to start usually involves making the libraries available to the framework. On
...
@@ -19,15 +19,59 @@ something like:
...
@@ -19,15 +19,59 @@ something like:
export LD_LIBRARY_PATH=path/to/ngraph_dist/lib/
export LD_LIBRARY_PATH=path/to/ngraph_dist/lib/
Find or display nGraph Version
Find or display version
-------------------------------
=======================
If you're working with the :doc:`../python_api/index`, the following command
may be useful:
.. code-block:: console
.. code-block:: console
python3 -c "import ngraph as ng; print('nGraph version: ',ng.__version__)";
python3 -c "import ngraph as ng; print('nGraph version: ',ng.__version__)";
To manually build a newer version than is available from the latest `PyPI`_
(:abbr:`Python Package Index (PyPI)`), see our nGraph Python API `BUILDING.md`_
documentation.
Activate logtrace-related environment variables
===============================================
Another configuration option is to activate ``NGRAPH_CPU_DEBUG_TRACER``,
a runtime environment variable that supports extra logging and debug detail.
This is a useful tool for data scientists interested in outputs from logtrace
files that can, for example, help in tracking down model convergences. It can
also help engineers who might want to add their new ``Backend`` to an existing
framework to compare intermediate tensors/values to references from a CPU
backend.
To activate this tool, set the ``env`` var ``NGRAPH_CPU_DEBUG_TRACER=1``.
It will dump ``trace_meta.log`` and ``trace_bin_data.log``. The names of the
logfiles can be customized.
To specify the names of logs with those flags:
::
NGRAPH_TRACER_LOG = "meta.log"
NGRAPH_BIN_TRACER_LOG = "bin.log"
The meta_log contains::
kernel_name, serial_number_of_op, tensor_id, symbol_of_in_out, num_elements, shape, binary_data_offset, mean_of_tensor, variance_of_tensor
A line example from a unit-test might look like::
K=Add S=0 TID=0_0 >> size=4 Shape{2, 2} bin_data_offset=8 mean=1.5 var=1.25
The binary_log line contains::
tensor_id, binary data (tensor data)
A reference for the implementation of parsing these logfiles can also be found
in the unit test for this feature.
FMV
FMV
---
---
...
@@ -37,7 +81,7 @@ number of generic ways to patch or bring architecture-based optimizations to
...
@@ -37,7 +81,7 @@ number of generic ways to patch or bring architecture-based optimizations to
the :abbr:`Operating System (OS)` that is handling your ML environment. See
the :abbr:`Operating System (OS)` that is handling your ML environment. See
the `GCC wiki for details`_.
the `GCC wiki for details`_.
If your nGraph build is a Neural Network configured on Clear Linux* OS
If your nGraph build is a Neural Network configured on Clear Linux
\
* OS
for Intel® Architecture, and it includes at least one older CPU, the
for Intel® Architecture, and it includes at least one older CPU, the
`following article may be helpful`_.
`following article may be helpful`_.
...
@@ -63,11 +107,14 @@ For CPU (and most cuDNN) backends, the preferred layout is currently ``NCHW``.
...
@@ -63,11 +107,14 @@ For CPU (and most cuDNN) backends, the preferred layout is currently ``NCHW``.
Intel® Math Kernel Library for Deep Neural Networks
Intel® Math Kernel Library for Deep Neural Networks
---------------------------------------------------
---------------------------------------------------
-The following `KMP options`_ were originally optimized for models using the
.. important:: Intel® MKL-DNN is automatically enabled as part of an
nGraph default :doc:`build <../buildlb>`; you do *not* need to add it
separately or as an additional component to be able to use these
configuration settings.
The following `KMP`_ options were originally optimized for models using the
Intel® `MKL-DNN`_ to train models with the ``NCHW`` data layout; however, other
Intel® `MKL-DNN`_ to train models with the ``NCHW`` data layout; however, other
configurations can be explored. MKL-DNN is automatically enabled as part of an
configurations can be explored.
nGraph compilation; you do *not* need to add MKL-DNN separately or as an
additional component to be able to use these configuration settings.
* ``KMP_BLOCKTIME`` Sets the time, in milliseconds, that a thread should wait
* ``KMP_BLOCKTIME`` Sets the time, in milliseconds, that a thread should wait
after completing the execution of a parallel region, before sleeping.
after completing the execution of a parallel region, before sleeping.
...
@@ -128,10 +175,11 @@ Convolution shapes
...
@@ -128,10 +175,11 @@ Convolution shapes
``OMP_NUM_THREADS``
``OMP_NUM_THREADS``
^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^
The best resource for this configuration option is the `gnu.org site`_
The best resource for this configuration option is the Intel® OpenMP\* docs
``OMP_NUM_THREADS`` defaults to the number of logical cores. To check the
at the following link: `Intel OpenMP documentation`_. ``OMP_NUM_THREADS``
number of cores on your system, you can run the following on the command-line to
defaults to the number of logical cores. To check the number of cores on your
see the details of your CPU:
system, you can run the following on the command-line to see the details
of your CPU:
.. code-block:: console
.. code-block:: console
...
@@ -171,11 +219,12 @@ achieve the best performance for NN workloads on CPU platforms. The nGraph
...
@@ -171,11 +219,12 @@ achieve the best performance for NN workloads on CPU platforms. The nGraph
Compiler stack runs on transformers handled by Intel® Architecture (IA), and
Compiler stack runs on transformers handled by Intel® Architecture (IA), and
thus can make more efficient use of the underlying hardware.
thus can make more efficient use of the underlying hardware.
.. _PyPI: https://pypi.org/project/ngraph-core
.. _KMP options: https://software.intel.com/en-us/cpp-compiler-developer-guide-and-reference-controlling-thread-allocation
.. _KMP: https://software.intel.com/en-us/node/522691
.. KMP options: https://software.intel.com/en-us/node/522691
.. _MKL-DNN: https://github.com/intel/mkl-dnn
.. _MKL-DNN: https://github.com/intel/mkl-dnn
.. _
gnu.org site: https://gcc.gnu.org/onlinedocs/libgomp/Environment-Variables.html
.. _
Intel OpenMP documentation: https://www.openmprtl.org/documentation
.. _Movidius: https://www.movidius.com/
.. _Movidius: https://www.movidius.com/
.. _BUILDING.md: https://github.com/NervanaSystems/ngraph/blob/master/python/BUILDING.md
.. _GCC wiki for details: https://gcc.gnu.org/wiki/FunctionMultiVersioning
.. _GCC wiki for details: https://gcc.gnu.org/wiki/FunctionMultiVersioning
.. _following article may be helpful: https://clearlinux.org/documentation/clear-linux/tutorials/fmv
.. _following article may be helpful: https://clearlinux.org/documentation/clear-linux/tutorials/fmv
doc/sphinx/source/frameworks/mxnet_integ.rst
View file @
4b84262c
.. frameworks/mxnet_integ.rst:
.. frameworks/mxnet_integ.rst:
MXNet\* bridge
MXNet\* bridge
===============
==============
.. deprecated:: 0.21.0
* See the nGraph-MXNet `Integration Guide`_ on the nGraph-MXNet repo.
* See the nGraph-MXNet `Integration Guide`_ on the nGraph-MXNet repo.
...
...
doc/sphinx/source/frameworks/onnx_integ.rst
View file @
4b84262c
...
@@ -10,7 +10,7 @@ nGraph's internal representation and converted to ``Function`` objects, which
...
@@ -10,7 +10,7 @@ nGraph's internal representation and converted to ``Function`` objects, which
can be compiled and executed on one of nGraph's backends.
can be compiled and executed on one of nGraph's backends.
You can use nGraph's Python API to run an ONNX model and nGraph can be used
You can use nGraph's Python API to run an ONNX model and nGraph can be used
as an ONNX backend using the add-on package `nGraph
-ONNX <ngraph_onnx>
`_.
as an ONNX backend using the add-on package `nGraph
ONNX
`_.
.. note:: In order to support ONNX, nGraph must be built with the
.. note:: In order to support ONNX, nGraph must be built with the
...
@@ -33,8 +33,7 @@ for nGraph, ONNX and NumPy:
...
@@ -33,8 +33,7 @@ for nGraph, ONNX and NumPy:
Importing an ONNX model
Importing an ONNX model
-----------------------
-----------------------
You can download models from the `ONNX Model Zoo <onnx_model_zoo_>`_.
You can download models from the `ONNX Model Zoo`_. For example, ResNet-50:
For example ResNet-50:
::
::
...
@@ -92,9 +91,9 @@ data:
...
@@ -92,9 +91,9 @@ data:
Find more information about nGraph and ONNX in the
Find more information about nGraph and ONNX in the
`nGraph
-ONNX <ngraph_onnx>
`_ GitHub repository.
`nGraph
ONNX
`_ GitHub repository.
.. _ngraph
_onnx: https://github.com/NervanaSystems/ngraph-onnx/
.. _ngraph
ONNX: https://github.com/NervanaSystems/ngraph-onnx
.. _ngraph
_onnx_
building: https://github.com/NervanaSystems/ngraph-onnx/blob/master/BUILDING.md
.. _ngraph
ONNX
building: https://github.com/NervanaSystems/ngraph-onnx/blob/master/BUILDING.md
.. _
onnx_model_
zoo: https://github.com/onnx/models
.. _
ONNX model
zoo: https://github.com/onnx/models
doc/sphinx/source/index.rst
View file @
4b84262c
.. ---------------------------------------------------------------------------
.. Copyright 2018-2019 Intel Corporation
.. Copyright 2018-2019 Intel Corporation
.. Licensed under the Apache License, Version 2.0 (the "License");
.. Licensed under the Apache License, Version 2.0 (the "License");
.. you may not use this file except in compliance with the License.
.. you may not use this file except in compliance with the License.
...
...
doc/sphinx/source/inspection/index.rst
View file @
4b84262c
...
@@ -6,11 +6,11 @@ Visualization Tools
...
@@ -6,11 +6,11 @@ Visualization Tools
nGraph provides serialization and deserialization facilities, along with the
nGraph provides serialization and deserialization facilities, along with the
ability to create image formats or a PDF.
ability to create image formats or a PDF.
When visualization is enabled,
a ``dot`` file gets generated, along with a
When visualization is enabled,
``svg`` files for your graph get generated. The
``png``. The default can be adjusted by setting the
default can be adjusted by setting the ``NGRAPH_VISUALIZE_TRACING_FORMAT``
``NGRAPH_VISUALIZE_TREE_OUTPUT_FORMAT`` flag to another format, like
PDF.
flag to another format, like PNG or
PDF.
.. note:: Large graphs are usually not legible with formats like PDF.
.. note:: Large graphs are usually not legible with formats like PDF.
Large graphs may require additional work to get into a human-readable format.
Large graphs may require additional work to get into a human-readable format.
On the back end, very long edges will need to be cut to make (for example) a
On the back end, very long edges will need to be cut to make (for example) a
...
...
doc/sphinx/source/project/doc-contributor-README.rst
View file @
4b84262c
...
@@ -18,9 +18,36 @@
...
@@ -18,9 +18,36 @@
Contributing to documentation
Contributing to documentation
=============================
=============================
.. important:: Read this for changes affecting **anything** in ``ngraph/doc``
.. note:: Tips for contributors who are new to the highly-dynamic
environment of documentation in AI software:
For updates to the nGraph Library ``/doc`` repo, please submit a PR with
* A good place to start is "document something you figured out how to
get working". Content changes and additions should be targeted at
something more specific than "developers". If you don't understand
how varied and wide the audience is, you'll inadvertently break or block
things.
* There are experts who work on all parts of the stack; try asking how
documentation changes ought to be made in their respective sections.
* Start with something small. It is okay to add a "patch" to fix a typo
or suggest a word change; larger changes to files or structure require
research and testing first, as well as some logic for why you think
something needs changed.
* Most documentation should wrap at about ``80``. We do our best to help
authors source-link and maintain their own code and contributions;
overwriting something already documented doesn't always improve it.
* Be careful editing files with links already present in them; deleting
links to papers, citations, or sources is discouraged.
* Please do not submit Jupyter* notebook code to the nGraph Library
or core repos; best practice is to maintain any project-specific
examples, tests, or walk-throughs in a separate repository and to link
back to the stable ``op`` or Ops that you use in your project.
For updates within the 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 changes made, additions, deletions, and feature requests.
with respect to changes made, additions, deletions, and feature requests.
...
@@ -36,7 +63,6 @@ it for a specific use case. Add a note on our wiki to show us what you
...
@@ -36,7 +63,6 @@ it for a specific use case. Add a note on our wiki to show us what you
did; new and novel applications may have their projects highlighted on an
did; new and novel applications may have their projects highlighted on an
upcoming `ngraph.ai`_ release.
upcoming `ngraph.ai`_ release.
.. note:: Please do not submit Jupyter* notebook code to the nGraph Library
.. note:: Please do not submit Jupyter* notebook code to the nGraph Library
or core repos; best practice is to maintain any project-specific examples,
or core repos; best practice is to maintain any project-specific examples,
tests, or walk-throughs in a separate repository.
tests, or walk-throughs in a separate repository.
...
@@ -45,9 +71,11 @@ upcoming `ngraph.ai`_ release.
...
@@ -45,9 +71,11 @@ upcoming `ngraph.ai`_ release.
Documenting source code examples
Documenting source code examples
--------------------------------
--------------------------------
When **verbosely** documenting functionality of specific sections of code -- whether
When **verbosely** documenting functionality of specific sections of code --
they are entire code blocks within a file, or code strings that are **outside**
whether they are entire code blocks within a file, or code strings that are
the nGraph Library's `documentation repo`_, here is an example of best practice:
**outside** the nGraph Library's `documentation repo`_, here is an example
of best practice:
Say a file has some interesting functionality that could benefit from more
Say a file has some interesting functionality that could benefit from more
explanation about one or more of the pieces in context. To keep the "in context"
explanation about one or more of the pieces in context. To keep the "in context"
...
@@ -73,8 +101,7 @@ the folder where the ``Makefile`` is that generates the documentation you're
...
@@ -73,8 +101,7 @@ the folder where the ``Makefile`` is that generates the documentation you're
writing.
writing.
See the **note** at the bottom of this page for more detail about how
See the **note** at the bottom of this page for more detail about how
this works in the current |version| version of Intel nGraph library
this works in the current |version| version of nGraph Library documentation.
documentation.
Adding captions to code blocks
Adding captions to code blocks
...
...
doc/sphinx/source/project/release-notes.rst
View file @
4b84262c
...
@@ -6,34 +6,50 @@ Release Notes
...
@@ -6,34 +6,50 @@ Release Notes
nGraph is provided as source code, APIs, build scripts, and some binary formats
nGraph is provided as source code, APIs, build scripts, and some binary formats
for various Compiler stack configurations and use cases.
for various Compiler stack configurations and use cases.
For downloads formatted as ``.zip`` and ``tar.gz``, see
https://github.com/NervanaSystems/ngraph/releases.
This page includes additional documentation updates.
This page includes additional documentation updates.
We are pleased to announce the release of version |version|-doc.
We are pleased to announce the release of version |version|-doc.
0.21-doc
Core updates for |version|
--------
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Documentation updates
+ PlaidML support
~~~~~~~~~~~~~~~~~~~~~
+ More ONNX ops
+ Elementwise divide defaults to Python semantics
+ GenerateMask seed optional
Summary of documentation-related changes:
+ Update :doc:`doc-contributor-README` for new community-based contributions.
Latest doc updates
+ Added instructions on how to test or display the installed nGraph version.
~~~~~~~~~~~~~~~~~~
+ Added instructions on building nGraph bridge (ngraph-bridge).
+ Updated Backend Developer Guides and ToC structure.
+ Tested documentation build on Clear Linux OS; it works.
+ Fixed a few links and redirs affected by filename changes.
+ Some coding adjustments for options to render math symbols, so they can be
documented more clearly and without excessive JS (see replacements.txt).
+ Consistent filenaming on all BE indexes.
+ Remove deprecated TensorAPI.
+
+ Document new debug tool
+ Note deprecation of MXNet's ``ngraph-mxnet`` PyPI
+ Note default change to `svg` files for graphs and visualization
+ Add more prominent tips for contributors who find the doc-contributor-README
.. important:: Pre-releases (``-rc-0.*``) have newer features, and are less stable.
Changelog on Previous Releases
==============================
0.22
----
+ More ONNX ops
+ Optimizations
+ Don't reseed RNG on each use
+ Initial doc and API for IntelGPU backend
+ DynamicBackend API
Core updates for |version|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
0.21
----
+ The offset argument in tensor reads and writes has been removed
+ The offset argument in tensor reads and writes has been removed
+ Save/load API
+ Save/load API
...
@@ -43,17 +59,19 @@ Core updates for |version|
...
@@ -43,17 +59,19 @@ Core updates for |version|
+ Provenance improvements
+ Provenance improvements
+ offset arg for tensor creation is deprecated
+ offset arg for tensor creation is deprecated
+ static linking support
+ static linking support
+ Initial test of 0.21-doc
+ Updated :doc:`doc-contributor-README` for new community-based contributions.
+ Added instructions on how to test or display the installed nGraph version.
+ Added instructions on building nGraph bridge (ngraph-bridge).
+ Updated Backend Developer Guides and ToC structure.
+ Tested documentation build on Clear Linux OS; it works.
+ Fixed a few links and redirs affected by filename changes.
+ Some coding adjustments for options to render math symbols, so they can be
documented more clearly and without excessive JS (see replacements.txt).
+ Consistent filenaming on all BE indexes.
+ Removed deprecated TensorAPI.
.. important:: Pre-releases (``-rc-0.*``) have newer features, and are less stable.
Changelog on Previous Releases
==============================
For downloads formatted as ``.zip`` and ``tar.gz``, see
https://github.com/NervanaSystems/ngraph/releases.
0.20
0.20
----
----
...
@@ -67,8 +85,6 @@ https://github.com/NervanaSystems/ngraph/releases.
...
@@ -67,8 +85,6 @@ https://github.com/NervanaSystems/ngraph/releases.
0.19
0.19
----
----
**Download** `0.19.0-rc.2`_
+ More dynamic shape preparation
+ More dynamic shape preparation
+ Distributed interface factored out
+ Distributed interface factored out
+ fp16 and bfloat16 types
+ fp16 and bfloat16 types
...
@@ -88,9 +104,6 @@ https://github.com/NervanaSystems/ngraph/releases.
...
@@ -88,9 +104,6 @@ https://github.com/NervanaSystems/ngraph/releases.
0.18
0.18
----
----
**Download** `0.18.1`_
+ Python formatting issue
+ Python formatting issue
+ mkl-dnn work-around
+ mkl-dnn work-around
+ Event tracing improvements
+ Event tracing improvements
...
@@ -103,8 +116,6 @@ https://github.com/NervanaSystems/ngraph/releases.
...
@@ -103,8 +116,6 @@ https://github.com/NervanaSystems/ngraph/releases.
0.17
0.17
----
----
**Download** `0.17.0-rc.1`_
+ Allow negative padding in more places
+ Allow negative padding in more places
+ Add code generation for some quantized ops
+ Add code generation for some quantized ops
+ Preliminary dynamic shape support
+ Preliminary dynamic shape support
...
@@ -116,11 +127,6 @@ https://github.com/NervanaSystems/ngraph/releases.
...
@@ -116,11 +127,6 @@ https://github.com/NervanaSystems/ngraph/releases.
0.16
0.16
----
----
* **Download**: `0.16.0-rc.3`_
* **Download** `0.16.0-rc.2`_
* **Download** `0.16.0-rc.1`_
+ NodeInput and NodeOutput classes prepare for simplifications of Node
+ NodeInput and NodeOutput classes prepare for simplifications of Node
+ Test improvements
+ Test improvements
+ Additional quantization ops
+ Additional quantization ops
...
@@ -128,11 +134,3 @@ https://github.com/NervanaSystems/ngraph/releases.
...
@@ -128,11 +134,3 @@ https://github.com/NervanaSystems/ngraph/releases.
+ Fix memory leak
+ Fix memory leak
+ Concat optimization
+ Concat optimization
+ Doc updates
+ Doc updates
.. _0.20.0-rc.0: https://github.com/NervanaSystems/ngraph/releases/tag/v0.20.0-rc.0_
.. _0.19.0-rc.2: https://github.com/NervanaSystems/ngraph/releases/tag/v0.19.0-rc.2_
.. _0.18.1: https://github.com/NervanaSystems/ngraph/releases/tag/v0.18.1_
.. _0.17.0-rc.1: `https://github.com/NervanaSystems/ngraph/releases/tag/v0.17.0-rc.1
.. _0.16.0-rc.3: https://github.com/NervanaSystems/ngraph/releases/tag/v0.16.0-rc.3
.. _0.16.0-rc.2: https://github.com/NervanaSystems/ngraph/releases/tag/v0.16.0-rc.2
.. _0.16.0-rc.1: https://github.com/NervanaSystems/ngraph/releases/tag/v0.16.0-rc.1
python/BUILDING.md
View file @
4b84262c
...
@@ -2,10 +2,10 @@
...
@@ -2,10 +2,10 @@
## Building nGraph Python Wheels
## Building nGraph Python Wheels
If you want to try a newer version of nGraph's Python API than is available
from
If you want to try a newer version of nGraph's Python API than is available
PyPI, you can build your own latest version from the source code. Th
is
from PyPI, you can build the latest version from source code. This process
is
process is very similar to what is outlined in our
[
ngraph_build
]
instructions
very similar to what is outlined in our
[
ngraph_build
]
instructions with two
with two
important differences:
important differences:
1.
You must specify:
`-DNGRAPH_PYTHON_BUILD_ENABLE=ON`
and
`-DNGRAPH_ONNX_IMPORT_ENABLE=ON`
1.
You must specify:
`-DNGRAPH_PYTHON_BUILD_ENABLE=ON`
and
`-DNGRAPH_ONNX_IMPORT_ENABLE=ON`
when running
`cmake`
.
when running
`cmake`
.
...
@@ -18,7 +18,7 @@ with two important differences:
...
@@ -18,7 +18,7 @@ with two important differences:
After this procedure completes, the
`ngraph/build/python/dist`
directory should
After this procedure completes, the
`ngraph/build/python/dist`
directory should
contain the Python packages of the version you cloned. For example, if you
contain the Python packages of the version you cloned. For example, if you
checked out and built
`0.21`
, you may
see something like:
checked out and built
`0.21`
for Python 3.7, you might
see something like:
$ ls python/dist/
$ ls python/dist/
ngraph-core-0.21.0rc0.tar.gz
ngraph-core-0.21.0rc0.tar.gz
...
...
python/README.md
View file @
4b84262c
...
@@ -18,8 +18,8 @@ boost compared to native implementations.
...
@@ -18,8 +18,8 @@ boost compared to native implementations.
nGraph can be used directly with the
[
Python API
][
api_python
]
described here, or
nGraph can be used directly with the
[
Python API
][
api_python
]
described here, or
with the
[
C++ API
][
api_cpp
]
described in the
[
core documentation
]
. Alternatively,
with the
[
C++ API
][
api_cpp
]
described in the
[
core documentation
]
. Alternatively,
its performance benefits can be realized through
a frontend
such as
its performance benefits can be realized through
frontends
such as
[
TensorFlow
][
frontend_tf
]
,
[
MXNet
][
frontend_mxnet
]
,
and
[
ONNX
][
frontend_onnx
]
.
[
TensorFlow
][
frontend_tf
]
,
[
PaddlePaddle
][
paddle_paddle
]
and
[
ONNX
][
frontend_onnx
]
.
You can also create your own custom framework to integrate directly with the
You can also create your own custom framework to integrate directly with the
[
nGraph Ops
]
for highly-targeted graph execution.
[
nGraph Ops
]
for highly-targeted graph execution.
...
@@ -77,7 +77,7 @@ print('Result = ', result)
...
@@ -77,7 +77,7 @@ print('Result = ', result)
[
up to 45X
]:
https://ai.intel.com/ngraph-compiler-stack-beta-release/
[
up to 45X
]:
https://ai.intel.com/ngraph-compiler-stack-beta-release/
[
frontend_onnx
]:
https://pypi.org/project/ngraph-onnx/
[
frontend_onnx
]:
https://pypi.org/project/ngraph-onnx/
[
frontend_mxnet
]:
https://pypi.org/project/ngraph-mxnet/
[
paddle_paddle
]:
https://ngraph.nervanasys.com/docs/latest/frameworks/paddle_integ.html
[
frontend_tf
]:
https://pypi.org/project/ngraph-tensorflow-bridge/
[
frontend_tf
]:
https://pypi.org/project/ngraph-tensorflow-bridge/
[
ngraph_github
]:
https://github.com/NervanaSystems/ngraph
"nGraph on GitHub"
[
ngraph_github
]:
https://github.com/NervanaSystems/ngraph
"nGraph on GitHub"
[
ngraph_building
]:
https://github.com/NervanaSystems/ngraph/blob/master/python/BUILDING.md
"Building nGraph"
[
ngraph_building
]:
https://github.com/NervanaSystems/ngraph/blob/master/python/BUILDING.md
"Building nGraph"
...
...
src/ngraph/CMakeLists.txt
View file @
4b84262c
...
@@ -370,7 +370,6 @@ set (SRC
...
@@ -370,7 +370,6 @@ set (SRC
op/util/index_reduction.hpp
op/util/index_reduction.hpp
op/util/logical_reduction.cpp
op/util/logical_reduction.cpp
op/util/logical_reduction.hpp
op/util/logical_reduction.hpp
op/util/reshape.hpp
op/util/rnn_cell_base.cpp
op/util/rnn_cell_base.cpp
op/util/rnn_cell_base.hpp
op/util/rnn_cell_base.hpp
op/util/unary_elementwise_arithmetic.cpp
op/util/unary_elementwise_arithmetic.cpp
...
@@ -458,6 +457,8 @@ set (SRC
...
@@ -458,6 +457,8 @@ set (SRC
rank.hpp
rank.hpp
runtime/aligned_buffer.cpp
runtime/aligned_buffer.cpp
runtime/aligned_buffer.hpp
runtime/aligned_buffer.hpp
runtime/allocator.cpp
runtime/allocator.hpp
runtime/backend.cpp
runtime/backend.cpp
runtime/backend.hpp
runtime/backend.hpp
runtime/backend_manager.cpp
runtime/backend_manager.cpp
...
...
src/ngraph/distributed.cpp
View file @
4b84262c
...
@@ -46,7 +46,7 @@ static std::unique_ptr<DistributedInterface> s_distributed_interface;
...
@@ -46,7 +46,7 @@ static std::unique_ptr<DistributedInterface> s_distributed_interface;
void
ngraph
::
set_distributed_interface
(
std
::
unique_ptr
<
DistributedInterface
>
distributed_interface
)
void
ngraph
::
set_distributed_interface
(
std
::
unique_ptr
<
DistributedInterface
>
distributed_interface
)
{
{
NGRAPH_DEBUG
<<
"Setting distributed interf
s
ce to: "
<<
distributed_interface
->
get_name
();
NGRAPH_DEBUG
<<
"Setting distributed interf
a
ce to: "
<<
distributed_interface
->
get_name
();
s_distributed_interface
=
std
::
move
(
distributed_interface
);
s_distributed_interface
=
std
::
move
(
distributed_interface
);
}
}
...
...
src/ngraph/op/fused/group_conv_transpose.cpp
View file @
4b84262c
...
@@ -203,7 +203,8 @@ shared_ptr<Node> op::GroupConvolutionTranspose::copy_with_new_args(const NodeVec
...
@@ -203,7 +203,8 @@ shared_ptr<Node> op::GroupConvolutionTranspose::copy_with_new_args(const NodeVec
get_padding_end
(),
get_padding_end
(),
get_output_padding
(),
get_output_padding
(),
get_groups
(),
get_groups
(),
get_pad_type
());
get_pad_type
(),
get_output_shape
());
}
}
Shape
op
::
GroupConvolutionTranspose
::
get_data_batch_shape
()
const
Shape
op
::
GroupConvolutionTranspose
::
get_data_batch_shape
()
const
...
...
src/ngraph/op/util/reshape.hpp
deleted
100644 → 0
View file @
098b73c1
//*****************************************************************************
// Copyright 2017-2019 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.
//*****************************************************************************
#pragma once
#include <cstddef>
#include <memory>
#include <vector>
#include "ngraph/builder/reshape.hpp"
#include "ngraph/node.hpp"
#include "ngraph/shape.hpp"
namespace
ngraph
{
namespace
op
{
namespace
util
{
/// \brief Change shape of input tensor.
///
/// \param[in] node The node producing the tensor to be reshaped.
/// \param[in] shape The new shape for input tensor.
///
/// \return The node representing a Reshape operation.
///
std
::
shared_ptr
<
ngraph
::
Node
>
reshape
(
const
std
::
shared_ptr
<
ngraph
::
Node
>&
node
,
const
Shape
&
shape
)
{
return
builder
::
reshape
(
node
,
shape
);
}
/// \brief Permute axes according to specified axes_order parameter.
///
/// \param node The node which axes we want to permute.
/// \param axes_order The permutation of node tensor axes.
///
/// \return: New node with permuted axes.
std
::
shared_ptr
<
ngraph
::
Node
>
reorder_axes
(
const
std
::
shared_ptr
<
ngraph
::
Node
>&
node
,
std
::
vector
<
std
::
size_t
>
axes_order
)
{
return
builder
::
reorder_axes
(
node
,
axes_order
);
}
/// \brief Return transposed tensor (with axes in reversed order).
///
/// \param node Input tensor we want to transpose
///
/// \return: New node with reversed dimensions.
std
::
shared_ptr
<
ngraph
::
Node
>
transpose
(
const
std
::
shared_ptr
<
ngraph
::
Node
>&
node
)
{
return
builder
::
transpose
(
node
);
}
/// \brief Flatten the input tensor into a 2D matrix.
///
/// \param node The tensor to be flattened.
/// \param axis The axis dividing shape.
///
/// \return The new node will be a 2D matrix representing the flattened input node.
std
::
shared_ptr
<
ngraph
::
Node
>
flatten
(
const
std
::
shared_ptr
<
ngraph
::
Node
>&
node
,
int
axis
)
{
return
builder
::
flatten
(
node
,
axis
);
}
}
// namespace util
}
// namespace op
}
// namespace ngraph
src/ngraph/runtime/aligned_buffer.cpp
View file @
4b84262c
...
@@ -18,22 +18,34 @@
...
@@ -18,22 +18,34 @@
#include <memory>
#include <memory>
#include "ngraph/runtime/aligned_buffer.hpp"
#include "ngraph/runtime/aligned_buffer.hpp"
#include "ngraph/runtime/allocator.hpp"
#include "ngraph/util.hpp"
#include "ngraph/util.hpp"
using
namespace
ngraph
;
using
namespace
ngraph
;
using
namespace
std
;
runtime
::
AlignedBuffer
::
AlignedBuffer
()
runtime
::
AlignedBuffer
::
AlignedBuffer
()
:
m_allocated_buffer
(
nullptr
)
:
m_allocator
(
nullptr
)
,
m_allocated_buffer
(
nullptr
)
,
m_aligned_buffer
(
nullptr
)
,
m_aligned_buffer
(
nullptr
)
,
m_byte_size
(
0
)
,
m_byte_size
(
0
)
{
{
}
}
runtime
::
AlignedBuffer
::
AlignedBuffer
(
size_t
byte_size
,
size_t
alignment
)
runtime
::
AlignedBuffer
::
AlignedBuffer
(
size_t
byte_size
,
size_t
alignment
,
Allocator
*
allocator
)
:
m_allocator
(
allocator
)
,
m_byte_size
(
byte_size
)
{
{
m_byte_size
=
std
::
max
<
size_t
>
(
1
,
byte_size
);
m_byte_size
=
std
::
max
<
size_t
>
(
1
,
byte_size
);
size_t
allocation_size
=
m_byte_size
+
alignment
;
size_t
allocation_size
=
m_byte_size
+
alignment
;
m_allocated_buffer
=
static_cast
<
char
*>
(
ngraph_malloc
(
allocation_size
));
if
(
allocator
)
{
m_allocated_buffer
=
static_cast
<
char
*>
(
m_allocator
->
malloc
(
allocation_size
,
alignment
));
}
else
{
m_allocated_buffer
=
static_cast
<
char
*>
(
malloc
(
allocation_size
));
}
m_aligned_buffer
=
m_allocated_buffer
;
m_aligned_buffer
=
m_allocated_buffer
;
size_t
mod
=
size_t
(
m_aligned_buffer
)
%
alignment
;
size_t
mod
=
size_t
(
m_aligned_buffer
)
%
alignment
;
...
@@ -44,10 +56,12 @@ runtime::AlignedBuffer::AlignedBuffer(size_t byte_size, size_t alignment)
...
@@ -44,10 +56,12 @@ runtime::AlignedBuffer::AlignedBuffer(size_t byte_size, size_t alignment)
}
}
runtime
::
AlignedBuffer
::
AlignedBuffer
(
AlignedBuffer
&&
other
)
runtime
::
AlignedBuffer
::
AlignedBuffer
(
AlignedBuffer
&&
other
)
:
m_allocated_buffer
(
other
.
m_allocated_buffer
)
:
m_allocator
(
other
.
m_allocator
)
,
m_allocated_buffer
(
other
.
m_allocated_buffer
)
,
m_aligned_buffer
(
other
.
m_aligned_buffer
)
,
m_aligned_buffer
(
other
.
m_aligned_buffer
)
,
m_byte_size
(
other
.
m_byte_size
)
,
m_byte_size
(
other
.
m_byte_size
)
{
{
other
.
m_allocator
=
nullptr
;
other
.
m_allocated_buffer
=
nullptr
;
other
.
m_allocated_buffer
=
nullptr
;
other
.
m_aligned_buffer
=
nullptr
;
other
.
m_aligned_buffer
=
nullptr
;
other
.
m_byte_size
=
0
;
other
.
m_byte_size
=
0
;
...
@@ -57,7 +71,14 @@ runtime::AlignedBuffer::~AlignedBuffer()
...
@@ -57,7 +71,14 @@ runtime::AlignedBuffer::~AlignedBuffer()
{
{
if
(
m_allocated_buffer
!=
nullptr
)
if
(
m_allocated_buffer
!=
nullptr
)
{
{
ngraph_free
(
m_allocated_buffer
);
if
(
m_allocator
)
{
m_allocator
->
free
(
m_allocated_buffer
);
}
else
{
free
(
m_allocated_buffer
);
}
}
}
}
}
...
@@ -65,9 +86,11 @@ runtime::AlignedBuffer& runtime::AlignedBuffer::operator=(AlignedBuffer&& other)
...
@@ -65,9 +86,11 @@ runtime::AlignedBuffer& runtime::AlignedBuffer::operator=(AlignedBuffer&& other)
{
{
if
(
this
!=
&
other
)
if
(
this
!=
&
other
)
{
{
m_allocator
=
other
.
m_allocator
;
m_allocated_buffer
=
other
.
m_allocated_buffer
;
m_allocated_buffer
=
other
.
m_allocated_buffer
;
m_aligned_buffer
=
other
.
m_aligned_buffer
;
m_aligned_buffer
=
other
.
m_aligned_buffer
;
m_byte_size
=
other
.
m_byte_size
;
m_byte_size
=
other
.
m_byte_size
;
other
.
m_allocator
=
nullptr
;
other
.
m_allocated_buffer
=
nullptr
;
other
.
m_allocated_buffer
=
nullptr
;
other
.
m_aligned_buffer
=
nullptr
;
other
.
m_aligned_buffer
=
nullptr
;
other
.
m_byte_size
=
0
;
other
.
m_byte_size
=
0
;
...
...
src/ngraph/runtime/aligned_buffer.hpp
View file @
4b84262c
...
@@ -18,6 +18,8 @@
...
@@ -18,6 +18,8 @@
#include <cstddef>
#include <cstddef>
#include "ngraph/runtime/allocator.hpp"
namespace
ngraph
namespace
ngraph
{
{
namespace
runtime
namespace
runtime
...
@@ -32,7 +34,11 @@ namespace ngraph
...
@@ -32,7 +34,11 @@ namespace ngraph
class
ngraph
::
runtime
::
AlignedBuffer
class
ngraph
::
runtime
::
AlignedBuffer
{
{
public
:
public
:
AlignedBuffer
(
size_t
byte_size
,
size_t
alignment
);
// Allocator objects and the allocation interfaces are owned by the
// creators of AlignedBuffers. They need to ensure that the lifetime of
// allocator exceeds the lifetime of this AlignedBuffer.
AlignedBuffer
(
size_t
byte_size
,
size_t
alignment
,
Allocator
*
allocator
=
nullptr
);
AlignedBuffer
();
AlignedBuffer
();
~
AlignedBuffer
();
~
AlignedBuffer
();
...
@@ -46,6 +52,7 @@ private:
...
@@ -46,6 +52,7 @@ private:
AlignedBuffer
(
const
AlignedBuffer
&
)
=
delete
;
AlignedBuffer
(
const
AlignedBuffer
&
)
=
delete
;
AlignedBuffer
&
operator
=
(
const
AlignedBuffer
&
)
=
delete
;
AlignedBuffer
&
operator
=
(
const
AlignedBuffer
&
)
=
delete
;
Allocator
*
m_allocator
;
char
*
m_allocated_buffer
;
char
*
m_allocated_buffer
;
char
*
m_aligned_buffer
;
char
*
m_aligned_buffer
;
size_t
m_byte_size
;
size_t
m_byte_size
;
...
...
src/ngraph/runtime/allocator.cpp
0 → 100644
View file @
4b84262c
//*****************************************************************************
// Copyright 2017-2019 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include "ngraph/runtime/allocator.hpp"
ngraph
::
runtime
::
Allocator
::~
Allocator
()
{
}
class
ngraph
::
runtime
::
DefaultAllocator
:
public
ngraph
::
runtime
::
Allocator
{
public
:
void
*
malloc
(
size_t
size
,
size_t
alignment
)
{
// If allocation succeeds, returns a pointer to the lowest (first) byte in the
// allocated memory block that is suitably aligned for any scalar type.
// TODO(pruthvi): replace std::malloc with custom aligned_alloc implementation
// which is portable and work on all alignment requirement.
void
*
ptr
=
std
::
malloc
(
size
);
// check for exception
if
(
!
ptr
)
{
throw
ngraph
::
ngraph_error
(
"malloc failed to allocate memory of size "
+
std
::
to_string
(
size
));
}
return
ptr
;
}
void
free
(
void
*
ptr
)
{
if
(
ptr
)
{
std
::
free
(
ptr
);
}
}
};
std
::
unique_ptr
<
ngraph
::
runtime
::
Allocator
>
ngraph
::
runtime
::
create_default_allocator
()
{
return
std
::
unique_ptr
<
DefaultAllocator
>
(
new
DefaultAllocator
());
}
src/ngraph/runtime/allocator.hpp
0 → 100644
View file @
4b84262c
//*****************************************************************************
// Copyright 2017-2019 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.
//*****************************************************************************
#pragma once
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include "ngraph/except.hpp"
#include "ngraph/util.hpp"
namespace
ngraph
{
namespace
runtime
{
class
Allocator
;
class
DefaultAllocator
;
/// \brief Create a default allocator that calls into system
/// allocation libraries
std
::
unique_ptr
<
Allocator
>
create_default_allocator
();
}
}
/// \brief Abstract class for the allocator
class
ngraph
::
runtime
::
Allocator
{
public
:
virtual
~
Allocator
()
=
0
;
/// \brief allocates memory with the given size and alignment requirement
/// \param size exact size of bytes to allocate
/// \param alignment specifies the alignment. Must be a valid alignment supported by the implementation.
virtual
void
*
malloc
(
size_t
size
,
size_t
alignment
)
=
0
;
/// \brief deallocates the memory pointed by ptr
/// \param ptr pointer to the aligned memory to be released
virtual
void
free
(
void
*
ptr
)
=
0
;
};
src/ngraph/runtime/backend.cpp
View file @
4b84262c
...
@@ -93,6 +93,13 @@ void runtime::Backend::remove_compiled_function(std::shared_ptr<Executable> exec
...
@@ -93,6 +93,13 @@ void runtime::Backend::remove_compiled_function(std::shared_ptr<Executable> exec
{
{
}
}
bool
runtime
::
Backend
::
is_device_memory
(
void
*
ptr
)
{
// override this method for each supported backend to determine if the passed pointer is in
// device pinned memory or not
return
false
;
}
std
::
shared_ptr
<
runtime
::
Executable
>
runtime
::
Backend
::
load
(
istream
&
input_stream
)
std
::
shared_ptr
<
runtime
::
Executable
>
runtime
::
Backend
::
load
(
istream
&
input_stream
)
{
{
throw
runtime_error
(
"load opertion unimplemented."
);
throw
runtime_error
(
"load opertion unimplemented."
);
...
...
src/ngraph/runtime/backend.hpp
View file @
4b84262c
...
@@ -21,10 +21,12 @@
...
@@ -21,10 +21,12 @@
#include "ngraph/function.hpp"
#include "ngraph/function.hpp"
#include "ngraph/pass/pass_config.hpp"
#include "ngraph/pass/pass_config.hpp"
#include "ngraph/runtime/allocator.hpp"
#include "ngraph/runtime/executable.hpp"
#include "ngraph/runtime/executable.hpp"
#include "ngraph/runtime/performance_counter.hpp"
#include "ngraph/runtime/performance_counter.hpp"
#include "ngraph/shape.hpp"
#include "ngraph/shape.hpp"
#include "ngraph/type/element_type.hpp"
#include "ngraph/type/element_type.hpp"
#include "ngraph/util.hpp"
namespace
ngraph
namespace
ngraph
{
{
...
@@ -142,6 +144,23 @@ public:
...
@@ -142,6 +144,23 @@ public:
/// \returns a shared pointer to the op if found, else nullptr
/// \returns a shared pointer to the op if found, else nullptr
virtual
std
::
shared_ptr
<
ngraph
::
Node
>
get_backend_op
(
const
std
::
string
&
op_name
,
...);
virtual
std
::
shared_ptr
<
ngraph
::
Node
>
get_backend_op
(
const
std
::
string
&
op_name
,
...);
/// \brief Returns memory allocator used by backend for host allocations
virtual
Allocator
*
get_host_memory_allocator
()
{
return
nullptr
;
}
/// \brief Set the host memory allocator to be used by the backend
/// \param allocator is pointer to host memory allocator object
virtual
void
set_host_memory_allocator
(
std
::
unique_ptr
<
Allocator
>
allocator
)
{}
/// \brief Returns memory allocator used by backend for device allocations
virtual
Allocator
*
get_device_memory_allocator
()
{
// override this method from each supported backend to return
// its own device memory allocator
return
nullptr
;
}
/// \brief method for each supported backend to determine if the passed pointer is in device pinned memory or not
/// \param ptr pointer to the memory to determine if its in device memory or not
virtual
bool
is_device_memory
(
void
*
ptr
);
/// \brief Allows sending backend specific configuration. The map contains key, value pairs
/// \brief Allows sending backend specific configuration. The map contains key, value pairs
/// specific to a particluar backend. The definition of these key, value pairs is
/// specific to a particluar backend. The definition of these key, value pairs is
/// defined by each backend.
/// defined by each backend.
...
...
src/ngraph/runtime/cpu/cpu_backend.cpp
View file @
4b84262c
...
@@ -63,11 +63,17 @@ namespace
...
@@ -63,11 +63,17 @@ namespace
}
s_cpu_static_init
;
}
s_cpu_static_init
;
}
}
runtime
::
cpu
::
CPU_Backend
::~
CPU_Backend
()
{
m_exec_map
.
clear
();
}
shared_ptr
<
runtime
::
cpu
::
CPU_CallFrame
>
runtime
::
cpu
::
CPU_Backend
::
make_call_frame
(
shared_ptr
<
runtime
::
cpu
::
CPU_CallFrame
>
runtime
::
cpu
::
CPU_Backend
::
make_call_frame
(
const
shared_ptr
<
runtime
::
cpu
::
CPU_ExternalFunction
>&
external_function
,
const
shared_ptr
<
runtime
::
cpu
::
CPU_ExternalFunction
>&
external_function
,
ngraph
::
pass
::
PassConfig
&
pass_config
)
ngraph
::
pass
::
PassConfig
&
pass_config
,
Allocator
*
allocator
)
{
{
return
external_function
->
make_call_frame
(
pass_config
);
return
external_function
->
make_call_frame
(
pass_config
,
allocator
);
}
}
shared_ptr
<
runtime
::
Tensor
>
shared_ptr
<
runtime
::
Tensor
>
...
@@ -114,7 +120,8 @@ shared_ptr<runtime::Executable>
...
@@ -114,7 +120,8 @@ shared_ptr<runtime::Executable>
return
rc
;
return
rc
;
}
}
}
}
rc
=
make_shared
<
CPU_Executable
>
(
func
,
pass_config
,
performance_counters_enabled
);
rc
=
make_shared
<
CPU_Executable
>
(
func
,
pass_config
,
get_host_memory_allocator
(),
performance_counters_enabled
);
{
{
std
::
lock_guard
<
std
::
mutex
>
guard
(
m_exec_map_mutex
);
std
::
lock_guard
<
std
::
mutex
>
guard
(
m_exec_map_mutex
);
m_exec_map
.
insert
({
func
,
rc
});
m_exec_map
.
insert
({
func
,
rc
});
...
@@ -124,6 +131,7 @@ shared_ptr<runtime::Executable>
...
@@ -124,6 +131,7 @@ shared_ptr<runtime::Executable>
runtime
::
cpu
::
CPU_Executable
::
CPU_Executable
(
shared_ptr
<
Function
>
func
,
runtime
::
cpu
::
CPU_Executable
::
CPU_Executable
(
shared_ptr
<
Function
>
func
,
ngraph
::
pass
::
PassConfig
&
pass_config
,
ngraph
::
pass
::
PassConfig
&
pass_config
,
Allocator
*
allocator
,
bool
performance_counters_enabled
)
bool
performance_counters_enabled
)
{
{
FunctionInstance
&
instance
=
m_function_instance
;
FunctionInstance
&
instance
=
m_function_instance
;
...
@@ -131,7 +139,7 @@ runtime::cpu::CPU_Executable::CPU_Executable(shared_ptr<Function> func,
...
@@ -131,7 +139,7 @@ runtime::cpu::CPU_Executable::CPU_Executable(shared_ptr<Function> func,
{
{
instance
.
m_external_function
=
make_shared
<
CPU_ExternalFunction
>
(
func
);
instance
.
m_external_function
=
make_shared
<
CPU_ExternalFunction
>
(
func
);
instance
.
m_external_function
->
m_emit_timing
=
performance_counters_enabled
;
instance
.
m_external_function
->
m_emit_timing
=
performance_counters_enabled
;
auto
cf
=
instance
.
m_external_function
->
make_call_frame
(
pass_config
);
auto
cf
=
instance
.
m_external_function
->
make_call_frame
(
pass_config
,
allocator
);
instance
.
m_call_frame
=
dynamic_pointer_cast
<
CPU_CallFrame
>
(
cf
);
instance
.
m_call_frame
=
dynamic_pointer_cast
<
CPU_CallFrame
>
(
cf
);
}
}
set_parameters_and_results
(
*
func
);
set_parameters_and_results
(
*
func
);
...
@@ -173,6 +181,28 @@ void runtime::cpu::CPU_Backend::remove_compiled_function(shared_ptr<Executable>
...
@@ -173,6 +181,28 @@ void runtime::cpu::CPU_Backend::remove_compiled_function(shared_ptr<Executable>
}
}
}
}
runtime
::
Allocator
*
runtime
::
cpu
::
CPU_Backend
::
get_host_memory_allocator
()
{
if
(
!
m_allocator
)
{
m_allocator
=
create_default_allocator
();
}
return
m_allocator
.
get
();
}
void
runtime
::
cpu
::
CPU_Backend
::
set_host_memory_allocator
(
std
::
unique_ptr
<
runtime
::
Allocator
>
allocator
)
{
if
(
m_allocator
)
{
// Resources allocated with the existing allocator might still be around and expect it
// to be available for freeing. We cannot switch to the new allocator
throw
ngraph_error
(
"Allocator already exists. Changing allocators mid-execution is not permitted."
);
}
m_allocator
=
std
::
move
(
allocator
);
}
vector
<
runtime
::
PerformanceCounter
>
runtime
::
cpu
::
CPU_Executable
::
get_performance_data
()
const
vector
<
runtime
::
PerformanceCounter
>
runtime
::
cpu
::
CPU_Executable
::
get_performance_data
()
const
{
{
vector
<
runtime
::
PerformanceCounter
>
rc
;
vector
<
runtime
::
PerformanceCounter
>
rc
;
...
@@ -190,6 +220,7 @@ bool runtime::cpu::CPU_Backend::is_supported(const Node& op) const
...
@@ -190,6 +220,7 @@ bool runtime::cpu::CPU_Backend::is_supported(const Node& op) const
{
{
return
true
;
return
true
;
}
}
bool
runtime
::
cpu
::
CPU_Backend
::
is_supported_property
(
const
Property
prop
)
const
bool
runtime
::
cpu
::
CPU_Backend
::
is_supported_property
(
const
Property
prop
)
const
{
{
if
(
prop
==
Property
::
memory_attach
)
if
(
prop
==
Property
::
memory_attach
)
...
...
src/ngraph/runtime/cpu/cpu_backend.hpp
View file @
4b84262c
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include "cpu_backend_visibility.h"
#include "cpu_backend_visibility.h"
#include "ngraph/pass/pass_config.hpp"
#include "ngraph/pass/pass_config.hpp"
#include "ngraph/runtime/allocator.hpp"
#include "ngraph/runtime/backend.hpp"
#include "ngraph/runtime/backend.hpp"
namespace
ngraph
namespace
ngraph
...
@@ -36,9 +37,12 @@ namespace ngraph
...
@@ -36,9 +37,12 @@ namespace ngraph
class
CPU_BACKEND_API
CPU_Backend
:
public
runtime
::
Backend
class
CPU_BACKEND_API
CPU_Backend
:
public
runtime
::
Backend
{
{
public
:
public
:
~
CPU_Backend
()
override
;
std
::
shared_ptr
<
CPU_CallFrame
>
std
::
shared_ptr
<
CPU_CallFrame
>
make_call_frame
(
const
std
::
shared_ptr
<
CPU_ExternalFunction
>&
external_function
,
make_call_frame
(
const
std
::
shared_ptr
<
CPU_ExternalFunction
>&
external_function
,
ngraph
::
pass
::
PassConfig
&
pass_config
);
ngraph
::
pass
::
PassConfig
&
pass_config
,
Allocator
*
allocator
);
std
::
shared_ptr
<
ngraph
::
runtime
::
Tensor
>
std
::
shared_ptr
<
ngraph
::
runtime
::
Tensor
>
create_tensor
(
const
ngraph
::
element
::
Type
&
element_type
,
create_tensor
(
const
ngraph
::
element
::
Type
&
element_type
,
...
@@ -60,6 +64,9 @@ namespace ngraph
...
@@ -60,6 +64,9 @@ namespace ngraph
void
remove_compiled_function
(
std
::
shared_ptr
<
Executable
>
exec
)
override
;
void
remove_compiled_function
(
std
::
shared_ptr
<
Executable
>
exec
)
override
;
Allocator
*
get_host_memory_allocator
()
override
;
void
set_host_memory_allocator
(
std
::
unique_ptr
<
Allocator
>
allocator
)
override
;
bool
is_supported
(
const
Node
&
node
)
const
override
;
bool
is_supported
(
const
Node
&
node
)
const
override
;
bool
is_supported_property
(
const
Property
prop
)
const
override
;
bool
is_supported_property
(
const
Property
prop
)
const
override
;
...
@@ -69,6 +76,7 @@ namespace ngraph
...
@@ -69,6 +76,7 @@ namespace ngraph
std
::
mutex
m_exec_map_mutex
;
std
::
mutex
m_exec_map_mutex
;
std
::
unordered_map
<
std
::
shared_ptr
<
Function
>
,
std
::
shared_ptr
<
Executable
>>
std
::
unordered_map
<
std
::
shared_ptr
<
Function
>
,
std
::
shared_ptr
<
Executable
>>
m_exec_map
;
m_exec_map
;
std
::
unique_ptr
<
Allocator
>
m_allocator
;
};
};
class
CPU_BACKEND_API
CPU_Executable
:
public
runtime
::
Executable
class
CPU_BACKEND_API
CPU_Executable
:
public
runtime
::
Executable
...
@@ -76,6 +84,7 @@ namespace ngraph
...
@@ -76,6 +84,7 @@ namespace ngraph
public
:
public
:
CPU_Executable
(
std
::
shared_ptr
<
Function
>
func
,
CPU_Executable
(
std
::
shared_ptr
<
Function
>
func
,
ngraph
::
pass
::
PassConfig
&
pass_config
,
ngraph
::
pass
::
PassConfig
&
pass_config
,
Allocator
*
allocator
,
bool
performance_counters_enabled
);
bool
performance_counters_enabled
);
bool
call
(
const
std
::
vector
<
std
::
shared_ptr
<
runtime
::
Tensor
>>&
outputs
,
bool
call
(
const
std
::
vector
<
std
::
shared_ptr
<
runtime
::
Tensor
>>&
outputs
,
const
std
::
vector
<
std
::
shared_ptr
<
runtime
::
Tensor
>>&
inputs
)
override
;
const
std
::
vector
<
std
::
shared_ptr
<
runtime
::
Tensor
>>&
inputs
)
override
;
...
...
src/ngraph/runtime/cpu/cpu_call_frame.cpp
View file @
4b84262c
...
@@ -30,7 +30,8 @@ using namespace ngraph;
...
@@ -30,7 +30,8 @@ using namespace ngraph;
runtime
::
cpu
::
CPU_CallFrame
::
CPU_CallFrame
(
std
::
shared_ptr
<
CPU_ExternalFunction
>
external_function
,
runtime
::
cpu
::
CPU_CallFrame
::
CPU_CallFrame
(
std
::
shared_ptr
<
CPU_ExternalFunction
>
external_function
,
InitContextFuncCG
compiled_init_ctx_func
,
InitContextFuncCG
compiled_init_ctx_func
,
DestroyContextFuncCG
compiled_destroy_ctx_func
,
DestroyContextFuncCG
compiled_destroy_ctx_func
,
EntryPoint
compiled_function
)
EntryPoint
compiled_function
,
runtime
::
Allocator
*
allocator
)
:
m_external_function
(
external_function
)
:
m_external_function
(
external_function
)
,
m_compiled_init_ctx_func
(
compiled_init_ctx_func
)
,
m_compiled_init_ctx_func
(
compiled_init_ctx_func
)
,
m_compiled_destroy_ctx_func
(
compiled_destroy_ctx_func
)
,
m_compiled_destroy_ctx_func
(
compiled_destroy_ctx_func
)
...
@@ -47,7 +48,7 @@ runtime::cpu::CPU_CallFrame::CPU_CallFrame(std::shared_ptr<CPU_ExternalFunction>
...
@@ -47,7 +48,7 @@ runtime::cpu::CPU_CallFrame::CPU_CallFrame(std::shared_ptr<CPU_ExternalFunction>
std
::
to_string
(
std
::
thread
::
hardware_concurrency
())
+
"]"
);
std
::
to_string
(
std
::
thread
::
hardware_concurrency
())
+
"]"
);
}
}
setup_runtime_context
();
setup_runtime_context
(
allocator
);
if
(
!
m_external_function
->
is_direct_execution
())
if
(
!
m_external_function
->
is_direct_execution
())
{
{
// Invoke codegen runtime context initialization function.
// Invoke codegen runtime context initialization function.
...
@@ -178,7 +179,7 @@ void runtime::cpu::CPU_CallFrame::propagate_layouts(
...
@@ -178,7 +179,7 @@ void runtime::cpu::CPU_CallFrame::propagate_layouts(
}
}
}
}
void
runtime
::
cpu
::
CPU_CallFrame
::
setup_runtime_context
()
void
runtime
::
cpu
::
CPU_CallFrame
::
setup_runtime_context
(
Allocator
*
allocator
)
{
{
for
(
auto
i
=
0
;
i
<
m_num_ctx
;
i
++
)
for
(
auto
i
=
0
;
i
<
m_num_ctx
;
i
++
)
{
{
...
@@ -202,7 +203,7 @@ void runtime::cpu::CPU_CallFrame::setup_runtime_context()
...
@@ -202,7 +203,7 @@ void runtime::cpu::CPU_CallFrame::setup_runtime_context()
size_t
alignment
=
runtime
::
cpu
::
CPU_ExternalFunction
::
s_memory_pool_alignment
;
size_t
alignment
=
runtime
::
cpu
::
CPU_ExternalFunction
::
s_memory_pool_alignment
;
for
(
auto
buffer_size
:
m_external_function
->
get_memory_buffer_sizes
())
for
(
auto
buffer_size
:
m_external_function
->
get_memory_buffer_sizes
())
{
{
auto
buffer
=
new
AlignedBuffer
(
buffer_size
,
alignment
);
auto
buffer
=
new
AlignedBuffer
(
buffer_size
,
alignment
,
allocator
);
ctx
->
memory_buffers
.
push_back
(
buffer
);
ctx
->
memory_buffers
.
push_back
(
buffer
);
}
}
const
auto
&
mkldnn_emitter
=
m_external_function
->
get_mkldnn_emitter
();
const
auto
&
mkldnn_emitter
=
m_external_function
->
get_mkldnn_emitter
();
...
...
src/ngraph/runtime/cpu/cpu_call_frame.hpp
View file @
4b84262c
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#include <vector>
#include <vector>
#include "ngraph/function.hpp"
#include "ngraph/function.hpp"
#include "ngraph/runtime/allocator.hpp"
#include "ngraph/runtime/cpu/cpu_layout_descriptor.hpp"
#include "ngraph/runtime/cpu/cpu_layout_descriptor.hpp"
#include "ngraph/runtime/cpu/cpu_runtime_context.hpp"
#include "ngraph/runtime/cpu/cpu_runtime_context.hpp"
#include "ngraph/runtime/tensor.hpp"
#include "ngraph/runtime/tensor.hpp"
...
@@ -59,7 +60,8 @@ namespace ngraph
...
@@ -59,7 +60,8 @@ namespace ngraph
CPU_CallFrame
(
std
::
shared_ptr
<
CPU_ExternalFunction
>
external_function
,
CPU_CallFrame
(
std
::
shared_ptr
<
CPU_ExternalFunction
>
external_function
,
InitContextFuncCG
compiled_init_ctx_func
,
InitContextFuncCG
compiled_init_ctx_func
,
DestroyContextFuncCG
compiled_destroy_ctx_func
,
DestroyContextFuncCG
compiled_destroy_ctx_func
,
EntryPoint
compiled_function
);
EntryPoint
compiled_function
,
runtime
::
Allocator
*
allocator
);
~
CPU_CallFrame
();
~
CPU_CallFrame
();
/// \brief Invoke the function with values matching the signature of the function.
/// \brief Invoke the function with values matching the signature of the function.
...
@@ -71,7 +73,7 @@ namespace ngraph
...
@@ -71,7 +73,7 @@ namespace ngraph
void
propagate_layouts
(
const
std
::
vector
<
std
::
shared_ptr
<
runtime
::
Tensor
>>&
tvs
,
void
propagate_layouts
(
const
std
::
vector
<
std
::
shared_ptr
<
runtime
::
Tensor
>>&
tvs
,
const
LayoutDescriptorPtrs
&
layouts
)
const
;
const
LayoutDescriptorPtrs
&
layouts
)
const
;
void
setup_runtime_context
();
void
setup_runtime_context
(
runtime
::
Allocator
*
allocator
);
void
setup_cg_runtime_context
();
void
setup_cg_runtime_context
();
void
cleanup_runtime_context
();
void
cleanup_runtime_context
();
...
...
src/ngraph/runtime/cpu/cpu_external_function.cpp
View file @
4b84262c
...
@@ -1825,7 +1825,8 @@ bool runtime::cpu::CPU_ExternalFunction::is_codegen(const ngraph::pass::PassConf
...
@@ -1825,7 +1825,8 @@ bool runtime::cpu::CPU_ExternalFunction::is_codegen(const ngraph::pass::PassConf
}
}
shared_ptr
<
ngraph
::
runtime
::
cpu
::
CPU_CallFrame
>
shared_ptr
<
ngraph
::
runtime
::
cpu
::
CPU_CallFrame
>
runtime
::
cpu
::
CPU_ExternalFunction
::
make_call_frame
(
ngraph
::
pass
::
PassConfig
&
pass_config
)
runtime
::
cpu
::
CPU_ExternalFunction
::
make_call_frame
(
ngraph
::
pass
::
PassConfig
&
pass_config
,
Allocator
*
allocator
)
{
{
#if defined(NGRAPH_DEX_ONLY)
#if defined(NGRAPH_DEX_ONLY)
if
(
is_codegen
(
pass_config
))
if
(
is_codegen
(
pass_config
))
...
@@ -1853,7 +1854,8 @@ shared_ptr<ngraph::runtime::cpu::CPU_CallFrame>
...
@@ -1853,7 +1854,8 @@ shared_ptr<ngraph::runtime::cpu::CPU_CallFrame>
return
make_shared
<
ngraph
::
runtime
::
cpu
::
CPU_CallFrame
>
(
shared_from_this
(),
return
make_shared
<
ngraph
::
runtime
::
cpu
::
CPU_CallFrame
>
(
shared_from_this
(),
m_compiled_init_ctx_func
,
m_compiled_init_ctx_func
,
m_compiled_destroy_ctx_func
,
m_compiled_destroy_ctx_func
,
m_compiled_function
);
m_compiled_function
,
allocator
);
}
}
const
runtime
::
cpu
::
LayoutDescriptorPtrs
&
const
runtime
::
cpu
::
LayoutDescriptorPtrs
&
...
...
src/ngraph/runtime/cpu/cpu_external_function.hpp
View file @
4b84262c
...
@@ -100,8 +100,7 @@ namespace ngraph
...
@@ -100,8 +100,7 @@ namespace ngraph
bool
release_function
=
true
);
bool
release_function
=
true
);
~
CPU_ExternalFunction
();
~
CPU_ExternalFunction
();
std
::
shared_ptr
<
ngraph
::
runtime
::
cpu
::
CPU_CallFrame
>
std
::
shared_ptr
<
ngraph
::
runtime
::
cpu
::
CPU_CallFrame
>
make_call_frame
(
ngraph
::
pass
::
PassConfig
&
pass_config
);
make_call_frame
(
ngraph
::
pass
::
PassConfig
&
pass_config
,
Allocator
*
allocator
);
const
LayoutDescriptorPtrs
&
get_parameter_layout_descriptors
();
const
LayoutDescriptorPtrs
&
get_parameter_layout_descriptors
();
const
LayoutDescriptorPtrs
&
get_result_layout_descriptors
();
const
LayoutDescriptorPtrs
&
get_result_layout_descriptors
();
const
std
::
vector
<
size_t
>&
get_memory_buffer_sizes
()
const
const
std
::
vector
<
size_t
>&
get_memory_buffer_sizes
()
const
...
...
src/ngraph/runtime/cpu/cpu_runtime_context.hpp
View file @
4b84262c
...
@@ -37,7 +37,6 @@ namespace ngraph
...
@@ -37,7 +37,6 @@ namespace ngraph
{
{
class
AlignedBuffer
;
class
AlignedBuffer
;
}
}
class
State
;
class
State
;
}
}
...
...
test/files/onnx/convtranspose_output_shape/w.bin
0 → 100644
View file @
4b84262c
File added
test/files/onnx/convtranspose_output_shape/x.bin
0 → 100644
View file @
4b84262c
File added
test/files/onnx/convtranspose_output_shape/y.bin
0 → 100644
View file @
4b84262c
File added
test/models/onnx/convtranspose_output_shape.prototxt
0 → 100644
View file @
4b84262c
ir_version: 3
producer_name: "backend-test"
graph {
node {
input: "X"
input: "W"
output: "Y"
op_type: "ConvTranspose"
attribute {
name: "output_shape"
ints: 10
ints: 8
type: INTS
}
attribute {
name: "strides"
ints: 3
ints: 2
type: INTS
}
}
name: "test_convtranspose_output_shape"
input {
name: "X"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 1
}
dim {
dim_value: 1
}
dim {
dim_value: 3
}
dim {
dim_value: 3
}
}
}
}
}
input {
name: "W"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 1
}
dim {
dim_value: 2
}
dim {
dim_value: 3
}
dim {
dim_value: 3
}
}
}
}
}
output {
name: "Y"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 1
}
dim {
dim_value: 2
}
dim {
dim_value: 10
}
dim {
dim_value: 8
}
}
}
}
}
}
opset_import {
version: 9
}
test/onnx/onnx_import_convpool.in.cpp
View file @
4b84262c
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
#include "util/all_close.hpp"
#include "util/all_close.hpp"
#include "util/all_close_f.hpp"
#include "util/all_close_f.hpp"
#include "util/ndarray.hpp"
#include "util/ndarray.hpp"
#include "util/test_case.hpp"
#include "util/test_control.hpp"
#include "util/test_control.hpp"
#include "util/test_tools.hpp"
#include "util/test_tools.hpp"
...
@@ -409,3 +410,19 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_global_lp_pool_p3)
...
@@ -409,3 +410,19 @@ NGRAPH_TEST(onnx_${BACKEND_NAME}, model_global_lp_pool_p3)
EXPECT_TRUE
(
test
::
all_close_f
(
expected_outputs
.
front
(),
outputs
.
front
()));
EXPECT_TRUE
(
test
::
all_close_f
(
expected_outputs
.
front
(),
outputs
.
front
()));
}
}
NGRAPH_TEST
(
onnx_
$
{
BACKEND_NAME
},
model_convtranspose_output_shape
)
{
auto
conv_transpose_fn
=
onnx_import
::
import_onnx_model
(
file_util
::
path_join
(
SERIALIZED_ZOO
,
"onnx/convtranspose_output_shape.prototxt"
));
auto
test_case
=
ngraph
::
test
::
NgraphTestCase
(
conv_transpose_fn
,
"${BACKEND_NAME}"
);
test_case
.
add_input_from_file
<
float
>
(
TEST_FILES
,
"onnx/convtranspose_output_shape/x.bin"
);
test_case
.
add_input_from_file
<
float
>
(
TEST_FILES
,
"onnx/convtranspose_output_shape/w.bin"
);
test_case
.
add_expected_output_from_file
<
float
>
(
{
1
,
2
,
10
,
8
},
TEST_FILES
,
"onnx/convtranspose_output_shape/y.bin"
);
test_case
.
dump_results
();
test_case
.
run
();
}
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