lite_support_asan

This commit is contained in:
sunsuodong 2021-05-18 10:13:37 +08:00
parent 7820e12396
commit 1b3ff6d0e5
8 changed files with 18 additions and 58 deletions

View File

@ -1,6 +1,6 @@
include(CMakePackageConfigHelpers)
set(RUNTIME_PKG_NAME ${MAIN_DIR}-${RUNTIME_COMPONENT_NAME})
set(RUNTIME_PKG_NAME ${PKG_NAME_PREFIX}-${RUNTIME_COMPONENT_NAME})
set(CODEGEN_ROOT_DIR ${RUNTIME_PKG_NAME}/tools/codegen)
set(CONVERTER_ROOT_DIR ${RUNTIME_PKG_NAME}/tools/converter)
@ -366,7 +366,7 @@ endif()
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
set(CPACK_COMPONENTS_ALL ${RUNTIME_COMPONENT_NAME})
set(CPACK_PACKAGE_FILE_NAME ${MAIN_DIR})
set(CPACK_PACKAGE_FILE_NAME ${PKG_NAME_PREFIX})
if(WIN32)
set(CPACK_PACKAGE_DIRECTORY ${TOP_DIR}/output)

View File

@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.14)
project(Lite)
set(BUILD_LITE "on")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3.0)
message(FATAL_ERROR "GCC version ${CMAKE_CXX_COMPILER_VERSION} must not be less than 7.3.0")
endif()
@ -47,34 +49,19 @@ if(ENABLE_ASAN)
endif()
endif()
set(DIR_PREFIX mindspore-lite)
set(MS_VERSION ${MS_VERSION_MAJOR}.${MS_VERSION_MINOR}.${MS_VERSION_REVISION})
set(MAIN_DIR ${DIR_PREFIX}-${MS_VERSION})
set(PKG_NAME_PREFIX mindspore-lite-${MS_VERSION_MAJOR}.${MS_VERSION_MINOR}.${MS_VERSION_REVISION})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMS_VERSION_MAJOR=${MS_VERSION_MAJOR} -DMS_VERSION_MINOR=${MS_VERSION_MINOR} \
-DMS_VERSION_REVISION=${MS_VERSION_REVISION}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMS_VERSION_MAJOR=${MS_VERSION_MAJOR} -DMS_VERSION_MINOR=${MS_VERSION_MINOR} \
-DMS_VERSION_REVISION=${MS_VERSION_REVISION}")
set(BUILD_MINDDATA "lite_cv" CACHE STRING "off, lite, lite_cv, wrapper or full")
set(BUILD_LITE "on")
set(PLATFORM_ARM "off")
if(PLATFORM_ARM64 OR PLATFORM_ARM32)
set(PLATFORM_ARM "on")
set(ENABLE_CONVERTER off)
#set for cross-compiling toolchain
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)
endif()
#if(BUILD_MINDDATA STREQUAL "lite" OR BUILD_MINDDATA STREQUAL "full" OR BUILD_MINDDATA STREQUAL "wrapper")
if(SUPPORT_GPU)
set(PROCESS_UNIT gpu)
elseif(SUPPORT_NPU)
set(PROCESS_UNIT npu)
else()
set(PROCESS_UNIT cpu)
endif()
if(SUBGRAPH_SPLIT)
add_compile_definitions(SUBGRAPH_SPLIT)
endif()
@ -242,25 +229,14 @@ if(ENABLE_MINDRT)
add_compile_definitions(ENABLE_MINDRT)
endif()
if(PLATFORM_ARM32 OR PLATFORM_ARM64)
if(NOT APPLE AND NOT DEFINED ENV{ANDROID_NDK})
message(FATAL_ERROR "env ANDROID_NDK should be set for ARM compile")
endif()
add_compile_definitions(ENABLE_ARM)
endif()
if(PLATFORM_ARM32)
add_definitions(-mfloat-abi=softfp -mfpu=neon)
add_compile_definitions(ENABLE_ARM32)
add_compile_definitions(ENABLE_ARM)
endif()
if(PLATFORM_ARM64)
add_compile_definitions(ENABLE_ARM64)
endif()
if(PLATFORM_ARM32 OR PLATFORM_ARM64)
if(ENABLE_CONVERTER)
set(BUILD_MINDDATA "off")
endif()
add_compile_definitions(ENABLE_ARM)
endif()
if(NOT PLATFORM_ARM32 AND NOT PLATFORM_ARM64)

View File

@ -58,7 +58,10 @@ set(JNI_SRC
${CMAKE_CURRENT_SOURCE_DIR}/runtime/lite_session.cpp
)
set(LITE_SO_NAME mindspore-lite)
if(SUPPORT_TRAIN)
set(LITE_SO_NAME mindspore-lite-train)
set(JNI_SRC
${JNI_SRC}
${CMAKE_CURRENT_SOURCE_DIR}/runtime/train_session.cpp
@ -69,7 +72,7 @@ add_library(mindspore-lite-jni SHARED ${JNI_SRC})
if(PLATFORM_ARM64 OR PLATFORM_ARM32)
find_library(log-lib log)
target_link_libraries(mindspore-lite-jni mindspore-lite ${log-lib})
target_link_libraries(mindspore-lite-jni ${LITE_SO_NAME} ${log-lib})
else()
target_link_libraries(mindspore-lite-jni mindspore-lite)
target_link_libraries(mindspore-lite-jni ${LITE_SO_NAME})
endif()

View File

@ -12,7 +12,6 @@ include(${TOP_DIR}/cmake/utils.cmake)
include(${TOP_DIR}/cmake/dependency_utils.cmake)
include(${TOP_DIR}/cmake/dependency_securec.cmake)
if(NOT PLATFORM_ARM64 AND NOT PLATFORM_ARM32)
set(ENABLE_CONVERTER ON)
set(BUILD_LITE ON)
include(${TOP_DIR}/cmake/external_libs/glog.cmake)
### flatbuffer
@ -30,8 +29,6 @@ if(NOT PLATFORM_ARM64 AND NOT PLATFORM_ARM32)
${CMAKE_BINARY_DIR}/schema/inner
"inner"
)
else()
set(ENABLE_CONVERTER OFF)
endif()

View File

@ -457,7 +457,6 @@ elseif(BUILD_MINDDATA STREQUAL "wrapper")
if(PLATFORM_ARM32 OR PLATFORM_ARM64)
target_link_libraries(minddata-lite log)
elseif(BUILD_MINDDATA_EXAMPLE)
endif()
elseif(BUILD_MINDDATA STREQUAL "lite")
list(REMOVE_ITEM MINDDATA_CORE_SRC_FILES "${MINDDATA_DIR}/core/client.cc")

View File

@ -200,22 +200,15 @@ if(SUPPORT_TRAIN)
target_link_libraries(mindspore-lite_static minddata-lite)
endif()
if(NOT APPLE AND PLATFORM_ARM)
set(NDK_STRIP
"${ANDROID_NDK}/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/aarch64-linux-android/bin/strip")
endif()
if(NOT APPLE AND "${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND PLATFORM_ARM)
add_custom_command(TARGET mindspore-lite POST_BUILD COMMAND ${NDK_STRIP}
${CMAKE_BINARY_DIR}/src/libmindspore-lite*.so)
endif()
target_link_libraries(mindspore-lite mslite_kernel_reg)
target_link_libraries(mindspore-lite_static mslite_kernel_reg)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
if(NOT APPLE AND PLATFORM_ARM)
set(NDK_STRIP
"${ANDROID_NDK}/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/aarch64-linux-android/bin/strip")
add_custom_command(TARGET mindspore-lite POST_BUILD COMMAND ${NDK_STRIP}
${CMAKE_BINARY_DIR}/src/libmindspore-lite*.so)
${CMAKE_BINARY_DIR}/src/libmindspore-lite*.so)
elseif(NOT WIN32)
add_custom_command(TARGET mindspore-lite POST_BUILD COMMAND strip ${CMAKE_BINARY_DIR}/src/libmindspore-lite*.so)
endif()

View File

@ -114,11 +114,6 @@ if(SUPPORT_GPU STREQUAL vulkan)
)
endif()
if(PLATFORM_ARM32 OR PLATFORM_ARM64)
if(ENABLE_CONVERTER)
set(BUILD_MINDDATA "off")
endif()
endif()
### runtime framework
add_definitions(-DENABLE_V0)
file(GLOB_RECURSE OPS_SRC ${LITE_DIR}/src/ops/*.cc)

View File

@ -18,6 +18,3 @@ add_library(quantizer_mid OBJECT ${QUANTIZER})
add_dependencies(quantizer_mid fbs_src)
add_dependencies(quantizer_mid fbs_inner_src)
if(ENABLE_ASAN)
target_link_libraries(quantizer_mid libasan libSecodefuzz)
endif()