Skip to content

Commit

Permalink
implement torch.frac() on-GPU.
Browse files Browse the repository at this point in the history
  • Loading branch information
Birch-san committed Nov 5, 2022
1 parent 0602097 commit c56a015
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion k_diffusion/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ def sigma_to_t(self, sigma, quantize=None):

def t_to_sigma(self, t):
t = t.float()
low_idx, high_idx, w = t.floor().long(), t.ceil().long(), t.frac()
low_idx = t.floor().long()
high_idx = t.ceil().long()
w = t-low_idx if t.device.type == 'mps' else t.frac()
log_sigma = (1 - w) * self.log_sigmas[low_idx] + w * self.log_sigmas[high_idx]
return log_sigma.exp()

Expand Down

0 comments on commit c56a015

Please sign in to comment.