Skip to content

Commit 782b1d2

Browse files
committed
RoiAlign aligned=True
1 parent 972ca65 commit 782b1d2

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
@@ -25,11 +25,12 @@ def roi_align(g, input, rois, spatial_scale, pooled_height, pooled_width, sampli
2525
batch_indices = _cast_Long(g, squeeze(g, select(g, rois, 1, g.op('Constant',
2626
value_t=torch.tensor([0], dtype=torch.long))), 1), False)
2727
rois = select(g, rois, 1, g.op('Constant', value_t=torch.tensor([1, 2, 3, 4], dtype=torch.long)))
28+
# TODO: Remove this warning after ONNX opset 16 is supported.
2829
if aligned:
29-
warnings.warn("ONNX export of ROIAlign with aligned=True does not match PyTorch when using malformed boxes,"
30-
" ONNX forces ROIs to be 1x1 or larger.")
31-
scale = torch.tensor(0.5 / spatial_scale).to(dtype=torch.float)
32-
rois = g.op("Sub", rois, scale)
30+
warnings.warn("ROIAlign with aligned=True is not supported in ONNX, but will be supported in opset 16. "
31+
"The workaround is that the user need apply the patch "
32+
"https://github.com/microsoft/onnxruntime/pull/8564 "
33+
"and build ONNXRuntime from source.")
3334

3435
# ONNX doesn't support negative sampling_ratio
3536
if sampling_ratio < 0:

0 commit comments

Comments
 (0)