-
Notifications
You must be signed in to change notification settings - Fork 874
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Construct
pylibcudf
columns from objects supporting `__cuda_array_i…
…nterface__` (#15615) This PR allows zero copy construction of `pylibcudf` columns from device arrays via the `gpumemoryview` class. cc @mroeschke Authors: - https://github.com/brandon-b-miller Approvers: - Matthew Roeschke (https://github.com/mroeschke) - Lawrence Mitchell (https://github.com/wence-) URL: #15615
- Loading branch information
1 parent
6882870
commit 4494991
Showing
3 changed files
with
162 additions
and
32 deletions.
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) |