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
dcf836cf
"src/git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "561ab54de3d3aaa9007e76aeb3b15e8be3ed353f"
Unverified
Commit
dcf836cf
authored
Apr 14, 2025
by
hlky
Committed by
GitHub
Apr 14, 2025
Browse files
Use float32 on mps or npu in transformer_hidream_image's rope (#11316)
parent
1cb73cb1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
src/diffusers/models/transformers/transformer_hidream_image.py
...iffusers/models/transformers/transformer_hidream_image.py
+6
-1
No files found.
src/diffusers/models/transformers/transformer_hidream_image.py
View file @
dcf836cf
...
@@ -95,7 +95,12 @@ class HiDreamImagePatchEmbed(nn.Module):
...
@@ -95,7 +95,12 @@ class HiDreamImagePatchEmbed(nn.Module):
def
rope
(
pos
:
torch
.
Tensor
,
dim
:
int
,
theta
:
int
)
->
torch
.
Tensor
:
def
rope
(
pos
:
torch
.
Tensor
,
dim
:
int
,
theta
:
int
)
->
torch
.
Tensor
:
assert
dim
%
2
==
0
,
"The dimension must be even."
assert
dim
%
2
==
0
,
"The dimension must be even."
scale
=
torch
.
arange
(
0
,
dim
,
2
,
dtype
=
torch
.
float64
,
device
=
pos
.
device
)
/
dim
is_mps
=
pos
.
device
.
type
==
"mps"
is_npu
=
pos
.
device
.
type
==
"npu"
dtype
=
torch
.
float32
if
(
is_mps
or
is_npu
)
else
torch
.
float64
scale
=
torch
.
arange
(
0
,
dim
,
2
,
dtype
=
dtype
,
device
=
pos
.
device
)
/
dim
omega
=
1.0
/
(
theta
**
scale
)
omega
=
1.0
/
(
theta
**
scale
)
batch_size
,
seq_length
=
pos
.
shape
batch_size
,
seq_length
=
pos
.
shape
...
...
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