@@ -153,26 +153,6 @@ def xfail_jit_python_scalar_arg(name, *, reason=None):
153153 )
154154
155155
156- def xfail_jit_tuple_instead_of_list (name , * , reason = None ):
157- reason = reason or f"Passing a tuple instead of a list for `{ name } ` is not supported when scripting"
158- return xfail_jit (
159- reason or f"Passing a tuple instead of a list for `{ name } ` is not supported when scripting" ,
160- condition = lambda args_kwargs : isinstance (args_kwargs .kwargs .get (name ), tuple ),
161- )
162-
163-
164- def is_list_of_ints (args_kwargs ):
165- fill = args_kwargs .kwargs .get ("fill" )
166- return isinstance (fill , list ) and any (isinstance (scalar_fill , int ) for scalar_fill in fill )
167-
168-
169- def xfail_jit_list_of_ints (name , * , reason = None ):
170- return xfail_jit (
171- reason or f"Passing a list of integers for `{ name } ` is not supported when scripting" ,
172- condition = is_list_of_ints ,
173- )
174-
175-
176156KERNEL_INFOS = []
177157
178158
@@ -450,21 +430,21 @@ def _full_affine_params(**partial_params):
450430]
451431
452432
453- def get_fills (* , num_channels , dtype , vector = True ):
433+ def get_fills (* , num_channels , dtype ):
454434 yield None
455435
456- max_value = get_max_value (dtype )
457- # This intentionally gives us a float and an int scalar fill value
458- yield max_value / 2
459- yield max_value
436+ int_value = get_max_value (dtype )
437+ float_value = int_value / 2
438+ yield int_value
439+ yield float_value
460440
461- if not vector :
462- return
441+ for vector_type in [list , tuple ]:
442+ yield vector_type ([int_value ])
443+ yield vector_type ([float_value ])
463444
464- if dtype .is_floating_point :
465- yield [0.1 + c / 10 for c in range (num_channels )]
466- else :
467- yield [12.0 + c for c in range (num_channels )]
445+ if num_channels > 1 :
446+ yield vector_type (float_value * c / 10 for c in range (num_channels ))
447+ yield vector_type (int_value if c % 2 == 0 else 0 for c in range (num_channels ))
468448
469449
470450def float32_vs_uint8_fill_adapter (other_args , kwargs ):
@@ -644,9 +624,7 @@ def sample_inputs_affine_video():
644624 closeness_kwargs = pil_reference_pixel_difference (10 , mae = True ),
645625 test_marks = [
646626 xfail_jit_python_scalar_arg ("shear" ),
647- xfail_jit_tuple_instead_of_list ("fill" ),
648- # TODO: check if this is a regression since it seems that should be supported if `int` is ok
649- xfail_jit_list_of_ints ("fill" ),
627+ xfail_jit_python_scalar_arg ("fill" ),
650628 ],
651629 ),
652630 KernelInfo (
@@ -873,9 +851,7 @@ def sample_inputs_rotate_video():
873851 float32_vs_uint8 = True ,
874852 closeness_kwargs = pil_reference_pixel_difference (1 , mae = True ),
875853 test_marks = [
876- xfail_jit_tuple_instead_of_list ("fill" ),
877- # TODO: check if this is a regression since it seems that should be supported if `int` is ok
878- xfail_jit_list_of_ints ("fill" ),
854+ xfail_jit_python_scalar_arg ("fill" ),
879855 ],
880856 ),
881857 KernelInfo (
@@ -1122,12 +1098,14 @@ def reference_inputs_pad_image_tensor():
11221098 for image_loader , params in itertools .product (
11231099 make_image_loaders (extra_dims = [()], dtypes = [torch .uint8 ]), _PAD_PARAMS
11241100 ):
1125- # FIXME: PIL kernel doesn't support sequences of length 1 if the number of channels is larger. Shouldn't it?
11261101 for fill in get_fills (
11271102 num_channels = image_loader .num_channels ,
11281103 dtype = image_loader .dtype ,
1129- vector = params ["padding_mode" ] == "constant" ,
11301104 ):
1105+ # FIXME: PIL kernel doesn't support sequences of length 1 if the number of channels is larger. Shouldn't it?
1106+ if isinstance (fill , (list , tuple )):
1107+ continue
1108+
11311109 yield ArgsKwargs (image_loader , fill = fill , ** params )
11321110
11331111
@@ -1195,6 +1173,16 @@ def reference_inputs_pad_bounding_box():
11951173 )
11961174
11971175
1176+ def pad_xfail_jit_fill_condition (args_kwargs ):
1177+ fill = args_kwargs .kwargs .get ("fill" )
1178+ if not isinstance (fill , (list , tuple )):
1179+ return False
1180+ elif isinstance (fill , tuple ):
1181+ return True
1182+ else : # isinstance(fill, list):
1183+ return all (isinstance (f , int ) for f in fill )
1184+
1185+
11981186KERNEL_INFOS .extend (
11991187 [
12001188 KernelInfo (
@@ -1205,10 +1193,10 @@ def reference_inputs_pad_bounding_box():
12051193 float32_vs_uint8 = float32_vs_uint8_fill_adapter ,
12061194 closeness_kwargs = float32_vs_uint8_pixel_difference (),
12071195 test_marks = [
1208- xfail_jit_tuple_instead_of_list ("padding" ),
1209- xfail_jit_tuple_instead_of_list ( "fill" ),
1210- # TODO: check if this is a regression since it seems that should be supported if `int` is ok
1211- xfail_jit_list_of_ints ( "fill" ),
1196+ xfail_jit_python_scalar_arg ("padding" ),
1197+ xfail_jit (
1198+ "F.pad only supports vector fills for list of floats" , condition = pad_xfail_jit_fill_condition
1199+ ),
12121200 ],
12131201 ),
12141202 KernelInfo (
@@ -1217,7 +1205,7 @@ def reference_inputs_pad_bounding_box():
12171205 reference_fn = reference_pad_bounding_box ,
12181206 reference_inputs_fn = reference_inputs_pad_bounding_box ,
12191207 test_marks = [
1220- xfail_jit_tuple_instead_of_list ("padding" ),
1208+ xfail_jit_python_scalar_arg ("padding" ),
12211209 ],
12221210 ),
12231211 KernelInfo (
@@ -1261,8 +1249,11 @@ def reference_inputs_perspective_image_tensor():
12611249 F .InterpolationMode .BILINEAR ,
12621250 ],
12631251 ):
1264- # FIXME: PIL kernel doesn't support sequences of length 1 if the number of channels is larger. Shouldn't it?
12651252 for fill in get_fills (num_channels = image_loader .num_channels , dtype = image_loader .dtype ):
1253+ # FIXME: PIL kernel doesn't support sequences of length 1 if the number of channels is larger. Shouldn't it?
1254+ if isinstance (fill , (list , tuple )):
1255+ continue
1256+
12661257 yield ArgsKwargs (
12671258 image_loader ,
12681259 startpoints = None ,
@@ -1327,6 +1318,7 @@ def sample_inputs_perspective_video():
13271318 ** scripted_vs_eager_float64_tolerances ("cpu" , atol = 1e-5 , rtol = 1e-5 ),
13281319 ** scripted_vs_eager_float64_tolerances ("cuda" , atol = 1e-5 , rtol = 1e-5 ),
13291320 },
1321+ test_marks = [xfail_jit_python_scalar_arg ("fill" )],
13301322 ),
13311323 KernelInfo (
13321324 F .perspective_bounding_box ,
@@ -1418,6 +1410,7 @@ def sample_inputs_elastic_video():
14181410 ** float32_vs_uint8_pixel_difference (6 , mae = True ),
14191411 ** cuda_vs_cpu_pixel_difference (),
14201412 },
1413+ test_marks = [xfail_jit_python_scalar_arg ("fill" )],
14211414 ),
14221415 KernelInfo (
14231416 F .elastic_bounding_box ,
0 commit comments