forked from mindspore-Ecosystem/mindspore
add cortex-m7 build
This commit is contained in:
parent
3f729fa969
commit
c3fd5e63b4
|
@ -2,7 +2,6 @@ include(CMakePackageConfigHelpers)
|
|||
|
||||
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)
|
||||
set(OBFUSCATOR_ROOT_DIR ${RUNTIME_PKG_NAME}/tools/obfuscator)
|
||||
set(CROPPER_ROOT_DIR ${RUNTIME_PKG_NAME}/tools/cropper)
|
||||
|
@ -24,13 +23,14 @@ set(MSLITE_PROPOSAL_LIB_NAME libmslite_proposal)
|
|||
set(MICRO_NNIE_LIB_NAME libmicro_nnie)
|
||||
set(DPICO_ACL_ADAPTER_LIB_NAME libdpico_acl_adapter)
|
||||
set(BENCHMARK_ROOT_DIR ${RUNTIME_PKG_NAME}/tools/benchmark)
|
||||
set(MICRO_DIR ${TOP_DIR}/mindspore/lite/tools/converter/micro)
|
||||
|
||||
set(MINDSPORE_LITE_TRAIN_LIB_NAME libmindspore-lite-train)
|
||||
set(BENCHMARK_TRAIN_NAME benchmark_train)
|
||||
set(BENCHMARK_TRAIN_ROOT_DIR ${RUNTIME_PKG_NAME}/tools/benchmark_train)
|
||||
file(GLOB JPEGTURBO_LIB_LIST ${jpeg_turbo_LIBPATH}/*.so)
|
||||
|
||||
include(${TOP_DIR}/cmake/package_micro.cmake)
|
||||
|
||||
function(__install_white_list_ops)
|
||||
install(FILES
|
||||
${TOP_DIR}/mindspore/core/ops/abs.h
|
||||
|
@ -357,34 +357,6 @@ if(MSLITE_MINDDATA_IMPLEMENT STREQUAL "lite_cv")
|
|||
endif()
|
||||
endif()
|
||||
|
||||
function(__install_micro_wrapper)
|
||||
file(GLOB NNACL_FILES GLOB ${NNACL_DIR}/*.h)
|
||||
install(FILES ${NNACL_FILES} DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
install(DIRECTORY ${NNACL_DIR}/base DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl
|
||||
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
|
||||
install(DIRECTORY ${NNACL_DIR}/int8 DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl
|
||||
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
|
||||
install(DIRECTORY ${NNACL_DIR}/fp32 DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl
|
||||
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
|
||||
install(DIRECTORY ${NNACL_DIR}/intrinsics DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl
|
||||
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
|
||||
install(DIRECTORY ${MICRO_DIR}/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})
|
||||
endfunction()
|
||||
|
||||
function(__install_micro_codegen)
|
||||
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})
|
||||
endfunction()
|
||||
|
||||
if(WIN32)
|
||||
install(FILES ${TOP_DIR}/build/.commit_id DESTINATION ${RUNTIME_PKG_NAME}
|
||||
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
set(CODEGEN_ROOT_DIR ${RUNTIME_PKG_NAME}/tools/codegen)
|
||||
set(MICRO_DIR ${TOP_DIR}/mindspore/lite/tools/converter/micro)
|
||||
|
||||
function(__install_micro_wrapper)
|
||||
file(GLOB NNACL_FILES GLOB ${NNACL_DIR}/*.h)
|
||||
install(FILES ${NNACL_FILES} DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
install(DIRECTORY ${NNACL_DIR}/base DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl
|
||||
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
|
||||
install(DIRECTORY ${NNACL_DIR}/int8 DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl
|
||||
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
|
||||
install(DIRECTORY ${NNACL_DIR}/fp32 DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl
|
||||
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
|
||||
install(DIRECTORY ${NNACL_DIR}/intrinsics DESTINATION ${CODEGEN_ROOT_DIR}/include/nnacl
|
||||
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
|
||||
install(DIRECTORY ${MICRO_DIR}/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})
|
||||
install(TARGETS nnacl_static ARCHIVE DESTINATION ${CODEGEN_ROOT_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
endfunction()
|
||||
|
||||
function(__install_micro_codegen)
|
||||
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})
|
||||
endfunction()
|
|
@ -165,3 +165,6 @@ endif()
|
|||
if(PLATFORM_ARM)
|
||||
add_subdirectory(${NNACL_DIR}/optimize)
|
||||
endif()
|
||||
add_library(nnacl_static STATIC $<TARGET_OBJECTS:nnacl_mid>)
|
||||
set_target_properties(nnacl_static PROPERTIES OUTPUT_NAME "nnacl")
|
||||
set_target_properties(nnacl_static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
void Conv1x1Int8Opt(const int8_t *packed_input, const int8_t *packed_weight, int8_t *dst, const int32_t *input_sum,
|
||||
const int32_t *bias, int row, int col, int deep4, int32_t *left_shift, int32_t *right_shift,
|
||||
int32_t *multiplier, ConvParameter *conv_param, MATMUL_OPT_DP_FUNC matmul_func,
|
||||
const int *filter_zp) {
|
||||
const int32_t *filter_zp) {
|
||||
int is_per_oc = (int)conv_param->conv_quant_arg_.filter_arg_num_ != 1;
|
||||
matmul_func(packed_input, packed_weight, dst, row, col, deep4, conv_param->output_channel_, input_sum, bias,
|
||||
left_shift, right_shift, multiplier, conv_param->conv_quant_arg_.output_quant_args_[0].zp_,
|
||||
|
|
|
@ -293,8 +293,8 @@ void MatMulInt8_4x2_r(const int8_t *a, const int8_t *b, int8_t *dst, size_t row,
|
|||
}
|
||||
|
||||
#ifndef ENABLE_ARM
|
||||
void MatmulInt8Opt(const int8_t *a, const int8_t *b, int8_t *dst, int row, int col, int deep16, const int *a_sums,
|
||||
const int *bias, int mini, int maxi, int out_zp, const int32_t *multiplier,
|
||||
void MatmulInt8Opt(const int8_t *a, const int8_t *b, int8_t *dst, int row, int col, int deep16, const int32_t *a_sums,
|
||||
const int32_t *bias, int mini, int maxi, int out_zp, const int32_t *multiplier,
|
||||
const int32_t *left_shift, const int32_t *right_shift, size_t stride, size_t filter_peroc,
|
||||
const int32_t *filter_zp) {
|
||||
/*
|
||||
|
@ -783,7 +783,7 @@ void RowMajor2Col4x16MajorInt8(const int8_t *src, int8_t *dst, int row, int col)
|
|||
}
|
||||
}
|
||||
|
||||
void CalcInputSums(const int8_t *input, int row, int col, int weight_zp, int *dst, DataOrder order) {
|
||||
void CalcInputSums(const int8_t *input, int row, int col, int weight_zp, int32_t *dst, DataOrder order) {
|
||||
for (int r = 0; r < row; ++r) {
|
||||
int sum = 0;
|
||||
for (int c = 0; c < col; ++c) {
|
||||
|
@ -800,7 +800,7 @@ void CalcInputSums(const int8_t *input, int row, int col, int weight_zp, int *ds
|
|||
|
||||
// dst: bias + depth*input_zp*weight_zp - input_zp*weight_col_sums
|
||||
void CalcWeightBiasSums(const int8_t *weight, int row, int col, int input_zp, const int *weight_zp_ptr, const int *bias,
|
||||
int *dst, DataOrder order, bool filter_per_channel) {
|
||||
int32_t *dst, DataOrder order, bool filter_per_channel) {
|
||||
for (int c = 0; c < col; ++c) {
|
||||
int sum = 0;
|
||||
for (int r = 0; r < row; ++r) {
|
||||
|
|
|
@ -35,14 +35,14 @@ void RowMajor2Col4x16MajorInt8(const int8_t *src, int8_t *dst, int row, int col)
|
|||
void RowMajor2Col4x16MajorPartInt8(const int8_t *src, int8_t *dst, int row, int col, int cur_oc);
|
||||
void PackInput2Col4x4AndInputSumPert(const int8_t *src_input, int8_t *packed_input, int32_t *input_sum, int row,
|
||||
int col, int row_stride, int32_t filter_zp);
|
||||
void CalcInputSums(const int8_t *input, int row, int col, int weight_zp, int *dst, DataOrder order);
|
||||
void CalcInputSums(const int8_t *input, int row, int col, int weight_zp, int32_t *dst, DataOrder order);
|
||||
void CalcWeightBiasSums(const int8_t *weight, int row, int col, int input_zp, const int *weight_zp_ptr, const int *bias,
|
||||
int *dst, DataOrder order, bool filter_per_channel);
|
||||
int32_t *dst, DataOrder order, bool filter_per_channel);
|
||||
void CalcPartWeightBiasSums(const int8_t *weight, int row, int stride, int cur_col, int input_zp,
|
||||
const int *weight_zp_ptr, const int *bias, int *dst, DataOrder order,
|
||||
bool filter_per_channel);
|
||||
void MatmulInt8Opt(const int8_t *a, const int8_t *b, int8_t *dst, int row, int col, int deep16, const int *a_sums,
|
||||
const int *bias, int act_min, int act_max, int out_zp, const int32_t *multiplier,
|
||||
void MatmulInt8Opt(const int8_t *a, const int8_t *b, int8_t *dst, int row, int col, int deep16, const int32_t *a_sums,
|
||||
const int32_t *bias, int act_min, int act_max, int out_zp, const int32_t *multiplier,
|
||||
const int32_t *left_shift, const int32_t *right_shift, size_t stride, size_t filter_peroc,
|
||||
const int32_t *filter_zp);
|
||||
/* 8x4 4x8 -> 8x8 */
|
||||
|
|
|
@ -12,6 +12,8 @@ set(MSLITE_GPU_BACKEND "" CACHE STRING "enable gpu backend, \
|
|||
opencl only support arm64 and x86_64 , tensorrt only support x86_64, opencl/cuda/tensorrt/off")
|
||||
set(MSLITE_REGISTRY_DEVICE "off" CACHE STRING "Compile Mindspore Lite that supports specific devices, \
|
||||
currently supported devices: Hi3516D/Hi3519A/Hi3559A/SD3403")
|
||||
set(MSLITE_MICRO_PLATFORM "auto" CACHE STRING "Platform of micro static library micro static, \
|
||||
currently supported : cortex-m7/auto")
|
||||
if(NOT ENABLE_CLOUD_AND_LITE)
|
||||
set(MSLITE_MINDDATA_IMPLEMENT "lite_cv" CACHE STRING "off, lite_cv, cloud, or full")
|
||||
else()
|
||||
|
@ -81,6 +83,9 @@ endif()
|
|||
if(DEFINED ENV{MSLITE_REGISTRY_DEVICE})
|
||||
set(MSLITE_REGISTRY_DEVICE $ENV{MSLITE_REGISTRY_DEVICE})
|
||||
endif()
|
||||
if(DEFINED ENV{MSLITE_MICRO_PLATFORM})
|
||||
set(MSLITE_MICRO_PLATFORM $ENV{MSLITE_MICRO_PLATFORM})
|
||||
endif()
|
||||
if(DEFINED ENV{MSLITE_ENABLE_NPU})
|
||||
set(MSLITE_ENABLE_NPU $ENV{MSLITE_ENABLE_NPU})
|
||||
endif()
|
||||
|
@ -388,6 +393,7 @@ message(STATUS "\tMSLITE_GPU_BACKEND = \t${MSLITE_GPU_BA
|
|||
message(STATUS "\tMSLITE_REGISTRY_DEVICE = \t${MSLITE_REGISTRY_DEVICE}")
|
||||
message(STATUS "\tMSLITE_ENABLE_NPU = \t${MSLITE_ENABLE_NPU}")
|
||||
message(STATUS "\tMSLITE_ENABLE_TRAIN = \t${MSLITE_ENABLE_TRAIN}")
|
||||
message(STATUS "\tMSLITE_MICRO_PLATFORM = \t${MSLITE_MICRO_PLATFORM}")
|
||||
message(STATUS "\tMSLITE_ENABLE_SSE = \t${MSLITE_ENABLE_SSE}")
|
||||
message(STATUS "\tMSLITE_ENABLE_AVX = \t${MSLITE_ENABLE_AVX}")
|
||||
message(STATUS "\tMSLITE_ENABLE_AVX512 = \t${MSLITE_ENABLE_AVX512}")
|
||||
|
@ -525,6 +531,14 @@ string(REPLACE "/mindspore/lite" "" TOP_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|||
set(CORE_DIR ${TOP_DIR}/mindspore/core)
|
||||
set(CCSRC_DIR ${TOP_DIR}/mindspore/ccsrc)
|
||||
set(NNACL_DIR ${CCSRC_DIR}/plugin/device/cpu/kernel/nnacl)
|
||||
|
||||
if(TOOLCHAIN_NAME STREQUAL "cortex-m7")
|
||||
set(RUNTIME_COMPONENT_NAME "cortex-m7")
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/converter/micro/cmake/cortex-m/ build)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/tools/converter/micro/cmake/cortex-m/package.cmake)
|
||||
return()
|
||||
endif()
|
||||
|
||||
include_directories(${TOP_DIR})
|
||||
include_directories(${CORE_DIR})
|
||||
include_directories(${CORE_DIR}/ir)
|
||||
|
|
|
@ -401,6 +401,10 @@ build_lite() {
|
|||
echo "Use the '-I arm64' command when compiling MindSpore Lite on an aarch64 architecture system."
|
||||
exit 1
|
||||
fi
|
||||
if [[ "${MSLITE_MICRO_PLATFORM}" == cortex-m* ]]; then
|
||||
CMAKE_TOOLCHAIN_FILE=${BASEPATH}/mindspore/lite/cmake/cortex-m7.toolchain.cmake
|
||||
LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DTOOLCHAIN_NAME=cortex-m7"
|
||||
fi
|
||||
LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DMSLITE_MINDDATA_IMPLEMENT=lite_cv"
|
||||
LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DPLATFORM_X86_64=on"
|
||||
fi
|
||||
|
@ -442,7 +446,7 @@ build_lite() {
|
|||
fi
|
||||
fi
|
||||
make package
|
||||
if [[ "${local_lite_platform}" == "x86_64" ]]; then
|
||||
if [[ "${local_lite_platform}" == "x86_64" && "X$CMAKE_TOOLCHAIN_FILE" == "X" ]]; then
|
||||
build_python_wheel_package "x86_64"
|
||||
if [ "${JAVA_HOME}" ]; then
|
||||
echo -e "\e[31mJAVA_HOME=$JAVA_HOME \e[0m"
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR arm)
|
||||
|
||||
find_program(arm-none-eabi-gcc_EXE arm-none-eabi-gcc)
|
||||
if(NOT arm-none-eabi-gcc_EXE)
|
||||
message(FATAL_ERROR "Required C COMPILER arm-none-eabi-gcc not found, "
|
||||
"please install the package and try building MindSpore again.")
|
||||
else()
|
||||
message("Find C COMPILER PATH: ${arm-none-eabi-gcc_EXE}")
|
||||
endif()
|
||||
|
||||
find_program(arm-none-eabi-g++_EXE arm-none-eabi-g++)
|
||||
if(NOT arm-none-eabi-g++_EXE)
|
||||
message(FATAL_ERROR "Required CXX COMPILER arm-none-eabi-g++ not found, "
|
||||
"please install the package and try building MindSpore again.")
|
||||
else()
|
||||
message("Find CXX COMPILER PATH: ${arm-none-eabi-g++_EXE}")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
|
||||
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "-mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard ${CMAKE_CXX_FLAGS}")
|
||||
set(CMAKE_C_FLAGS "-mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard ${CMAKE_C_FLAGS}")
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
||||
set(CROSS_COMPILATION_ARM contex-m7)
|
||||
set(CROSS_COMPILATION_ARCHITECTURE armv7-m)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags")
|
||||
|
||||
SET(CMAKE_C_COMPILER_WORKS TRUE)
|
||||
SET(CMAKE_CXX_COMPILER_WORKS TRUE)
|
||||
SET(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
|
|
@ -0,0 +1,69 @@
|
|||
cmake_minimum_required(VERSION 3.12)
|
||||
project(Micro)
|
||||
|
||||
string(REPLACE "-Werror" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
|
||||
string(REPLACE "-Werror" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
|
||||
set(CMAKE_VERBOSE_MAKEFILE on)
|
||||
set(MICRO_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..)
|
||||
|
||||
include_directories(${NNACL_DIR}/..)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-attributes -fdata-sections -ffunction-sections")
|
||||
|
||||
file(GLOB KERNEL_SRC
|
||||
${NNACL_DIR}/*.c
|
||||
${NNACL_DIR}/fp32/*.c
|
||||
${NNACL_DIR}/infer/*.c
|
||||
${NNACL_DIR}/base/*.c
|
||||
${NNACL_DIR}/fp32_grad/*.c
|
||||
${NNACL_DIR}/kernel/*.c
|
||||
${NNACL_DIR}/experimental/*.c
|
||||
${NNACL_DIR}/int8/*.c
|
||||
${NNACL_DIR}/fp32_sparse/*.c
|
||||
${NNACL_DIR}/infer/string/*.c
|
||||
${NNACL_DIR}/infer/control/*.c
|
||||
)
|
||||
|
||||
list(REMOVE_ITEM KERNEL_SRC ${NNACL_DIR}/infer/shape_fusion_infer.c)
|
||||
|
||||
string(REPLACE "-fvisibility=hidden" "-fvisibility=default" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
|
||||
add_library(nnacl_static STATIC ${KERNEL_SRC})
|
||||
target_compile_options(nnacl_static PRIVATE -fPIC)
|
||||
|
||||
target_link_options(nnacl_static PRIVATE -Wl,-z,relro,-z,now,-z,noexecstack)
|
||||
|
||||
include(${TOP_DIR}/cmake/utils.cmake)
|
||||
include(${TOP_DIR}/cmake/external_libs/cmsis.cmake)
|
||||
|
||||
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(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
|
||||
)
|
||||
list(REMOVE_ITEM CMSIS_OPS ${CMSIS_DIR}/CMSIS/NN/Source/NNSupportFunctions/arm_nn_mat_mult_nt_t_s8.c)
|
||||
add_library(cmsis_nn STATIC ${CMSIS_OPS})
|
||||
|
||||
include_directories(${MICRO_DIR}/coder/)
|
||||
set(WRAPPER_DIR ${MICRO_DIR}/coder/wrapper/)
|
||||
file(GLOB WRAPPER_SRC
|
||||
${WRAPPER_DIR}/base/*.c
|
||||
${WRAPPER_DIR}/fp32/*.c
|
||||
${WRAPPER_DIR}/int8/*.c
|
||||
)
|
||||
|
||||
# generate static library
|
||||
add_library(wrapper STATIC ${WRAPPER_SRC})
|
|
@ -0,0 +1,26 @@
|
|||
include(CMakePackageConfigHelpers)
|
||||
|
||||
set(RUNTIME_PKG_NAME ${PKG_NAME_PREFIX}-${RUNTIME_COMPONENT_NAME})
|
||||
|
||||
include(${TOP_DIR}/cmake/package_micro.cmake)
|
||||
|
||||
__install_micro_wrapper()
|
||||
__install_micro_codegen()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
set(CPACK_GENERATOR ZIP)
|
||||
else()
|
||||
set(CPACK_GENERATOR TGZ)
|
||||
endif()
|
||||
|
||||
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
|
||||
set(CPACK_COMPONENTS_ALL ${RUNTIME_COMPONENT_NAME})
|
||||
set(CPACK_PACKAGE_FILE_NAME ${PKG_NAME_PREFIX})
|
||||
|
||||
if(WIN32)
|
||||
set(CPACK_PACKAGE_DIRECTORY ${TOP_DIR}/output)
|
||||
else()
|
||||
set(CPACK_PACKAGE_DIRECTORY ${TOP_DIR}/output/tmp)
|
||||
endif()
|
||||
set(CPACK_PACKAGE_CHECKSUM SHA256)
|
||||
include(CPack)
|
Loading…
Reference in New Issue