diff --git a/cmake/package_lite.cmake b/cmake/package_lite.cmake index 55ecc82c8e5cf9cb060ef823b609b20c481246f5..996ea06dfcaab44e7e295d43090ae604e97a61f8 100644 --- a/cmake/package_lite.cmake +++ b/cmake/package_lite.cmake @@ -7,7 +7,6 @@ set(OPENCV_DIR ${MAIN_DIR}/third_party/opencv) set(PROTOBF_DIR ${MAIN_DIR}/third_party/protobuf) set(FLATBF_DIR ${MAIN_DIR}/third_party/flatbuffers) -install(FILES ${TOP_DIR}/mindspore/lite/build/src/libmindspore-lite.so DESTINATION ${LIB_DIR} COMPONENT ${COMPONENT_NAME}) if (BUILD_MINDDATA) install(DIRECTORY ${TOP_DIR}/mindspore/ccsrc/minddata/dataset/include/ DESTINATION ${INC_DIR} COMPONENT ${COMPONENT_NAME} FILES_MATCHING PATTERN "*.h") install(FILES ${TOP_DIR}/mindspore/lite/build/minddata/libminddata-lite.so DESTINATION ${LIB_DIR} COMPONENT ${COMPONENT_NAME}) @@ -30,24 +29,30 @@ if (BUILD_MINDDATA) endif () if (PLATFORM_ARM64) + install(FILES ${TOP_DIR}/mindspore/lite/build/src/libmindspore-lite.so DESTINATION ${LIB_DIR} COMPONENT ${COMPONENT_NAME}) install(FILES ${TOP_DIR}/mindspore/core/ir/dtype/type_id.h DESTINATION ${INC_DIR}/ir/dtype COMPONENT ${COMPONENT_NAME}) install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/ DESTINATION ${INC_DIR} COMPONENT ${COMPONENT_NAME} FILES_MATCHING PATTERN "*.h") install(DIRECTORY ${TOP_DIR}/mindspore/lite/schema/ DESTINATION ${INC_DIR}/schema COMPONENT ${COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "inner" EXCLUDE) install(FILES ${TOP_DIR}/mindspore/lite/build/nnacl/liboptimize.so DESTINATION ${LIB_DIR} COMPONENT ${COMPONENT_NAME}) install(DIRECTORY ${TOP_DIR}/third_party/flatbuffers/include DESTINATION ${FLATBF_DIR} COMPONENT ${COMPONENT_NAME}) elseif (PLATFORM_ARM32) + install(FILES ${TOP_DIR}/mindspore/lite/build/src/libmindspore-lite.so DESTINATION ${LIB_DIR} COMPONENT ${COMPONENT_NAME}) install(FILES ${TOP_DIR}/mindspore/core/ir/dtype/type_id.h DESTINATION ${INC_DIR}/ir/dtype COMPONENT ${COMPONENT_NAME}) install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/ DESTINATION ${INC_DIR} COMPONENT ${COMPONENT_NAME} FILES_MATCHING PATTERN "*.h") install(DIRECTORY ${TOP_DIR}/mindspore/lite/schema/ DESTINATION ${INC_DIR}/schema COMPONENT ${COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "inner" EXCLUDE) install(DIRECTORY ${TOP_DIR}/third_party/flatbuffers/include DESTINATION ${FLATBF_DIR} COMPONENT ${COMPONENT_NAME}) else () + install(FILES ${TOP_DIR}/mindspore/lite/build/src/libmindspore-lite.so DESTINATION ${LIB_DIR} COMPONENT ${RUN_X86_COMPONENT_NAME}) install(FILES ${TOP_DIR}/third_party/protobuf/build/lib/libprotobuf.so.19.0.0 DESTINATION ${PROTOBF_DIR}/lib RENAME libprotobuf.so.19 COMPONENT ${COMPONENT_NAME}) - endif () set(CPACK_GENERATOR TGZ) set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) -set(CPACK_COMPONENTS_ALL ${COMPONENT_NAME}) +if (PLATFORM_ARM64 OR PLATFORM_ARM32) + set(CPACK_COMPONENTS_ALL ${COMPONENT_NAME}) +else () + set(CPACK_COMPONENTS_ALL ${COMPONENT_NAME} ${RUN_X86_COMPONENT_NAME}) +endif () set(CPACK_PACKAGE_FILE_NAME ${MAIN_DIR}) set(CPACK_PACKAGE_DIRECTORY ${TOP_DIR}/output/tmp) set(CPACK_PACKAGE_CHECKSUM SHA256) diff --git a/mindspore/lite/CMakeLists.txt b/mindspore/lite/CMakeLists.txt index 537f4245c01e57355d04e9294b275fe9af50a089..eff4c2613a9546a2b63bd20fa5a9433bb8715e9c 100644 --- a/mindspore/lite/CMakeLists.txt +++ b/mindspore/lite/CMakeLists.txt @@ -28,6 +28,7 @@ elseif (PLATFORM_ARM32) else () set(COMPONENT_NAME convert-ubuntu) endif() +set(RUN_X86_COMPONENT_NAME runtime-x86-${PROCESS_UNIT}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") set(TOP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..) @@ -77,6 +78,8 @@ if (NOT PLATFORM_ARM64 AND NOT PLATFORM_ARM32) set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-z,relro,-z,now -Wl,-z,noexecstack ${CMAKE_SHARED_LINKER_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,relro,-z,now -Wl,-z,noexecstack ${CMAKE_EXE_LINKER_FLAGS}") string(REPLACE " -g " " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") endif () endif () diff --git a/mindspore/lite/nnacl/CMakeLists.txt b/mindspore/lite/nnacl/CMakeLists.txt index 675393d9a7126c24f2ffd0c49913b995210d8798..6b3eb33a246345b0e3c7ce45c1c8ee2160ec8067 100644 --- a/mindspore/lite/nnacl/CMakeLists.txt +++ b/mindspore/lite/nnacl/CMakeLists.txt @@ -2,6 +2,42 @@ project(nnacl) set(NNACL_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(TOP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..) +set(SRC_DIR ${TOP_DIR}/src) +set(LITE_SRC + ${SRC_DIR}/common/graph_util.cc + ${SRC_DIR}/common/ms_tensor_utils.cc + ${SRC_DIR}/runtime/allocator.cc + ${SRC_DIR}/runtime/runtime_api.cc + ${SRC_DIR}/runtime/thread_pool.cc + ${SRC_DIR}/runtime/workspace_pool.cc + ${SRC_DIR}/ir/tensor.cc + ${SRC_DIR}/context.cc + ${SRC_DIR}/executor.cc + ${SRC_DIR}/kernel_registry.cc + ${SRC_DIR}/lite_kernel.cc + ${SRC_DIR}/populate_parameter.cc + ${SRC_DIR}/scheduler.cc + ${SRC_DIR}/lite_session.cc + ${SRC_DIR}/model.cc + ) + +if (SUPPORT_GPU) + set(LITE_SRC + ${LITE_SRC} + ${SRC_DIR}/runtime/kernel/opencl/subgraph_opencl_kernel.cc + ${SRC_DIR}/runtime/kernel/opencl/utils.cc + ${SRC_DIR}/runtime/opencl/opencl_executor.cc + ${SRC_DIR}/runtime/opencl/opencl_allocator.cc + ${SRC_DIR}/runtime/opencl/opencl_runtime.cc + ${SRC_DIR}/runtime/opencl/opencl_wrapper.cc + ) +endif () + +set(ANF_SRC + ${ANF_SRC} + ${SRC_DIR}/ir/meta_tensor_extends.cc + ) +file(GLOB_RECURSE C_OPS_SRC ${SRC_DIR}/ops/*.cc) include_directories(NNACL_DIR) ########################### optimized files ########################### @@ -25,11 +61,11 @@ if (PLATFORM_ARM64) string(REPLACE "-fvisibility=hidden" "-fvisibility=default" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8.2-a+dotprod+fp16") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv8.2-a+dotprod+fp16") - add_library(optimize SHARED ${OPTIMIZED_OPS}) - target_link_libraries( - optimize - mindspore-lite - ) + add_library(optimize SHARED ${OPTIMIZED_OPS} ${LITE_SRC} ${ANF_SRC} ${C_OPS_SRC}) + add_library(cpu_kernel STATIC $) + target_link_libraries(optimize cpu_kernel) + find_library(log-lib log) + target_link_libraries(optimize ${log-lib}) set_target_properties(optimize PROPERTIES CLEAN_DIRECT_OUTPUT 1) add_custom_command(TARGET optimize POST_BUILD diff --git a/mindspore/lite/nnacl/fp16/reduce_fp16.c b/mindspore/lite/nnacl/fp16/reduce_fp16.c index 6a3bdf5f7cfa3afefd887ed28d3d0c9873c33541..cf7665ac0e1788b46f16a2d0ed9a229685daf170 100644 --- a/mindspore/lite/nnacl/fp16/reduce_fp16.c +++ b/mindspore/lite/nnacl/fp16/reduce_fp16.c @@ -18,7 +18,7 @@ #include "nnacl/fp16/reduce_fp16.h" #include "nnacl/errorcode.h" -int ReduceMean(const int outer_size, const int inner_size, const int axis_size, const float16_t *src_data, +int ReduceMeanFp16(const int outer_size, const int inner_size, const int axis_size, const float16_t *src_data, const int *src_shape, float16_t *dst_data, const int tid, const int thread_num) { if (src_data == NULL || src_shape == NULL || dst_data == NULL) { return NNACL_NULL_PTR; diff --git a/mindspore/lite/nnacl/fp16/reduce_fp16.h b/mindspore/lite/nnacl/fp16/reduce_fp16.h index e7066b0256345a72b7ab6a325a6c2b55fce63da7..4827c691dd2b55d743f709cb5cc9a65fd57150f2 100644 --- a/mindspore/lite/nnacl/fp16/reduce_fp16.h +++ b/mindspore/lite/nnacl/fp16/reduce_fp16.h @@ -25,7 +25,7 @@ #ifdef __cplusplus extern "C" { #endif -int ReduceMean(const int outer_size, const int inner_size, const int axis_size, const float16_t *src_data, +int ReduceMeanFp16(const int outer_size, const int inner_size, const int axis_size, const float16_t *src_data, const int *src_shape, float16_t *dst_data, const int tid, const int thread_num); #ifdef __cplusplus diff --git a/mindspore/lite/nnacl/int8/reduce_int8.c b/mindspore/lite/nnacl/int8/reduce_int8.c index 1858c194f2960f87f5ec1a8d5cca27c402bac874..1893a7ef0e80b934b8628f7ebf2e371225984432 100644 --- a/mindspore/lite/nnacl/int8/reduce_int8.c +++ b/mindspore/lite/nnacl/int8/reduce_int8.c @@ -268,7 +268,7 @@ int ReduceMinLastAxis(const int outer_size, const int inner_size, const int axis RoundingDivideByPOT(SaturatingRoundingDoublingHighMul( (tmp - quant->in_zp_) * (1 << ((unsigned int)quant->in_out_left_shift_ + base_offset)), quant->in_out_multiplier_), - quant->in_out_right_shift_ + base_offset); + quant->in_out_right_shift_ + base_offset); if (isAddOverflow(tmp_scaled, quant->out_zp_)) { return NNACL_ERRCODE_ADD_OVERFLOW; } diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/arithmetic_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/arithmetic_fp16.cc index 63e40c995a44722f3f62a0d3587f7f130dc1b063..3bb35549995e41ab333b42d63eb8b60242cc2d59 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/arithmetic_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/arithmetic_fp16.cc @@ -333,7 +333,7 @@ int ArithmeticFP16CPUKernel::DoArithmetic(int task_id) { return RET_OK; } -int ArithmeticsRun(int task_id, LiteParallelGroupEnv *penv, void *cdata) { +static int ArithmeticsRun(int task_id, LiteParallelGroupEnv *penv, void *cdata) { auto arithmetic_kernel = reinterpret_cast(cdata); auto error_code = arithmetic_kernel->DoArithmetic(task_id); if (error_code != RET_OK) { diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_1x1_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_1x1_fp16.cc index ed602d65c77c3496416c84fbe6e6ec165bc1fe1c..7f56320630a61342f0d6c48091c2893a703a76da 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_1x1_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_1x1_fp16.cc @@ -170,7 +170,7 @@ int Convolution1x1FP16CPUKernel::RunImpl(int task_id) { return RET_OK; } -int Convolution1x1Fp16Impl(int task_id, LiteParallelGroupEnv *penv, void *cdata) { +static int Convolution1x1Fp16Impl(int task_id, LiteParallelGroupEnv *penv, void *cdata) { auto conv = reinterpret_cast(cdata); auto error_code = conv->RunImpl(task_id); if (error_code != RET_OK) { diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_3x3_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_3x3_fp16.cc index 153274d7ed65a3e19967752445c984102a1f1366..883d7bca0b75058f2abb83ec61435b5b56ca3571 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_3x3_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_3x3_fp16.cc @@ -197,7 +197,7 @@ int Convolution3x3FP16CPUKernel::RunImpl(int task_id) { return RET_OK; } -int Convolution3x3Fp16Impl(int task_id, LiteParallelGroupEnv *penv, void *cdata) { +static int Convolution3x3Fp16Impl(int task_id, LiteParallelGroupEnv *penv, void *cdata) { auto conv = reinterpret_cast(cdata); auto error_code = conv->RunImpl(task_id); if (error_code != RET_OK) { diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_depthwise_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_depthwise_fp16.cc index 6da98cb524a489e2aee586987e50a72c908bc7b5..cf88b2be25f7b749efa52985593fc0ae78c4321e 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_depthwise_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_depthwise_fp16.cc @@ -150,7 +150,7 @@ int ConvolutionDepthwiseFp16CPUKernel::Execute(int task_id) { return RET_OK; } -int ConvDwFp16Run(int task_id, LiteParallelGroupEnv *penv, void *cdata) { +static int ConvDwFp16Run(int task_id, LiteParallelGroupEnv *penv, void *cdata) { auto conv_dw_fp16 = reinterpret_cast(cdata); auto ret = conv_dw_fp16->Execute(task_id); if (ret != RET_OK) { diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_fp16.cc index b42e3d6009b896b222565a4290d132893941fd8a..e4c1429b203d51aab1d21c0dc9299cf700325584 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_fp16.cc @@ -177,7 +177,7 @@ int ConvolutionFP16CPUKernel::RunImpl(int task_id) { return RET_OK; } -int ConvolutionFp16Impl(int task_id, LiteParallelGroupEnv *penv, void *cdata) { +static int ConvolutionFp16Impl(int task_id, LiteParallelGroupEnv *penv, void *cdata) { auto conv = reinterpret_cast(cdata); auto error_code = conv->RunImpl(task_id); if (error_code != RET_OK) { diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_sw_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_sw_fp16.cc index dc2c1bd07e622a6c4b99f22c8af62381ed190f60..7b7d1e17b3207afcfeb5f0c9d6d0a4a7b159b31c 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_sw_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_sw_fp16.cc @@ -186,7 +186,7 @@ int ConvolutionSWFP16CPUKernel::RunImpl(int task_id) { return RET_OK; } -int ConvolutionSWFp16Impl(int task_id, LiteParallelGroupEnv *penv, void *cdata) { +static int ConvolutionSWFp16Impl(int task_id, LiteParallelGroupEnv *penv, void *cdata) { auto conv = reinterpret_cast(cdata); auto error_code = conv->RunImpl(task_id); if (error_code != RET_OK) { diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_winograd_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_winograd_fp16.cc index a361abca303be7f22a741d52f3e2fd4db7c53e07..0f55fe633bc63e74d5a35267576bc0f61f648776 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_winograd_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/convolution_winograd_fp16.cc @@ -348,7 +348,7 @@ int ConvolutionWinogradFP16CPUKernel::RunImpl(int task_id) { return RET_OK; } -int ConvolutionWinogradFp16Impl(int task_id, LiteParallelGroupEnv *penv, void *cdata) { +static int ConvolutionWinogradFp16Impl(int task_id, LiteParallelGroupEnv *penv, void *cdata) { auto conv = reinterpret_cast(cdata); auto error_code = conv->RunImpl(task_id); if (error_code != RET_OK) { diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_depthwise_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_depthwise_fp16.cc index 82c0a4a8eef0be12f5d3985b4f421516d8459f8e..3a8ca200f2bcdc6b738dc989ab315388359ac01f 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_depthwise_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_depthwise_fp16.cc @@ -157,7 +157,7 @@ int DeconvolutionDepthwiseFp16CPUKernel::Execute(int task_id) { return RET_OK; } -int DeconvDwFp16Run(int task_id, LiteParallelGroupEnv *penv, void *cdata) { +static int DeconvDwFp16Run(int task_id, LiteParallelGroupEnv *penv, void *cdata) { auto deconv_dw_fp16 = reinterpret_cast(cdata); auto ret = deconv_dw_fp16->Execute(task_id); if (ret != RET_OK) { diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_fp16.cc index 09fe8de61b232c9eb47c940be6097c8d33195e54..0deb852cf9bd59afe2b602dd7ce2682854d4ac49 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/deconvolution_fp16.cc @@ -137,7 +137,7 @@ void DeConvolutionFp16CPUKernel::FreeRunBuf() { return; } -int DeConvFp16Run(int task_id, LiteParallelGroupEnv *penv, void *cdata) { +static int DeConvFp16Run(int task_id, LiteParallelGroupEnv *penv, void *cdata) { auto deconv = reinterpret_cast(cdata); auto error_code = deconv->DoDeconv(task_id); if (error_code != RET_OK) { diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/pooling_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/pooling_fp16.cc index b280b7fb68d2406249e8f6d9ca0f54ef0e012a78..dddad9ae9b5168487f71569a1eca73d280571c65 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/pooling_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/pooling_fp16.cc @@ -89,7 +89,7 @@ int PoolingFp16CPUKernel::RunImpl(int task_id) { return RET_OK; } -int PoolingFp16Impl(int task_id, LiteParallelGroupEnv *penv, void *cdata) { +static int PoolingFp16Impl(int task_id, LiteParallelGroupEnv *penv, void *cdata) { auto pooling = reinterpret_cast(cdata); auto error_code = pooling->RunImpl(task_id); if (error_code != RET_OK) { diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/reduce_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/reduce_fp16.cc index c17baab5a227164a1e76dbbc1a52c8aa50668722..3bc9d21ada3e11bfce7e9404ad112cac6f727a7f 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/reduce_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/reduce_fp16.cc @@ -49,7 +49,7 @@ int ReduceFp16CPUKernel::Init() { MS_LOG(ERROR) << "Reduce fp16 only support ReduceMode_ReduceMean"; return RET_ERROR; } - reducer_ = ReduceMean; + reducer_ = ReduceMeanFp16; if (!InferShapeDone()) { return RET_OK; @@ -67,7 +67,7 @@ int ReduceFp16CPUKernel::CallReduceUnit(int task_id) { return ret; } -int ReduceImpl(int task_id, LiteParallelGroupEnv *penv, void *cdata) { +static int ReduceImpl(int task_id, LiteParallelGroupEnv *penv, void *cdata) { auto reduce = reinterpret_cast(cdata); auto error_code = reduce->CallReduceUnit(task_id); if (error_code != RET_OK) { diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/split_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/split_fp16.cc index e7ec771e7d67ad8f682dd6e6dbe94f7ac87bca3b..5174e10bafb26c2ea6f1c7e6259a6cac0df4b5ba 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/split_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/split_fp16.cc @@ -63,7 +63,7 @@ int SplitFp16CPUKernel::Split(int task_id) { return RET_OK; } -int SplitRun(int task_id, LiteParallelGroupEnv *penv, void *cdata) { +static int SplitRun(int task_id, LiteParallelGroupEnv *penv, void *cdata) { auto g_kernel = reinterpret_cast(cdata); auto ret = g_kernel->Split(task_id); if (ret != RET_OK) { diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/transpose_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/transpose_fp16.cc index c9c0e3fb8bd661a44bb5ba2b1d2f703776729280..0333c3687010ed58c7e4e597c16e79b3c1df023d 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/transpose_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/transpose_fp16.cc @@ -121,7 +121,7 @@ int TransposeFp16CPUKernel::TransposeParallel(int task_id) { return RET_OK; } -int TransposeRun(int task_id, LiteParallelGroupEnv *penv, void *cdata) { +static int TransposeRun(int task_id, LiteParallelGroupEnv *penv, void *cdata) { auto g_kernel = reinterpret_cast(cdata); auto ret = g_kernel->TransposeParallel(task_id); if (ret != RET_OK) { diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/unstack.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/unstack.cc index dd81083dcf526fa53300b350b407ead21aecbdf9..e12754a640842a7f166e1574733a5f8e89e16878 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/unstack.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/unstack.cc @@ -42,7 +42,7 @@ int UnstackCPUKernel::ReSize() { if (para->axis_ < 0) { para->axis_ += shape_size; } - for (size_t i = 0; i < static_cast(shape_size); i++) { + for (size_t i = 0; i < shape_size; i++) { if (static_cast(i) < para->axis_) { para->pre_dims_ *= input->DimensionSize(i); } else if (static_cast(i) > para->axis_) { diff --git a/mindspore/lite/test/CMakeLists.txt b/mindspore/lite/test/CMakeLists.txt index 3aea9e8ace66e71adf4da913553bc9e1aed94cd0..7b1e91a602a2729c2896bb975ab9e2c8b7b4da41 100644 --- a/mindspore/lite/test/CMakeLists.txt +++ b/mindspore/lite/test/CMakeLists.txt @@ -8,8 +8,8 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/dependency_gtest.cmake) string(REPLACE " -Werror " " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") string(REPLACE " -Werror " " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") -STRING(REPLACE " fvisibility=hidden " " -fvisibility=default " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") -STRING(REPLACE " fvisibility=hidden " " -fvisibility=default " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") +STRING(REPLACE " -fvisibility=hidden " " -fvisibility=default " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") +STRING(REPLACE " -fvisibility=hidden " " -fvisibility=default " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") ### anf src set(ANF_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../core/ir/meta_tensor.cc diff --git a/mindspore/lite/test/run_benchmark_nets.sh b/mindspore/lite/test/run_benchmark_nets.sh index 533b85707a010c006d54f586ebdd597230b617ac..389229ab30514445f7e02d90fa11c4c21ae5b28f 100644 --- a/mindspore/lite/test/run_benchmark_nets.sh +++ b/mindspore/lite/test/run_benchmark_nets.sh @@ -9,8 +9,8 @@ function Run_x86() { continue fi echo ${model_name} - echo 'cd '${convertor_path}'/mindspore-lite-'${version}'-convert-ubuntu' - cd ${convertor_path}/mindspore-lite-${version}-convert-ubuntu || return 1 + echo 'cd '${convertor_path}'/mindspore-lite-'${version}'-runtime-x86-'${process_unit_x86} + cd ${convertor_path}/mindspore-lite-${version}-runtime-x86-${process_unit_x86} || return 1 echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./lib;./benchmark/benchmark --modelPath='${ms_models_path}'/'${model_name}'.ms --inDataPath=/home/workspace/mindspore_dataset/mslite/models/hiai/input_output/input/'${model_name}'.ms.bin --calibDataPath=/home/workspace/mindspore_dataset/mslite/models/hiai/input_output/output/'${model_name}'.ms.out --warmUpLoopCount=1 --loopCount=1' || return 1 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./lib;./benchmark/benchmark --modelPath=${ms_models_path}/${model_name}.ms --inDataPath=/home/workspace/mindspore_dataset/mslite/models/hiai/input_output/input/${model_name}.ms.bin --calibDataPath=/home/workspace/mindspore_dataset/mslite/models/hiai/input_output/output/${model_name}.ms.out --warmUpLoopCount=1 --loopCount=1 if [ $? = 0 ]; then @@ -30,8 +30,8 @@ function Run_x86() { continue fi echo ${model_name} - echo 'cd '${convertor_path}'/mindspore-lite-'${version}'-convert-ubuntu' - cd ${convertor_path}/mindspore-lite-${version}-convert-ubuntu || return 1 + echo 'cd '${convertor_path}'/mindspore-lite-'${version}'-runtime-x86-'${process_unit_x86} + cd ${convertor_path}/mindspore-lite-${version}-runtime-x86-${process_unit_x86} || return 1 echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./lib;./benchmark/benchmark --modelPath='${ms_models_path}'/'${model_name}'.ms --inDataPath=/home/workspace/mindspore_dataset/mslite/models/hiai/input_output/input/'${model_name}'.ms.bin --calibDataPath=/home/workspace/mindspore_dataset/mslite/models/hiai/input_output/output/'${model_name}'.ms.out --warmUpLoopCount=1 --loopCount=1' || return 1 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./lib;./benchmark/benchmark --modelPath=${ms_models_path}/${model_name}.ms --inDataPath=/home/workspace/mindspore_dataset/mslite/models/hiai/input_output/input/${model_name}.ms.bin --calibDataPath=/home/workspace/mindspore_dataset/mslite/models/hiai/input_output/output/${model_name}.ms.out --warmUpLoopCount=1 --loopCount=1 if [ $? = 0 ]; then @@ -51,8 +51,8 @@ function Run_x86() { continue fi echo ${model_name} - echo 'cd '${convertor_path}'/mindspore-lite-'${version}'-convert-ubuntu' - cd ${convertor_path}/mindspore-lite-${version}-convert-ubuntu || return 1 + echo 'cd '${convertor_path}'/mindspore-lite-'${version}'-runtime-x86-'${process_unit_x86} + cd ${convertor_path}/mindspore-lite-${version}-runtime-x86-${process_unit_x86} || return 1 echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./lib;./benchmark/benchmark --modelPath='${ms_models_path}'/'${model_name}'.ms --inDataPath=/home/workspace/mindspore_dataset/mslite/models/hiai/input_output/input/'${model_name}'.ms.bin --calibDataPath=/home/workspace/mindspore_dataset/mslite/models/hiai/input_output/output/'${model_name}'.ms.out --warmUpLoopCount=1 --loopCount=1' || return 1 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./lib;./benchmark/benchmark --modelPath=${ms_models_path}/${model_name}.ms --inDataPath=/home/workspace/mindspore_dataset/mslite/models/hiai/input_output/input/${model_name}.ms.bin --calibDataPath=/home/workspace/mindspore_dataset/mslite/models/hiai/input_output/output/${model_name}.ms.out --warmUpLoopCount=1 --loopCount=1 if [ $? = 0 ]; then @@ -72,8 +72,8 @@ function Run_x86() { continue fi echo ${model_name} - echo 'cd '${convertor_path}'/mindspore-lite-'${version}'-convert-ubuntu' - cd ${convertor_path}/mindspore-lite-${version}-convert-ubuntu || return 1 + echo 'cd '${convertor_path}'/mindspore-lite-'${version}'-runtime-x86-'${process_unit_x86} + cd ${convertor_path}/mindspore-lite-${version}-runtime-x86-${process_unit_x86} || return 1 echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./lib;./benchmark/benchmark --modelPath='${ms_models_path}'/'${model_name}'_posttraining.ms --inDataPath=/home/workspace/mindspore_dataset/mslite/quantTraining/mnist_calibration_data/00099.bin --calibDataPath=/home/workspace/mindspore_dataset/mslite/models/hiai/input_output/output/'${model_name}'_posttraining.ms.out --warmUpLoopCount=1 --loopCount=1' || return 1 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./lib;./benchmark/benchmark --modelPath=${ms_models_path}/${model_name}_posttraining.ms --inDataPath=/home/workspace/mindspore_dataset/mslite/quantTraining/mnist_calibration_data/00099.bin --calibDataPath=/home/workspace/mindspore_dataset/mslite/models/hiai/input_output/output/${model_name}_posttraining.ms.out --warmUpLoopCount=1 --loopCount=1 if [ $? = 0 ]; then @@ -93,8 +93,8 @@ function Run_x86() { continue fi echo ${model_name} - echo 'cd '${convertor_path}'/mindspore-lite-'${version}'-convert-ubuntu' - cd ${convertor_path}/mindspore-lite-${version}-convert-ubuntu || return 1 + echo 'cd '${convertor_path}'/mindspore-lite-'${version}'-runtime-x86-'${process_unit_x86} + cd ${convertor_path}/mindspore-lite-${version}-runtime-x86-${process_unit_x86} || return 1 echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./lib;./benchmark/benchmark --modelPath='${ms_models_path}'/'${model_name}'.ms --inDataPath=/home/workspace/mindspore_dataset/mslite/models/hiai/input_output/input/${model_name}.ms.bin --calibDataPath=/home/workspace/mindspore_dataset/mslite/models/hiai/input_output/output/'${model_name}'.ms.out --warmUpLoopCount=1 --loopCount=1 --numThreads=1' || return 1 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./lib;./benchmark/benchmark --modelPath=${ms_models_path}/${model_name}.ms --inDataPath=/home/workspace/mindspore_dataset/mslite/models/hiai/input_output/input/${model_name}.ms.bin --calibDataPath=/home/workspace/mindspore_dataset/mslite/models/hiai/input_output/output/${model_name}.ms.out --warmUpLoopCount=1 --loopCount=1 --numThreads=1 if [ $? = 0 ]; then @@ -114,8 +114,8 @@ function Run_x86() { continue fi echo ${model_name} - echo 'cd '${convertor_path}'/mindspore-lite-'${version}'-convert-ubuntu' - cd ${convertor_path}/mindspore-lite-${version}-convert-ubuntu || return 1 + echo 'cd '${convertor_path}'/mindspore-lite-'${version}'-runtime-x86-'${process_unit_x86} + cd ${convertor_path}/mindspore-lite-${version}-runtime-x86-${process_unit_x86} || return 1 echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./lib;./benchmark/benchmark --modelPath='${ms_models_path}'/'${model_name}'.ms --inDataPath=/home/workspace/mindspore_dataset/mslite/models/hiai/input_output/input/'${model_name}'.ms.bin --calibDataPath=/home/workspace/mindspore_dataset/mslite/models/hiai/input_output/output/'${model_name}'.ms.out --warmUpLoopCount=1 --loopCount=1' || return 1 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./lib;./benchmark/benchmark --modelPath=${ms_models_path}/${model_name}.ms --inDataPath=/home/workspace/mindspore_dataset/mslite/models/hiai/input_output/input/${model_name}.ms.bin --calibDataPath=/home/workspace/mindspore_dataset/mslite/models/hiai/input_output/output/${model_name}.ms.out --warmUpLoopCount=1 --loopCount=1 --accuracyThreshold=1.5 if [ $? = 0 ]; then @@ -323,15 +323,23 @@ file_name=$(ls ${arm_path}/*runtime-arm64*.tar.gz) IFS="-" read -r -a file_name_array <<< "$file_name" version=${file_name_array[2]} IFS="." read -r -a suffix <<< "${file_name_array[-1]}" -process_unit=${suffix[0]} +process_unit_arm=${suffix[0]} + +file_name=$(ls ${convertor_path}/*runtime-x86*.tar.gz) +IFS="-" read -r -a file_name_array <<< "$file_name" +IFS="." read -r -a suffix <<< "${file_name_array[-1]}" +process_unit_x86=${suffix[0]} # Unzip arm cd ${arm_path} || exit 1 -mkdir mindspore-lite-${version}-runtime-arm64-${process_unit} -tar -zxf mindspore-lite-${version}-runtime-arm64-${process_unit}.tar.gz -C mindspore-lite-${version}-runtime-arm64-${process_unit} --strip-components 1 || exit 1 +mkdir mindspore-lite-${version}-runtime-arm64-${process_unit_arm} +tar -zxf mindspore-lite-${version}-runtime-arm64-${process_unit_arm}.tar.gz -C mindspore-lite-${version}-runtime-arm64-${process_unit_arm} --strip-components 1 || exit 1 -# Unzip convertor +# Unzip x86 runtime and convertor cd ${convertor_path} || exit 1 +mkdir mindspore-lite-${version}-runtime-x86-${process_unit_x86} +tar -zxf mindspore-lite-${version}-runtime-x86-${process_unit_x86}.tar.gz -C mindspore-lite-${version}-runtime-x86-${process_unit_x86} --strip-components 1 || exit 1 + mkdir mindspore-lite-${version}-convert-ubuntu tar -zxf mindspore-lite-${version}-convert-ubuntu.tar.gz -C mindspore-lite-${version}-convert-ubuntu --strip-components 1 || exit 1 cd ${convertor_path}/mindspore-lite-${version}-convert-ubuntu || exit 1 @@ -439,9 +447,9 @@ rm -rf ${basepath}/benchmark_test mkdir -p ${basepath}/benchmark_test benchmark_test_path=${basepath}/benchmark_test cd ${benchmark_test_path} || exit 1 -cp -a ${arm_path}/mindspore-lite-${version}-runtime-arm64-${process_unit}/lib/libmindspore-lite.so ${benchmark_test_path}/libmindspore-lite.so || exit 1 -cp -a ${arm_path}/mindspore-lite-${version}-runtime-arm64-${process_unit}/lib/liboptimize.so ${benchmark_test_path}/liboptimize.so || exit 1 -cp -a ${arm_path}/mindspore-lite-${version}-runtime-arm64-${process_unit}/benchmark/benchmark ${benchmark_test_path}/benchmark || exit 1 +cp -a ${arm_path}/mindspore-lite-${version}-runtime-arm64-${process_unit_arm}/lib/libmindspore-lite.so ${benchmark_test_path}/libmindspore-lite.so || exit 1 +cp -a ${arm_path}/mindspore-lite-${version}-runtime-arm64-${process_unit_arm}/lib/liboptimize.so ${benchmark_test_path}/liboptimize.so || exit 1 +cp -a ${arm_path}/mindspore-lite-${version}-runtime-arm64-${process_unit_arm}/benchmark/benchmark ${benchmark_test_path}/benchmark || exit 1 # Copy the MindSpore models: cp -a ${ms_models_path}/*.ms ${benchmark_test_path} || exit 1 diff --git a/mindspore/lite/tools/benchmark/CMakeLists.txt b/mindspore/lite/tools/benchmark/CMakeLists.txt index 5996ce595520a161f055542f618b8d5b39e1b2d6..8151e126edc646a68ba253fd31b8c59d5f559236 100644 --- a/mindspore/lite/tools/benchmark/CMakeLists.txt +++ b/mindspore/lite/tools/benchmark/CMakeLists.txt @@ -15,6 +15,10 @@ if (PLATFORM_ARM32 OR PLATFORM_ARM64) else() target_link_libraries(benchmark mindspore-lite pthread) endif() - -install(TARGETS benchmark - RUNTIME DESTINATION ${MAIN_DIR}/benchmark COMPONENT ${COMPONENT_NAME}) \ No newline at end of file +if (PLATFORM_ARM32 OR PLATFORM_ARM64) + install(TARGETS benchmark + RUNTIME DESTINATION ${MAIN_DIR}/benchmark COMPONENT ${COMPONENT_NAME}) +else() + install(TARGETS benchmark + RUNTIME DESTINATION ${MAIN_DIR}/benchmark COMPONENT ${RUN_X86_COMPONENT_NAME}) +endif() diff --git a/mindspore/lite/tools/converter/CMakeLists.txt b/mindspore/lite/tools/converter/CMakeLists.txt index cc6fc7e1ee886cb0a7da903a02736410d20c2527..d98b37a6dacce234aeb9b0b74b578382e19c652d 100644 --- a/mindspore/lite/tools/converter/CMakeLists.txt +++ b/mindspore/lite/tools/converter/CMakeLists.txt @@ -185,7 +185,7 @@ target_link_libraries(converter_lite PRIVATE mindspore::eigen ) -if (NOT PLATFORM_arm64 AND NOT PLATFORM_arm32) +if (NOT PLATFORM_ARM64 AND NOT PLATFORM_ARM32) install(TARGETS converter_lite RUNTIME DESTINATION ${MAIN_DIR}/converter COMPONENT ${COMPONENT_NAME}) endif () diff --git a/mindspore/lite/tools/converter/quantizer/quantize_util.cc b/mindspore/lite/tools/converter/quantizer/quantize_util.cc index a5dc5a13a9ad8e8f4dd583f0357938f8dacc5de7..95f8a48810588aa3d9ac66a4e018d3e1893e2a9f 100644 --- a/mindspore/lite/tools/converter/quantizer/quantize_util.cc +++ b/mindspore/lite/tools/converter/quantizer/quantize_util.cc @@ -373,7 +373,7 @@ STATUS QuantFilter(ParamValueLitePtr weight, std::shared_ptr primiti float min = FLT_MAX; float max = -FLT_MAX; // find min and max - for (uint32_t j = 0; j < one_filter_size; j++) { + for (size_t j = 0; j < one_filter_size; j++) { auto index = j + i * one_filter_size; if (index >= elem_count) { MS_LOG(ERROR) << "over flow!";