2020-03-27 14:49:12 +08:00
|
|
|
#!/bin/bash
|
|
|
|
# Copyright 2019 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.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
# ============================================================================
|
|
|
|
|
|
|
|
set -e
|
|
|
|
BASEPATH=$(cd "$(dirname $0)"; pwd)
|
|
|
|
CUDA_PATH=""
|
|
|
|
export BUILD_PATH="${BASEPATH}/build/"
|
|
|
|
# print usage message
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
echo "Usage:"
|
2020-12-30 09:40:31 +08:00
|
|
|
echo "bash build.sh [-d] [-r] [-v] [-c on|off] [-t ut|st] [-g on|off] [-h] [-b ge] [-m infer|train] \\"
|
2021-04-20 10:39:09 +08:00
|
|
|
echo " [-a on|off] [-p on|off] [-i] [-R] [-D on|off] [-j[n]] [-e gpu|ascend|cpu|npu] \\"
|
2021-05-23 11:42:33 +08:00
|
|
|
echo " [-P on|off] [-z [on|off]] [-M on|off] [-V 10.1|11.1|310|910] [-I arm64|arm32|x86_64] [-K] \\"
|
2021-02-28 17:03:20 +08:00
|
|
|
echo " [-B on|off] [-E] [-l on|off] [-n full|lite|off] [-T on|off] [-H on|off] \\"
|
2020-11-03 14:06:36 +08:00
|
|
|
echo " [-A [cpp|java|object-c] [-C on|off] [-o on|off] [-S on|off] [-k on|off] [-W sse|neon|avx|off] \\"
|
2021-04-25 15:39:28 +08:00
|
|
|
echo " [-L Tensor-RT path] \\"
|
2020-03-27 14:49:12 +08:00
|
|
|
echo ""
|
|
|
|
echo "Options:"
|
|
|
|
echo " -d Debug mode"
|
|
|
|
echo " -r Release mode, default mode"
|
|
|
|
echo " -v Display build command"
|
2020-04-22 11:50:24 +08:00
|
|
|
echo " -c Enable code coverage, default off"
|
2020-12-30 09:40:31 +08:00
|
|
|
echo " -t Run testcases, default off"
|
2020-03-27 14:49:12 +08:00
|
|
|
echo " -g Use glog to output log, default on"
|
|
|
|
echo " -h Print usage"
|
|
|
|
echo " -b Select other backend, available: \\"
|
2020-04-22 11:50:24 +08:00
|
|
|
echo " ge:graph engine"
|
|
|
|
echo " -m Select graph engine backend mode, available: infer, train, default is infer"
|
2020-03-27 14:49:12 +08:00
|
|
|
echo " -a Enable ASAN, default off"
|
2020-04-22 11:50:24 +08:00
|
|
|
echo " -p Enable pipeline profile, print to stdout, default off"
|
|
|
|
echo " -R Enable pipeline profile, record to json, default off"
|
2020-03-27 14:49:12 +08:00
|
|
|
echo " -i Enable increment building, default off"
|
|
|
|
echo " -j[n] Set the threads when building (Default: -j8)"
|
2020-12-07 18:50:07 +08:00
|
|
|
echo " -e Use cpu, gpu, npu or ascend"
|
2020-03-27 14:49:12 +08:00
|
|
|
echo " -P Enable dump anf graph to file in ProtoBuffer format, default on"
|
|
|
|
echo " -D Enable dumping of function graph ir, default on"
|
2020-04-06 11:22:47 +08:00
|
|
|
echo " -z Compile dataset & mindrecord, default on"
|
2020-11-26 15:50:46 +08:00
|
|
|
echo " -n Compile minddata with mindspore lite, available: off, lite, full, lite_cv, full mode in lite train and lite_cv, wrapper mode in lite predict"
|
2020-06-15 16:33:40 +08:00
|
|
|
echo " -M Enable MPI and NCCL for GPU training, gpu default on"
|
2020-12-04 15:58:59 +08:00
|
|
|
echo " -V Specify the device version, if -e gpu, default CUDA 10.1, if -e ascend, default Ascend 910"
|
2020-09-28 10:57:29 +08:00
|
|
|
echo " -I Enable compiling mindspore lite for arm64, arm32 or x86_64, default disable mindspore lite compilation"
|
2020-06-28 17:52:23 +08:00
|
|
|
echo " -K Compile with AKG, default on"
|
2020-09-10 06:55:10 +08:00
|
|
|
echo " -B Enable debugger, default on"
|
2020-06-08 15:31:37 +08:00
|
|
|
echo " -E Enable IBVERBS for parameter server, default off"
|
2020-07-11 04:26:00 +08:00
|
|
|
echo " -l Compile with python dependency, default on"
|
2020-09-28 10:57:29 +08:00
|
|
|
echo " -A Language used by mindspore lite, default cpp"
|
2020-09-14 09:28:36 +08:00
|
|
|
echo " -T Enable on-device training, default off"
|
2020-09-28 10:57:29 +08:00
|
|
|
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"
|
2020-10-14 19:35:13 +08:00
|
|
|
echo " -S Enable enable download cmake compile dependency from gitee , default off"
|
2020-10-26 09:39:49 +08:00
|
|
|
echo " -k Enable make clean, clean up compilation generated cache "
|
2020-11-03 14:06:36 +08:00
|
|
|
echo " -W Enable x86_64 SSE or AVX instruction set, use [sse|avx|neon|off], default off"
|
2021-02-28 17:03:20 +08:00
|
|
|
echo " -H Enable hidden"
|
2021-04-25 15:39:28 +08:00
|
|
|
echo " -L Link and specify Tensor-RT library path, default disable Tensor-RT lib linking"
|
2020-03-27 14:49:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# check value of input is 'on' or 'off'
|
|
|
|
# usage: check_on_off arg_value arg_name
|
|
|
|
check_on_off()
|
|
|
|
{
|
|
|
|
if [[ "X$1" != "Xon" && "X$1" != "Xoff" ]]; then
|
|
|
|
echo "Invalid value $1 for option -$2"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# check and set options
|
|
|
|
checkopts()
|
|
|
|
{
|
|
|
|
# Init default values of build options
|
|
|
|
THREAD_NUM=8
|
|
|
|
DEBUG_MODE="off"
|
|
|
|
VERBOSE=""
|
|
|
|
ENABLE_COVERAGE="off"
|
|
|
|
RUN_TESTCASES="off"
|
2020-12-30 09:40:31 +08:00
|
|
|
RUN_CPP_ST_TESTS="off"
|
2020-03-27 14:49:12 +08:00
|
|
|
ENABLE_BACKEND=""
|
|
|
|
TRAIN_MODE="INFER"
|
|
|
|
ENABLE_ASAN="off"
|
|
|
|
ENABLE_PROFILE="off"
|
|
|
|
INC_BUILD="off"
|
|
|
|
ENABLE_TIMELINE="off"
|
|
|
|
ENABLE_DUMP2PROTO="on"
|
|
|
|
ENABLE_DUMP_IR="on"
|
2020-04-06 11:22:47 +08:00
|
|
|
COMPILE_MINDDATA="on"
|
2020-09-24 20:27:32 +08:00
|
|
|
COMPILE_MINDDATA_LITE="lite_cv"
|
2020-06-04 17:20:47 +08:00
|
|
|
ENABLE_MPI="off"
|
2020-06-23 22:12:37 +08:00
|
|
|
CUDA_VERSION="10.1"
|
2020-07-29 02:16:33 +08:00
|
|
|
COMPILE_LITE="off"
|
|
|
|
LITE_PLATFORM=""
|
|
|
|
SUPPORT_TRAIN="off"
|
2020-03-27 14:49:12 +08:00
|
|
|
USE_GLOG="on"
|
2020-06-22 10:26:26 +08:00
|
|
|
ENABLE_AKG="on"
|
2020-07-21 11:19:00 +08:00
|
|
|
ENABLE_ACL="off"
|
2021-05-26 11:31:02 +08:00
|
|
|
ENABLE_D="off"
|
2020-09-10 06:55:10 +08:00
|
|
|
ENABLE_DEBUGGER="on"
|
2020-06-08 15:31:37 +08:00
|
|
|
ENABLE_IBVERBS="off"
|
2020-07-11 04:26:00 +08:00
|
|
|
ENABLE_PYTHON="on"
|
2020-08-05 09:29:27 +08:00
|
|
|
ENABLE_GPU="off"
|
2020-09-19 18:44:46 +08:00
|
|
|
ENABLE_VERBOSE="off"
|
2020-09-28 10:57:29 +08:00
|
|
|
ENABLE_TOOLS="on"
|
|
|
|
ENABLE_CONVERTER="on"
|
|
|
|
LITE_LANGUAGE="cpp"
|
2020-10-14 19:35:13 +08:00
|
|
|
ENABLE_GITEE="off"
|
2020-10-24 15:07:28 +08:00
|
|
|
ANDROID_STL="c++_shared"
|
2020-10-26 09:39:49 +08:00
|
|
|
ENABLE_MAKE_CLEAN="off"
|
2020-11-03 14:06:36 +08:00
|
|
|
X86_64_SIMD="off"
|
2021-04-26 19:35:06 +08:00
|
|
|
ARM_SIMD="off"
|
2020-12-04 15:58:59 +08:00
|
|
|
DEVICE_VERSION=""
|
|
|
|
DEVICE=""
|
2020-12-07 18:50:07 +08:00
|
|
|
ENABLE_NPU="off"
|
2021-02-28 17:03:20 +08:00
|
|
|
ENABLE_HIDDEN="on"
|
2021-02-24 17:24:12 +08:00
|
|
|
LITE_ENABLE_GPU=""
|
2021-04-25 15:39:28 +08:00
|
|
|
TENSORRT_HOME=""
|
2020-03-27 14:49:12 +08:00
|
|
|
# Process the options
|
2021-04-25 15:39:28 +08:00
|
|
|
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
|
2020-03-27 14:49:12 +08:00
|
|
|
do
|
2021-04-25 15:39:28 +08:00
|
|
|
CASE_SENSIVE_ARG=${OPTARG}
|
2020-03-27 14:49:12 +08:00
|
|
|
OPTARG=$(echo ${OPTARG} | tr '[A-Z]' '[a-z]')
|
|
|
|
case "${opt}" in
|
|
|
|
d)
|
|
|
|
DEBUG_MODE="on"
|
|
|
|
;;
|
2020-08-05 09:29:27 +08:00
|
|
|
n)
|
2020-11-26 15:50:46 +08:00
|
|
|
if [[ "X$OPTARG" == "Xoff" || "X$OPTARG" == "Xlite" || "X$OPTARG" == "Xfull" || "X$OPTARG" == "Xlite_cv" || "X$OPTARG" == "Xwrapper" ]]; then
|
2020-08-22 03:49:53 +08:00
|
|
|
COMPILE_MINDDATA_LITE="$OPTARG"
|
|
|
|
else
|
|
|
|
echo "Invalid value ${OPTARG} for option -n"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-08-05 09:29:27 +08:00
|
|
|
;;
|
2020-03-27 14:49:12 +08:00
|
|
|
r)
|
|
|
|
DEBUG_MODE="off"
|
|
|
|
;;
|
|
|
|
v)
|
2020-09-19 18:44:46 +08:00
|
|
|
ENABLE_VERBOSE="on"
|
2020-03-27 14:49:12 +08:00
|
|
|
VERBOSE="VERBOSE=1"
|
|
|
|
;;
|
|
|
|
j)
|
|
|
|
THREAD_NUM=$OPTARG
|
|
|
|
;;
|
|
|
|
c)
|
|
|
|
check_on_off $OPTARG c
|
|
|
|
ENABLE_COVERAGE="$OPTARG"
|
|
|
|
;;
|
|
|
|
t)
|
2020-12-30 09:40:31 +08:00
|
|
|
if [[ "X$OPTARG" == "Xon" || "X$OPTARG" == "Xut" ]]; then
|
|
|
|
RUN_TESTCASES="on"
|
|
|
|
elif [[ "X$OPTARG" == "Xoff" ]]; then
|
|
|
|
RUN_TESTCASES="off"
|
|
|
|
elif [[ "X$OPTARG" == "Xst" ]]; then
|
|
|
|
RUN_CPP_ST_TESTS="on"
|
|
|
|
else
|
|
|
|
echo "Invalid value ${OPTARG} for option -t"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-03-27 14:49:12 +08:00
|
|
|
;;
|
|
|
|
g)
|
|
|
|
check_on_off $OPTARG g
|
|
|
|
USE_GLOG="$OPTARG"
|
|
|
|
;;
|
|
|
|
h)
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
b)
|
|
|
|
if [[ "X$OPTARG" != "Xge" && "X$OPTARG" != "Xcpu" ]]; then
|
|
|
|
echo "Invalid value ${OPTARG} for option -b"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
ENABLE_BACKEND=$(echo "$OPTARG" | tr '[a-z]' '[A-Z]')
|
|
|
|
if [[ "X$ENABLE_BACKEND" != "XCPU" ]]; then
|
|
|
|
ENABLE_CPU="on"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
a)
|
|
|
|
check_on_off $OPTARG a
|
|
|
|
ENABLE_ASAN="$OPTARG"
|
|
|
|
;;
|
|
|
|
p)
|
|
|
|
check_on_off $OPTARG p
|
|
|
|
ENABLE_PROFILE="$OPTARG"
|
|
|
|
;;
|
2020-07-11 04:26:00 +08:00
|
|
|
l)
|
|
|
|
check_on_off $OPTARG l
|
|
|
|
ENABLE_PYTHON="$OPTARG"
|
|
|
|
;;
|
2020-03-27 14:49:12 +08:00
|
|
|
i)
|
|
|
|
INC_BUILD="on"
|
|
|
|
;;
|
|
|
|
m)
|
|
|
|
if [[ "X$OPTARG" != "Xinfer" && "X$OPTARG" != "Xtrain" ]]; then
|
|
|
|
echo "Invalid value ${OPTARG} for option -m"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
TRAIN_MODE=$(echo "$OPTARG" | tr '[a-z]' '[A-Z]')
|
|
|
|
;;
|
|
|
|
R)
|
|
|
|
ENABLE_TIMELINE="on"
|
|
|
|
echo "enable time_line record"
|
|
|
|
;;
|
2020-10-14 19:35:13 +08:00
|
|
|
S)
|
|
|
|
check_on_off $OPTARG S
|
|
|
|
ENABLE_GITEE="$OPTARG"
|
|
|
|
echo "enable download from gitee"
|
|
|
|
;;
|
2020-10-26 09:39:49 +08:00
|
|
|
k)
|
|
|
|
check_on_off $OPTARG k
|
|
|
|
ENABLE_MAKE_CLEAN="$OPTARG"
|
|
|
|
echo "enable make clean"
|
|
|
|
;;
|
2020-03-27 14:49:12 +08:00
|
|
|
e)
|
2020-12-04 15:58:59 +08:00
|
|
|
DEVICE=$OPTARG
|
2020-03-27 14:49:12 +08:00
|
|
|
;;
|
|
|
|
M)
|
|
|
|
check_on_off $OPTARG M
|
|
|
|
ENABLE_MPI="$OPTARG"
|
|
|
|
;;
|
|
|
|
V)
|
2020-12-04 15:58:59 +08:00
|
|
|
DEVICE_VERSION=$OPTARG
|
2020-03-27 14:49:12 +08:00
|
|
|
;;
|
|
|
|
P)
|
|
|
|
check_on_off $OPTARG p
|
|
|
|
ENABLE_DUMP2PROTO="$OPTARG"
|
|
|
|
echo "enable dump anf graph to proto file"
|
|
|
|
;;
|
|
|
|
D)
|
|
|
|
check_on_off $OPTARG D
|
|
|
|
ENABLE_DUMP_IR="$OPTARG"
|
|
|
|
echo "enable dump function graph ir"
|
|
|
|
;;
|
|
|
|
z)
|
2020-04-06 11:22:47 +08:00
|
|
|
eval ARG=\$\{$OPTIND\}
|
2020-09-19 17:27:01 +08:00
|
|
|
if [[ -n "$ARG" && "$ARG" != -* ]]; then
|
2020-09-16 16:17:29 +08:00
|
|
|
OPTARG="$ARG"
|
2020-04-06 11:22:47 +08:00
|
|
|
check_on_off $OPTARG z
|
|
|
|
OPTIND=$((OPTIND + 1))
|
|
|
|
else
|
|
|
|
OPTARG=""
|
|
|
|
fi
|
|
|
|
if [[ "X$OPTARG" == "Xoff" ]]; then
|
|
|
|
COMPILE_MINDDATA="off"
|
|
|
|
fi
|
2020-03-27 14:49:12 +08:00
|
|
|
;;
|
|
|
|
I)
|
2020-07-29 02:16:33 +08:00
|
|
|
COMPILE_LITE="on"
|
2020-03-27 14:49:12 +08:00
|
|
|
if [[ "$OPTARG" == "arm64" ]]; then
|
2020-09-25 11:20:25 +08:00
|
|
|
ENABLE_CONVERTER="off"
|
2020-10-21 14:23:20 +08:00
|
|
|
RUN_TESTCASES="on"
|
2020-07-29 02:16:33 +08:00
|
|
|
LITE_PLATFORM="arm64"
|
|
|
|
elif [[ "$OPTARG" == "arm32" ]]; then
|
2020-09-25 11:20:25 +08:00
|
|
|
ENABLE_CONVERTER="off"
|
2020-10-21 14:23:20 +08:00
|
|
|
RUN_TESTCASES="on"
|
2020-07-29 02:16:33 +08:00
|
|
|
LITE_PLATFORM="arm32"
|
2020-03-27 14:49:12 +08:00
|
|
|
elif [[ "$OPTARG" == "x86_64" ]]; then
|
2020-07-29 02:16:33 +08:00
|
|
|
ENABLE_CONVERTER="on"
|
2020-10-21 14:23:20 +08:00
|
|
|
RUN_TESTCASES="on"
|
2020-07-29 02:16:33 +08:00
|
|
|
LITE_PLATFORM="x86_64"
|
2020-03-27 14:49:12 +08:00
|
|
|
else
|
2020-07-29 02:16:33 +08:00
|
|
|
echo "-I parameter must be arm64、arm32 or x86_64"
|
2020-03-27 14:49:12 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
K)
|
|
|
|
ENABLE_AKG="on"
|
|
|
|
echo "enable compile with akg"
|
|
|
|
;;
|
2020-06-11 22:42:57 +08:00
|
|
|
B)
|
|
|
|
check_on_off $OPTARG B
|
2020-09-10 06:55:10 +08:00
|
|
|
ENABLE_DEBUGGER="$OPTARG"
|
2020-06-11 22:42:57 +08:00
|
|
|
;;
|
2020-06-08 15:31:37 +08:00
|
|
|
E)
|
|
|
|
ENABLE_IBVERBS="on"
|
|
|
|
echo "enable IBVERBS for parameter server"
|
|
|
|
;;
|
2020-09-25 11:20:25 +08:00
|
|
|
T)
|
2020-08-09 19:32:04 +08:00
|
|
|
check_on_off $OPTARG T
|
|
|
|
SUPPORT_TRAIN=$OPTARG
|
2020-10-22 15:35:40 +08:00
|
|
|
COMPILE_MINDDATA_LITE="full"
|
2020-08-09 19:32:04 +08:00
|
|
|
echo "support train on device "
|
|
|
|
;;
|
2020-09-28 10:57:29 +08:00
|
|
|
A)
|
|
|
|
COMPILE_LITE="on"
|
|
|
|
if [[ "$OPTARG" == "cpp" ]]; then
|
|
|
|
LITE_LANGUAGE="cpp"
|
2020-10-24 15:07:28 +08:00
|
|
|
ANDROID_STL="c++_shared"
|
2020-09-28 10:57:29 +08:00
|
|
|
elif [[ "$OPTARG" == "java" ]]; then
|
|
|
|
LITE_LANGUAGE="java"
|
2020-10-14 12:15:39 +08:00
|
|
|
ENABLE_CONVERTER="off"
|
2020-10-24 15:07:28 +08:00
|
|
|
ANDROID_STL="c++_static"
|
2020-11-04 09:37:07 +08:00
|
|
|
RUN_TESTCASES="off"
|
|
|
|
ENABLE_TOOLS="off"
|
2020-09-28 10:57:29 +08:00
|
|
|
elif [[ "$OPTARG" == "object-c" ]]; then
|
|
|
|
LITE_LANGUAGE="object-c"
|
|
|
|
else
|
2020-10-21 14:23:20 +08:00
|
|
|
echo "-A parameter must be cpp, java or object-c"
|
2020-09-28 10:57:29 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
C)
|
|
|
|
check_on_off $OPTARG C
|
|
|
|
ENABLE_CONVERTER="$OPTARG"
|
|
|
|
;;
|
|
|
|
o)
|
|
|
|
check_on_off $OPTARG o
|
|
|
|
ENABLE_TOOLS="$OPTARG"
|
|
|
|
;;
|
2020-11-03 14:06:36 +08:00
|
|
|
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"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [[ "$OPTARG" == "sse" || "$OPTARG" == "avx" ]]; then
|
|
|
|
X86_64_SIMD="$OPTARG"
|
|
|
|
fi
|
2021-04-26 19:35:06 +08:00
|
|
|
if [[ "$OPTARG" == "neon" ]]; then
|
|
|
|
ARM_SIMD="$OPTARG"
|
|
|
|
fi
|
2020-11-03 14:06:36 +08:00
|
|
|
;;
|
2021-02-28 17:03:20 +08:00
|
|
|
H)
|
|
|
|
check_on_off $OPTARG H
|
|
|
|
ENABLE_HIDDEN="$OPTARG"
|
|
|
|
echo "${OPTARG} hidden"
|
|
|
|
;;
|
2021-04-25 15:39:28 +08:00
|
|
|
L)
|
|
|
|
ENABLE_TRT="on"
|
|
|
|
TENSORRT_HOME="$CASE_SENSIVE_ARG"
|
|
|
|
echo "Link Tensor-RT library. Path: ${CASE_SENSIVE_ARG}"
|
|
|
|
;;
|
2020-03-27 14:49:12 +08:00
|
|
|
*)
|
|
|
|
echo "Unknown option ${opt}!"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
done
|
2020-12-07 09:23:36 +08:00
|
|
|
|
2021-04-22 19:59:48 +08:00
|
|
|
if [[ "X$RUN_TESTCASES" == "Xon" && "X$DEVICE" != "X" && "X$COMPILE_LITE" != "Xon" ]]; then
|
2021-04-20 11:47:09 +08:00
|
|
|
echo "WARNING:Option -e can't be set while option -t on/ut is set, reset device to empty."
|
|
|
|
DEVICE=""
|
|
|
|
fi
|
|
|
|
|
2020-12-10 21:39:36 +08:00
|
|
|
# Parse device
|
2020-12-07 09:23:36 +08:00
|
|
|
# Process build option
|
|
|
|
if [[ "X$DEVICE" == "Xgpu" ]]; then
|
2021-01-06 12:15:07 +08:00
|
|
|
LITE_ENABLE_GPU="opencl"
|
2020-12-07 09:23:36 +08:00
|
|
|
ENABLE_GPU="on"
|
|
|
|
ENABLE_CPU="on"
|
|
|
|
ENABLE_MPI="on"
|
|
|
|
# version default 10.1
|
|
|
|
if [[ "X$DEVICE_VERSION" == "X" ]]; then
|
|
|
|
DEVICE_VERSION=10.1
|
|
|
|
fi
|
2021-03-16 17:22:19 +08:00
|
|
|
if [[ "X$DEVICE_VERSION" != "X11.1" && "X$DEVICE_VERSION" != "X10.1" ]]; then
|
2020-12-07 09:23:36 +08:00
|
|
|
echo "Invalid value ${DEVICE_VERSION} for option -V"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
CUDA_VERSION="$DEVICE_VERSION"
|
|
|
|
elif [[ "X$DEVICE" == "Xd" || "X$DEVICE" == "Xascend" ]]; then
|
|
|
|
# version default 910
|
|
|
|
if [[ "X$DEVICE_VERSION" == "X" ]]; then
|
|
|
|
DEVICE_VERSION=910
|
|
|
|
fi
|
2021-05-26 11:31:02 +08:00
|
|
|
# building 310 package by giving specific -V 310 instruction
|
2020-12-07 09:23:36 +08:00
|
|
|
if [[ "X$DEVICE_VERSION" == "X310" ]]; then
|
|
|
|
ENABLE_ACL="on"
|
2021-05-26 11:31:02 +08:00
|
|
|
# universal ascend package
|
2020-12-07 09:23:36 +08:00
|
|
|
elif [[ "X$DEVICE_VERSION" == "X910" ]]; then
|
|
|
|
ENABLE_D="on"
|
2021-05-26 11:31:02 +08:00
|
|
|
ENABLE_ACL="on"
|
2020-12-07 09:23:36 +08:00
|
|
|
ENABLE_CPU="on"
|
|
|
|
else
|
|
|
|
echo "Invalid value ${DEVICE_VERSION} for option -V"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-12-07 18:50:07 +08:00
|
|
|
elif [[ "X$DEVICE" == "Xnpu" ]]; then
|
|
|
|
ENABLE_NPU="on"
|
|
|
|
ENABLE_CPU="on"
|
2020-12-07 09:23:36 +08:00
|
|
|
elif [[ "X$DEVICE" == "Xcpu" ]]; then
|
|
|
|
ENABLE_CPU="on"
|
2021-01-06 12:15:07 +08:00
|
|
|
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"
|
2020-12-07 09:23:36 +08:00
|
|
|
elif [[ "X$DEVICE" == "X" ]]; then
|
|
|
|
:
|
|
|
|
else
|
|
|
|
echo "Invalid value ${DEVICE} for option -e"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-03-27 14:49:12 +08:00
|
|
|
checkopts "$@"
|
2020-06-20 14:27:37 +08:00
|
|
|
echo "---------------- MindSpore: build start ----------------"
|
2020-03-27 14:49:12 +08:00
|
|
|
mkdir -pv "${BUILD_PATH}/package/mindspore/lib"
|
|
|
|
git submodule update --init graphengine
|
2021-02-05 11:03:33 +08:00
|
|
|
cd "${BASEPATH}/graphengine"
|
|
|
|
git submodule update --init metadef
|
|
|
|
cd "${BASEPATH}"
|
2020-07-29 12:52:07 +08:00
|
|
|
if [[ "X$ENABLE_AKG" = "Xon" ]] && [[ "X$ENABLE_D" = "Xon" || "X$ENABLE_GPU" = "Xon" ]]; then
|
2020-06-04 09:59:26 +08:00
|
|
|
git submodule update --init --recursive akg
|
|
|
|
fi
|
2020-03-27 14:49:12 +08:00
|
|
|
|
2021-01-18 00:17:30 +08:00
|
|
|
|
2020-03-27 14:49:12 +08:00
|
|
|
build_exit()
|
|
|
|
{
|
|
|
|
echo "$@" >&2
|
|
|
|
stty echo
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Create building path
|
|
|
|
build_mindspore()
|
|
|
|
{
|
|
|
|
echo "start build mindspore project."
|
|
|
|
mkdir -pv "${BUILD_PATH}/mindspore"
|
|
|
|
cd "${BUILD_PATH}/mindspore"
|
2021-04-22 19:33:57 +08:00
|
|
|
CMAKE_ARGS="-DDEBUG_MODE=$DEBUG_MODE -DBUILD_PATH=$BUILD_PATH -DX86_64_SIMD=${X86_64_SIMD}"
|
2020-03-27 14:49:12 +08:00
|
|
|
if [[ "X$ENABLE_COVERAGE" = "Xon" ]]; then
|
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_COVERAGE=ON"
|
|
|
|
fi
|
|
|
|
if [[ "X$RUN_TESTCASES" = "Xon" ]]; then
|
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_TESTCASES=ON"
|
|
|
|
fi
|
2020-12-30 09:40:31 +08:00
|
|
|
if [[ "X$RUN_CPP_ST_TESTS" = "Xon" ]]; then
|
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_CPP_ST=ON"
|
|
|
|
fi
|
2020-03-27 14:49:12 +08:00
|
|
|
if [[ -n "$ENABLE_BACKEND" ]]; then
|
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_${ENABLE_BACKEND}=ON"
|
|
|
|
fi
|
|
|
|
if [[ -n "$TRAIN_MODE" ]]; then
|
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_${TRAIN_MODE}=ON"
|
|
|
|
fi
|
|
|
|
if [[ "X$ENABLE_ASAN" = "Xon" ]]; then
|
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_ASAN=ON"
|
|
|
|
fi
|
|
|
|
if [[ "X$ENABLE_PROFILE" = "Xon" ]]; then
|
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_PROFILE=ON"
|
|
|
|
fi
|
|
|
|
if [[ "X$ENABLE_TIMELINE" = "Xon" ]]; then
|
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_TIMELINE=ON"
|
|
|
|
fi
|
|
|
|
if [[ "X$ENABLE_DUMP2PROTO" = "Xon" ]]; then
|
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_DUMP_PROTO=ON"
|
|
|
|
fi
|
2020-10-14 19:35:13 +08:00
|
|
|
if [[ "X$ENABLE_GITEE" = "Xon" ]]; then
|
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_GITEE=ON"
|
|
|
|
fi
|
2020-04-13 19:42:12 +08:00
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_DUMP_IR=${ENABLE_DUMP_IR}"
|
2020-07-11 04:26:00 +08:00
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_PYTHON=${ENABLE_PYTHON}"
|
2020-03-27 14:49:12 +08:00
|
|
|
if [[ "X$ENABLE_MPI" = "Xon" ]]; then
|
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_MPI=ON"
|
|
|
|
fi
|
|
|
|
if [[ "X$ENABLE_D" = "Xon" ]]; then
|
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_D=ON"
|
|
|
|
fi
|
|
|
|
if [[ "X$ENABLE_GPU" = "Xon" ]]; then
|
2020-09-08 21:31:27 +08:00
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_GPU=ON -DUSE_CUDA=ON -DCUDA_PATH=$CUDA_PATH -DMS_REQUIRE_CUDA_VERSION=${CUDA_VERSION}"
|
2020-03-27 14:49:12 +08:00
|
|
|
fi
|
|
|
|
if [[ "X$ENABLE_CPU" = "Xon" ]]; then
|
2021-04-26 19:35:06 +08:00
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_CPU=ON -DX86_64_SIMD=${X86_64_SIMD} -DARM_SIMD=${ARM_SIMD}"
|
2020-03-27 14:49:12 +08:00
|
|
|
fi
|
|
|
|
if [[ "X$COMPILE_MINDDATA" = "Xon" ]]; then
|
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_MINDDATA=ON"
|
|
|
|
fi
|
|
|
|
if [[ "X$USE_GLOG" = "Xon" ]]; then
|
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DUSE_GLOG=ON"
|
|
|
|
fi
|
2020-07-29 12:52:07 +08:00
|
|
|
if [[ "X$ENABLE_AKG" = "Xon" ]] && [[ "X$ENABLE_D" = "Xon" || "X$ENABLE_GPU" = "Xon" ]]; then
|
2020-03-27 14:49:12 +08:00
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_AKG=ON"
|
|
|
|
fi
|
2020-07-21 11:19:00 +08:00
|
|
|
if [[ "X$ENABLE_ACL" = "Xon" ]]; then
|
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_ACL=ON"
|
|
|
|
fi
|
2020-06-11 22:42:57 +08:00
|
|
|
if [[ "X$ENABLE_DEBUGGER" = "Xon" ]]; then
|
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_DEBUGGER=ON"
|
|
|
|
fi
|
2020-06-21 14:37:27 +08:00
|
|
|
|
2020-06-08 15:31:37 +08:00
|
|
|
if [[ "X$ENABLE_IBVERBS" = "Xon" ]]; then
|
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_IBVERBS=ON"
|
|
|
|
fi
|
2021-02-28 17:03:20 +08:00
|
|
|
if [[ "X$ENABLE_HIDDEN" = "Xoff" ]]; then
|
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_HIDDEN=OFF"
|
|
|
|
fi
|
2021-04-25 15:39:28 +08:00
|
|
|
if [[ "X$ENABLE_TRT" == "Xon" ]]; then
|
|
|
|
CMAKE_ARGS="${CMAKE_ARGS} -DTENSORRT_HOME=${TENSORRT_HOME}"
|
|
|
|
fi
|
2020-03-27 14:49:12 +08:00
|
|
|
echo "${CMAKE_ARGS}"
|
|
|
|
if [[ "X$INC_BUILD" = "Xoff" ]]; then
|
|
|
|
cmake ${CMAKE_ARGS} ../..
|
|
|
|
fi
|
2020-04-19 12:14:46 +08:00
|
|
|
if [[ -n "$VERBOSE" ]]; then
|
|
|
|
CMAKE_VERBOSE="--verbose"
|
|
|
|
fi
|
|
|
|
cmake --build . --target package ${CMAKE_VERBOSE} -j$THREAD_NUM
|
2020-06-17 11:02:39 +08:00
|
|
|
echo "success building mindspore project!"
|
2020-03-27 14:49:12 +08:00
|
|
|
}
|
|
|
|
|
2020-07-29 02:16:33 +08:00
|
|
|
checkndk() {
|
|
|
|
if [ "${ANDROID_NDK}" ]; then
|
2021-01-23 11:51:26 +08:00
|
|
|
echo -e "\e[31mANDROID_NDK=$ANDROID_NDK \e[0m"
|
2020-07-29 02:16:33 +08:00
|
|
|
else
|
2020-08-08 15:29:42 +08:00
|
|
|
echo -e "\e[31mplease set ANDROID_NDK in environment variable for example: export ANDROID_NDK=/root/usr/android-ndk-r20b/ \e[0m"
|
2020-07-29 02:16:33 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
2020-03-27 14:49:12 +08:00
|
|
|
|
2020-12-07 18:50:07 +08:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2020-09-28 10:57:29 +08:00
|
|
|
get_version() {
|
2020-10-21 14:23:20 +08:00
|
|
|
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]")
|
|
|
|
VERSION_REVISION=$(grep "const int ms_version_revision =" ${BASEPATH}/mindspore/lite/include/version.h | tr -dc "[0-9]")
|
2020-09-28 10:57:29 +08:00
|
|
|
VERSION_STR=${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION}
|
|
|
|
}
|
|
|
|
|
2021-01-14 19:21:29 +08:00
|
|
|
write_commit_file() {
|
|
|
|
COMMIT_STR=$(git log -1 | grep commit)
|
|
|
|
echo ${COMMIT_STR} > "${BASEPATH}/mindspore/lite/build/.commit_id"
|
|
|
|
}
|
|
|
|
|
2020-07-29 02:16:33 +08:00
|
|
|
build_lite()
|
|
|
|
{
|
2021-05-26 10:10:25 +08:00
|
|
|
[ -n "${BASEPATH}" ] && rm -rf ${BASEPATH}/output
|
2020-09-28 10:57:29 +08:00
|
|
|
get_version
|
|
|
|
echo "============ Start building MindSpore Lite ${VERSION_STR} ============"
|
2021-05-26 10:10:25 +08:00
|
|
|
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}
|
2021-03-16 19:03:48 +08:00
|
|
|
|
2021-02-24 17:24:12 +08:00
|
|
|
if [[ "${LITE_LANGUAGE}" == "java" ]]; then
|
|
|
|
if [[ "X$1" != "X" ]]; then
|
2021-05-26 10:10:25 +08:00
|
|
|
local_lite_platform=$1
|
2021-02-24 17:24:12 +08:00
|
|
|
else
|
2021-05-26 10:10:25 +08:00
|
|
|
local_lite_platform=""
|
2021-02-24 17:24:12 +08:00
|
|
|
fi
|
|
|
|
if [[ "X$2" != "X" ]]; then
|
2021-05-26 10:10:25 +08:00
|
|
|
local_lite_inc_build=$2
|
2021-02-24 17:24:12 +08:00
|
|
|
else
|
2021-05-26 10:10:25 +08:00
|
|
|
local_lite_inc_build=""
|
2021-02-24 17:24:12 +08:00
|
|
|
fi
|
|
|
|
if [[ "X$3" != "X" ]]; then
|
2021-05-26 10:10:25 +08:00
|
|
|
local_lite_enable_gpu=$3
|
2021-02-24 17:24:12 +08:00
|
|
|
else
|
2021-05-26 10:10:25 +08:00
|
|
|
local_lite_enable_gpu=""
|
2021-02-24 17:24:12 +08:00
|
|
|
fi
|
2021-03-16 19:03:48 +08:00
|
|
|
mkdir -p ${BASEPATH}/mindspore/lite/build/java
|
|
|
|
cd ${BASEPATH}/mindspore/lite/build/
|
2021-05-26 10:10:25 +08:00
|
|
|
[ -n "${BASEPATH}" ] && find . -maxdepth 1 | grep -v java | grep '/' | xargs -I {} rm -rf {}
|
2021-03-16 19:03:48 +08:00
|
|
|
fi
|
|
|
|
if [[ "${LITE_LANGUAGE}" == "cpp" ]]; then
|
2021-05-17 09:52:34 +08:00
|
|
|
if [[ "${DEVICE}" == "" ]]; then
|
2021-05-26 10:10:25 +08:00
|
|
|
if [[ "${local_lite_platform}" == "arm64" || "${local_lite_platform}" == "arm32" ]]; then
|
|
|
|
local_lite_enable_npu="on"
|
2021-05-17 09:52:34 +08:00
|
|
|
fi
|
2021-05-26 10:10:25 +08:00
|
|
|
if [[ "${local_lite_platform}" == "arm64" ]]; then
|
|
|
|
local_lite_enable_gpu="opencl"
|
2021-05-17 09:52:34 +08:00
|
|
|
fi
|
2021-03-16 19:03:48 +08:00
|
|
|
fi
|
|
|
|
|
2021-05-26 10:10:25 +08:00
|
|
|
if [[ "${local_lite_inc_build}" == "off" ]]; then
|
|
|
|
[ -n "${BASEPATH}" ] && rm -rf ${BASEPATH}/mindspore/lite/build
|
2021-03-16 19:03:48 +08:00
|
|
|
fi
|
|
|
|
mkdir -pv ${BASEPATH}/mindspore/lite/build
|
2021-02-24 17:24:12 +08:00
|
|
|
fi
|
2021-03-16 19:03:48 +08:00
|
|
|
|
2021-05-26 10:10:25 +08:00
|
|
|
if [ "${local_lite_enable_npu}" == "on" ]; then
|
2021-05-17 09:52:34 +08:00
|
|
|
checkddk
|
2020-12-07 18:50:07 +08:00
|
|
|
fi
|
2020-09-25 11:20:25 +08:00
|
|
|
|
2021-03-16 19:03:48 +08:00
|
|
|
cd ${BASEPATH}/mindspore/lite/build
|
2021-01-14 19:21:29 +08:00
|
|
|
write_commit_file
|
2020-07-29 02:16:33 +08:00
|
|
|
BUILD_TYPE="Release"
|
|
|
|
if [[ "${DEBUG_MODE}" == "on" ]]; then
|
|
|
|
BUILD_TYPE="Debug"
|
2020-03-27 14:49:12 +08:00
|
|
|
fi
|
|
|
|
|
2021-05-26 10:10:25 +08:00
|
|
|
if [[ "${local_lite_platform}" == "arm64" ]]; then
|
2021-04-29 09:10:45 +08:00
|
|
|
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" \
|
2021-05-15 23:18:33 +08:00
|
|
|
-DOFFLINE_COMPILE=${OPENCL_OFFLINE_COMPILE} -DBUILD_MINDDATA="" -DENABLE_ASAN=${ENABLE_ASAN} \
|
2021-04-29 09:10:45 +08:00
|
|
|
-DCMAKE_INSTALL_PREFIX=${BUILD_PATH}/output/tmp \
|
|
|
|
-G Xcode ..
|
|
|
|
else
|
2020-07-29 02:16:33 +08:00
|
|
|
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" \
|
2020-10-24 15:07:28 +08:00
|
|
|
-DANDROID_STL=${ANDROID_STL} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DSUPPORT_TRAIN=${SUPPORT_TRAIN} \
|
2021-01-12 15:58:21 +08:00
|
|
|
-DPLATFORM_ARM64=on -DENABLE_NEON=on -DENABLE_FP16="on" \
|
2020-10-21 14:23:20 +08:00
|
|
|
-DENABLE_TOOLS=${ENABLE_TOOLS} -DENABLE_CONVERTER=${ENABLE_CONVERTER} -DBUILD_TESTCASES=${RUN_TESTCASES} \
|
2021-05-26 10:10:25 +08:00
|
|
|
-DSUPPORT_GPU=${local_lite_enable_gpu} -DSUPPORT_NPU=${local_lite_enable_npu} -DENABLE_V0=on \
|
2021-05-15 23:18:33 +08:00
|
|
|
-DOFFLINE_COMPILE=${OPENCL_OFFLINE_COMPILE} -DBUILD_MINDDATA=${COMPILE_MINDDATA_LITE} -DENABLE_ASAN=${ENABLE_ASAN} \
|
2020-09-01 16:35:47 +08:00
|
|
|
-DCMAKE_INSTALL_PREFIX=${BASEPATH}/output/tmp -DMS_VERSION_MAJOR=${VERSION_MAJOR} \
|
2020-09-19 18:44:46 +08:00
|
|
|
-DMS_VERSION_MINOR=${VERSION_MINOR} -DMS_VERSION_REVISION=${VERSION_REVISION} -DENABLE_VERBOSE=${ENABLE_VERBOSE} \
|
2020-09-25 11:20:25 +08:00
|
|
|
"${BASEPATH}/mindspore/lite"
|
2021-04-29 09:10:45 +08:00
|
|
|
fi
|
2021-05-26 10:10:25 +08:00
|
|
|
elif [[ "${local_lite_platform}" == "arm32" ]]; then
|
2021-04-29 09:10:45 +08:00
|
|
|
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 \
|
2021-05-15 23:18:33 +08:00
|
|
|
-DOFFLINE_COMPILE=${OPENCL_OFFLINE_COMPILE} -DBUILD_MINDDATA="" -DENABLE_ASAN=${ENABLE_ASAN} \
|
2021-04-29 09:10:45 +08:00
|
|
|
-DCMAKE_INSTALL_PREFIX=${BUILD_PATH}/output/tmp \
|
|
|
|
-G Xcode ..
|
|
|
|
else
|
2020-07-29 02:16:33 +08:00
|
|
|
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" \
|
2020-10-24 15:07:28 +08:00
|
|
|
-DANDROID_STL=${ANDROID_STL} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
2021-04-13 14:10:40 +08:00
|
|
|
-DPLATFORM_ARM32=on -DENABLE_NEON=on -DSUPPORT_TRAIN=${SUPPORT_TRAIN} -DENABLE_FP16="on" \
|
2020-10-21 14:23:20 +08:00
|
|
|
-DENABLE_TOOLS=${ENABLE_TOOLS} -DENABLE_CONVERTER=${ENABLE_CONVERTER} -DBUILD_TESTCASES=${RUN_TESTCASES} \
|
2021-05-26 10:10:25 +08:00
|
|
|
-DSUPPORT_GPU=${local_lite_enable_gpu} -DSUPPORT_NPU=${local_lite_enable_npu} -DENABLE_V0=on \
|
2021-05-15 23:18:33 +08:00
|
|
|
-DOFFLINE_COMPILE=${OPENCL_OFFLINE_COMPILE} -DBUILD_MINDDATA=${COMPILE_MINDDATA_LITE} -DENABLE_ASAN=${ENABLE_ASAN} \
|
2020-09-01 16:35:47 +08:00
|
|
|
-DCMAKE_INSTALL_PREFIX=${BASEPATH}/output/tmp -DMS_VERSION_MAJOR=${VERSION_MAJOR} \
|
2020-09-19 18:44:46 +08:00
|
|
|
-DMS_VERSION_MINOR=${VERSION_MINOR} -DMS_VERSION_REVISION=${VERSION_REVISION} -DENABLE_VERBOSE=${ENABLE_VERBOSE} \
|
2020-09-25 11:20:25 +08:00
|
|
|
"${BASEPATH}/mindspore/lite"
|
2021-04-29 09:10:45 +08:00
|
|
|
fi
|
2020-07-29 02:16:33 +08:00
|
|
|
else
|
2020-10-09 17:28:33 +08:00
|
|
|
cmake -DPLATFORM_ARM64=off -DSUPPORT_TRAIN=${SUPPORT_TRAIN} \
|
2020-10-21 14:23:20 +08:00
|
|
|
-DENABLE_TOOLS=${ENABLE_TOOLS} -DENABLE_CONVERTER=${ENABLE_CONVERTER} -DBUILD_TESTCASES=${RUN_TESTCASES} \
|
2021-05-26 10:10:25 +08:00
|
|
|
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DSUPPORT_GPU=${local_lite_enable_gpu} -DSUPPORT_NPU=${local_lite_enable_npu} \
|
2021-05-15 23:18:33 +08:00
|
|
|
-DBUILD_MINDDATA=${COMPILE_MINDDATA_LITE} -DENABLE_V0=on -DENABLE_ASAN=${ENABLE_ASAN} \
|
2020-09-01 16:35:47 +08:00
|
|
|
-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} \
|
2020-11-03 14:06:36 +08:00
|
|
|
-DENABLE_VERBOSE=${ENABLE_VERBOSE} -DX86_64_SIMD=${X86_64_SIMD} "${BASEPATH}/mindspore/lite"
|
2020-03-27 14:49:12 +08:00
|
|
|
fi
|
2021-04-29 09:10:45 +08:00
|
|
|
if [ "${OS}" == "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
|
|
|
|
fi
|
2020-12-10 21:39:36 +08:00
|
|
|
if [[ $? -ne 0 ]]; then
|
2020-07-29 02:16:33 +08:00
|
|
|
echo "---------------- mindspore lite: build failed ----------------"
|
2020-08-23 14:00:13 +08:00
|
|
|
exit 1
|
2020-07-29 02:16:33 +08:00
|
|
|
else
|
2021-03-16 19:03:48 +08:00
|
|
|
if [[ "${LITE_LANGUAGE}" == "cpp" ]]; then
|
2021-04-29 09:10:45 +08:00
|
|
|
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
|
2021-05-26 10:10:25 +08:00
|
|
|
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
|
2021-04-29 09:10:45 +08:00
|
|
|
rm -r mindspore_lite.framework
|
|
|
|
else
|
|
|
|
mv ${BASEPATH}/output/tmp/*.tar.gz* ${BASEPATH}/output/
|
|
|
|
fi
|
2021-03-16 19:03:48 +08:00
|
|
|
elif [[ "${LITE_LANGUAGE}" == "java" ]]; then
|
|
|
|
mv ${BASEPATH}/output/tmp/*.tar.gz* ${BASEPATH}/mindspore/lite/build/java
|
|
|
|
fi
|
2021-05-26 10:10:25 +08:00
|
|
|
[ -n "${BASEPATH}" ] && rm -rf ${BASEPATH}/output/tmp/
|
2020-07-29 02:16:33 +08:00
|
|
|
echo "---------------- mindspore lite: build success ----------------"
|
2020-09-28 10:57:29 +08:00
|
|
|
if [[ "X$LITE_LANGUAGE" = "Xcpp" ]]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
2021-04-29 09:10:45 +08:00
|
|
|
if [ "${OS}" == "Darwin" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
2020-03-27 14:49:12 +08:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-09-28 10:57:29 +08:00
|
|
|
build_lite_java_arm64() {
|
|
|
|
# build mindspore-lite arm64
|
2021-05-26 10:10:25 +08:00
|
|
|
local local_pkg_name=mindspore-lite-${VERSION_STR}-inference-android-aarch64
|
2021-01-18 00:17:30 +08:00
|
|
|
if [[ "X$SUPPORT_TRAIN" = "Xon" ]]; then
|
2021-05-26 10:10:25 +08:00
|
|
|
local_pkg_name=mindspore-lite-${VERSION_STR}-train-android-aarch64
|
2021-01-18 00:17:30 +08:00
|
|
|
fi
|
2021-05-26 10:10:25 +08:00
|
|
|
if [[ "X$INC_BUILD" == "Xoff" ]] || [[ ! -f "${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}.tar.gz" ]]; then
|
2021-02-24 17:24:12 +08:00
|
|
|
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
|
2020-09-28 10:57:29 +08:00
|
|
|
fi
|
|
|
|
# copy arm64 so
|
2021-03-16 19:03:48 +08:00
|
|
|
cd ${BASEPATH}/mindspore/lite/build/java/
|
2021-05-26 10:10:25 +08:00
|
|
|
[ -n "${local_pkg_name}" ] && rm -rf ${local_pkg_name}
|
|
|
|
tar -zxvf ${local_pkg_name}.tar.gz
|
2020-10-21 14:23:20 +08:00
|
|
|
[ -n "${JAVA_PATH}" ] && rm -rf ${JAVA_PATH}/java/app/libs/arm64-v8a/
|
2020-09-28 10:57:29 +08:00
|
|
|
mkdir -p ${JAVA_PATH}/java/app/libs/arm64-v8a/
|
2021-02-24 17:24:12 +08:00
|
|
|
mkdir -p ${JAVA_PATH}/native/libs/arm64-v8a/
|
2021-03-12 16:42:55 +08:00
|
|
|
if [[ "X$SUPPORT_TRAIN" = "Xon" ]]; then
|
2021-05-26 10:10:25 +08:00
|
|
|
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/
|
2021-03-24 09:17:51 +08:00
|
|
|
|
2021-05-26 10:10:25 +08:00
|
|
|
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/
|
2021-03-24 09:17:51 +08:00
|
|
|
|
2021-05-26 10:10:25 +08:00
|
|
|
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/
|
2021-03-12 16:42:55 +08:00
|
|
|
else
|
2021-05-26 10:10:25 +08:00
|
|
|
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/
|
2021-03-12 16:42:55 +08:00
|
|
|
fi
|
2021-05-26 10:10:25 +08:00
|
|
|
[ -n "${local_pkg_name}" ] && rm -rf ${local_pkg_name}
|
2020-09-28 10:57:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
build_lite_java_arm32() {
|
|
|
|
# build mindspore-lite arm32
|
2021-05-26 10:10:25 +08:00
|
|
|
local local_pkg_name=mindspore-lite-${VERSION_STR}-inference-android-aarch32
|
2021-01-18 00:17:30 +08:00
|
|
|
if [[ "X$SUPPORT_TRAIN" = "Xon" ]]; then
|
2021-05-26 10:10:25 +08:00
|
|
|
local_pkg_name=mindspore-lite-${VERSION_STR}-train-android-aarch32
|
2021-01-18 00:17:30 +08:00
|
|
|
fi
|
2021-05-26 10:10:25 +08:00
|
|
|
if [[ "X$INC_BUILD" == "Xoff" ]] || [[ ! -f "${BASEPATH}/mindspore/lite/build/java/${local_pkg_name}.tar.gz" ]]; then
|
2021-02-24 17:24:12 +08:00
|
|
|
build_lite "arm32" "off" ""
|
2020-09-28 10:57:29 +08:00
|
|
|
fi
|
|
|
|
# copy arm32 so
|
2021-03-16 19:03:48 +08:00
|
|
|
cd ${BASEPATH}/mindspore/lite/build/java/
|
2021-05-26 10:10:25 +08:00
|
|
|
[ -n "${local_pkg_name}" ] && rm -rf ${local_pkg_name}
|
|
|
|
tar -zxvf ${local_pkg_name}.tar.gz
|
2020-10-21 14:23:20 +08:00
|
|
|
[ -n "${JAVA_PATH}" ] && rm -rf ${JAVA_PATH}/java/app/libs/armeabi-v7a/
|
2020-09-28 10:57:29 +08:00
|
|
|
mkdir -p ${JAVA_PATH}/java/app/libs/armeabi-v7a/
|
2021-02-24 17:24:12 +08:00
|
|
|
mkdir -p ${JAVA_PATH}/native/libs/armeabi-v7a/
|
2021-03-12 16:42:55 +08:00
|
|
|
if [[ "X$SUPPORT_TRAIN" = "Xon" ]]; then
|
2021-05-26 10:10:25 +08:00
|
|
|
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/
|
2021-03-24 09:17:51 +08:00
|
|
|
|
2021-05-26 10:10:25 +08:00
|
|
|
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/
|
2021-03-24 09:17:51 +08:00
|
|
|
|
2021-05-26 10:10:25 +08:00
|
|
|
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/
|
2021-03-12 16:42:55 +08:00
|
|
|
else
|
2021-05-26 10:10:25 +08:00
|
|
|
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/
|
2021-03-12 16:42:55 +08:00
|
|
|
fi
|
2021-05-26 10:10:25 +08:00
|
|
|
[ -n "${local_pkg_name}" ] && rm -rf ${local_pkg_name}
|
2020-09-28 10:57:29 +08:00
|
|
|
}
|
|
|
|
|
2021-02-24 17:24:12 +08:00
|
|
|
build_lite_java_x86() {
|
|
|
|
# build mindspore-lite x86
|
2021-03-24 09:17:51 +08:00
|
|
|
local inference_or_train=inference
|
|
|
|
if [[ "X$SUPPORT_TRAIN" = "Xon" ]]; then
|
|
|
|
inference_or_train=train
|
|
|
|
fi
|
2021-05-26 10:10:25 +08:00
|
|
|
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
|
2021-02-24 17:24:12 +08:00
|
|
|
build_lite "x86_64" "off" ""
|
|
|
|
fi
|
|
|
|
# copy x86 so
|
2021-03-16 19:03:48 +08:00
|
|
|
cd ${BASEPATH}/mindspore/lite/build/java
|
2021-05-26 10:10:25 +08:00
|
|
|
[ -n "${local_pkg_name}" ] && rm -rf ${local_pkg_name}
|
|
|
|
tar -zxvf ${local_pkg_name}.tar.gz
|
2021-02-24 17:24:12 +08:00
|
|
|
[ -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/
|
2021-03-24 09:17:51 +08:00
|
|
|
if [[ "X$SUPPORT_TRAIN" = "Xon" ]]; then
|
2021-05-26 10:10:25 +08:00
|
|
|
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/
|
2021-03-24 09:17:51 +08:00
|
|
|
|
2021-05-26 10:10:25 +08:00
|
|
|
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/
|
2021-03-24 09:17:51 +08:00
|
|
|
|
2021-05-26 10:10:25 +08:00
|
|
|
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/
|
2021-03-24 09:17:51 +08:00
|
|
|
else
|
2021-05-26 10:10:25 +08:00
|
|
|
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/
|
2021-03-24 09:17:51 +08:00
|
|
|
fi
|
2021-05-26 10:10:25 +08:00
|
|
|
[ -n "${local_pkg_name}" ] && rm -rf ${local_pkg_name}
|
2021-02-24 17:24:12 +08:00
|
|
|
}
|
|
|
|
|
2020-09-28 10:57:29 +08:00
|
|
|
build_jni_arm64() {
|
|
|
|
# build jni so
|
|
|
|
cd "${BASEPATH}/mindspore/lite/build"
|
2021-05-26 10:10:25 +08:00
|
|
|
[ -n "${BASEPATH}" ] && rm -rf java/jni
|
2021-03-16 19:03:48 +08:00
|
|
|
mkdir -pv java/jni
|
|
|
|
cd java/jni
|
2020-09-28 10:57:29 +08:00
|
|
|
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} \
|
2021-02-24 17:24:12 +08:00
|
|
|
-DSUPPORT_TRAIN=${SUPPORT_TRAIN} -DPLATFORM_ARM64=on "${JAVA_PATH}/native/"
|
2020-09-28 10:57:29 +08:00
|
|
|
make -j$THREAD_NUM
|
2020-12-10 21:39:36 +08:00
|
|
|
if [[ $? -ne 0 ]]; then
|
2020-09-28 10:57:29 +08:00
|
|
|
echo "---------------- mindspore lite: build jni arm64 failed----------------"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
mkdir -p ${JAVA_PATH}/java/app/libs/arm64-v8a/
|
2021-03-16 19:03:48 +08:00
|
|
|
cp ${BASEPATH}/mindspore/lite/build/java/jni/libmindspore-lite-jni.so ${JAVA_PATH}/java/app/libs/arm64-v8a/
|
2021-02-24 17:24:12 +08:00
|
|
|
mkdir -p ${JAVA_PATH}/native/libs/arm64-v8a/
|
2021-03-16 19:03:48 +08:00
|
|
|
cp ${BASEPATH}/mindspore/lite/build/java/jni/libmindspore-lite-jni.so ${JAVA_PATH}/native/libs/arm64-v8a/
|
2020-09-28 10:57:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
build_jni_arm32() {
|
|
|
|
# build jni so
|
|
|
|
cd "${BASEPATH}/mindspore/lite/build"
|
2021-05-26 10:10:25 +08:00
|
|
|
[ -n "${BASEPATH}" ] && rm -rf java/jni
|
2021-03-16 19:03:48 +08:00
|
|
|
mkdir -pv java/jni
|
|
|
|
cd java/jni
|
2020-09-28 10:57:29 +08:00
|
|
|
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} \
|
2021-02-24 17:24:12 +08:00
|
|
|
-DSUPPORT_TRAIN=${SUPPORT_TRAIN} -DPLATFORM_ARM32=on "${JAVA_PATH}/native"
|
2020-09-28 10:57:29 +08:00
|
|
|
make -j$THREAD_NUM
|
2020-12-10 21:39:36 +08:00
|
|
|
if [[ $? -ne 0 ]]; then
|
2020-09-28 10:57:29 +08:00
|
|
|
echo "---------------- mindspore lite: build jni arm32 failed----------------"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
mkdir -p ${JAVA_PATH}/java/app/libs/armeabi-v7a/
|
2021-03-16 19:03:48 +08:00
|
|
|
cp ${BASEPATH}/mindspore/lite/build/java/jni/libmindspore-lite-jni.so ${JAVA_PATH}/java/app/libs/armeabi-v7a/
|
2021-02-24 17:24:12 +08:00
|
|
|
mkdir -p ${JAVA_PATH}/native/libs/armeabi-v7a/
|
2021-03-16 19:03:48 +08:00
|
|
|
cp ${BASEPATH}/mindspore/lite/build/java/jni/libmindspore-lite-jni.so ${JAVA_PATH}/native/libs/armeabi-v7a/
|
2021-02-24 17:24:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
build_jni_x86_64() {
|
|
|
|
# build jni so
|
|
|
|
cd "${BASEPATH}/mindspore/lite/build"
|
2021-05-26 10:10:25 +08:00
|
|
|
[ -n "${BASEPATH}" ] && rm -rf java/jni
|
2021-03-16 19:03:48 +08:00
|
|
|
mkdir -pv java/jni
|
|
|
|
cd java/jni
|
2021-02-24 17:24:12 +08:00
|
|
|
cmake -DMS_VERSION_MAJOR=${VERSION_MAJOR} -DMS_VERSION_MINOR=${VERSION_MINOR} -DMS_VERSION_REVISION=${VERSION_REVISION} \
|
2021-03-24 09:17:51 +08:00
|
|
|
-DENABLE_VERBOSE=${ENABLE_VERBOSE} -DSUPPORT_TRAIN=${SUPPORT_TRAIN} "${JAVA_PATH}/native/"
|
2021-02-24 17:24:12 +08:00
|
|
|
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/
|
2021-03-16 19:03:48 +08:00
|
|
|
cp ${BASEPATH}/mindspore/lite/build/java/jni/libmindspore-lite-jni.so ${JAVA_PATH}/java/linux_x86/libs/
|
2021-02-24 17:24:12 +08:00
|
|
|
mkdir -p ${JAVA_PATH}/native/libs/linux_x86/
|
2021-03-16 19:03:48 +08:00
|
|
|
cp ${BASEPATH}/mindspore/lite/build/java/jni/libmindspore-lite-jni.so ${JAVA_PATH}/native/libs/linux_x86/
|
2021-02-24 17:24:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
check_java_home() {
|
|
|
|
if [ "${JAVA_PATH}" ]; 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"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-09-28 10:57:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
build_java() {
|
2021-02-24 17:24:12 +08:00
|
|
|
JAVA_PATH=${BASEPATH}/mindspore/lite/java
|
|
|
|
get_version
|
2021-03-16 19:03:48 +08:00
|
|
|
if [[ "X${INC_BUILD}" == "Xoff" ]]; then
|
2021-05-26 10:10:25 +08:00
|
|
|
[ -n "${BASEPATH}" ] && rm -rf ${BASEPATH}/mindspore/lite/build
|
2021-03-16 19:03:48 +08:00
|
|
|
fi
|
2021-02-24 17:24:12 +08:00
|
|
|
# build common module
|
|
|
|
cd ${JAVA_PATH}/java/common
|
|
|
|
gradle clean
|
|
|
|
gradle build
|
|
|
|
|
|
|
|
# build aar
|
|
|
|
build_lite_java_arm64
|
|
|
|
build_jni_arm64
|
|
|
|
build_lite_java_arm32
|
|
|
|
build_jni_arm32
|
|
|
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
2021-03-24 09:17:51 +08:00
|
|
|
local inference_or_train=inference
|
|
|
|
if [[ "X$SUPPORT_TRAIN" = "Xon" ]]; then
|
|
|
|
inference_or_train=train
|
|
|
|
fi
|
|
|
|
|
2021-02-24 17:24:12 +08:00
|
|
|
# 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
|
2021-03-24 09:17:51 +08:00
|
|
|
cp ${JAVA_PATH}/java/linux_x86/libs/*.so* ${JAVA_PATH}/java/linux_x86/build/lib/jar
|
2021-03-12 17:42:00 +08:00
|
|
|
cd ${JAVA_PATH}/java/linux_x86/build/
|
2021-03-24 09:17:51 +08:00
|
|
|
|
2021-05-26 10:10:25 +08:00
|
|
|
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}
|
2021-02-24 17:24:12 +08:00
|
|
|
# copy output
|
2021-03-23 10:21:01 +08:00
|
|
|
cp ${JAVA_PATH}/java/app/build/mindspore-lite-maven-${VERSION_STR}.zip ${BASEPATH}/output
|
2021-05-26 10:10:25 +08:00
|
|
|
cp ${local_pkg_name}.tar.gz ${BASEPATH}/output
|
2021-03-24 09:17:51 +08:00
|
|
|
|
2021-03-12 17:42:00 +08:00
|
|
|
cd ${BASEPATH}/output
|
2021-05-26 10:10:25 +08:00
|
|
|
[ -n "${BASEPATH}" ] && rm -rf ${BASEPATH}/mindspore/lite/build/java/mindspore-lite-${VERSION_STR}-${inference_or_train}-linux-x64
|
2021-02-24 17:24:12 +08:00
|
|
|
exit 0
|
2020-09-28 10:57:29 +08:00
|
|
|
}
|
|
|
|
|
2020-10-26 09:39:49 +08:00
|
|
|
make_clean()
|
|
|
|
{
|
2021-01-23 11:51:26 +08:00
|
|
|
echo "enable make clean"
|
2020-10-26 09:39:49 +08:00
|
|
|
cd "${BUILD_PATH}/mindspore"
|
|
|
|
cmake --build . --target clean
|
|
|
|
}
|
|
|
|
|
2021-04-29 09:10:45 +08:00
|
|
|
OS=$(uname)
|
2020-07-29 02:16:33 +08:00
|
|
|
if [[ "X$COMPILE_LITE" = "Xon" ]]; then
|
2020-09-28 10:57:29 +08:00
|
|
|
if [[ "X$LITE_LANGUAGE" = "Xjava" ]]; then
|
|
|
|
build_java
|
|
|
|
else
|
2020-07-29 02:16:33 +08:00
|
|
|
build_lite
|
2020-09-28 10:57:29 +08:00
|
|
|
fi
|
2020-03-27 14:49:12 +08:00
|
|
|
else
|
|
|
|
build_mindspore
|
|
|
|
fi
|
|
|
|
|
2020-10-26 09:39:49 +08:00
|
|
|
if [[ "X$ENABLE_MAKE_CLEAN" = "Xon" ]]; then
|
|
|
|
make_clean
|
|
|
|
fi
|
|
|
|
|
2021-05-26 11:31:02 +08:00
|
|
|
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
|
2021-04-29 09:10:45 +08:00
|
|
|
|
2020-03-27 14:49:12 +08:00
|
|
|
echo "---------------- mindspore: build end ----------------"
|