-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TOOL][NATIVE] Android native application for deploy and run (#13791)
* [TOOL][NATIVE] Android native appliction for deploy and run This application helps as a reference for verifying and integration of TVM compiled models on Android targets natively independent of RPC setup. tvmc will be used to for compiling tuning and to run it before deployment. This PR also covers * Enabling clml for tvmc compilation tool. * Graph runtime api "get_output_info" to return output tensor specification similar to "get_input_into" * This tool adds and enabled 3rdparty dependency "cnpy" to deal with npz files. * Update apps/cpp_rtvm/README.md Co-authored-by: Egor Churaev <egor.churaev@gmail.com> * Update apps/cpp_rtvm/README.md Co-authored-by: Egor Churaev <egor.churaev@gmail.com> * * review comments. * * proof reading * Update apps/cpp_rtvm/README.md Co-authored-by: Egor Churaev <egor.churaev@gmail.com> * * review Co-authored-by: Egor Churaev <egor.churaev@gmail.com>
- Loading branch information
1 parent
1d89071
commit 1f40b92
Showing
19 changed files
with
1,248 additions
and
3 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
cmake_policy(SET CMP0069 NEW) # suppress cmake warning about IPO | ||
|
||
set(RTVM_SOURCES | ||
main.cc | ||
tvm_runner.cc | ||
../../3rdparty/cnpy/cnpy.cpp | ||
) | ||
set(TVM_RUNNER_SOURCES | ||
tvm_runner.cc | ||
../../3rdparty/cnpy/cnpy.cpp | ||
) | ||
|
||
set(RTVM_LINKER_LIBS "") | ||
|
||
if(WIN32) | ||
list(APPEND RTVM_SOURCES win32_process.cc) | ||
list(APPEND TVM_RUNNER_SOURCES win32_process.cc) | ||
endif() | ||
|
||
# Set output to same directory as the other TVM libs | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) | ||
add_executable(rtvm ${RTVM_SOURCES}) | ||
add_library(tvm_runner_objs OBJECT ${TVM_RUNNER_SOURCES}) | ||
add_library(tvm_runner SHARED $<TARGET_OBJECTS:tvm_runner_objs>) | ||
|
||
include(CheckIPOSupported) | ||
check_ipo_supported(RESULT result OUTPUT output) | ||
if(result) | ||
set_property(TARGET rtvm PROPERTY INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE) | ||
endif() | ||
|
||
if(WIN32) | ||
target_compile_definitions(rtvm PUBLIC -DNOMINMAX) | ||
endif() | ||
|
||
if (OS) | ||
if (OS STREQUAL "Linux") | ||
set_property(TARGET rtvm PROPERTY LINK_FLAGS -lpthread) | ||
set_property(TARGET tvm_runner PROPERTY LINK_FLAGS -lpthread) | ||
endif() | ||
endif() | ||
|
||
if(USE_OPENCL) | ||
if (ANDROID_ABI) | ||
if(DEFINED ENV{ANDROID_NDK_MAJOR}) | ||
if($ENV{ANDROID_NDK_MAJOR} VERSION_LESS "23") | ||
set_property(TARGET rtvm PROPERTY LINK_FLAGS -fuse-ld=gold) | ||
set_property(TARGET tvm_runner PROPERTY LINK_FLAGS -fuse-ld=gold) | ||
endif() | ||
endif() | ||
endif() | ||
endif() | ||
|
||
target_include_directories( | ||
rtvm | ||
PUBLIC "../../include" | ||
PUBLIC "../../3rdparty/cnpy" | ||
PUBLIC DLPACK_PATH | ||
PUBLIC DMLC_PATH | ||
) | ||
|
||
if (BUILD_FOR_ANDROID AND USE_HEXAGON) | ||
get_hexagon_sdk_property("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}" | ||
DSPRPC_LIB DSPRPC_LIB_DIRS | ||
) | ||
if(DSPRPC_LIB_DIRS) | ||
link_directories(${DSPRPC_LIB_DIRS}) | ||
else() | ||
message(WARNING "Could not locate some Hexagon SDK components") | ||
endif() | ||
list(APPEND RTVM_LINKER_LIBS cdsprpc log) | ||
endif() | ||
|
||
if(USE_ETHOSN) | ||
if (ETHOSN_RUNTIME_LIBRARY) | ||
list(APPEND RTVM_LINKER_LIBS ${ETHOSN_RUNTIME_LIBRARY}) | ||
else() | ||
message(WARNING "Could not locate Arm(R) Ethos(TM)-N runtime library components") | ||
endif() | ||
endif() | ||
|
||
if(BUILD_STATIC_RUNTIME) | ||
list(APPEND RTVM_LINKER_LIBS -Wl,--whole-archive tvm_runtime -Wl,--no-whole-archive z) | ||
else() | ||
list(APPEND RTVM_LINKER_LIBS tvm_runtime z) | ||
endif() | ||
|
||
target_link_libraries(rtvm ${RTVM_LINKER_LIBS}) | ||
|
||
# Build tvm_runner as a exportable lib | ||
target_include_directories( | ||
tvm_runner_objs | ||
PUBLIC "../../include" | ||
PUBLIC "../../3rdparty/cnpy" | ||
PUBLIC DLPACK_PATH | ||
PUBLIC DMLC_PATH | ||
) | ||
target_link_libraries(tvm_runner ${RTVM_LINKER_LIBS}) |
Oops, something went wrong.