Repository navigation
Fix dpnp.repeat with uint64 repeats above the int64 maximum - #3115
Merged
Merged
Conversation
`dpnp.tensor.repeat` checked a `uint64` repeats array for negative values before casting it to `int64`, so values above the `int64` maximum passed the check and wrapped only later. A multi-element array silently gave a wrong result and a single element raised an `OverflowError`. Cast `uint64` repeats to `int64` first so such values become negative and raise a `ValueError`. Also fix the casting rule named in the `TypeError` message, which is `same_kind`, not `safe`.
antonwolfy
requested review from
ndgrigorian and
vlad-perevezentsev
as code owners
October 19, 2026 18:45
Contributor
|
Array API standard conformance tests for dpnp=0.21.0dev15=np2py314h8d9cdd5_13 ran successfully. |
Contributor
|
View rendered docs @ https://intelpython.github.io/dpnp/pull/3115/index.html |
Collaborator
A uint64 value above the int64 maximum wraps to negative on the cast to int64, so it was reported as "must be positive" although it is positive. Since uint64 is never negative, keep the cast and the existing sign check but raise a message about the int64 maximum for uint64 repeats, so no extra kernel or host sync is needed. The message is now also the same for single- and multi-element repeats arrays.
vlad-perevezentsev
self-requested a review
October 22, 2026 07:33
vlad-perevezentsev
approved these changes
Oct 22, 2026
vlad-perevezentsev
left a comment
Contributor
There was a problem hiding this comment.
LGTM
Thank you @antonwolfy
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.
dpnp.tensor.repeat, and sodpnp.repeat, accepts auint64repeats array, but it checked the array for negative values before casting it toint64. Auint64value is never negative, so values above theint64maximum got past the check:int64, and the result was silently wronginttoo large for the output shape, which raised anOverflowErroruint64repeats are now cast toint64first, so such values become negative and raise the sameValueErroras any other negative repeat:test_repeat_arg_validationnow covers both cases, and both checks fail without the fix.