-
Notifications
You must be signed in to change notification settings - Fork 0
/
rundemo.sh
executable file
·90 lines (84 loc) · 2.19 KB
/
rundemo.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
#!/bin/bash
help(){
echo "> Usage: rundemo.sh < target platform > "
echo "> rundemo.sh --target=<fpga|gpu|cpu> --json=<input.json> --build=<y=build|Y=clean and build|n= don't build>"
exit 1
}
create_modelfolders(){
# check if output dir exists. If not, create it
json=$1
if [ -f "$json" ]; then
echo "> Input JSON: $json"
mname=`cat $json | grep mname | cut -d: -f2 | cut -d\" -f2`
echo "> Model Name: $mname"
else
echo "> Input JSON: $json (File not found!)"
exit;
fi
outdir=`cat $json | grep outdir | cut -d: -f2 | cut -d\" -f2`
if [ -d "$outdir" ]; then
echo "> Outdir: $outdir "
else
echo "> Outdir: $outdir (Not found!)"
mkdir -p $outdir
fi
# create output tmp files
inputpath=$json
outdir_log="$outdir/log"
outdir_tmp="$outdir/tmp"
outdir_img="$outdir/img"
mkdir -p $outdir_log
mkdir -p $outdir_tmp
mkdir -p $outdir_img
# check if datdir exists. If not, create it
datdir=`cat $json | grep datdir | cut -d: -f2 | cut -d\" -f2`
if [ -d "$datdir" ]; then
echo "> Datdir: $datdir"
else
echo "> Datdir: $datdir (Not found!)"
mkdir -p $datdir
fi
}
## default vars
target="gpu"
acc="off"
build="y"
jsonPath=""
runscript="script/runcpu.sh"
reportdir="data"
fpgakernel="data/kernel/hw/rtmforward_maxY128_maxZ512_b16_nPEZ4_nPEX2_nFSM2.xclbin"
# fpgakernel="data/kernel/sw_emu/rtmforward_maxY128_maxZ256_b16_nPEZ4_nPEX2_nFSM2.xclbin"
while [ $# -gt 0 ]; do
case "$1" in
--target=*)
target="${1#*=}"
;;
--json=*)
jsonPath="${1#*=}"
;;
--build=*)
build="${1#*=}"
;;
--xclbin=*)
fpgakernel="${1#*=}"
;;
*)
help
esac
shift
done
create_modelfolders $jsonPath
if [ "$target" = "gpu" ];then
runscript="script/rungpu.sh"
./$runscript $jsonPath $build $outdir_log
elif [ "$target" = "fpga" ];then
runscript="script/runfpga.sh"
if [ "$fpgakernel" != "" ]; then
./$runscript $jsonPath $build $outdir_log $fpgakernel
else
./$runscript $jsonPath $build $outdir_log
fi
else
runscript="script/runcpu.sh"
./$runscript $jsonPath $build $outdir_log
fi