[torchlib] Fix torchvision::roi_align lowering to accept 7-arg schema#2830
[torchlib] Fix torchvision::roi_align lowering to accept 7-arg schema#2830FraGirla wants to merge 5 commits intomicrosoft:mainfrom
Conversation
Dynamo ONNX export calls torchvision::roi_align with (input, rois, spatial_scale, pooled_h, pooled_w, sampling_ratio, aligned), but torchlib’s torchvision_roi_align expected output_size and rejected the extra args. Update torchvision_roi_align to take pooled_h/pooled_w directly and add an OpInfo input_wrangler to adapt wrapper-style roi_align(input, boxes, output_size, ...). Refs pytorch/pytorch#175732 Test: pytest tests/function_libs/torch_lib/ops_test.py -k roi_align -v
|
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Please update the extra_opinfo file instead of creating a wrangler.
… remove redundant tests and simplify input handling
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2830 +/- ##
==========================================
- Coverage 71.78% 71.77% -0.01%
==========================================
Files 239 239
Lines 28989 28988 -1
Branches 2859 2859
==========================================
- Hits 20809 20806 -3
- Misses 7209 7210 +1
- Partials 971 972 +1 ☔ View full report in Codecov by Sentry. |
|
Still want to check when this was changed. Since it is a breaking change we need to define the function conditionally based on pytorch version. |
|
I checked versions: this fix targets the torch.export/Dynamo ONNX exporter path (torch.onnx.export(..., dynamo=True)), which is available in recent PyTorch releases (docs mention >= 2.5). The change simply aligns the torchlib lowering with the underlying operator schema for torchvision::roi_align (7 args: input, rois, spatial_scale, pooled_height, pooled_width, sampling_ratio, aligned). The operator itself has been 7-arg for a long time; what’s new is that the Dynamo ONNX exporter path now hits the operator-level call directly, while the previous torchlib lowering matched the Python wrapper signature (output_size tuple), so the mismatch only surfaced once this path got exercised more. Also fixed lintrunner issues in a follow-up commit. |
Dynamo ONNX export calls torchvision::roi_align with (input, rois, spatial_scale,
pooled_h, pooled_w, sampling_ratio, aligned), but torchlib’s lowering expected
output_size and rejected the extra args.
Update torchvision_roi_align to take pooled_h/pooled_w directly and add an OpInfo
input_wrangler to adapt wrapper-style roi_align(input, boxes, output_size, ...).
Refs pytorch/pytorch#175732
Test: pytest tests/function_libs/torch_lib/ops_test.py -k roi_align -v