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
da7e3994
Unverified
Commit
da7e3994
authored
Sep 13, 2022
by
Kashif Rasul
Committed by
GitHub
Sep 13, 2022
Browse files
Fix vae tests for cpu and gpu (#480)
parent
55f7ca3b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
tests/test_models_vae.py
tests/test_models_vae.py
+11
-3
No files found.
tests/test_models_vae.py
View file @
da7e3994
...
...
@@ -104,7 +104,15 @@ class AutoencoderKLTests(ModelTesterMixin, unittest.TestCase):
output_slice
=
output
[
0
,
-
1
,
-
3
:,
-
3
:].
flatten
().
cpu
()
# fmt: off
expected_output_slice
=
torch
.
tensor
([
-
0.1352
,
0.0878
,
0.0419
,
-
0.0818
,
-
0.1069
,
0.0688
,
-
0.1458
,
-
0.4446
,
-
0.0026
])
# fmt: on
# Since the VAE Gaussian prior's generator is seeded on the appropriate device,
# the expected output slices are not the same for CPU and GPU.
if
torch_device
in
(
"mps"
,
"cpu"
):
expected_output_slice
=
torch
.
tensor
(
[
-
0.1352
,
0.0878
,
0.0419
,
-
0.0818
,
-
0.1069
,
0.0688
,
-
0.1458
,
-
0.4446
,
-
0.0026
]
)
else
:
expected_output_slice
=
torch
.
tensor
(
[
-
0.2421
,
0.4642
,
0.2507
,
-
0.0438
,
0.0682
,
0.3160
,
-
0.2018
,
-
0.0727
,
0.2485
]
)
self
.
assertTrue
(
torch
.
allclose
(
output_slice
,
expected_output_slice
,
rtol
=
1e-2
))
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