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

Remove cudf._lib.scalar in favor of pylibcudf #17701

Merged
merged 20 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b40e595
start migrating devicescalar logic to scalar.py
mroeschke Dec 31, 2024
aad6984
Merge remote-tracking branch 'upstream/branch-25.02' into rm/scalar/d…
mroeschke Jan 3, 2025
700dcef
Move over device to host scalar code, and gather_metadata
mroeschke Jan 4, 2025
1209f08
Merge remote-tracking branch 'upstream/branch-25.02' into rm/scalar/d…
mroeschke Jan 7, 2025
eba1936
remove DeviceScalar usage
mroeschke Jan 7, 2025
cf7968d
Merge remote-tracking branch 'upstream/branch-25.02' into rm/scalar/d…
mroeschke Jan 7, 2025
83f2c43
fix some bug tests
mroeschke Jan 8, 2025
a5ae666
Merge remote-tracking branch 'upstream/branch-25.02' into rm/scalar/d…
mroeschke Jan 8, 2025
4ffc5ae
Fix some tests
mroeschke Jan 8, 2025
16e6ef2
Merge remote-tracking branch 'upstream/branch-25.02' into rm/scalar/d…
mroeschke Jan 8, 2025
5e294e8
Fix more struct tests
mroeschke Jan 9, 2025
0cca875
Remove cudf._lib.scalar
mroeschke Jan 9, 2025
644f8db
Merge remote-tracking branch 'upstream/branch-25.02' into rm/scalar/d…
mroeschke Jan 9, 2025
9fbe28f
Run pre-commit verify-copyright
mroeschke Jan 9, 2025
133256b
Merge remote-tracking branch 'upstream/branch-25.02' into rm/scalar/d…
mroeschke Jan 9, 2025
76ca634
Merge remote-tracking branch 'upstream/branch-25.02' into rm/scalar/d…
mroeschke Jan 10, 2025
99f171c
Fix scalar element indexing with new scalar return
mroeschke Jan 10, 2025
dac3305
Merge remote-tracking branch 'upstream/branch-25.02' into rm/scalar/d…
mroeschke Jan 17, 2025
d146229
Rename from_device_scalar to from_pylibcudf
mroeschke Jan 17, 2025
8472cf8
Add back test_struct_scalar_null
mroeschke Jan 17, 2025
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
2 changes: 1 addition & 1 deletion python/cudf/cudf/_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# the License.
# =============================================================================

set(cython_sources column.pyx scalar.pyx strings_udf.pyx)
set(cython_sources column.pyx strings_udf.pyx)
set(linked_libraries cudf::cudf)

rapids_cython_create_modules(
Expand Down
18 changes: 9 additions & 9 deletions python/cudf/cudf/_lib/column.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ from libcpp.vector cimport vector

from rmm.pylibrmm.device_buffer cimport DeviceBuffer

from pylibcudf cimport DataType as plc_DataType, Column as plc_Column
from pylibcudf cimport (
DataType as plc_DataType,
Column as plc_Column,
Scalar as plc_Scalar,
)
cimport pylibcudf.libcudf.copying as cpp_copying
cimport pylibcudf.libcudf.types as libcudf_types
cimport pylibcudf.libcudf.unary as libcudf_unary
Expand All @@ -46,8 +50,6 @@ from pylibcudf.libcudf.lists.lists_column_view cimport lists_column_view
from pylibcudf.libcudf.null_mask cimport null_count as cpp_null_count
from pylibcudf.libcudf.scalar.scalar cimport scalar

from cudf._lib.scalar cimport DeviceScalar


cdef get_element(column_view col_view, size_type index):

Expand All @@ -56,10 +58,8 @@ cdef get_element(column_view col_view, size_type index):
c_output = move(
cpp_copying.get_element(col_view, index)
)

return DeviceScalar.from_unique_ptr(
move(c_output), dtype=dtype_from_column_view(col_view)
)
plc_scalar = plc_Scalar.from_libcudf(move(c_output))
return pylibcudf.interop.to_arrow(plc_scalar).as_py()


def dtype_from_pylibcudf_column(plc_Column col not None):
Expand Down Expand Up @@ -772,7 +772,7 @@ cdef class Column:
base_nbytes = 0
else:
chars_size = get_element(
offset_child_column, offset_child_column.size()-1).value
offset_child_column, offset_child_column.size()-1)
base_nbytes = chars_size

if data_ptr:
Expand Down Expand Up @@ -913,6 +913,6 @@ cdef class Column:
def from_scalar(py_val, size_type size):
return Column.from_pylibcudf(
pylibcudf.Column.from_scalar(
py_val.device_value.c_value, size
py_val.device_value, size
)
)
22 changes: 0 additions & 22 deletions python/cudf/cudf/_lib/scalar.pxd

This file was deleted.

243 changes: 0 additions & 243 deletions python/cudf/cudf/_lib/scalar.pyx

This file was deleted.

4 changes: 3 additions & 1 deletion python/cudf/cudf/api/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import pyarrow as pa
from pandas.api import types as pd_types

import pylibcudf as plc

import cudf
from cudf.core._compat import PANDAS_LT_300
from cudf.core.dtypes import ( # noqa: F401
Expand Down Expand Up @@ -143,8 +145,8 @@ def is_scalar(val):
val,
(
cudf.Scalar,
cudf._lib.scalar.DeviceScalar,
cudf.core.tools.datetimes.DateOffset,
plc.Scalar,
pa.Scalar,
),
) or (
Expand Down
4 changes: 2 additions & 2 deletions python/cudf/cudf/core/_internals/binaryop.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ def binaryop(
plc.binaryop.binary_operation(
lhs.to_pylibcudf(mode="read")
if isinstance(lhs, Column)
else lhs.device_value.c_value,
else lhs.device_value,
rhs.to_pylibcudf(mode="read")
if isinstance(rhs, Column)
else rhs.device_value.c_value,
else rhs.device_value,
plc.binaryop.BinaryOperator[op],
dtype_to_pylibcudf_type(dtype),
)
Expand Down
4 changes: 2 additions & 2 deletions python/cudf/cudf/core/_internals/copying.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2024, NVIDIA CORPORATION.
# Copyright (c) 2020-2025, NVIDIA CORPORATION.
from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down Expand Up @@ -67,7 +67,7 @@ def scatter(
plc_tbl = plc.copying.scatter(
plc.Table([col.to_pylibcudf(mode="read") for col in sources]) # type: ignore[union-attr]
if isinstance(sources[0], cudf._lib.column.Column)
else [slr.device_value.c_value for slr in sources], # type: ignore[union-attr]
else [slr.device_value for slr in sources], # type: ignore[union-attr]
scatter_map.to_pylibcudf(mode="read"),
plc.Table([col.to_pylibcudf(mode="read") for col in target_columns]),
)
Expand Down
Loading
Loading