Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
renzhc
diffusers_dcu
Commits
47ef7946
Unverified
Commit
47ef7946
authored
Jun 12, 2025
by
Tolga Cangöz
Committed by
GitHub
Jun 11, 2025
Browse files
Apply Occam's Razor in position embedding calculation (#11562)
* fix: remove redundant indexing * style
parent
b272807b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
3 deletions
+1
-3
src/diffusers/models/embeddings.py
src/diffusers/models/embeddings.py
+1
-3
No files found.
src/diffusers/models/embeddings.py
View file @
47ef7946
...
@@ -1149,9 +1149,7 @@ def get_1d_rotary_pos_embed(
...
@@ -1149,9 +1149,7 @@ def get_1d_rotary_pos_embed(
theta
=
theta
*
ntk_factor
theta
=
theta
*
ntk_factor
freqs
=
(
freqs
=
(
1.0
1.0
/
(
theta
**
(
torch
.
arange
(
0
,
dim
,
2
,
dtype
=
freqs_dtype
,
device
=
pos
.
device
)
/
dim
))
/
linear_factor
/
(
theta
**
(
torch
.
arange
(
0
,
dim
,
2
,
dtype
=
freqs_dtype
,
device
=
pos
.
device
)[:
(
dim
//
2
)]
/
dim
))
/
linear_factor
)
# [D/2]
)
# [D/2]
freqs
=
torch
.
outer
(
pos
,
freqs
)
# type: ignore # [S, D/2]
freqs
=
torch
.
outer
(
pos
,
freqs
)
# type: ignore # [S, D/2]
is_npu
=
freqs
.
device
.
type
==
"npu"
is_npu
=
freqs
.
device
.
type
==
"npu"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment