Skip to content
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

Migrate copy_column and Column.from_scalar to pylibcudf #17513

Merged
merged 3 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions python/cudf/cudf/_lib/column.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ cimport pylibcudf.libcudf.types as libcudf_types
cimport pylibcudf.libcudf.unary as libcudf_unary
from pylibcudf.libcudf.column.column cimport column, column_contents
from pylibcudf.libcudf.column.column_factories cimport (
make_column_from_scalar as cpp_make_column_from_scalar,
make_numeric_column,
make_numeric_column
)
from pylibcudf.libcudf.column.column_view cimport column_view
from pylibcudf.libcudf.null_mask cimport null_count as cpp_null_count
Expand Down Expand Up @@ -840,9 +839,8 @@ cdef class Column:

@staticmethod
def from_scalar(py_val, size_type size):
cdef DeviceScalar val = py_val.device_value
cdef const scalar* c_val = val.get_raw_ptr()
cdef unique_ptr[column] c_result
with nogil:
c_result = move(cpp_make_column_from_scalar(c_val[0], size))
return Column.from_unique_ptr(move(c_result))
return Column.from_pylibcudf(
pylibcudf.Column.from_scalar(
py_val.device_value.c_value, size
)
)
15 changes: 3 additions & 12 deletions python/cudf/cudf/_lib/copying.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import pickle

from libcpp cimport bool
from libcpp.memory cimport unique_ptr
from libcpp.utility cimport move
import pylibcudf

import cudf
Expand All @@ -18,10 +16,6 @@ from cudf._lib.scalar cimport DeviceScalar

from cudf._lib.reduce import minmax

from libcpp.memory cimport make_unique

from pylibcudf.libcudf.column.column cimport column
from pylibcudf.libcudf.column.column_view cimport column_view
from pylibcudf.libcudf.types cimport size_type

from cudf._lib.utils cimport columns_from_pylibcudf_table, data_from_pylibcudf_table
Expand Down Expand Up @@ -59,12 +53,9 @@ def copy_column(Column input_column):
-------
Deep copied column
"""
cdef unique_ptr[column] c_result
cdef column_view input_column_view = input_column.view()
with nogil:
c_result = move(make_unique[column](input_column_view))

return Column.from_unique_ptr(move(c_result))
return Column.from_pylibcudf(
input_column.to_pylibcudf(mode="read").copy()
)


@acquire_spill_lock()
Expand Down
Loading