@@ -153,26 +153,6 @@ def xfail_jit_python_scalar_arg(name, *, reason=None):
153
153
)
154
154
155
155
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
-
176
156
KERNEL_INFOS = []
177
157
178
158
@@ -450,21 +430,21 @@ def _full_affine_params(**partial_params):
450
430
]
451
431
452
432
453
- def get_fills (* , num_channels , dtype , vector = True ):
433
+ def get_fills (* , num_channels , dtype ):
454
434
yield None
455
435
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
460
440
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 ])
463
444
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 ))
468
448
469
449
470
450
def float32_vs_uint8_fill_adapter (other_args , kwargs ):
@@ -644,9 +624,7 @@ def sample_inputs_affine_video():
644
624
closeness_kwargs = pil_reference_pixel_difference (10 , mae = True ),
645
625
test_marks = [
646
626
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" ),
650
628
],
651
629
),
652
630
KernelInfo (
@@ -873,9 +851,7 @@ def sample_inputs_rotate_video():
873
851
float32_vs_uint8 = True ,
874
852
closeness_kwargs = pil_reference_pixel_difference (1 , mae = True ),
875
853
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" ),
879
855
],
880
856
),
881
857
KernelInfo (
@@ -1122,12 +1098,14 @@ def reference_inputs_pad_image_tensor():
1122
1098
for image_loader , params in itertools .product (
1123
1099
make_image_loaders (extra_dims = [()], dtypes = [torch .uint8 ]), _PAD_PARAMS
1124
1100
):
1125
- # FIXME: PIL kernel doesn't support sequences of length 1 if the number of channels is larger. Shouldn't it?
1126
1101
for fill in get_fills (
1127
1102
num_channels = image_loader .num_channels ,
1128
1103
dtype = image_loader .dtype ,
1129
- vector = params ["padding_mode" ] == "constant" ,
1130
1104
):
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
+
1131
1109
yield ArgsKwargs (image_loader , fill = fill , ** params )
1132
1110
1133
1111
@@ -1195,6 +1173,16 @@ def reference_inputs_pad_bounding_box():
1195
1173
)
1196
1174
1197
1175
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
+
1198
1186
KERNEL_INFOS .extend (
1199
1187
[
1200
1188
KernelInfo (
@@ -1205,10 +1193,10 @@ def reference_inputs_pad_bounding_box():
1205
1193
float32_vs_uint8 = float32_vs_uint8_fill_adapter ,
1206
1194
closeness_kwargs = float32_vs_uint8_pixel_difference (),
1207
1195
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
+ ),
1212
1200
],
1213
1201
),
1214
1202
KernelInfo (
@@ -1217,7 +1205,7 @@ def reference_inputs_pad_bounding_box():
1217
1205
reference_fn = reference_pad_bounding_box ,
1218
1206
reference_inputs_fn = reference_inputs_pad_bounding_box ,
1219
1207
test_marks = [
1220
- xfail_jit_tuple_instead_of_list ("padding" ),
1208
+ xfail_jit_python_scalar_arg ("padding" ),
1221
1209
],
1222
1210
),
1223
1211
KernelInfo (
@@ -1261,8 +1249,11 @@ def reference_inputs_perspective_image_tensor():
1261
1249
F .InterpolationMode .BILINEAR ,
1262
1250
],
1263
1251
):
1264
- # FIXME: PIL kernel doesn't support sequences of length 1 if the number of channels is larger. Shouldn't it?
1265
1252
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
+
1266
1257
yield ArgsKwargs (
1267
1258
image_loader ,
1268
1259
startpoints = None ,
@@ -1327,6 +1318,7 @@ def sample_inputs_perspective_video():
1327
1318
** scripted_vs_eager_float64_tolerances ("cpu" , atol = 1e-5 , rtol = 1e-5 ),
1328
1319
** scripted_vs_eager_float64_tolerances ("cuda" , atol = 1e-5 , rtol = 1e-5 ),
1329
1320
},
1321
+ test_marks = [xfail_jit_python_scalar_arg ("fill" )],
1330
1322
),
1331
1323
KernelInfo (
1332
1324
F .perspective_bounding_box ,
@@ -1418,6 +1410,7 @@ def sample_inputs_elastic_video():
1418
1410
** float32_vs_uint8_pixel_difference (6 , mae = True ),
1419
1411
** cuda_vs_cpu_pixel_difference (),
1420
1412
},
1413
+ test_marks = [xfail_jit_python_scalar_arg ("fill" )],
1421
1414
),
1422
1415
KernelInfo (
1423
1416
F .elastic_bounding_box ,
0 commit comments