!14608 rename-pkg_name-for-micro

From: @yangjie159
Reviewed-by: @wangchengyuan,@HilbertDavid
Signed-off-by: @wangchengyuan
This commit is contained in:
mindspore-ci-bot 2021-04-02 17:31:20 +08:00 committed by Gitee
commit db574ff591
45 changed files with 152 additions and 192 deletions

View File

@ -30,25 +30,25 @@ endif()
if(BUILD_MINDDATA STREQUAL "full")
install(DIRECTORY ${TOP_DIR}/mindspore/ccsrc/minddata/dataset/liteapi/include/ DESTINATION
${MIND_DATA_INC_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
${MIND_DATA_INC_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
if(PLATFORM_ARM64)
file(GLOB JPEGTURBO_LIB_LIST ${jpeg_turbo_LIBPATH}/*.so)
install(FILES ${TOP_DIR}/mindspore/lite/build/minddata/libminddata-lite.so
DESTINATION ${MIND_DATA_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
DESTINATION ${MIND_DATA_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
install(FILES ${JPEGTURBO_LIB_LIST} DESTINATION ${TURBO_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME})
elseif(PLATFORM_ARM32)
file(GLOB JPEGTURBO_LIB_LIST ${jpeg_turbo_LIBPATH}/*.so)
install(FILES ${TOP_DIR}/mindspore/lite/build/minddata/libminddata-lite.so DESTINATION
${MIND_DATA_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
${MIND_DATA_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
install(FILES ${JPEGTURBO_LIB_LIST} DESTINATION ${TURBO_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME})
else()
install(FILES ${TOP_DIR}/mindspore/lite/build/minddata/libminddata-lite.so DESTINATION
${MIND_DATA_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
${MIND_DATA_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
install(FILES ${jpeg_turbo_LIBPATH}/libjpeg.so.62.3.0 DESTINATION ${TURBO_DIR}/lib
RENAME libjpeg.so.62 COMPONENT ${RUNTIME_COMPONENT_NAME})
RENAME libjpeg.so.62 COMPONENT ${RUNTIME_COMPONENT_NAME})
install(FILES ${jpeg_turbo_LIBPATH}/libturbojpeg.so.0.2.0 DESTINATION ${TURBO_DIR}/lib
RENAME libturbojpeg.so.0 COMPONENT ${RUNTIME_COMPONENT_NAME})
RENAME libturbojpeg.so.0 COMPONENT ${RUNTIME_COMPONENT_NAME})
endif()
endif()
@ -68,7 +68,7 @@ if(BUILD_MINDDATA STREQUAL "wrapper")
else()
install(FILES ${TOP_DIR}/mindspore/lite/build/minddata/libminddata-lite.so DESTINATION ${MIND_DATA_LIB_DIR}
COMPONENT ${RUNTIME_COMPONENT_NAME})
install(FILES ${jpeg_turbo_LIBPATH}/libjpeg.so.62.3.0 DESTINATION ${TURBO_DIR}/lib RENAME libjpeg.so.62
install(FILES ${jpeg_turbo_LIBPATH}/libjpeg.so.62.3.0 DESTINATION ${TURBO_DIR}/lib RENAME libjpeg.so.62
COMPONENT ${RUNTIME_COMPONENT_NAME})
install(FILES ${jpeg_turbo_LIBPATH}/libturbojpeg.so.0.2.0 DESTINATION ${TURBO_DIR}/lib RENAME libturbojpeg.so.0
COMPONENT ${RUNTIME_COMPONENT_NAME})
@ -153,8 +153,19 @@ if(PLATFORM_ARM64)
COMPONENT ${RUNTIME_COMPONENT_NAME})
install(DIRECTORY ${TOP_DIR}/include/api/ DESTINATION ${RUNTIME_INC_DIR}/api
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "ops*" EXCLUDE)
install(DIRECTORY ${TOP_DIR}/mindspore/lite/build/operator_library DESTINATION ${CODEGEN_ROOT_DIR}
COMPONENT ${RUNTIME_COMPONENT_NAME})
file(GLOB NNACL_FILES GLOB ${TOP_DIR}/mindspore/lite/nnacl/*.h)
install(FILES ${NNACL_FILES} DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl COMPONENT ${RUNTIME_COMPONENT_NAME})
install(DIRECTORY ${TOP_DIR}/mindspore/lite/nnacl/base DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${TOP_DIR}/mindspore/lite/nnacl/int8 DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${TOP_DIR}/mindspore/lite/nnacl/fp32 DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${TOP_DIR}/mindspore/lite/nnacl/intrinsics DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${TOP_DIR}/mindspore/lite/micro/coder/wrapper DESTINATION ${CODEGEN_ROOT_DIR}/include
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
install(TARGETS wrapper ARCHIVE DESTINATION ${CODEGEN_ROOT_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME})
if(ENABLE_TOOLS)
install(TARGETS ${BENCHMARK_NAME} RUNTIME DESTINATION ${BENCHMARK_ROOT_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
endif()
@ -174,8 +185,19 @@ elseif(PLATFORM_ARM32)
COMPONENT ${RUNTIME_COMPONENT_NAME})
install(DIRECTORY ${TOP_DIR}/include/api/ DESTINATION ${RUNTIME_INC_DIR}/api
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "ops*" EXCLUDE)
install(DIRECTORY ${TOP_DIR}/mindspore/lite/build/operator_library DESTINATION ${CODEGEN_ROOT_DIR}
COMPONENT ${RUNTIME_COMPONENT_NAME})
file(GLOB NNACL_FILES GLOB ${TOP_DIR}/mindspore/lite/nnacl/*.h)
install(FILES ${NNACL_FILES} DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl COMPONENT ${RUNTIME_COMPONENT_NAME})
install(DIRECTORY ${TOP_DIR}/mindspore/lite/nnacl/base DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${TOP_DIR}/mindspore/lite/nnacl/int8 DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${TOP_DIR}/mindspore/lite/nnacl/fp32 DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${TOP_DIR}/mindspore/lite/nnacl/intrinsics DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${TOP_DIR}/mindspore/lite/micro/coder/wrapper DESTINATION ${CODEGEN_ROOT_DIR}/include
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
install(TARGETS wrapper ARCHIVE DESTINATION ${CODEGEN_ROOT_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME})
if(ENABLE_TOOLS)
install(TARGETS ${BENCHMARK_NAME} RUNTIME DESTINATION ${BENCHMARK_ROOT_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
endif()
@ -240,7 +262,27 @@ else()
install(FILES ${glog_LIBPATH}/libglog.so.0.4.0
DESTINATION ${CONVERTER_ROOT_DIR}/third_party/glog/lib RENAME libglog.so.0
COMPONENT ${RUNTIME_COMPONENT_NAME})
install(DIRECTORY ${TOP_DIR}/mindspore/lite/build/operator_library DESTINATION ${CODEGEN_ROOT_DIR}
file(GLOB NNACL_FILES GLOB ${TOP_DIR}/mindspore/lite/nnacl/*.h)
install(FILES ${NNACL_FILES} DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl COMPONENT ${RUNTIME_COMPONENT_NAME})
install(DIRECTORY ${TOP_DIR}/mindspore/lite/nnacl/base DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${TOP_DIR}/mindspore/lite/nnacl/int8 DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${TOP_DIR}/mindspore/lite/nnacl/fp32 DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${TOP_DIR}/mindspore/lite/nnacl/intrinsics DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${TOP_DIR}/mindspore/lite/micro/coder/wrapper DESTINATION ${CODEGEN_ROOT_DIR}/include
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
install(TARGETS wrapper ARCHIVE DESTINATION ${CODEGEN_ROOT_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME})
set(MICRO_CMSIS_DIR ${CMAKE_BINARY_DIR}/cmsis/CMSIS)
install(DIRECTORY ${MICRO_CMSIS_DIR}/Core/Include DESTINATION ${CODEGEN_ROOT_DIR}/third_party/include/CMSIS/Core
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${MICRO_CMSIS_DIR}/DSP/Include DESTINATION ${CODEGEN_ROOT_DIR}/third_party/include/CMSIS/DSP
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${MICRO_CMSIS_DIR}/NN/Include DESTINATION ${CODEGEN_ROOT_DIR}/third_party/include/CMSIS/NN
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
install(TARGETS cmsis_nn ARCHIVE DESTINATION ${CODEGEN_ROOT_DIR}/third_party/lib
COMPONENT ${RUNTIME_COMPONENT_NAME})
install(TARGETS codegen RUNTIME DESTINATION ${CODEGEN_ROOT_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
endif()

View File

@ -1,21 +1,20 @@
set(CMSIS_DIR ${LITE_DIR}/micro/build/cmsis)
if(MICRO_CMSIS_X86)
message("build cmsis kernels")
include_directories(${CMSIS_DIR}/CMSIS/Core/Include)
include_directories(${CMSIS_DIR}/CMSIS/DSP/Include)
include_directories(${CMSIS_DIR}/CMSIS/NN/Include)
set(CMSIS_DIR ${CMAKE_BINARY_DIR}/cmsis)
message("build cmsis kernels")
include_directories(${CMSIS_DIR}/CMSIS/Core/Include)
include_directories(${CMSIS_DIR}/CMSIS/DSP/Include)
include_directories(${CMSIS_DIR}/CMSIS/NN/Include)
file(REMOVE ${CMSIS_DIR}/CMSIS/NN/Source/NNSupportFunctions/arm_q7_to_q15_reordered_no_shift.c)
file(REMOVE ${CMSIS_DIR}/CMSIS/NN/Source/NNSupportFunctions/arm_q7_to_q15_reordered_no_shift.c)
file(GLOB CMSIS_OPS
${CMSIS_DIR}/CMSIS/NN/Source/BasicMathFunctions/*.c
${CMSIS_DIR}/CMSIS/NN/Source/ActivationFunctions/*.c
${CMSIS_DIR}/CMSIS/NN/Source/ConcatenationFunctions/*.c
${CMSIS_DIR}/CMSIS/NN/Source/ConvolutionFunctions/*.c
${CMSIS_DIR}/CMSIS/NN/Source/FullyConnectedFunctions/*.c
${CMSIS_DIR}/CMSIS/NN/Source/NNSupportFunctions/*.c
${CMSIS_DIR}/CMSIS/NN/Source/PoolingFunctions/*.c
${CMSIS_DIR}/CMSIS/NN/Source/ReshapeFunctions/*.c
${CMSIS_DIR}/CMSIS/NN/Source/SoftmaxFunctions/*.c
)
file(GLOB CMSIS_OPS
${CMSIS_DIR}/CMSIS/NN/Source/BasicMathFunctions/*.c
${CMSIS_DIR}/CMSIS/NN/Source/ActivationFunctions/*.c
${CMSIS_DIR}/CMSIS/NN/Source/ConcatenationFunctions/*.c
${CMSIS_DIR}/CMSIS/NN/Source/ConvolutionFunctions/*.c
${CMSIS_DIR}/CMSIS/NN/Source/FullyConnectedFunctions/*.c
${CMSIS_DIR}/CMSIS/NN/Source/NNSupportFunctions/*.c
${CMSIS_DIR}/CMSIS/NN/Source/PoolingFunctions/*.c
${CMSIS_DIR}/CMSIS/NN/Source/ReshapeFunctions/*.c
${CMSIS_DIR}/CMSIS/NN/Source/SoftmaxFunctions/*.c
)
endif()

View File

@ -1,7 +1,5 @@
include_directories(${LITE_DIR}/micro/coder/operator_library)
set(WRAPPER_DIR ${LITE_DIR}/micro/coder/operator_library/wrapper/)
include_directories(${LITE_DIR}/micro/coder/)
set(WRAPPER_DIR ${LITE_DIR}/micro/coder/wrapper/)
set(WRAPPER_SRC
${WRAPPER_DIR}/base/common_wrapper.c

View File

@ -24,7 +24,7 @@ include_directories(${MICRO_DIR})
include(${TOP_DIR}/cmake/external_libs/cmsis.cmake)
include(${MICRO_DIR}/cmake/file_list.cmake)
include(${MICRO_DIR}/cmake/package_wrapper.cmake)
add_subdirectory(operator_library)
add_subdirectory(wrapper)
if(ENABLE_CONVERTER)
add_executable(codegen main.cc ${FILE_SET})

View File

@ -30,23 +30,22 @@ get_filename_component(PKG_PATH ${PKG_PATH} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_BI
set(HEADER_PATH ${PKG_PATH}/inference)
option(MICRO_BUILD_ARM64 "build android arm64" OFF)
option(MICRO_BUILD_ARM32A "build android arm32" OFF)
option(PLATFORM_ARM64 "build android arm64" OFF)
option(PLATFORM_ARM32 "build android arm32" OFF)
add_compile_definitions(NOT_USE_STL)
if(MICRO_BUILD_ARM64 OR MICRO_BUILD_ARM32A)
if(PLATFORM_ARM64 OR PLATFORM_ARM32)
add_compile_definitions(ENABLE_NEON)
add_compile_definitions(ENABLE_ARM)
endif()
if(MICRO_BUILD_ARM64)
if(PLATFORM_ARM64)
add_compile_definitions(ENABLE_ARM64)
endif()
if(MICRO_BUILD_ARM32A)
if(PLATFORM_ARM32)
add_compile_definitions(ENABLE_ARM32)
add_definitions(-mfloat-abi=softfp -mfpu=neon)
endif()
set(CMAKE_C_FLAGS "${CMAKE_ENABLE_C99} ${CMAKE_C_FLAGS}")
@ -88,8 +87,9 @@ endif()
get_filename_component(PKG_PATH ${PKG_PATH} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(OP_LIB ${PKG_PATH}/tools/codegen/operator_library/lib/libops.a)
set(OP_HEADER_PATH ${PKG_PATH}/tools/codegen/operator_library/include)
set(OP_LIB ${PKG_PATH}/inference/lib/libmindspore-lite.a)
set(WRAPPER_LIB ${PKG_PATH}/tools/codegen/lib/libwrapper.a)
set(OP_HEADER_PATH ${PKG_PATH}/tools/codegen/include)
set(HEADER_PATH ${PKG_PATH}/inference)
message("operator lib path: ${OP_LIB}")
@ -100,23 +100,29 @@ add_compile_definitions(NOT_USE_STL)
include_directories(${OP_HEADER_PATH})
include_directories(${HEADER_PATH})
if(NOT PLATFORM_ARM32 AND NOT PLATFORM_ARM64)
include_directories(${PKG_PATH}/tools/codegen/third_party/include)
include_directories(${PKG_PATH}/tools/codegen/third_party/include/CMSIS/Core/Include)
include_directories(${PKG_PATH}/tools/codegen/third_party/include/CMSIS/DSP/Include)
include_directories(${PKG_PATH}/tools/codegen/third_party/include/CMSIS/NN/Include)
endif()
include(net.cmake)
option(MICRO_BUILD_ARM64 "build android arm64" OFF)
option(MICRO_BUILD_ARM32A "build android arm32" OFF)
option(PLATFORM_ARM64 "build android arm64" OFF)
option(PLATFORM_ARM32 "build android arm32" OFF)
if(MICRO_BUILD_ARM64 OR MICRO_BUILD_ARM32A)
if(PLATFORM_ARM64 OR PLATFORM_ARM32)
add_compile_definitions(ENABLE_NEON)
add_compile_definitions(ENABLE_ARM)
endif()
if(MICRO_BUILD_ARM64)
if(PLATFORM_ARM64)
add_compile_definitions(ENABLE_ARM64)
endif()
if(MICRO_BUILD_ARM32A)
if(PLATFORM_ARM32)
add_compile_definitions(ENABLE_ARM32)
add_definitions(-mfloat-abi=softfp -mfpu=neon)
endif()
set(CMAKE_C_FLAGS "${CMAKE_ENABLE_C99} ${CMAKE_C_FLAGS}")
@ -143,11 +149,17 @@ function(create_library)
COMMAND rm -rf tmp
COMMAND mkdir tmp
COMMAND cd tmp && ar -x ${OP_LIB}
COMMAND cd tmp && ar -x ${WRAPPER_LIB}
COMMAND echo "raw static library ${library_name} size:"
COMMAND ls -lh ${library_name}
COMMAND mv ${library_name} ./tmp && cd tmp && ar -x ${library_name}
COMMENT "unzip raw static library ${library_name}"
)
if(NOT PLATFORM_ARM32 AND NOT PLATFORM_ARM64)
set(CMSIS_LIB ${PKG_PATH}/tools/codegen/third_party/lib/libcmsis_nn.a)
add_custom_command(TARGET net POST_BUILD COMMAND cd tmp && ar -x ${CMSIS_LIB})
endif()
foreach(object_file ${OP_SRC})
add_custom_command(TARGET net POST_BUILD COMMAND mv ./tmp/${object_file} .)
endforeach()

View File

@ -1,120 +0,0 @@
option(MICRO_CMSIS_X86 "build for CMSIS x86" ON)
option(ENABLE_ASAN "enable asan" OFF)
option(CMAKE_BUILD_TYPE "debug or release" Debug)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(DEBUG_MODE "Debug")
endif()
set(CMAKE_C_FLAGS "${CMAKE_ENABLE_C99} ${CMAKE_C_FLAGS}")
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(CMAKE_C_FLAGS "-DDebug -g -fvisibility=default ${CMAKE_C_FLAGS}")
else()
set(CMAKE_C_FLAGS "-fPIC -fPIE -Werror -O3 -fstack-protector-strong -fomit-frame-pointer ${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS_Release "${CMAKE_C_FLAGS_Release} -O3 -ffunction-sections -fdata-sections")
string(REPLACE "-g" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
endif()
if(ENABLE_ASAN)
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} ${OPTION_CXX_FLAGS} -lasan")
endif()
include_directories(${LITE_DIR})
set(MICRO_CMAKE_PATH ${MICRO_DIR}/cmake)
set(OPERATOR_LIBRARY_PATH ${CMAKE_BINARY_DIR}/operator_library)
set(HEADER_PATH "${OPERATOR_LIBRARY_PATH}/include")
set(LIB_PATH "${OPERATOR_LIBRARY_PATH}/lib")
set(NNACL_DIR ${LITE_DIR}/nnacl)
message("===========>start to pack operators' head file")
file(REMOVE_RECURSE ${OPERATOR_LIBRARY_PATH})
file(MAKE_DIRECTORY ${OPERATOR_LIBRARY_PATH})
file(GLOB NNACL_FILES GLOB ${LITE_DIR}/nnacl/*.h)
file(COPY ${NNACL_FILES} DESTINATION ${HEADER_PATH}/nnacl/)
file(COPY ${LITE_DIR}/nnacl/base
${LITE_DIR}/nnacl/int8
${LITE_DIR}/nnacl/fp32
${LITE_DIR}/nnacl/intrinsics
DESTINATION ${HEADER_PATH}/nnacl FILES_MATCHING PATTERN "*.h")
file(COPY ${MICRO_DIR}/coder/operator_library/wrapper DESTINATION ${HEADER_PATH} FILES_MATCHING PATTERN "*.h")
file(COPY ${CMAKE_BINARY_DIR}/cmsis/CMSIS/Core/Include
${CMAKE_BINARY_DIR}/cmsis/CMSIS/DSP/Include
${CMAKE_BINARY_DIR}/cmsis/CMSIS/NN/Include
DESTINATION ${HEADER_PATH}/CMSIS/Core)
if(PLATFORM_ARM64)
add_compile_definitions(ENABLE_ARM64)
endif()
if(PLATFORM_ARM32)
add_compile_definitions(ENABLE_ARM32)
add_definitions(-mfloat-abi=softfp -mfpu=neon)
endif()
if(PLATFORM_ARM64 OR PLATFORM_ARM32)
add_compile_definitions(ENABLE_NEON)
add_compile_definitions(ENABLE_ARM)
endif()
file(GLOB KERNEL_SRC
${NNACL_DIR}/*.c
${NNACL_DIR}/base/*.c
${NNACL_DIR}/fp32/*.c
${NNACL_DIR}/int8/*.c
)
if(PLATFORM_ARM64)
file(GLOB ASSEMBLY_SRC ${NNACL_DIR}/assembly/arm64/*.S)
set_property(SOURCE ${ASSEMBLY_SRC} PROPERTY LANGUAGE C)
endif()
if(PLATFORM_ARM32)
file(GLOB ASSEMBLY_SRC ${NNACL_DIR}/assembly/arm32/*.S)
set_property(SOURCE ${ASSEMBLY_SRC} PROPERTY LANGUAGE C)
endif()
set(NNACL_OPS ${KERNEL_SRC} ${ASSEMBLY_SRC})
set(RUNTIME_SRC ${LITE_DIR}/src/runtime/thread_pool.c)
include(${MICRO_CMAKE_PATH}/package_cmsis.cmake)
include(${MICRO_CMAKE_PATH}/package_wrapper.cmake)
list(APPEND OP_FILES ${NNACL_OPS} ${WRAPPER_SRC} ${RUNTIME_SRC})
if(NOT PLATFORM_ARM64 AND NOT PLATFORM_ARM32)
list(APPEND OP_FILES ${CMSIS_OPS})
endif()
# generate static library
add_library(ops STATIC ${OP_FILES})
function(create_library)
string(CONCAT library_name "lib" ops ".a")
string(CONCAT opt_name "lib" opt_ops ".a")
set(ANDROID_AR
${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar)
add_custom_command(TARGET ops
POST_BUILD
COMMAND rm -rf tmp
COMMAND mkdir tmp
COMMAND mv ${opt_name} ./tmp && cd ./tmp && ${ANDROID_AR} -x ${opt_name}
COMMAND mv ${library_name} ./tmp && cd ./tmp && ${ANDROID_AR} -x ${library_name}
COMMENT "unzip raw static library ${library_name}"
COMMAND ${ANDROID_AR} cr ${library_name} ./tmp/*.o
COMMAND rm -rf tmp
COMMENT "generate specified static library ${library_name}"
)
endfunction()
if(PLATFORM_ARM64)
file(GLOB OPT_SRC ${NNACL_DIR}/assembly/opt/*.S)
set_property(SOURCE ${OPT_SRC} PROPERTY LANGUAGE C)
add_library(opt_ops STATIC ${OPT_SRC})
add_dependencies(ops opt_ops)
set_target_properties(opt_ops PROPERTIES COMPILE_FLAGS -march=armv8.2-a+dotprod)
create_library()
endif()
install(TARGETS ops ARCHIVE DESTINATION ${LIB_PATH})

View File

@ -0,0 +1,29 @@
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(CMAKE_C_FLAGS "-DDebug -g -fvisibility=default ${CMAKE_C_FLAGS}")
else()
set(CMAKE_C_FLAGS "-fPIC -fPIE -Werror -O3 -fstack-protector-strong -fomit-frame-pointer ${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS_Release "${CMAKE_C_FLAGS_Release} -O3 -ffunction-sections -fdata-sections")
string(REPLACE "-g" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
endif()
include_directories(${LITE_DIR})
set(OPERATOR_LIBRARY_PATH ${CMAKE_BINARY_DIR}/operator_library)
set(HEADER_PATH "${OPERATOR_LIBRARY_PATH}/include")
if(PLATFORM_ARM64)
add_compile_definitions(ENABLE_ARM64)
add_compile_definitions(ENABLE_NEON)
add_compile_definitions(ENABLE_ARM)
elseif(PLATFORM_ARM32)
add_compile_definitions(ENABLE_ARM32)
add_compile_definitions(ENABLE_NEON)
add_compile_definitions(ENABLE_ARM)
else()
include(${MICRO_DIR}/cmake/package_cmsis.cmake)
add_library(cmsis_nn STATIC ${CMSIS_OPS})
endif()
include(${MICRO_DIR}/cmake/package_wrapper.cmake)
# generate static library
add_library(wrapper STATIC ${WRAPPER_SRC})

View File

@ -10,22 +10,22 @@ get_filename_component(PKG_PATH ${PKG_PATH} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_BI
set(HEADER_PATH ${PKG_PATH}/inference)
option(MICRO_BUILD_ARM64 "build android arm64" OFF)
option(MICRO_BUILD_ARM32A "build android arm32" OFF)
option(PLATFORM_ARM64 "build android arm64" OFF)
option(PLATFORM_ARM32 "build android arm32" OFF)
add_compile_definitions(NOT_USE_STL)
if(MICRO_BUILD_ARM64 OR MICRO_BUILD_ARM32A)
if(PLATFORM_ARM64 OR PLATFORM_ARM32)
add_compile_definitions(ENABLE_NEON)
add_compile_definitions(ENABLE_ARM)
endif()
if(MICRO_BUILD_ARM64)
if(PLATFORM_ARM64)
add_compile_definitions(ENABLE_ARM64)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8.2-a+dotprod")
endif()
if(MICRO_BUILD_ARM32A)
if(PLATFORM_ARM32)
add_compile_definitions(ENABLE_ARM32)
add_definitions(-mfloat-abi=softfp -mfpu=neon)
endif()

View File

@ -22,20 +22,20 @@ include_directories(${HEADER_PATH})
include(net.cmake)
option(MICRO_BUILD_ARM64 "build android arm64" OFF)
option(MICRO_BUILD_ARM32A "build android arm32" OFF)
option(PLATFORM_ARM64 "build android arm64" OFF)
option(PLATFORM_ARM32 "build android arm32" OFF)
if(MICRO_BUILD_ARM64 OR MICRO_BUILD_ARM32A)
if(PLATFORM_ARM64 OR PLATFORM_ARM32)
add_compile_definitions(ENABLE_NEON)
add_compile_definitions(ENABLE_ARM)
endif()
if(MICRO_BUILD_ARM64)
if(PLATFORM_ARM64)
add_compile_definitions(ENABLE_ARM64)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8.2-a+dotprod")
endif()
if(MICRO_BUILD_ARM32A)
if(PLATFORM_ARM32)
add_compile_definitions(ENABLE_ARM32)
add_definitions(-mfloat-abi=softfp -mfpu=neon)
endif()

View File

@ -10,22 +10,22 @@ get_filename_component(PKG_PATH ${PKG_PATH} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_BI
set(HEADER_PATH ${PKG_PATH}/inference)
option(MICRO_BUILD_ARM64 "build android arm64" OFF)
option(MICRO_BUILD_ARM32A "build android arm32" OFF)
option(PLATFORM_ARM64 "build android arm64" OFF)
option(PLATFORM_ARM32 "build android arm32" OFF)
add_compile_definitions(NOT_USE_STL)
if(MICRO_BUILD_ARM64 OR MICRO_BUILD_ARM32A)
if(PLATFORM_ARM64 OR PLATFORM_ARM32)
add_compile_definitions(ENABLE_NEON)
add_compile_definitions(ENABLE_ARM)
endif()
if(MICRO_BUILD_ARM64)
if(PLATFORM_ARM64)
add_compile_definitions(ENABLE_ARM64)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8.2-a+dotprod")
endif()
if(MICRO_BUILD_ARM32A)
if(PLATFORM_ARM32)
add_compile_definitions(ENABLE_ARM32)
add_definitions(-mfloat-abi=softfp -mfpu=neon)
endif()

View File

@ -22,20 +22,20 @@ include_directories(${HEADER_PATH})
include(net.cmake)
option(MICRO_BUILD_ARM64 "build android arm64" OFF)
option(MICRO_BUILD_ARM32A "build android arm32" OFF)
option(PLATFORM_ARM64 "build android arm64" OFF)
option(PLATFORM_ARM32 "build android arm32" OFF)
if(MICRO_BUILD_ARM64 OR MICRO_BUILD_ARM32A)
if(PLATFORM_ARM64 OR PLATFORM_ARM32)
add_compile_definitions(ENABLE_NEON)
add_compile_definitions(ENABLE_ARM)
endif()
if(MICRO_BUILD_ARM64)
if(PLATFORM_ARM64)
add_compile_definitions(ENABLE_ARM64)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8.2-a+dotprod")
endif()
if(MICRO_BUILD_ARM32A)
if(PLATFORM_ARM32)
add_compile_definitions(ENABLE_ARM32)
add_definitions(-mfloat-abi=softfp -mfpu=neon)
endif()

View File

@ -90,7 +90,7 @@ cmake -DCMAKE_BUILD_TYPE=Release \
-DANDROID_ABI="arm64-v8a" \
-DANDROID_TOOLCHAIN_NAME="aarch64-linux-android-clang" \
-DANDROID_NATIVE_API_LEVEL="19" \
-DMICRO_BUILD_ARM64=ON \
-DPLATFORM_ARM64=ON \
-DPKG_PATH={path to}/mindspore-lite-{version}-inference-android ..
make
```

View File

@ -130,7 +130,7 @@ if [[ "${LITE_PLATFORM}" == "arm64" ]]; then
-DANDROID_ABI="arm64-v8a" \
-DANDROID_TOOLCHAIN_NAME="aarch64-linux-android-clang" \
-DANDROID_NATIVE_API_LEVEL="19" \
-DMICRO_BUILD_ARM64=ON \
-DPLATFORM_ARM64=ON \
-DPKG_PATH=${PKG_PATH} ${BENCHMARK_PATH}
else
cmake -DCMAKE_BUILD_TYPE=Release \