Fix missing strides validation in dpnp.tensor.usm_ndarray#2927
Draft
vlad-perevezentsev wants to merge 3 commits into
Draft
Fix missing strides validation in dpnp.tensor.usm_ndarray#2927vlad-perevezentsev wants to merge 3 commits into
dpnp.tensor.usm_ndarray#2927vlad-perevezentsev wants to merge 3 commits into
Conversation
Contributor
|
View rendered docs @ https://intelpython.github.io/dpnp/pull/2927/index.html |
Contributor
|
Array API standard conformance tests for dpnp=0.21.0dev0=py313h509198e_44 ran successfully. |
ndgrigorian
reviewed
May 20, 2026
Comment on lines
+384
to
+386
| "strides={} result in a negative memory displacement " | ||
| "and are not allowed when allocating new " | ||
| "memory".format(strides)) |
Collaborator
There was a problem hiding this comment.
Suggested change
| "strides={} result in a negative memory displacement " | |
| "and are not allowed when allocating new " | |
| "memory".format(strides)) | |
| f"strides={strides} result in a negative memory displacement " | |
| "and are not allowed when allocating new " | |
| "memory" |
ndgrigorian
reviewed
May 20, 2026
Comment on lines
+392
to
+394
| "strides={} is incompatible with shape={} when " | ||
| "allocating new memory because the memory footprint " | ||
| "exceeds the number of elements".format(strides, shape)) |
Collaborator
There was a problem hiding this comment.
Suggested change
| "strides={} is incompatible with shape={} when " | |
| "allocating new memory because the memory footprint " | |
| "exceeds the number of elements".format(strides, shape)) | |
| f"strides={strides} is incompatible with shape={shape} when " | |
| "allocating new memory because the memory footprint " | |
| "exceeds the number of elements" |
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.
This PR proposes to fix #2881 issue.
The problem was that
usm_ndarrayconstructor did not validate user-provided strides when allocating new memory.This made it possible to create arrays with invalid stride patterns producing negative memory displacement or oversized memory footprints.
This PR adds validation for invalid stride configurations when allocating new memory and raises
ValueErrorfor unsupported strides.It also adds a new
test_ctor_invalid_stridesintest_usm_ndarray_ctor.pyto cover these cases