[MSLITE] runtime convert

This commit is contained in:
ling 2021-10-19 09:02:38 +08:00
parent eb5c02725e
commit 0592c6983d
3 changed files with 39 additions and 15 deletions

View File

@ -13,6 +13,7 @@ set(RUNTIME_INC_DIR ${RUNTIME_PKG_NAME}/runtime/include)
set(RUNTIME_LIB_DIR ${RUNTIME_PKG_NAME}/runtime/lib) set(RUNTIME_LIB_DIR ${RUNTIME_PKG_NAME}/runtime/lib)
set(MIND_DATA_INC_DIR ${RUNTIME_PKG_NAME}/runtime/include/dataset) set(MIND_DATA_INC_DIR ${RUNTIME_PKG_NAME}/runtime/include/dataset)
set(TURBO_DIR ${RUNTIME_PKG_NAME}/runtime/third_party/libjpeg-turbo) set(TURBO_DIR ${RUNTIME_PKG_NAME}/runtime/third_party/libjpeg-turbo)
set(GLOG_DIR ${RUNTIME_PKG_NAME}/runtime/third_party/glog)
set(SECUREC_DIR ${RUNTIME_PKG_NAME}/runtime/third_party/securec) set(SECUREC_DIR ${RUNTIME_PKG_NAME}/runtime/third_party/securec)
set(MINDSPORE_LITE_LIB_NAME libmindspore-lite) set(MINDSPORE_LITE_LIB_NAME libmindspore-lite)
set(MINDSPORE_CORE_LIB_NAME libmindspore_core) set(MINDSPORE_CORE_LIB_NAME libmindspore_core)
@ -468,6 +469,12 @@ else()
install(FILES ${LITE_ACL_DIR}/mindspore_shared_lib/libmindspore_shared_lib.so install(FILES ${LITE_ACL_DIR}/mindspore_shared_lib/libmindspore_shared_lib.so
DESTINATION ${CONVERTER_ROOT_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME}) DESTINATION ${CONVERTER_ROOT_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME})
endif() endif()
if(MSLITE_ENABLE_RUNTIME_GLOG)
install(DIRECTORY ${glog_LIBPATH}/../include/glog/ DESTINATION ${RUNTIME_INC_DIR}/third_party/glog
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
install(FILES ${glog_LIBPATH}/libglog.so.0.4.0 DESTINATION ${GLOG_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
endif()
__install_micro_wrapper() __install_micro_wrapper()
__install_micro_codegen() __install_micro_codegen()
endif() endif()

View File

@ -31,6 +31,7 @@ option(MSLITE_ENABLE_ACL "enable ACL" off)
option(MSLITE_ENABLE_MODEL_ENCRYPTION "enable model encryption, only converter support" on) option(MSLITE_ENABLE_MODEL_ENCRYPTION "enable model encryption, only converter support" on)
option(MSLITE_ENABLE_SPARSE_COMPUTE "enable sparse kernel" off) option(MSLITE_ENABLE_SPARSE_COMPUTE "enable sparse kernel" off)
option(MSLITE_ENABLE_RUNTIME_CONVERT "enable runtime convert" off) option(MSLITE_ENABLE_RUNTIME_CONVERT "enable runtime convert" off)
option(MSLITE_ENABLE_RUNTIME_GLOG "enable runtime glog" off)
#Option that can be configured through manually #Option that can be configured through manually
option(ENABLE_VERBOSE "" off) option(ENABLE_VERBOSE "" off)
@ -106,6 +107,9 @@ endif()
if(DEFINED ENV{MSLITE_ENABLE_RUNTIME_CONVERT}) if(DEFINED ENV{MSLITE_ENABLE_RUNTIME_CONVERT})
set(MSLITE_ENABLE_RUNTIME_CONVERT $ENV{MSLITE_ENABLE_RUNTIME_CONVERT}) set(MSLITE_ENABLE_RUNTIME_CONVERT $ENV{MSLITE_ENABLE_RUNTIME_CONVERT})
endif() endif()
if(DEFINED ENV{MSLITE_ENABLE_RUNTIME_GLOG})
set(MSLITE_ENABLE_RUNTIME_GLOG $ENV{MSLITE_ENABLE_RUNTIME_GLOG})
endif()
if(TOOLCHAIN_NAME STREQUAL "himix200") if(TOOLCHAIN_NAME STREQUAL "himix200")
set(TARGET_HIMIX on) set(TARGET_HIMIX on)
@ -160,6 +164,7 @@ if(PLATFORM_ARM64 OR PLATFORM_ARM32)
set(MSLITE_ENABLE_SSE off) set(MSLITE_ENABLE_SSE off)
set(MSLITE_ENABLE_AVX off) set(MSLITE_ENABLE_AVX off)
set(MSLITE_ENABLE_CONVERTER off) set(MSLITE_ENABLE_CONVERTER off)
set(MSLITE_ENABLE_RUNTIME_GLOG off)
set(MSLITE_ENABLE_RUNTIME_CONVERT off) set(MSLITE_ENABLE_RUNTIME_CONVERT off)
#set for cross - compiling toolchain #set for cross - compiling toolchain
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
@ -170,9 +175,9 @@ else()
endif() endif()
if(MSLITE_ENABLE_RUNTIME_CONVERT) if(MSLITE_ENABLE_RUNTIME_CONVERT)
set(MSLITE_ENABLE_RUNTIME_GLOG on)
set(MSLITE_ENABLE_CONVERTER on) set(MSLITE_ENABLE_CONVERTER on)
set(MSLITE_ENABLE_V0 off) set(MSLITE_ENABLE_V0 off)
set(MSLITE_ENABLE_TRAIN off)
endif() endif()
if(MSLITE_ENABLE_TRAIN) if(MSLITE_ENABLE_TRAIN)
@ -225,6 +230,7 @@ message(STATUS "\tMSLITE_ENABLE_FP16 = \t${MSLITE_ENABLE_FP16}")
message(STATUS "\tMSLITE_ENABLE_MODEL_ENCRYPTION = \t${MSLITE_ENABLE_MODEL_ENCRYPTION}") message(STATUS "\tMSLITE_ENABLE_MODEL_ENCRYPTION = \t${MSLITE_ENABLE_MODEL_ENCRYPTION}")
message(STATUS "\tMSLITE_ENABLE_SPARSE_COMPUTE = \t${MSLITE_ENABLE_SPARSE_COMPUTE}") message(STATUS "\tMSLITE_ENABLE_SPARSE_COMPUTE = \t${MSLITE_ENABLE_SPARSE_COMPUTE}")
message(STATUS "\tMSLITE_ENABLE_RUNTIME_CONVERT = \t${MSLITE_ENABLE_RUNTIME_CONVERT}") message(STATUS "\tMSLITE_ENABLE_RUNTIME_CONVERT = \t${MSLITE_ENABLE_RUNTIME_CONVERT}")
message(STATUS "\tMSLITE_ENABLE_RUNTIME_GLOG = \t${MSLITE_ENABLE_RUNTIME_GLOG}")
if((MSLITE_ENABLE_CONVERTER OR MSLITE_ENABLE_TESTCASES) AND ( if((MSLITE_ENABLE_CONVERTER OR MSLITE_ENABLE_TESTCASES) AND (
NOT MSLITE_ENABLE_MINDRT NOT MSLITE_ENABLE_MINDRT

View File

@ -110,11 +110,18 @@ set(LITE_SRC
${CMAKE_CURRENT_SOURCE_DIR}/lite_session.cc ${CMAKE_CURRENT_SOURCE_DIR}/lite_session.cc
${CMAKE_CURRENT_SOURCE_DIR}/errorcode.cc ${CMAKE_CURRENT_SOURCE_DIR}/errorcode.cc
${CMAKE_CURRENT_SOURCE_DIR}/cpu_info.cc ${CMAKE_CURRENT_SOURCE_DIR}/cpu_info.cc
${CMAKE_CURRENT_SOURCE_DIR}/ops/ops_def.cc
${CMAKE_CURRENT_SOURCE_DIR}/ops/ops_utils.cc
) )
if(MSLITE_ENABLE_RUNTIME_CONVERT) if(MSLITE_ENABLE_RUNTIME_GLOG)
add_definitions(-DPRIMITIVE_WRITEABLE) add_definitions(-DPRIMITIVE_WRITEABLE)
add_definitions(-DUSE_GLOG) add_definitions(-DUSE_GLOG)
string(REPLACE "-fno-rtti" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
string(REPLACE "-fno-rtti" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
endif()
if(MSLITE_ENABLE_RUNTIME_CONVERT)
add_definitions(-DRUNTIME_CONVERT) add_definitions(-DRUNTIME_CONVERT)
file(GLOB RUNTIME_CONVERT_SRC file(GLOB RUNTIME_CONVERT_SRC
@ -294,6 +301,9 @@ if(MSVC)
set_target_properties(mindspore-lite_static PROPERTIES PREFIX lib) set_target_properties(mindspore-lite_static PROPERTIES PREFIX lib)
endif() endif()
target_link_libraries(mindspore-lite cpu_kernel_mid nnacl_mid cpu_ops_mid)
target_link_libraries(mindspore-lite_static cpu_kernel_mid nnacl_mid cpu_ops_mid)
if(MSLITE_ENABLE_MINDRT) if(MSLITE_ENABLE_MINDRT)
target_link_libraries(mindspore-lite mindrt_mid) target_link_libraries(mindspore-lite mindrt_mid)
target_link_libraries(mindspore-lite_static mindrt_mid) target_link_libraries(mindspore-lite_static mindrt_mid)
@ -314,16 +324,14 @@ endif()
if(MSLITE_GPU_BACKEND STREQUAL opencl) if(MSLITE_GPU_BACKEND STREQUAL opencl)
add_subdirectory(runtime/kernel/opencl) add_subdirectory(runtime/kernel/opencl)
target_link_libraries(mindspore-lite cpu_kernel_mid opencl_kernel_mid nnacl_mid cpu_ops_mid) target_link_libraries(mindspore-lite opencl_kernel_mid)
target_link_libraries(mindspore-lite_static cpu_kernel_mid opencl_kernel_mid nnacl_mid cpu_ops_mid) target_link_libraries(mindspore-lite_static opencl_kernel_mid)
elseif(MSLITE_GPU_BACKEND STREQUAL cuda) elseif(MSLITE_GPU_BACKEND STREQUAL cuda)
add_subdirectory(runtime/kernel/cuda) add_subdirectory(runtime/kernel/cuda)
target_link_libraries(mindspore-lite cpu_kernel_mid cuda_kernel_mid nnacl_mid cpu_ops_mid) target_link_libraries(mindspore-lite cuda_kernel_mid)
target_link_libraries(mindspore-lite_static cpu_kernel_mid cuda_kernel_mid nnacl_mid cpu_ops_mid) target_link_libraries(mindspore-lite_static cuda_kernel_mid)
else()
target_link_libraries(mindspore-lite cpu_kernel_mid nnacl_mid cpu_ops_mid)
target_link_libraries(mindspore-lite_static cpu_kernel_mid nnacl_mid cpu_ops_mid)
endif() endif()
if(SUPPORT_NPU) if(SUPPORT_NPU)
add_subdirectory(delegate/npu) add_subdirectory(delegate/npu)
target_link_libraries(mindspore-lite npu_kernel_mid) target_link_libraries(mindspore-lite npu_kernel_mid)
@ -365,19 +373,22 @@ if(PLATFORM_ARM)
endif() endif()
endif() endif()
if(MSLITE_ENABLE_RUNTIME_GLOG)
target_link_libraries(mindspore-lite mindspore::glog mindspore_core)
target_link_libraries(mindspore-lite_static mindspore::glog mindspore_core)
endif()
if(MSLITE_ENABLE_RUNTIME_CONVERT) if(MSLITE_ENABLE_RUNTIME_CONVERT)
target_link_libraries(mindspore-lite target_link_libraries(mindspore-lite
quantizer_mid fusion_mid proto_mid graph_pass_mid preprocess_mid quantizer_mid fusion_mid proto_mid graph_pass_mid preprocess_mid
cpu_kernel_mid ccsrc_src_mid converter_src_mid anf_exporter_mid cpu_kernel_mid ccsrc_src_mid converter_src_mid anf_exporter_mid
mindspore_core config_parser_mid mslite_converter_plugin config_parser_mid mslite_converter_plugin
-Wl,--whole-archive -Wl,--no-whole-archive ${SECUREC_LIBRARY} mindspore::protobuf ${SECUREC_LIBRARY})
mindspore::json mindspore::eigen mindspore::protobuf mindspore::glog)
target_link_libraries(mindspore-lite_static target_link_libraries(mindspore-lite_static
quantizer_mid fusion_mid proto_mid graph_pass_mid preprocess_mid quantizer_mid fusion_mid proto_mid graph_pass_mid preprocess_mid
cpu_kernel_mid ccsrc_src_mid converter_src_mid anf_exporter_mid cpu_kernel_mid ccsrc_src_mid converter_src_mid anf_exporter_mid
mindspore_core config_parser_mid mslite_converter_plugin config_parser_mid mslite_converter_plugin
-Wl,--whole-archive -Wl,--no-whole-archive ${SECUREC_LIBRARY} mindspore::protobuf ${SECUREC_LIBRARY})
mindspore::json mindspore::eigen mindspore::protobuf mindspore::glog)
endif() endif()
if(DEFINED ARCHS) if(DEFINED ARCHS)