@@ -1240,6 +1240,10 @@ def test_kernel_video(self):
12401240 make_image_tensor ,
12411241 make_image_pil ,
12421242 make_image ,
1243+ pytest .param (
1244+ make_image_cvcuda ,
1245+ marks = pytest .mark .skipif (not CVCUDA_AVAILABLE , reason = "CVCUDA is not available" ),
1246+ ),
12431247 make_bounding_boxes ,
12441248 make_segmentation_mask ,
12451249 make_video ,
@@ -1255,13 +1259,20 @@ def test_functional(self, make_input):
12551259 (F .horizontal_flip_image , torch .Tensor ),
12561260 (F ._geometry ._horizontal_flip_image_pil , PIL .Image .Image ),
12571261 (F .horizontal_flip_image , tv_tensors .Image ),
1262+ pytest .param (
1263+ F ._geometry ._horizontal_flip_image_cvcuda ,
1264+ None ,
1265+ marks = pytest .mark .skipif (not CVCUDA_AVAILABLE , reason = "CVCUDA is not available" ),
1266+ ),
12581267 (F .horizontal_flip_bounding_boxes , tv_tensors .BoundingBoxes ),
12591268 (F .horizontal_flip_mask , tv_tensors .Mask ),
12601269 (F .horizontal_flip_video , tv_tensors .Video ),
12611270 (F .horizontal_flip_keypoints , tv_tensors .KeyPoints ),
12621271 ],
12631272 )
12641273 def test_functional_signature (self , kernel , input_type ):
1274+ if kernel is F ._geometry ._horizontal_flip_image_cvcuda :
1275+ input_type = _import_cvcuda ().Tensor
12651276 check_functional_kernel_signature_match (F .horizontal_flip , kernel = kernel , input_type = input_type )
12661277
12671278 @pytest .mark .parametrize (
@@ -1270,6 +1281,10 @@ def test_functional_signature(self, kernel, input_type):
12701281 make_image_tensor ,
12711282 make_image_pil ,
12721283 make_image ,
1284+ pytest .param (
1285+ make_image_cvcuda ,
1286+ marks = pytest .mark .skipif (not CVCUDA_AVAILABLE , reason = "CVCUDA is not available" ),
1287+ ),
12731288 make_bounding_boxes ,
12741289 make_segmentation_mask ,
12751290 make_video ,
@@ -1283,13 +1298,23 @@ def test_transform(self, make_input, device):
12831298 @pytest .mark .parametrize (
12841299 "fn" , [F .horizontal_flip , transform_cls_to_functional (transforms .RandomHorizontalFlip , p = 1 )]
12851300 )
1286- def test_image_correctness (self , fn ):
1287- image = make_image (dtype = torch .uint8 , device = "cpu" )
1288-
1301+ @pytest .mark .parametrize (
1302+ "make_input" ,
1303+ [
1304+ make_image ,
1305+ pytest .param (
1306+ make_image_cvcuda ,
1307+ marks = pytest .mark .skipif (not CVCUDA_AVAILABLE , reason = "CVCUDA is not available" ),
1308+ ),
1309+ ],
1310+ )
1311+ def test_image_correctness (self , fn , make_input ):
1312+ image = make_input ()
12891313 actual = fn (image )
1290- expected = F .to_image (F .horizontal_flip (F .to_pil_image (image )))
1291-
1292- torch .testing .assert_close (actual , expected )
1314+ if make_input is make_image_cvcuda :
1315+ image = F .cvcuda_to_tensor (image )[0 ].cpu ()
1316+ expected = F .horizontal_flip (F .to_pil_image (image ))
1317+ assert_equal (actual , expected )
12931318
12941319 def _reference_horizontal_flip_bounding_boxes (self , bounding_boxes : tv_tensors .BoundingBoxes ):
12951320 affine_matrix = np .array (
@@ -1345,6 +1370,10 @@ def test_keypoints_correctness(self, fn):
13451370 make_image_tensor ,
13461371 make_image_pil ,
13471372 make_image ,
1373+ pytest .param (
1374+ make_image_cvcuda ,
1375+ marks = pytest .mark .skipif (not CVCUDA_AVAILABLE , reason = "CVCUDA is not available" ),
1376+ ),
13481377 make_bounding_boxes ,
13491378 make_segmentation_mask ,
13501379 make_video ,
@@ -1354,11 +1383,8 @@ def test_keypoints_correctness(self, fn):
13541383 @pytest .mark .parametrize ("device" , cpu_and_cuda ())
13551384 def test_transform_noop (self , make_input , device ):
13561385 input = make_input (device = device )
1357-
13581386 transform = transforms .RandomHorizontalFlip (p = 0 )
1359-
13601387 output = transform (input )
1361-
13621388 assert_equal (output , input )
13631389
13641390
@@ -1856,6 +1882,10 @@ def test_kernel_video(self):
18561882 make_image_tensor ,
18571883 make_image_pil ,
18581884 make_image ,
1885+ pytest .param (
1886+ make_image_cvcuda ,
1887+ marks = pytest .mark .skipif (not CVCUDA_AVAILABLE , reason = "CVCUDA is not available" ),
1888+ ),
18591889 make_bounding_boxes ,
18601890 make_segmentation_mask ,
18611891 make_video ,
@@ -1871,13 +1901,20 @@ def test_functional(self, make_input):
18711901 (F .vertical_flip_image , torch .Tensor ),
18721902 (F ._geometry ._vertical_flip_image_pil , PIL .Image .Image ),
18731903 (F .vertical_flip_image , tv_tensors .Image ),
1904+ pytest .param (
1905+ F ._geometry ._vertical_flip_image_cvcuda ,
1906+ None ,
1907+ marks = pytest .mark .skipif (not CVCUDA_AVAILABLE , reason = "CVCUDA is not available" ),
1908+ ),
18741909 (F .vertical_flip_bounding_boxes , tv_tensors .BoundingBoxes ),
18751910 (F .vertical_flip_mask , tv_tensors .Mask ),
18761911 (F .vertical_flip_video , tv_tensors .Video ),
18771912 (F .vertical_flip_keypoints , tv_tensors .KeyPoints ),
18781913 ],
18791914 )
18801915 def test_functional_signature (self , kernel , input_type ):
1916+ if kernel is F ._geometry ._vertical_flip_image_cvcuda :
1917+ input_type = _import_cvcuda ().Tensor
18811918 check_functional_kernel_signature_match (F .vertical_flip , kernel = kernel , input_type = input_type )
18821919
18831920 @pytest .mark .parametrize (
@@ -1886,6 +1923,10 @@ def test_functional_signature(self, kernel, input_type):
18861923 make_image_tensor ,
18871924 make_image_pil ,
18881925 make_image ,
1926+ pytest .param (
1927+ make_image_cvcuda ,
1928+ marks = pytest .mark .skipif (not CVCUDA_AVAILABLE , reason = "CVCUDA is not available" ),
1929+ ),
18891930 make_bounding_boxes ,
18901931 make_segmentation_mask ,
18911932 make_video ,
@@ -1897,13 +1938,23 @@ def test_transform(self, make_input, device):
18971938 check_transform (transforms .RandomVerticalFlip (p = 1 ), make_input (device = device ))
18981939
18991940 @pytest .mark .parametrize ("fn" , [F .vertical_flip , transform_cls_to_functional (transforms .RandomVerticalFlip , p = 1 )])
1900- def test_image_correctness (self , fn ):
1901- image = make_image (dtype = torch .uint8 , device = "cpu" )
1902-
1941+ @pytest .mark .parametrize (
1942+ "make_input" ,
1943+ [
1944+ make_image ,
1945+ pytest .param (
1946+ make_image_cvcuda ,
1947+ marks = pytest .mark .skipif (not CVCUDA_AVAILABLE , reason = "CVCUDA is not available" ),
1948+ ),
1949+ ],
1950+ )
1951+ def test_image_correctness (self , fn , make_input ):
1952+ image = make_input ()
19031953 actual = fn (image )
1904- expected = F .to_image (F .vertical_flip (F .to_pil_image (image )))
1905-
1906- torch .testing .assert_close (actual , expected )
1954+ if make_input is make_image_cvcuda :
1955+ image = F .cvcuda_to_tensor (image )[0 ].cpu ()
1956+ expected = F .vertical_flip (F .to_pil_image (image ))
1957+ assert_equal (actual , expected )
19071958
19081959 def _reference_vertical_flip_bounding_boxes (self , bounding_boxes : tv_tensors .BoundingBoxes ):
19091960 affine_matrix = np .array (
@@ -1955,6 +2006,10 @@ def test_keypoints_correctness(self, fn):
19552006 make_image_tensor ,
19562007 make_image_pil ,
19572008 make_image ,
2009+ pytest .param (
2010+ make_image_cvcuda ,
2011+ marks = pytest .mark .skipif (not CVCUDA_AVAILABLE , reason = "CVCUDA is not available" ),
2012+ ),
19582013 make_bounding_boxes ,
19592014 make_segmentation_mask ,
19602015 make_video ,
@@ -1964,11 +2019,8 @@ def test_keypoints_correctness(self, fn):
19642019 @pytest .mark .parametrize ("device" , cpu_and_cuda ())
19652020 def test_transform_noop (self , make_input , device ):
19662021 input = make_input (device = device )
1967-
19682022 transform = transforms .RandomVerticalFlip (p = 0 )
1969-
19702023 output = transform (input )
1971-
19722024 assert_equal (output , input )
19732025
19742026
0 commit comments