Skip to content

Commit

Permalink
[docs] microTVM model training tutorial with Colab support (#10921)
Browse files Browse the repository at this point in the history
* First draft of micro train tutorial

* unit test code

* Fix obvious formatting issues

* Linting

* Proof of concept showing that "Open in Colab" is possible

* Make test Python script more readable

* Fix formatting

* Ready for review

* Import pyserial only when needed

Changes from code review

Use official sphinx-gallery repo

Correctly specify version

Import pyserial only when necessary

* Add warning to ignored list

Try to avoid throwing warning

Fix linting, try verbosity filter

Try adding to ignore file

Remove fix attempts

* Grammar fixes

* Address code review comments

Include full git hashes

* Rerun tests

* Rerun again
  • Loading branch information
guberti authored Jun 3, 2022
1 parent 6dbdf2e commit f05ebde
Show file tree
Hide file tree
Showing 7 changed files with 660 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import re

from packaging import version
import serial.tools.list_ports

from tvm.micro.project_api import server

Expand Down Expand Up @@ -485,6 +484,9 @@ def flash(self, options):
subprocess.run(upload_cmd, check=True)

def open_transport(self, options):
import serial
import serial.tools.list_ports

# Zephyr example doesn't throw an error in this case
if self._serial is not None:
return
Expand Down
2 changes: 1 addition & 1 deletion apps/microtvm/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ importer-tflite = ["tflite", "tensorflow", "tensorflow-estimator"]
autodocsumm = "^0.1"
black = "^19.10b0"
sphinx = "^3.0"
sphinx-gallery = "^0.8"
sphinx-gallery = { git = "https://github.com/sphinx-gallery/sphinx-gallery.git", rev = "6142f179" }
sphinx-rtd-theme = "^0.4"
matplotlib = "^3.2"
Image = "^1.5"
Expand Down
2 changes: 1 addition & 1 deletion docker/install/ubuntu_install_sphinx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ pip3 install \
matplotlib \
sphinx==4.2.0 \
sphinx_autodoc_annotation \
sphinx-gallery==0.4.0 \
"git+https://github.com/sphinx-gallery/sphinx-gallery.git@6142f1791151849b5bec4bf3959f75697ba226cd" \
sphinx_rtd_theme
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ def git_describe_version(original_version):
"bring_your_own_datatypes.py",
],
"micro": [
"micro_train.py",
"micro_autotune.py",
"micro_reference_vm.py",
"micro_tflite.py",
Expand Down Expand Up @@ -360,11 +361,11 @@ def force_gc(gallery_conf, fname):
"gallery_dirs": gallery_dirs,
"subsection_order": subsection_order,
"filename_pattern": os.environ.get("TVM_TUTORIAL_EXEC_PATTERN", ".py"),
"find_mayavi_figures": False,
"download_all_examples": False,
"min_reported_time": 60,
"expected_failing_examples": [],
"reset_modules": ("matplotlib", "seaborn", force_gc),
"promote_jupyter_magic": True,
}

autodoc_default_options = {
Expand Down
649 changes: 649 additions & 0 deletions gallery/how_to/work_with_microtvm/micro_train.py

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion tests/scripts/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ def docs(
"tlcpack-sphinx-addon==0.2.1",
"synr==0.5.0",
"image==1.5.33",
"sphinx-gallery==0.4.0",
# Temporary git link until a release is published
"git+https://github.com/sphinx-gallery/sphinx-gallery.git@6142f1791151849b5bec4bf3959f75697ba226cd",
"sphinx-rtd-theme==1.0.0",
"matplotlib==3.3.4",
"commonmark==0.9.1",
Expand Down
2 changes: 2 additions & 0 deletions tests/scripts/task_python_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ IGNORED_WARNINGS=(
'autotvm:Cannot find config for target=llvm -keys=cpu -link-params=0'
'autotvm:One or more operators have not been tuned. Please tune your model for better performance. Use DEBUG logging level to see more details.'
'autotvm:Cannot find config for target=cuda -keys=cuda,gpu'
# Warning is thrown during TFLite quantization for micro_train tutorial
'absl:For model inputs containing unsupported operations which cannot be quantized, the `inference_input_type` attribute will default to the original type.'
)

JOINED_WARNINGS=$(join_by '|' "${IGNORED_WARNINGS[@]}")
Expand Down

0 comments on commit f05ebde

Please sign in to comment.