forked from huismiling/wenet_trt8
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_ppq.sh
52 lines (44 loc) · 2.19 KB
/
build_ppq.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
#!/bin/bash
set -x
workspace=24576
git submodule update --init
cd FasterTransformer_wenet
sh build_ft.sh
cd -
rm -rf ./libwenet_plugin.so
ln -s FasterTransformer_wenet/build/lib/libwenet_plugin.so .
# #git clone https://github.com/huismiling/FasterTransformer_wenet.git FasterTransformer_wenet
cd ./other_branch/
tar -xvf ppq.tar
cd ./ppq/
apt install ninja-build
pip3 install -r requirements.txt
pip3 install -v -e .
cd ../quant_ppq/
python3 encoder_fix.py
# python3 encoder_quant.py # no quant for encoder
python3 model_dynamic.py encoder
python3 replace_encoder_ln.py
python3 decoder_quant.py
python3 model_dynamic.py decoder
python3 replace_decoder_ln.py
mv ./encoder_replace.onnx ../../encoder_replace.onnx
mv ./decoder_replace.onnx ../../decoder_replace.onnx
cd ../../
trtexec --onnx=./encoder_replace.onnx --saveEngine=./encoder.plan \
--minShapes=speech:1x1x80,speech_lengths:1,speech_lengths_mask:1x40x40 \
--optShapes=speech:4x750x80,speech_lengths:4,speech_lengths_mask:4x220x220 \
--maxShapes=speech:16x1500x80,speech_lengths:16,speech_lengths_mask:16x400x400 \
--plugins=./libwenet_plugin.so \
--workspace=$workspace --verbose 2>&1 | tee ./log/encoder_build.log
trtexec --onnx=./decoder_replace.onnx --saveEngine=./decoder.plan \
--minShapes=encoder_out:1x40x256,encoder_out_lens:1,hyps_pad_sos_eos:1x10x64,hyps_lens_sos:1x10,ctc_score:1x10,self_attn_mask:10x63x63,cross_attn_mask:10x63x40 \
--optShapes=encoder_out:4x165x256,encoder_out_lens:4,hyps_pad_sos_eos:4x10x64,hyps_lens_sos:4x10,ctc_score:4x10,self_attn_mask:40x63x63,cross_attn_mask:40x63x165 \
--maxShapes=encoder_out:16x370x256,encoder_out_lens:16,hyps_pad_sos_eos:16x10x64,hyps_lens_sos:16x10,ctc_score:16x10,self_attn_mask:160x63x63,cross_attn_mask:160x63x370 \
--plugins=./libwenet_plugin.so --int8 \
--workspace=$workspace --verbose 2>&1 | tee ./log/decoder_build.log
# trtexec --onnx=./encoder_quant_dynamic.onnx --saveEngine=./encoder.plan \
# --minShapes=speech:1x1x80,speech_lengths:1 \
# --optShapes=speech:4x750x80,speech_lengths:4 \
# --maxShapes=speech:16x1500x80,speech_lengths:16 \
# --workspace=24576 --verbose 2>&1 | tee ./log.log