未验证 提交 36ec3a40 编写于 作者: Z zhoujun 提交者: GitHub

update tipc to_static (#9369)

* add d2s train for slanet and v3

* fix bug

* udpate tipc to_static

* update db

* remove_print

* update benchmark_train.sh

* update maybe_download_params
上级 2e05d54a
...@@ -102,7 +102,7 @@ export frame_version=${str_tmp%%.post*} ...@@ -102,7 +102,7 @@ export frame_version=${str_tmp%%.post*}
export frame_commit=$(echo `${python} -c "import paddle;print(paddle.version.commit)"`) export frame_commit=$(echo `${python} -c "import paddle;print(paddle.version.commit)"`)
# 获取benchmark_params所在的行数 # 获取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 # for train log parser
batch_size=$(func_parser_value "${lines[line_num]}") batch_size=$(func_parser_value "${lines[line_num]}")
line_num=`expr $line_num + 1` line_num=`expr $line_num + 1`
......
...@@ -17,7 +17,7 @@ norm_train:tools/train.py --config_file config/icdar2015_resnet50_FPN_DBhead_pol ...@@ -17,7 +17,7 @@ norm_train:tools/train.py --config_file config/icdar2015_resnet50_FPN_DBhead_pol
quant_export:null quant_export:null
fpgm_export:null fpgm_export:null
distill_train:null distill_train:null
to_static_train:trainer.to_static=true null:null
null:null null:null
## ##
===========================eval_params=========================== ===========================eval_params===========================
...@@ -56,4 +56,6 @@ batch_size:8 ...@@ -56,4 +56,6 @@ batch_size:8
fp_items:fp32|fp16 fp_items:fp32|fp16
epoch:2 epoch:2
--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile --profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile
flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096 flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096
\ No newline at end of file ===========================to_static_train_benchmark_params===========================
to_static_train:trainer.to_static=true
\ No newline at end of file
...@@ -5,7 +5,7 @@ FILENAME=$1 ...@@ -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 be one of ['lite_train_lite_infer' 'lite_train_whole_infer' 'whole_train_whole_infer', 'whole_infer']
MODE=$2 MODE=$2
dataline=$(awk 'NR==1, NR==51{print}' $FILENAME) dataline=$(awk 'NR>=1{print}' $FILENAME)
# parser params # parser params
IFS=$'\n' IFS=$'\n'
...@@ -40,8 +40,8 @@ fpgm_key=$(func_parser_key "${lines[17]}") ...@@ -40,8 +40,8 @@ fpgm_key=$(func_parser_key "${lines[17]}")
fpgm_trainer=$(func_parser_value "${lines[17]}") fpgm_trainer=$(func_parser_value "${lines[17]}")
distill_key=$(func_parser_key "${lines[18]}") distill_key=$(func_parser_key "${lines[18]}")
distill_trainer=$(func_parser_value "${lines[18]}") distill_trainer=$(func_parser_value "${lines[18]}")
to_static_key=$(func_parser_key "${lines[19]}") trainer_key1=$(func_parser_key "${lines[19]}")
to_static_value=$(func_parser_value "${lines[19]}") trainer_value1=$(func_parser_value "${lines[19]}")
trainer_key2=$(func_parser_key "${lines[20]}") trainer_key2=$(func_parser_key "${lines[20]}")
trainer_value2=$(func_parser_value "${lines[20]}") trainer_value2=$(func_parser_value "${lines[20]}")
...@@ -92,6 +92,9 @@ LOG_PATH="./test_tipc/output/${model_name}/${MODE}" ...@@ -92,6 +92,9 @@ LOG_PATH="./test_tipc/output/${model_name}/${MODE}"
mkdir -p ${LOG_PATH} mkdir -p ${LOG_PATH}
status_log="${LOG_PATH}/results_python.log" status_log="${LOG_PATH}/results_python.log"
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]}")
function func_inference(){ function func_inference(){
IFS='|' IFS='|'
...@@ -254,7 +257,7 @@ else ...@@ -254,7 +257,7 @@ else
run_train=${distill_trainer} run_train=${distill_trainer}
run_export=${distill_export} run_export=${distill_export}
elif [ ${trainer} = "${to_static_key}" ]; then elif [ ${trainer} = "${to_static_key}" ]; then
run_train="${norm_trainer} ${to_static_value}" run_train="${norm_trainer} ${to_static_trainer}"
run_export=${norm_export} run_export=${norm_export}
elif [[ ${trainer} = ${trainer_key2} ]]; then elif [[ ${trainer} = ${trainer_key2} ]]; then
run_train=${trainer_value2} run_train=${trainer_value2}
......
...@@ -70,10 +70,8 @@ def maybe_download(model_storage_directory, url): ...@@ -70,10 +70,8 @@ def maybe_download(model_storage_directory, url):
def maybe_download_params(model_path): def maybe_download_params(model_path):
if os.path.exists(model_path): if os.path.exists(model_path) or not is_link(model_path):
return model_path return model_path
elif not is_link(model_path):
url = 'https://paddleocr.bj.bcebos.com/' + model_path
else: else:
url = model_path url = model_path
tmp_path = os.path.join(MODELS_DIR, url.split('/')[-1]) tmp_path = os.path.join(MODELS_DIR, url.split('/')[-1])
......
...@@ -102,7 +102,7 @@ export frame_version=${str_tmp%%.post*} ...@@ -102,7 +102,7 @@ export frame_version=${str_tmp%%.post*}
export frame_commit=$(echo `${python} -c "import paddle;print(paddle.version.commit)"`) export frame_commit=$(echo `${python} -c "import paddle;print(paddle.version.commit)"`)
# 获取benchmark_params所在的行数 # 获取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 # for train log parser
batch_size=$(func_parser_value "${lines[line_num]}") batch_size=$(func_parser_value "${lines[line_num]}")
line_num=`expr $line_num + 1` line_num=`expr $line_num + 1`
......
...@@ -57,3 +57,5 @@ fp_items:fp32|fp16 ...@@ -57,3 +57,5 @@ fp_items:fp32|fp16
epoch:2 epoch:2
--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile --profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile
flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096 flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096
===========================to_static_train_benchmark_params===========================
to_static_train:Global.to_static=true
\ No newline at end of file
...@@ -57,4 +57,5 @@ fp_items:fp32|fp16 ...@@ -57,4 +57,5 @@ fp_items:fp32|fp16
epoch:1 epoch:1
--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile --profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile
flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096 flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096
===========================to_static_train_benchmark_params===========================
to_static_train:Global.to_static=true
...@@ -57,3 +57,5 @@ fp_items:fp32|fp16 ...@@ -57,3 +57,5 @@ fp_items:fp32|fp16
epoch:2 epoch:2
--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile --profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile
flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096 flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096
===========================to_static_train_benchmark_params===========================
to_static_train:Global.to_static=true
\ No newline at end of file
...@@ -17,7 +17,7 @@ norm_train:tools/train.py -c test_tipc/configs/table_master/table_master.yml -o ...@@ -17,7 +17,7 @@ norm_train:tools/train.py -c test_tipc/configs/table_master/table_master.yml -o
pact_train:null pact_train:null
fpgm_train:null fpgm_train:null
distill_train:null distill_train:null
to_static_train:Global.to_static=true null:null
null:null null:null
## ##
===========================eval_params=========================== ===========================eval_params===========================
...@@ -56,4 +56,6 @@ batch_size:10 ...@@ -56,4 +56,6 @@ batch_size:10
fp_items:fp32|fp16 fp_items:fp32|fp16
epoch:2 epoch:2
--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile --profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile
flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096 flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096
\ No newline at end of file ===========================to_static_train_benchmark_params===========================
to_static_train:Global.to_static=true
\ No newline at end of file
...@@ -57,3 +57,5 @@ fp_items:fp32|fp16 ...@@ -57,3 +57,5 @@ fp_items:fp32|fp16
epoch:3 epoch:3
--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile --profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile
flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98 flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98
===========================to_static_train_benchmark_params===========================
to_static_train:Global.to_static=true
...@@ -5,7 +5,7 @@ FILENAME=$1 ...@@ -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 be one of ['lite_train_lite_infer' 'lite_train_whole_infer' 'whole_train_whole_infer', 'whole_infer']
MODE=$2 MODE=$2
dataline=$(awk 'NR==1, NR==51{print}' $FILENAME) dataline=$(awk 'NR>=1{print}' $FILENAME)
# parser params # parser params
IFS=$'\n' IFS=$'\n'
...@@ -40,8 +40,8 @@ fpgm_key=$(func_parser_key "${lines[17]}") ...@@ -40,8 +40,8 @@ fpgm_key=$(func_parser_key "${lines[17]}")
fpgm_trainer=$(func_parser_value "${lines[17]}") fpgm_trainer=$(func_parser_value "${lines[17]}")
distill_key=$(func_parser_key "${lines[18]}") distill_key=$(func_parser_key "${lines[18]}")
distill_trainer=$(func_parser_value "${lines[18]}") distill_trainer=$(func_parser_value "${lines[18]}")
to_static_key=$(func_parser_key "${lines[19]}") trainer_key1=$(func_parser_key "${lines[19]}")
to_static_value=$(func_parser_value "${lines[19]}") trainer_value1=$(func_parser_value "${lines[19]}")
trainer_key2=$(func_parser_key "${lines[20]}") trainer_key2=$(func_parser_key "${lines[20]}")
trainer_value2=$(func_parser_value "${lines[20]}") trainer_value2=$(func_parser_value "${lines[20]}")
...@@ -88,11 +88,14 @@ benchmark_value=$(func_parser_value "${lines[49]}") ...@@ -88,11 +88,14 @@ benchmark_value=$(func_parser_value "${lines[49]}")
infer_key1=$(func_parser_key "${lines[50]}") infer_key1=$(func_parser_key "${lines[50]}")
infer_value1=$(func_parser_value "${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}" LOG_PATH="./test_tipc/output/${model_name}/${MODE}"
mkdir -p ${LOG_PATH} mkdir -p ${LOG_PATH}
status_log="${LOG_PATH}/results_python.log" status_log="${LOG_PATH}/results_python.log"
function func_inference(){ function func_inference(){
IFS='|' IFS='|'
_python=$1 _python=$1
...@@ -254,7 +257,7 @@ else ...@@ -254,7 +257,7 @@ else
run_train=${distill_trainer} run_train=${distill_trainer}
run_export=${distill_export} run_export=${distill_export}
elif [ ${trainer} = "${to_static_key}" ]; then elif [ ${trainer} = "${to_static_key}" ]; then
run_train="${norm_trainer} ${to_static_value}" run_train="${norm_trainer} ${to_static_trainer}"
run_export=${norm_export} run_export=${norm_export}
elif [[ ${trainer} = ${trainer_key2} ]]; then elif [[ ${trainer} = ${trainer_key2} ]]; then
run_train=${trainer_value2} run_train=${trainer_value2}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册