Skip to content

Commit

Permalink
zipformer2 logaddexp onnx safe (#1157)
Browse files Browse the repository at this point in the history
  • Loading branch information
MicKot authored Jun 30, 2023
1 parent ccd8c62 commit 98d8946
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion egs/librispeech/ASR/zipformer/scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def logaddexp(x: Tensor, y: Tensor) -> Tensor:
if not torch.jit.is_tracing():
return torch.logaddexp(x, y)
else:
return (x.exp() + y.exp()).log()
max_value = torch.max(x, y)
diff = torch.abs(x - y)
return max_value + torch.log1p(torch.exp(-diff))

class PiecewiseLinear(object):
"""
Expand Down

0 comments on commit 98d8946

Please sign in to comment.