test_train_inference_python_xpu.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/bash
  2. source test_tipc/common_func.sh
  3. function readlinkf() {
  4. perl -MCwd -e 'print Cwd::abs_path shift' "$1";
  5. }
  6. function func_parser_config() {
  7. strs=$1
  8. IFS=" "
  9. array=(${strs})
  10. tmp=${array[2]}
  11. echo ${tmp}
  12. }
  13. BASEDIR=$(dirname "$0")
  14. REPO_ROOT_PATH=$(readlinkf ${BASEDIR}/../)
  15. FILENAME=$1
  16. # disable mkldnn on non x86_64 env
  17. arch=$(uname -i)
  18. if [ $arch != 'x86_64' ]; then
  19. sed -i 's/--enable_mkldnn:True|False/--enable_mkldnn:False/g' $FILENAME
  20. sed -i 's/--enable_mkldnn:True/--enable_mkldnn:False/g' $FILENAME
  21. fi
  22. # change gpu to xpu in tipc txt configs
  23. sed -i 's/use_gpu/use_xpu/g' $FILENAME
  24. # disable benchmark as AutoLog required nvidia-smi command
  25. sed -i 's/--benchmark:True/--benchmark:False/g' $FILENAME
  26. dataline=`cat $FILENAME`
  27. # parser params
  28. IFS=$'\n'
  29. lines=(${dataline})
  30. # replace training config file
  31. grep -n 'tools/.*yml' $FILENAME | cut -d ":" -f 1 \
  32. | while read line_num ; do
  33. train_cmd=$(func_parser_value "${lines[line_num-1]}")
  34. trainer_config=$(func_parser_config ${train_cmd})
  35. sed -i 's/use_gpu/use_xpu/g' "$REPO_ROOT_PATH/$trainer_config"
  36. done
  37. # change gpu to xpu in execution script
  38. sed -i 's/\"gpu\"/\"xpu\"/g' test_tipc/test_train_inference_python.sh
  39. # pass parameters to test_train_inference_python.sh
  40. cmd='bash test_tipc/test_train_inference_python.sh ${FILENAME} $2'
  41. echo -e '\033[1;32m Started to run command: ${cmd}! \033[0m'
  42. eval $cmd