33
33
UNet2DConditionModel ,
34
34
)
35
35
from diffusers .utils .testing_utils import (
36
+ backend_empty_cache ,
36
37
enable_full_determinism ,
37
38
floats_tensor ,
38
39
load_image ,
39
- require_torch_gpu ,
40
+ require_torch_accelerator ,
40
41
slow ,
41
42
torch_device ,
42
43
)
@@ -395,17 +396,17 @@ def test_marigold_depth_dummy_no_processing_resolution(self):
395
396
396
397
397
398
@slow
398
- @require_torch_gpu
399
+ @require_torch_accelerator
399
400
class MarigoldIntrinsicsPipelineIntegrationTests (unittest .TestCase ):
400
401
def setUp (self ):
401
402
super ().setUp ()
402
403
gc .collect ()
403
- torch . cuda . empty_cache ( )
404
+ backend_empty_cache ( torch_device )
404
405
405
406
def tearDown (self ):
406
407
super ().tearDown ()
407
408
gc .collect ()
408
- torch . cuda . empty_cache ( )
409
+ backend_empty_cache ( torch_device )
409
410
410
411
def _test_marigold_intrinsics (
411
412
self ,
@@ -424,7 +425,7 @@ def _test_marigold_intrinsics(
424
425
from_pretrained_kwargs ["torch_dtype" ] = torch .float16
425
426
426
427
pipe = MarigoldIntrinsicsPipeline .from_pretrained (model_id , ** from_pretrained_kwargs )
427
- if device == "cuda" :
428
+ if device in [ "cuda" , "xpu" ] :
428
429
pipe .enable_model_cpu_offload ()
429
430
pipe .set_progress_bar_config (disable = None )
430
431
@@ -464,10 +465,10 @@ def test_marigold_intrinsics_einstein_f32_cpu_G0_S1_P32_E1_B1_M1(self):
464
465
match_input_resolution = True ,
465
466
)
466
467
467
- def test_marigold_intrinsics_einstein_f32_cuda_G0_S1_P768_E1_B1_M1 (self ):
468
+ def test_marigold_intrinsics_einstein_f32_accelerator_G0_S1_P768_E1_B1_M1 (self ):
468
469
self ._test_marigold_intrinsics (
469
470
is_fp16 = False ,
470
- device = "cuda" ,
471
+ device = torch_device ,
471
472
generator_seed = 0 ,
472
473
expected_slice = np .array ([0.62127 , 0.61906 , 0.61687 , 0.61946 , 0.61903 , 0.61961 , 0.61808 , 0.62099 , 0.62894 ]),
473
474
num_inference_steps = 1 ,
@@ -477,10 +478,10 @@ def test_marigold_intrinsics_einstein_f32_cuda_G0_S1_P768_E1_B1_M1(self):
477
478
match_input_resolution = True ,
478
479
)
479
480
480
- def test_marigold_intrinsics_einstein_f16_cuda_G0_S1_P768_E1_B1_M1 (self ):
481
+ def test_marigold_intrinsics_einstein_f16_accelerator_G0_S1_P768_E1_B1_M1 (self ):
481
482
self ._test_marigold_intrinsics (
482
483
is_fp16 = True ,
483
- device = "cuda" ,
484
+ device = torch_device ,
484
485
generator_seed = 0 ,
485
486
expected_slice = np .array ([0.62109 , 0.61914 , 0.61719 , 0.61963 , 0.61914 , 0.61963 , 0.61816 , 0.62109 , 0.62891 ]),
486
487
num_inference_steps = 1 ,
@@ -490,10 +491,10 @@ def test_marigold_intrinsics_einstein_f16_cuda_G0_S1_P768_E1_B1_M1(self):
490
491
match_input_resolution = True ,
491
492
)
492
493
493
- def test_marigold_intrinsics_einstein_f16_cuda_G2024_S1_P768_E1_B1_M1 (self ):
494
+ def test_marigold_intrinsics_einstein_f16_accelerator_G2024_S1_P768_E1_B1_M1 (self ):
494
495
self ._test_marigold_intrinsics (
495
496
is_fp16 = True ,
496
- device = "cuda" ,
497
+ device = torch_device ,
497
498
generator_seed = 2024 ,
498
499
expected_slice = np .array ([0.64111 , 0.63916 , 0.63623 , 0.63965 , 0.63916 , 0.63965 , 0.6377 , 0.64062 , 0.64941 ]),
499
500
num_inference_steps = 1 ,
@@ -503,10 +504,10 @@ def test_marigold_intrinsics_einstein_f16_cuda_G2024_S1_P768_E1_B1_M1(self):
503
504
match_input_resolution = True ,
504
505
)
505
506
506
- def test_marigold_intrinsics_einstein_f16_cuda_G0_S2_P768_E1_B1_M1 (self ):
507
+ def test_marigold_intrinsics_einstein_f16_accelerator_G0_S2_P768_E1_B1_M1 (self ):
507
508
self ._test_marigold_intrinsics (
508
509
is_fp16 = True ,
509
- device = "cuda" ,
510
+ device = torch_device ,
510
511
generator_seed = 0 ,
511
512
expected_slice = np .array ([0.60254 , 0.60059 , 0.59961 , 0.60156 , 0.60107 , 0.60205 , 0.60254 , 0.60449 , 0.61133 ]),
512
513
num_inference_steps = 2 ,
@@ -516,10 +517,10 @@ def test_marigold_intrinsics_einstein_f16_cuda_G0_S2_P768_E1_B1_M1(self):
516
517
match_input_resolution = True ,
517
518
)
518
519
519
- def test_marigold_intrinsics_einstein_f16_cuda_G0_S1_P512_E1_B1_M1 (self ):
520
+ def test_marigold_intrinsics_einstein_f16_accelerator_G0_S1_P512_E1_B1_M1 (self ):
520
521
self ._test_marigold_intrinsics (
521
522
is_fp16 = True ,
522
- device = "cuda" ,
523
+ device = torch_device ,
523
524
generator_seed = 0 ,
524
525
expected_slice = np .array ([0.64551 , 0.64453 , 0.64404 , 0.64502 , 0.64844 , 0.65039 , 0.64502 , 0.65039 , 0.65332 ]),
525
526
num_inference_steps = 1 ,
@@ -529,10 +530,10 @@ def test_marigold_intrinsics_einstein_f16_cuda_G0_S1_P512_E1_B1_M1(self):
529
530
match_input_resolution = True ,
530
531
)
531
532
532
- def test_marigold_intrinsics_einstein_f16_cuda_G0_S1_P768_E3_B1_M1 (self ):
533
+ def test_marigold_intrinsics_einstein_f16_accelerator_G0_S1_P768_E3_B1_M1 (self ):
533
534
self ._test_marigold_intrinsics (
534
535
is_fp16 = True ,
535
- device = "cuda" ,
536
+ device = torch_device ,
536
537
generator_seed = 0 ,
537
538
expected_slice = np .array ([0.61572 , 0.61377 , 0.61182 , 0.61426 , 0.61377 , 0.61426 , 0.61279 , 0.61572 , 0.62354 ]),
538
539
num_inference_steps = 1 ,
@@ -543,10 +544,10 @@ def test_marigold_intrinsics_einstein_f16_cuda_G0_S1_P768_E3_B1_M1(self):
543
544
match_input_resolution = True ,
544
545
)
545
546
546
- def test_marigold_intrinsics_einstein_f16_cuda_G0_S1_P768_E4_B2_M1 (self ):
547
+ def test_marigold_intrinsics_einstein_f16_accelerator_G0_S1_P768_E4_B2_M1 (self ):
547
548
self ._test_marigold_intrinsics (
548
549
is_fp16 = True ,
549
- device = "cuda" ,
550
+ device = torch_device ,
550
551
generator_seed = 0 ,
551
552
expected_slice = np .array ([0.61914 , 0.6167 , 0.61475 , 0.61719 , 0.61719 , 0.61768 , 0.61572 , 0.61914 , 0.62695 ]),
552
553
num_inference_steps = 1 ,
@@ -557,10 +558,10 @@ def test_marigold_intrinsics_einstein_f16_cuda_G0_S1_P768_E4_B2_M1(self):
557
558
match_input_resolution = True ,
558
559
)
559
560
560
- def test_marigold_intrinsics_einstein_f16_cuda_G0_S1_P512_E1_B1_M0 (self ):
561
+ def test_marigold_intrinsics_einstein_f16_accelerator_G0_S1_P512_E1_B1_M0 (self ):
561
562
self ._test_marigold_intrinsics (
562
563
is_fp16 = True ,
563
- device = "cuda" ,
564
+ device = torch_device ,
564
565
generator_seed = 0 ,
565
566
expected_slice = np .array ([0.65332 , 0.64697 , 0.64648 , 0.64844 , 0.64697 , 0.64111 , 0.64941 , 0.64209 , 0.65332 ]),
566
567
num_inference_steps = 1 ,
0 commit comments