Repository navigation
CUDA: Use relaxed strides checking to compute contiguity - #6830
Merged
Merged
Conversation
Since NumPy 1.8, a relaxed strides check has been available for computing the contiguity of arrays (and the relaxed check is the default starting from 1.12). The relaxed check permits additional conditions for arrays to be considered contiguous: - All 0-size arrays are considered contiguous, even if they are multidimensional. - Strides for an axis are ignored if its shape is 1 when checking contiguity. Examples of shapes and strides that would now be considered contiguous: - Shape: (1, 10), Strides: (800, 80): because the first axis has size 1. - Shape: (1, 0, 2), Strides (64, 16, 8): because the second axis has size 0. This commit makes relaxed strides checking the default when computing the C- and F-contiguity of device arrays, and enables more use cases. For example, from the reproducer in Issue numba#6824: ```python import dask.array as da import numpy as np from numba import guvectorize x = da.arange(10000, dtype=np.float64).reshape(100, 100).rechunk((1, 10)) f = np.ascontiguousarray(x.blocks[0, 0]) ``` `f` is an array that is only contiguous under relaxed strides checking, and prior to this commit could not be transferred to a device array. Since this may expose latent bugs (the switch in NumPy exposed some issues between versions 1.10.0 and 1.10.2, for example), a config variable, `NPY_RELAXED_STRIDES_CHECKING` is provided to restore the old, strict checking. This is provided on a temporary basis in case any bugs need to be worked out, and will be removed in 0.55 in the current deprecation schedule. Fixes numba#6824. Fixes numba#4943. Fixes numba#2766.
2 tasks done
stuartarchibald
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the patch and for working on a fix for this issue. In general it seems good, just a few minor comments/queries to look at. Thanks again!
Member
Author
|
@stuartarchibald Many thanks for the review - comments addressed / responded to! |
stuartarchibald
approved these changes
Mar 17, 2021
stuartarchibald
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the fixes.
Contributor
|
Buildfarm ID: |
Contributor
Passed. |
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.
Since NumPy 1.8, a relaxed strides check has been available for computing the contiguity of arrays (and the relaxed check is the default starting from 1.12). The relaxed check permits additional conditions for arrays to be considered contiguous:
Examples of shapes and strides that would now be considered contiguous:
This PR makes relaxed strides checking the default when computing the C- and F-contiguity of device arrays, and enables more use cases. For example, from the reproducer in Issue #6824:
fis an array that is only contiguous under relaxed strides checking, and prior to this commit could not be transferred to a device array.Since this may expose latent bugs (the switch in NumPy exposed some issues between versions 1.10.0 and 1.10.2, for example), a config variable,
NPY_RELAXED_STRIDES_CHECKINGis provided to restore the old, strict checking. This is provided on a temporary basis in case any bugs need to be worked out, and will be removed in 0.55 in the current deprecation schedule.Fixes #6824.
Fixes #4943.
Fixes #2766.