Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MicroTVM tutorial using the STM32F746 discovery board #5655

Merged
merged 15 commits into from
Jun 24, 2020

Conversation

tom-gall
Copy link
Contributor

Add MicroTVM tutorial using the STM32F746 discovery board
with a sample tflite model

Signed-off-by: Tom Gall [email protected]

Thanks for contributing to TVM! Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from Reviewers by @ them in the pull request thread.

with a sample tflite model

Signed-off-by: Tom Gall <[email protected]>
@tom-gall
Copy link
Contributor Author

tom-gall commented May 22, 2020

@areusch @u99127

@tqchen
Copy link
Member

tqchen commented Jun 2, 2020

@tom-gall please look into the CI failure

@areusch
Copy link
Contributor

areusch commented Jun 2, 2020

Hey Tom, to get this to build further along in the CI, I think you can add the following line to docs/conf.py:

'../tutorials/micro'

I added this around line 168 and it kept building

tutorials/micro/README.txt Outdated Show resolved Hide resolved
tom-gall added 6 commits June 4, 2020 16:06
comment out portion of tutorial that will not run without a physical board available

Signed-off-by: Tom Gall <[email protected]>
The block is commented out since it can only run on device

Signed-off-by: Tom Gall <[email protected]>
@tqchen
Copy link
Member

tqchen commented Jun 10, 2020

@tom-gall please followup on @liangfu 's comment

Copy link
Member

@liangfu liangfu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tom-gall for your valuable contribution on the uTVM tutorial. I've rendered your tutorial and it's not displayed correctly as expected. Please try generate the html by running

make html

in the <tvm_root>/docs directory, so that you could preview the rendered html (in <tvm_root>/docs/_build/html) and fix the syntax errors.

tutorials/micro/micro_tflite.py Outdated Show resolved Hide resolved
tutorials/micro/micro_tflite.py Outdated Show resolved Hide resolved
tutorials/micro/micro_tflite.py Outdated Show resolved Hide resolved
tutorials/micro/micro_tflite.py Outdated Show resolved Hide resolved
docs/conf.py Outdated Show resolved Hide resolved
tutorials/micro/micro_tflite.py Show resolved Hide resolved
# install tflite
# .. code-block:: bash
#
# pip install tflite=2.1.0 --user
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow RST syntax to put the extra indentation, otherwise it's not rendered as code.

Please try reproduce the the rendered html by running

make html

in <tvm_root>/docs directory, so that the tutorial could be more reader friendly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly make html dies with an exception :

python3 -m sphinx -b html -d _build/doctrees . _build/html
Running Sphinx v3.1.0
loading pickled environment... done
[autosummary] generating autosummary for: api/links.rst, api/python/autotvm.rst, api/python/contrib.rst, api/python/driver.rst, api/python/error.rst, api/python/graph_runtime.rst, api/python/index.rst, api/python/ir.rst, api/python/micro.rst, api/python/ndarray.rst, ..., vta/index.rst, vta/install.rst, vta/tutorials/autotvm/tune_relay_vta.rst, vta/tutorials/frontend/deploy_classification.rst, vta/tutorials/frontend/deploy_detection.rst, vta/tutorials/index.rst, vta/tutorials/matrix_multiply.rst, vta/tutorials/optimize/convolution_opt.rst, vta/tutorials/optimize/matrix_multiply_opt.rst, vta/tutorials/vta_get_started.rst
generating gallery...
generating gallery for tutorials... [ 33%] relay_quick_start.py
Extension error:
Handler <function generate_gallery_rst at 0x7f23e55b04d0> for event 'builder-inited' threw an exception
make: *** [Makefile:70: html] Error 2

I'm using ./tests/scripts/task_sphinx_precheck.sh which seems to generate less than perfect html when viewed elsewhere. I'm less than confident that the html generated is acceptable :-/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to get this to work by deleting the other tutorials. I haven't seen that specific exception, though. I did build your tutorial locally and I think it looks okay now. i'll add a couple of small nitpicks which you could fix if you want to be a perfectionist about it.

tutorials/micro/micro_tflite.py Outdated Show resolved Hide resolved
tutorials/micro/micro_tflite.py Outdated Show resolved Hide resolved
tutorials/micro/micro_tflite.py Show resolved Hide resolved
tutorials/micro/micro_tflite.py Outdated Show resolved Hide resolved
tutorials/micro/micro_tflite.py Outdated Show resolved Hide resolved
tutorials/micro/micro_tflite.py Show resolved Hide resolved
tutorials/micro/micro_tflite.py Show resolved Hide resolved
tom-gall added 2 commits June 10, 2020 17:02
Within docs/conf.py place the microTVM tutorial prior to the VTA tutorials

Within the micro_tflite
  - rework section headers
  - reorder code so model prep code is all in one place as well as code
    for running on device
  - address indentation feedback
  - remove '' '' usage which I mistakenly thought was getting around a
    sphinx issue involving **

Signed-off-by: Tom Gall <[email protected]>
…assContext

Change to pull example model from github with download_testdata
Add 2.5K tflite model
Couple of small changes following https://sphinx-gallery.github.io/stable/syntax.html

Signed-off-by: Tom Gall <[email protected]>
Copy link
Member

@tqchen tqchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot check in binary files into the codebase, please place the model elsewhere where we can download via download_testdata

tom-gall added 4 commits June 12, 2020 11:26
Change download_testdata back to pull model from linaro server

Signed-off-by: Tom Gall <[email protected]>
Copy link
Member

@tqchen tqchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# install tflite
# .. code-block:: bash
#
# pip install tflite=2.1.0 --user
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to get this to work by deleting the other tutorials. I haven't seen that specific exception, though. I did build your tutorial locally and I think it looks okay now. i'll add a couple of small nitpicks which you could fix if you want to be a perfectionist about it.

tutorials/micro/micro_tflite.py Show resolved Hide resolved
tutorials/micro/micro_tflite.py Outdated Show resolved Hide resolved
tutorials/micro/micro_tflite.py Outdated Show resolved Hide resolved
@tqchen
Copy link
Member

tqchen commented Jun 20, 2020

@tom-gall please followup on @areusch 's last comments

@tqchen tqchen merged commit 7a9346a into apache:master Jun 24, 2020
@tqchen
Copy link
Member

tqchen commented Jun 24, 2020

Thanks @tom-gall @areusch @liangfu !

trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Jun 30, 2020
* Add MicroTVM tutorial using the STM32F746 discovery board
with a sample tflite model

Signed-off-by: Tom Gall <[email protected]>

* Fix: add a reference to the new turtorials/micro directory

Signed-off-by: Tom Gall <[email protected]>

* fix: Cosmetic, align Micro TVM text with divider

Signed-off-by: Tom Gall <[email protected]>

* Fixes to remove warnings, spaces for readability, code blocks

Signed-off-by: Tom Gall <[email protected]>

* remove use of dload in favor of requests for obtaining the TFLite model

Signed-off-by: Tom Gall <[email protected]>

* add setup for CMSIS_ST_PATH
comment out portion of tutorial that will not run without a physical board available

Signed-off-by: Tom Gall <[email protected]>

* Fix warning due to ** in python but part of a comment block
The block is commented out since it can only run on device

Signed-off-by: Tom Gall <[email protected]>

* Numerous reworks to address feedback.

Within docs/conf.py place the microTVM tutorial prior to the VTA tutorials

Within the micro_tflite
  - rework section headers
  - reorder code so model prep code is all in one place as well as code
    for running on device
  - address indentation feedback
  - remove '' '' usage which I mistakenly thought was getting around a
    sphinx issue involving **

Signed-off-by: Tom Gall <[email protected]>

* Change disable_vectorize to use current approach with tvm.transform.PassContext
Change to pull example model from github with download_testdata
Add 2.5K tflite model
Couple of small changes following https://sphinx-gallery.github.io/stable/syntax.html

Signed-off-by: Tom Gall <[email protected]>

* remove use of relay.build_config in favor of PassContext

Signed-off-by: Tom Gall <[email protected]>

* Couple of minor 4 space fix ups

Signed-off-by: Tom Gall <[email protected]>

* Change to use tvm.transform.PassContext for disable_victorize and disabling FuseOps

Signed-off-by: Tom Gall <[email protected]>

* Remove binary module from repo
Change download_testdata back to pull model from linaro server

Signed-off-by: Tom Gall <[email protected]>

* Couple of small cosmetic changes. (spaces and extra lines)

Signed-off-by: Tom Gall <[email protected]>

* Convert link to tf docs to examine a tf lite model to use RST syntax

Signed-off-by: Tom Gall <[email protected]>
zhiics pushed a commit to neo-ai/tvm that referenced this pull request Jul 2, 2020
* Add MicroTVM tutorial using the STM32F746 discovery board
with a sample tflite model

Signed-off-by: Tom Gall <[email protected]>

* Fix: add a reference to the new turtorials/micro directory

Signed-off-by: Tom Gall <[email protected]>

* fix: Cosmetic, align Micro TVM text with divider

Signed-off-by: Tom Gall <[email protected]>

* Fixes to remove warnings, spaces for readability, code blocks

Signed-off-by: Tom Gall <[email protected]>

* remove use of dload in favor of requests for obtaining the TFLite model

Signed-off-by: Tom Gall <[email protected]>

* add setup for CMSIS_ST_PATH
comment out portion of tutorial that will not run without a physical board available

Signed-off-by: Tom Gall <[email protected]>

* Fix warning due to ** in python but part of a comment block
The block is commented out since it can only run on device

Signed-off-by: Tom Gall <[email protected]>

* Numerous reworks to address feedback.

Within docs/conf.py place the microTVM tutorial prior to the VTA tutorials

Within the micro_tflite
  - rework section headers
  - reorder code so model prep code is all in one place as well as code
    for running on device
  - address indentation feedback
  - remove '' '' usage which I mistakenly thought was getting around a
    sphinx issue involving **

Signed-off-by: Tom Gall <[email protected]>

* Change disable_vectorize to use current approach with tvm.transform.PassContext
Change to pull example model from github with download_testdata
Add 2.5K tflite model
Couple of small changes following https://sphinx-gallery.github.io/stable/syntax.html

Signed-off-by: Tom Gall <[email protected]>

* remove use of relay.build_config in favor of PassContext

Signed-off-by: Tom Gall <[email protected]>

* Couple of minor 4 space fix ups

Signed-off-by: Tom Gall <[email protected]>

* Change to use tvm.transform.PassContext for disable_victorize and disabling FuseOps

Signed-off-by: Tom Gall <[email protected]>

* Remove binary module from repo
Change download_testdata back to pull model from linaro server

Signed-off-by: Tom Gall <[email protected]>

* Couple of small cosmetic changes. (spaces and extra lines)

Signed-off-by: Tom Gall <[email protected]>

* Convert link to tf docs to examine a tf lite model to use RST syntax

Signed-off-by: Tom Gall <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants