You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ge_update.sh 5.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. set -e
  17. PROJECT_HOME=${PROJECT_HOME:-$(dirname "$0")/../../}
  18. PROJECT_HOME=$(cd $PROJECT_HOME || return; pwd)
  19. DOWNLOAD_PATH=${PROJECT_HOME}/deps
  20. DEP_LIB_DIR=./lib
  21. DEP_TMP_DIR=./tmp
  22. function extract_deps_so()
  23. {
  24. echo "begin to extract .run file ........."
  25. chmod 777 ./${DRIVER_RUN_NAME}
  26. unzip ${DEV_TOOLS_PACKAGE}.zip
  27. chmod -R 777 ${DEV_TOOLS_PACKAGE}
  28. [ -n "${DEP_TMP_DIR}" ] && rm -rf "${DEP_TMP_DIR}"
  29. ./${DRIVER_RUN_NAME} --noexec --extract=${DEP_TMP_DIR}/driver
  30. ./${DEV_TOOLS_PACKAGE}/${ATC_RUN_NAME} --noexec --extract=${DEP_TMP_DIR}/atc
  31. ./${DEV_TOOLS_PACKAGE}/${ACL_RUN_NAME} --noexec --extract=${DEP_TMP_DIR}/acllib
  32. ./${DEV_TOOLS_PACKAGE}/${FWKACL_RUN_NAME} --noexec --extract=${DEP_TMP_DIR}/fwkacllib
  33. }
  34. function extract_deps_so_community()
  35. {
  36. echo "begin to extract .run file ........."
  37. chmod +x ./${DRIVER_RUN_NAME_C}
  38. chmod +X ./${PACKAGE_NAME_C}
  39. [ -n "${DEP_TMP_DIR}" ] && rm -rf "${DEP_TMP_DIR}"
  40. ./${DRIVER_RUN_NAME_C} --noexec --extract=${DEP_TMP_DIR}/driver
  41. ./${PACKAGE_NAME_C} --noexec --extract=${DEP_TMP_DIR}/Packages_tmp
  42. ${DEP_TMP_DIR}/Packages_tmp/run_package/${ATC_RUN_NAME_C} --noexec --extract=${DEP_TMP_DIR}/atc
  43. ${DEP_TMP_DIR}/Packages_tmp/run_package/${ACL_RUN_NAME_C} --noexec --extract=${DEP_TMP_DIR}/acllib
  44. ${DEP_TMP_DIR}/Packages_tmp/run_package/${FWKACL_RUN_NAME_C} --noexec --extract=${DEP_TMP_DIR}/fwkacllib
  45. }
  46. function copy_so_to_target_dir()
  47. {
  48. mkdir -p $DEP_LIB_DIR
  49. mv ${DEP_TMP_DIR}/driver/driver $DEP_LIB_DIR/driver
  50. mv ${DEP_TMP_DIR}/atc/atc $DEP_LIB_DIR/atc
  51. mv ${DEP_TMP_DIR}/acllib/acllib $DEP_LIB_DIR/acllib
  52. mv ${DEP_TMP_DIR}/fwkacllib/fwkacllib $DEP_LIB_DIR/fwkacllib
  53. }
  54. function clear_libs()
  55. {
  56. [ -n "${DOWNLOAD_PATH}" ] && rm -rf "${DOWNLOAD_PATH}"
  57. }
  58. function download_runs()
  59. {
  60. source scripts/update/deps_config.sh
  61. echo "begin to download .run file ........."
  62. clear_libs
  63. mkdir -p ./ ${DOWNLOAD_PATH}
  64. pushd "${DOWNLOAD_PATH}" >/dev/null
  65. cd ${DOWNLOAD_PATH}
  66. wget --user=${DEP_USER} --password=${DEP_PASSWORD} ${DRIVER_URL}
  67. wget --user=${DEP_USER} --password=${DEP_PASSWORD} ${DEV_TOOLS_URL}
  68. popd >/dev/null
  69. }
  70. function download_runs_from_community
  71. {
  72. source scripts/update/deps_config_community.sh
  73. echo "begin to download .run file from community........."
  74. clear_libs
  75. mkdir -p ./ ${DOWNLOAD_PATH}
  76. pushd "${DOWNLOAD_PATH}" >/dev/null
  77. cd ${DOWNLOAD_PATH}
  78. wget ${DRIVER_URL_C}
  79. wget ${PACKAGE_URL_C}
  80. popd >/dev/null
  81. }
  82. function install_deps()
  83. {
  84. source scripts/update/deps_config.sh
  85. mkdir -p ./ ${DOWNLOAD_PATH}
  86. pushd "${DOWNLOAD_PATH}" >/dev/null
  87. cd ${DOWNLOAD_PATH}
  88. extract_deps_so
  89. copy_so_to_target_dir
  90. popd >/dev/null
  91. }
  92. function install_deps_community()
  93. {
  94. source scripts/update/deps_config_community.sh
  95. mkdir -p ./ ${DOWNLOAD_PATH}
  96. pushd "${DOWNLOAD_PATH}" >/dev/null
  97. cd ${DOWNLOAD_PATH}
  98. extract_deps_so_community
  99. copy_so_to_target_dir
  100. popd >/dev/null
  101. }
  102. function help(){
  103. cat <<-EOF
  104. Usage: ge update [OPTIONS]
  105. update dependencies of build and test
  106. Options:
  107. -p, --public Download dependencies from community
  108. -d, --download Download dependencies
  109. -i, --install Install dependencies
  110. -c, --clear Clear dependencies
  111. -h, --help
  112. EOF
  113. }
  114. function parse_args(){
  115. parsed_args=$(getopt -a -o pdich --long public,download,install,clear,help -- "$@") || {
  116. help
  117. exit 1
  118. }
  119. if [ $# -lt 1 ]; then
  120. download_runs_from_community
  121. install_deps_community
  122. exit 1
  123. fi
  124. eval set -- "$parsed_args"
  125. while true; do
  126. case "$1" in
  127. -p | --public)
  128. download_runs_from_community
  129. install_deps_community
  130. ;;
  131. -d | --download)
  132. download_runs
  133. ;;
  134. -i | --install)
  135. install_deps
  136. ;;
  137. -c | --clear)
  138. clear_libs
  139. ;;
  140. -h | --help)
  141. help; exit 1;
  142. ;;
  143. --)
  144. shift; break;
  145. ;;
  146. *)
  147. help; exit 1
  148. ;;
  149. esac
  150. shift
  151. done
  152. }
  153. function main(){
  154. parse_args "$@"
  155. }
  156. main "$@"
  157. set +e

图引擎模块(GE)是MindSpore的一个子模块,其代码由C++实现,位于前端模块ME和底层硬件之间,起到承接作用。图引擎模块以ME下发的图作为输入,然后进行一系列的深度图优化操作,最后输出一张可以在底层硬件上高效运行的图。GE针对昇腾AI处理器的硬件结构特点,做了特定的优化工作,以此来充分发挥出昇腾AI处理器的强大算力。在进行模型训练/推理时,GE会被自动调用而用户并不感知。GE主要由GE API和GE Core两部分组成,详细的架构图如下所示