Skip to content

Commit 48b67d6

Browse files
committed
update code
1 parent 0666a53 commit 48b67d6

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

tests/pipelines/animatediff/test_animatediff.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ def test_inference_batch_single_identical(
272272
max_diff = np.abs(to_np(output_batch[0][0]) - to_np(output[0][0])).max()
273273
assert max_diff < expected_max_diff
274274

275+
@unittest.skipIf(torch_device = "cpu", reason="Hardware Accelerator and CPU are required to switch devices")
275276
def test_to_device(self):
276277
components = self.get_dummy_components()
277278
pipe = self.pipeline_class(**components)

tests/pipelines/latent_diffusion/test_latent_diffusion_superresolution.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def test_inference_superresolution(self):
9393

9494
assert np.abs(image_slice.flatten() - expected_slice).max() < 1e-2
9595

96+
@unittest.skipIf(torch_device = "cpu", "This test requires a hardware accelerator")
9697
def test_inference_superresolution_fp16(self):
9798
unet = self.dummy_uncond_unet
9899
scheduler = DDIMScheduler()

tests/pipelines/test_pipelines_common.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -771,8 +771,8 @@ def test_from_pipe_consistent_forward_pass(self, expected_max_diff=1e-3):
771771
), "`from_pipe` changed the attention processor in original pipeline."
772772

773773
@unittest.skipIf(
774-
not is_accelerate_available() or is_accelerate_version("<", "0.14.0"),
775-
reason="CPU offload is only available with `accelerate v0.14.0` or higher",
774+
torch_device = "cpu" or not is_accelerate_available() or is_accelerate_version("<", "0.14.0"),
775+
reason="CPU offload is only available with hardware accelerator and `accelerate v0.14.0` or higher",
776776
)
777777
def test_from_pipe_consistent_forward_pass_cpu_offload(self, expected_max_diff=1e-3):
778778
components = self.get_dummy_components()
@@ -1317,6 +1317,7 @@ def test_save_load_optional_components(self, expected_max_difference=1e-4):
13171317
max_diff = np.abs(to_np(output) - to_np(output_loaded)).max()
13181318
self.assertLess(max_diff, expected_max_difference)
13191319

1320+
@unittest.skipIf(torch_device = "cpu", reason="Hardware accelerator and CPU are required to switch devices")
13201321
def test_to_device(self):
13211322
components = self.get_dummy_components()
13221323
pipe = self.pipeline_class(**components)
@@ -1391,8 +1392,8 @@ def _test_attention_slicing_forward_pass(
13911392
assert_mean_pixel_difference(to_np(output_with_slicing2[0]), to_np(output_without_slicing[0]))
13921393

13931394
@unittest.skipIf(
1394-
not is_accelerate_available() or is_accelerate_version("<", "0.14.0"),
1395-
reason="CPU offload is only available with `accelerate v0.14.0` or higher",
1395+
torch_device = "cpu" or not is_accelerate_available() or is_accelerate_version("<", "0.14.0"),
1396+
reason="CPU offload is only available with hardware accelerator and `accelerate v0.14.0` or higher",
13961397
)
13971398
def test_sequential_cpu_offload_forward_pass(self, expected_max_diff=1e-4):
13981399
import accelerate
@@ -1454,8 +1455,8 @@ def test_sequential_cpu_offload_forward_pass(self, expected_max_diff=1e-4):
14541455
)
14551456

14561457
@unittest.skipIf(
1457-
not is_accelerate_available() or is_accelerate_version("<", "0.17.0"),
1458-
reason="CPU offload is only available with `accelerate v0.17.0` or higher",
1458+
torch_device = "cpu" or not is_accelerate_available() or is_accelerate_version("<", "0.17.0"),
1459+
reason="CPU offload is only available with hardware accelerator and `accelerate v0.17.0` or higher",
14591460
)
14601461
def test_model_cpu_offload_forward_pass(self, expected_max_diff=2e-4):
14611462
import accelerate
@@ -1511,8 +1512,8 @@ def test_model_cpu_offload_forward_pass(self, expected_max_diff=2e-4):
15111512
)
15121513

15131514
@unittest.skipIf(
1514-
not is_accelerate_available() or is_accelerate_version("<", "0.17.0"),
1515-
reason="CPU offload is only available with `accelerate v0.17.0` or higher",
1515+
torch_device = "cpu" or not is_accelerate_available() or is_accelerate_version("<", "0.17.0"),
1516+
reason="CPU offload is only available with hardware accelerator and `accelerate v0.17.0` or higher",
15161517
)
15171518
def test_cpu_offload_forward_pass_twice(self, expected_max_diff=2e-4):
15181519
import accelerate
@@ -1568,8 +1569,8 @@ def test_cpu_offload_forward_pass_twice(self, expected_max_diff=2e-4):
15681569
)
15691570

15701571
@unittest.skipIf(
1571-
not is_accelerate_available() or is_accelerate_version("<", "0.14.0"),
1572-
reason="CPU offload is only available with `accelerate v0.14.0` or higher",
1572+
torch_device = "cpu" or not is_accelerate_available() or is_accelerate_version("<", "0.14.0"),
1573+
reason="CPU offload is only available with hardware accelerator and `accelerate v0.14.0` or higher",
15731574
)
15741575
def test_sequential_offload_forward_pass_twice(self, expected_max_diff=2e-4):
15751576
import accelerate

0 commit comments

Comments
 (0)