Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 12 additions & 27 deletions PyTorch/SpeechSynthesis/Tacotron2/exports/export_tacotron2_onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,9 @@ def main():
do_constant_folding=True,
input_names=["sequences", "sequence_lengths"],
output_names=["memory", "processed_memory", "lens"],
dynamic_axes={"sequences": {0: "batch_size", 1: "text_seq"},
"sequence_lengths": {0: "batch_size"},
"memory": {0: "batch_size", 1: "mem_seq"},
"processed_memory": {0: "batch_size", 1: "mem_seq"},
"lens": {0: "batch_size"},
dynamic_axes={"sequences": {1: "text_seq"},
"memory": {1: "mem_seq"},
"processed_memory": {1: "mem_seq"}
})

decoder_iter = DecoderIter(tacotron2)
Expand Down Expand Up @@ -379,26 +377,13 @@ def main():
"out_attention_weights",
"out_attention_weights_cum",
"out_attention_context"],
dynamic_axes={"decoder_input" : {0: "batch_size"},
"attention_hidden" : {0: "batch_size"},
"attention_cell" : {0: "batch_size"},
"decoder_hidden" : {0: "batch_size"},
"decoder_cell" : {0: "batch_size"},
"attention_weights" : {0: "batch_size", 1: "seq_len"},
"attention_weights_cum" : {0: "batch_size", 1: "seq_len"},
"attention_context" : {0: "batch_size"},
"memory" : {0: "batch_size", 1: "seq_len"},
"processed_memory" : {0: "batch_size", 1: "seq_len"},
"mask" : {0: "batch_size", 1: "seq_len"},
"decoder_output" : {0: "batch_size"},
"gate_prediction" : {0: "batch_size"},
"out_attention_hidden" : {0: "batch_size"},
"out_attention_cell" : {0: "batch_size"},
"out_decoder_hidden" : {0: "batch_size"},
"out_decoder_cell" : {0: "batch_size"},
"out_attention_weights" : {0: "batch_size", 1: "seq_len"},
"out_attention_weights_cum" : {0: "batch_size", 1: "seq_len"},
"out_attention_context" : {0: "batch_size"}
dynamic_axes={"attention_weights" : {1: "seq_len"},
"attention_weights_cum" : {1: "seq_len"},
"memory" : {1: "seq_len"},
"processed_memory" : {1: "seq_len"},
"mask" : {1: "seq_len"},
"out_attention_weights" : {1: "seq_len"},
"out_attention_weights_cum" : {1: "seq_len"}
})

postnet = Postnet(tacotron2)
Expand All @@ -410,8 +395,8 @@ def main():
do_constant_folding=True,
input_names=["mel_outputs"],
output_names=["mel_outputs_postnet"],
dynamic_axes={"mel_outputs": {0: "batch_size", 2: "mel_seq"},
"mel_outputs_postnet": {0: "batch_size", 2: "mel_seq"}})
dynamic_axes={"mel_outputs": {2: "mel_seq"},
"mel_outputs_postnet": {2: "mel_seq"}})

mel = test_inference(encoder, decoder_iter, postnet)
torch.save(mel, "mel.pt")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ def export_onnx(parser, args):
do_constant_folding=True,
input_names=["mel", "z"],
output_names=["audio"],
dynamic_axes={"mel": {0: "batch_size", 2: "mel_seq"},
"z": {0: "batch_size", 2: "z_seq"},
"audio": {0: "batch_size", 1: "audio_seq"}})
dynamic_axes={"mel": {2: "mel_seq"},
"z": {2: "z_seq"},
"audio": {1: "audio_seq"}})


def main():
Expand Down
2 changes: 1 addition & 1 deletion PyTorch/SpeechSynthesis/Tacotron2/trt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@ Our results were obtained by running the `./trt/run_latency_tests_trt.sh` script

|Framework|Batch size|Input length|Precision|Avg latency (s)|Latency std (s)|Latency confidence interval 90% (s)|Latency confidence interval 95% (s)|Latency confidence interval 99% (s)|Throughput (samples/sec)|Speed-up PyT+TRT/TRT|Avg mels generated (81 mels=1 sec of speech)|Avg audio length (s)|Avg RTF|
|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|
|PyT+TRT|1| 128| FP16| 1.13| 0.01| 1.15| 1.15| 1.16| 137,738| 1.45| 608| 7.06| 6.24|
|PyT+TRT|1| 128| FP16| 1.02| 0.05| 1.09| 1.10| 1.14| 150,439| 1.59| 602| 6.99| 6.86|
|PyT |1| 128| FP16| 1.63| 0.07| 1.71| 1.73| 1.81| 94,758| 1.00| 601| 6.98| 4.30|
28 changes: 14 additions & 14 deletions PyTorch/SpeechSynthesis/Tacotron2/trt/export_onnx2trt.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def main():
engine_prec = "_fp16" if args.fp16 else "_fp32"

# Encoder
shapes=[{"name": "sequences", "min": (1,4), "opt": (1,128), "max": (4,256)},
{"name": "sequence_lengths", "min": (1,), "opt": (1,), "max": (4,)}]
shapes=[{"name": "sequences", "min": (1,4), "opt": (1,128), "max": (1,256)},
{"name": "sequence_lengths", "min": (1,), "opt": (1,), "max": (1,)}]
if args.encoder != "":
print("Building Encoder ...")
encoder_engine = build_engine(args.encoder, shapes=shapes, fp16=args.fp16)
Expand All @@ -79,17 +79,17 @@ def main():
sys.exit()

# DecoderIter
shapes=[{"name": "decoder_input", "min": (1,80), "opt": (1,80), "max": (4,80)},
{"name": "attention_hidden", "min": (1,1024), "opt": (1,1024), "max": (4,1024)},
{"name": "attention_cell", "min": (1,1024), "opt": (1,1024), "max": (4,1024)},
{"name": "decoder_hidden", "min": (1,1024), "opt": (1,1024), "max": (4,1024)},
{"name": "decoder_cell", "min": (1,1024), "opt": (1,1024), "max": (4,1024)},
{"name": "attention_weights", "min": (1,4), "opt": (1,128), "max": (4,256)},
{"name": "attention_weights_cum", "min": (1,4), "opt": (1,128), "max": (4,256)},
{"name": "attention_context", "min": (1,512), "opt": (1,512), "max": (4,512)},
{"name": "memory", "min": (1,4,512), "opt": (1,128,512), "max": (4,256,512)},
{"name": "processed_memory", "min": (1,4,128), "opt": (1,128,128), "max": (4,256,128)},
{"name": "mask", "min": (1,4), "opt": (1,128), "max": (4,256)}]
shapes=[{"name": "decoder_input", "min": (1,80), "opt": (1,80), "max": (1,80)},
{"name": "attention_hidden", "min": (1,1024), "opt": (1,1024), "max": (1,1024)},
{"name": "attention_cell", "min": (1,1024), "opt": (1,1024), "max": (1,1024)},
{"name": "decoder_hidden", "min": (1,1024), "opt": (1,1024), "max": (1,1024)},
{"name": "decoder_cell", "min": (1,1024), "opt": (1,1024), "max": (1,1024)},
{"name": "attention_weights", "min": (1,4), "opt": (1,128), "max": (1,256)},
{"name": "attention_weights_cum", "min": (1,4), "opt": (1,128), "max": (1,256)},
{"name": "attention_context", "min": (1,512), "opt": (1,512), "max": (1,512)},
{"name": "memory", "min": (1,4,512), "opt": (1,128,512), "max": (1,256,512)},
{"name": "processed_memory", "min": (1,4,128), "opt": (1,128,128), "max": (1,256,128)},
{"name": "mask", "min": (1,4), "opt": (1,128), "max": (1,256)}]
if args.decoder != "":
print("Building Decoder ...")
decoder_iter_engine = build_engine(args.decoder, shapes=shapes, fp16=args.fp16)
Expand All @@ -101,7 +101,7 @@ def main():
sys.exit()

# Postnet
shapes=[{"name": "mel_outputs", "min": (1,80,32), "opt": (1,80,768), "max": (4,80,1664)}]
shapes=[{"name": "mel_outputs", "min": (1,80,32), "opt": (1,80,768), "max": (1,80,1664)}]
if args.postnet != "":
print("Building Postnet ...")
postnet_engine = build_engine(args.postnet, shapes=shapes, fp16=args.fp16)
Expand Down