Skip to content

Commit 2ee3215

Browse files
authored
[tests] make 2 tests device-agnostic (#9347)
* enabel on xpu * fix style
1 parent 8ecf499 commit 2ee3215

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tests/models/autoencoders/test_models_vae.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,9 +1036,9 @@ def test_encode_decode(self):
10361036
"https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
10371037
"/img2img/sketch-mountains-input.jpg"
10381038
).resize((256, 256))
1039-
image = torch.from_numpy(np.array(image).transpose(2, 0, 1).astype(np.float32) / 127.5 - 1)[
1040-
None, :, :, :
1041-
].cuda()
1039+
image = torch.from_numpy(np.array(image).transpose(2, 0, 1).astype(np.float32) / 127.5 - 1)[None, :, :, :].to(
1040+
torch_device
1041+
)
10421042

10431043
latent = vae.encode(image).latent_dist.mean
10441044

@@ -1079,7 +1079,7 @@ def test_encode_decode_f16(self):
10791079
image = (
10801080
torch.from_numpy(np.array(image).transpose(2, 0, 1).astype(np.float32) / 127.5 - 1)[None, :, :, :]
10811081
.half()
1082-
.cuda()
1082+
.to(torch_device)
10831083
)
10841084

10851085
latent = vae.encode(image).latent_dist.mean

0 commit comments

Comments
 (0)