1#!/bin/bash 2# Copyright 2019-2021 Huawei Technologies Co., Ltd 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# ============================================================================ 16 17set -e 18BASEPATH=$(cd "$(dirname $0)"; pwd) 19export CUDA_PATH="" 20export BUILD_PATH="${BASEPATH}/build/" 21 22source ./scripts/build/usage.sh 23source ./scripts/build/default_options.sh 24source ./scripts/build/option_proc_debug.sh 25source ./scripts/build/option_proc_mindspore.sh 26source ./scripts/build/option_proc_lite.sh 27source ./scripts/build/process_options.sh 28source ./scripts/build/parse_device.sh 29source ./scripts/build/build_mindspore.sh 30 31# check value of input is 'on' or 'off' 32# usage: check_on_off arg_value arg_name 33check_on_off() 34{ 35 if [[ "X$1" != "Xon" && "X$1" != "Xoff" ]]; then 36 echo "Invalid value $1 for option -$2" 37 usage 38 exit 1 39 fi 40} 41 42update_submodule() 43{ 44 git submodule update --init graphengine 45 cd "${BASEPATH}/graphengine" 46 git submodule update --init metadef 47 cd "${BASEPATH}" 48 if [[ "X$ENABLE_AKG" = "Xon" ]] && [[ "X$ENABLE_D" = "Xon" || "X$ENABLE_GPU" = "Xon" ]]; then 49 git submodule update --init --recursive akg 50 fi 51} 52 53build_exit() 54{ 55 echo "$@" >&2 56 stty echo 57 exit 1 58} 59 60 61make_clean() 62{ 63 echo "enable make clean" 64 cd "${BUILD_PATH}/mindspore" 65 cmake --build . --target clean 66} 67 68echo "---------------- MindSpore: build start ----------------" 69init_default_options 70process_options "$@" 71parse_device 72 73if [[ "X$COMPILE_LITE" = "Xon" ]]; then 74 export COMPILE_MINDDATA_LITE 75 export ENABLE_VERBOSE 76 export LITE_PLATFORM 77 export LITE_ENABLE_AAR 78 export MSLITE_MINDDATA_IMPLEMENT=off 79 export MSLITE_ENABLE_TRAIN=off 80 source mindspore/lite/build_lite.sh 81else 82 mkdir -pv "${BUILD_PATH}/package/mindspore/lib" 83 update_submodule 84 85 build_mindspore 86 87 if [[ "X$ENABLE_MAKE_CLEAN" = "Xon" ]]; then 88 make_clean 89 fi 90 if [[ "X$ENABLE_ACL" == "Xon" ]] && [[ "X$ENABLE_D" == "Xoff" ]]; then 91 echo "acl mode, skipping deploy phase" 92 rm -rf ${BASEPATH}/output/_CPack_Packages/ 93 else 94 cp -rf ${BUILD_PATH}/package/mindspore/lib ${BASEPATH}/mindspore 95 cp -rf ${BUILD_PATH}/package/mindspore/*.so ${BASEPATH}/mindspore 96 fi 97fi 98echo "---------------- MindSpore: build end ----------------" 99