[DOC] Codebase walkthrough with Vector add example#2206
Closed
masahi wants to merge 0 commit intoapache:masterfrom
Closed
[DOC] Codebase walkthrough with Vector add example#2206masahi wants to merge 0 commit intoapache:masterfrom
masahi wants to merge 0 commit intoapache:masterfrom
Conversation
vinx13
reviewed
Dec 1, 2018
| - ``topi`` - Compute definitions and backend schedules for standard neural network operators. | ||
| - ``nnvm`` - C++ code and Python frontend for graph optimization and compilation. Depends on three directories above. | ||
|
|
||
| Using standard Deep Learning terminologies, ``nnvm`` is the component that manages a computational graph, and nodes in a graph are compiled and executed using infrastructures implemented in ``src`` and ``python``. Operators corresponding to each node are registered in ``nnvm``. Registration can be done via C++ or Python. Implemenations for operators are in ``topi``, and they are also coded in either C++ or Python. |
Member
There was a problem hiding this comment.
Implemenations -> Implementations
|
|
||
| Using standard Deep Learning terminologies, ``nnvm`` is the component that manages a computational graph, and nodes in a graph are compiled and executed using infrastructures implemented in ``src`` and ``python``. Operators corresponding to each node are registered in ``nnvm``. Registration can be done via C++ or Python. Implemenations for operators are in ``topi``, and they are also coded in either C++ or Python. | ||
|
|
||
| When an user invokes graph compilation by ``nnvm.compiler.build(...)``, the following sequence of actions happens for each node in the graph: |
|
|
||
| The process of ``tvm.build()`` can be divided into two steps: | ||
|
|
||
| - Lowering, where an high level, initial loop nest structures are transformed into a final, low level IR |
|
|
||
| One of the interesting aspects of TVM codebase is that interop between C++ and Python is not unidirectional. Typically, all code that do heavy liftings are implemented in C++, and Python bindings are provided for user interface. This is also true in TVM, but in TVM codebase, C++ code also call into functions defined in a Python module. For example, the convolution operator is implemented in Python, and its implementation is invoked from C++ code in nnvm. | ||
|
|
||
| At the time of writing (Nov. 30, 2018), there is an going effort to reimplement functionality offered by ``nnvm`` in a new intermidiate representation called Relay. New Relay code resides in ``src/relay`` and ``python/tvm/relay``. |
| B = tvm.placeholder((n,), name='B') | ||
| C = tvm.compute(A.shape, lambda i: A[i] + B[i], name="C") | ||
|
|
||
| Here, types of ``A``, ``B``, ``C`` are ``tvm.tensor.Tensor``, defined in ``python/tvm/tensor.py``. The Python ``Tensor`` is backed by C++ ``Tensor``, implemented in ``include/tvm/tensor.h`` and ``src/lang/tensor.cc``. All Python types in TVM can be thought of as a handle to the underlining C++ type with the same name. If you look at the definition of Python ``Tensor`` type below, you can see it is an subclass of ``NodeBase``. |
Member
Author
|
@vinx13 Thanks. Fixed. |
Member
|
Would probably be good to port this to Relay soonish too. One of the Relay developers can probably manage that though, I will add a note to the tracking issue. |
16 tasks
merrymercy
reviewed
Dec 11, 2018
| B = tvm.placeholder((n,), name='B') | ||
| C = tvm.compute(A.shape, lambda i: A[i] + B[i], name="C") | ||
|
|
||
| Here, types of ``A``, ``B``, ``C`` are ``tvm.tensor.Tensor``, defined in ``python/tvm/tensor.py``. The Python ``Tensor`` is backed by C++ ``Tensor``, implemented in ``include/tvm/tensor.h`` and ``src/lang/tensor.cc``. All Python types in TVM can be thought of as a handle to the underlining C++ type with the same name. If you look at the definition of Python ``Tensor`` type below, you can see it is a subclass of ``NodeBase``. |
7cd3e98 to
1e40e0c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first stab at #2160.
@tqchen @yzhliu @merrymercy @Ravenwater please review.