@@ -6149,7 +6149,18 @@ def test_kernel_image(self, dtype, device):
61496149 def test_kernel_video (self ):
61506150 check_kernel (F .adjust_hue_video , make_video (), hue_factor = 0.25 )
61516151
6152- @pytest .mark .parametrize ("make_input" , [make_image_tensor , make_image , make_image_pil , make_video ])
6152+ @pytest .mark .parametrize (
6153+ "make_input" ,
6154+ [
6155+ make_image_tensor ,
6156+ make_image ,
6157+ make_image_pil ,
6158+ make_video ,
6159+ pytest .param (
6160+ make_image_cvcuda , marks = pytest .mark .skipif (not CVCUDA_AVAILABLE , reason = "CVCUDA not available" )
6161+ ),
6162+ ],
6163+ )
61536164 def test_functional (self , make_input ):
61546165 check_functional (F .adjust_hue , make_input (), hue_factor = 0.25 )
61556166
@@ -6160,9 +6171,16 @@ def test_functional(self, make_input):
61606171 (F ._color ._adjust_hue_image_pil , PIL .Image .Image ),
61616172 (F .adjust_hue_image , tv_tensors .Image ),
61626173 (F .adjust_hue_video , tv_tensors .Video ),
6174+ pytest .param (
6175+ F ._color ._adjust_hue_cvcuda ,
6176+ "cvcuda.Tensor" ,
6177+ marks = pytest .mark .skipif (not CVCUDA_AVAILABLE , reason = "CVCUDA not available" ),
6178+ ),
61636179 ],
61646180 )
61656181 def test_functional_signature (self , kernel , input_type ):
6182+ if input_type == "cvcuda.Tensor" :
6183+ input_type = _import_cvcuda ().Tensor
61666184 check_functional_kernel_signature_match (F .adjust_hue , kernel = kernel , input_type = input_type )
61676185
61686186 def test_functional_error (self ):
@@ -6173,11 +6191,27 @@ def test_functional_error(self):
61736191 with pytest .raises (ValueError , match = re .escape ("is not in [-0.5, 0.5]" )):
61746192 F .adjust_hue (make_image (), hue_factor = hue_factor )
61756193
6194+ @pytest .mark .parametrize (
6195+ "make_input" ,
6196+ [
6197+ make_image ,
6198+ pytest .param (
6199+ make_image_cvcuda , marks = pytest .mark .skipif (not CVCUDA_AVAILABLE , reason = "CVCUDA not available" )
6200+ ),
6201+ ],
6202+ )
61766203 @pytest .mark .parametrize ("hue_factor" , [- 0.5 , - 0.3 , 0.0 , 0.2 , 0.5 ])
6177- def test_correctness_image (self , hue_factor ):
6178- image = make_image (dtype = torch .uint8 , device = "cpu" )
6204+ def test_correctness_image (self , make_input , hue_factor ):
6205+ image = make_input (dtype = torch .uint8 , device = "cpu" )
61796206
61806207 actual = F .adjust_hue (image , hue_factor = hue_factor )
6208+
6209+ if make_input is make_image_cvcuda :
6210+ actual = F .cvcuda_to_tensor (actual ).to (device = "cpu" )
6211+ actual = actual .squeeze (0 )
6212+ image = F .cvcuda_to_tensor (image )
6213+ image = image .squeeze (0 )
6214+
61816215 expected = F .to_image (F .adjust_hue (F .to_pil_image (image ), hue_factor = hue_factor ))
61826216
61836217 mae = (actual .float () - expected .float ()).abs ().mean ()
0 commit comments