|
|
@ -20,10 +20,10 @@ train_use_gpu_value=$(func_parser_value "${lines[4]}")
|
|
|
|
autocast_list=$(func_parser_value "${lines[5]}")
|
|
|
|
autocast_list=$(func_parser_value "${lines[5]}")
|
|
|
|
autocast_key=$(func_parser_key "${lines[5]}")
|
|
|
|
autocast_key=$(func_parser_key "${lines[5]}")
|
|
|
|
epoch_key=$(func_parser_key "${lines[6]}")
|
|
|
|
epoch_key=$(func_parser_key "${lines[6]}")
|
|
|
|
epoch_num=$(func_parser_params "${lines[6]}")
|
|
|
|
epoch_num=$(func_parser_params "${lines[6]}" "${MODE}")
|
|
|
|
save_model_key=$(func_parser_key "${lines[7]}")
|
|
|
|
save_model_key=$(func_parser_key "${lines[7]}")
|
|
|
|
train_batch_key=$(func_parser_key "${lines[8]}")
|
|
|
|
train_batch_key=$(func_parser_key "${lines[8]}")
|
|
|
|
train_batch_value=$(func_parser_params "${lines[8]}")
|
|
|
|
train_batch_value=$(func_parser_params "${lines[8]}" "${MODE}")
|
|
|
|
pretrain_model_key=$(func_parser_key "${lines[9]}")
|
|
|
|
pretrain_model_key=$(func_parser_key "${lines[9]}")
|
|
|
|
pretrain_model_value=$(func_parser_value "${lines[9]}")
|
|
|
|
pretrain_model_value=$(func_parser_value "${lines[9]}")
|
|
|
|
train_model_name=$(func_parser_value "${lines[10]}")
|
|
|
|
train_model_name=$(func_parser_value "${lines[10]}")
|
|
|
@ -50,7 +50,6 @@ eval_key1=$(func_parser_key "${lines[24]}")
|
|
|
|
eval_value1=$(func_parser_value "${lines[24]}")
|
|
|
|
eval_value1=$(func_parser_value "${lines[24]}")
|
|
|
|
|
|
|
|
|
|
|
|
save_infer_key=$(func_parser_key "${lines[27]}")
|
|
|
|
save_infer_key=$(func_parser_key "${lines[27]}")
|
|
|
|
save_infer_value=$(func_parser_value "${lines[27]}")
|
|
|
|
|
|
|
|
export_weight=$(func_parser_key "${lines[28]}")
|
|
|
|
export_weight=$(func_parser_key "${lines[28]}")
|
|
|
|
norm_export=$(func_parser_value "${lines[29]}")
|
|
|
|
norm_export=$(func_parser_value "${lines[29]}")
|
|
|
|
pact_export=$(func_parser_value "${lines[30]}")
|
|
|
|
pact_export=$(func_parser_value "${lines[30]}")
|
|
|
@ -91,44 +90,42 @@ infer_value1=$(func_parser_value "${lines[50]}")
|
|
|
|
|
|
|
|
|
|
|
|
# parser klquant_infer
|
|
|
|
# parser klquant_infer
|
|
|
|
if [ ${MODE} = "klquant_whole_infer" ]; then
|
|
|
|
if [ ${MODE} = "klquant_whole_infer" ]; then
|
|
|
|
dataline=$(awk 'NR==1 NR==17{print}' $FILENAME)
|
|
|
|
dataline=$(awk 'NR==1, NR==17{print}' $FILENAME)
|
|
|
|
lines=(${dataline})
|
|
|
|
lines=(${dataline})
|
|
|
|
model_name=$(func_parser_value "${lines[1]}")
|
|
|
|
model_name=$(func_parser_value "${lines[1]}")
|
|
|
|
python=$(func_parser_value "${lines[2]}")
|
|
|
|
python=$(func_parser_value "${lines[2]}")
|
|
|
|
|
|
|
|
export_weight=$(func_parser_key "${lines[3]}")
|
|
|
|
|
|
|
|
save_infer_key=$(func_parser_key "${lines[4]}")
|
|
|
|
# parser inference model
|
|
|
|
# parser inference model
|
|
|
|
infer_model_dir_list=$(func_parser_value "${lines[3]}")
|
|
|
|
infer_model_dir_list=$(func_parser_value "${lines[5]}")
|
|
|
|
infer_export_list=$(func_parser_value "${lines[4]}")
|
|
|
|
infer_export_list=$(func_parser_value "${lines[6]}")
|
|
|
|
infer_is_quant=$(func_parser_value "${lines[5]}")
|
|
|
|
infer_is_quant=$(func_parser_value "${lines[7]}")
|
|
|
|
# parser inference
|
|
|
|
# parser inference
|
|
|
|
inference_py=$(func_parser_value "${lines[6]}")
|
|
|
|
inference_py=$(func_parser_value "${lines[8]}")
|
|
|
|
use_gpu_key=$(func_parser_key "${lines[7]}")
|
|
|
|
use_gpu_key=$(func_parser_key "${lines[9]}")
|
|
|
|
use_gpu_list=$(func_parser_value "${lines[7]}")
|
|
|
|
use_gpu_list=$(func_parser_value "${lines[9]}")
|
|
|
|
use_mkldnn_key=$(func_parser_key "${lines[8]}")
|
|
|
|
use_mkldnn_key=$(func_parser_key "${lines[10]}")
|
|
|
|
use_mkldnn_list=$(func_parser_value "${lines[8]}")
|
|
|
|
use_mkldnn_list=$(func_parser_value "${lines[10]}")
|
|
|
|
cpu_threads_key=$(func_parser_key "${lines[9]}")
|
|
|
|
cpu_threads_key=$(func_parser_key "${lines[11]}")
|
|
|
|
cpu_threads_list=$(func_parser_value "${lines[9]}")
|
|
|
|
cpu_threads_list=$(func_parser_value "${lines[11]}")
|
|
|
|
batch_size_key=$(func_parser_key "${lines[10]}")
|
|
|
|
batch_size_key=$(func_parser_key "${lines[12]}")
|
|
|
|
batch_size_list=$(func_parser_value "${lines[10]}")
|
|
|
|
batch_size_list=$(func_parser_value "${lines[12]}")
|
|
|
|
use_trt_key=$(func_parser_key "${lines[11]}")
|
|
|
|
use_trt_key=$(func_parser_key "${lines[13]}")
|
|
|
|
use_trt_list=$(func_parser_value "${lines[11]}")
|
|
|
|
use_trt_list=$(func_parser_value "${lines[13]}")
|
|
|
|
precision_key=$(func_parser_key "${lines[12]}")
|
|
|
|
precision_key=$(func_parser_key "${lines[14]}")
|
|
|
|
precision_list=$(func_parser_value "${lines[12]}")
|
|
|
|
precision_list=$(func_parser_value "${lines[14]}")
|
|
|
|
infer_model_key=$(func_parser_key "${lines[13]}")
|
|
|
|
infer_model_key=$(func_parser_key "${lines[15]}")
|
|
|
|
image_dir_key=$(func_parser_key "${lines[14]}")
|
|
|
|
image_dir_key=$(func_parser_key "${lines[16]}")
|
|
|
|
infer_img_dir=$(func_parser_value "${lines[14]}")
|
|
|
|
infer_img_dir=$(func_parser_value "${lines[16]}")
|
|
|
|
save_log_key=$(func_parser_key "${lines[15]}")
|
|
|
|
save_log_key=$(func_parser_key "${lines[17]}")
|
|
|
|
benchmark_key=$(func_parser_key "${lines[16]}")
|
|
|
|
save_log_value=$(func_parser_value "${lines[17]}")
|
|
|
|
benchmark_value=$(func_parser_value "${lines[16]}")
|
|
|
|
benchmark_key=$(func_parser_key "${lines[18]}")
|
|
|
|
infer_key1=$(func_parser_key "${lines[17]}")
|
|
|
|
benchmark_value=$(func_parser_value "${lines[18]}")
|
|
|
|
infer_value1=$(func_parser_value "${lines[17]}")
|
|
|
|
infer_key1=$(func_parser_key "${lines[19]}")
|
|
|
|
|
|
|
|
infer_value1=$(func_parser_value "${lines[19]}")
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
save_model_value=$(func_parser_value "${lines[7]}")
|
|
|
|
|
|
|
|
if [[ ${save_model_value} = " " ]] || [[ ${save_model_value} = "null" ]] || [[ ${save_model_value} = "" ]];then
|
|
|
|
|
|
|
|
LOG_PATH="./test_tipc/output"
|
|
|
|
LOG_PATH="./test_tipc/output"
|
|
|
|
else
|
|
|
|
|
|
|
|
LOG_PATH=${save_model_value}
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p ${LOG_PATH}
|
|
|
|
mkdir -p ${LOG_PATH}
|
|
|
|
status_log="${LOG_PATH}/results_python.log"
|
|
|
|
status_log="${LOG_PATH}/results_python.log"
|
|
|
|
|
|
|
|
|
|
|
@ -163,10 +160,12 @@ function func_inference(){
|
|
|
|
set_infer_data=$(func_set_params "${image_dir_key}" "${_img_dir}")
|
|
|
|
set_infer_data=$(func_set_params "${image_dir_key}" "${_img_dir}")
|
|
|
|
set_benchmark=$(func_set_params "${benchmark_key}" "${benchmark_value}")
|
|
|
|
set_benchmark=$(func_set_params "${benchmark_key}" "${benchmark_value}")
|
|
|
|
set_batchsize=$(func_set_params "${batch_size_key}" "${batch_size}")
|
|
|
|
set_batchsize=$(func_set_params "${batch_size_key}" "${batch_size}")
|
|
|
|
|
|
|
|
set_mkldnn=$(func_set_params "${use_mkldnn_key}" "${use_mkldnn}")
|
|
|
|
set_cpu_threads=$(func_set_params "${cpu_threads_key}" "${threads}")
|
|
|
|
set_cpu_threads=$(func_set_params "${cpu_threads_key}" "${threads}")
|
|
|
|
set_model_dir=$(func_set_params "${infer_model_key}" "${_model_dir}")
|
|
|
|
set_model_dir=$(func_set_params "${infer_model_key}" "${_model_dir}")
|
|
|
|
|
|
|
|
set_infer_params0=$(func_set_params "${save_log_key}" "${save_log_value}")
|
|
|
|
set_infer_params1=$(func_set_params "${infer_key1}" "${infer_value1}")
|
|
|
|
set_infer_params1=$(func_set_params "${infer_key1}" "${infer_value1}")
|
|
|
|
command="${_python} ${_script} ${use_gpu_key}=${use_gpu} ${use_mkldnn_key}=${use_mkldnn} ${set_cpu_threads} ${set_model_dir} ${set_batchsize} ${set_infer_data} ${set_benchmark} ${set_precision} ${set_infer_params1} > ${_save_log_path} 2>&1 "
|
|
|
|
command="${_python} ${_script} ${use_gpu_key}=${use_gpu} ${set_mkldnn} ${set_cpu_threads} ${set_model_dir} ${set_batchsize} ${set_infer_params0} ${set_infer_data} ${set_benchmark} ${set_precision} ${set_infer_params1} > ${_save_log_path} 2>&1 "
|
|
|
|
eval $command
|
|
|
|
eval $command
|
|
|
|
last_status=${PIPESTATUS[0]}
|
|
|
|
last_status=${PIPESTATUS[0]}
|
|
|
|
eval "cat ${_save_log_path}"
|
|
|
|
eval "cat ${_save_log_path}"
|
|
|
@ -184,7 +183,7 @@ function func_inference(){
|
|
|
|
if [[ ${precision} =~ "fp16" || ${precision} =~ "int8" ]] && [ ${use_trt} = "False" ]; then
|
|
|
|
if [[ ${precision} =~ "fp16" || ${precision} =~ "int8" ]] && [ ${use_trt} = "False" ]; then
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [[ ${use_trt} = "False" || ${precision} =~ "int8" ]] && [ ${_flag_quant} = "True" ]; then
|
|
|
|
if [[ ${use_trt} = "False" && ${precision} =~ "int8" ]] && [ ${_flag_quant} = "True" ]; then
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
for batch_size in ${batch_size_list[*]}; do
|
|
|
|
for batch_size in ${batch_size_list[*]}; do
|
|
|
@ -195,8 +194,9 @@ function func_inference(){
|
|
|
|
set_tensorrt=$(func_set_params "${use_trt_key}" "${use_trt}")
|
|
|
|
set_tensorrt=$(func_set_params "${use_trt_key}" "${use_trt}")
|
|
|
|
set_precision=$(func_set_params "${precision_key}" "${precision}")
|
|
|
|
set_precision=$(func_set_params "${precision_key}" "${precision}")
|
|
|
|
set_model_dir=$(func_set_params "${infer_model_key}" "${_model_dir}")
|
|
|
|
set_model_dir=$(func_set_params "${infer_model_key}" "${_model_dir}")
|
|
|
|
|
|
|
|
set_infer_params0=$(func_set_params "${save_log_key}" "${save_log_value}")
|
|
|
|
set_infer_params1=$(func_set_params "${infer_key1}" "${infer_value1}")
|
|
|
|
set_infer_params1=$(func_set_params "${infer_key1}" "${infer_value1}")
|
|
|
|
command="${_python} ${_script} ${use_gpu_key}=${use_gpu} ${set_tensorrt} ${set_precision} ${set_model_dir} ${set_batchsize} ${set_infer_data} ${set_benchmark} ${set_infer_params1} > ${_save_log_path} 2>&1 "
|
|
|
|
command="${_python} ${_script} ${use_gpu_key}=${use_gpu} ${set_tensorrt} ${set_precision} ${set_model_dir} ${set_batchsize} ${set_infer_data} ${set_benchmark} ${set_infer_params1} ${set_infer_params0} > ${_save_log_path} 2>&1 "
|
|
|
|
eval $command
|
|
|
|
eval $command
|
|
|
|
last_status=${PIPESTATUS[0]}
|
|
|
|
last_status=${PIPESTATUS[0]}
|
|
|
|
eval "cat ${_save_log_path}"
|
|
|
|
eval "cat ${_save_log_path}"
|
|
|
@ -227,12 +227,15 @@ if [ ${MODE} = "whole_infer" ] || [ ${MODE} = "klquant_whole_infer" ]; then
|
|
|
|
for infer_model in ${infer_model_dir_list[*]}; do
|
|
|
|
for infer_model in ${infer_model_dir_list[*]}; do
|
|
|
|
# run export
|
|
|
|
# run export
|
|
|
|
if [ ${infer_run_exports[Count]} != "null" ];then
|
|
|
|
if [ ${infer_run_exports[Count]} != "null" ];then
|
|
|
|
save_infer_dir=$(dirname $infer_model)
|
|
|
|
if [ ${MODE} = "klquant_whole_infer" ]; then
|
|
|
|
|
|
|
|
save_infer_dir="${infer_model}_klquant"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ${MODE} = "whole_infer" ]; then
|
|
|
|
|
|
|
|
save_infer_dir="${infer_model}"
|
|
|
|
|
|
|
|
fi
|
|
|
|
set_export_weight=$(func_set_params "${export_weight}" "${infer_model}")
|
|
|
|
set_export_weight=$(func_set_params "${export_weight}" "${infer_model}")
|
|
|
|
set_save_infer_key=$(func_set_params "${save_infer_key}" "${save_infer_dir}")
|
|
|
|
set_save_infer_key=$(func_set_params "${save_infer_key}" "${save_infer_dir}")
|
|
|
|
# For lac which needs the `data_dir` args
|
|
|
|
export_cmd="${python} ${infer_run_exports[Count]} ${set_export_weight} ${set_save_infer_key}"
|
|
|
|
set_export1_key=$(func_set_params "${export_key1}" "${export_value1}")
|
|
|
|
|
|
|
|
export_cmd="${python} ${infer_run_exports[Count]} ${set_export_weight} ${set_save_infer_key} ${set_export1_key}"
|
|
|
|
|
|
|
|
echo ${infer_run_exports[Count]}
|
|
|
|
echo ${infer_run_exports[Count]}
|
|
|
|
echo $export_cmd
|
|
|
|
echo $export_cmd
|
|
|
|
eval $export_cmd
|
|
|
|
eval $export_cmd
|
|
|
@ -243,7 +246,7 @@ if [ ${MODE} = "whole_infer" ] || [ ${MODE} = "klquant_whole_infer" ]; then
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
#run inference
|
|
|
|
#run inference
|
|
|
|
is_quant=${infer_quant_flag[Count]}
|
|
|
|
is_quant=${infer_quant_flag[Count]}
|
|
|
|
if [ ${MODE} = "klquant_infer" ]; then
|
|
|
|
if [ ${MODE} = "klquant_whole_infer" ]; then
|
|
|
|
is_quant="True"
|
|
|
|
is_quant="True"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
func_inference "${python}" "${inference_py}" "${save_infer_dir}" "${LOG_PATH}" "${infer_img_dir}" ${is_quant}
|
|
|
|
func_inference "${python}" "${inference_py}" "${save_infer_dir}" "${LOG_PATH}" "${infer_img_dir}" ${is_quant}
|
|
|
@ -261,7 +264,6 @@ else
|
|
|
|
env=""
|
|
|
|
env=""
|
|
|
|
elif [ ${#gpu} -le 1 ];then
|
|
|
|
elif [ ${#gpu} -le 1 ];then
|
|
|
|
env="export CUDA_VISIBLE_DEVICES=${gpu}"
|
|
|
|
env="export CUDA_VISIBLE_DEVICES=${gpu}"
|
|
|
|
eval ${env}
|
|
|
|
|
|
|
|
elif [ ${#gpu} -le 15 ];then
|
|
|
|
elif [ ${#gpu} -le 15 ];then
|
|
|
|
IFS=","
|
|
|
|
IFS=","
|
|
|
|
array=(${gpu})
|
|
|
|
array=(${gpu})
|
|
|
@ -324,10 +326,6 @@ else
|
|
|
|
save_log="${LOG_PATH}/${trainer}_gpus_${gpu}_autocast_${autocast}_nodes_${nodes}"
|
|
|
|
save_log="${LOG_PATH}/${trainer}_gpus_${gpu}_autocast_${autocast}_nodes_${nodes}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# load pretrain from norm training if current trainer is pact or fpgm trainer
|
|
|
|
|
|
|
|
if ([ ${trainer} = ${pact_key} ] || [ ${trainer} = ${fpgm_key} ]) && [ ${nodes} -le 1 ]; then
|
|
|
|
|
|
|
|
set_pretrain="${load_norm_train_model}"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set_save_model=$(func_set_params "${save_model_key}" "${save_log}")
|
|
|
|
set_save_model=$(func_set_params "${save_model_key}" "${save_log}")
|
|
|
|
if [ ${#gpu} -le 2 ];then # train with cpu or single gpu
|
|
|
|
if [ ${#gpu} -le 2 ];then # train with cpu or single gpu
|
|
|
@ -338,17 +336,14 @@ else
|
|
|
|
cmd="${python} -m paddle.distributed.launch --ips=${ips} --gpus=${gpu} ${run_train} ${set_use_gpu} ${set_save_model} ${set_pretrain} ${set_epoch} ${set_autocast} ${set_batchsize} ${set_train_params1} ${set_amp_config}"
|
|
|
|
cmd="${python} -m paddle.distributed.launch --ips=${ips} --gpus=${gpu} ${run_train} ${set_use_gpu} ${set_save_model} ${set_pretrain} ${set_epoch} ${set_autocast} ${set_batchsize} ${set_train_params1} ${set_amp_config}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
# run train
|
|
|
|
# run train
|
|
|
|
eval "unset CUDA_VISIBLE_DEVICES"
|
|
|
|
|
|
|
|
eval $cmd
|
|
|
|
eval $cmd
|
|
|
|
status_check $? "${cmd}" "${status_log}"
|
|
|
|
status_check $? "${cmd}" "${status_log}"
|
|
|
|
|
|
|
|
|
|
|
|
set_eval_pretrain=$(func_set_params "${pretrain_model_key}" "${save_log}/${train_model_name}")
|
|
|
|
set_eval_pretrain=$(func_set_params "${pretrain_model_key}" "${save_log}/${train_model_name}")
|
|
|
|
# save norm trained models to set pretrain for pact training and fpgm training
|
|
|
|
|
|
|
|
if [ ${trainer} = ${trainer_norm} ] && [ ${nodes} -le 1 ]; then
|
|
|
|
|
|
|
|
load_norm_train_model=${set_eval_pretrain}
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
# run eval
|
|
|
|
# run eval
|
|
|
|
if [ ${eval_py} != "null" ]; then
|
|
|
|
if [ ${eval_py} != "null" ]; then
|
|
|
|
|
|
|
|
eval ${env}
|
|
|
|
set_eval_params1=$(func_set_params "${eval_key1}" "${eval_value1}")
|
|
|
|
set_eval_params1=$(func_set_params "${eval_key1}" "${eval_value1}")
|
|
|
|
eval_cmd="${python} ${eval_py} ${set_eval_pretrain} ${set_use_gpu} ${set_eval_params1}"
|
|
|
|
eval_cmd="${python} ${eval_py} ${set_eval_pretrain} ${set_use_gpu} ${set_eval_params1}"
|
|
|
|
eval $eval_cmd
|
|
|
|
eval $eval_cmd
|
|
|
@ -357,20 +352,17 @@ else
|
|
|
|
# run export model
|
|
|
|
# run export model
|
|
|
|
if [ ${run_export} != "null" ]; then
|
|
|
|
if [ ${run_export} != "null" ]; then
|
|
|
|
# run export model
|
|
|
|
# run export model
|
|
|
|
save_infer_path="${save_infer_value}"
|
|
|
|
save_infer_path="${save_log}"
|
|
|
|
set_export_weight=$(func_set_params "${export_weight}" "${save_log}/${train_model_name}")
|
|
|
|
set_export_weight=$(func_set_params "${export_weight}" "${save_log}/${train_model_name}")
|
|
|
|
set_save_infer_key=$(func_set_params "${save_infer_key}" "${save_infer_path}")
|
|
|
|
set_save_infer_key=$(func_set_params "${save_infer_key}" "${save_infer_path}")
|
|
|
|
# For lac which needs the `data_dir` args
|
|
|
|
export_cmd="${python} ${run_export} ${set_export_weight} ${set_save_infer_key}"
|
|
|
|
set_export1_key=$(func_set_params "${export_key1}" "${export_value1}")
|
|
|
|
|
|
|
|
export_cmd="${python} ${run_export} ${set_export_weight} ${set_save_infer_key} ${set_export1_key}"
|
|
|
|
|
|
|
|
eval $export_cmd
|
|
|
|
eval $export_cmd
|
|
|
|
status_check $? "${export_cmd}" "${status_log}"
|
|
|
|
status_check $? "${export_cmd}" "${status_log}"
|
|
|
|
|
|
|
|
|
|
|
|
#run inference
|
|
|
|
#run inference
|
|
|
|
eval $env
|
|
|
|
eval $env
|
|
|
|
save_infer_path="${save_infer_value}"
|
|
|
|
save_infer_path="${save_log}"
|
|
|
|
|
|
|
|
if [[ ${inference_dir} != "null" ]] && [[ ${inference_dir} != '##' ]]; then
|
|
|
|
if [ ${inference_dir} != "null" ] && [ ${inference_dir} != '##' ]; then
|
|
|
|
|
|
|
|
infer_model_dir="${save_infer_path}/${inference_dir}"
|
|
|
|
infer_model_dir="${save_infer_path}/${inference_dir}"
|
|
|
|
else
|
|
|
|
else
|
|
|
|
infer_model_dir=${save_infer_path}
|
|
|
|
infer_model_dir=${save_infer_path}
|
|
|
|