-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[microTVM] Enable micro tvmc tutorial testing in CI #10555
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| import argparse | ||
| import pathlib | ||
|
|
||
| BASH = "# bash" | ||
| BASH_IGNORE = "# bash-ignore" | ||
| BASH_MULTILINE_COMMENT_START = ": '" | ||
| BASH_MULTILINE_COMMENT_END = "'" | ||
|
|
||
|
|
||
| def convert(args: argparse.Namespace): | ||
| src_path = pathlib.Path(args.script) | ||
| des_path = src_path.parent / f"{src_path.stem}.py" | ||
| with open(src_path, "r") as src_f: | ||
| with open(des_path, "w") as des_f: | ||
| line = src_f.readline() | ||
mehrdadh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| bash_block = [] | ||
| bash_detected = False | ||
| bash_ignore_detected = False | ||
| while line: | ||
| line = line.strip("\n").strip("\r") | ||
| if bash_detected: | ||
| if line == BASH: | ||
| # write the bash block to destination | ||
| python_code = "# .. code-block:: bash\n#\n" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we run the bash script from this file and include the output? we could probably do that by injecting output markers into the script e.g. then we could take the might need to think about the path a little bit
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the idea to add the output of each command to generated python file and finally have it as part of generated HTML file?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah exactly |
||
| for bash_line in bash_block: | ||
| python_code += f"#\t {bash_line}\n" | ||
| python_code += "#\n" | ||
| des_f.write(python_code) | ||
|
|
||
| bash_detected = False | ||
| bash_block = [] | ||
| else: | ||
| # add new bash command line | ||
| bash_block.append(line) | ||
| elif bash_ignore_detected: | ||
| if line == BASH_IGNORE: | ||
| bash_ignore_detected = False | ||
| else: | ||
| pass | ||
| else: | ||
| if line == BASH: | ||
| bash_detected = True | ||
| elif line == BASH_IGNORE: | ||
| bash_ignore_detected = True | ||
| elif line in [BASH_MULTILINE_COMMENT_START, BASH_MULTILINE_COMMENT_END]: | ||
| des_f.write('"""\n') | ||
| else: | ||
| des_f.write(f"{line}\n") | ||
|
|
||
| line = src_f.readline() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| parser = argparse.ArgumentParser(description="Convert tutorial script to Python.") | ||
| parser.add_argument("script", type=str, help="Path to script file.") | ||
|
|
||
| args = parser.parse_args() | ||
| convert(args) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #!/usr/bin/env bash | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}") | ||
| TVM_DIR=$(cd "${SCRIPTS_DIR}" && git rev-parse --show-toplevel) | ||
| python3 "${TVM_DIR}/docs/script_convert.py" "${TVM_DIR}/gallery/how_to/work_with_microtvm/micro_tvmc.sh" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,9 +45,10 @@ run_pytest ctypes python-microtvm-stm32 tests/micro/stm32 | |
| run_pytest ctypes python-microtvm-common-qemu_x86 tests/micro/common --board=qemu_x86 | ||
| run_pytest ctypes python-microtvm-common-due tests/micro/common --test-build-only --board=due | ||
|
|
||
| # # Tutorials running with host CRT | ||
| # Tutorials | ||
| python3 gallery/how_to/work_with_microtvm/micro_tflite.py | ||
| python3 gallery/how_to/work_with_microtvm/micro_autotune.py | ||
| ./gallery/how_to/work_with_microtvm/micro_tvmc.sh | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we add this to
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This script requires zephyr.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah hmm. that is a bit challenging then....maybe my other questions are tricky to implement given this limitation of doc-builder.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that would be a bigger change. GPU docker image which is used for doc generation should be able to run Zephyr and other platforms in future. Other possibility is to have each docker step to run and convert the script which is related to their target and store the output in a shared directory which is passed to GPU doc stage. Not sure how much of this idea is feasible in our Jenkins configuration.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is almost what we do now (the GPU docker image runs the tutorials and sends a
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @driazati Does this work between executors? Can we run something on ci-qemu and pass it to ci-gpu for doc generation?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. k, so for this PR the delta is at least that now we test the tvmc commands to make sure they don't crash. next it would be great to do what @driazati mentioned, where we run script_convert.py in ci-qemu and then forward the output to the doc-builder step. let's merge this now though to make incremental progress. |
||
|
|
||
| # Tutorials running with Zephyr | ||
| export TVM_MICRO_USE_HW=1 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.