-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[microTVM][tutorial] AOT host-driven tutorial with TFLite model #12182
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
Conversation
gromero
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mehrdadh Did a first pass and have a few comments on it.
|
|
||
| This tutorial is showcasing microTVM host-driven AoT compilation with | ||
| a TFLite model. This tutorial can be executed on a X86 CPU using C runtime (CRT) | ||
| or on Zephyr plarform on a microcontroller that supports Zephyr platform. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
platform
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| # Import a TFLite model | ||
| # --------------------- | ||
| # | ||
| # To begin with, download and import a TFLite model from TinyMLPerf models. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not actually importing directly from the MLPerf Tiny bench, i.e. from:
Should this benchmark be mentioned just as the original source of this model?
Also I think the current name for the bench is MLPerf Tiny, not TinyMLPerf, like in the text found in the READM.md here? https://github.com/mlcommons/tiny
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added comment about the origin of the model and fixed MLPerf Tiny name.
| `Mehrdad Hessar <https://github.com/mehrdadh>`_, | ||
| `Alan MacDonald <https://github.com/alanmacd>`_ | ||
|
|
||
| This tutorial is showcasing microTVM host-driven AoT compilation with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be mentioned, at least briefly, the benefits of the AOT executor or the scenarios where it helps -- in contrast to the Graph executor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added few comments, please take another look.
guberti
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of good suggestions from @gromero - I've only got a few nits.
| `Alan MacDonald <https://github.com/alanmacd>`_ | ||
|
|
||
| This tutorial is showcasing microTVM host-driven AoT compilation with | ||
| a TFLite model. This tutorial can be executed on a X86 CPU using C runtime (CRT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit here and in a few other places:
| a TFLite model. This tutorial can be executed on a X86 CPU using C runtime (CRT) | |
| a TFLite model. This tutorial can be executed on a x86 CPU using C runtime (CRT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
| # with the compiled model in microTVM. To do this, we use Project API. We have defined | ||
| # CRT and Zephyr microTVM template projects which are used for X86 CPU and Zephyr platforms | ||
| # respectively. | ||
| # |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this and leave a blank line here
| # |
| # **Note:** By default this tutorial runs on X86 CPU using CRT, if you would like to run on Zephyr platform | ||
| # you need to export `TVM_MICRO_USE_HW` environment variable. | ||
| # | ||
| use_physical_hw = bool(os.getenv("TVM_MICRO_USE_HW")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should mention the KWS dataset we're using, and probably ought to credit Google as the author (see https://ai.googleblog.com/2017/08/launching-speech-commands-dataset.html).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added that.
areusch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great comments all around, just a few suggestions to clarify text.
| # ------------------- | ||
| # | ||
| # Now we need to define the target, runtime and executor. In this tutorial, we focused on | ||
| # using AOT host driven executor. We use the host micro target which is for running a model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest to make this super clear:
# Use the C runtime (crt) and enable static linking by setting system-lib to True
RUNTIME = Runtime("crt", {"system-lib": True})
# Simulate a microcontroller on the host machine. Uses the main() from src/runtime/crt/host/main.cc. To use physical hardware, replace "host" with something matching your hardware. See abc location for instructions.
TARGET = tvm.target.target.micro("host")
# Use the AOT executor rather than graph or vm executors. Don't use unpacked API or C calling style
EXECUTOR = Executor("aot")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
mehrdadh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| `Alan MacDonald <https://github.com/alanmacd>`_ | ||
|
|
||
| This tutorial is showcasing microTVM host-driven AoT compilation with | ||
| a TFLite model. This tutorial can be executed on a X86 CPU using C runtime (CRT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
| `Mehrdad Hessar <https://github.com/mehrdadh>`_, | ||
| `Alan MacDonald <https://github.com/alanmacd>`_ | ||
|
|
||
| This tutorial is showcasing microTVM host-driven AoT compilation with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added few comments, please take another look.
|
|
||
| This tutorial is showcasing microTVM host-driven AoT compilation with | ||
| a TFLite model. This tutorial can be executed on a X86 CPU using C runtime (CRT) | ||
| or on Zephyr plarform on a microcontroller that supports Zephyr platform. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| # Import a TFLite model | ||
| # --------------------- | ||
| # | ||
| # To begin with, download and import a TFLite model from TinyMLPerf models. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added comment about the origin of the model and fixed MLPerf Tiny name.
| # **Note:** By default this tutorial runs on X86 CPU using CRT, if you would like to run on Zephyr platform | ||
| # you need to export `TVM_MICRO_USE_HW` environment variable. | ||
| # | ||
| use_physical_hw = bool(os.getenv("TVM_MICRO_USE_HW")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added that.
| # ------------------- | ||
| # | ||
| # Now we need to define the target, runtime and executor. In this tutorial, we focused on | ||
| # using AOT host driven executor. We use the host micro target which is for running a model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
|
@gromero thanks for the second review. I addressed your comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # to use the compiled model with microTVM. To do this, we use Project API. We have defined | ||
| # CRT and Zephyr microTVM template projects which are used for x86 CPU and Zephyr platforms | ||
| # CRT and Zephyr microTVM template projects which are used for x86 CPU and Zephyr boards | ||
| # respectively. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a native English speaker, but I think that ideally there must be a comma before "respectively", so it's up to you to add it or not :) I won't block on this nit, so just saying in case you need to re-spin the PR after some other review comment and if you can confirm that is indeed correct ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should be, for some reason my eyes where seeing it there but I didn't actually put it there lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha I missed it previously too! :)
|
@mehrdadh I'm not sure what failed here and how to reproduce it locally. Hardly it's related to your PR, but I wonder if there is any CI issue filed for that error. Any idea? If not, maybe just ret-rigger the CI for now. |
areusch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for me, @guberti can take a look and then we can merge
|
@mehrdadh Could you please rebase? |
9f939b5 to
83124d9
Compare
|
@gromero done! |
guberti
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…he#12182) * Add aot tutorial
cc @areusch @gromero @guberti @alanmacd