提交 5d7b2ce8 编写于 作者: B breezedeus

fix: different devices when running in gpu

上级 2d4877d6
......@@ -65,7 +65,9 @@ class CTCPostProcessor(object):
best_path = torch.argmax(probs, dim=1) # [N, T]
if input_lengths is not None:
length_mask = gen_length_mask(input_lengths, probs.shape) # [N, 1, T]
length_mask = gen_length_mask(input_lengths, probs.shape).to(
device=probs.device
) # [N, 1, T]
probs.masked_fill_(length_mask, 1.0)
best_path.masked_fill_(length_mask.squeeze(1), blank)
......@@ -102,4 +104,4 @@ class CTCPostProcessor(object):
vocab=self.vocab,
input_lengths=input_lengths,
blank=len(self.vocab),
)
\ No newline at end of file
)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册