1
0
mirror of https://github.com/huggingface/diffusers.git synced 2026-01-27 17:22:53 +03:00

[tests] make 2 tests device-agnostic (#9347)

* enabel on xpu

* fix style
This commit is contained in:
Fanli Lin
2024-09-04 10:34:03 +08:00
committed by GitHub
parent 8ecf499d8b
commit 2ee3215949

View File

@@ -1036,9 +1036,9 @@ class ConsistencyDecoderVAEIntegrationTests(unittest.TestCase):
"https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
"/img2img/sketch-mountains-input.jpg"
).resize((256, 256))
image = torch.from_numpy(np.array(image).transpose(2, 0, 1).astype(np.float32) / 127.5 - 1)[
None, :, :, :
].cuda()
image = torch.from_numpy(np.array(image).transpose(2, 0, 1).astype(np.float32) / 127.5 - 1)[None, :, :, :].to(
torch_device
)
latent = vae.encode(image).latent_dist.mean
@@ -1079,7 +1079,7 @@ class ConsistencyDecoderVAEIntegrationTests(unittest.TestCase):
image = (
torch.from_numpy(np.array(image).transpose(2, 0, 1).astype(np.float32) / 127.5 - 1)[None, :, :, :]
.half()
.cuda()
.to(torch_device)
)
latent = vae.encode(image).latent_dist.mean