mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-01-25 15:55:18 +00:00
Small optimization.
This commit is contained in:
parent
f2e844e054
commit
1281f933c1
@ -243,9 +243,9 @@ class TimestepEmbedder(nn.Module):
|
|||||||
half = dim // 2
|
half = dim // 2
|
||||||
freqs = torch.exp(
|
freqs = torch.exp(
|
||||||
-math.log(max_period)
|
-math.log(max_period)
|
||||||
* torch.arange(start=0, end=half, dtype=torch.float32)
|
* torch.arange(start=0, end=half, dtype=torch.float32, device=t.device)
|
||||||
/ half
|
/ half
|
||||||
).to(device=t.device)
|
)
|
||||||
args = t[:, None].float() * freqs[None]
|
args = t[:, None].float() * freqs[None]
|
||||||
embedding = torch.cat([torch.cos(args), torch.sin(args)], dim=-1)
|
embedding = torch.cat([torch.cos(args), torch.sin(args)], dim=-1)
|
||||||
if dim % 2:
|
if dim % 2:
|
||||||
|
Loading…
Reference in New Issue
Block a user