diff --git a/mindspore/lite/test/codegen/models_codegen_parallel.cfg b/mindspore/lite/test/codegen/models_codegen_parallel.cfg new file mode 100644 index 00000000000..696f82cd629 --- /dev/null +++ b/mindspore/lite/test/codegen/models_codegen_parallel.cfg @@ -0,0 +1 @@ +intent_detect_hi_v2.tflite diff --git a/mindspore/lite/test/st/scripts/run_benchmark_x86.sh b/mindspore/lite/test/st/scripts/run_benchmark_x86.sh index 23ec599404b..af08a3c435b 100644 --- a/mindspore/lite/test/st/scripts/run_benchmark_x86.sh +++ b/mindspore/lite/test/st/scripts/run_benchmark_x86.sh @@ -1257,21 +1257,15 @@ function Run_x86_codegen() { continue fi echo ${model_name} >> "${run_x86_codegen_log_file}" - local PARALLEL=$1 - ${CODEGEN_PATH}/codegen --codePath=${build_path} --modelPath=${ms_models_path}/${model_name}.ms --supportParallel=${PARALLEL} >> ${run_x86_codegen_log_file} + ${CODEGEN_PATH}/codegen --codePath=${build_path} --modelPath=${ms_models_path}/${model_name}.ms >> ${run_x86_codegen_log_file} # 1. build benchmark mkdir -p ${build_path}/${model_name}/build && cd ${build_path}/${model_name}/build || exit 1 cmake -DPKG_PATH=${x86_path}/mindspore-lite-${version}-inference-linux-x64 ${build_path}/${model_name} >> ${run_x86_codegen_log_file} make >> ${run_x86_codegen_log_file} # 2. run benchmark echo "net file: ${build_path}/${model_name}/src/net.bin" >> ${run_x86_codegen_log_file} - if [[ "${PARALLEL}" == "false" ]]; then - echo "./benchmark ${models_path}/input_output/input/${model_name}.ms.bin ${build_path}/${model_name}/src/net.bin 1 ${models_path}/input_output/output/${model_name}.ms.out" >> ${run_x86_codegen_log_file} - ./benchmark ${models_path}/input_output/input/${model_name}.ms.bin ${build_path}/${model_name}/src/net.bin 1 ${models_path}/input_output/output/${model_name}.ms.out >> ${run_x86_codegen_log_file} - else - echo "./benchmark ${models_path}/input_output/input/${model_name}.ms.bin ${build_path}/${model_name}/src/net.bin 1 ${models_path}/input_output/output/${model_name}.ms.out 4 0" >> ${run_x86_codegen_log_file} - ./benchmark ${models_path}/input_output/input/${model_name}.ms.bin ${build_path}/${model_name}/src/net.bin 1 ${models_path}/input_output/output/${model_name}.ms.out 4 0 >> ${run_x86_codegen_log_file} - fi + echo "./benchmark ${models_path}/input_output/input/${model_name}.ms.bin ${build_path}/${model_name}/src/net.bin 1 ${models_path}/input_output/output/${model_name}.ms.out" >> ${run_x86_codegen_log_file} + ./benchmark ${models_path}/input_output/input/${model_name}.ms.bin ${build_path}/${model_name}/src/net.bin 1 ${models_path}/input_output/output/${model_name}.ms.out >> ${run_x86_codegen_log_file} if [ $? = 0 ]; then run_result='x86_codegen: '${model_name}' pass'; echo ${run_result} >> ${run_benchmark_result_file} else @@ -1282,6 +1276,38 @@ function Run_x86_codegen() { rm -rf ${build_path} } +# Run on x86 codegen benchmark parallel +function Run_x86_codegen_parallel() { + local CODEGEN_PATH=${x86_path}/mindspore-lite-${version}-inference-linux-x64/tools/codegen + + rm -rf ${build_parallal_path} + mkdir -p ${build_parallal_path} + + while read line; do + model_name=${line} + if [[ $model_name == \#* ]]; then + continue + fi + echo ${model_name} >> "${run_x86_codegen_parallel_log_file}" + ${CODEGEN_PATH}/codegen --codePath=${build_parallal_path} --modelPath=${ms_models_path}/${model_name}.ms --supportParallel=true >> ${run_x86_codegen_parallel_log_file} + # 1. build benchmark + mkdir -p ${build_parallal_path}/${model_name}/build && cd ${build_parallal_path}/${model_name}/build || exit 1 + cmake -DPKG_PATH=${x86_path}/mindspore-lite-${version}-inference-linux-x64 ${build_parallal_path}/${model_name} >> ${run_x86_codegen_parallel_log_file} + make >> ${run_x86_codegen_parallel_log_file} + # 2. run benchmark + echo "net file: ${build_parallal_path}/${model_name}/src/net.bin" >> ${run_x86_codegen_parallel_log_file} + echo "./benchmark ${models_path}/input_output/input/${model_name}.ms.bin ${build_parallal_path}/${model_name}/src/net.bin 1 ${models_path}/input_output/output/${model_name}.ms.out thread_num=4 0" >> ${run_x86_codegen_parallel_log_file} + ./benchmark ${models_path}/input_output/input/${model_name}.ms.bin ${build_parallal_path}/${model_name}/src/net.bin 1 ${models_path}/input_output/output/${model_name}.ms.out 4 0 >> ${run_x86_codegen_parallel_log_file} + if [ $? = 0 ]; then + run_result='x86_codegen_parallel: '${model_name}' pass'; echo ${run_result} >> ${run_benchmark_result_file} + else + run_result='x86_codegen_parallel: '${model_name}' failed'; echo ${run_result} >> ${run_benchmark_result_file}; return 1 + fi + done < ${models_codegen_parallel_config} + + rm -rf ${build_parallal_path} +} + # Print start msg before run testcase function MS_PRINT_TESTCASE_START_MSG() { echo "" @@ -1363,9 +1389,11 @@ models_with_multiple_inputs_config=${basepath}/../config/models_with_multiple_in models_for_process_only_config=${basepath}/../config/models_for_process_only.cfg models_tf_weightquant_config=${basepath}/../config/models_tf_weightquant.cfg models_codegen_config=${basepath}/../codegen/models_codegen.cfg +models_codegen_parallel_config=${basepath}/../codegen/models_codegen_parallel.cfg ms_models_path=${basepath}/ms_models build_path=${basepath}/codegen_build +build_parallal_path=${basepath}/codegen_parallel_build # Write converter result to temp file run_converter_log_file=${basepath}/run_converter_log.txt @@ -1413,6 +1441,9 @@ echo 'run x86 java logs: ' > ${run_x86_java_log_file} run_x86_codegen_log_file=${basepath}/run_x86_codegen_log.txt echo 'run x86 codegen logs: ' > ${run_x86_codegen_log_file} +run_x86_codegen_parallel_log_file=${basepath}/run_x86_codegen_parallel_log.txt +echo 'run x86 codegen parallel logs: ' > ${run_x86_codegen_parallel_log_file} + backend=${backend:-"all"} isFailed=0 @@ -1448,13 +1479,21 @@ if [[ $backend == "all" || $backend == "x86-all" || $backend == "x86-java" ]]; t fi if [[ $backend == "all" || $backend == "x86-all" || $backend == "x86-codegen" ]]; then - # Run on x86-java + # Run on x86-codegen echo "start Run x86 codegen ..." - Run_x86_codegen "false" & + Run_x86_codegen & Run_x86_codegen_PID=$! sleep 1 fi +if [[ $backend == "all" || $backend == "x86-all" || $backend == "x86-codegen-parallel" ]]; then + # Run on x86-codegen-parallel + echo "start Run x86 codegen parallel ..." + Run_x86_codegen_parallel & + Run_x86_codegen_parallel_PID=$! + sleep 1 +fi + if [[ $backend == "all" || $backend == "x86-all" || $backend == "x86-sse" ]]; then wait ${Run_x86_sse_PID} Run_x86_sse_status=$? @@ -1509,6 +1548,17 @@ if [[ $backend == "all" || $backend == "x86-all" || $backend == "x86-codegen" ]] fi fi +if [[ $backend == "all" || $backend == "x86-all" || $backend == "x86-codegen-parallel" ]]; then + wait ${Run_x86_codegen_parallel_PID} + Run_x86_codegen_parallel_status=$? + + if [[ ${Run_x86_codegen_parallel_status} != 0 ]];then + echo "Run_x86 codegen parallel failed" + cat ${run_x86_codegen_log_file} + isFailed=1 + fi +fi + echo "Run_x86 and Run_x86_sse and Run_x86_avx and is ended" Print_Benchmark_Result if [[ $isFailed == 1 ]]; then