Skip to content

Commit 5eb121f

Browse files
committed
up
1 parent 2515423 commit 5eb121f

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

tests/modular_pipelines/test_modular_pipelines_common.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from diffusers.guiders import ClassifierFreeGuidance
1111
from diffusers.utils import logging
1212

13-
from ..testing_utils import backend_empty_cache, numpy_cosine_similarity_distance, torch_device
13+
from ..testing_utils import backend_empty_cache, numpy_cosine_similarity_distance, require_accelerator, torch_device
1414

1515

1616
class ModularPipelineTesterMixin:
@@ -197,7 +197,7 @@ def test_inference_batch_single_identical(
197197
max_diff = torch.abs(output_batch[0] - output[0]).max()
198198
assert max_diff < expected_max_diff, "Batch inference results different from single inference results"
199199

200-
@pytest.mark.skipif(torch_device == "cpu", reason="Test needs an accelerator.")
200+
@require_accelerator
201201
def test_float16_inference(self, expected_max_diff=5e-2):
202202
pipe = self.get_pipeline()
203203
pipe.to(torch_device, torch.float32)
@@ -223,7 +223,7 @@ def test_float16_inference(self, expected_max_diff=5e-2):
223223
max_diff = numpy_cosine_similarity_distance(output.flatten(), output_fp16.flatten())
224224
assert max_diff < expected_max_diff, "FP16 inference is different from FP32 inference"
225225

226-
@pytest.mark.skipif(torch_device == "cpu", reason="Test needs an accelerator.")
226+
@require_accelerator
227227
def test_to_device(self):
228228
pipe = self.get_pipeline().to("cpu")
229229

@@ -246,7 +246,7 @@ def test_inference_is_not_nan_cpu(self):
246246
output = pipe(**self.get_dummy_inputs(), output="images")
247247
assert torch.isnan(output).sum() == 0, "CPU Inference returns NaN"
248248

249-
@pytest.mark.skipif(torch_device == "cpu", reason="Test needs an accelerator.")
249+
@require_accelerator
250250
def test_inference_is_not_nan(self):
251251
pipe = self.get_pipeline().to(torch_device)
252252

@@ -274,7 +274,7 @@ def test_num_images_per_prompt(self):
274274

275275
assert images.shape[0] == batch_size * num_images_per_prompt
276276

277-
@pytest.mark.skipif(torch_device == "cpu", reason="Test needs an accelerator.")
277+
@require_accelerator
278278
def test_components_auto_cpu_offload_inference_consistent(self):
279279
base_pipe = self.get_pipeline().to(torch_device)
280280

0 commit comments

Comments
 (0)