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.

crc32.sh 2.9 kB

5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/bash
  2. # Copyright 2020 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. SCRIPT_BASEDIR=$(
  16. cd "$(dirname "$0")" || exit
  17. pwd
  18. )
  19. THIRD_PARTY_DIR=$(realpath "${SCRIPT_BASEDIR}/../../third_party")
  20. SECUREC_SOURCE_DIR="${THIRD_PARTY_DIR}/securec"
  21. build_securec() {
  22. CMAKE=$(command -v cmake)
  23. if [ -z "${CMAKE}" ]; then
  24. echo "Could not find cmake command"
  25. exit 1
  26. fi
  27. cd "${SECUREC_SOURCE_DIR}" || exit
  28. rm -rf build
  29. mkdir build
  30. cd build || exit
  31. ${CMAKE} ..
  32. make
  33. cd - >/dev/null 2>&1 || exit
  34. }
  35. build_crc32() {
  36. CPP=$(command -v c++)
  37. if [ -z "${CPP}" ]; then
  38. echo "Could not find c++ command"
  39. exit 1
  40. fi
  41. PYTHON=$(command -v python3 || command -v python)
  42. if [ -z "${PYTHON}" ]; then
  43. echo "Could not find python3 or python command"
  44. exit 1
  45. fi
  46. PYTHON_VERSION=$(${PYTHON} -c "import platform; print(platform.python_version())" | grep '^3.*')
  47. if [ -z "${PYTHON_VERSION}" ]; then
  48. echo "Could not find Python 3"
  49. exit 1
  50. fi
  51. DATAVISUAL_DIR=$(realpath "${SCRIPT_BASEDIR}/../../mindinsight/datavisual")
  52. CRC32_SOURCE_DIR="${DATAVISUAL_DIR}/utils/crc32"
  53. CRC32_OUTPUT_DIR="${DATAVISUAL_DIR}/utils"
  54. CRC32_SO_FILE="crc32$(python3-config --extension-suffix)"
  55. rm -f "${CRC32_SOURCE_DIR}/${CRC32_SO_FILE}"
  56. rm -f "${CRC32_OUTPUT_DIR}/${CRC32_SO_FILE}"
  57. cd "${CRC32_SOURCE_DIR}" || exit
  58. PYBIND11_INCLUDES=$(${PYTHON} -m pybind11 --includes)
  59. if [ -z "${PYBIND11_INCLUDES}" ]; then
  60. echo "Could not find pybind11 module"
  61. exit 1
  62. fi
  63. PYTHON_INCLUDE=$(echo "${PYBIND11_INCLUDES}" | awk '{print $1}' | sed "s/^-I//g")
  64. PYTHON_HEADERS=$(echo "${PYBIND11_INCLUDES}" | awk '{print $2}' | sed "s/^-I//g")
  65. ${CPP} -O2 -O3 -shared -std=c++11 -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 \
  66. -Wno-maybe-uninitialized -Wno-unused-parameter -Wall -Wl,-z,relro,-z,now,-z,noexecstack \
  67. -I"${THIRD_PARTY_DIR}" -I"${DATAVISUAL_DIR}/utils" -I"${PYTHON_INCLUDE}" -I"${PYTHON_HEADERS}" \
  68. -o "${CRC32_SO_FILE}" crc32.cc "${SECUREC_SOURCE_DIR}/build/src/libsecurec.a"
  69. if [ ! -f "${CRC32_SO_FILE}" ]; then
  70. echo "crc so file does not exist, build failed"
  71. exit 1
  72. fi
  73. mv "${CRC32_SO_FILE}" "${CRC32_OUTPUT_DIR}"
  74. }
  75. cd "${SCRIPT_BASEDIR}" || exit
  76. build_securec
  77. cd "${SCRIPT_BASEDIR}" || exit
  78. build_crc32

MindInsight为MindSpore提供了简单易用的调优调试能力。在训练过程中,可以将标量、张量、图像、计算图、模型超参、训练耗时等数据记录到文件中,通过MindInsight可视化页面进行查看及分析。

Contributors (1)