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
a982c793
Commit
a982c793
authored
Mar 02, 2018
by
Scott Cyphers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix line numbers
parent
6d067132
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
18 deletions
+11
-18
abc.cpp
doc/examples/abc.cpp
+1
-1
execute.rst
doc/sphinx/source/howto/execute.rst
+10
-17
No files found.
doc/examples/abc.cpp
View file @
a982c793
...
...
@@ -37,9 +37,9 @@ int main()
// Get the backend
auto
manager
=
runtime
::
Manager
::
get
(
"CPU"
);
auto
backend
=
manager
->
allocate_backend
();
auto
external
=
manager
->
compile
(
f
);
// Compile the function
auto
external
=
manager
->
compile
(
f
);
auto
cf
=
backend
->
make_call_frame
(
external
);
// Allocate tensors
...
...
doc/sphinx/source/howto/execute.rst
View file @
a982c793
...
...
@@ -75,7 +75,7 @@ be passed to them.
.. literalinclude:: ../../../examples/abc.cpp
:language: cpp
:lines:
11-13
:lines:
26-29
Here we have made three parameter nodes, each a 32-bit float of shape ``(2, 3)``
using a row-major element layout.
...
...
@@ -85,20 +85,20 @@ from ``a`` and ``b``, and an ``op::Multiply`` node from the add node and ``c``:
.. literalinclude:: ../../../examples/abc.cpp
:language: cpp
:lines:
15-16
:lines:
31-32
When the ``op::Add`` op is constructed, it will check that the element types and
shapes of its inputs match; to support multiple frameworks, ngraph does not do
automatic type conversion or broadcasting. In this case, they match, and the
shape of the unique output of ``t0`` will be a 32-bit float with shape ``(2, 3)``.
Similarly, ``op::Multiply``checks that its inputs match and sets the element
Similarly, ``op::Multiply``
checks that its inputs match and sets the element
type and shape of its unique output.
Once the graph is built, we need to package it in a ``Function``:
.. literalinclude:: ../../../examples/abc.cpp
:language: cpp
:lines:
19
:lines:
35
The first argument to the constuctor specifies the nodes that the function will
return; in this case, the product. A ``NodeVector`` is a vector of shared
...
...
@@ -133,7 +133,7 @@ To select the ``"CPU"`` backend,
.. literalinclude:: ../../../examples/abc.cpp
:language: cpp
:lines:
22-23
:lines:
38-39
.. _compile_cmp:
...
...
@@ -150,7 +150,7 @@ thread needs to execute the function at the same time, create multiple
.. literalinclude:: ../../../examples/abc.cpp
:language: cpp
:lines:
24-28
:lines:
42-43
.. _allocate_bkd_storage:
...
...
@@ -185,17 +185,11 @@ tensor view, it will be freed when convenient for the backend.
Initialize the inputs
=====================
Normally the framework bridge reads and writes bytes to the tensor, assuming a
row-major element layout. To simplify writing unit tests, we have developed a
class for making tensor literals. We can use these to initialize our tensors:
Next we need to copy some data into the tensors.
.. literalinclude:: ../../../examples/abc.cpp
:language: cpp
:lines: 36-38
The ``test::NDArray`` needs to know the element type (``float`` for this
example) and rank (``2`` for this example) of the tensors; it will then
populate the shape during template expansion.
:lines: 45-58
The ``runtime::TensorView`` interface has ``write`` and ``read`` methods for
copying data to/from the tensor.
...
...
@@ -210,7 +204,7 @@ call frame:
.. literalinclude:: ../../../examples/abc.cpp
:language: cpp
:lines:
4
1
:lines:
6
1
.. _access_outputs:
...
...
@@ -222,7 +216,7 @@ We can use the ``read`` method to access the result:
.. literalinclude:: ../../../examples/abc.cpp
:language: cpp
:lines:
44-4
5
:lines:
64-6
5
.. _all_together:
...
...
@@ -231,6 +225,5 @@ Putting it all together
.. literalinclude:: ../../../examples/abc.cpp
:language: cpp
:lines: 1-46
:caption: "The (a + b) * c example for executing a computation on nGraph"
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