-
Notifications
You must be signed in to change notification settings - Fork 890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Construct pylibcudf
columns from objects supporting __cuda_array_interface__
#15615
Merged
rapids-bot
merged 10 commits into
rapidsai:branch-24.06
from
brandon-b-miller:pylibcudf-col-from-cuda-iface
May 2, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4b55227
initial
brandon-b-miller ea9f9b5
cleanup
brandon-b-miller 5805a0e
Apply suggestions from code review
brandon-b-miller 37cfb75
Merge branch 'branch-24.06' into pylibcudf-col-from-cuda-iface
brandon-b-miller 2a86b37
cache dtype lookup
brandon-b-miller 3a50093
fix bool test
brandon-b-miller 52715d2
do not module scope fixtures unnecessarily
brandon-b-miller 7312c73
raise if mask is populated but not if interface is missing
brandon-b-miller d5b6ba8
Merge branch 'branch-24.06' into pylibcudf-col-from-cuda-iface
brandon-b-miller 0736605
move is_c_contiguous and use it
brandon-b-miller File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
51 changes: 51 additions & 0 deletions
51
python/cudf/cudf/pylibcudf_tests/test_column_from_device.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION. | ||
|
||
import pyarrow as pa | ||
import pytest | ||
from utils import assert_column_eq | ||
|
||
import cudf | ||
from cudf._lib import pylibcudf as plc | ||
|
||
VALID_TYPES = [ | ||
pa.int8(), | ||
pa.int16(), | ||
pa.int32(), | ||
pa.int64(), | ||
pa.uint8(), | ||
pa.uint16(), | ||
pa.uint32(), | ||
pa.uint64(), | ||
pa.float32(), | ||
pa.float64(), | ||
pa.bool_(), | ||
pa.timestamp("s"), | ||
pa.timestamp("ms"), | ||
pa.timestamp("us"), | ||
pa.timestamp("ns"), | ||
pa.duration("s"), | ||
pa.duration("ms"), | ||
pa.duration("us"), | ||
pa.duration("ns"), | ||
] | ||
|
||
|
||
@pytest.fixture(params=VALID_TYPES, ids=repr) | ||
def valid_type(request): | ||
return request.param | ||
|
||
|
||
@pytest.fixture | ||
def valid_column(valid_type): | ||
if valid_type == pa.bool_(): | ||
return pa.array([True, False, True], type=valid_type) | ||
return pa.array([1, 2, 3], type=valid_type) | ||
|
||
|
||
def test_from_cuda_array_interface(valid_column): | ||
col = plc.column.Column.from_cuda_array_interface_obj( | ||
cudf.Series(valid_column) | ||
) | ||
expect = valid_column | ||
|
||
assert_column_eq(col, expect) |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: Someone needs to check that the object being described is one-dimensional and contiguous. So we should probably:
And also assert that strides are appropriate (either
None
or(1,)
I think?)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We implemented something similar for buffer here, but it's in the cuDF python namespace. Would it be overkill to move the impl to a cython utility we can consume from both places?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because we need to check here too, otherwise we're potentially producing a nonsense result.