@@ -4728,7 +4728,9 @@ def test_kernel_video(self):
47284728 make_segmentation_mask ,
47294729 make_video ,
47304730 make_keypoints ,
4731- make_image_cvcuda ,
4731+ pytest .param (
4732+ make_image_cvcuda , marks = pytest .mark .skipif (not CVCUDA_AVAILABLE , reason = "test requires CVCUDA" )
4733+ ),
47324734 ],
47334735 )
47344736 def test_functional (self , make_input ):
@@ -4769,7 +4771,9 @@ def test_functional_signature(self, kernel, input_type):
47694771 make_segmentation_mask ,
47704772 make_video ,
47714773 make_keypoints ,
4772- make_image_cvcuda ,
4774+ pytest .param (
4775+ make_image_cvcuda , marks = pytest .mark .skipif (not CVCUDA_AVAILABLE , reason = "test requires CVCUDA" )
4776+ ),
47734777 ],
47744778 )
47754779 def test_transform (self , make_input ):
@@ -4794,26 +4798,15 @@ def test_transform_errors(self):
47944798 with pytest .raises (ValueError , match = "Padding mode should be either" ):
47954799 transforms .Pad (12 , padding_mode = "abc" )
47964800
4797- @pytest .mark .parametrize ("padding" , CORRECTNESS_PADDINGS )
47984801 @pytest .mark .parametrize (
4799- ( "padding_mode" , "fill" ) ,
4802+ "make_input" ,
48004803 [
4801- * [("constant" , fill ) for fill in CORRECTNESS_FILLS ],
4802- * [(padding_mode , None ) for padding_mode in ["symmetric" , "edge" , "reflect" ]],
4804+ make_image ,
4805+ pytest .param (
4806+ make_image_cvcuda , marks = pytest .mark .skipif (not CVCUDA_AVAILABLE , reason = "test requires CVCUDA" )
4807+ ),
48034808 ],
48044809 )
4805- @pytest .mark .parametrize ("fn" , [F .pad , transform_cls_to_functional (transforms .Pad )])
4806- def test_image_correctness (self , padding , padding_mode , fill , fn ):
4807- image = make_image (dtype = torch .uint8 , device = "cpu" )
4808-
4809- fill = adapt_fill (fill , dtype = torch .uint8 )
4810-
4811- actual = fn (image , padding = padding , padding_mode = padding_mode , fill = fill )
4812- expected = F .to_image (F .pad (F .to_pil_image (image ), padding = padding , padding_mode = padding_mode , fill = fill ))
4813-
4814- assert_equal (actual , expected )
4815-
4816- @pytest .mark .skipif (not CVCUDA_AVAILABLE , reason = "test requires CVCUDA" )
48174810 @pytest .mark .parametrize ("padding" , CORRECTNESS_PADDINGS )
48184811 @pytest .mark .parametrize (
48194812 ("padding_mode" , "fill" ),
@@ -4823,15 +4816,19 @@ def test_image_correctness(self, padding, padding_mode, fill, fn):
48234816 ],
48244817 )
48254818 @pytest .mark .parametrize ("fn" , [F .pad , transform_cls_to_functional (transforms .Pad )])
4826- def test_cvcuda_correctness (self , padding , padding_mode , fill , fn ):
4827- image = make_image_cvcuda (dtype = torch .uint8 , device = "cuda " )
4819+ def test_image_correctness (self , make_input , padding , padding_mode , fill , fn ):
4820+ image = make_input (dtype = torch .uint8 , device = "cpu " )
48284821
48294822 fill = adapt_fill (fill , dtype = torch .uint8 )
48304823
48314824 actual = fn (image , padding = padding , padding_mode = padding_mode , fill = fill )
4832- expected = F .pad (F .cvcuda_to_tensor (image ), padding = padding , padding_mode = padding_mode , fill = fill )
48334825
4834- assert_equal (F .cvcuda_to_tensor (actual ), expected )
4826+ if make_input is make_image_cvcuda :
4827+ image = cvcuda_to_pil_compatible_tensor (image )
4828+
4829+ expected = F .to_image (F .pad (F .to_pil_image (image ), padding = padding , padding_mode = padding_mode , fill = fill ))
4830+
4831+ assert_equal (actual , expected )
48354832
48364833 def _reference_pad_bounding_boxes (self , bounding_boxes , * , padding ):
48374834 if isinstance (padding , int ):
0 commit comments