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.

dbg_dump_parser.sh 3.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #!/bin/bash
  2. # Copyright 2019 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 -x
  17. set -e
  18. export SAVE_GRAPHS=YES
  19. # print usage message
  20. function usage()
  21. {
  22. echo "Usage:"
  23. echo "bash $0 [-g] [-d] [-a] [-h] [-f file]"
  24. echo "e.g. $0 -f 3_specialize.dat"
  25. echo ""
  26. echo "Options:"
  27. echo " -g Generate ir file for debug"
  28. echo " -d Debug dumped ir"
  29. echo " -a Execute all steps, default"
  30. echo " -f File to be parse"
  31. echo " -h Print usage"
  32. }
  33. # check and set options
  34. function checkopts()
  35. {
  36. # init variable
  37. MODE_GEN=0
  38. MODE_DBG=1
  39. MODE_ALL=2
  40. FILE_NAME="3_optimize.dat"
  41. mode="${MODE_ALL}" # default execute all steps
  42. # Process the options
  43. while getopts 'gdaf:h' opt
  44. do
  45. case "${opt}" in
  46. g)
  47. mode="${MODE_GEN}"
  48. ;;
  49. d)
  50. mode="${MODE_DBG}"
  51. ;;
  52. a)
  53. mode="${MODE_ALL}"
  54. ;;
  55. f)
  56. FILE_NAME="$OPTARG"
  57. if ! [ -f "${FILE_NAME}" ]; then
  58. echo "File $FILE_NAME does not exist"
  59. usage
  60. exit 1
  61. fi
  62. ;;
  63. h)
  64. usage
  65. exit 0
  66. ;;
  67. *)
  68. echo "Unknown option ${opt}!"
  69. usage
  70. exit 1
  71. esac
  72. done
  73. }
  74. # init variable
  75. # check options
  76. checkopts "$@"
  77. CUR_PATH=$(pwd)
  78. cd "`dirname $0`/.."
  79. cd build/mindspore/
  80. make -j8
  81. cp -v mindspore/ccsrc/_c_expression.cpython-*.so ../../mindspore/
  82. cd -
  83. UT_NAME="./tests/ut/python/model/test_lenet.py::test_lenet5_train_sens"
  84. #UT_NAME="./tests/python/ops/test_math_ops.py::test_matmul_grad"
  85. #UT_NAME="./tests/python/exec/resnet_example.py::test_compile"
  86. #UT_NAME="./tests/perf_test/test_bert_train.py::test_bert_train"
  87. if [[ "${mode}" == "${MODE_GEN}" || "${mode}" == "${MODE_ALL}" ]]; then
  88. rm -rf pkl_objs
  89. mkdir -p pkl_objs
  90. echo "MS_IR_PATH=$(pwd)/pkl_objs pytest -s ${UT_NAME}"
  91. MS_IR_PATH=$(pwd)/pkl_objs/ pytest -s "${UT_NAME}"
  92. #pytest -s $UT_NAME
  93. # 1_resolve.dat
  94. # 3_specialize.dat
  95. # 4_simplify_data_structures.dat
  96. # 5_opt.dat
  97. # 6_opt2.dat
  98. # 7_opt_ge_adaptor_special.dat
  99. # 8_cconv.dat
  100. # 9_validate.dat
  101. cp "${FILE_NAME}" anf_ir_file.dbg
  102. rm -rf pkl_objs.dbg
  103. cp -rf pkl_objs pkl_objs.dbg
  104. fi
  105. if [[ "${mode}" == "${MODE_DBG}" || "${mode}" == "${MODE_ALL}" ]]; then
  106. echo "MS_IR_FILE=$(pwd)/anf_ir_file.dbg MS_IR_PATH=$(pwd)/pkl_objs.dbg/ pytest -s ${UT_NAME}"
  107. MS_IR_FILE=$(pwd)/anf_ir_file.dbg MS_IR_PATH=$(pwd)/pkl_objs.dbg/ pytest -s "${UT_NAME}"
  108. fi
  109. cd $CUR_PATH