Skip to content

Commit b4ec9e4

Browse files
authored
Merge branch 'main' into aelfjnalefjnaljenf
2 parents 3657a06 + 1ababf9 commit b4ec9e4

File tree

3 files changed

+39
-22
lines changed

3 files changed

+39
-22
lines changed

test/optests_failures_dict.json

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
{
22
"_description": "This is a dict containing failures for tests autogenerated by generate_opcheck_tests. For more details, please see https://docs.google.com/document/d/1Pj5HRZvdOq3xpFpbEjUZp2hBovhy7Wnxw14m6lF2154/edit",
33
"_version": 1,
4-
"data": {
5-
"torchvision::roi_align": {
6-
"TestRoIAlign.test_aot_dispatch_dynamic__test_mps_error_inputs": {
7-
"comment": "RuntimeError: MPS does not support roi_align backward with float16 inputs",
8-
"status": "xfail"
9-
},
10-
"TestRoIAlign.test_autograd_registration__test_mps_error_inputs": {
11-
"comment": "NotImplementedError: autograd_registration_check: NYI devices other than CPU/CUDA, got {'mps'}",
12-
"status": "xfail"
13-
}
14-
}
15-
}
4+
"data": {}
165
}

test/test_datasets_video_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_video_clips_custom_fps(self, tmpdir):
6060
video_list = get_list_of_videos(tmpdir, num_videos=3, sizes=[12, 12, 12], fps=[3, 4, 6])
6161
num_frames = 4
6262
for fps in [1, 3, 4, 10]:
63-
video_clips = VideoClips(video_list, num_frames, num_frames, fps, num_workers=2)
63+
video_clips = VideoClips(video_list, num_frames, num_frames, fps)
6464
for i in range(video_clips.num_clips()):
6565
video, audio, info, video_idx = video_clips.get_clip(i)
6666
assert video.shape[0] == num_frames

test/test_ops.py

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -610,15 +610,6 @@ def test_jit_boxes_list(self):
610610
self._helper_jit_boxes_list(model)
611611

612612

613-
optests.generate_opcheck_tests(
614-
testcase=TestRoIAlign,
615-
namespaces=["torchvision"],
616-
failures_dict_path=os.path.join(os.path.dirname(__file__), "optests_failures_dict.json"),
617-
additional_decorators=[],
618-
test_utils=OPTESTS,
619-
)
620-
621-
622613
class TestPSRoIAlign(RoIOpTester):
623614
mps_backward_atol = 5e-2
624615

@@ -676,6 +667,43 @@ def test_boxes_shape(self):
676667
self._helper_boxes_shape(ops.ps_roi_align)
677668

678669

670+
@pytest.mark.parametrize(
671+
"op",
672+
(
673+
torch.ops.torchvision.roi_pool,
674+
torch.ops.torchvision.ps_roi_pool,
675+
torch.ops.torchvision.roi_align,
676+
torch.ops.torchvision.ps_roi_align,
677+
),
678+
)
679+
@pytest.mark.parametrize("dtype", (torch.float16, torch.float32, torch.float64))
680+
@pytest.mark.parametrize("device", cpu_and_cuda())
681+
@pytest.mark.parametrize("requires_grad", (True, False))
682+
def test_roi_opcheck(op, dtype, device, requires_grad):
683+
# This manually calls opcheck() on the roi ops. We do that instead of
684+
# relying on opcheck.generate_opcheck_tests() as e.g. done for nms, because
685+
# pytest and generate_opcheck_tests() don't interact very well when it comes
686+
# to skipping tests - and these ops need to skip the MPS tests since MPS we
687+
# don't support dynamic shapes yet for MPS.
688+
rois = torch.tensor(
689+
[[0, 0, 0, 9, 9], [0, 0, 5, 4, 9], [0, 5, 5, 9, 9], [1, 0, 0, 9, 9]],
690+
dtype=dtype,
691+
device=device,
692+
requires_grad=requires_grad,
693+
)
694+
pool_size = 5
695+
num_channels = 2 * (pool_size**2)
696+
x = torch.rand(2, num_channels, 10, 10, dtype=dtype, device=device)
697+
698+
kwargs = dict(rois=rois, spatial_scale=1, pooled_height=pool_size, pooled_width=pool_size)
699+
if op in (torch.ops.torchvision.roi_align, torch.ops.torchvision.ps_roi_align):
700+
kwargs["sampling_ratio"] = -1
701+
if op is torch.ops.torchvision.roi_align:
702+
kwargs["aligned"] = True
703+
704+
optests.opcheck(op, args=(x,), kwargs=kwargs)
705+
706+
679707
class TestMultiScaleRoIAlign:
680708
def make_obj(self, fmap_names=None, output_size=(7, 7), sampling_ratio=2, wrap=False):
681709
if fmap_names is None:

0 commit comments

Comments
 (0)