"...text-generation-inference.git" did not exist on "17bc841b1be18436b32c533c8eaeacade1f45381"
Unverified Commit 1ababf90 authored by Nicolas Hug's avatar Nicolas Hug Committed by GitHub
Browse files

Add manual opcheck tests for roi ops (#8144)

parent fe0d280d
{
"_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",
"_version": 1,
"data": {
"torchvision::roi_align": {
"TestRoIAlign.test_aot_dispatch_dynamic__test_mps_error_inputs": {
"comment": "RuntimeError: MPS does not support roi_align backward with float16 inputs",
"status": "xfail"
},
"TestRoIAlign.test_autograd_registration__test_mps_error_inputs": {
"comment": "NotImplementedError: autograd_registration_check: NYI devices other than CPU/CUDA, got {'mps'}",
"status": "xfail"
}
}
}
"data": {}
}
......@@ -610,15 +610,6 @@ class TestRoIAlign(RoIOpTester):
self._helper_jit_boxes_list(model)
optests.generate_opcheck_tests(
testcase=TestRoIAlign,
namespaces=["torchvision"],
failures_dict_path=os.path.join(os.path.dirname(__file__), "optests_failures_dict.json"),
additional_decorators=[],
test_utils=OPTESTS,
)
class TestPSRoIAlign(RoIOpTester):
mps_backward_atol = 5e-2
......@@ -676,6 +667,43 @@ class TestPSRoIAlign(RoIOpTester):
self._helper_boxes_shape(ops.ps_roi_align)
@pytest.mark.parametrize(
"op",
(
torch.ops.torchvision.roi_pool,
torch.ops.torchvision.ps_roi_pool,
torch.ops.torchvision.roi_align,
torch.ops.torchvision.ps_roi_align,
),
)
@pytest.mark.parametrize("dtype", (torch.float16, torch.float32, torch.float64))
@pytest.mark.parametrize("device", cpu_and_cuda())
@pytest.mark.parametrize("requires_grad", (True, False))
def test_roi_opcheck(op, dtype, device, requires_grad):
# This manually calls opcheck() on the roi ops. We do that instead of
# relying on opcheck.generate_opcheck_tests() as e.g. done for nms, because
# pytest and generate_opcheck_tests() don't interact very well when it comes
# to skipping tests - and these ops need to skip the MPS tests since MPS we
# don't support dynamic shapes yet for MPS.
rois = torch.tensor(
[[0, 0, 0, 9, 9], [0, 0, 5, 4, 9], [0, 5, 5, 9, 9], [1, 0, 0, 9, 9]],
dtype=dtype,
device=device,
requires_grad=requires_grad,
)
pool_size = 5
num_channels = 2 * (pool_size**2)
x = torch.rand(2, num_channels, 10, 10, dtype=dtype, device=device)
kwargs = dict(rois=rois, spatial_scale=1, pooled_height=pool_size, pooled_width=pool_size)
if op in (torch.ops.torchvision.roi_align, torch.ops.torchvision.ps_roi_align):
kwargs["sampling_ratio"] = -1
if op is torch.ops.torchvision.roi_align:
kwargs["aligned"] = True
optests.opcheck(op, args=(x,), kwargs=kwargs)
class TestMultiScaleRoIAlign:
def make_obj(self, fmap_names=None, output_size=(7, 7), sampling_ratio=2, wrap=False):
if fmap_names is None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment