Skip to content

[torchlib] Fix torchvision::roi_align lowering to accept 7-arg schema#2830

Open
FraGirla wants to merge 5 commits intomicrosoft:mainfrom
FraGirla:fix-torch-roi-align
Open

[torchlib] Fix torchvision::roi_align lowering to accept 7-arg schema#2830
FraGirla wants to merge 5 commits intomicrosoft:mainfrom
FraGirla:fix-torch-roi-align

Conversation

@FraGirla
Copy link

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

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
@FraGirla
Copy link
Author

@microsoft-github-policy-service agree

@justinchuby justinchuby self-assigned this Feb 25, 2026
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the extra_opinfo file instead of creating a wrangler.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in the last commits

@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.77%. Comparing base (ef2bc22) to head (d1cb271).

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.
📢 Have feedback on the report? Share it here.

@justinchuby
Copy link
Collaborator

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.

@FraGirla
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants