Skip to content

Commit 1bd69d2

Browse files
Vincent Moensfacebook-github-bot
authored andcommitted
[fbsync] RoiAlign aligned=True (#4692)
Summary: Co-authored-by: Prabhat Roy <[email protected]> Reviewed By: NicolasHug Differential Revision: D31957853 fbshipit-source-id: 5054da13eb08732c0702cc684a9b065b70fd2917
1 parent 790a3b2 commit 1bd69d2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

torchvision/ops/_register_onnx_ops.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ def roi_align(g, input, rois, spatial_scale, pooled_height, pooled_width, sampli
2626
g, squeeze(g, select(g, rois, 1, g.op("Constant", value_t=torch.tensor([0], dtype=torch.long))), 1), False
2727
)
2828
rois = select(g, rois, 1, g.op("Constant", value_t=torch.tensor([1, 2, 3, 4], dtype=torch.long)))
29+
# TODO: Remove this warning after ONNX opset 16 is supported.
2930
if aligned:
3031
warnings.warn(
31-
"ONNX export of ROIAlign with aligned=True does not match PyTorch when using malformed boxes,"
32-
" ONNX forces ROIs to be 1x1 or larger."
32+
"ROIAlign with aligned=True is not supported in ONNX, but will be supported in opset 16. "
33+
"The workaround is that the user need apply the patch "
34+
"https://github.com/microsoft/onnxruntime/pull/8564 "
35+
"and build ONNXRuntime from source."
3336
)
34-
scale = torch.tensor(0.5 / spatial_scale).to(dtype=torch.float)
35-
rois = g.op("Sub", rois, scale)
3637

3738
# ONNX doesn't support negative sampling_ratio
3839
if sampling_ratio < 0:

0 commit comments

Comments
 (0)