Skip to content

Commit

Permalink
[squeezeformer] Support ONNX export. (#1593)
Browse files Browse the repository at this point in the history
  • Loading branch information
yygle authored Dec 1, 2022
1 parent ed2060c commit cd0d9cb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions wenet/squeezeformer/encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def forward_chunk(
recover_pos_emb, recover_mask_pad) \
= recover_activations[index]
# recover output length for ctc decode
xs = torch.repeat_interleave(xs, repeats=2, dim=1)
xs = xs.unsqueeze(2).repeat(1, 1, 2, 1).flatten(1, 2)
xs = self.time_recover_layer(xs)
recoverd_t = recover_tensor.size(1)
xs = recover_tensor + xs[:, :recoverd_t, :].contiguous()
Expand All @@ -391,7 +391,8 @@ def forward_chunk(
cached_att \
= new_att_cache[:, :, next_cache_start // factor:, :]
cached_cnn = new_cnn_cache.unsqueeze(0)
cached_att = cached_att.repeat_interleave(repeats=factor, dim=2)
cached_att = cached_att.unsqueeze(3).\
repeat(1, 1, 1, factor, 1).flatten(2, 3)
if i == 0:
# record length for the first block as max length
max_att_len = cached_att.size(2)
Expand Down

0 comments on commit cd0d9cb

Please sign in to comment.