-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
µTVM CRT modifications for on-device RPC server #5921
Merged
Merged
Changes from 9 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
15a4ca0
Reorganize CRT into parts, public API, and add standalone build.
areusch da7daab
Add TVMFuncRegistry, CRT test infrastructure, and tests.
areusch 4e2688c
Add TVMErrorf()
areusch cf36cb3
[API_CHANGE] Integrate func registry into CRT.
areusch f664bbf
Generalize arena-based memory manager.
areusch 4e1e1c8
lint
areusch 5c724c0
Fix git-clang-format arg parsing
areusch a451506
add apache header
areusch fa4f0e6
add mutable func registry tests
areusch ea426db
Merge remote-tracking branch 'tvm/master' into utvm-crt-changes
areusch ad1a72a
git-clang-format
areusch 9ce722f
fix more lint
areusch 5ec235e
Move memory_test to crttests.
areusch c71fed9
fix tests
areusch d0988e1
checkpoint
areusch 99b8b95
checkpoint
areusch 349c04c
bundle_deploy demo_static works
areusch e7a251e
rm debug printf
areusch 773ae77
git-clang-format
areusch d496349
Merge remote-tracking branch 'tvm/master' into utvm-crt-changes
areusch 1c69010
fix lint
areusch 408d820
add asf header
areusch 2a9d157
pylint
areusch c19a346
update build configs for jenkins
areusch 008d92b
make regression compiler happy
areusch 099c254
fix build errors in regression GCC
areusch 622a66e
Merge remote-tracking branch 'tvm/master' into utvm-crt-changes
areusch f0ee8a6
address comments
areusch d1a7b42
git-clang-format
areusch d2cc3b9
fix for 32-bit cpp regression
areusch 0595624
fix incorrect use of memcpy and tests for 32-bit
areusch 9acf614
clang-format
areusch 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 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 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 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 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 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 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,134 @@ | ||
# 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_STANDALONE_CRT) | ||
message(STATUS "Build with standalone CRT") | ||
file(GLOB crt_srcs src/runtime/crt/**) | ||
|
||
function(tvm_crt_add_copy_file var src dest) | ||
get_filename_component(basename "${src}" NAME) | ||
get_filename_component(dest_parent_dir "${dest}" DIRECTORY) | ||
add_custom_command( | ||
OUTPUT "${dest}" | ||
COMMAND "${CMAKE_COMMAND}" -E copy "${src}" "${dest}" | ||
DEPENDS "${src}") | ||
list(APPEND "${var}" "${dest}") | ||
set("${var}" "${${var}}" PARENT_SCOPE) | ||
endfunction(tvm_crt_add_copy_file) | ||
|
||
# Build an isolated build directory, separate from the TVM tree. | ||
file(GLOB_RECURSE crt_srcs | ||
RELATIVE "${CMAKE_SOURCE_DIR}/src/runtime/crt" | ||
"${CMAKE_SOURCE_DIR}/src/runtime/crt/common/*.c" | ||
"${CMAKE_SOURCE_DIR}/src/runtime/crt/graph_runtime/*.c" | ||
"${CMAKE_SOURCE_DIR}/src/runtime/crt/include/*.h") | ||
|
||
foreach(src IN LISTS crt_srcs) | ||
tvm_crt_add_copy_file(host_isolated_build_deps ${CMAKE_SOURCE_DIR}/src/runtime/crt/${src} standalone_crt/${src}) | ||
endforeach() | ||
|
||
file(GLOB_RECURSE crt_headers RELATIVE "${CMAKE_SOURCE_DIR}/include" include/tvm/runtime/crt/*.h) | ||
foreach(hdr IN LISTS crt_headers) | ||
tvm_crt_add_copy_file(host_isolated_build_deps ${CMAKE_SOURCE_DIR}/include/${hdr} standalone_crt/include/${hdr}) | ||
endforeach() | ||
|
||
tvm_crt_add_copy_file(host_isolated_build_deps | ||
${CMAKE_SOURCE_DIR}/include/tvm/runtime/c_runtime_api.h standalone_crt/include/tvm/runtime/c_runtime_api.h) | ||
tvm_crt_add_copy_file(host_isolated_build_deps | ||
${CMAKE_SOURCE_DIR}/include/tvm/runtime/c_backend_api.h standalone_crt/include/tvm/runtime/c_backend_api.h) | ||
tvm_crt_add_copy_file(host_isolated_build_deps | ||
${CMAKE_SOURCE_DIR}/src/runtime/crt/Makefile standalone_crt/Makefile) | ||
|
||
get_filename_component(crt_config_abspath src/runtime/crt/host/crt_config.h ABSOLUTE) | ||
list(APPEND host_isolated_build_deps src/runtime/crt/host/crt_config.h) | ||
|
||
get_filename_component(host_build_dir_abspath "${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt" ABSOLUTE) | ||
|
||
if(${VERBOSE}) | ||
set(make_quiet QUIET=) | ||
else(${VERBOSE}) | ||
set(make_quiet ) | ||
endif(${VERBOSE}) | ||
add_custom_command( | ||
OUTPUT host_standalone_crt/common/libcommon.a host_standalone_crt/graph_runtime/libgraph_runtime.a | ||
COMMAND make | ||
DLPACK_INCLUDE_DIR=${CMAKE_SOURCE_DIR}/3rdparty/dlpack/include | ||
TVM_INCLUDE_DIR=${CMAKE_CURRENT_BINARY_DIR}/standalone_crt/include | ||
CRT_CONFIG=${crt_config_abspath} | ||
BUILD_DIR=${host_build_dir_abspath} all ${make_quiet} | ||
WORKING_DIRECTORY standalone_crt | ||
DEPENDS ${host_isolated_build_deps}) | ||
add_custom_target(host_standalone_crt SOURCES host_standalone_crt/common/libcommon.a host_standalone_crt/graph_runtime/libgraph_runtime.a) | ||
|
||
# add_custom_target(host_standalone_crt ALL | ||
# DEPENDS host_standalone_crt/common/libcommon.a host_standalone_crt/graph_runtime/libgraph_runtime.a) | ||
add_library(host_standalone_crt_common INTERFACE) | ||
add_dependencies(host_standalone_crt_common host_standalone_crt) | ||
target_link_libraries(host_standalone_crt_common | ||
INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/crt/common/libcommon.a) | ||
# set_target_properties(host_standalone_crt_common PROPERTIES | ||
# IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/crt/common | ||
# IMPORTED_OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/crt/common/libcommon.a | ||
# PUBLIC_HEADER ${crt_headers}) | ||
add_dependencies(host_standalone_crt_common host_standalone_crt) | ||
# ${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt/common/libcommon.a) | ||
|
||
add_library(host_standalone_crt_graph_runtime INTERFACE IMPORTED) | ||
add_dependencies(host_standalone_crt_graph_runtime host_standalone_crt) | ||
target_link_libraries(host_standalone_crt_graph_runtime | ||
INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/crt/graph_runtime/libgraph_runtime.a) | ||
|
||
# set_target_properties(host_standalone_crt_graph_runtime PROPERTIES | ||
# IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/crt/graph_runtime | ||
# IMPORTED_OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/crt/graph_runtime/libgraph_runtime.a | ||
# PUBLIC_HEADER ${crt_headers}) | ||
add_dependencies(host_standalone_crt_graph_runtime host_standalone_crt) | ||
# ${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt/graph_runtime/libgraph_runtime.a) | ||
|
||
# Standalone CRT tests | ||
file(GLOB TEST_SRCS ${CMAKE_SOURCE_DIR}/tests/crt/*.cc) | ||
find_path(GTEST_INCLUDE_DIR gtest/gtest.h) | ||
find_library(GTEST_LIB gtest "$ENV{GTEST_LIB}") | ||
|
||
# Create the `crttest` target if we can find GTest. If not, we create dummy | ||
# targets that give the user an informative error message. | ||
if(GTEST_INCLUDE_DIR AND GTEST_LIB) | ||
foreach(__srcpath ${TEST_SRCS}) | ||
get_filename_component(__srcname ${__srcpath} NAME) | ||
string(REPLACE ".cc" "" __execname ${__srcname}) | ||
add_executable(${__execname} ${__srcpath}) | ||
list(APPEND TEST_EXECS ${__execname}) | ||
target_include_directories(${__execname} PUBLIC ${GTEST_INCLUDE_DIR}) | ||
target_link_directories(${__execname} PRIVATE | ||
${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt/common | ||
${CMAKE_CURRENT_BINARY_DIR}/host_standalone_crt/graph_runtime) | ||
target_link_libraries(${__execname} common graph_runtime ${GTEST_LIB}) | ||
set_target_properties(${__execname} PROPERTIES EXCLUDE_FROM_ALL 1) | ||
set_target_properties(${__execname} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1) | ||
endforeach() | ||
add_custom_target(crttest DEPENDS ${TEST_EXECS}) | ||
elseif(NOT GTEST_INCLUDE_DIR) | ||
add_custom_target(crttest | ||
COMMAND echo "Missing Google Test headers in include path" | ||
COMMAND exit 1) | ||
elseif(NOT GTEST_LIB) | ||
add_custom_target(crttest | ||
COMMAND echo "Missing Google Test library" | ||
COMMAND exit 1) | ||
endif() | ||
|
||
endif(USE_STANDALONE_CRT) |
This file contains 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 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,54 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/*! | ||
* \file src/runtime/crt/error_codes.h | ||
* \brief Defines integral error codes returned by the CRT. | ||
*/ | ||
#ifndef TVM_RUNTIME_CRT_ERROR_CODES_H_ | ||
#define TVM_RUNTIME_CRT_ERROR_CODES_H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#define TVM_CRT_ERROR_CATEGORY_Pos 8 | ||
#define TVM_CRT_ERROR_CATEGORY_Msk (0xff << TVM_CRT_ERROR_CATEGORY_Pos) | ||
#define TVM_CRT_ERROR_CODE_Pos 0 | ||
#define TVM_CRT_ERROR_CODE_Msk (0xff << TVM_CRT_ERROR_CODE_Pos) | ||
|
||
#define DEFINE_TVM_CRT_ERROR(category, code) \ | ||
(((category) << TVM_CRT_ERROR_CATEGORY_Pos) | ((code) << TVM_CRT_ERROR_CODE_Pos)) | ||
typedef enum { kTvmErrorCategoryFunctionRegistry = 1 } tvm_crt_error_category_t; | ||
|
||
typedef enum { | ||
kTvmErrorNoError = 0, | ||
|
||
// Function Registry | ||
kTvmErrorFunctionNameNotFound = DEFINE_TVM_CRT_ERROR(kTvmErrorCategoryFunctionRegistry, 0), | ||
kTvmErrorFunctionIndexInvalid = DEFINE_TVM_CRT_ERROR(kTvmErrorCategoryFunctionRegistry, 1), | ||
kTvmErrorFunctionRegistryFull = DEFINE_TVM_CRT_ERROR(kTvmErrorCategoryFunctionRegistry, 2), | ||
kTvmErrorFunctionAlreadyDefined = DEFINE_TVM_CRT_ERROR(kTvmErrorCategoryFunctionRegistry, 3), | ||
} tvm_crt_error_t; | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // TVM_RUNTIME_CRT_ERROR_CODES_H_ |
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.
i think we should add this to the cmake config
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.
done