@@ -67,7 +67,6 @@ def test_scale_channel():
6767
6868
6969class TestRotate :
70-
7170 ALL_DTYPES = [None , torch .float32 , torch .float64 , torch .float16 ]
7271 scripted_rotate = torch .jit .script (F .rotate )
7372 IMG_W = 26
@@ -153,7 +152,6 @@ def test_rotate_interpolation_type(self):
153152
154153
155154class TestAffine :
156-
157155 ALL_DTYPES = [None , torch .float32 , torch .float64 , torch .float16 ]
158156 scripted_affine = torch .jit .script (F .affine )
159157
@@ -407,7 +405,6 @@ def _get_data_dims_and_points_for_perspective():
407405)
408406@pytest .mark .parametrize ("fn" , [F .perspective , torch .jit .script (F .perspective )])
409407def test_perspective_pil_vs_tensor (device , dims_and_points , dt , fill , fn ):
410-
411408 if dt == torch .float16 and device == "cpu" :
412409 # skip float16 on CPU case
413410 return
@@ -439,7 +436,6 @@ def test_perspective_pil_vs_tensor(device, dims_and_points, dt, fill, fn):
439436@pytest .mark .parametrize ("dims_and_points" , _get_data_dims_and_points_for_perspective ())
440437@pytest .mark .parametrize ("dt" , [None , torch .float32 , torch .float64 , torch .float16 ])
441438def test_perspective_batch (device , dims_and_points , dt ):
442-
443439 if dt == torch .float16 and device == "cpu" :
444440 # skip float16 on CPU case
445441 return
@@ -491,7 +487,6 @@ def test_perspective_interpolation_type():
491487@pytest .mark .parametrize ("max_size" , [None , 34 , 40 , 1000 ])
492488@pytest .mark .parametrize ("interpolation" , [BILINEAR , BICUBIC , NEAREST , NEAREST_EXACT ])
493489def test_resize (device , dt , size , max_size , interpolation ):
494-
495490 if dt == torch .float16 and device == "cpu" :
496491 # skip float16 on CPU case
497492 return
@@ -541,7 +536,6 @@ def test_resize(device, dt, size, max_size, interpolation):
541536
542537@pytest .mark .parametrize ("device" , cpu_and_gpu ())
543538def test_resize_asserts (device ):
544-
545539 tensor , pil_img = _create_data (26 , 36 , device = device )
546540
547541 res1 = F .resize (tensor , size = 32 , interpolation = PIL .Image .BILINEAR )
@@ -561,7 +555,6 @@ def test_resize_asserts(device):
561555@pytest .mark .parametrize ("size" , [[96 , 72 ], [96 , 420 ], [420 , 72 ]])
562556@pytest .mark .parametrize ("interpolation" , [BILINEAR , BICUBIC ])
563557def test_resize_antialias (device , dt , size , interpolation ):
564-
565558 if dt == torch .float16 and device == "cpu" :
566559 # skip float16 on CPU case
567560 return
@@ -609,23 +602,7 @@ def test_resize_antialias(device, dt, size, interpolation):
609602 assert_equal (resized_tensor , resize_result )
610603
611604
612- @needs_cuda
613- @pytest .mark .parametrize ("interpolation" , [BILINEAR , BICUBIC ])
614- def test_assert_resize_antialias (interpolation ):
615-
616- # Checks implementation on very large scales
617- # and catch TORCH_CHECK inside PyTorch implementation
618- torch .manual_seed (12 )
619- tensor , _ = _create_data (1000 , 1000 , device = "cuda" )
620-
621- # Error message is not yet updated in pytorch nightly
622- # with pytest.raises(RuntimeError, match=r"Provided interpolation parameters can not be handled"):
623- with pytest .raises (RuntimeError , match = r"Too much shared memory required" ):
624- F .resize (tensor , size = (5 , 5 ), interpolation = interpolation , antialias = True )
625-
626-
627605def test_resize_antialias_default_warning ():
628-
629606 img = torch .randint (0 , 256 , size = (3 , 44 , 56 ), dtype = torch .uint8 )
630607
631608 match = "The default value of the antialias"
@@ -641,29 +618,9 @@ def test_resize_antialias_default_warning():
641618 F .resized_crop (img , 0 , 0 , 10 , 10 , size = (20 , 20 ), interpolation = NEAREST )
642619
643620
644- @pytest .mark .parametrize ("device" , cpu_and_gpu ())
645- @pytest .mark .parametrize ("dt" , [torch .float32 , torch .float64 , torch .float16 ])
646- @pytest .mark .parametrize ("size" , [[10 , 7 ], [10 , 42 ], [42 , 7 ]])
647- @pytest .mark .parametrize ("interpolation" , [BILINEAR , BICUBIC ])
648- def test_interpolate_antialias_backward (device , dt , size , interpolation ):
649-
650- if dt == torch .float16 and device == "cpu" :
651- # skip float16 on CPU case
652- return
653-
654- torch .manual_seed (12 )
655- x = (torch .rand (1 , 32 , 29 , 3 , dtype = torch .double , device = device ).permute (0 , 3 , 1 , 2 ).requires_grad_ (True ),)
656- resize = partial (F .resize , size = size , interpolation = interpolation , antialias = True )
657- assert torch .autograd .gradcheck (resize , x , eps = 1e-8 , atol = 1e-6 , rtol = 1e-6 , fast_mode = False )
658-
659- x = (torch .rand (1 , 3 , 32 , 29 , dtype = torch .double , device = device , requires_grad = True ),)
660- assert torch .autograd .gradcheck (resize , x , eps = 1e-8 , atol = 1e-6 , rtol = 1e-6 , fast_mode = False )
661-
662-
663621def check_functional_vs_PIL_vs_scripted (
664622 fn , fn_pil , fn_t , config , device , dtype , channels = 3 , tol = 2.0 + 1e-10 , agg_method = "max"
665623):
666-
667624 script_fn = torch .jit .script (fn )
668625 torch .manual_seed (15 )
669626 tensor , pil_img = _create_data (26 , 34 , channels = channels , device = device )
@@ -1100,7 +1057,6 @@ def test_crop(device, top, left, height, width):
11001057@pytest .mark .parametrize ("sigma" , [[0.5 , 0.5 ], (0.5 , 0.5 ), (0.8 , 0.8 ), (1.7 , 1.7 )])
11011058@pytest .mark .parametrize ("fn" , [F .gaussian_blur , torch .jit .script (F .gaussian_blur )])
11021059def test_gaussian_blur (device , image_size , dt , ksize , sigma , fn ):
1103-
11041060 # true_cv2_results = {
11051061 # # np_img = np.arange(3 * 10 * 12, dtype="uint8").reshape((10, 12, 3))
11061062 # # cv2.GaussianBlur(np_img, ksize=(3, 3), sigmaX=0.8)
0 commit comments