Use std::in_range for integer range checking#179400
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/179400
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 New Failures, 9 Unrelated Failures, 8 Unclassified FailuresAs of commit 27907b0 with merge base b9a2479 ( NEW FAILURES - The following jobs have failed:
UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
BROKEN TRUNK - The following jobs failed but was present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
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. |
Attention! PyTorch one of the C-stable API file was changedYou MUST NOT change existing function declarations in this, as this header defines a stable C ABI. If you need to change the signature for a function, introduce a new v2 version of the function and modify code generation to target the new version of the function. Resolved |
Skylion007
left a comment
There was a problem hiding this comment.
So the reason this is useful is removing that possibility of accidental implicit casts when reading the doc and it's therefore safer. You should update the PR description to reflect that.
Skylion007
left a comment
There was a problem hiding this comment.
Not sure about the stable API stuff
|
Yeah, I am not sure either. I believe @janeyx99 will be able to check if this makes sense or should be reverted. |
96c22f6 to
81764b7
Compare
1b511df to
76b2297
Compare
76b2297 to
cf1a505
Compare
|
@pytorchmergebot merge |
|
This PR has pending changes requested. Please address the comments and update the PR before merging. |
|
@Skylion007 can you please re-review? I have reverted the changes related to stable API |
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
|
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
|
Rebase failed due to Command Raised by https://github.com/pytorch/pytorch/actions/runs/26020550472 |
|
@pytorchbot merge -i |
C++20 provides [`std::in_range`](https://en.cppreference.com/w/cpp/utility/in_range.html) which allows checking if an integer value can fit in a given integer type. This PR replaces such checks with in_range. std::in_range is safer than direct comparisons because it avoids implicit casts. The call sites to update were obtained by grepping for `"numeric_limits.*min"`. PyTorch supports C++20 now pytorch#176662 I have also proposed a clang-tidy checker to take care of this automatically going forward llvm/llvm-project#190665 Pull Request resolved: pytorch#179400 Approved by: https://github.com/janeyx99
C++20 provides [`std::in_range`](https://en.cppreference.com/w/cpp/utility/in_range.html) which allows checking if an integer value can fit in a given integer type. This PR replaces such checks with in_range. std::in_range is safer than direct comparisons because it avoids implicit casts. The call sites to update were obtained by grepping for `"numeric_limits.*min"`. PyTorch supports C++20 now pytorch#176662 I have also proposed a clang-tidy checker to take care of this automatically going forward llvm/llvm-project#190665 Pull Request resolved: pytorch#179400 Approved by: https://github.com/janeyx99
|
@claude review if this PR caused following failures: https://github.com/pytorch/pytorch/actions/runs/26198707681/job/77106554779 |
|
Claude finished @atalman's task in 49s —— View job CI Failure Diagnosis for PR #179400
Root CauseThis is the same issue that caused the original revert. The fix was not applied before re-merging. At std::in_range<int8_t>(device_index),
FixRevert line 309 in STD_TORCH_CHECK(
device_index >= std::numeric_limits<int8_t>::min() &&
device_index <= std::numeric_limits<int8_t>::max(),
"Device index is out of range of return type int8_t, please use get_device_index() instead.");The rest of the TL;DR: The |
|
@pytorchmergebot revert -c nosignal -m "Broke nightly builds. Please test with ciflow/binaries when remerging" |
|
@pytorchbot successfully started a revert job. Check the current status here. |
|
@lakshayg your PR has been successfully reverted. |
This reverts commit d7e3761. Reverted #179400 on behalf of https://github.com/atalman due to Broke nightly builds. Please test with ciflow/binaries when remerging ([comment](#179400 (comment)))
|
@pytorchmergebot rebase |
|
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
|
Rebase failed due to Raised by https://github.com/pytorch/pytorch/actions/runs/26299810141 |
5a92e3d to
dba62d8
Compare
C++20 provides
std::in_rangewhich allows checkingif an integer value can fit in a given integer type. This PR
replaces such checks with in_range.
std::in_range is safer than direct comparisons
because it avoids implicit casts.
The call sites to update were obtained by grepping
for
"numeric_limits.*min".PyTorch supports C++20 now #176662
I have also proposed a clang-tidy checker to take
care of this automatically going forward llvm/llvm-project#190665