Skip to content

[torchlib] Add aten::upsample_linear1d.vec - #3166

Merged
Justin Chu (justinchuby) merged 1 commit into
microsoft:mainfrom
kyunggeunlee:torchlib-upsample-linear1d-vec
Nov 6, 2026
Merged

Justin Chu (justinchuby) merged 1 commit into
microsoft:mainfrom
kyunggeunlee:torchlib-upsample-linear1d-vec

Conversation

@kyunggeunlee

Copy link
Copy Markdown
Contributor

resolves #3165

Summary

Adds the missing aten::upsample_linear1d.vec overload to torchlib. aten::upsample_linear1d was already implemented, but the .vec overload, upsample_linear1d.vec(Tensor input, SymInt[]? output_size, bool align_corners, float[]? scale_factors), was not.

Changes

  • onnxscript/function_libs/torch_lib/ops/nn.py: add aten_upsample_linear1d_vec. It mirrors aten_upsample_bilinear2d_vec:
    • If scale_factors is given, it resizes via _aten_upsample_scales.
    • Otherwise it resizes via _aten_upsample_output_size, which requires output_size.
    • Both paths use mode="linear", with align_corners mapped to align_corners / half_pixel through _get_upsample_align_corners_mode.
  • tests/function_libs/torch_lib/extra_opinfo.py: add sample_inputs_upsample_linear1d_vec and the ops.aten.upsample_linear1d.vec OpInfo. Samples cover output sizes 3, 1 and 5, and scale_factors of [1.7], [0.6] and [4.2], each with align_corners both True and False.
  • tests/function_libs/torch_lib/ops_test_data.py: register ops.aten.upsample_linear1d.vec.

Testing

pytest tests/function_libs/torch_lib/ops_test.py -k upsample_linear1d
  • ops.aten.upsample_linear1d.vec output-match test passes on all samples, including align_corners=False with scale_factors. No xfail is needed.
  • The existing non-vec ops.aten.upsample_linear1d test is unchanged. It passes, and its known align_corners=False with scales xfail still applies.
  • The test_script_function_passes_checker tests are skipped for both ops, because trace-only functions have no function proto.

🤖 Generated with Claude Code

Add a conversion rule for the .vec overload of upsample_linear1d, mirroring
upsample_bilinear2d.vec, along with sample inputs, an OpInfo and a test entry.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Kyunggeun Lee <kyunggeu@qti.qualcomm.com>
@kyunggeunlee

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="Qualcomm"

@justinchuby
Justin Chu (justinchuby) requested a balanced review from Copilot November 6, 2026 22:18

@justinchuby Justin Chu (justinchuby) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks

@github-project-automation github-project-automation Bot moved this from Todo to Done in ONNX Script Review Board Nov 6, 2026
@justinchuby
Justin Chu (justinchuby) enabled auto-merge (squash) November 6, 2026 22:19
@justinchuby Justin Chu (justinchuby) added the module: torchlib Related to the torch/aten function lib in development label Nov 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The upsample lowering rounds double-precision scale factors to float32, which can produce incorrect output lengths; it needs to preserve ATen-computed lengths, including for dynamic inputs, and add a rounding-boundary regression test.

1 open issue
What changed in this PR

Adds torchlib support for aten::upsample_linear1d.vec, addressing #3165 by providing a direct ONNX Resize lowering instead of relying on decomposition during export.

Changes:

  • Handles scale factors and explicit output sizes using existing resize helpers.
  • Adds samples covering upsampling, downsampling, singleton outputs, and both corner-alignment modes.
  • Registers the overload in the operator test suite.
File Description
tests/​function_libs/​torch_lib/​ops_test_data.py Registers the new overload for testing.
tests/​function_libs/​torch_lib/​extra_opinfo.py Adds sample inputs and the overload’s OpInfo.
onnxscript/​function_libs/​torch_lib/​ops/​nn.py Implements the trace-only linear1d vector overload.

Review effort: Balanced

@codecov

codecov Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.35%. Comparing base (5b210da) to head (e9872a1).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3166   +/-   ##
=======================================
  Coverage   73.34%   73.35%           
=======================================
  Files         269      269           
  Lines       33564    33571    +7     
  Branches     3210     3211    +1     
=======================================
+ Hits        24618    24625    +7     
  Misses       7876     7876           
  Partials     1070     1070           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@justinchuby
Justin Chu (justinchuby) merged commit 97749eb into microsoft:main Nov 6, 2026
29 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: torchlib Related to the torch/aten function lib in development

Projects

Development

Successfully merging this pull request may close these issues.

[torchlib] aten::upsample_linear1d.vec is not supported

3 participants