• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright 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
18
19# Create building path
20build_mindspore()
21{
22    echo "start build mindspore project."
23    mkdir -pv "${BUILD_PATH}/mindspore"
24    cd "${BUILD_PATH}/mindspore"
25    CMAKE_ARGS="-DDEBUG_MODE=$DEBUG_MODE -DBUILD_PATH=$BUILD_PATH"
26    if [[ "X$ENABLE_COVERAGE" = "Xon" ]]; then
27      CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_COVERAGE=ON"
28    fi
29    if [[ "X$RUN_TESTCASES" = "Xon" ]]; then
30      CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_TESTCASES=ON"
31    fi
32    if [[ "X$RUN_CPP_ST_TESTS" = "Xon" ]]; then
33      CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_CPP_ST=ON"
34    fi
35    if [[ -n "$ENABLE_BACKEND" ]]; then
36      CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_${ENABLE_BACKEND}=ON"
37    fi
38    if [[ "X$ENABLE_SYM_FILE" = "Xon" ]]; then
39        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_SYM_FILE=ON"
40    fi
41    if [[ "X$ENABLE_ASAN" = "Xon" ]]; then
42        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_ASAN=ON"
43    fi
44    if [[ "X$ENABLE_PROFILE" = "Xon" ]]; then
45        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_PROFILE=ON"
46    fi
47    if [[ "X$ENABLE_SECURITY" = "Xon" ]]; then
48        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_SECURITY=ON"
49    fi
50    if [[ "X$ENABLE_TIMELINE" = "Xon" ]]; then
51        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_TIMELINE=ON"
52    fi
53    if [[ "X$ENABLE_DUMP2PROTO" = "Xon" ]]; then
54        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_DUMP_PROTO=ON"
55    fi
56    if [[ "X$ENABLE_GITEE" = "Xon" ]]; then
57        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_GITEE=ON"
58    fi
59    CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_DUMP_IR=${ENABLE_DUMP_IR}"
60    CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_PYTHON=${ENABLE_PYTHON}"
61    if [[ "X$ENABLE_MPI" = "Xon" ]]; then
62        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_MPI=ON"
63    fi
64    if [[ "X$ENABLE_D" = "Xon" ]]; then
65        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_D=ON -DASCEND_VERSION=${ASCEND_VERSION}"
66    fi
67    if [[ "X$ENABLE_GPU" = "Xon" ]]; then
68        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_GPU=ON"
69    fi
70    if [[ "X$GPU_BACKEND" = "Xrocm" ]]; then
71        CMAKE_ARGS="${CMAKE_ARGS} -DGPU_BACKEND_ROCM=ON -DROCM_PATH=$ROCM_PATH"
72    fi
73    if [[ "X$GPU_BACKEND" = "Xcuda" ]]; then
74        CMAKE_ARGS="${CMAKE_ARGS}  -DGPU_BACKEND_CUDA=ON -DUSE_CUDA=ON -DCUDA_PATH=$CUDA_PATH -DMS_REQUIRE_CUDA_VERSION=${CUDA_VERSION}"
75    fi
76    if [[ "X$ENABLE_CPU" = "Xon" ]]; then
77        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_CPU=ON -DX86_64_SIMD=${X86_64_SIMD} -DARM_SIMD=${ARM_SIMD}"
78    fi
79    if [[ "X$COMPILE_MINDDATA" = "Xon" ]]; then
80        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_MINDDATA=ON"
81    fi
82    if [[ "X$USE_GLOG" = "Xon" ]]; then
83        CMAKE_ARGS="${CMAKE_ARGS} -DUSE_GLOG=ON"
84    fi
85    if [[ "X$ENABLE_AKG" = "Xon" ]]; then
86        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_AKG=ON"
87        if [[ "X$USE_LLVM" = "Xon" ]]; then
88            CMAKE_ARGS="${CMAKE_ARGS} -DUSE_LLVM=ON"
89        fi
90    fi
91    if [[ "X$ENABLE_ACL" = "Xon" ]]; then
92        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_ACL=ON"
93    fi
94    if [[ "X$ENABLE_DEBUGGER" = "Xon" ]]; then
95        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_DEBUGGER=ON"
96    fi
97
98    if [[ "X$ENABLE_RDMA" = "Xon" ]]; then
99        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_RDMA=ON"
100    fi
101    if [[ "X$ENABLE_HIDDEN" = "Xoff" ]]; then
102        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_HIDDEN=OFF"
103    fi
104    if [[ "X$ENABLE_TRT" == "Xon" ]]; then
105        CMAKE_ARGS="${CMAKE_ARGS} -DTENSORRT_HOME=${TENSORRT_HOME}"
106    fi
107    if [[ "X$ENABLE_FAST_HASH_TABLE" == "Xon" ]]; then
108        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_FAST_HASH_TABLE=ON"
109    else
110        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_FAST_HASH_TABLE=OFF"
111    fi
112    if [[ "X$FASTER_BUILD_FOR_PLUGINS" == "Xon" ]]; then
113        CMAKE_ARGS="${CMAKE_ARGS} -DONLY_BUILD_DEVICE_PLUGINS=ON"
114    fi
115    if [[ "X$ENABLE_AIO" = "Xon" ]]; then
116        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_AIO=ON"
117    fi
118    if [[ "X$ENABLE_DVM" = "Xon" ]]; then
119        CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_DVM=ON"
120    fi
121    echo "${CMAKE_ARGS}"
122    if [[ "X$INC_BUILD" = "Xoff" ]]; then
123      cmake ${CMAKE_ARGS} ${BASEPATH}
124    fi
125    if [[ -n "$VERBOSE" ]]; then
126      CMAKE_VERBOSE="--verbose"
127    fi
128    cmake --build . --target package ${CMAKE_VERBOSE} -j$THREAD_NUM
129    echo "success building mindspore project!"
130}
131