Fix overflow in FP16
This commit is contained in:
parent
f9f74fda55
commit
220f772e9a
|
@ -51,7 +51,7 @@ class InvalidScoreLogitsProcessor(LogitsProcessor):
|
||||||
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> torch.FloatTensor:
|
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> torch.FloatTensor:
|
||||||
if torch.isnan(scores).any() or torch.isinf(scores).any():
|
if torch.isnan(scores).any() or torch.isinf(scores).any():
|
||||||
scores.zero_()
|
scores.zero_()
|
||||||
scores[..., 20005] = 1e5
|
scores[..., 20005] = 5e4
|
||||||
return scores
|
return scores
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue