!20465 [MS][LITE] fix nnie ci bug

Merge pull request !20465 from jianghui58/rm_so
This commit is contained in:
i-robot 2021-07-21 08:08:31 +00:00 committed by Gitee
commit fc41903a34
7 changed files with 97 additions and 26 deletions

View File

@ -478,6 +478,10 @@ else()
DESTINATION ${CONVERTER_ROOT_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME})
install(FILES ${glog_LIBPATH}/libglog.so.0.4.0 DESTINATION ${CONVERTER_ROOT_DIR}/lib RENAME libglog.so.0
COMPONENT ${RUNTIME_COMPONENT_NAME})
if(MSLITE_ENABLE_NNIE)
install(FILES ${glog_LIBPATH}/libglog.so.0.4.0 DESTINATION ${CONVERTER_ROOT_DIR}/lib RENAME libglog.so
COMPONENT ${RUNTIME_COMPONENT_NAME})
endif()
__install_micro_wrapper()
__install_micro_codegen()
endif()

View File

@ -4,6 +4,7 @@ project(Lite)
set(BUILD_LITE "on")
if(TOOLCHAIN_NAME STREQUAL "himix200")
set(TARGET_HIMIX200 on)
set(ENABLE_MINDRT off)
add_compile_definitions(SUPPORT_NNIE)
endif()

View File

@ -135,21 +135,23 @@ build_lite() {
write_commit_file
if [[ "${local_lite_platform}" == "arm32" ]]; then
if [[ "${TOOLCHAIN_FILE}" && "${TOOLCHAIN_NAME}" ]]; then
COMPILE_MINDDATA_LITE="off"
CMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE}
CMAKE_TOOLCHAIN_NAME=${TOOLCHAIN_NAME}
CMAKE_BUILD_TYPE=${LITE_BUILD_TYPE}
else
CMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake
ANDROID_NATIVE_API_LEVEL="19"
CMAKE_ANDROID_NDK=${ANDROID_NDK}
CMAKE_ANDROID_ABI="armeabi-v7a"
CMAKE_ANDROID_TOOLCHAIN_NAME="clang"
CMAKE_ANDROID_STL=${MSLITE_ANDROID_STL}
CMAKE_BUILD_TYPE=${LITE_BUILD_TYPE}
ENABLE_FP16="on"
fi
if [[ "${TOOLCHAIN_NAME}" == "ohos-lite" ]]; then
COMPILE_MINDDATA_LITE="off"
CMAKE_TOOLCHAIN_FILE=${BASEPATH}/mindspore/lite/cmake/ohos-lite.toolchain.cmake
CMAKE_TOOLCHAIN_NAME="ohos-lite"
elif [[ "${TOOLCHAIN_NAME}" == "himix200" ]]; then
COMPILE_MINDDATA_LITE="off"
CMAKE_TOOLCHAIN_FILE=${BASEPATH}/mindspore/lite/cmake/himix200.toolchain.cmake
CMAKE_TOOLCHAIN_NAME="himix200"
else
CMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake
ANDROID_NATIVE_API_LEVEL="19"
CMAKE_ANDROID_NDK=${ANDROID_NDK}
CMAKE_ANDROID_ABI="armeabi-v7a"
CMAKE_ANDROID_TOOLCHAIN_NAME="clang"
CMAKE_ANDROID_STL=${MSLITE_ANDROID_STL}
ENABLE_FP16="on"
fi
fi
if [[ "${local_lite_platform}" == "arm64" ]]; then
@ -181,7 +183,7 @@ build_lite() {
echo "default link libc++_static.a, export MSLITE_ANDROID_STL=c++_shared to link libc++_shared.so"
cmake -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DTOOLCHAIN_NAME=${CMAKE_TOOLCHAIN_NAME} -DANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL} \
-DANDROID_NDK=${CMAKE_ANDROID_NDK} -DANDROID_ABI=${CMAKE_ANDROID_ABI} -DANDROID_TOOLCHAIN_NAME=${CMAKE_ANDROID_TOOLCHAIN_NAME} \
-DANDROID_STL=${CMAKE_ANDROID_STL} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBUILD_MINDDATA=${COMPILE_MINDDATA_LITE} \
-DANDROID_STL=${CMAKE_ANDROID_STL} -DCMAKE_BUILD_TYPE=${LITE_BUILD_TYPE} -DBUILD_MINDDATA=${COMPILE_MINDDATA_LITE} \
-DPLATFORM_ARM32="on" -DENABLE_NEON="on" -DENABLE_FP16=${ENABLE_FP16} -DCMAKE_INSTALL_PREFIX=${BASEPATH}/output/tmp \
-DMS_VERSION_MAJOR=${VERSION_MAJOR} -DMS_VERSION_MINOR=${VERSION_MINOR} -DMS_VERSION_REVISION=${VERSION_REVISION} \
-DENABLE_ASAN=${ENABLE_ASAN} -DENABLE_VERBOSE=${ENABLE_VERBOSE} "${BASEPATH}/mindspore/lite"
@ -220,6 +222,23 @@ build_lite() {
mv ${BASEPATH}/output/tmp/*.tar.gz* ${BASEPATH}/output/
fi
[ -n "${BASEPATH}" ] && rm -rf ${BASEPATH}/output/tmp/
if [[ "${MSLITE_ENABLE_NNIE}" == "on" ]]; then
compile_nnie_script=${BASEPATH}/mindspore/lite/tools/providers/NNIE/Hi3516D/compile_nnie.sh
cd ${BASEPATH}/../
if [[ "${local_lite_platform}" == "x86_64" ]]; then
sh ${compile_nnie_script} -I x86_64 -b nnie_master -j $THREAD_NUM
if [[ $? -ne 0 ]]; then
echo "compile x86_64 for nnie failed."
exit 1
fi
elif [[ "${local_lite_platform}" == "arm32" ]]; then
sh ${compile_nnie_script} -I arm32 -b nnie_master -j $THREAD_NUM
if [[ $? -ne 0 ]]; then
echo "compile arm32 for nnie failed."
exit 1
fi
fi
fi
echo "---------------- mindspore lite: build success ----------------"
fi
}

View File

@ -0,0 +1,31 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
if(DEFINED ENV{HISI_TOOLCHAIN_PATH})
set(HISI_TOOLCHAIN_PATH $ENV{HISI_TOOLCHAIN_PATH})
else()
message(FATAL_ERROR "ENV HISI_TOOLCHAIN_PATH not found")
endif()
set(CMAKE_C_COMPILER ${HISI_TOOLCHAIN_PATH}/hisi-linux/x86_arm/arm-himix200-linux/bin/arm-himix200-linux-gcc)
set(CMAKE_CXX_COMPILER ${HISI_TOOLCHAIN_PATH}/hisi-linux/x86_arm/arm-himix200-linux/bin/arm-himix200-linux-g++)
find_path(GCC_PATH gcc)
find_path(GXX_PATH g++)
if(NOT ${GCC_PATH} STREQUAL "GCC_PATH-NOTFOUND" AND NOT ${GXX_PATH} STREQUAL "GXX_PATH-NOTFOUND")
set(FLATC_GCC_COMPILER ${GCC_PATH}/gcc)
set(FLATC_GXX_COMPILER ${GXX_PATH}/g++)
endif()
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 himix200)
set(CROSS_COMPILATION_ARCHITECTURE armv7-a)
set(CMAKE_CXX_FLAGS "-march=armv7-a -mfloat-abi=softfp -mfpu=neon-vfpv4 ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags")
set(HIMIX_STRIP ${HISI_TOOLCHAIN_PATH}/hisi-linux/x86_arm/arm-himix200-linux/bin/arm-himix200-linux-strip)

View File

@ -270,7 +270,7 @@ if(NOT APPLE AND PLATFORM_ARM)
set(NDK_STRIP
"${ANDROID_NDK}/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/aarch64-linux-android/bin/strip")
if(TARGET_HIMIX200)
set(NDK_STRIP "arm-himix200-linux-strip")
set(NDK_STRIP ${HIMIX_STRIP})
endif()
endif()

View File

@ -147,7 +147,11 @@ int CreateOutputDir(std::string *file_path) {
return RET_ERROR;
}
}
#ifdef _WIN32
*file_path += "\\" + std::to_string(count);
#else
*file_path += "/" + std::to_string(count);
#endif
int ret = MKDIR(file_path->c_str());
if (ret != RET_OK) {
MS_LOG(ERROR) << "mkdir failed. " << file_path->c_str();

View File

@ -19,19 +19,27 @@ function Run_Build_x86() {
export MSLITE_ENABLE_NNIE=on
export MSLITE_ENABLE_CONVERTER=off
export MSLITE_ENABLE_TRAIN=off
bash ${nnie_code_path}/mindspore/build.sh -I x86_64 -j 64
bash ${nnie_code_path}/mindspore/build.sh -I x86_64 -j ${thread_num}
if [ $? = 0 ]; then
echo "build x86 for nnie success"
hi3516d_release_path=${open_source_ms_path}/output/mindspore-lite-${version}-linux-x64/tools/converter/providers/Hi3516D
rm -rf ${hi3516d_release_path}
mkdir -p ${hi3516d_release_path}/third_party
cp -r ${nnie_code_path}/mindspore/mindspore/lite/tools/providers/NNIE/Hi3516D/opencv-4.2.0/ ${hi3516d_release_path}/third_party/
cp -r ${nnie_code_path}/mindspore/mindspore/lite/tools/providers/NNIE/Hi3516D/protobuf-3.9.0/ ${hi3516d_release_path}/third_party/
mkdir -p ${hi3516d_release_path}/third_party/opencv-4.2.0
mkdir -p ${hi3516d_release_path}/third_party/protobuf-3.9.0
cp ${nnie_code_path}/mindspore/mindspore/lite/tools/providers/NNIE/Hi3516D/opencv-4.2.0/lib/* ${hi3516d_release_path}/third_party/opencv-4.2.0/
cp ${nnie_code_path}/mindspore/mindspore/lite/tools/providers/NNIE/Hi3516D/protobuf-3.9.0/lib/* ${hi3516d_release_path}/third_party/protobuf-3.9.0/
cp ${nnie_code_path}/mindspore/mindspore/lite/tools/providers/NNIE/Hi3516D/libnnie_mapper.so ${hi3516d_release_path}/
cp ${nnie_code_path}/mindspore/mindspore/lite/build/tools/converter/nnie/libmslite_nnie_converter.so ${hi3516d_release_path}/ || exit 1
cp ${nnie_code_path}/mindspore/mindspore/lite/build/tools/converter/nnie/data_process/libmslite_nnie_data_process.so ${hi3516d_release_path}/ || exit 1
echo "cp new nnie so to release pkg success"
cd ${open_source_ms_path}/output/ || exit 1
# remove unused static library
rm ./mindspore-lite-${version}-linux-x64/tools/converter/lib/libcrypto.a
rm ./mindspore-lite-${version}-linux-x64/tools/converter/lib/libmindspore_core.a
rm ./mindspore-lite-${version}-linux-x64/tools/converter/lib/libmindspore_gvar.a
rm ./mindspore-lite-${version}-linux-x64/tools/converter/lib/libprotobuf.a
rm ./mindspore-lite-${version}-linux-x64/tools/converter/lib/libsecurec.a
echo "cp new nnie so to release pkg success"
rm ${open_source_ms_path}/output/mindspore-lite-${version}-linux-x64.tar.gz
tar -zcf ./mindspore-lite-${version}-linux-x64.tar.gz ./mindspore-lite-${version}-linux-x64/
sha256sum ./mindspore-lite-${version}-linux-x64.tar.gz > ./mindspore-lite-${version}-linux-x64.tar.gz.sha256
@ -59,7 +67,7 @@ function Run_Build_arm32() {
cp -r ./runtime/ ${nnie_code_path}/mindspore/mindspore/lite/tools/benchmark/nnie_proposal/third_patry/
# compile nnie runtime so
export TOOLCHAIN_FILE=${nnie_code_path}/mindspore/cmake/toolchains/himix200.toolchain.cmake
export TOOLCHAIN_FILE=${open_source_ms_path}/mindspore/lite/cmake/himix200.toolchain.cmake
export TOOLCHAIN_NAME=himix200
# disable gpu & npu & train
@ -68,7 +76,7 @@ function Run_Build_arm32() {
export MSLITE_ENABLE_TRAIN=off
export MSLITE_ENABLE_NNIE=on
bash ${nnie_code_path}/mindspore/build.sh -I arm32 -j 64
bash ${nnie_code_path}/mindspore/build.sh -I arm32 -e cpu -j ${thread_num}
if [ $? = 0 ]; then
echo "build arm32 for nnie success"
hi3516d_release_path=${open_source_ms_path}/output/mindspore-lite-${version}-linux-aarch32/providers/Hi3516D/
@ -81,7 +89,7 @@ function Run_Build_arm32() {
cd ${open_source_ms_path}/output/ || exit 1
rm ${open_source_ms_path}/output/mindspore-lite-${version}-linux-aarch32.tar.gz
tar -zcf ./mindspore-lite-${version}-linux-aarch32.tar.gz ./mindspore-lite-${version}-linux-aarch32/
sha256sum /mindspore-lite-${version}-linux-aarch32.tar.gz > /mindspore-lite-${version}-linux-aarch32.tar.gz.sha256
sha256sum ./mindspore-lite-${version}-linux-aarch32.tar.gz > ./mindspore-lite-${version}-linux-aarch32.tar.gz.sha256
else
echo "build arm32 for nnie failed"; return 1
fi
@ -94,7 +102,7 @@ echo "basepath is ${basepath}"
open_source_ms_path=${basepath}/mindspore
# Example:sh compile_nnie.sh -I arm32 -b nnie_master
while getopts "I:b:" opt; do
while getopts "I:b:j:" opt; do
case ${opt} in
I)
task=${OPTARG}
@ -104,6 +112,10 @@ while getopts "I:b:" opt; do
branch_name=${OPTARG}
echo "branch name is ${OPTARG}"
;;
j)
thread_num=${OPTARG}
echo "thread_num is ${OPTARG}"
;;
?)
echo "unknown para"
exit 1;;