Repository navigation
[torchlib] Add aten::upsample_linear1d.vec - #3166
Justin Chu (justinchuby) merged 1 commit into
Conversation
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>
|
@microsoft-github-policy-service agree company="Qualcomm" |
Justin Chu (justinchuby)
left a comment
There was a problem hiding this comment.
Thanks
There was a problem hiding this comment.
🟡 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 Report✅ All modified and coverable lines are covered by tests. 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. |
97749eb
into
microsoft:main

resolves #3165
Summary
Adds the missing
aten::upsample_linear1d.vecoverload to torchlib.aten::upsample_linear1dwas already implemented, but the.vecoverload,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: addaten_upsample_linear1d_vec. It mirrorsaten_upsample_bilinear2d_vec:scale_factorsis given, it resizes via_aten_upsample_scales._aten_upsample_output_size, which requiresoutput_size.mode="linear", withalign_cornersmapped toalign_corners/half_pixelthrough_get_upsample_align_corners_mode.tests/function_libs/torch_lib/extra_opinfo.py: addsample_inputs_upsample_linear1d_vecand theops.aten.upsample_linear1d.vecOpInfo. Samples cover output sizes 3, 1 and 5, andscale_factorsof[1.7],[0.6]and[4.2], each withalign_cornersboth True and False.tests/function_libs/torch_lib/ops_test_data.py: registerops.aten.upsample_linear1d.vec.Testing
ops.aten.upsample_linear1d.vecoutput-match test passes on all samples, includingalign_corners=Falsewithscale_factors. No xfail is needed.ops.aten.upsample_linear1dtest is unchanged. It passes, and its knownalign_corners=Falsewithscalesxfail still applies.test_script_function_passes_checkertests are skipped for both ops, because trace-only functions have no function proto.🤖 Generated with Claude Code