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

[microTVM] Add tutorial on how to generate MLPerfTiny submissions #13783

Merged
merged 10 commits into from
Jan 19, 2023

Conversation

mehrdadh
Copy link
Member

This PR adds a tutorial on how to generate an MLPerftiny submission on Zephyr OS using microTVM.

cc @alanmacd @gromero @mkatanbaf

@tvm-bot
Copy link
Collaborator

tvm-bot commented Jan 14, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

@mehrdadh mehrdadh requested a review from guberti January 14, 2023 00:44
@github-actions github-actions bot requested a review from gromero January 14, 2023 00:45
@mehrdadh mehrdadh force-pushed the micro/mlperftiny_tutorial branch from b344fed to 2bcb15e Compare January 14, 2023 00:49
Copy link
Contributor

@areusch areusch left a comment

Choose a reason for hiding this comment

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

thanks @mehrdadh !

gallery/how_to/work_with_microtvm/micro_mlperftiny.py Outdated Show resolved Hide resolved
python/tvm/micro/testing/utils.py Outdated Show resolved Hide resolved
# If you like to build the submission with CMSIS-NN, modify USE_CMSIS variable.
#

MODEL_URL = "https://github.com/mlcommons/tiny/raw/bceb91c5ad2e2deb295547d81505721d3a87d578/benchmark/training/visual_wake_words/trained_models/vww_96_int8.tflite"
Copy link
Contributor

Choose a reason for hiding this comment

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

should we include other models, since we reference them elsewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it would redundant here. We can make a micro/test api call that returns the address to the model.

Copy link
Member

Choose a reason for hiding this comment

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

I'm with @mehrdadh - I worry having multiple URLS might be confusing. Adding a micro API call would be a good way to clean this up in a future PR.

Choose a reason for hiding this comment

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

Can this line (101) be pleased changed as follows?

MODEL_URL = os.environ.get("MODEL_URL", "https://github.com/mlcommons/tiny/raw/bceb91c5ad2e2deb295547d81505721d3a87d578/benchmark/training/visual_wake_words/trained_models/vww_96_int8.tflite")

This can give flexibility to the user to change the url without having to modify the code.

Copy link
Member Author

Choose a reason for hiding this comment

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

@arjunsuresh Unfortunately that's not the only change that is required to use a different model in this tutorial. We could change this tutorial in a follow up PR to get all the model URL, name and index from test APIs in TVM

Copy link
Member

@guberti guberti left a comment

Choose a reason for hiding this comment

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

This looks nice, thanks for writing it up! I've just got a few nits.

It would also be nice to add/copy over a unit test for MLPerf Tiny performance at some point, but that's a separate issue.

gallery/how_to/work_with_microtvm/micro_mlperftiny.py Outdated Show resolved Hide resolved
gallery/how_to/work_with_microtvm/micro_mlperftiny.py Outdated Show resolved Hide resolved
gallery/how_to/work_with_microtvm/micro_mlperftiny.py Outdated Show resolved Hide resolved
gallery/how_to/work_with_microtvm/micro_mlperftiny.py Outdated Show resolved Hide resolved
Comment on lines 245 to 248
f"-DWORKSPACE_SIZE={workspace_size + 512}",
f"-DTARGET_MODEL={MODEL_INDEX}",
f"-DTH_MODEL_VERSION=EE_MODEL_VERSION_{MODEL_SHORT_NAME}01",
f"-DMAX_DB_INPUT_SIZE={input_total_size}",
Copy link
Member

Choose a reason for hiding this comment

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

Would love for you to briefly state what these do.

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

Comment on lines 259 to 262
if BOARD == "nrf5340dk_nrf5340_cpuapp":
config_main_stack_size = 4000
elif BOARD == "nucleo_l4r5zi":
config_main_stack_size = 4000
Copy link
Member

Choose a reason for hiding this comment

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

Can we just set config_main_stack_size=4000?

Copy link
Member Author

Choose a reason for hiding this comment

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

done, added a note that they might need to adjust it based on their board

python/tvm/micro/testing/utils.py Outdated Show resolved Hide resolved
@mehrdadh mehrdadh requested review from guberti and alanmacd January 17, 2023 21:25
Copy link
Member

@guberti guberti left a comment

Choose a reason for hiding this comment

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

LGTM!

# If you like to build the submission with CMSIS-NN, modify USE_CMSIS variable.
#

MODEL_URL = "https://github.com/mlcommons/tiny/raw/bceb91c5ad2e2deb295547d81505721d3a87d578/benchmark/training/visual_wake_words/trained_models/vww_96_int8.tflite"
Copy link
Member

Choose a reason for hiding this comment

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

I'm with @mehrdadh - I worry having multiple URLS might be confusing. Adding a micro API call would be a good way to clean this up in a future PR.

Copy link
Contributor

@gromero gromero left a comment

Choose a reason for hiding this comment

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

@mehrdadh Great tutorial! Nice you're playing with the EEMBC runner :-)

@gromero gromero changed the title [microTVM]Tutorial on how to generate MLPerfTiny Submission [microTVM] Add tutorial on how to generate MLPerfTiny submissions Jan 17, 2023
@mehrdadh mehrdadh force-pushed the micro/mlperftiny_tutorial branch from 000b551 to faf3b56 Compare January 18, 2023 00:01
@mehrdadh mehrdadh merged commit cfa65b2 into apache:main Jan 19, 2023
@mehrdadh mehrdadh deleted the micro/mlperftiny_tutorial branch January 19, 2023 23:32
fzi-peccia pushed a commit to fzi-peccia/tvm that referenced this pull request Mar 27, 2023
…ache#13783)

This PR adds a tutorial on how to generate an MLPerftiny submission on Zephyr OS using microTVM.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants