2026-01-28 06:16:04 +00:00

93 lines
3.1 KiB
Bash

#!/bin/bash
############################## Constants
SCRIPT_FOLDER=/workspace/scripts
# SCRIPT_FOLDER=/docker_mount/toolchain_docker_scripts
LIBS_FOLDER=/workspace/libs
TMP_FOLDER=/workspace/.tmp
RESULT_FOLDER=/data1
############################# Functions
delFolder(){
if [ -d $1 ]; then
if [ -L $1 ]; then
# It is a symlink!
# Symbolic link specific commands go here.
rm $1
else
# It's a directory!
# Directory command goes here.
rm -r $1
fi
fi
}
delFile(){
if [ -e $1 ];then
rm $1
fi
}
chk_flow () {
if [ $1 -ne 0 ]; then
echo "[FAULT] $2" >> $ResultDir/log.txt
exit 1
fi
}
createFolderIfNo(){
if [ ! -d "$1" ]; then
mkdir -p $1
fi
}
parseParams () {
# Parse input params
createFolderIfNo $TMP_FOLDER
echo "parse input params..."
python $SCRIPT_FOLDER/utils/extract_input_params_520.py -i /data1/input_params.json -o $TMP_FOLDER/input_params.txt
chk_flow $? "parse input params fails!"
input_image_folder=$(sed -n '1 p' $TMP_FOLDER/input_params.txt)
img_channel=$(sed -n '2 p' $TMP_FOLDER/input_params.txt)
model_input_width=$(sed -n '3 p' $TMP_FOLDER/input_params.txt)
model_input_height=$(sed -n '4 p' $TMP_FOLDER/input_params.txt)
img_preprocess_method=$(sed -n '5 p' $TMP_FOLDER/input_params.txt)
input_onnx_file=$(sed -n '6 p' $TMP_FOLDER/input_params.txt)
keep_aspect_ratio=$(sed -n '7 p' $TMP_FOLDER/input_params.txt)
command_addr=$(sed -n '8 p' $TMP_FOLDER/input_params.txt)
weight_addr=$(sed -n '9 p' $TMP_FOLDER/input_params.txt)
sram_addr=$(sed -n '10 p' $TMP_FOLDER/input_params.txt)
dram_addr=$(sed -n '11 p' $TMP_FOLDER/input_params.txt)
whether_encryption=$(sed -n '12 p' $TMP_FOLDER/input_params.txt)
encryption_key=$(sed -n '13 p' $TMP_FOLDER/input_params.txt)
simulator_img_file=$(sed -n '14 p' $TMP_FOLDER/input_params.txt)
emulator_img_folder=$(sed -n '15 p' $TMP_FOLDER/input_params.txt)
cmd_bin_file=$(sed -n '16 p' $TMP_FOLDER/input_params.txt)
weight_bin_file=$(sed -n '17 p' $TMP_FOLDER/input_params.txt)
setup_bin_file=$(sed -n '18 p' $TMP_FOLDER/input_params.txt)
whether_npu_preprocess=$(sed -n '19 p' $TMP_FOLDER/input_params.txt)
radix=$(sed -n '21 p' $TMP_FOLDER/input_params.txt)
pad_mode=$(sed -n '22 p' $TMP_FOLDER/input_params.txt)
roate=$(sed -n '23 p' $TMP_FOLDER/input_params.txt)
crop_x=$(sed -n '24 p' $TMP_FOLDER/input_params.txt)
crop_y=$(sed -n '25 p' $TMP_FOLDER/input_params.txt)
crop_w=$(sed -n '26 p' $TMP_FOLDER/input_params.txt)
crop_h=$(sed -n '27 p' $TMP_FOLDER/input_params.txt)
bCropFirstly=$(sed -n '28 p' $TMP_FOLDER/input_params.txt)
raw_img_fmt=$(sed -n '29 p' $TMP_FOLDER/input_params.txt)
input_img_width=$(sed -n '30 p' $TMP_FOLDER/input_params.txt)
input_img_height=$(sed -n '31 p' $TMP_FOLDER/input_params.txt)
add_norm=$(sed -n '32 p' $TMP_FOLDER/input_params.txt)
model_input_name=$(sed -n '33 p' $TMP_FOLDER/input_params.txt)
rm -f $TMP_FOLDER/input_params.txt
}