Skip to content

Commit

Permalink
optimize: mps audio quality by contiguous scores (#373)
Browse files Browse the repository at this point in the history
Ensuring logits scores are contiguous resolved the bug on MPS
  • Loading branch information
LeoN0425 authored Jun 20, 2024
1 parent 3a936ea commit 654b0f2
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions ChatTTS/utils/infer_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> to
freq = F.one_hot(input_ids, scores.size(1)).sum(1)
freq[self.max_input_ids:] = 0
alpha = self.penalty**freq
scores = scores.contiguous()
scores = torch.where(scores < 0, scores*alpha, scores/alpha)

return scores
Expand Down

0 comments on commit 654b0f2

Please sign in to comment.