Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
diffusers
Commits
cb0bf0bd
Unverified
Commit
cb0bf0bd
authored
Oct 07, 2022
by
Kevin Turner
Committed by
GitHub
Oct 07, 2022
Browse files
fix(DDIM scheduler): use correct dtype for noise (#742)
Otherwise, it crashes when eta > 0 with float16.
parent
e0fece2b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
src/diffusers/schedulers/scheduling_ddim.py
src/diffusers/schedulers/scheduling_ddim.py
+2
-1
No files found.
src/diffusers/schedulers/scheduling_ddim.py
View file @
cb0bf0bd
...
...
@@ -283,8 +283,9 @@ class DDIMScheduler(SchedulerMixin, ConfigMixin):
prev_sample
=
alpha_prod_t_prev
**
(
0.5
)
*
pred_original_sample
+
pred_sample_direction
if
eta
>
0
:
# randn_like does not support generator https://github.com/pytorch/pytorch/issues/27072
device
=
model_output
.
device
if
torch
.
is_tensor
(
model_output
)
else
"cpu"
noise
=
torch
.
randn
(
model_output
.
shape
,
generator
=
generator
).
to
(
device
)
noise
=
torch
.
randn
(
model_output
.
shape
,
dtype
=
model_output
.
dtype
,
generator
=
generator
).
to
(
device
)
variance
=
self
.
_get_variance
(
timestep
,
prev_timestep
)
**
(
0.5
)
*
eta
*
noise
prev_sample
=
prev_sample
+
variance
...
...
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