{{ message }}
PR: Add allow_copy flag to interchange protocol#44
Closed
steff456 wants to merge 3 commits into
Closed
Conversation
Member
allow_copy flag to interchange protocol
Member
Adding the following to the requirements docs: |
8 tasks
rgommers
reviewed
Aug 23, 2021
|
|
||
| ``allow_copy`` is a keyword that defines if the given implementation | ||
| is going to support striding buffers. It is optional, and the libraries | ||
| do not need to implement it. |
Member
There was a problem hiding this comment.
Rephrasing this a bit:
``allow_copy`` is a keyword that defines whether or not the library is
allowed to make a copy of the data. This can for example happen if a
library supports strided buffers (those would need a copy, because this
protocol specifies contiguous buffers).
|
|
||
| ``allow_copy`` is a keyword that defines if the given implementation | ||
| is going to support striding buffers. It is optional, and the libraries | ||
| do not need to implement it. Currently, if the flag is set to ``True`` it |
Member
There was a problem hiding this comment.
This removes the actual check for striding (not x.strides == (x.dtype.itemsize,):), that needs to be put back.
Member
There was a problem hiding this comment.
Logic:
if not x.strides == (x.dtype.itemsize,):
# The protocol does not support strided buffers, so a copy is
# necessary. If that's not allowed, we need to raise an exception.
if allow_copy:
x = x.copy()
else:
raise RuntimeError("Exports cannot be zero-copy in the case "
"of a non-contiguous buffer")
Member
There was a problem hiding this comment.
And then adding a test case shows there's a problem - we don't hold on to the memory.
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 adds a flag to throw an exception if the export cannot be zero-copy. (e.g. for pandas, possible due to block manager where rows are contiguous and columns are not) .
allow_zero_copyflag to the DataFrame class.RuntimeErrorwhen it is truetest_noncontiguous_columns