Fix incorrect dtype default in aten_full causing ONNX shape-inference errors#2926
Merged
Conversation
Copilot
AI
changed the title
[WIP] Fix bug in ONNX export of aten_full due to incorrect dtype default
Fix incorrect dtype default in aten_full causing ONNX shape-inference errors
Jun 1, 2026
justinchuby
approved these changes
Jun 1, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes aten_full’s default dtype handling in the Torch lib so that, when dtype is not specified, the fill_value’s original element type is preserved (avoiding downstream ONNX type/shape-inference mismatches such as Expand type inference errors).
Changes:
- Update
aten_full’sdtypedefault fromFLOAT.dtypeto-1(unspecified), aligning it withaten_full_like. - Rely on the existing
if dtype != -1:guard to skipCastwhen dtype is unspecified.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2926 +/- ##
=======================================
Coverage 72.64% 72.65%
=======================================
Files 259 259
Lines 31655 31655
Branches 2981 2981
=======================================
+ Hits 22997 22998 +1
Misses 7649 7649
+ Partials 1009 1008 -1 ☔ View full report in Codecov by Sentry. |
titaiwangms
approved these changes
Jun 1, 2026
xadupre
approved these changes
Jun 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
aten_fulldefaulteddtypetoFLOAT.dtype. Whenfill_valueis integral and no dtype is supplied, the value was cast to float, yielding type mismatches downstream (e.g.Expand:Inferred elem type differs from existing elem type: (1) vs (7)) and failing strict shape inference.Change
onnxscript/function_libs/torch_lib/ops/core.py: defaultdtypechanged fromFLOAT.dtypeto-1, matchingaten_full_like. The existingif dtype != -1:guard now skips the cast when dtype is unspecified, preservingfill_value's original type.With the prior default, an integral
fill_valuewith no dtype reproduced theExpandTypeInferenceError; the change resolves it while leaving the explicit-dtype path unchanged.