forked from mindspore-Ecosystem/mindspore
compile_option
This commit is contained in:
parent
9c4d063198
commit
3302b508e5
32
build.bat
32
build.bat
|
@ -19,7 +19,6 @@ SET BASE_PATH=%CD%
|
|||
SET BUILD_PATH=%BASE_PATH%/build
|
||||
|
||||
SET threads=6
|
||||
SET X86_64_SIMD=off
|
||||
SET ENABLE_GITEE=OFF
|
||||
|
||||
set VERSION_MAJOR=''
|
||||
|
@ -36,25 +35,6 @@ set VERSION_REVISION=%z:~1,1%
|
|||
ECHO %2%|FINDSTR "^[0-9][0-9]*$"
|
||||
IF %errorlevel% == 0 (
|
||||
SET threads=%2%
|
||||
) ELSE (
|
||||
IF NOT "%2%" == "" (
|
||||
IF "%2%" == "avx" (
|
||||
SET X86_64_SIMD=avx
|
||||
) ELSE IF "%2%" == "sse" (
|
||||
SET X86_64_SIMD=sse
|
||||
) ELSE IF "%2%" == "off" (
|
||||
SET X86_64_SIMD=off
|
||||
) ELSE IF "%2%" == "avx512" (
|
||||
SET X86_64_SIMD=avx512
|
||||
) ELSE (
|
||||
echo "MindSpore_lite the second parameter must in [avx, avx512, sse, off], but now is [%2%]"
|
||||
call :clean
|
||||
EXIT /b 1
|
||||
)
|
||||
IF NOT "%3%" == "" (
|
||||
SET threads=%3%
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
IF "%FROM_GITEE%" == "1" (
|
||||
|
@ -73,18 +53,14 @@ IF NOT EXIST "%BUILD_PATH%/mindspore" (
|
|||
cd %BUILD_PATH%/mindspore
|
||||
IF "%1%" == "lite" (
|
||||
echo "======Start building MindSpore Lite %VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_REVISION%======"
|
||||
cmake --build "%BUILD_PATH%\mindspore" --target clean
|
||||
rd /s /q "%BASE_PATH%\output"
|
||||
(git log -1 | findstr "^commit") > %BUILD_PATH%\.commit_id
|
||||
cmake -DPLATFORM_ARM64=off -DSUPPORT_TRAIN=off ^
|
||||
-DENABLE_TOOLS=on -DENABLE_CONVERTER=on -DBUILD_TESTCASES=off ^
|
||||
-DCMAKE_BUILD_TYPE=Release -DSUPPORT_GPU=off -DBUILD_MINDDATA=off -DOFFLINE_COMPILE=off ^
|
||||
-DMS_VERSION_MAJOR=%VERSION_MAJOR% -DMS_VERSION_MINOR=%VERSION_MINOR% -DMS_VERSION_REVISION=%VERSION_REVISION% ^
|
||||
-DX86_64_SIMD=%X86_64_SIMD% ^
|
||||
-G "CodeBlocks - MinGW Makefiles" "%BASE_PATH%/mindspore/lite"
|
||||
cmake -DPLATFORM_X86_64=on -DBUILD_MINDDATA=off ^
|
||||
-DMS_VERSION_MAJOR=%VERSION_MAJOR% -DMS_VERSION_MINOR=%VERSION_MINOR% -DMS_VERSION_REVISION=%VERSION_REVISION% ^
|
||||
-DCMAKE_BUILD_TYPE=Release -G "CodeBlocks - MinGW Makefiles" "%BASE_PATH%/mindspore/lite"
|
||||
) ELSE (
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CPU=ON -DENABLE_MINDDATA=ON -DUSE_GLOG=ON -DENABLE_GITEE=%ENABLE_GITEE% ^
|
||||
-G "CodeBlocks - MinGW Makefiles" ../..
|
||||
-G "CodeBlocks - MinGW Makefiles" ../..
|
||||
)
|
||||
IF NOT %errorlevel% == 0 (
|
||||
echo "cmake fail."
|
||||
|
|
627
build.sh
627
build.sh
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
# Copyright 2019 Huawei Technologies Co., Ltd
|
||||
# Copyright 2019-2021 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -23,10 +23,10 @@ usage()
|
|||
{
|
||||
echo "Usage:"
|
||||
echo "bash build.sh [-d] [-r] [-v] [-c on|off] [-t ut|st] [-g on|off] [-h] [-b ge] [-m infer|train] \\"
|
||||
echo " [-a on|off] [-p on|off] [-i] [-R] [-D on|off] [-j[n]] [-e gpu|ascend|cpu|npu] \\"
|
||||
echo " [-a on|off] [-p on|off] [-i] [-R] [-D on|off] [-j[n]] [-e gpu|ascend|cpu] \\"
|
||||
echo " [-P on|off] [-z [on|off]] [-M on|off] [-V 10.1|11.1|310|910] [-I arm64|arm32|x86_64] [-K] \\"
|
||||
echo " [-B on|off] [-E] [-l on|off] [-n full|lite|off] [-T on|off] [-H on|off] \\"
|
||||
echo " [-A [cpp|java|object-c] [-C on|off] [-o on|off] [-S on|off] [-k on|off] [-W sse|neon|avx|off] \\"
|
||||
echo " [-B on|off] [-E] [-l on|off] [-n full|lite|off] [-H on|off] \\"
|
||||
echo " [-A on|off] [-S on|off] [-k on|off] [-W sse|neon|avx|off] \\"
|
||||
echo " [-L Tensor-RT path] \\"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
|
@ -45,7 +45,7 @@ usage()
|
|||
echo " -R Enable pipeline profile, record to json, default off"
|
||||
echo " -i Enable increment building, default off"
|
||||
echo " -j[n] Set the threads when building (Default: -j8)"
|
||||
echo " -e Use cpu, gpu, npu or ascend"
|
||||
echo " -e Use cpu, gpu or ascend"
|
||||
echo " -P Enable dump anf graph to file in ProtoBuffer format, default on"
|
||||
echo " -D Enable dumping of function graph ir, default on"
|
||||
echo " -z Compile dataset & mindrecord, default on"
|
||||
|
@ -53,14 +53,11 @@ usage()
|
|||
echo " -M Enable MPI and NCCL for GPU training, gpu default on"
|
||||
echo " -V Specify the device version, if -e gpu, default CUDA 10.1, if -e ascend, default Ascend 910"
|
||||
echo " -I Enable compiling mindspore lite for arm64, arm32 or x86_64, default disable mindspore lite compilation"
|
||||
echo " -A Enable compiling mindspore lite aar package, option: on/off, default: off"
|
||||
echo " -K Compile with AKG, default on"
|
||||
echo " -B Enable debugger, default on"
|
||||
echo " -E Enable IBVERBS for parameter server, default off"
|
||||
echo " -l Compile with python dependency, default on"
|
||||
echo " -A Language used by mindspore lite, default cpp"
|
||||
echo " -T Enable on-device training, default off"
|
||||
echo " -C Enable mindspore lite converter compilation, enabled when -I is specified, default on"
|
||||
echo " -o Enable mindspore lite tools compilation, enabled when -I is specified, default on"
|
||||
echo " -S Enable enable download cmake compile dependency from gitee , default off"
|
||||
echo " -k Enable make clean, clean up compilation generated cache "
|
||||
echo " -W Enable x86_64 SSE or AVX instruction set, use [sse|avx|neon|off], default off"
|
||||
|
@ -103,7 +100,7 @@ checkopts()
|
|||
CUDA_VERSION="10.1"
|
||||
COMPILE_LITE="off"
|
||||
LITE_PLATFORM=""
|
||||
SUPPORT_TRAIN="off"
|
||||
LITE_ENABLE_AAR="off"
|
||||
USE_GLOG="on"
|
||||
ENABLE_AKG="on"
|
||||
ENABLE_ACL="off"
|
||||
|
@ -113,22 +110,16 @@ checkopts()
|
|||
ENABLE_PYTHON="on"
|
||||
ENABLE_GPU="off"
|
||||
ENABLE_VERBOSE="off"
|
||||
ENABLE_TOOLS="on"
|
||||
ENABLE_CONVERTER="on"
|
||||
LITE_LANGUAGE="cpp"
|
||||
ENABLE_GITEE="off"
|
||||
ANDROID_STL="c++_shared"
|
||||
ENABLE_MAKE_CLEAN="off"
|
||||
X86_64_SIMD="off"
|
||||
ARM_SIMD="off"
|
||||
DEVICE_VERSION=""
|
||||
DEVICE=""
|
||||
ENABLE_NPU="off"
|
||||
ENABLE_HIDDEN="on"
|
||||
LITE_ENABLE_GPU=""
|
||||
TENSORRT_HOME=""
|
||||
# Process the options
|
||||
while getopts 'drvj:c:t:hsb:a:g:p:ie:m:l:I:RP:D:zM:V:K:B:En:T:A:C:o:S:k:W:H:L:' opt
|
||||
while getopts 'drvj:c:t:hsb:a:g:p:ie:m:l:I:RP:D:zM:V:K:B:En:A:S:k:W:H:L:' opt
|
||||
do
|
||||
CASE_SENSIVE_ARG=${OPTARG}
|
||||
OPTARG=$(echo ${OPTARG} | tr '[A-Z]' '[a-z]')
|
||||
|
@ -264,16 +255,10 @@ checkopts()
|
|||
I)
|
||||
COMPILE_LITE="on"
|
||||
if [[ "$OPTARG" == "arm64" ]]; then
|
||||
ENABLE_CONVERTER="off"
|
||||
RUN_TESTCASES="on"
|
||||
LITE_PLATFORM="arm64"
|
||||
elif [[ "$OPTARG" == "arm32" ]]; then
|
||||
ENABLE_CONVERTER="off"
|
||||
RUN_TESTCASES="on"
|
||||
LITE_PLATFORM="arm32"
|
||||
elif [[ "$OPTARG" == "x86_64" ]]; then
|
||||
ENABLE_CONVERTER="on"
|
||||
RUN_TESTCASES="on"
|
||||
LITE_PLATFORM="x86_64"
|
||||
else
|
||||
echo "-I parameter must be arm64、arm32 or x86_64"
|
||||
|
@ -292,38 +277,12 @@ checkopts()
|
|||
ENABLE_IBVERBS="on"
|
||||
echo "enable IBVERBS for parameter server"
|
||||
;;
|
||||
T)
|
||||
check_on_off $OPTARG T
|
||||
SUPPORT_TRAIN=$OPTARG
|
||||
COMPILE_MINDDATA_LITE="full"
|
||||
echo "support train on device "
|
||||
;;
|
||||
A)
|
||||
COMPILE_LITE="on"
|
||||
if [[ "$OPTARG" == "cpp" ]]; then
|
||||
LITE_LANGUAGE="cpp"
|
||||
ANDROID_STL="c++_shared"
|
||||
elif [[ "$OPTARG" == "java" ]]; then
|
||||
LITE_LANGUAGE="java"
|
||||
ENABLE_CONVERTER="off"
|
||||
ANDROID_STL="c++_static"
|
||||
RUN_TESTCASES="off"
|
||||
ENABLE_TOOLS="off"
|
||||
elif [[ "$OPTARG" == "object-c" ]]; then
|
||||
LITE_LANGUAGE="object-c"
|
||||
else
|
||||
echo "-A parameter must be cpp, java or object-c"
|
||||
exit 1
|
||||
if [[ "$OPTARG" == "on" ]]; then
|
||||
LITE_ENABLE_AAR="on"
|
||||
fi
|
||||
;;
|
||||
C)
|
||||
check_on_off $OPTARG C
|
||||
ENABLE_CONVERTER="$OPTARG"
|
||||
;;
|
||||
o)
|
||||
check_on_off $OPTARG o
|
||||
ENABLE_TOOLS="$OPTARG"
|
||||
;;
|
||||
W)
|
||||
if [[ "$OPTARG" != "sse" && "$OPTARG" != "off" && "$OPTARG" != "avx" && "$OPTARG" != "neon" ]]; then
|
||||
echo "Invalid value ${OPTARG} for option -W, -W parameter must be sse|neon|avx|off"
|
||||
|
@ -354,7 +313,7 @@ checkopts()
|
|||
esac
|
||||
done
|
||||
|
||||
if [[ "X$RUN_TESTCASES" == "Xon" && "X$DEVICE" != "X" && "X$COMPILE_LITE" != "Xon" ]]; then
|
||||
if [[ "X$RUN_TESTCASES" == "Xon" && "X$DEVICE" != "X" ]]; then
|
||||
echo "WARNING:Option -e can't be set while option -t on/ut is set, reset device to empty."
|
||||
DEVICE=""
|
||||
fi
|
||||
|
@ -362,7 +321,6 @@ checkopts()
|
|||
# Parse device
|
||||
# Process build option
|
||||
if [[ "X$DEVICE" == "Xgpu" ]]; then
|
||||
LITE_ENABLE_GPU="opencl"
|
||||
ENABLE_GPU="on"
|
||||
ENABLE_CPU="on"
|
||||
ENABLE_MPI="on"
|
||||
|
@ -394,17 +352,8 @@ checkopts()
|
|||
usage
|
||||
exit 1
|
||||
fi
|
||||
elif [[ "X$DEVICE" == "Xnpu" ]]; then
|
||||
ENABLE_NPU="on"
|
||||
ENABLE_CPU="on"
|
||||
elif [[ "X$DEVICE" == "Xcpu" ]]; then
|
||||
ENABLE_CPU="on"
|
||||
elif [[ "X$DEVICE" == "Xopencl" ]]; then
|
||||
LITE_ENABLE_GPU="opencl"
|
||||
elif [[ "X$DEVICE" == "Xvulkan" ]]; then
|
||||
LITE_ENABLE_GPU="vulkan"
|
||||
elif [[ "X$DEVICE" == "Xcuda" ]]; then
|
||||
LITE_ENABLE_GPU="cuda"
|
||||
elif [[ "X$DEVICE" == "X" ]]; then
|
||||
:
|
||||
else
|
||||
|
@ -414,17 +363,16 @@ checkopts()
|
|||
fi
|
||||
}
|
||||
|
||||
checkopts "$@"
|
||||
echo "---------------- MindSpore: build start ----------------"
|
||||
mkdir -pv "${BUILD_PATH}/package/mindspore/lib"
|
||||
git submodule update --init graphengine
|
||||
cd "${BASEPATH}/graphengine"
|
||||
git submodule update --init metadef
|
||||
cd "${BASEPATH}"
|
||||
if [[ "X$ENABLE_AKG" = "Xon" ]] && [[ "X$ENABLE_D" = "Xon" || "X$ENABLE_GPU" = "Xon" ]]; then
|
||||
git submodule update --init --recursive akg
|
||||
fi
|
||||
|
||||
update_submodule()
|
||||
{
|
||||
git submodule update --init graphengine
|
||||
cd "${BASEPATH}/graphengine"
|
||||
git submodule update --init metadef
|
||||
cd "${BASEPATH}"
|
||||
if [[ "X$ENABLE_AKG" = "Xon" ]] && [[ "X$ENABLE_D" = "Xon" || "X$ENABLE_GPU" = "Xon" ]]; then
|
||||
git submodule update --init --recursive akg
|
||||
fi
|
||||
}
|
||||
|
||||
build_exit()
|
||||
{
|
||||
|
@ -529,15 +477,6 @@ checkndk() {
|
|||
fi
|
||||
}
|
||||
|
||||
checkddk() {
|
||||
if [ "${HWHIAI_DDK}" ]; then
|
||||
echo -e "\e[31mHWHIAI_DDK=$HWHIAI_DDK \e[0m"
|
||||
else
|
||||
echo -e "\e[31mplease set HWHIAI_DDK in environment variable for example: export HWHIAI_DDK=/root/usr/hwhiai-ddk-100.500.010.010/ \e[0m"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
get_version() {
|
||||
VERSION_MAJOR=$(grep "const int ms_version_major =" ${BASEPATH}/mindspore/lite/include/version.h | tr -dc "[0-9]")
|
||||
VERSION_MINOR=$(grep "const int ms_version_minor =" ${BASEPATH}/mindspore/lite/include/version.h | tr -dc "[0-9]")
|
||||
|
@ -550,328 +489,239 @@ write_commit_file() {
|
|||
echo ${COMMIT_STR} > "${BASEPATH}/mindspore/lite/build/.commit_id"
|
||||
}
|
||||
|
||||
build_lite_x86_64_jni_and_jar()
|
||||
{
|
||||
# copy x86 so
|
||||
local inference_or_train=inference
|
||||
local is_train=off
|
||||
cd ${BASEPATH}/output/tmp
|
||||
if [ -f "mindspore-lite-${VERSION_STR}-train-linux-x64.tar.gz" ]; then
|
||||
inference_or_train=train
|
||||
is_train=on
|
||||
fi
|
||||
local pkg_name=mindspore-lite-${VERSION_STR}-${inference_or_train}-linux-x64
|
||||
|
||||
cd ${BASEPATH}/output/tmp/
|
||||
rm -rf ${pkg_name}
|
||||
tar -zxf ${BASEPATH}/output/tmp/${pkg_name}.tar.gz
|
||||
rm -rf ${LITE_JAVA_PATH}/java/linux_x86/libs/ && mkdir -pv ${LITE_JAVA_PATH}/java/linux_x86/libs/
|
||||
rm -rf ${LITE_JAVA_PATH}/native/libs/linux_x86/ && mkdir -pv ${LITE_JAVA_PATH}/native/libs/linux_x86/
|
||||
cp ./${pkg_name}/${inference_or_train}/lib/*.so* ${LITE_JAVA_PATH}/java/linux_x86/libs/
|
||||
cp ./${pkg_name}/${inference_or_train}/lib/*.so* ${LITE_JAVA_PATH}/native/libs/linux_x86/
|
||||
if [ -f "mindspore-lite-${VERSION_STR}-train-linux-x64.tar.gz" ]; then
|
||||
cp ./${pkg_name}/train/third_party/libjpeg-turbo/lib/*.so* ${LITE_JAVA_PATH}/java/linux_x86/libs/
|
||||
cp ./${pkg_name}/train/third_party/libjpeg-turbo/lib/*.so* ${LITE_JAVA_PATH}/native/libs/linux_x86/
|
||||
fi
|
||||
# build jni so
|
||||
cd ${BASEPATH}/mindspore/lite/build
|
||||
rm -rf java/jni && mkdir -pv java/jni
|
||||
cd java/jni
|
||||
cmake -DMS_VERSION_MAJOR=${VERSION_MAJOR} -DMS_VERSION_MINOR=${VERSION_MINOR} -DMS_VERSION_REVISION=${VERSION_REVISION} \
|
||||
-DCMAKE_BUILD_TYPE=${LITE_BUILD_TYPE} -DENABLE_VERBOSE=${ENABLE_VERBOSE} -DSUPPORT_TRAIN=${is_train} "${LITE_JAVA_PATH}/native/"
|
||||
make -j$THREAD_NUM
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "---------------- mindspore lite: build jni x86_64 failed----------------"
|
||||
exit 1
|
||||
fi
|
||||
cp ./libmindspore-lite-jni.so ${LITE_JAVA_PATH}/java/linux_x86/libs/
|
||||
cp ./libmindspore-lite-jni.so ${LITE_JAVA_PATH}/native/libs/linux_x86/
|
||||
cp ./libmindspore-lite-jni.so ${BASEPATH}/output/tmp/${pkg_name}/${inference_or_train}/lib/
|
||||
|
||||
# build java common
|
||||
cd ${LITE_JAVA_PATH}/java/common
|
||||
gradle clean
|
||||
gradle build
|
||||
cp ${LITE_JAVA_PATH}/java/common/build/libs/mindspore-lite-java-common.jar ${LITE_JAVA_PATH}/java/linux_x86/libs/
|
||||
|
||||
# build jar
|
||||
cd ${LITE_JAVA_PATH}/java/linux_x86/
|
||||
gradle clean
|
||||
gradle releaseJar
|
||||
cp ./build/lib/jar/*.jar ${BASEPATH}/output/tmp/${pkg_name}/${inference_or_train}/lib/
|
||||
|
||||
# package
|
||||
cd ${BASEPATH}/output/tmp
|
||||
rm -rf ${pkg_name}.tar.gz ${pkg_name}.tar.gz.sha256
|
||||
tar czf ${pkg_name}.tar.gz ${pkg_name}
|
||||
sha256sum ${pkg_name}.tar.gz > ${pkg_name}.tar.gz.sha256
|
||||
rm -rf ${LITE_JAVA_PATH}/java/linux_x86/libs/
|
||||
rm -rf ${LITE_JAVA_PATH}/native/libs/linux_x86/
|
||||
}
|
||||
|
||||
build_lite()
|
||||
{
|
||||
[ -n "${BASEPATH}" ] && rm -rf ${BASEPATH}/output
|
||||
get_version
|
||||
echo "============ Start building MindSpore Lite ${VERSION_STR} ============"
|
||||
local local_lite_platform=${LITE_PLATFORM}
|
||||
local local_lite_inc_build=${INC_BUILD}
|
||||
local local_lite_enable_gpu=${LITE_ENABLE_GPU}
|
||||
local local_lite_enable_npu=${ENABLE_NPU}
|
||||
|
||||
if [[ "${LITE_LANGUAGE}" == "java" ]]; then
|
||||
if [[ "X$1" != "X" ]]; then
|
||||
local_lite_platform=$1
|
||||
else
|
||||
local_lite_platform=""
|
||||
fi
|
||||
if [[ "X$2" != "X" ]]; then
|
||||
local_lite_inc_build=$2
|
||||
else
|
||||
local_lite_inc_build=""
|
||||
fi
|
||||
if [[ "X$3" != "X" ]]; then
|
||||
local_lite_enable_gpu=$3
|
||||
else
|
||||
local_lite_enable_gpu=""
|
||||
fi
|
||||
mkdir -p ${BASEPATH}/mindspore/lite/build/java
|
||||
if [[ "${LITE_ENABLE_AAR}" == "on" ]]; then
|
||||
local_lite_platform=$1
|
||||
mkdir -pv ${BASEPATH}/mindspore/lite/build/java
|
||||
cd ${BASEPATH}/mindspore/lite/build/
|
||||
[ -n "${BASEPATH}" ] && find . -maxdepth 1 | grep -v java | grep '/' | xargs -I {} rm -rf {}
|
||||
fi
|
||||
if [[ "${LITE_LANGUAGE}" == "cpp" ]]; then
|
||||
if [[ "${DEVICE}" == "" ]]; then
|
||||
if [[ "${local_lite_platform}" == "arm64" || "${local_lite_platform}" == "arm32" ]]; then
|
||||
local_lite_enable_npu="on"
|
||||
fi
|
||||
if [[ "${local_lite_platform}" == "arm64" ]]; then
|
||||
local_lite_enable_gpu="opencl"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${local_lite_inc_build}" == "off" ]]; then
|
||||
[ -n "${BASEPATH}" ] && rm -rf ${BASEPATH}/mindspore/lite/build
|
||||
else
|
||||
if [[ "${INC_BUILD}" == "off" ]]; then
|
||||
[ -n "${BASEPATH}" ] && rm -rf ${BASEPATH}/mindspore/lite/build
|
||||
fi
|
||||
mkdir -pv ${BASEPATH}/mindspore/lite/build
|
||||
fi
|
||||
|
||||
if [ "${local_lite_enable_npu}" == "on" ]; then
|
||||
checkddk
|
||||
fi
|
||||
|
||||
cd ${BASEPATH}/mindspore/lite/build
|
||||
write_commit_file
|
||||
BUILD_TYPE="Release"
|
||||
if [[ "${DEBUG_MODE}" == "on" ]]; then
|
||||
BUILD_TYPE="Debug"
|
||||
fi
|
||||
|
||||
if [[ "${local_lite_platform}" == "arm64" ]]; then
|
||||
if [ "${OS}" == "Darwin" ]; then
|
||||
cmake -DCMAKE_BUILD_TYPE="Release" \
|
||||
-DCMAKE_TOOLCHAIN_FILE=${BASEPATH}/cmake/lite_ios.cmake \
|
||||
-DARCHS="arm64" -DENABLE_BITCODE=0 \
|
||||
-DSUPPORT_TRAIN="off" \
|
||||
-DENABLE_MINDRT=off \
|
||||
-DPLATFORM_ARM64="on" -DENABLE_NEON=on -DENABLE_FP16="on" \
|
||||
-DENABLE_TOOLS="on" -DENABLE_CONVERTER="off" -DBUILD_TESTCASES="off" \
|
||||
-DSUPPORT_GPU="" -DSUPPORT_NPU="off" -DENABLE_V0="on" \
|
||||
-DOFFLINE_COMPILE=${OPENCL_OFFLINE_COMPILE} -DBUILD_MINDDATA="" -DENABLE_ASAN=${ENABLE_ASAN} \
|
||||
-DCMAKE_INSTALL_PREFIX=${BUILD_PATH}/output/tmp \
|
||||
-G Xcode ..
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=${BASEPATH}/cmake/lite_ios.cmake -DARCHS="arm64" -DENABLE_BITCODE=0 \
|
||||
-DCMAKE_BUILD_TYPE="Release" -DBUILD_MINDDATA="" -DPLATFORM_ARM64="on" -DENABLE_NEON="on" -DENABLE_FP16="on" \
|
||||
-DMSLITE_ENABLE_TRAIN="off" -DENABLE_MINDRT="off" -DMSLITE_GPU_BACKEND="off" -DMSLITE_ENABLE_NPU="off" \
|
||||
-DENABLE_ASAN=${ENABLE_ASAN} -DCMAKE_INSTALL_PREFIX=${BUILD_PATH}/output/tmp -G Xcode ..
|
||||
else
|
||||
checkndk
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" -DANDROID_NATIVE_API_LEVEL="19" \
|
||||
-DANDROID_NDK="${ANDROID_NDK}" -DANDROID_ABI="arm64-v8a" -DANDROID_TOOLCHAIN_NAME="aarch64-linux-android-clang" \
|
||||
-DANDROID_STL=${ANDROID_STL} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DSUPPORT_TRAIN=${SUPPORT_TRAIN} \
|
||||
-DPLATFORM_ARM64=on -DENABLE_NEON=on -DENABLE_FP16="on" \
|
||||
-DENABLE_TOOLS=${ENABLE_TOOLS} -DENABLE_CONVERTER=${ENABLE_CONVERTER} -DBUILD_TESTCASES=${RUN_TESTCASES} \
|
||||
-DSUPPORT_GPU=${local_lite_enable_gpu} -DSUPPORT_NPU=${local_lite_enable_npu} -DENABLE_V0=on \
|
||||
-DOFFLINE_COMPILE=${OPENCL_OFFLINE_COMPILE} -DBUILD_MINDDATA=${COMPILE_MINDDATA_LITE} -DENABLE_ASAN=${ENABLE_ASAN} \
|
||||
-DCMAKE_INSTALL_PREFIX=${BASEPATH}/output/tmp -DMS_VERSION_MAJOR=${VERSION_MAJOR} \
|
||||
-DMS_VERSION_MINOR=${VERSION_MINOR} -DMS_VERSION_REVISION=${VERSION_REVISION} -DENABLE_VERBOSE=${ENABLE_VERBOSE} \
|
||||
"${BASEPATH}/mindspore/lite"
|
||||
echo "default link libc++_static.a, export MSLITE_ANDROID_STL=c++_shared to link libc++_shared.so"
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" -DANDROID_NATIVE_API_LEVEL="19" \
|
||||
-DANDROID_NDK="${ANDROID_NDK}" -DANDROID_ABI="arm64-v8a" -DANDROID_TOOLCHAIN_NAME="aarch64-linux-android-clang" \
|
||||
-DANDROID_STL=${MSLITE_ANDROID_STL} -DCMAKE_BUILD_TYPE=${LITE_BUILD_TYPE} -DBUILD_MINDDATA=${COMPILE_MINDDATA_LITE} \
|
||||
-DPLATFORM_ARM64="on" -DENABLE_NEON="on" -DENABLE_FP16="on" -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"
|
||||
fi
|
||||
elif [[ "${local_lite_platform}" == "arm32" ]]; then
|
||||
if [ "${OS}" == "Darwin" ]; then
|
||||
cmake -DCMAKE_BUILD_TYPE="Release" \
|
||||
-DCMAKE_TOOLCHAIN_FILE=${BASEPATH}/cmake/lite_ios.cmake \
|
||||
-DARCHS="armv7;armv7s" -DENABLE_BITCODE=0 \
|
||||
-DSUPPORT_TRAIN="off" \
|
||||
-DENABLE_MINDRT=off \
|
||||
-DPLATFORM_ARM32="on" -DENABLE_NEON=on \
|
||||
-DENABLE_TOOLS="on" -DENABLE_CONVERTER="off" -DBUILD_TESTCASES="off" \
|
||||
-DSUPPORT_GPU="" -DSUPPORT_NPU="off" -DENABLE_V0=on \
|
||||
-DOFFLINE_COMPILE=${OPENCL_OFFLINE_COMPILE} -DBUILD_MINDDATA="" -DENABLE_ASAN=${ENABLE_ASAN} \
|
||||
-DCMAKE_INSTALL_PREFIX=${BUILD_PATH}/output/tmp \
|
||||
-G Xcode ..
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=${BASEPATH}/cmake/lite_ios.cmake -DARCHS="armv7;armv7s" -DENABLE_BITCODE=0 \
|
||||
-DCMAKE_BUILD_TYPE="Release" -DBUILD_MINDDATA="" -DPLATFORM_ARM32="on" -DENABLE_NEON="on" \
|
||||
-DMSLITE_ENABLE_TRAIN="off" -DENABLE_MINDRT="off" \
|
||||
-DENABLE_ASAN=${ENABLE_ASAN} -DCMAKE_INSTALL_PREFIX=${BUILD_PATH}/output/tmp -G Xcode ..
|
||||
else
|
||||
checkndk
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" -DANDROID_NATIVE_API_LEVEL="19" \
|
||||
-DANDROID_NDK="${ANDROID_NDK}" -DANDROID_ABI="armeabi-v7a" -DANDROID_TOOLCHAIN_NAME="clang" \
|
||||
-DANDROID_STL=${ANDROID_STL} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DPLATFORM_ARM32=on -DENABLE_NEON=on -DSUPPORT_TRAIN=${SUPPORT_TRAIN} -DENABLE_FP16="on" \
|
||||
-DENABLE_TOOLS=${ENABLE_TOOLS} -DENABLE_CONVERTER=${ENABLE_CONVERTER} -DBUILD_TESTCASES=${RUN_TESTCASES} \
|
||||
-DSUPPORT_GPU=${local_lite_enable_gpu} -DSUPPORT_NPU=${local_lite_enable_npu} -DENABLE_V0=on \
|
||||
-DOFFLINE_COMPILE=${OPENCL_OFFLINE_COMPILE} -DBUILD_MINDDATA=${COMPILE_MINDDATA_LITE} -DENABLE_ASAN=${ENABLE_ASAN} \
|
||||
-DCMAKE_INSTALL_PREFIX=${BASEPATH}/output/tmp -DMS_VERSION_MAJOR=${VERSION_MAJOR} \
|
||||
-DMS_VERSION_MINOR=${VERSION_MINOR} -DMS_VERSION_REVISION=${VERSION_REVISION} -DENABLE_VERBOSE=${ENABLE_VERBOSE} \
|
||||
"${BASEPATH}/mindspore/lite"
|
||||
echo "default link libc++_static.a, export MSLITE_ANDROID_STL=c++_shared to link libc++_shared.so"
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" -DANDROID_NATIVE_API_LEVEL="19" \
|
||||
-DANDROID_NDK="${ANDROID_NDK}" -DANDROID_ABI="armeabi-v7a" -DANDROID_TOOLCHAIN_NAME="clang" \
|
||||
-DANDROID_STL=${MSLITE_ANDROID_STL} -DCMAKE_BUILD_TYPE=${LITE_BUILD_TYPE} -DBUILD_MINDDATA=${COMPILE_MINDDATA_LITE} \
|
||||
-DPLATFORM_ARM32="on" -DENABLE_NEON="on" -DENABLE_FP16="on" -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"
|
||||
fi
|
||||
else
|
||||
cmake -DPLATFORM_ARM64=off -DSUPPORT_TRAIN=${SUPPORT_TRAIN} \
|
||||
-DENABLE_TOOLS=${ENABLE_TOOLS} -DENABLE_CONVERTER=${ENABLE_CONVERTER} -DBUILD_TESTCASES=${RUN_TESTCASES} \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DSUPPORT_GPU=${local_lite_enable_gpu} -DSUPPORT_NPU=${local_lite_enable_npu} \
|
||||
-DBUILD_MINDDATA=${COMPILE_MINDDATA_LITE} -DENABLE_V0=on -DENABLE_ASAN=${ENABLE_ASAN} \
|
||||
-DOFFLINE_COMPILE=${OPENCL_OFFLINE_COMPILE} -DCMAKE_INSTALL_PREFIX=${BASEPATH}/output/tmp \
|
||||
-DMS_VERSION_MAJOR=${VERSION_MAJOR} -DMS_VERSION_MINOR=${VERSION_MINOR} -DMS_VERSION_REVISION=${VERSION_REVISION} \
|
||||
-DENABLE_VERBOSE=${ENABLE_VERBOSE} -DX86_64_SIMD=${X86_64_SIMD} "${BASEPATH}/mindspore/lite"
|
||||
cmake -DPLATFORM_X86_64=on -DCMAKE_BUILD_TYPE=${LITE_BUILD_TYPE} -DBUILD_MINDDATA=${COMPILE_MINDDATA_LITE} \
|
||||
-DMS_VERSION_MAJOR=${VERSION_MAJOR} -DMS_VERSION_MINOR=${VERSION_MINOR} -DMS_VERSION_REVISION=${VERSION_REVISION} \
|
||||
-DENABLE_ASAN=${ENABLE_ASAN} -DCMAKE_INSTALL_PREFIX=${BASEPATH}/output/tmp -DENABLE_VERBOSE=${ENABLE_VERBOSE} "${BASEPATH}/mindspore/lite"
|
||||
fi
|
||||
if [ "${OS}" == "Darwin" ]; then
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
xcodebuild ONLY_ACTIVE_ARCH=NO -configuration Release -scheme mindspore_lite -target mindspore_lite -sdk iphoneos -quiet
|
||||
else
|
||||
make -j$THREAD_NUM && make install && make package
|
||||
if [[ "${local_lite_platform}" == "x86_64" ]]; then
|
||||
if [ "${JAVA_HOME}" ]; then
|
||||
echo -e "\e[31mJAVA_HOME=$JAVA_HOME \e[0m"
|
||||
build_lite_x86_64_jni_and_jar
|
||||
else
|
||||
echo -e "\e[31mJAVA_HOME is not set, so jni and jar packages will not be compiled \e[0m"
|
||||
echo -e "\e[31mIf you want to compile the JAR package, please set $JAVA_HOME. For example: export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 \e[0m"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "---------------- mindspore lite: build failed ----------------"
|
||||
exit 1
|
||||
else
|
||||
if [[ "${LITE_LANGUAGE}" == "cpp" ]]; then
|
||||
if [ "${OS}" == "Darwin" ]; then
|
||||
mkdir -p ${BASEPATH}/output
|
||||
cp -r ${BASEPATH}/mindspore/lite/build/src/Release-iphoneos/mindspore_lite.framework ${BASEPATH}/output/mindspore_lite.framework
|
||||
cd ${BASEPATH}/output
|
||||
tar -zcvf mindspore_lite.framework-${VERSION_STR}-${local_lite_platform}.tar.gz mindspore_lite.framework/
|
||||
sha256sum mindspore_lite.framework-${VERSION_STR}-${local_lite_platform}.tar.gz > \
|
||||
mindspore_lite.framework-${VERSION_STR}-${local_lite_platform}.tar.gz.sha256
|
||||
rm -r mindspore_lite.framework
|
||||
else
|
||||
mv ${BASEPATH}/output/tmp/*.tar.gz* ${BASEPATH}/output/
|
||||
fi
|
||||
elif [[ "${LITE_LANGUAGE}" == "java" ]]; then
|
||||
mv ${BASEPATH}/output/tmp/*.tar.gz* ${BASEPATH}/mindspore/lite/build/java
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
mkdir -p ${BASEPATH}/output
|
||||
cp -r ${BASEPATH}/mindspore/lite/build/src/Release-iphoneos/mindspore_lite.framework ${BASEPATH}/output/mindspore_lite.framework
|
||||
cd ${BASEPATH}/output
|
||||
tar -zcvf mindspore_lite.framework-${VERSION_STR}-${local_lite_platform}.tar.gz mindspore_lite.framework/
|
||||
sha256sum mindspore_lite.framework-${VERSION_STR}-${local_lite_platform}.tar.gz > \
|
||||
mindspore_lite.framework-${VERSION_STR}-${local_lite_platform}.tar.gz.sha256
|
||||
rm -r mindspore_lite.framework
|
||||
else
|
||||
mv ${BASEPATH}/output/tmp/*.tar.gz* ${BASEPATH}/output/
|
||||
fi
|
||||
[ -n "${BASEPATH}" ] && rm -rf ${BASEPATH}/output/tmp/
|
||||
echo "---------------- mindspore lite: build success ----------------"
|
||||
if [[ "X$LITE_LANGUAGE" = "Xcpp" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
if [ "${OS}" == "Darwin" ]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
build_lite_java_arm64() {
|
||||
# build mindspore-lite arm64
|
||||
local local_pkg_name=mindspore-lite-${VERSION_STR}-inference-android-aarch64
|
||||
if [[ "X$SUPPORT_TRAIN" = "Xon" ]]; then
|
||||
local_pkg_name=mindspore-lite-${VERSION_STR}-train-android-aarch64
|
||||
fi
|
||||
if [[ "X$INC_BUILD" == "Xoff" ]] || [[ ! -f "${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}.tar.gz" ]]; then
|
||||
if [[ "X${DEVICE}" == "Xcpu" ]]; then
|
||||
build_lite "arm64" "off" ""
|
||||
elif [[ "X${DEVICE}" == "Xnpu" ]]; then
|
||||
echo "NPU only support c++."
|
||||
exit 1
|
||||
else
|
||||
build_lite "arm64" "off" "opencl"
|
||||
fi
|
||||
fi
|
||||
build_lite_arm64_and_jni() {
|
||||
# build arm64
|
||||
build_lite "arm64"
|
||||
# copy arm64 so
|
||||
cd ${BASEPATH}/mindspore/lite/build/java/
|
||||
[ -n "${local_pkg_name}" ] && rm -rf ${local_pkg_name}
|
||||
tar -zxvf ${local_pkg_name}.tar.gz
|
||||
[ -n "${JAVA_PATH}" ] && rm -rf ${JAVA_PATH}/java/app/libs/arm64-v8a/
|
||||
mkdir -p ${JAVA_PATH}/java/app/libs/arm64-v8a/
|
||||
mkdir -p ${JAVA_PATH}/native/libs/arm64-v8a/
|
||||
if [[ "X$SUPPORT_TRAIN" = "Xon" ]]; then
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libmindspore-lite-train.so ${JAVA_PATH}/java/app/libs/arm64-v8a/
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libmindspore-lite-train.so ${JAVA_PATH}/native/libs/arm64-v8a/
|
||||
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libminddata-lite.so ${JAVA_PATH}/java/app/libs/arm64-v8a/
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libminddata-lite.so ${JAVA_PATH}/native/libs/arm64-v8a/
|
||||
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/third_party/libjpeg-turbo/lib/*.so ${JAVA_PATH}/java/app/libs/arm64-v8a/
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/third_party/libjpeg-turbo/lib/*.so ${JAVA_PATH}/native/libs/arm64-v8a/
|
||||
else
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/inference/lib/libmindspore-lite.so ${JAVA_PATH}/java/app/libs/arm64-v8a/
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/inference/lib/libmindspore-lite.so ${JAVA_PATH}/native/libs/arm64-v8a/
|
||||
fi
|
||||
[ -n "${local_pkg_name}" ] && rm -rf ${local_pkg_name}
|
||||
}
|
||||
|
||||
build_lite_java_arm32() {
|
||||
# build mindspore-lite arm32
|
||||
local local_pkg_name=mindspore-lite-${VERSION_STR}-inference-android-aarch32
|
||||
if [[ "X$SUPPORT_TRAIN" = "Xon" ]]; then
|
||||
local_pkg_name=mindspore-lite-${VERSION_STR}-train-android-aarch32
|
||||
fi
|
||||
if [[ "X$INC_BUILD" == "Xoff" ]] || [[ ! -f "${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}.tar.gz" ]]; then
|
||||
build_lite "arm32" "off" ""
|
||||
fi
|
||||
# copy arm32 so
|
||||
cd ${BASEPATH}/mindspore/lite/build/java/
|
||||
[ -n "${local_pkg_name}" ] && rm -rf ${local_pkg_name}
|
||||
tar -zxvf ${local_pkg_name}.tar.gz
|
||||
[ -n "${JAVA_PATH}" ] && rm -rf ${JAVA_PATH}/java/app/libs/armeabi-v7a/
|
||||
mkdir -p ${JAVA_PATH}/java/app/libs/armeabi-v7a/
|
||||
mkdir -p ${JAVA_PATH}/native/libs/armeabi-v7a/
|
||||
if [[ "X$SUPPORT_TRAIN" = "Xon" ]]; then
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libmindspore-lite-train.so ${JAVA_PATH}/java/app/libs/armeabi-v7a/
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libmindspore-lite-train.so ${JAVA_PATH}/native/libs/armeabi-v7a/
|
||||
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libminddata-lite.so ${JAVA_PATH}/java/app/libs/armeabi-v7a/
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libminddata-lite.so ${JAVA_PATH}/native/libs/armeabi-v7a/
|
||||
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/third_party/libjpeg-turbo/lib/*.so ${JAVA_PATH}/java/app/libs/armeabi-v7a/
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/third_party/libjpeg-turbo/lib/*.so ${JAVA_PATH}/native/libs/armeabi-v7a/
|
||||
else
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/inference/lib/libmindspore-lite.so ${JAVA_PATH}/java/app/libs/armeabi-v7a/
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/inference/lib/libmindspore-lite.so ${JAVA_PATH}/native/libs/armeabi-v7a/
|
||||
fi
|
||||
[ -n "${local_pkg_name}" ] && rm -rf ${local_pkg_name}
|
||||
}
|
||||
|
||||
build_lite_java_x86() {
|
||||
# build mindspore-lite x86
|
||||
local inference_or_train=inference
|
||||
if [[ "X$SUPPORT_TRAIN" = "Xon" ]]; then
|
||||
inference_or_train=train
|
||||
local is_train=off
|
||||
if [ -f "${BASEPATH}/output/mindspore-lite-${VERSION_STR}-train-android-aarch64.tar.gz" ]; then
|
||||
inference_or_train=train
|
||||
is_train=on
|
||||
fi
|
||||
local local_pkg_name=mindspore-lite-${VERSION_STR}-${inference_or_train}-linux-x64
|
||||
if [[ "X$INC_BUILD" == "Xoff" ]] || [[ ! -f "${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}.tar.gz" ]]; then
|
||||
build_lite "x86_64" "off" ""
|
||||
fi
|
||||
# copy x86 so
|
||||
cd ${BASEPATH}/mindspore/lite/build/java
|
||||
[ -n "${local_pkg_name}" ] && rm -rf ${local_pkg_name}
|
||||
tar -zxvf ${local_pkg_name}.tar.gz
|
||||
[ -n "${JAVA_PATH}" ] && rm -rf ${JAVA_PATH}/java/linux_x86/libs/
|
||||
mkdir -p ${JAVA_PATH}/java/linux_x86/libs/
|
||||
mkdir -p ${JAVA_PATH}/native/libs/linux_x86/
|
||||
if [[ "X$SUPPORT_TRAIN" = "Xon" ]]; then
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libmindspore-lite-train.so ${JAVA_PATH}/java/linux_x86/libs/
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libmindspore-lite-train.so ${JAVA_PATH}/native/libs/linux_x86/
|
||||
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libminddata-lite.so ${JAVA_PATH}/java/linux_x86/libs/
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/lib/libminddata-lite.so ${JAVA_PATH}/native/libs/linux_x86/
|
||||
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/third_party/libjpeg-turbo/lib/*.so* ${JAVA_PATH}/java/linux_x86/libs/
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/train/third_party/libjpeg-turbo/lib/*.so* ${JAVA_PATH}/native/libs/linux_x86/
|
||||
else
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/inference/lib/libmindspore-lite.so ${JAVA_PATH}/java/linux_x86/libs/
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}/inference/lib/libmindspore-lite.so ${JAVA_PATH}/native/libs/linux_x86/
|
||||
fi
|
||||
[ -n "${local_pkg_name}" ] && rm -rf ${local_pkg_name}
|
||||
}
|
||||
|
||||
build_jni_arm64() {
|
||||
# build jni so
|
||||
local pkg_name=mindspore-lite-${VERSION_STR}-${inference_or_train}-android-aarch64
|
||||
cd "${BASEPATH}/mindspore/lite/build"
|
||||
[ -n "${BASEPATH}" ] && rm -rf java/jni
|
||||
mkdir -pv java/jni
|
||||
|
||||
rm -rf ${pkg_name}
|
||||
tar -zxf ${BASEPATH}/output/${pkg_name}.tar.gz
|
||||
rm -rf ${LITE_JAVA_PATH}/java/app/libs/arm64-v8a/ && mkdir -p ${LITE_JAVA_PATH}/java/app/libs/arm64-v8a/
|
||||
rm -rf ${LITE_JAVA_PATH}/native/libs/arm64-v8a/ && mkdir -p ${LITE_JAVA_PATH}/native/libs/arm64-v8a/
|
||||
cp ./${pkg_name}/${inference_or_train}/lib/*.so* ${LITE_JAVA_PATH}/java/app/libs/arm64-v8a/
|
||||
cp ./${pkg_name}/${inference_or_train}/lib/*.so* ${LITE_JAVA_PATH}/native/libs/arm64-v8a/
|
||||
if [ -f "${BASEPATH}/output/mindspore-lite-${VERSION_STR}-train-android-aarch64.tar.gz" ]; then
|
||||
cp ./${pkg_name}/train/third_party/libjpeg-turbo/lib/*.so* ${LITE_JAVA_PATH}/java/app/libs/arm64-v8a/
|
||||
cp ./${pkg_name}/train/third_party/libjpeg-turbo/lib/*.so* ${LITE_JAVA_PATH}/native/libs/arm64-v8a/
|
||||
fi
|
||||
# build jni so
|
||||
[ -n "${BASEPATH}" ] && rm -rf java/jni && mkdir -pv java/jni
|
||||
cd java/jni
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" -DANDROID_NATIVE_API_LEVEL="19" \
|
||||
-DANDROID_NDK="${ANDROID_NDK}" -DANDROID_ABI="arm64-v8a" -DANDROID_TOOLCHAIN_NAME="aarch64-linux-android-clang" \
|
||||
-DMS_VERSION_MAJOR=${VERSION_MAJOR} -DMS_VERSION_MINOR=${VERSION_MINOR} -DMS_VERSION_REVISION=${VERSION_REVISION} \
|
||||
-DANDROID_STL="c++_static" -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DENABLE_VERBOSE=${ENABLE_VERBOSE} \
|
||||
-DSUPPORT_TRAIN=${SUPPORT_TRAIN} -DPLATFORM_ARM64=on "${JAVA_PATH}/native/"
|
||||
-DANDROID_STL=${MSLITE_ANDROID_STL} -DCMAKE_BUILD_TYPE=${LITE_BUILD_TYPE} -DENABLE_VERBOSE=${ENABLE_VERBOSE} \
|
||||
-DSUPPORT_TRAIN=${is_train} -DPLATFORM_ARM64=on "${LITE_JAVA_PATH}/native/"
|
||||
make -j$THREAD_NUM
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "---------------- mindspore lite: build jni arm64 failed----------------"
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p ${JAVA_PATH}/java/app/libs/arm64-v8a/
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/jni/libmindspore-lite-jni.so ${JAVA_PATH}/java/app/libs/arm64-v8a/
|
||||
mkdir -p ${JAVA_PATH}/native/libs/arm64-v8a/
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/jni/libmindspore-lite-jni.so ${JAVA_PATH}/native/libs/arm64-v8a/
|
||||
cp ./libmindspore-lite-jni.so ${LITE_JAVA_PATH}/java/app/libs/arm64-v8a/
|
||||
cp ./libmindspore-lite-jni.so ${LITE_JAVA_PATH}/native/libs/arm64-v8a/
|
||||
}
|
||||
|
||||
build_jni_arm32() {
|
||||
# build jni so
|
||||
build_lite_arm32_and_jni() {
|
||||
# build arm32
|
||||
build_lite "arm32"
|
||||
# copy arm32 so
|
||||
local inference_or_train=inference
|
||||
local is_train=off
|
||||
if [ -f "${BASEPATH}/output/mindspore-lite-${VERSION_STR}-train-android-aarch32.tar.gz" ]; then
|
||||
inference_or_train=train
|
||||
is_train=on
|
||||
fi
|
||||
local pkg_name=mindspore-lite-${VERSION_STR}-${inference_or_train}-android-aarch32
|
||||
cd "${BASEPATH}/mindspore/lite/build"
|
||||
[ -n "${BASEPATH}" ] && rm -rf java/jni
|
||||
mkdir -pv java/jni
|
||||
|
||||
rm -rf ${pkg_name}
|
||||
tar -zxf ${BASEPATH}/output/${pkg_name}.tar.gz
|
||||
rm -rf ${LITE_JAVA_PATH}/java/app/libs/armeabi-v7a/ && mkdir -pv ${LITE_JAVA_PATH}/java/app/libs/armeabi-v7a/
|
||||
rm -rf ${LITE_JAVA_PATH}/native/libs/armeabi-v7a/ && mkdir -pv ${LITE_JAVA_PATH}/native/libs/armeabi-v7a/
|
||||
cp ./${pkg_name}/${inference_or_train}/lib/*.so* ${LITE_JAVA_PATH}/java/app/libs/armeabi-v7a/
|
||||
cp ./${pkg_name}/${inference_or_train}/lib/*.so* ${LITE_JAVA_PATH}/native/libs/armeabi-v7a/
|
||||
if [ -f "${BASEPATH}/output/mindspore-lite-${VERSION_STR}-train-android-aarch32.tar.gz" ]; then
|
||||
cp ./${pkg_name}/train/third_party/libjpeg-turbo/lib/*.so* ${LITE_JAVA_PATH}/java/app/libs/armeabi-v7a/
|
||||
cp ./${pkg_name}/train/third_party/libjpeg-turbo/lib/*.so* ${LITE_JAVA_PATH}/native/libs/armeabi-v7a/
|
||||
fi
|
||||
|
||||
# build jni so
|
||||
[ -n "${BASEPATH}" ] && rm -rf java/jni && mkdir -pv java/jni
|
||||
cd java/jni
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" -DANDROID_NATIVE_API_LEVEL="19" \
|
||||
-DANDROID_NDK="${ANDROID_NDK}" -DANDROID_ABI="armeabi-v7a" -DANDROID_TOOLCHAIN_NAME="aarch64-linux-android-clang" \
|
||||
-DMS_VERSION_MAJOR=${VERSION_MAJOR} -DMS_VERSION_MINOR=${VERSION_MINOR} -DMS_VERSION_REVISION=${VERSION_REVISION} \
|
||||
-DANDROID_STL="c++_static" -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DENABLE_VERBOSE=${ENABLE_VERBOSE} \
|
||||
-DSUPPORT_TRAIN=${SUPPORT_TRAIN} -DPLATFORM_ARM32=on "${JAVA_PATH}/native"
|
||||
-DANDROID_STL=${MSLITE_ANDROID_STL} -DCMAKE_BUILD_TYPE=${LITE_BUILD_TYPE} -DENABLE_VERBOSE=${ENABLE_VERBOSE} \
|
||||
-DSUPPORT_TRAIN=${is_train} -DPLATFORM_ARM32=on "${LITE_JAVA_PATH}/native"
|
||||
make -j$THREAD_NUM
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "---------------- mindspore lite: build jni arm32 failed----------------"
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p ${JAVA_PATH}/java/app/libs/armeabi-v7a/
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/jni/libmindspore-lite-jni.so ${JAVA_PATH}/java/app/libs/armeabi-v7a/
|
||||
mkdir -p ${JAVA_PATH}/native/libs/armeabi-v7a/
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/jni/libmindspore-lite-jni.so ${JAVA_PATH}/native/libs/armeabi-v7a/
|
||||
}
|
||||
|
||||
build_jni_x86_64() {
|
||||
# build jni so
|
||||
cd "${BASEPATH}/mindspore/lite/build"
|
||||
[ -n "${BASEPATH}" ] && rm -rf java/jni
|
||||
mkdir -pv java/jni
|
||||
cd java/jni
|
||||
cmake -DMS_VERSION_MAJOR=${VERSION_MAJOR} -DMS_VERSION_MINOR=${VERSION_MINOR} -DMS_VERSION_REVISION=${VERSION_REVISION} \
|
||||
-DENABLE_VERBOSE=${ENABLE_VERBOSE} -DSUPPORT_TRAIN=${SUPPORT_TRAIN} "${JAVA_PATH}/native/"
|
||||
make -j$THREAD_NUM
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "---------------- mindspore lite: build jni x86_64 failed----------------"
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p ${JAVA_PATH}/java/linux_x86/libs/
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/jni/libmindspore-lite-jni.so ${JAVA_PATH}/java/linux_x86/libs/
|
||||
mkdir -p ${JAVA_PATH}/native/libs/linux_x86/
|
||||
cp ${BASEPATH}/mindspore/lite/build/java/jni/libmindspore-lite-jni.so ${JAVA_PATH}/native/libs/linux_x86/
|
||||
cp ./libmindspore-lite-jni.so ${LITE_JAVA_PATH}/java/app/libs/armeabi-v7a/
|
||||
cp ./libmindspore-lite-jni.so ${LITE_JAVA_PATH}/native/libs/armeabi-v7a/
|
||||
}
|
||||
|
||||
check_java_home() {
|
||||
if [ "${JAVA_PATH}" ]; then
|
||||
if [ "${JAVA_HOME}" ]; then
|
||||
echo -e "\e[31mJAVA_HOME=$JAVA_HOME \e[0m"
|
||||
else
|
||||
echo -e "\e[31mplease set $JAVA_HOME in environment variable for example: export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 \e[0m"
|
||||
|
@ -879,65 +729,34 @@ check_java_home() {
|
|||
fi
|
||||
}
|
||||
|
||||
build_java() {
|
||||
JAVA_PATH=${BASEPATH}/mindspore/lite/java
|
||||
build_aar() {
|
||||
get_version
|
||||
if [[ "X${INC_BUILD}" == "Xoff" ]]; then
|
||||
[ -n "${BASEPATH}" ] && rm -rf ${BASEPATH}/mindspore/lite/build
|
||||
fi
|
||||
# build common module
|
||||
cd ${JAVA_PATH}/java/common
|
||||
cd ${LITE_JAVA_PATH}/java/common
|
||||
gradle clean
|
||||
gradle build
|
||||
|
||||
# build aar
|
||||
build_lite_java_arm64
|
||||
build_jni_arm64
|
||||
build_lite_java_arm32
|
||||
build_jni_arm32
|
||||
local npu_bak=${MSLITE_ENABLE_NPU}
|
||||
export MSLITE_ENABLE_NPU="off"
|
||||
build_lite_arm64_and_jni
|
||||
build_lite_arm32_and_jni
|
||||
export MSLITE_ENABLE_NPU=${npu_bak}
|
||||
|
||||
mkdir -p ${JAVA_PATH}/java/linux_x86/libs
|
||||
cp ${JAVA_PATH}/java/common/build/libs/mindspore-lite-java-common.jar ${JAVA_PATH}/java/app/libs
|
||||
cd ${JAVA_PATH}/java/app
|
||||
cp ${LITE_JAVA_PATH}/java/common/build/libs/mindspore-lite-java-common.jar ${LITE_JAVA_PATH}/java/app/libs
|
||||
cd ${LITE_JAVA_PATH}/java/app
|
||||
gradle clean
|
||||
gradle build
|
||||
|
||||
gradle publish -PLITE_VERSION=${VERSION_STR}
|
||||
|
||||
cd ${JAVA_PATH}/java/app/build
|
||||
zip -r mindspore-lite-maven-${VERSION_STR}.zip mindspore
|
||||
|
||||
local inference_or_train=inference
|
||||
if [[ "X$SUPPORT_TRAIN" = "Xon" ]]; then
|
||||
inference_or_train=train
|
||||
fi
|
||||
|
||||
# build linux x86 jar
|
||||
check_java_home
|
||||
build_lite_java_x86
|
||||
build_jni_x86_64
|
||||
|
||||
mkdir -p ${JAVA_PATH}/java/linux_x86/libs
|
||||
cp ${JAVA_PATH}/java/common/build/libs/mindspore-lite-java-common.jar ${JAVA_PATH}/java/linux_x86/libs/
|
||||
# build java
|
||||
cd ${JAVA_PATH}/java/linux_x86/
|
||||
gradle clean
|
||||
gradle releaseJar
|
||||
# install and package
|
||||
mkdir -p ${JAVA_PATH}/java/linux_x86/build/lib
|
||||
cp ${JAVA_PATH}/java/linux_x86/libs/*.so* ${JAVA_PATH}/java/linux_x86/build/lib/jar
|
||||
cd ${JAVA_PATH}/java/linux_x86/build/
|
||||
|
||||
local local_pkg_name=mindspore-lite-${VERSION_STR}-${inference_or_train}-linux-x64-jar
|
||||
cp -r ${JAVA_PATH}/java/linux_x86/build/lib ${JAVA_PATH}/java/linux_x86/build/${local_pkg_name}
|
||||
tar czvf ${local_pkg_name}.tar.gz ${local_pkg_name}
|
||||
# copy output
|
||||
cp ${JAVA_PATH}/java/app/build/mindspore-lite-maven-${VERSION_STR}.zip ${BASEPATH}/output
|
||||
cp ${local_pkg_name}.tar.gz ${BASEPATH}/output
|
||||
|
||||
cd ${LITE_JAVA_PATH}/java/app/build
|
||||
[ -n "${BASEPATH}" ] && rm -rf ${BASEPATH}/output/*.tar.gz*
|
||||
zip -r ${BASEPATH}/output/mindspore-lite-maven-${VERSION_STR}.zip mindspore
|
||||
cd ${BASEPATH}/output
|
||||
[ -n "${BASEPATH}" ] && rm -rf ${BASEPATH}/mindspore/lite/build/java/mindspore-lite-${VERSION_STR}-${inference_or_train}-linux-x64
|
||||
exit 0
|
||||
sha256sum mindspore-lite-maven-${VERSION_STR}.zip > mindspore-lite-maven-${VERSION_STR}.zip.sha256
|
||||
}
|
||||
|
||||
make_clean()
|
||||
|
@ -947,27 +766,37 @@ make_clean()
|
|||
cmake --build . --target clean
|
||||
}
|
||||
|
||||
OS=$(uname)
|
||||
echo "---------------- MindSpore: build start ----------------"
|
||||
checkopts "$@"
|
||||
|
||||
if [[ "X$COMPILE_LITE" = "Xon" ]]; then
|
||||
if [[ "X$LITE_LANGUAGE" = "Xjava" ]]; then
|
||||
build_java
|
||||
else
|
||||
LITE_JAVA_PATH=${BASEPATH}/mindspore/lite/java
|
||||
LITE_BUILD_TYPE="Release"
|
||||
if [[ "${DEBUG_MODE}" == "on" ]]; then
|
||||
LITE_BUILD_TYPE="Debug"
|
||||
fi
|
||||
if [[ "X$LITE_ENABLE_AAR" = "Xon" ]]; then
|
||||
build_aar
|
||||
elif [[ "X$LITE_PLATFORM" != "X" ]]; then
|
||||
build_lite
|
||||
else
|
||||
echo "Invalid parameter"
|
||||
fi
|
||||
else
|
||||
build_mindspore
|
||||
fi
|
||||
mkdir -pv "${BUILD_PATH}/package/mindspore/lib"
|
||||
update_submodule
|
||||
|
||||
if [[ "X$ENABLE_MAKE_CLEAN" = "Xon" ]]; then
|
||||
make_clean
|
||||
fi
|
||||
build_mindspore
|
||||
|
||||
if [[ "X$ENABLE_ACL" == "Xon" ]] && [[ "X$ENABLE_D" == "Xoff" ]]; then
|
||||
echo "acl mode, skipping deploy phase"
|
||||
rm -rf ${BASEPATH}/output/_CPack_Packages/
|
||||
else
|
||||
cp -rf ${BUILD_PATH}/package/mindspore/lib ${BUILD_PATH}/../mindspore
|
||||
cp -rf ${BUILD_PATH}/package/mindspore/*.so ${BUILD_PATH}/../mindspore
|
||||
if [[ "X$ENABLE_MAKE_CLEAN" = "Xon" ]]; then
|
||||
make_clean
|
||||
fi
|
||||
if [[ "X$ENABLE_ACL" == "Xon" ]] && [[ "X$ENABLE_D" == "Xoff" ]]; then
|
||||
echo "acl mode, skipping deploy phase"
|
||||
rm -rf ${BASEPATH}/output/_CPack_Packages/
|
||||
else
|
||||
cp -rf ${BUILD_PATH}/package/mindspore/lib ${BUILD_PATH}/../mindspore
|
||||
cp -rf ${BUILD_PATH}/package/mindspore/*.so ${BUILD_PATH}/../mindspore
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "---------------- mindspore: build end ----------------"
|
||||
echo "---------------- MindSpore: build end ----------------"
|
||||
|
|
|
@ -192,7 +192,7 @@ if(PLATFORM_ARM64)
|
|||
install(DIRECTORY ${TOP_DIR}/mindspore/lite/micro/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})
|
||||
if(ENABLE_TOOLS)
|
||||
if(MSLITE_ENABLE_TOOLS)
|
||||
install(TARGETS ${BENCHMARK_NAME} RUNTIME DESTINATION ${BENCHMARK_ROOT_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
endif()
|
||||
elseif(PLATFORM_ARM32)
|
||||
|
@ -237,14 +237,14 @@ elseif(PLATFORM_ARM32)
|
|||
install(DIRECTORY ${TOP_DIR}/mindspore/lite/micro/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})
|
||||
if(ENABLE_TOOLS)
|
||||
if(MSLITE_ENABLE_TOOLS)
|
||||
install(TARGETS ${BENCHMARK_NAME} RUNTIME DESTINATION ${BENCHMARK_ROOT_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
endif()
|
||||
elseif(WIN32)
|
||||
get_filename_component(CXX_DIR ${CMAKE_CXX_COMPILER} PATH)
|
||||
file(GLOB LIB_LIST ${CXX_DIR}/libstdc++-6.dll ${CXX_DIR}/libwinpthread-1.dll
|
||||
${CXX_DIR}/libssp-0.dll ${CXX_DIR}/libgcc_s_*-1.dll)
|
||||
if(ENABLE_CONVERTER)
|
||||
if(MSLITE_ENABLE_CONVERTER)
|
||||
install(TARGETS converter_lite RUNTIME DESTINATION ${CONVERTER_ROOT_DIR}/converter
|
||||
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/registry/ DESTINATION ${CONVERTER_ROOT_DIR}/include/registry
|
||||
|
@ -277,7 +277,7 @@ elseif(WIN32)
|
|||
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
install(TARGETS codegen RUNTIME DESTINATION ${CODEGEN_ROOT_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
endif()
|
||||
if(ENABLE_TOOLS)
|
||||
if(MSLITE_ENABLE_TOOLS)
|
||||
install(TARGETS ${BENCHMARK_NAME} RUNTIME DESTINATION ${BENCHMARK_ROOT_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
endif()
|
||||
install(FILES ${LIB_LIST} DESTINATION ${RUNTIME_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
|
@ -325,7 +325,7 @@ else()
|
|||
install(FILES ${TOP_DIR}/mindspore/lite/tools/obfuscator/lib/linux-x64/libmsdeobfuscator-lite.so
|
||||
DESTINATION ${RUNTIME_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
endif()
|
||||
if(ENABLE_CONVERTER)
|
||||
if(MSLITE_ENABLE_CONVERTER)
|
||||
install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/registry/ DESTINATION ${CONVERTER_ROOT_DIR}/include/registry
|
||||
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
|
||||
install(TARGETS converter_lite RUNTIME DESTINATION ${CONVERTER_ROOT_DIR}/converter
|
||||
|
@ -358,7 +358,7 @@ else()
|
|||
COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
install(TARGETS codegen RUNTIME DESTINATION ${CODEGEN_ROOT_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
endif()
|
||||
if(ENABLE_TOOLS)
|
||||
if(MSLITE_ENABLE_TOOLS)
|
||||
install(TARGETS ${BENCHMARK_NAME} RUNTIME DESTINATION ${BENCHMARK_ROOT_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
install(TARGETS cropper RUNTIME DESTINATION ${CROPPER_ROOT_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
install(FILES ${TOP_DIR}/mindspore/lite/build/tools/cropper/cropper_mapping_cpu.cfg
|
||||
|
|
|
@ -13,33 +13,85 @@ if(PLATFORM_ARM32 AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPI
|
|||
your Clang version:[${CMAKE_CXX_COMPILER_VERSION}] must not be less than 9.0 and please use android nkd r21e!")
|
||||
endif()
|
||||
|
||||
option(MS_VERSION_MAJOR "major version" 0)
|
||||
option(MS_VERSION_MINOR "minor version" 7)
|
||||
option(MS_VERSION_REVISION "revision version" 0)
|
||||
option(CMAKE_BUILD_TYPE "build type" Release)
|
||||
option(COMPILE_LITE "compile for lite" on)
|
||||
option(SUPPORT_TRAIN "if build for on-device train" off)
|
||||
option(PLATFORM_ARM64 "if build device for arm64" off)
|
||||
option(PLATFORM_ARM32 "if build device for arm32" off)
|
||||
option(ENABLE_CONVERTER "if build converter" on)
|
||||
option(ENABLE_FP16 "if build fp16 ops" off)
|
||||
# Options that can be configured through environment variables
|
||||
set(MSLITE_GPU_BACKEND "opencl" CACHE STRING "enable gpu backend, only arm64 support, opencl/vulkan/cuda/off")
|
||||
option(MSLITE_ENABLE_NPU "enable npu, only arm64 support" on)
|
||||
option(MSLITE_ENABLE_TRAIN "enable train" off)
|
||||
option(MSLITE_ENABLE_SSE "enable SSE instruction set" off)
|
||||
option(MSLITE_ENABLE_AVX "enable AVX instruction set" off)
|
||||
option(MSLITE_ENABLE_CONVERTER "enable converter, only x86_64 support" on)
|
||||
option(MSLITE_ENABLE_TOOLS "enable tools" on)
|
||||
option(MSLITE_ENABLE_TESTCASES "enable testcase" off)
|
||||
|
||||
# Option that can be configured through manually
|
||||
option(ENABLE_ARM82_A32 "if build fp16 on platform_arm32" off)
|
||||
option(ENABLE_TOOLS "if build tools" on)
|
||||
option(BUILD_TESTCASES "if build testcase" on)
|
||||
option(SUPPORT_GPU "if support gpu" off)
|
||||
option(GPU_OPENCL "if support gpu opencl" off)
|
||||
option(GPU_VULKAN "if support gpu vulkan" off)
|
||||
option(GPU_CUDA "if support gpu cuda" off)
|
||||
option(SUPPORT_NPU "if support npu" off)
|
||||
option(OFFLINE_COMPILE "if offline compile OpenCL kernel" off)
|
||||
option(BUILD_MINDDATA_EXAMPLE "" on)
|
||||
option(ENABLE_VERBOSE "" off)
|
||||
option(ENABLE_SSE "if x86_64 support SSE instruction set" off)
|
||||
option(ENABLE_AVX "if x86_64 support SSE instruction set" off)
|
||||
option(ENABLE_MINDRT "if support mindrt" on)
|
||||
option(SUBGRAPH_SPLIT "if support sub graph split" off)
|
||||
option(ENABLE_DEBUG "build is debug" off)
|
||||
option(ENABLE_MODEL_OBF "if support model obfuscation" off)
|
||||
option(ENABLE_V0 "support v0 schema" on)
|
||||
|
||||
if(DEFINED ENV{MSLITE_GPU_BACKEND})
|
||||
set(MSLITE_GPU_BACKEND $ENV{MSLITE_GPU_BACKEND})
|
||||
endif()
|
||||
if(DEFINED ENV{MSLITE_ENABLE_NPU})
|
||||
set(MSLITE_ENABLE_NPU $ENV{MSLITE_ENABLE_NPU})
|
||||
endif()
|
||||
if(DEFINED ENV{MSLITE_ENABLE_TRAIN})
|
||||
set(MSLITE_ENABLE_TRAIN $ENV{MSLITE_ENABLE_TRAIN})
|
||||
endif()
|
||||
if(DEFINED ENV{MSLITE_ENABLE_SSE})
|
||||
set(MSLITE_ENABLE_SSE $ENV{MSLITE_ENABLE_SSE})
|
||||
endif()
|
||||
if(DEFINED ENV{MSLITE_ENABLE_AVX})
|
||||
set(MSLITE_ENABLE_AVX $ENV{MSLITE_ENABLE_AVX})
|
||||
endif()
|
||||
if(DEFINED ENV{MSLITE_ENABLE_CONVERTER})
|
||||
set(MSLITE_ENABLE_CONVERTER $ENV{MSLITE_ENABLE_CONVERTER})
|
||||
endif()
|
||||
if(DEFINED ENV{MSLITE_ENABLE_TOOLS})
|
||||
set(MSLITE_ENABLE_TOOLS $ENV{MSLITE_ENABLE_TOOLS})
|
||||
endif()
|
||||
if(DEFINED ENV{MSLITE_ENABLE_TESTCASES})
|
||||
set(MSLITE_ENABLE_TESTCASES $ENV{MSLITE_ENABLE_TESTCASES})
|
||||
endif()
|
||||
|
||||
if(PLATFORM_ARM64 OR PLATFORM_ARM32)
|
||||
set(PLATFORM_ARM "on")
|
||||
set(MSLITE_ENABLE_CONVERTER off)
|
||||
else()
|
||||
set(MSLITE_GPU_BACKEND off)
|
||||
set(MSLITE_ENABLE_NPU off)
|
||||
endif()
|
||||
|
||||
if(MSLITE_ENABLE_TRAIN)
|
||||
set(SUPPORT_TRAIN on)
|
||||
set(BUILD_MINDDATA full)
|
||||
endif()
|
||||
|
||||
if(MSLITE_ENABLE_NPU)
|
||||
set(SUPPORT_NPU on)
|
||||
if(NOT PLATFORM_ARM)
|
||||
message(FATAL_ERROR "NPU only support platform arm.")
|
||||
endif()
|
||||
if(DEFINED ENV{HWHIAI_DDK})
|
||||
message("HWHIAI_DDK=$ENV{HWHIAI_DDK}")
|
||||
else()
|
||||
message(FATAL_ERROR "please set HWHIAI_DDK, example: export HWHIAI_DDK=/root/usr/hwhiai-ddk-100.500.010.010/")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message(STATUS, "MindSpore Lite Build Option:")
|
||||
message(STATUS, "MSLITE_GPU_BACKEND = ${MSLITE_GPU_BACKEND}")
|
||||
message(STATUS, "MSLITE_ENABLE_NPU = ${MSLITE_ENABLE_NPU}")
|
||||
message(STATUS, "MSLITE_ENABLE_TRAIN = ${MSLITE_ENABLE_TRAIN}")
|
||||
message(STATUS, "MSLITE_ENABLE_SSE = ${MSLITE_ENABLE_SSE}")
|
||||
message(STATUS, "MSLITE_ENABLE_AVX = ${MSLITE_ENABLE_AVX}")
|
||||
message(STATUS, "MSLITE_ENABLE_CONVERTER = ${MSLITE_ENABLE_CONVERTER}")
|
||||
message(STATUS, "MSLITE_ENABLE_TOOLS = ${MSLITE_ENABLE_TOOLS}")
|
||||
message(STATUS, "MSLITE_ENABLE_TESTCASES = ${MSLITE_ENABLE_TESTCASES}")
|
||||
|
||||
if(ENABLE_ASAN)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize-recover=address -fno-omit-frame-pointer")
|
||||
|
@ -51,7 +103,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
|
|||
set(BUILD_MINDDATA "lite_cv" CACHE STRING "off, lite, lite_cv, wrapper or full")
|
||||
|
||||
if(PLATFORM_ARM64 OR PLATFORM_ARM32)
|
||||
set(PLATFORM_ARM "on")
|
||||
set(ENABLE_CONVERTER off)
|
||||
#set for cross-compiling toolchain
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
|
||||
|
@ -119,14 +170,15 @@ include(${TOP_DIR}/cmake/utils.cmake)
|
|||
include(${TOP_DIR}/cmake/dependency_utils.cmake)
|
||||
include(${TOP_DIR}/cmake/dependency_securec.cmake)
|
||||
include(${TOP_DIR}/cmake/external_libs/flatbuffers.cmake)
|
||||
if(SUPPORT_GPU STREQUAL opencl)
|
||||
if(MSLITE_GPU_BACKEND STREQUAL opencl)
|
||||
include(${TOP_DIR}/cmake/external_libs/opencl.cmake)
|
||||
endif()
|
||||
if(SUPPORT_GPU STREQUAL vulkan)
|
||||
if(MSLITE_GPU_BACKEND STREQUAL vulkan)
|
||||
include(${TOP_DIR}/cmake/external_libs/vulkan.cmake)
|
||||
endif()
|
||||
|
||||
if(ENABLE_CONVERTER OR BUILD_MINDDATA STREQUAL "full" OR BUILD_MINDDATA STREQUAL "wrapper" OR ENABLE_TOOLS)
|
||||
if(MSLITE_ENABLE_CONVERTER OR BUILD_MINDDATA STREQUAL "full" OR BUILD_MINDDATA STREQUAL "wrapper" OR
|
||||
MSLITE_ENABLE_TOOLS)
|
||||
include(${TOP_DIR}/cmake/external_libs/json.cmake)
|
||||
endif()
|
||||
|
||||
|
@ -173,7 +225,7 @@ if(ENABLE_FP16)
|
|||
add_compile_definitions(ENABLE_ARM82_A32)
|
||||
endif()
|
||||
endif()
|
||||
if(SUPPORT_GPU STREQUAL opencl)
|
||||
if(MSLITE_GPU_BACKEND STREQUAL opencl)
|
||||
add_definitions(-DGPU_OPENCL)
|
||||
gene_opencl(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_definitions(-DUSE_OPENCL_WRAPPER)
|
||||
|
@ -188,13 +240,13 @@ if(SUPPORT_GPU STREQUAL opencl)
|
|||
include_directories(${CMAKE_BINARY_DIR}/_deps/opencl-headers-src/)
|
||||
include_directories(${CMAKE_BINARY_DIR}/_deps/opencl-clhpp-src/include)
|
||||
endif()
|
||||
if(SUPPORT_GPU STREQUAL vulkan)
|
||||
if(MSLITE_GPU_BACKEND STREQUAL vulkan)
|
||||
add_definitions(-DGPU_VULKAN)
|
||||
add_definitions(-DVK_NO_PROTOTYPES)
|
||||
add_compile_definitions(SUPPORT_GPU)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/build/_deps/vulkan-headers-src/include)
|
||||
endif()
|
||||
if(SUPPORT_GPU STREQUAL cuda)
|
||||
if(MSLITE_GPU_BACKEND STREQUAL cuda)
|
||||
add_definitions(-DGPU_CUDA)
|
||||
add_compile_definitions(SUPPORT_GPU)
|
||||
endif()
|
||||
|
@ -226,7 +278,7 @@ if(ENABLE_MODEL_OBF)
|
|||
set(OBF_LIBS libmsdeobfuscator-lite.so)
|
||||
endif()
|
||||
|
||||
if(ENABLE_CONVERTER)
|
||||
if(MSLITE_ENABLE_CONVERTER)
|
||||
if(PLATFORM_ARM)
|
||||
MESSAGE(FATAL_ERROR "Cannot build converter in arm platform")
|
||||
endif()
|
||||
|
@ -251,16 +303,17 @@ if(PLATFORM_ARM64)
|
|||
endif()
|
||||
|
||||
if(NOT PLATFORM_ARM32 AND NOT PLATFORM_ARM64)
|
||||
if("${X86_64_SIMD}" STREQUAL "sse")
|
||||
add_compile_definitions(ENABLE_SSE)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
|
||||
endif()
|
||||
if("${X86_64_SIMD}" STREQUAL "avx")
|
||||
if(MSLITE_ENABLE_AVX)
|
||||
set(X86_64_SIMD "avx")
|
||||
add_compile_definitions(ENABLE_SSE)
|
||||
add_compile_definitions(ENABLE_AVX)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx -mfma")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx -mfma")
|
||||
elseif(MSLITE_ENABLE_SSE)
|
||||
set(X86_64_SIMD "sse")
|
||||
add_compile_definitions(ENABLE_SSE)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -280,7 +333,7 @@ endif()
|
|||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
add_subdirectory(${CCSRC_DIR}/backend/kernel_compiler/cpu/nnacl build)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/micro/coder)
|
||||
if(NOT APPLE AND ENABLE_TOOLS)
|
||||
if(NOT APPLE AND MSLITE_ENABLE_TOOLS)
|
||||
if(SUPPORT_TRAIN)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/benchmark_train)
|
||||
else()
|
||||
|
@ -288,7 +341,7 @@ if(NOT APPLE AND ENABLE_TOOLS)
|
|||
endif()
|
||||
endif()
|
||||
if(NOT WIN32)
|
||||
if(ENABLE_TOOLS)
|
||||
if(MSLITE_ENABLE_TOOLS)
|
||||
if(NOT PLATFORM_ARM32 AND NOT PLATFORM_ARM64)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/cropper)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/schema_gen)
|
||||
|
@ -296,7 +349,7 @@ if(NOT WIN32)
|
|||
add_dependencies(fbs_inner_src gen_ops)
|
||||
endif()
|
||||
endif()
|
||||
if(BUILD_TESTCASES)
|
||||
if(MSLITE_ENABLE_TESTCASES)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test)
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
cmake_minimum_required(VERSION 3.14)
|
||||
project(micro)
|
||||
|
||||
option(BUILD_TESTCASES "if build testcase" on)
|
||||
option(MSLITE_ENABLE_TESTCASES "if build testcase" off)
|
||||
option(PLATFORM_ARM32 "build operator for android arm 32" off)
|
||||
option(PLATFORM_ARM64 "build operator for android arm 64" off)
|
||||
|
||||
|
@ -51,6 +51,6 @@ if(NOT WIN32)
|
|||
endif()
|
||||
|
||||
add_subdirectory(coder)
|
||||
if(BUILD_TESTCASES AND NOT PLATFORM_ARM64 AND NOT PLATFORM_ARM32)
|
||||
if(MSLITE_ENABLE_TESTCASES AND NOT PLATFORM_ARM64 AND NOT PLATFORM_ARM32)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
|
|
@ -6,7 +6,7 @@ set(3RD_DIR ${TOP_DIR}/third_party)
|
|||
set(LITE_DIR ${TOP_DIR}/mindspore/lite)
|
||||
set(MICRO_DIR ${LITE_DIR}/micro)
|
||||
|
||||
if(ENABLE_CONVERTER)
|
||||
if(MSLITE_ENABLE_CONVERTER)
|
||||
set(CODEGEN_PATH ${CMAKE_BINARY_DIR}/micro/coder/codegen)
|
||||
else()
|
||||
set(CODEGEN_PATH ${CMAKE_BINARY_DIR}/coder/codegen)
|
||||
|
@ -27,7 +27,7 @@ include(${MICRO_DIR}/cmake/file_list.cmake)
|
|||
include(${MICRO_DIR}/cmake/package_wrapper.cmake)
|
||||
add_subdirectory(wrapper)
|
||||
|
||||
if(ENABLE_CONVERTER)
|
||||
if(MSLITE_ENABLE_CONVERTER)
|
||||
add_executable(codegen main.cc ${FILE_SET})
|
||||
add_dependencies(codegen fbs_src)
|
||||
add_dependencies(codegen fbs_inner_src)
|
||||
|
|
|
@ -78,7 +78,8 @@ set(LITE_SRC
|
|||
|
||||
file(GLOB KERNEL_REG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/registry/*.cc)
|
||||
set(LITE_SRC ${LITE_SRC} ${KERNEL_REG_SRC})
|
||||
if(SUPPORT_GPU STREQUAL opencl)
|
||||
|
||||
if(MSLITE_GPU_BACKEND STREQUAL opencl)
|
||||
file(GLOB_RECURSE OPENCL_RUNTIME_SRC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/runtime/gpu/opencl/*.cc
|
||||
)
|
||||
|
@ -88,7 +89,7 @@ if(SUPPORT_GPU STREQUAL opencl)
|
|||
)
|
||||
endif()
|
||||
|
||||
if(SUPPORT_GPU STREQUAL vulkan)
|
||||
if(MSLITE_GPU_BACKEND STREQUAL vulkan)
|
||||
file(GLOB VULKAN_RUNTIME_SRC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/runtime/gpu/*.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/runtime/gpu/vulkan/*.cc
|
||||
|
@ -99,7 +100,7 @@ if(SUPPORT_GPU STREQUAL vulkan)
|
|||
)
|
||||
endif()
|
||||
|
||||
if(SUPPORT_GPU STREQUAL cuda)
|
||||
if(MSLITE_GPU_BACKEND STREQUAL cuda)
|
||||
file(GLOB CUDA_RUNTIME_SRC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/runtime/gpu/*.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/runtime/gpu/cuda/*.cc
|
||||
|
@ -167,14 +168,14 @@ if(ENABLE_MINDRT)
|
|||
target_link_libraries(mindspore-lite_static mindrt_mid)
|
||||
endif()
|
||||
|
||||
if(SUPPORT_GPU STREQUAL opencl)
|
||||
if(MSLITE_GPU_BACKEND STREQUAL opencl)
|
||||
add_subdirectory(runtime/kernel/opencl)
|
||||
target_link_libraries(mindspore-lite cpu_kernel_mid opencl_kernel_mid nnacl_mid cpu_ops_mid)
|
||||
target_link_libraries(mindspore-lite_static cpu_kernel_mid opencl_kernel_mid nnacl_mid cpu_ops_mid)
|
||||
elseif(SUPPORT_GPU STREQUAL cuda)
|
||||
add_subdirectory(runtime/kernel/cuda)
|
||||
target_link_libraries(mindspore-lite cpu_kernel_mid cuda_kernel_mid nnacl_mid cpu_ops_mid)
|
||||
target_link_libraries(mindspore-lite_static cpu_kernel_mid cuda_kernel_mid nnacl_mid cpu_ops_mid)
|
||||
elseif(MSLITE_GPU_BACKEND STREQUAL cuda)
|
||||
add_subdirectory(runtime/kernel/cuda)
|
||||
target_link_libraries(mindspore-lite cpu_kernel_mid cuda_kernel_mid nnacl_mid cpu_ops_mid)
|
||||
target_link_libraries(mindspore-lite_static cpu_kernel_mid cuda_kernel_mid nnacl_mid cpu_ops_mid)
|
||||
else()
|
||||
target_link_libraries(mindspore-lite cpu_kernel_mid nnacl_mid cpu_ops_mid)
|
||||
target_link_libraries(mindspore-lite_static cpu_kernel_mid nnacl_mid cpu_ops_mid)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
if(${SUPPORT_GPU} STREQUAL opencl)
|
||||
if(MSLITE_GPU_BACKEND STREQUAL opencl)
|
||||
file(GLOB_RECURSE OPENCL_KERNEL_SRC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/*.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel/*.cc
|
||||
|
|
|
@ -11,7 +11,7 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/external_libs/gtest.cmake)
|
|||
STRING(REPLACE " -fvisibility=hidden " " -fvisibility=default " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
STRING(REPLACE " -fvisibility=hidden " " -fvisibility=default " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
if(ENABLE_CONVERTER)
|
||||
if(MSLITE_ENABLE_CONVERTER)
|
||||
set(CCSRC_SRC
|
||||
## ccsrc
|
||||
${CCSRC_DIR}/backend/optimizer/common/pattern_engine.cc
|
||||
|
@ -40,7 +40,7 @@ if(SUPPORT_TRAIN)
|
|||
endif()
|
||||
|
||||
### gpu kernel
|
||||
if(SUPPORT_GPU STREQUAL opencl)
|
||||
if(MSLITE_GPU_BACKEND STREQUAL opencl)
|
||||
file(GLOB GPU_KERNEL_OP_SRC
|
||||
${LITE_DIR}/src/runtime/kernel/opencl/kernel/*.cc
|
||||
)
|
||||
|
@ -53,7 +53,7 @@ if(SUPPORT_GPU STREQUAL opencl)
|
|||
${LITE_DIR}/src/runtime/kernel/opencl/utils.cc
|
||||
)
|
||||
endif()
|
||||
if(SUPPORT_GPU STREQUAL vulkan)
|
||||
if(MSLITE_GPU_BACKEND STREQUAL vulkan)
|
||||
file(GLOB GPU_KERNEL_OP_SRC
|
||||
${LITE_DIR}/src/runtime/kernel/vulkan/kernel/*.cc
|
||||
)
|
||||
|
@ -67,7 +67,7 @@ endif()
|
|||
add_definitions(-DENABLE_V0)
|
||||
|
||||
file(GLOB_RECURSE OPS_SRC ${LITE_DIR}/src/ops/*.cc)
|
||||
if(ENABLE_CONVERTER)
|
||||
if(MSLITE_ENABLE_CONVERTER)
|
||||
set(OPS_SRC ${OPS_SRC})
|
||||
endif()
|
||||
set(TEST_LITE_SRC
|
||||
|
@ -120,7 +120,7 @@ if(ENABLE_TOOLS)
|
|||
endif()
|
||||
|
||||
### gpu runtime
|
||||
if(SUPPORT_GPU STREQUAL opencl)
|
||||
if(MSLITE_GPU_BACKEND STREQUAL opencl)
|
||||
include_directories(${CMAKE_BINARY_DIR}/_deps/opencl-headers-src)
|
||||
include_directories(${CMAKE_BINARY_DIR}/_deps/opencl-clhpp-src/include)
|
||||
file(GLOB_RECURSE OPENCL_RUNTIME_SRC
|
||||
|
@ -131,7 +131,7 @@ if(SUPPORT_GPU STREQUAL opencl)
|
|||
${OPENCL_RUNTIME_SRC}
|
||||
)
|
||||
endif()
|
||||
if(SUPPORT_GPU STREQUAL vulkan)
|
||||
if(MSLITE_GPU_BACKEND STREQUAL vulkan)
|
||||
include_directories(${LITE_DIR}/build/_deps/vulkan-headers-src/include)
|
||||
file(GLOB VULKAN_RUNTIME_SRC
|
||||
${LITE_DIR}/src/runtime/gpu/*.cc
|
||||
|
@ -166,7 +166,7 @@ endif()
|
|||
|
||||
|
||||
### converter
|
||||
if(ENABLE_CONVERTER)
|
||||
if(MSLITE_ENABLE_CONVERTER)
|
||||
add_definitions(-DPRIMITIVE_WRITEABLE)
|
||||
add_definitions(-DUSE_GLOG)
|
||||
file(GLOB_RECURSE TEST_CASE_TFLITE_PARSERS_SRC
|
||||
|
@ -304,7 +304,7 @@ set(TEST_SRC
|
|||
${TEST_DIR}/ut/src/lite_mindrt_test.cc
|
||||
)
|
||||
|
||||
if(ENABLE_CONVERTER)
|
||||
if(MSLITE_ENABLE_CONVERTER)
|
||||
set(TEST_SRC
|
||||
${TEST_SRC}
|
||||
${TEST_DIR}/st/converter_test.cc
|
||||
|
@ -332,7 +332,7 @@ else()
|
|||
)
|
||||
endif()
|
||||
|
||||
if(SUPPORT_GPU STREQUAL opencl)
|
||||
if(MSLITE_GPU_BACKEND STREQUAL opencl)
|
||||
file(GLOB_RECURSE TEST_CASE_KERNEL_GPU_SRC
|
||||
${TEST_DIR}/ut/src/runtime/kernel/opencl/*.cc
|
||||
)
|
||||
|
@ -382,9 +382,9 @@ endif()
|
|||
|
||||
if(SUPPORT_NPU)
|
||||
include_directories(${DDK_PATH})
|
||||
target_link_libraries(lite-test npu_kernel_mid)
|
||||
target_link_libraries(lite-test npu_kernel_mid c++_shared)
|
||||
endif()
|
||||
if(ENABLE_CONVERTER)
|
||||
if(MSLITE_ENABLE_CONVERTER)
|
||||
add_dependencies(lite-test fbs_inner_src)
|
||||
target_link_libraries(lite-test
|
||||
anf_exporter_mid
|
||||
|
|
|
@ -1215,11 +1215,11 @@ function Run_x86_avx() {
|
|||
# Run on x86 java platform:
|
||||
function Run_x86_java() {
|
||||
cd ${x86_java_path} || exit 1
|
||||
tar -zxf mindspore-lite-${version}-inference-linux-x64-jar.tar.gz || exit 1
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${x86_java_path}/mindspore-lite-${version}-inference-linux-x64-jar/jar
|
||||
tar -zxf mindspore-lite-${version}-inference-linux-x64.tar.gz || exit 1
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${x86_java_path}/mindspore-lite-${version}-inference-linux-x64/inference/lib
|
||||
# compile benchmark
|
||||
echo "javac -cp ${x86_java_path}/mindspore-lite-${version}-inference-linux-x64-jar/jar/mindspore-lite-java.jar ${basepath}/java/src/main/java/Benchmark.java -d ."
|
||||
javac -cp ${x86_java_path}/mindspore-lite-${version}-inference-linux-x64-jar/jar/mindspore-lite-java.jar ${basepath}/java/src/main/java/Benchmark.java -d .
|
||||
echo "javac -cp ${x86_java_path}/mindspore-lite-${version}-inference-linux-x64/inference/lib/mindspore-lite-java.jar ${basepath}/java/src/main/java/Benchmark.java -d ."
|
||||
javac -cp ${x86_java_path}/mindspore-lite-${version}-inference-linux-x64/inference/lib/mindspore-lite-java.jar ${basepath}/java/src/main/java/Benchmark.java -d .
|
||||
|
||||
count=0
|
||||
# Run tflite converted models:
|
||||
|
@ -1234,8 +1234,8 @@ function Run_x86_java() {
|
|||
continue
|
||||
fi
|
||||
echo ${model_name} >> "${run_x86_java_log_file}"
|
||||
echo "java -classpath .:${x86_java_path}/mindspore-lite-${version}-inference-linux-x64-jar/jar/mindspore-lite-java.jar Benchmark ${ms_models_path}/${model_name}.ms '${models_path}'/input_output/input/${model_name}.ms.bin '${models_path}'/input_output/output/${model_name}.ms.out 1" >> "${run_x86_java_log_file}"
|
||||
java -classpath .:${x86_java_path}/mindspore-lite-${version}-inference-linux-x64-jar/jar/mindspore-lite-java.jar Benchmark ${ms_models_path}/${model_name}.ms ${models_path}/input_output/input/${model_name}.ms.bin ${models_path}/input_output/output/${model_name}.ms.out 1
|
||||
echo "java -classpath .:${x86_java_path}/mindspore-lite-${version}-inference-linux-x64/inference/lib/mindspore-lite-java.jar Benchmark ${ms_models_path}/${model_name}.ms '${models_path}'/input_output/input/${model_name}.ms.bin '${models_path}'/input_output/output/${model_name}.ms.out 1" >> "${run_x86_java_log_file}"
|
||||
java -classpath .:${x86_java_path}/mindspore-lite-${version}-inference-linux-x64/inference/lib/mindspore-lite-java.jar Benchmark ${ms_models_path}/${model_name}.ms ${models_path}/input_output/input/${model_name}.ms.bin ${models_path}/input_output/output/${model_name}.ms.out 1
|
||||
if [ $? = 0 ]; then
|
||||
run_result='x86_java: '${model_name}' pass'; echo ${run_result} >> ${run_benchmark_result_file}
|
||||
else
|
||||
|
@ -1441,7 +1441,7 @@ fi
|
|||
if [[ $backend == "all" || $backend == "x86-all" || $backend == "x86-java" ]]; then
|
||||
# Run on x86-java
|
||||
echo "start Run x86 java ..."
|
||||
x86_java_path=${release_path}/aar/avx
|
||||
x86_java_path=${release_path}/ubuntu_x86/avx
|
||||
Run_x86_java &
|
||||
Run_x86_java_PID=$!
|
||||
sleep 1
|
||||
|
|
|
@ -13,7 +13,11 @@ add_executable(benchmark
|
|||
add_dependencies(benchmark fbs_src)
|
||||
|
||||
if(PLATFORM_ARM32 OR PLATFORM_ARM64)
|
||||
target_link_libraries(benchmark mindspore-lite mindspore::json)
|
||||
if(SUPPORT_NPU AND ANDROID_STL STREQUAL "c++_static")
|
||||
target_link_libraries(benchmark mindspore-lite mindspore::json c++_shared)
|
||||
else()
|
||||
target_link_libraries(benchmark mindspore-lite mindspore::json)
|
||||
endif()
|
||||
else()
|
||||
target_link_libraries(benchmark mindspore-lite mindspore::json pthread)
|
||||
endif()
|
||||
|
|
|
@ -16,7 +16,11 @@ else()
|
|||
endif()
|
||||
|
||||
if(PLATFORM_ARM32 OR PLATFORM_ARM64)
|
||||
target_link_libraries(benchmark_train mindspore-lite minddata-lite)
|
||||
if(SUPPORT_NPU AND ANDROID_STL STREQUAL "c++_static")
|
||||
target_link_libraries(benchmark_train mindspore-lite minddata-lite c++_shared)
|
||||
else()
|
||||
target_link_libraries(benchmark_train mindspore-lite minddata-lite)
|
||||
endif()
|
||||
else()
|
||||
if(WIN32)
|
||||
target_link_libraries(benchmark_train mindspore-lite_static pthread cpu_kernel_mid nnacl_mid minddata-lite)
|
||||
|
|
Loading…
Reference in New Issue