Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/24625
Note: Links to docs will display an error until the docs builds have been completed.
|
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the change to preserve integer scalar precision during tensor replacement.
No open issues 🎉
What changed in this PR
This PR preserves large integer scalars in the shared ReplaceScalarWithTensorArgPass, supporting exact int64 comparisons in the related Arm backend work.
Changes:
- Pass integer scalars directly to
full, avoiding precision loss from conversion to float. - Add regression tests for exact handling of
2**53 + 1and unchanged float handling.
| File | Description |
|---|---|
backends/transforms/test/test_replace_scalar_with_tensor.py |
Tests integer precision and unchanged float scalar handling. |
backends/transforms/replace_scalar_with_tensor.py |
Preserves integer scalars when creating replacement tensors. |
Review effort: Balanced
abm-77
force-pushed
the
transforms-exact-integer-scalar
branch
from
November 5, 2026 17:14
0d33694 to
523020b
Compare
Contributor
Author
|
@pytorchbot label "release notes: none" |
This branch has not been deployed
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.
Summary
ReplaceScalarWithTensorArgPasspasses the scalar tofullthroughfloat(), which rounds an integer above 2**53. With the Arm int64 extension,x == 2**53 + 1then compares against2**53. Integer scalars now go tofullunchanged, and float scalars are unchanged.Split out of #24128 at the Arm maintainers' request. Found while adding int64 comparisons in #24622.
Test Plan
Added
test_replace_scalar_with_tensor.py: an integer scalar of 2**53 + 1 is carried exactly and a float scalar is unchanged. With #24622,x == 2**53 + 1andx > 2**53 + 1underTOSA-1.1+INT+int64match the reference model.This PR was authored with Claude Code.
cc @nil-is-all @YufengShi-dudu @Erik-Lundell