-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[microTVM] Add microTVM Template Projects to tlcpack pip Package #9309
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d603cd4
zephyr lib fixed
mehrdadh 92d9416
restructure
mehrdadh 095da3c
readme
mehrdadh 17b27ed
Merge branch 'arduino_restructure' into add_micro_libs
mehrdadh 81a1e72
add arduino
mehrdadh 986bd59
add project template to setup.py
mehrdadh 1c01ea5
Merge branch 'apache:main' into add_micro_libs
mehrdadh d874407
fix lint
mehrdadh b37de64
fix tutorial
mehrdadh 2ae16fb
merge main
mehrdadh 142ae4a
address comments from PR9274
mehrdadh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| # 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. | ||
|
|
||
| if(USE_MICRO) | ||
| message(STATUS "Add Arduino for microTVM") | ||
|
|
||
| function(microtvm_add_arduino) | ||
| list( | ||
| APPEND | ||
| ARDUINO_FILE_COPY_JOBS | ||
| "apps/microtvm/arduino/template_project microtvm_api_server.py -> arduino" | ||
|
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 not copy the whole template_project?
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. we could. the only file that we don't need there is the README file. |
||
| "apps/microtvm/arduino/template_project boards.json -> arduino" | ||
| "apps/microtvm/arduino/template_project/src/example_project *.c -> arduino/src/example_project" | ||
| "apps/microtvm/arduino/template_project/src/example_project *.h -> arduino/src/example_project" | ||
| "apps/microtvm/arduino/template_project/src/example_project *.ino -> arduino/src/example_project" | ||
| "apps/microtvm/arduino/template_project/src/host_driven *.c -> arduino/src/host_driven" | ||
| "apps/microtvm/arduino/template_project/src/host_driven *.ino -> arduino/src/host_driven" | ||
| "apps/microtvm/arduino/template_project/crt_config *.h -> arduino/crt_config" | ||
| ) | ||
|
|
||
| foreach(job_spec IN LISTS ARDUINO_FILE_COPY_JOBS) | ||
| string(REPLACE " " ";" job_spec "${job_spec}") | ||
| list(LENGTH job_spec job_spec_length) | ||
| math(EXPR job_spec_length_mod "${job_spec_length} % 3") | ||
| if(NOT "${job_spec_length_mod}" EQUAL 1) | ||
| message( | ||
| FATAL_ERROR | ||
| "Arduino copy job spec list length is ${job_spec_length}; parsed job spec is ${job_spec}" | ||
| ) | ||
| endif() | ||
| math(EXPR job_spec_stop "${job_spec_length} - 3") | ||
|
|
||
| list(GET job_spec 0 job_src_base) | ||
| set(job_src_base "${CMAKE_SOURCE_DIR}/${job_src_base}") | ||
| foreach(copy_pattern_index RANGE 1 "${job_spec_stop}" 3) | ||
| list(GET job_spec ${copy_pattern_index} copy_pattern) | ||
| math(EXPR copy_dest_index "${copy_pattern_index} + 2") | ||
| list(GET job_spec ${copy_dest_index} copy_dest) | ||
|
|
||
| file( | ||
| GLOB_RECURSE copy_files | ||
| RELATIVE "${job_src_base}" | ||
| "${job_src_base}/${copy_pattern}") | ||
| list(LENGTH copy_files copy_files_length) | ||
| if("${copy_files_length}" EQUAL 0) | ||
| message( | ||
| FATAL_ERROR | ||
| "Arduino copy job matched 0 files: ${job_src_base}/${copy_pattern} -> ${copy_dest}" | ||
| ) | ||
| endif() | ||
| foreach(copy_src IN LISTS copy_files) | ||
| get_filename_component( | ||
| dest_path "${MICROTVM_TEMPLATE_PROJECTS}/${copy_dest}/${copy_src}" | ||
| ABSOLUTE) | ||
| tvm_micro_add_copy_file(arduino_template_deps | ||
| ${job_src_base}/${copy_src} ${dest_path}) | ||
| endforeach() | ||
| endforeach() | ||
| endforeach() | ||
|
|
||
| add_custom_target(arduino DEPENDS ${arduino_template_deps}) | ||
| endfunction() | ||
|
|
||
| microtvm_add_arduino() | ||
|
|
||
| endif(USE_MICRO) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| # 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. | ||
|
|
||
| if(USE_MICRO) | ||
| message(STATUS "Add Zephyr for microTVM") | ||
|
|
||
| function(microtvm_add_zephyr) | ||
| list( | ||
| APPEND | ||
| ZEPHYR_FILE_COPY_JOBS | ||
| "apps/microtvm/zephyr/template_project microtvm_api_server.py -> zephyr" | ||
| "apps/microtvm/zephyr/template_project boards.json -> zephyr" | ||
| "apps/microtvm/zephyr/template_project CMakeLists.txt.template -> zephyr" | ||
| "apps/microtvm/zephyr/template_project/src/aot_demo *.c -> zephyr/src/aot_demo" | ||
| "apps/microtvm/zephyr/template_project/src/aot_demo *.h -> zephyr/src/aot_demo" | ||
| "apps/microtvm/zephyr/template_project/src/host_driven *.c -> zephyr/src/host_driven" | ||
| "apps/microtvm/zephyr/template_project/qemu-hack * -> zephyr/qemu-hack" | ||
| "apps/microtvm/zephyr/template_project/crt_config *.h -> zephyr/crt_config" | ||
| ) | ||
|
|
||
| foreach(job_spec IN LISTS ZEPHYR_FILE_COPY_JOBS) | ||
| string(REPLACE " " ";" job_spec "${job_spec}") | ||
| list(LENGTH job_spec job_spec_length) | ||
| math(EXPR job_spec_length_mod "${job_spec_length} % 3") | ||
| if(NOT "${job_spec_length_mod}" EQUAL 1) | ||
| message( | ||
| FATAL_ERROR | ||
| "Zephyr copy job spec list length is ${job_spec_length}; parsed job spec is ${job_spec}" | ||
| ) | ||
| endif() | ||
| math(EXPR job_spec_stop "${job_spec_length} - 3") | ||
|
|
||
| list(GET job_spec 0 job_src_base) | ||
| set(job_src_base "${CMAKE_SOURCE_DIR}/${job_src_base}") | ||
| foreach(copy_pattern_index RANGE 1 "${job_spec_stop}" 3) | ||
| list(GET job_spec ${copy_pattern_index} copy_pattern) | ||
| math(EXPR copy_dest_index "${copy_pattern_index} + 2") | ||
| list(GET job_spec ${copy_dest_index} copy_dest) | ||
|
|
||
| file( | ||
| GLOB_RECURSE copy_files | ||
| RELATIVE "${job_src_base}" | ||
| "${job_src_base}/${copy_pattern}") | ||
| list(LENGTH copy_files copy_files_length) | ||
| if("${copy_files_length}" EQUAL 0) | ||
| message( | ||
| FATAL_ERROR | ||
| "Zephyr copy job matched 0 files: ${job_src_base}/${copy_pattern} -> ${copy_dest}" | ||
| ) | ||
| endif() | ||
| foreach(copy_src IN LISTS copy_files) | ||
| get_filename_component( | ||
| dest_path "${MICROTVM_TEMPLATE_PROJECTS}/${copy_dest}/${copy_src}" | ||
| ABSOLUTE) | ||
| tvm_micro_add_copy_file(zephyr_template_deps | ||
| ${job_src_base}/${copy_src} ${dest_path}) | ||
| endforeach() | ||
| endforeach() | ||
| endforeach() | ||
|
|
||
| add_custom_target(zephyr DEPENDS ${zephyr_template_deps}) | ||
| endfunction() | ||
|
|
||
| microtvm_add_zephyr() | ||
|
|
||
| endif(USE_MICRO) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: should add
r" string prefix(see https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals regarding backslashes)