From 758130924f37c320f905c2a8efd613937a0d0a4d Mon Sep 17 00:00:00 2001 From: wsc Date: Sat, 22 Aug 2020 17:34:07 +0800 Subject: [PATCH] Modify the '-fvisibility' attribute of mindspore-lite project. --- cmake/package_lite.cmake | 11 +++-- mindspore/lite/CMakeLists.txt | 3 ++ mindspore/lite/nnacl/CMakeLists.txt | 46 +++++++++++++++++-- mindspore/lite/nnacl/fp16/reduce_fp16.c | 2 +- mindspore/lite/nnacl/fp16/reduce_fp16.h | 2 +- mindspore/lite/nnacl/int8/reduce_int8.c | 2 +- .../kernel/arm/fp16/arithmetic_fp16.cc | 2 +- .../kernel/arm/fp16/convolution_1x1_fp16.cc | 2 +- .../kernel/arm/fp16/convolution_3x3_fp16.cc | 2 +- .../arm/fp16/convolution_depthwise_fp16.cc | 2 +- .../kernel/arm/fp16/convolution_fp16.cc | 2 +- .../kernel/arm/fp16/convolution_sw_fp16.cc | 2 +- .../arm/fp16/convolution_winograd_fp16.cc | 2 +- .../arm/fp16/deconvolution_depthwise_fp16.cc | 2 +- .../kernel/arm/fp16/deconvolution_fp16.cc | 2 +- .../runtime/kernel/arm/fp16/pooling_fp16.cc | 2 +- .../runtime/kernel/arm/fp16/reduce_fp16.cc | 4 +- .../src/runtime/kernel/arm/fp16/split_fp16.cc | 2 +- .../runtime/kernel/arm/fp16/transpose_fp16.cc | 2 +- .../src/runtime/kernel/arm/fp32/unstack.cc | 2 +- mindspore/lite/test/CMakeLists.txt | 4 +- mindspore/lite/test/run_benchmark_nets.sh | 46 +++++++++++-------- mindspore/lite/tools/benchmark/CMakeLists.txt | 10 ++-- mindspore/lite/tools/converter/CMakeLists.txt | 2 +- .../converter/quantizer/quantize_util.cc | 2 +- 25 files changed, 108 insertions(+), 52 deletions(-) diff --git a/cmake/package_lite.cmake b/cmake/package_lite.cmake index 55ecc82c8..996ea06df 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 537f4245c..eff4c2613 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 675393d9a..6b3eb33a2 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 6a3bdf5f7..cf7665ac0 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 e7066b025..4827c691d 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 1858c194f..1893a7ef0 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 63e40c995..3bb355499 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 ed602d65c..7f5632063 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 153274d7e..883d7bca0 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 6da98cb52..cf88b2be2 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 b42e3d600..e4c1429b2 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 dc2c1bd07..7b7d1e17b 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 a361abca3..0f55fe633 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 82c0a4a8e..3a8ca200f 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 09fe8de61..0deb852cf 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 b280b7fb6..dddad9ae9 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 c17baab5a..3bc9d21ad 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 e7ec771e7..5174e10ba 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 c9c0e3fb8..0333c3687 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 dd81083dc..e12754a64 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 3aea9e8ac..7b1e91a60 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 533b85707..389229ab3 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 5996ce595..8151e126e 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 cc6fc7e1e..d98b37a6d 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 a5dc5a13a..95f8a4881 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!"; -- GitLab