mehrdadh commented on code in PR #13955:
URL: https://github.com/apache/tvm/pull/13955#discussion_r1106398582
##########
.gitignore:
##########
@@ -277,3 +277,9 @@ gallery/how_to/work_with_microtvm/micro_tvmc.py
# GDB history file
.gdb_history
+
Review Comment:
yeah, I moved all the crt_config.h files under apps/microtvm, just need to
figure out the file under `src/runtime/micro` directory.
##########
apps/bundle_deploy/build_model.py:
##########
@@ -18,12 +18,15 @@
import argparse
import os
+import pathlib
+
from tvm import relay
import tvm
from tvm import runtime as tvm_runtime
import logging
from tvm.relay.backend import Runtime
from tvm.contrib import cc as _cc
+from tvm.micro import copy_crt_config_header
Review Comment:
I think these tests were already executed with the assumption of USE_MICRO=ON
check this file: tests/scripts/task_microtvm_cpp_tests.sh
##########
cmake/modules/StandaloneCrt.cmake:
##########
@@ -15,9 +15,11 @@
# specific language governing permissions and limitations
# under the License.
-
if(USE_MICRO)
+include(cmake/utils/CRTConfig.cmake)
Review Comment:
yeah, I'll wait for that to merge.
##########
apps/microtvm/zephyr/template_project/src/host_driven/main.c:
##########
@@ -90,9 +89,9 @@ void uart_irq_cb(const struct device* dev, void* user_data) {
// Write it into the ring buffer.
g_num_bytes_in_rx_buffer += rx_size;
- if (g_num_bytes_in_rx_buffer > RING_BUF_SIZE_BYTES) {
- TVMPlatformAbort((tvm_crt_error_t)0xbeef3);
- }
+ // if (g_num_bytes_in_rx_buffer > RING_BUF_SIZE_BYTES) {
Review Comment:
thanks for catching this, uncommented it.
##########
cmake/modules/Micro.cmake:
##########
@@ -15,8 +15,112 @@
# specific language governing permissions and limitations
# under the License.
+include(cmake/utils/CRTConfig.cmake)
+
if(USE_MICRO)
message(STATUS "Build with Micro support")
tvm_file_glob(GLOB RUNTIME_MICRO_SRCS src/runtime/micro/*.cc)
list(APPEND RUNTIME_SRCS ${RUNTIME_MICRO_SRCS})
endif(USE_MICRO)
+
+function(microtvm_add_platform_project_api platform)
+ if("${platform}" STREQUAL "zephyr")
+ list(
+ APPEND
+ PLATFORM_FILE_COPY_JOBS
+ "apps/microtvm/zephyr/template_project microtvm_api_server.py -> zephyr"
+ "python/tvm/micro/project_api server.py -> zephyr"
+ "apps/microtvm/zephyr/template_project launch_microtvm_api_server.sh ->
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_standalone_demo *.c ->
zephyr/src/aot_standalone_demo"
+ "apps/microtvm/zephyr/template_project/src/host_driven *.c ->
zephyr/src/host_driven"
+ "apps/microtvm/zephyr/template_project/src/host_driven *.h ->
zephyr/src/host_driven"
+ "apps/microtvm/zephyr/template_project/src/mlperftiny *.cc ->
zephyr/src/mlperftiny"
+ "3rdparty/mlperftiny/api * -> zephyr/src/mlperftiny/api"
+ "apps/microtvm/zephyr/template_project/fvp-hack * -> zephyr/fvp-hack"
+ "apps/microtvm/zephyr/template_project/qemu-hack * -> zephyr/qemu-hack"
+ "apps/microtvm/zephyr/template_project/app-overlay * ->
zephyr/app-overlay"
+ )
+ elseif("${platform}" STREQUAL "arduino")
+ list(
+ APPEND
+ PLATFORM_FILE_COPY_JOBS
+ "apps/microtvm/arduino/template_project microtvm_api_server.py ->
arduino"
+ "python/tvm/micro/project_api server.py -> arduino"
+ "apps/microtvm/arduino/template_project launch_microtvm_api_server.sh ->
arduino"
+ "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 Makefile.template -> arduino"
+ )
+ elseif("${platform}" STREQUAL "crt")
+ list(
+ APPEND
+ PLATFORM_FILE_COPY_JOBS
+ "src/runtime/crt/host microtvm_api_server.py -> crt"
+ "src/runtime/crt/host Makefile.template -> crt"
+ "src/runtime/crt/host **.cc -> crt/src"
+ )
+ else()
+ message(FATAL_ERROR "${platform} not supported.")
+ endif()
+
+ foreach(job_spec IN LISTS PLATFORM_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
+ "${platform} 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_CURRENT_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
+ "${platform} 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(platform_template_deps
+ ${job_src_base}/${copy_src} ${dest_path})
+ endforeach()
+ endforeach()
+ endforeach()
+
+ add_custom_target(${platform} DEPENDS ${platform_template_deps})
+endfunction()
+
+if(USE_MICRO)
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]