-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_infer.sh
114 lines (104 loc) · 2.58 KB
/
test_infer.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
BATCH_SIZE=1
INPUT_LENGTH=128
PRECISION="fp32"
NUM_ITERS=1003 # extra 3 iterations for warmup
TACOTRON2_CKPT="tacotron2_1032590_6000_amp"
WAVEGLOW_CKPT="waveglow_1076430_14000_amp"
AMP_RUN=""
TEST_PROGRAM="test_infer.py"
WN_CHANNELS=256
CPU_RUN=""
while [ -n "$1" ]
do
case "$1" in
-bs|--batch-size)
BATCH_SIZE="$2"
shift
;;
-il|--input-length)
INPUT_LENGTH="$2"
shift
;;
-p|--prec)
PRECISION="$2"
shift
;;
--num-iters)
NUM_ITERS="$2"
shift
;;
--test)
TEST_PROGRAM="$2"
shift
;;
--tacotron2)
TACOTRON2_CKPT="$2"
shift
;;
--encoder)
ENCODER_CKPT="$2"
shift
;;
--decoder)
DECODER_CKPT="$2"
shift
;;
--postnet)
POSTNET_CKPT="$2"
shift
;;
--waveglow)
WAVEGLOW_CKPT="$2"
shift
;;
--wn-channels)
WN_CHANNELS="$2"
shift
;;
--cpu-run)
CPU_RUN="--cpu-run"
shift
;;
*)
echo "Option $1 not recognized"
esac
shift
done
if [ "$PRECISION" = "amp" ]
then
AMP_RUN="--amp-run"
elif [ "$PRECISION" = "fp16" ]
then
AMP_RUN="--fp16"
fi
LOG_SUFFIX=bs${BATCH_SIZE}_il${INPUT_LENGTH}_${PRECISION}
NVLOG_FILE=nvlog_${LOG_SUFFIX}.json
TMP_LOGFILE=tmp_log_${LOG_SUFFIX}.log
LOGFILE=log_${LOG_SUFFIX}.log
if [ "$TEST_PROGRAM" = "trt/test_infer_trt.py" ]
then
TACOTRON2_PARAMS="--encoder $ENCODER_CKPT --decoder $DECODER_CKPT --postnet $POSTNET_CKPT"
else
TACOTRON2_PARAMS="--tacotron2 $TACOTRON2_CKPT"
fi
set -x
python $TEST_PROGRAM \
$TACOTRON2_PARAMS \
--waveglow $WAVEGLOW_CKPT \
--batch-size $BATCH_SIZE \
--input-length $INPUT_LENGTH $AMP_RUN \
--log-file $NVLOG_FILE \
--num-iters $NUM_ITERS \
--wn-channels $WN_CHANNELS \
$CPU_RUN \
|& tee $TMP_LOGFILE
set +x
PERF=$(cat $TMP_LOGFILE | grep -F 'Throughput average (samples/sec)' | awk -F'= ' '{print $2}')
NUM_MELS=$(cat $TMP_LOGFILE | grep -F 'Number of mels per audio average' | awk -F'= ' '{print $2}')
LATENCY=$(cat $TMP_LOGFILE | grep -F 'Latency average (seconds)' | awk -F'= ' '{print $2}')
LATENCYSTD=$(cat $TMP_LOGFILE | grep -F 'Latency std (seconds)' | awk -F'= ' '{print $2}')
LATENCY90=$(cat $TMP_LOGFILE | grep -F 'Latency cl 90 (seconds)' | awk -F'= ' '{print $2}')
LATENCY95=$(cat $TMP_LOGFILE | grep -F 'Latency cl 95 (seconds)' | awk -F'= ' '{print $2}')
LATENCY99=$(cat $TMP_LOGFILE | grep -F 'Latency cl 99 (seconds)' | awk -F'= ' '{print $2}')
echo "$BATCH_SIZE,$INPUT_LENGTH,$PRECISION,$NUM_ITERS,$LATENCY,$LATENCYSTD,$LATENCY90,$LATENCY95,$LATENCY99,$PERF,$NUM_MELS" >> $LOGFILE