From 0927444b54427f29f94bcd85c42423368089d45c Mon Sep 17 00:00:00 2001 From: wangna11BD <79366697+wangna11BD@users.noreply.github.com> Date: Mon, 13 Mar 2023 19:51:20 +0800 Subject: [PATCH] fix TIPC bug for cafe67538 (#765) * fix TIPC bug for cafe67538 * fix style for TIPC --- test_tipc/benchmark_train.sh | 25 ++++++++++++------- .../configs/CycleGAN/train_infer_python.txt | 4 ++- .../configs/Pix2pix/train_infer_python.txt | 4 ++- test_tipc/configs/edvr/train_infer_python.txt | 6 +++-- .../configs/esrgan/train_infer_python.txt | 6 +++-- .../configs/msvsr/train_infer_python.txt | 6 +++-- test_tipc/test_train_inference_python.sh | 10 +++++--- 7 files changed, 41 insertions(+), 20 deletions(-) diff --git a/test_tipc/benchmark_train.sh b/test_tipc/benchmark_train.sh index d5e225d..76e1413 100644 --- a/test_tipc/benchmark_train.sh +++ b/test_tipc/benchmark_train.sh @@ -67,6 +67,14 @@ FILENAME=$new_filename # MODE must be one of ['benchmark_train'] MODE=$2 PARAMS=$3 +REST_ARGS=$4 + +to_static="" +# parse "to_static" options and modify trainer into "to_static_trainer" +if [[ $PARAMS =~ "dynamicTostatic" ]] ;then + to_static="d2sT_" + sed -i 's/trainer:norm_train/trainer:to_static_train/g' $FILENAME +fi IFS=$'\n' # parser params from train_benchmark.txt @@ -77,7 +85,7 @@ lines=(${dataline}) model_name=$(func_parser_value "${lines[1]}") # 获取benchmark_params所在的行数 -line_num=`grep -n "train_benchmark_params" $FILENAME | cut -d ":" -f 1` +line_num=`grep -n -w "train_benchmark_params" $FILENAME | cut -d ":" -f 1` # for train log parser batch_size=$(func_parser_value "${lines[line_num]}") line_num=`expr $line_num + 1` @@ -128,6 +136,13 @@ if [ ! -n "$PARAMS" ] ;then fp_items_list=(${fp_items}) device_num_list=(N1C4) run_mode="DP" +elif [[ ${PARAMS} = "dynamicTostatic" ]] ;then + IFS="|" + model_type=$PARAMS + batch_size_list=(${batch_size}) + fp_items_list=(${fp_items}) + device_num_list=(N1C4) + run_mode="DP" else # parser params from input: modeltype_bs${bs_item}_${fp_item}_${run_mode}_${device_num} IFS="_" @@ -149,14 +164,6 @@ else device_num_list=($device_num) fi -# for log name -to_static="" -# parse "to_static" options and modify trainer into "to_static_trainer" -if [[ ${model_type} = "dynamicTostatic" ]];then - to_static="d2sT_" - sed -i 's/trainer:norm_train/trainer:to_static_train/g' $FILENAME -fi - IFS="|" for batch_size in ${batch_size_list[*]}; do for precision in ${fp_items_list[*]}; do diff --git a/test_tipc/configs/CycleGAN/train_infer_python.txt b/test_tipc/configs/CycleGAN/train_infer_python.txt index cd27a22..81ae013 100644 --- a/test_tipc/configs/CycleGAN/train_infer_python.txt +++ b/test_tipc/configs/CycleGAN/train_infer_python.txt @@ -17,7 +17,7 @@ norm_train:tools/main.py -c configs/cyclegan_horse2zebra.yaml --seed 123 -o log_ pact_train:null fpgm_train:null distill_train:null -to_static_train:model.to_static=True +null:null null:null ## ===========================eval_params=========================== @@ -49,6 +49,8 @@ null:null null:null --benchmark:True null:null +===========================to_static_train_benchmark_params=========================== +to_static_train:model.to_static=True ===========================train_benchmark_params========================== batch_size:1 fp_items:fp32 diff --git a/test_tipc/configs/Pix2pix/train_infer_python.txt b/test_tipc/configs/Pix2pix/train_infer_python.txt index e1aed5e..24d352d 100644 --- a/test_tipc/configs/Pix2pix/train_infer_python.txt +++ b/test_tipc/configs/Pix2pix/train_infer_python.txt @@ -17,7 +17,7 @@ norm_train:tools/main.py -c configs/pix2pix_facades.yaml --seed 123 -o log_confi pact_train:null fpgm_train:null distill_train:null -to_static_train:model.to_static=True +null:null null:null ## ===========================eval_params=========================== @@ -49,6 +49,8 @@ null:null null:null --benchmark:True null:null +===========================to_static_train_benchmark_params=========================== +to_static_train:model.to_static=True ===========================train_benchmark_params========================== batch_size:1 fp_items:fp32 diff --git a/test_tipc/configs/edvr/train_infer_python.txt b/test_tipc/configs/edvr/train_infer_python.txt index 9379f9c..e9b68ba 100644 --- a/test_tipc/configs/edvr/train_infer_python.txt +++ b/test_tipc/configs/edvr/train_infer_python.txt @@ -17,7 +17,7 @@ norm_train:tools/main.py -c configs/edvr_m_wo_tsa.yaml --seed 123 -o log_config. pact_train:null fpgm_train:null distill_train:null -to_static_train:model.to_static=True +null:null null:null ## ===========================eval_params=========================== @@ -49,9 +49,11 @@ null:null null:null --benchmark:True null:null +===========================to_static_train_benchmark_params=========================== +to_static_train:model.to_static=True ===========================train_benchmark_params========================== batch_size:64 fp_items:fp32|fp16 total_iters:100 --profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile -flags:FLAGS_cudnn_exhaustive_search=0 +flags:FLAGS_cudnn_exhaustive_search=1 diff --git a/test_tipc/configs/esrgan/train_infer_python.txt b/test_tipc/configs/esrgan/train_infer_python.txt index c70b93d..28490b6 100644 --- a/test_tipc/configs/esrgan/train_infer_python.txt +++ b/test_tipc/configs/esrgan/train_infer_python.txt @@ -17,7 +17,7 @@ norm_train:tools/main.py -c configs/esrgan_psnr_x4_div2k.yaml --seed 123 -o log_ pact_train:null fpgm_train:null distill_train:null -to_static_train:model.to_static=True +null:null null:null ## ===========================eval_params=========================== @@ -49,9 +49,11 @@ null:null null:null --benchmark:True null:null +===========================to_static_train_benchmark_params=========================== +to_static_train:model.to_static=True ===========================train_benchmark_params========================== batch_size:32|64 fp_items:fp32 total_iters:500 --profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile -flags:FLAGS_cudnn_exhaustive_search=0 +flags:FLAGS_cudnn_exhaustive_search=1 diff --git a/test_tipc/configs/msvsr/train_infer_python.txt b/test_tipc/configs/msvsr/train_infer_python.txt index 2153983..8b4fcb5 100644 --- a/test_tipc/configs/msvsr/train_infer_python.txt +++ b/test_tipc/configs/msvsr/train_infer_python.txt @@ -17,7 +17,7 @@ norm_train:tools/main.py -c configs/msvsr_reds.yaml --seed 123 -o log_config.int pact_train:null fpgm_train:null distill_train:null -to_static_train:model.to_static=True +null:null null:null ## ===========================eval_params=========================== @@ -49,11 +49,13 @@ null:null null:null --benchmark:True null:null +===========================to_static_train_benchmark_params=========================== +to_static_train:model.to_static=True ===========================train_benchmark_params========================== batch_size:2|4 fp_items:fp32|fp16 total_iters:60 --profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile -flags:FLAGS_cudnn_exhaustive_search=0 +flags:FLAGS_cudnn_exhaustive_search=1 ===========================infer_benchmark_params========================== random_infer_input:[{float32,[2,3,180,320]}] diff --git a/test_tipc/test_train_inference_python.sh b/test_tipc/test_train_inference_python.sh index c11e9b9..c5cdce8 100644 --- a/test_tipc/test_train_inference_python.sh +++ b/test_tipc/test_train_inference_python.sh @@ -5,7 +5,7 @@ FILENAME=$1 # MODE be one of ['lite_train_lite_infer' 'lite_train_whole_infer' 'whole_train_whole_infer', 'whole_infer'] MODE=$2 -dataline=$(awk 'NR==1, NR==51{print}' $FILENAME) +dataline=$(cat ${FILENAME}) # parser params IFS=$'\n' @@ -33,8 +33,8 @@ trainer_list=$(func_parser_value "${lines[14]}") trainer_norm=$(func_parser_key "${lines[15]}") norm_trainer=$(func_parser_value "${lines[15]}") -to_static_key=$(func_parser_key "${lines[19]}") -to_static_trainer=$(func_parser_value "${lines[19]}") +trainer_key1=$(func_parser_key "${lines[19]}") +trainer_value1=$(func_parser_value "${lines[19]}") trainer_key2=$(func_parser_key "${lines[20]}") trainer_value2=$(func_parser_value "${lines[20]}") @@ -73,6 +73,10 @@ save_log_key=$(func_parser_key "${lines[48]}") infer_key1=$(func_parser_key "${lines[50]}") infer_value1=$(func_parser_value "${lines[50]}") +line_num=`grep -n -w "to_static_train_benchmark_params" $FILENAME | cut -d ":" -f 1` +to_static_key=$(func_parser_key "${lines[line_num]}") +to_static_trainer=$(func_parser_value "${lines[line_num]}") + LOG_PATH="./test_tipc/output/${model_name}/${MODE}" mkdir -p ${LOG_PATH} status_log="${LOG_PATH}/results_python.log" -- GitLab