代码拉取完成,页面将自动刷新
同步操作将从 CANN/acl 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/bin/bash
# Copyright (c) 2024 Huawei Technologies Co., Ltd.
# This file is a part of the CANN Open Software.
# Licensed under CANN Open Software License Agreement Version 1.0 (the "License").
# Please refer to the License for details. You may not use this file except in compliance with the License.
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
# See LICENSE in the root of the software repository for the full text of the License.
# ======================================================================================================================
set -e
BASEPATH=$(cd "$(dirname $0)"; pwd)
OUTPUT_PATH="${BASEPATH}/output"
BUILD_RELATIVE_PATH="build"
BUILD_PATH="${BASEPATH}/${BUILD_RELATIVE_PATH}"
# print usage message
usage() {
echo "Usage:"
echo " sh build.sh [-h | --help] [-v | --verbose] [-j<N>]"
echo " [--ascend_install_path=<PATH>] [--ascend_3rd_lib_path=<PATH>]"
echo " [--platform=<PLATFORM>] [--product=<PRODUCT>]"
echo " [--ascendcl_c]"
echo ""
echo "Options:"
echo " -h, --help Print usage"
echo " -v, --verbose Display build command"
echo " -j<N> Set the number of threads used for building ACL, default is 8"
echo " --ascend_install_path=<PATH>"
echo " Set ascend package install path, default /usr/local/Ascend/ascend-toolkit/latest"
echo " --ascend_3rd_lib_path=<PATH>"
echo " Set ascend third_party package install path, default ./output/third_party"
echo " --platform=<PLATFORM>"
echo " Build inference or train"
echo " --product=<PRODUCT>"
echo " Product name"
echo " --ascendcl_c"
echo " Run ascendcl_c build, otherwise, run normal build"
echo ""
}
# parse and set options
checkopts() {
VERBOSE=""
THREAD_NUM=8
ASCENDCL_C="off"
PLATFORM=""
PRODUCT=""
ENABLE_ACL_UT="off"
ENABLE_ACL_COV="off"
ENABLE_C_UT="off"
ENABLE_C_COV="off"
ENABLE_GE_COMPILE="off"
ENABLE_ENGINES_COMPILE="off"
ENABLE_EXECUTOR_C_COMPILE="off"
BUILD_METADEF="off"
ASCEND_3RD_LIB_PATH="$BASEPATH/output/third_party"
CMAKE_BUILD_TYPE="Release"
if [ -z "$ASCEND_INSTALL_PATH" ]; then
ASCEND_INSTALL_PATH="/usr/local/Ascend/ascend-toolkit/latest"
fi
# Process the options
parsed_args=$(getopt -a -o j:hv -l help,verbose,ascend_install_path:,ascend_3rd_lib_path:,platform:,product:,ascendcl_c -- "$@") || {
usage
exit 1
}
eval set -- "$parsed_args"
while true; do
case "$1" in
-h | --help)
usage
exit 0
;;
-j)
THREAD_NUM="$2"
shift 2
;;
-v | --verbose)
VERBOSE="VERBOSE=1"
shift
;;
--ascend_install_path)
ASCEND_INSTALL_PATH="$(realpath $2)"
shift 2
;;
--ascend_3rd_lib_path)
ASCEND_3RD_LIB_PATH="$(realpath $2)"
shift 2
;;
--platform)
PLATFORM="$2"
shift 2
;;
--product)
PRODUCT="$2"
shift 2
;;
--ascendcl_c)
ASCENDCL_C="on"
shift
;;
--)
shift
break
;;
*)
echo "Undefined option: $1"
usage
exit 1
;;
esac
done
if [ "$ASCENDCL_C" = "off" ]; then
ENABLE_EXECUTOR_C_COMPILE="off"
if [ -z "$PLATFORM" ]; then
PLATFORM="all"
fi
if [ -z "$PRODUCT" ]; then
PRODUCT="normal"
fi
else
ENABLE_EXECUTOR_C_COMPILE="on"
if [ -z "$PLATFORM" ]; then
PLATFORM="tiny_arm"
fi
if [ -z "$PRODUCT" ]; then
PRODUCT="nano"
fi
fi
}
mk_dir() {
local create_dir="$1" # the target to make
mkdir -pv "${create_dir}"
echo "created ${create_dir}"
}
get_acl_type() {
if [ "$ASCENDCL_C" = "off" ]; then
echo "ACL"
else
echo "ACL_C"
fi
}
# create build path
build_acl() {
echo "create build directory and build $(get_acl_type)";
mk_dir "${BUILD_PATH}"
cd "${BUILD_PATH}"
CMAKE_ARGS="-DBUILD_OPEN_PROJECT=True \
-DENABLE_OPEN_SRC=True \
-DASCENDCL_C=${ASCENDCL_C} \
-DENABLE_GE_COMPILE=${ENABLE_GE_COMPILE} \
-DENABLE_ENGINES_COMPILE=${ENABLE_ENGINES_COMPILE} \
-DENABLE_EXECUTOR_C_COMPILE=${ENABLE_EXECUTOR_C_COMPILE} \
-DBUILD_METADEF=${BUILD_METADEF} \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX=${OUTPUT_PATH} \
-DASCEND_INSTALL_PATH=${ASCEND_INSTALL_PATH} \
-DASCEND_3RD_LIB_PATH=${ASCEND_3RD_LIB_PATH} \
-DENABLE_ACL_COV=${ENABLE_ACL_COV} \
-DENABLE_ACL_UT=${ENABLE_ACL_UT} \
-DENABLE_C_COV=${ENABLE_C_COV} \
-DENABLE_C_UT=${ENABLE_C_UT} \
-DPLATFORM=${PLATFORM} \
-DPRODUCT=${PRODUCT}"
echo "CMAKE_ARGS=${CMAKE_ARGS}"
cmake ${CMAKE_ARGS} ..
if [ $? -ne 0 ]; then
echo "execute command: cmake ${CMAKE_ARGS} .. failed."
return 1
fi
if [ "$ASCENDCL_C" = "off" ]; then
make ${VERBOSE} -j${THREAD_NUM} && make install
if [ $? -ne 0 ]; then
echo "execute command: make ${VERBOSE} -j${THREAD_NUM} && make install failed."
return 1
fi
make generate_install_script_acl package
if [ $? -ne 0 ]; then
echo "execute command: make package failed."
return 1
fi
else
make ${VERBOSE} ascendcl_c -j${THREAD_NUM}
if [ $? -ne 0 ]; then
echo "execute command: make ${VERBOSE} -j${THREAD_NUM} failed."
return 1
fi
fi
[ -n "$(ls ${OUTPUT_PATH}/CANN-*.run 2>/dev/null)" ] && mv -f ${OUTPUT_PATH}/CANN-*.run ${OUTPUT_PATH}/package/
echo "$(get_acl_type) build success!"
}
main() {
checkopts "$@"
# Acl build start
echo "---------------- $(get_acl_type) build start ----------------"
g++ -v
mk_dir ${OUTPUT_PATH}
build_acl
if [[ "$?" -ne 0 ]]; then
echo "$(get_acl_type) build failed.";
exit 1;
fi
echo "---------------- $(get_acl_type) build finished ----------------"
}
main "$@"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。