Skip to content

Commit c1a573a

Browse files
committed
RoiAlign aligned=True
1 parent 7839bdb commit c1a573a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

torchvision/ops/_register_onnx_ops.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ 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:
30-
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."
33-
)
34-
scale = torch.tensor(0.5 / spatial_scale).to(dtype=torch.float)
35-
rois = g.op("Sub", rois, scale)
31+
warnings.warn("ROIAlign with aligned=True is not supported in ONNX, but will be supported in opset 16. "
32+
"The workaround is that the user need apply the patch "
33+
"https://github.com/microsoft/onnxruntime/pull/8564 "
34+
"and build ONNXRuntime from source.")
3635

3736
# ONNX doesn't support negative sampling_ratio
3837
if sampling_ratio < 0:

0 commit comments

Comments
 (0)