-
Notifications
You must be signed in to change notification settings - Fork 3
/
run_generator.sh
executable file
·114 lines (93 loc) · 4.02 KB
/
run_generator.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash
mkdir -p ../example/test_demo
mkdir -p ../example/test_demo/hls_impl
mkdir -p ../example/test_demo/inference_net
mkdir -p ../example/test_demo/inference_net/stb_image
mkdir -p ../example/test_demo/net_inputs
copy_file(){
if [ -e $1 ]
then
if [[ $3 -eq 1 ]]
then
cp -f $1 $2
else
cp -r $1 $2
fi
else
echo "No $1 file"
fi
}
printf "\nPlease make sure the net_mean.txt,net_weights.txt and net_config_params.txt (and batch_norm_mean.txt,batch_norm_denominator.txt,scale_gamma.txt,scale_beta.txt and so on) have already generated in caffe_converter folder!\n\n"
read -p "Please enter test image path: " test_img_folder
read -p "Please enter test image name: " test_img_name
prm_file_name="net_config_params.txt"
if [ -f $prm_file_name ] ; then
rm $prm_file_name
fi
#copy_file "../caffe_converter/$prm_file_name" "." 1
copy_file "./examples/lenet/$prm_file_name" "." 1
if grep -q "lrn" "$prm_file_name";
then
copy_file "../fpga_cnn/lrn_layer_one_dim.h" "../example/test_demo/inference_net/" 1
fi
copy_file "../scripts/hls_script.tcl" "../example/test_demo/hls_impl/" 1
copy_file "../scripts/syn.sh" "../example/test_demo/hls_impl/" 1
copy_file "../stb_image" "../example/test_demo/inference_net/" 2
copy_file "../fpga_cnn/data_type.h" "../example/test_demo/inference_net/" 1
copy_file "../fpga_cnn/activation_functions.h" "../example/test_demo/inference_net/" 1
copy_file "../fpga_cnn/pow_function.h" "../example/test_demo/inference_net/" 1
copy_file "../fpga_cnn/softmax_one_dim.h" "../example/test_demo/inference_net/" 1
copy_file "../fpga_cnn/weight_bias_one_dim.h" "../example/test_demo/inference_net/" 1
copy_file "../fpga_cnn/image_converter.h" "../example/test_demo/inference_net/" 1
mkdir ../example/test_demo/net_inputs/test_imgs
copy_file "$test_img_folder/$test_img_name" "../example/test_demo/net_inputs/test_imgs/" 1
net_mean_name="../caffe_converter/net_mean.txt"
if [ -f $net_mean_name ] ; then
copy_file "../caffe_converter/net_mean.txt" "../example/test_demo/net_inputs/" 1
fi
copy_file "../caffe_converter/net_weights.txt" "../example/test_demo/net_inputs/" 1
#copy_file "$test_img_folder/val.txt" "../example/test_demo/net_inputs/" 1
copy_file "../scripts/Makefile" "../example/test_demo/" 1
copy_file "../fpga_cnn/predict_one_dim.h" "../example/test_demo/inference_net/" 1
copy_file "../fpga_cnn/accuracy_one_dim.h" "../example/test_demo/inference_net/" 1
copy_file "../fpga_cnn/resize_image.h" "../example/test_demo/inference_net/" 1
python generator_config.py $prm_file_name
python generator_ff_test.py $prm_file_name $test_img_name
python generator_acc_instance.py $prm_file_name
python generator.py $prm_file_name
python generator_conv_acc.py $prm_file_name
if grep -q "Max" "$prm_file_name";
then
python generator_max_pool_acc.py $prm_file_name
fi
if grep -q "Ave" "$prm_file_name";
then
python generator_ave_pool_acc.py $prm_file_name
fi
if grep -q "lrn" "$prm_file_name";
then
copy_file "../fpga_cnn/lrn_layer_one_dim.h" "../example/test_demo/inference_net/" 1
fi
if grep -q "BatchNorm" "$prm_file_name";
then
copy_file "../fpga_cnn/get_batch_norm_params.h" "../example/test_demo/inference_net/" 1
copy_file "../caffe_converter/batch_norm_mean.txt" "../example/test_demo/net_inputs/" 1
copy_file "../caffe_converter/batch_norm_denominator.txt" "../example/test_demo/net_inputs/" 1
python generator_conv_acc_w_bn.py $prm_file_name
if grep -q "Scale" "$prm_file_name";
then
copy_file "../fpga_cnn/batch_norm_scale_layer.h" "../example/test_demo/inference_net/" 1
copy_file "../caffe_converter/scale_gamma.txt" "../example/test_demo/net_inputs/" 1
copy_file "../caffe_converter/scale_beta.txt" "../example/test_demo/net_inputs/" 1
fi
fi
if grep -q "Eltwise" "$prm_file_name";
then
copy_file "../fpga_cnn/eltwise_layer.h" "../example/test_demo/inference_net/" 1
python generator_conv_acc_fc.py $prm_file_name
fi
if grep -q "Concat" "$prm_file_name";
then
copy_file "../fpga_cnn/concat_layer.h" "../example/test_demo/inference_net/" 1
fi
printf "You've generated the network successfully!\n\n"