Skip to content

Commit 47ef794

Browse files
authored
Apply Occam's Razor in position embedding calculation (#11562)
* fix: remove redundant indexing * style
1 parent b272807 commit 47ef794

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/diffusers/models/embeddings.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,9 +1149,7 @@ def get_1d_rotary_pos_embed(
11491149

11501150
theta = theta * ntk_factor
11511151
freqs = (
1152-
1.0
1153-
/ (theta ** (torch.arange(0, dim, 2, dtype=freqs_dtype, device=pos.device)[: (dim // 2)] / dim))
1154-
/ linear_factor
1152+
1.0 / (theta ** (torch.arange(0, dim, 2, dtype=freqs_dtype, device=pos.device) / dim)) / linear_factor
11551153
) # [D/2]
11561154
freqs = torch.outer(pos, freqs) # type: ignore # [S, D/2]
11571155
is_npu = freqs.device.type == "npu"

0 commit comments

Comments
 (0)