From 487dd3ebed9cc3a67ed456826532b43bd1e1b4b1 Mon Sep 17 00:00:00 2001 From: gongdaguo Date: Tue, 28 Dec 2021 11:48:50 +0800 Subject: [PATCH] fix benchmark build --- cmake/package_lite.cmake | 6 +++--- mindspore/lite/CMakeLists.txt | 2 +- mindspore/lite/build_lite.sh | 29 +++++++++++++++++++++++------ mindspore/lite/cmake/merge.cmake | 2 +- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/cmake/package_lite.cmake b/cmake/package_lite.cmake index 6c426961a9a..ea8988c5e0d 100644 --- a/cmake/package_lite.cmake +++ b/cmake/package_lite.cmake @@ -240,7 +240,7 @@ if(PLATFORM_ARM64) __install_micro_wrapper() endif() if(MSLITE_ENABLE_TOOLS) - if(NOT BUILD_FIRST) + if(NOT MSLITE_COMPILE_TWICE) install(TARGETS ${BENCHMARK_NAME} RUNTIME DESTINATION ${BENCHMARK_ROOT_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME}) if(TARGET_HIMIX) @@ -343,7 +343,7 @@ elseif(PLATFORM_ARM32) COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h") __install_micro_wrapper() if(MSLITE_ENABLE_TOOLS AND NOT TARGET_OHOS_LITE) - if(NOT BUILD_FIRST) + if(NOT MSLITE_COMPILE_TWICE) install(TARGETS ${BENCHMARK_NAME} RUNTIME DESTINATION ${BENCHMARK_ROOT_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME}) if(TARGET_HIMIX) @@ -631,7 +631,7 @@ else() __install_micro_codegen() endif() if(MSLITE_ENABLE_TOOLS) - if(NOT BUILD_FIRST) + if(NOT MSLITE_COMPILE_TWICE) install(TARGETS ${BENCHMARK_NAME} RUNTIME DESTINATION ${BENCHMARK_ROOT_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME}) endif() diff --git a/mindspore/lite/CMakeLists.txt b/mindspore/lite/CMakeLists.txt index e6422fbb325..3f2e75648d6 100644 --- a/mindspore/lite/CMakeLists.txt +++ b/mindspore/lite/CMakeLists.txt @@ -582,7 +582,7 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src) add_subdirectory(${CCSRC_DIR}/backend/kernel_compiler/cpu/nnacl build) if(MSLITE_ENABLE_TOOLS) - if(NOT BUILD_FIRST) + if(NOT MSLITE_COMPILE_TWICE) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/benchmark) endif() if(SUPPORT_TRAIN) diff --git a/mindspore/lite/build_lite.sh b/mindspore/lite/build_lite.sh index afdc4b5bdf5..62496debaa0 100755 --- a/mindspore/lite/build_lite.sh +++ b/mindspore/lite/build_lite.sh @@ -171,14 +171,18 @@ build_lite() { TOOLCHAIN_NAME="himix200" MSLITE_REGISTRY_DEVICE=Hi3516D check_Hi35xx + MSLITE_COMPILE_TWICE=ON elif [[ "${MSLITE_REGISTRY_DEVICE}" == "Hi3559A" && "${local_lite_platform}" == "arm64" ]]; then TOOLCHAIN_NAME="himix100" check_Hi35xx + MSLITE_COMPILE_TWICE=ON elif [[ "${MSLITE_REGISTRY_DEVICE}" == "SD3403" && "${local_lite_platform}" == "arm64" ]]; then TOOLCHAIN_NAME="mix210" + MSLITE_COMPILE_TWICE=ON elif [[ "${MSLITE_REGISTRY_DEVICE}" == "Hi3519A" && "${local_lite_platform}" == "arm32" ]]; then TOOLCHAIN_NAME="himix200" check_Hi35xx + MSLITE_COMPILE_TWICE=ON elif [[ ("${MSLITE_ENABLE_NNIE}" == "on" || "${MSLITE_REGISTRY_DEVICE}" == "Hi3516D") && "${local_lite_platform}" == "x86_64" ]]; then MSLITE_REGISTRY_DEVICE=Hi3516D fi @@ -256,12 +260,15 @@ build_lite() { if [[ "X$MSLITE_REGISTRY_DEVICE" != "X" ]]; then LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DMSLITE_REGISTRY_DEVICE=${MSLITE_REGISTRY_DEVICE}" fi + if [[ "X$MSLITE_COMPILE_TWICE" != "X" ]]; then + LITE_CMAKE_ARGS="${LITE_CMAKE_ARGS} -DMSLITE_COMPILE_TWICE=${MSLITE_COMPILE_TWICE}" + fi if [[ "${local_lite_platform}" == "arm64" || "${local_lite_platform}" == "arm32" ]]; then echo "default link libc++_static.a, export MSLITE_ANDROID_STL=c++_shared to link libc++_shared.so" fi - echo "cmake ${LITE_CMAKE_ARGS} -DBUILD_FIRST=ON ${BASEPATH}/mindspore/lite" - cmake ${LITE_CMAKE_ARGS} -DBUILD_FIRST=ON "${BASEPATH}/mindspore/lite" + echo "cmake ${LITE_CMAKE_ARGS} ${BASEPATH}/mindspore/lite" + cmake ${LITE_CMAKE_ARGS} "${BASEPATH}/mindspore/lite" if [[ "$(uname)" == "Darwin" && "${local_lite_platform}" != "x86_64" ]]; then xcodebuild ONLY_ACTIVE_ARCH=NO -configuration Release -scheme mindspore-lite_static -target mindspore-lite_static -sdk iphoneos -quiet -UseModernBuildSystem=YES @@ -269,10 +276,20 @@ build_lite() { xcodebuild ONLY_ACTIVE_ARCH=NO -configuration Release -scheme mindspore-lite_static -target mindspore-lite_static -sdk iphonesimulator -quiet -UseModernBuildSystem=YES else make -j$THREAD_NUM && make install - cp -r ${BASEPATH}/output/tmp/mindspore*/runtime ${BASEPATH}/mindspore/lite/tools/benchmark - cmake ${LITE_CMAKE_ARGS} -DBUILD_FIRST=off "${BASEPATH}/mindspore/lite" - cmake --build "${BASEPATH}/mindspore/lite/build" --target benchmark -j$THREAD_NUM - make install && make package + if [[ "X$MSLITE_COMPILE_TWICE" == "XON" ]]; then + if [[ "X$MSLITE_ENABLE_TOOLS" != "X" ]]; then + MSLITE_ENABLE_TOOLS=$(echo $MSLITE_ENABLE_TOOLS | tr '[a-z]' '[A-Z]') + fi + if [[ "X$MSLITE_ENABLE_TOOLS" != "XOFF" ]]; then + LITE_CMAKE_ARGS=`echo $LITE_CMAKE_ARGS | sed 's/-DMSLITE_COMPILE_TWICE=ON/-DMSLITE_COMPILE_TWICE=OFF/g'` + cp -r ${BASEPATH}/output/tmp/mindspore*/runtime ${BASEPATH}/mindspore/lite/tools/benchmark + echo "cmake ${LITE_CMAKE_ARGS} ${BASEPATH}/mindspore/lite" + cmake ${LITE_CMAKE_ARGS} "${BASEPATH}/mindspore/lite" + cmake --build "${BASEPATH}/mindspore/lite/build" --target benchmark -j$THREAD_NUM + make install + fi + fi + make package if [[ "${local_lite_platform}" == "x86_64" ]]; then if [ "${JAVA_HOME}" ]; then echo -e "\e[31mJAVA_HOME=$JAVA_HOME \e[0m" diff --git a/mindspore/lite/cmake/merge.cmake b/mindspore/lite/cmake/merge.cmake index 7241e43adaa..5821e4c989d 100644 --- a/mindspore/lite/cmake/merge.cmake +++ b/mindspore/lite/cmake/merge.cmake @@ -3,7 +3,7 @@ function(merge_parser CL_SRC_DIR OUT_FILE_NAME) if(NOT EXISTS ${CL_SRC_DIR}) return() endif() - if(DEFINED BUILD_FIRST AND NOT BUILD_FIRST) + if(DEFINED MSLITE_COMPILE_TWICE AND NOT MSLITE_COMPILE_TWICE) return() endif() file(GLOB_RECURSE CL_LIST ${CL_SRC_DIR}/*.cc)