KEMBAR78
[C10] Add `Scalar::isUnsigned()` method by malfet · Pull Request #159877 · pytorch/pytorch · GitHub
Skip to content

Conversation

@malfet
Copy link
Contributor

@malfet malfet commented Aug 5, 2025

Stack from ghstack (oldest at bottom):

That returns true if Scalar hold unsigned integral value

With the implications of Tag::HAS_u semantic.

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Aug 5, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/159877

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ You can merge normally! (3 Unrelated Failures)

As of commit ffc6fea with merge base 510e8b4 (image):

UNSTABLE - The following jobs are marked as unstable, possibly due to flakiness on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

malfet added a commit that referenced this pull request Aug 5, 2025
That returns true if Scalar hold unsigned integral value

With the implications of `Tag::HAS_u` semantic.

ghstack-source-id: be8a593
Pull Request resolved: #159877
@malfet malfet requested a review from ezyang August 5, 2025 16:26
@malfet malfet added release notes: cpp release notes category topic: improvements topic category labels Aug 5, 2025
[ghstack-poisoned]
malfet added a commit that referenced this pull request Aug 5, 2025
That returns true if Scalar hold unsigned integral value

With the implications of `Tag::HAS_u` semantic.

ghstack-source-id: 4bc1669
Pull Request resolved: #159877
[ghstack-poisoned]
malfet added a commit that referenced this pull request Aug 5, 2025
That returns true if Scalar hold unsigned integral value

With the implications of `Tag::HAS_u` semantic.

ghstack-source-id: 4b6248f
Pull Request resolved: #159877
// See Note [Meaning of HAS_u]
bool isUnsigned() const {
return Tag::HAS_u == tag || (Tag::HAS_i == tag && v.i >= 0);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes this is fine. But you might want an alternative that tells you if it fits in 64-bit int or not, since that's what you are probably actually interested in when you do the IValue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's kind of my debate: should I create some sort of semantically weird is64bitUnsigned API here, or check it on the caller side. I'm leaning towards later...

@malfet
Copy link
Contributor Author

malfet commented Aug 5, 2025

@pytorchbot merge -f "This seems fine"

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@github-actions github-actions bot deleted the gh/malfet/467/head branch September 5, 2025 02:09
markc-614 pushed a commit to markc-614/pytorch that referenced this pull request Sep 17, 2025
That returns true if Scalar hold unsigned integral value

With the implications of `Tag::HAS_u` semantic.
Pull Request resolved: pytorch#159877
Approved by: https://github.com/Skylion007, https://github.com/ezyang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged release notes: cpp release notes category topic: improvements topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants