-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[microTVM] additional refactoring for enabling USE_MICRO in more builds #13909
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 5 commits
67d948b
b840717
46a18ad
f46b47a
d5d5184
5224bda
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 |
|---|---|---|
|
|
@@ -15,41 +15,29 @@ | |
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
|
|
||
| if(USE_MICRO) | ||
|
|
||
| if(MSVC) | ||
|
|
||
| # When building for Windows, use standard CMake for compatibility with | ||
| # Visual Studio build tools and not require Make to be on the system. | ||
|
|
||
| # TODO: test building with this MSVC conditional code removed | ||
| # when USE_MICRO is enabled | ||
| message(STATUS "Build microTVM RPC common") | ||
|
|
||
| set(CRT_CONFIG, "src/runtime/micro/crt_config.h") | ||
| # add microTVM RPC common files to TVM runtime build | ||
| list(APPEND TVM_CRT_SOURCES | ||
| 3rdparty/libcrc/src/crcccitt.c | ||
| src/runtime/crt/microtvm_rpc_common/frame_buffer.cc | ||
| src/runtime/crt/microtvm_rpc_common/framing.cc | ||
| src/runtime/crt/microtvm_rpc_common/session.cc | ||
| src/runtime/crt/microtvm_rpc_common/write_stream.cc) | ||
|
|
||
| add_library(host_standalone_crt | ||
| STATIC | ||
| 3rdparty/libcrc/src/crcccitt.c | ||
| src/runtime/crt/microtvm_rpc_common/frame_buffer.cc | ||
| src/runtime/crt/microtvm_rpc_common/framing.cc | ||
| src/runtime/crt/microtvm_rpc_common/session.cc | ||
| src/runtime/crt/microtvm_rpc_common/write_stream.cc) | ||
| list(APPEND RUNTIME_SRCS ${TVM_CRT_SOURCES}) | ||
| include_directories(SYSTEM src/runtime/micro) | ||
|
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. Why the
Contributor
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. it needs a header in that directory to build those files that are in TVM_CRT_SOURCES, it's the same pattern used in other .cmake and CmakeLists.txt |
||
|
|
||
| target_include_directories(host_standalone_crt | ||
| PRIVATE | ||
| 3rdparty/libcrc/include | ||
| src/runtime/micro) | ||
|
|
||
| else() | ||
|
|
||
| function(create_crt_library CRT_LIBRARY) | ||
|
|
||
| set(CRT_LIBRARY_NAME host_standalone_crt_${CRT_LIBRARY}) | ||
| set(CRT_LIBRARY_SOURCES "") | ||
|
|
||
| foreach(FILE_NAME IN LISTS ARGN) | ||
| list(APPEND CRT_LIBRARY_SOURCES ${FILE_NAME}) | ||
| list(APPEND CRT_LIBRARY_SOURCES ${FILE_NAME}) | ||
| endforeach() | ||
|
|
||
| add_library(${CRT_LIBRARY_NAME} | ||
|
|
@@ -60,9 +48,9 @@ else() | |
| set(CRT_LIBRARIES ${CRT_LIBRARIES} ${CRT_LIBRARY_NAME} PARENT_SCOPE) | ||
|
|
||
| target_include_directories(${CRT_LIBRARY_NAME} | ||
| PUBLIC | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/micro/ | ||
| ${STANDALONE_CRT_BASE}/include) | ||
| PUBLIC | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/micro/ | ||
| ${STANDALONE_CRT_BASE}/include) | ||
|
|
||
| set_target_properties(${CRT_LIBRARY_NAME} | ||
| PROPERTIES | ||
|
|
@@ -75,7 +63,7 @@ else() | |
|
|
||
| endfunction() | ||
|
|
||
| message(STATUS "Build standalone CRT for microTVM") | ||
| message(STATUS "Build microTVM standalone CRT") | ||
|
|
||
| # Build an isolated build directory, separate from the TVM tree. | ||
| list(APPEND CRT_FILE_COPY_JOBS | ||
|
|
@@ -147,32 +135,36 @@ else() | |
| ${RUNTIME_CRT_SOURCE_DIR}/aot_executor_module/aot_executor_module.c) | ||
|
|
||
| create_crt_library(graph_executor | ||
| ${RUNTIME_CRT_SOURCE_DIR}/graph_executor/graph_executor.c | ||
| ${RUNTIME_CRT_SOURCE_DIR}/graph_executor/load_json.c) | ||
| ${RUNTIME_CRT_SOURCE_DIR}/graph_executor/graph_executor.c | ||
| ${RUNTIME_CRT_SOURCE_DIR}/graph_executor/load_json.c) | ||
|
|
||
| create_crt_library(graph_executor_module | ||
| ${RUNTIME_CRT_SOURCE_DIR}/graph_executor_module/graph_executor_module.c) | ||
| ${RUNTIME_CRT_SOURCE_DIR}/graph_executor_module/graph_executor_module.c) | ||
|
|
||
| create_crt_library(memory | ||
| ${RUNTIME_CRT_SOURCE_DIR}/memory/page_allocator.c | ||
| ${RUNTIME_CRT_SOURCE_DIR}/memory/stack_allocator.c) | ||
| ${RUNTIME_CRT_SOURCE_DIR}/memory/page_allocator.c | ||
| ${RUNTIME_CRT_SOURCE_DIR}/memory/stack_allocator.c) | ||
|
|
||
| create_crt_library(microtvm_rpc_common | ||
| ${RUNTIME_CRT_SOURCE_DIR}/microtvm_rpc_common/crcccitt.c | ||
| ${RUNTIME_CRT_SOURCE_DIR}/microtvm_rpc_common/frame_buffer.cc | ||
| ${RUNTIME_CRT_SOURCE_DIR}/microtvm_rpc_common/framing.cc | ||
| ${RUNTIME_CRT_SOURCE_DIR}/microtvm_rpc_common/session.cc | ||
| ${RUNTIME_CRT_SOURCE_DIR}/microtvm_rpc_common/write_stream.cc) | ||
| ${RUNTIME_CRT_SOURCE_DIR}/microtvm_rpc_common/crcccitt.c | ||
| ${RUNTIME_CRT_SOURCE_DIR}/microtvm_rpc_common/frame_buffer.cc | ||
| ${RUNTIME_CRT_SOURCE_DIR}/microtvm_rpc_common/framing.cc | ||
| ${RUNTIME_CRT_SOURCE_DIR}/microtvm_rpc_common/session.cc | ||
| ${RUNTIME_CRT_SOURCE_DIR}/microtvm_rpc_common/write_stream.cc) | ||
|
|
||
| create_crt_library(microtvm_rpc_server | ||
| ${RUNTIME_CRT_SOURCE_DIR}/microtvm_rpc_server/rpc_server.cc) | ||
|
|
||
| create_crt_library(common | ||
| ${RUNTIME_CRT_SOURCE_DIR}/common/crt_backend_api.c | ||
| ${RUNTIME_CRT_SOURCE_DIR}/common/crt_runtime_api.c | ||
| ${RUNTIME_CRT_SOURCE_DIR}/common/func_registry.c | ||
| ${RUNTIME_CRT_SOURCE_DIR}/common/ndarray.c | ||
| ${RUNTIME_CRT_SOURCE_DIR}/common/packed_func.c) | ||
| ${RUNTIME_CRT_SOURCE_DIR}/microtvm_rpc_server/rpc_server.cc) | ||
|
|
||
| if(NOT MSVC) | ||
| # TODO: if we want to eventually build standalone_crt for windows | ||
| # these files would be needed, but for now don't build them | ||
| create_crt_library(common | ||
| ${RUNTIME_CRT_SOURCE_DIR}/common/crt_backend_api.c | ||
| ${RUNTIME_CRT_SOURCE_DIR}/common/crt_runtime_api.c | ||
| ${RUNTIME_CRT_SOURCE_DIR}/common/func_registry.c | ||
| ${RUNTIME_CRT_SOURCE_DIR}/common/ndarray.c | ||
| ${RUNTIME_CRT_SOURCE_DIR}/common/packed_func.c) | ||
| endif() | ||
|
|
||
| add_custom_target(host_standalone_crt DEPENDS ${CRT_LIBRARIES} standalone_crt) | ||
|
|
||
|
|
@@ -188,15 +180,4 @@ else() | |
| gtest_discover_tests(crttest) | ||
| endif() | ||
|
|
||
| set(TVM_CRT_LINKER_LIB host_standalone_crt_microtvm_rpc_common) | ||
| if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") | ||
| list(APPEND TVM_RUNTIME_LINKER_LIBS -Wl,--whole-archive ${TVM_CRT_LINKER_LIB} -Wl,--no-whole-archive) | ||
| elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES ".*Clang") | ||
| list(APPEND TVM_RUNTIME_LINKER_LIBS -Wl,-force_load ${TVM_CRT_LINKER_LIB}) | ||
| else() | ||
| list(APPEND TVM_RUNTIME_LINKER_LIBS ${TVM_CRT_LINKER_LIB}) | ||
| endif() | ||
|
|
||
| endif() | ||
|
|
||
| endif() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,7 +112,7 @@ int TVMDeviceAllocDataSpaceWithScope(DLDevice dev, int ndim, const int64_t* shap | |
|
|
||
| int TVMDeviceFreeDataSpace(DLDevice dev, void* ptr) { return TVMPlatformMemoryFree(ptr, dev); } | ||
|
|
||
| static bool IsContiguous(const DLTensor* arr) { | ||
| TVM_ATTRIBUTE_UNUSED static bool IsContiguous(const DLTensor* arr) { | ||
|
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. Can you clarify why this was needed? was it for eliminating the warning?
Contributor
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.
|
||
| if (arr->strides == NULL) return true; | ||
| int64_t expected_stride = 1; | ||
| for (int32_t i = arr->ndim; i != 0; --i) { | ||
|
|
@@ -632,12 +632,12 @@ release_and_return : { | |
| } | ||
|
|
||
| // Default implementation, overridden by the platform runtime. | ||
| __attribute__((weak)) tvm_crt_error_t TVMPlatformGenerateRandom(uint8_t* buffer, size_t num_bytes) { | ||
| TVM_WEAK tvm_crt_error_t TVMPlatformGenerateRandom(uint8_t* buffer, size_t num_bytes) { | ||
| return kTvmErrorFunctionCallNotImplemented; | ||
| } | ||
|
|
||
| // Default implementation, overridden by the platform runtime. | ||
| __attribute__((weak)) tvm_crt_error_t TVMPlatformBeforeMeasurement() { return kTvmErrorNoError; } | ||
| TVM_WEAK tvm_crt_error_t TVMPlatformBeforeMeasurement() { return kTvmErrorNoError; } | ||
|
|
||
| // Default implementation, overridden by the platform runtime. | ||
| __attribute__((weak)) tvm_crt_error_t TVMPlatformAfterMeasurement() { return kTvmErrorNoError; } | ||
| TVM_WEAK tvm_crt_error_t TVMPlatformAfterMeasurement() { return kTvmErrorNoError; } | ||
Uh oh!
There was an error while loading. Please reload this page.