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
2ee32159
Unverified
Commit
2ee32159
authored
Sep 04, 2024
by
Fanli Lin
Committed by
GitHub
Sep 03, 2024
Browse files
[tests] make 2 tests device-agnostic (#9347)
* enabel on xpu * fix style
parent
8ecf499d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
tests/models/autoencoders/test_models_vae.py
tests/models/autoencoders/test_models_vae.py
+4
-4
No files found.
tests/models/autoencoders/test_models_vae.py
View file @
2ee32159
...
@@ -1036,9 +1036,9 @@ class ConsistencyDecoderVAEIntegrationTests(unittest.TestCase):
...
@@ -1036,9 +1036,9 @@ class ConsistencyDecoderVAEIntegrationTests(unittest.TestCase):
"https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
"https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
"/img2img/sketch-mountains-input.jpg"
"/img2img/sketch-mountains-input.jpg"
).
resize
((
256
,
256
))
).
resize
((
256
,
256
))
image
=
torch
.
from_numpy
(
np
.
array
(
image
).
transpose
(
2
,
0
,
1
).
astype
(
np
.
float32
)
/
127.5
-
1
)[
image
=
torch
.
from_numpy
(
np
.
array
(
image
).
transpose
(
2
,
0
,
1
).
astype
(
np
.
float32
)
/
127.5
-
1
)[
None
,
:,
:,
:].
to
(
None
,
:,
:,
:
torch_device
].
cuda
(
)
)
latent
=
vae
.
encode
(
image
).
latent_dist
.
mean
latent
=
vae
.
encode
(
image
).
latent_dist
.
mean
...
@@ -1079,7 +1079,7 @@ class ConsistencyDecoderVAEIntegrationTests(unittest.TestCase):
...
@@ -1079,7 +1079,7 @@ class ConsistencyDecoderVAEIntegrationTests(unittest.TestCase):
image
=
(
image
=
(
torch
.
from_numpy
(
np
.
array
(
image
).
transpose
(
2
,
0
,
1
).
astype
(
np
.
float32
)
/
127.5
-
1
)[
None
,
:,
:,
:]
torch
.
from_numpy
(
np
.
array
(
image
).
transpose
(
2
,
0
,
1
).
astype
(
np
.
float32
)
/
127.5
-
1
)[
None
,
:,
:,
:]
.
half
()
.
half
()
.
cuda
(
)
.
to
(
torch_device
)
)
)
latent
=
vae
.
encode
(
image
).
latent_dist
.
mean
latent
=
vae
.
encode
(
image
).
latent_dist
.
mean
...
...
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