3333    UNet2DConditionModel ,
3434)
3535from  diffusers .utils .testing_utils  import  (
36+     backend_empty_cache ,
3637    enable_full_determinism ,
3738    floats_tensor ,
3839    load_image ,
39-     require_torch_gpu ,
40+     require_torch_accelerator ,
4041    slow ,
4142    torch_device ,
4243)
@@ -395,17 +396,17 @@ def test_marigold_depth_dummy_no_processing_resolution(self):
395396
396397
397398@slow  
398- @require_torch_gpu  
399+ @require_torch_accelerator  
399400class  MarigoldIntrinsicsPipelineIntegrationTests (unittest .TestCase ):
400401    def  setUp (self ):
401402        super ().setUp ()
402403        gc .collect ()
403-         torch . cuda . empty_cache ( )
404+         backend_empty_cache ( torch_device )
404405
405406    def  tearDown (self ):
406407        super ().tearDown ()
407408        gc .collect ()
408-         torch . cuda . empty_cache ( )
409+         backend_empty_cache ( torch_device )
409410
410411    def  _test_marigold_intrinsics (
411412        self ,
@@ -424,7 +425,7 @@ def _test_marigold_intrinsics(
424425            from_pretrained_kwargs ["torch_dtype" ] =  torch .float16 
425426
426427        pipe  =  MarigoldIntrinsicsPipeline .from_pretrained (model_id , ** from_pretrained_kwargs )
427-         if  device  ==   "cuda" :
428+         if  device  in  [ "cuda" ,  "xpu" ] :
428429            pipe .enable_model_cpu_offload ()
429430        pipe .set_progress_bar_config (disable = None )
430431
@@ -464,10 +465,10 @@ def test_marigold_intrinsics_einstein_f32_cpu_G0_S1_P32_E1_B1_M1(self):
464465            match_input_resolution = True ,
465466        )
466467
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 ):
468469        self ._test_marigold_intrinsics (
469470            is_fp16 = False ,
470-             device = "cuda" ,
471+             device = torch_device ,
471472            generator_seed = 0 ,
472473            expected_slice = np .array ([0.62127 , 0.61906 , 0.61687 , 0.61946 , 0.61903 , 0.61961 , 0.61808 , 0.62099 , 0.62894 ]),
473474            num_inference_steps = 1 ,
@@ -477,10 +478,10 @@ def test_marigold_intrinsics_einstein_f32_cuda_G0_S1_P768_E1_B1_M1(self):
477478            match_input_resolution = True ,
478479        )
479480
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 ):
481482        self ._test_marigold_intrinsics (
482483            is_fp16 = True ,
483-             device = "cuda" ,
484+             device = torch_device ,
484485            generator_seed = 0 ,
485486            expected_slice = np .array ([0.62109 , 0.61914 , 0.61719 , 0.61963 , 0.61914 , 0.61963 , 0.61816 , 0.62109 , 0.62891 ]),
486487            num_inference_steps = 1 ,
@@ -490,10 +491,10 @@ def test_marigold_intrinsics_einstein_f16_cuda_G0_S1_P768_E1_B1_M1(self):
490491            match_input_resolution = True ,
491492        )
492493
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 ):
494495        self ._test_marigold_intrinsics (
495496            is_fp16 = True ,
496-             device = "cuda" ,
497+             device = torch_device ,
497498            generator_seed = 2024 ,
498499            expected_slice = np .array ([0.64111 , 0.63916 , 0.63623 , 0.63965 , 0.63916 , 0.63965 , 0.6377 , 0.64062 , 0.64941 ]),
499500            num_inference_steps = 1 ,
@@ -503,10 +504,10 @@ def test_marigold_intrinsics_einstein_f16_cuda_G2024_S1_P768_E1_B1_M1(self):
503504            match_input_resolution = True ,
504505        )
505506
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 ):
507508        self ._test_marigold_intrinsics (
508509            is_fp16 = True ,
509-             device = "cuda" ,
510+             device = torch_device ,
510511            generator_seed = 0 ,
511512            expected_slice = np .array ([0.60254 , 0.60059 , 0.59961 , 0.60156 , 0.60107 , 0.60205 , 0.60254 , 0.60449 , 0.61133 ]),
512513            num_inference_steps = 2 ,
@@ -516,10 +517,10 @@ def test_marigold_intrinsics_einstein_f16_cuda_G0_S2_P768_E1_B1_M1(self):
516517            match_input_resolution = True ,
517518        )
518519
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 ):
520521        self ._test_marigold_intrinsics (
521522            is_fp16 = True ,
522-             device = "cuda" ,
523+             device = torch_device ,
523524            generator_seed = 0 ,
524525            expected_slice = np .array ([0.64551 , 0.64453 , 0.64404 , 0.64502 , 0.64844 , 0.65039 , 0.64502 , 0.65039 , 0.65332 ]),
525526            num_inference_steps = 1 ,
@@ -529,10 +530,10 @@ def test_marigold_intrinsics_einstein_f16_cuda_G0_S1_P512_E1_B1_M1(self):
529530            match_input_resolution = True ,
530531        )
531532
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 ):
533534        self ._test_marigold_intrinsics (
534535            is_fp16 = True ,
535-             device = "cuda" ,
536+             device = torch_device ,
536537            generator_seed = 0 ,
537538            expected_slice = np .array ([0.61572 , 0.61377 , 0.61182 , 0.61426 , 0.61377 , 0.61426 , 0.61279 , 0.61572 , 0.62354 ]),
538539            num_inference_steps = 1 ,
@@ -543,10 +544,10 @@ def test_marigold_intrinsics_einstein_f16_cuda_G0_S1_P768_E3_B1_M1(self):
543544            match_input_resolution = True ,
544545        )
545546
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 ):
547548        self ._test_marigold_intrinsics (
548549            is_fp16 = True ,
549-             device = "cuda" ,
550+             device = torch_device ,
550551            generator_seed = 0 ,
551552            expected_slice = np .array ([0.61914 , 0.6167 , 0.61475 , 0.61719 , 0.61719 , 0.61768 , 0.61572 , 0.61914 , 0.62695 ]),
552553            num_inference_steps = 1 ,
@@ -557,10 +558,10 @@ def test_marigold_intrinsics_einstein_f16_cuda_G0_S1_P768_E4_B2_M1(self):
557558            match_input_resolution = True ,
558559        )
559560
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 ):
561562        self ._test_marigold_intrinsics (
562563            is_fp16 = True ,
563-             device = "cuda" ,
564+             device = torch_device ,
564565            generator_seed = 0 ,
565566            expected_slice = np .array ([0.65332 , 0.64697 , 0.64648 , 0.64844 , 0.64697 , 0.64111 , 0.64941 , 0.64209 , 0.65332 ]),
566567            num_inference_steps = 1 ,
0 commit comments